LCOV - code coverage report
Current view: top level - EnergyPlus - RefrigeratedCase.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 19.0 % 8317 1580
Test Date: 2025-06-02 12:03:30 Functions: 31.7 % 41 13

            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       248598 : 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       248598 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     344              : 
     345       248598 :     if (!state.dataRefrigCase->ManageRefrigeration) {
     346       248593 :         return;
     347              :     }
     348              : 
     349            5 :     CheckRefrigerationInput(state);
     350              : 
     351            5 :     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            5 :     if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->UseSysTimeStep)) {
     358              :         // Zero requests for cooling water from plant or tank
     359            0 :         ZeroHVACValues(state);
     360            0 :         return;
     361              :     }
     362              :     // Following case should never occur, but just for completeness:
     363            5 :     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            5 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->MyEnvrnFlag) {
     369            0 :         state.dataRefrigCase->MyEnvrnFlag = false;
     370            0 :         return;
     371              :     }
     372            5 :     if (!state.dataGlobal->BeginEnvrnFlag) {
     373            5 :         state.dataRefrigCase->MyEnvrnFlag = true;
     374              :     }
     375              : 
     376            5 :     if (state.dataRefrigCase->HaveRefrigRacks) {
     377           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
     378            5 :             RefrigRack(RackNum).CalcRackSystem(state);
     379            5 :             RefrigRack(RackNum).ReportRackSystem(state, RackNum);
     380              :         }
     381              :     }
     382              : 
     383            5 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
     384            0 :         SimulateDetailedRefrigerationSystems(state);
     385              :     }
     386            5 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
     387            0 :         SimulateDetailedTransRefrigSystems(state);
     388              :     }
     389              : }
     390              : 
     391          150 : 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          150 :     int constexpr NumWIAlphaFieldsBeforeZoneInput(9);   // Used to cycle through zones on input for walk in coolers
     416          150 :     int constexpr NumWIAlphaFieldsPerZone(4);           // Used to cycle through zones on input for walk in coolers
     417          150 :     int constexpr NumWINumberFieldsBeforeZoneInput(12); // Used to cycle through zones on input for walk in coolers
     418          150 :     int constexpr NumWINumberFieldsPerZone(8);          // Used to cycle through zones on input for walk in coolers
     419          150 :     Real64 constexpr CondARI460DelT(16.7);              // Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
     420          150 :     Real64 constexpr CondARI460Tcond(51.7);             // Rated sat cond temp for air-cooled cond, ARI 460
     421          150 :     Real64 constexpr CondARI490DelT(15.0);              // Rated sat cond temp - wet bulb air T for evap-cooled Cond w R22, ARI490
     422          150 :     Real64 constexpr CondARI490Tcond(40.6);             // Rated sat cond temp for evap-cooled cond with R22, ARI 490
     423          150 :     Real64 constexpr DelEvapTDefault(5.0);              // default difference between case T and evap T (C)
     424          150 :     Real64 constexpr DefaultCascadeCondApproach(3.0);   // Cascade condenser approach temperature difference (deltaC)
     425          150 :     Real64 constexpr DefaultCircRate(2.5);              // Phase change liquid overfeed circulating rate (ASHRAE definition)
     426          150 :     Real64 constexpr DefaultWISurfaceUValue(0.3154);    // equiv R18 in Archaic American units (W/m2-delta T)
     427          150 :     Real64 constexpr DefaultWIUValueGlassDr(1.136);     // equiv R5 in Archaic American units (W/m2-delta T)
     428          150 :     Real64 constexpr DefaultWIUValueStockDr(0.3785);    // equiv R15 in Archaic American units (W/m2-delta T)
     429          150 :     Real64 constexpr DefaultWIHeightGlassDr(1.5);       // glass door height in walk-in cooler (m)
     430          150 :     Real64 constexpr DefaultWIHeightStockDr(3.0);       // stock door height in walk-in cooler (m)
     431          150 :     Real64 constexpr PumpImpellerEfficiency(0.78);      // same as used in pump auto-sizing, dimensionless
     432          150 :     Real64 constexpr PumpMotorEfficiency(0.85);         // suggested as average value in ITT/Gould pump references,
     433              : 
     434          150 :     Array1D_string Alphas;             // Alpha items for object
     435          150 :     Array1D_string cAlphaFieldNames;   // Alpha field names (from input processor)
     436          150 :     Array1D_string cNumericFieldNames; // Numeric field names (from input processor)
     437          150 :     std::string CurrentModuleObject;   // Object type for getting and error messages
     438              : 
     439          150 :     Array1D_bool lAlphaBlanks;   // Logic array, alpha input blank = .TRUE.
     440          150 :     Array1D_bool lNumericBlanks; // Logic array, numeric input blank = .TRUE.
     441          150 :     bool ErrorsFound(false);     // Set to true if errors in input, fatal at end of routine
     442              : 
     443          150 :     int AlphaNum(0);                       // Used to cycle through input
     444          150 :     int IOStatus(0);                       // Used in GetObjectItem
     445          150 :     int MaxNumAlphasRack(0);               // Maximum number of alphas for rack object
     446          150 :     int MaxNumAlphasAirChiller(0);         // Maximum number of alphas for air chiller
     447          150 :     int MaxNumAlphasAll(0);                // Maximum number of alphas for all objects
     448          150 :     int MaxNumAlphasSys(0);                // Maximum number of alphas for system object
     449          150 :     int MaxNumAlphasTransSys(0);           // Maximum number of alphas for transcritical system object
     450          150 :     int MaxNumAlphasChillerSet(0);         // Maximum number of alphas for chiller set
     451          150 :     int MaxNumAlphasConda(0);              // Maximum number of alphas for air-cooled condenser object
     452          150 :     int MaxNumAlphasConde(0);              // Maximum number of alphas for evap-cooled condenser object
     453          150 :     int MaxNumAlphasCondw(0);              // Maximum number of alphas for water-cooled condenser object
     454          150 :     int MaxNumAlphasGasCoolera(0);         // Maximum number of alphas for air-cooled gas cooler object
     455          150 :     int MaxNumAlphasComp(0);               // Maximum number of alphas for compressor object
     456          150 :     int MaxNumAlphasCompressorList(0);     // Maximum number of alphas for compressor list objects
     457          150 :     int MaxNumAlphasCase(0);               // Maximum number of alphas for case object
     458          150 :     int MaxNumAlphasCaseAndWalkInList(0);  // Maximum number of alphas in CaseAndWalkInList
     459          150 :     int MaxNumAlphasWalkIn(0);             // Maximum number of alphas for walkin object
     460          150 :     int MaxNumAlphasSecond(0);             // Maximum number of alphas for air chiller object
     461          150 :     int MaxNumNumbersAirChiller(0);        // Maximum number of numbers for air chiller object
     462          150 :     int MaxNumNumbersSecond(0);            // Maximum number of numbers for secondary system object
     463          150 :     int MaxNumNumbersWalkIn(0);            // Maximum number of numbers for walkin object
     464          150 :     int MaxNumNumbersCase(0);              // Maximum number of numbers for case object
     465          150 :     int MaxNumNumbersCaseAndWalkInList(0); // Maximum number of numbers in CaseAndWalkInList
     466          150 :     int MaxNumNumbersRack(0);              // Maximum number of numbers for rack object
     467          150 :     int MaxNumNumbersAll(0);               // Maximum number of numeric inputs for all objects
     468          150 :     int MaxNumNumbersSys(0);               // Maximum number of numbers for system object
     469          150 :     int MaxNumNumbersTransSys(0);          // Maximum number of numbers for transcritical system object
     470          150 :     int MaxNumNumbersChillerSet(0);        // Maximum number of numbers for chiller set object
     471          150 :     int MaxNumNumbersConda(0);             // Maximum number of numbers for air-cooled condenser object
     472          150 :     int MaxNumNumbersConde(0);             // Maximum number of numbers for evap-cooled condenser object
     473          150 :     int MaxNumNumbersCondw(0);             // Maximum number of numbers for water-cooled condenser object
     474          150 :     int MaxNumNumbersGasCoolera(0);        // Maximum number of numbers for air-cooled gas cooler object
     475          150 :     int MaxNumNumbersComp(0);              // Maximum number of numbers for compressor object
     476          150 :     int MaxNumNumbersCompressorList(0);    // Maximum number of numbers
     477          150 :     int MaxNumArgs(0);                     // Max number of alphas and numbers (arguments) for rack object
     478          150 :     int NumAlphas(0);                      // Number of Alphas for each GetObjectItem call
     479          150 :     int NumCases(0);                       // Number of refrigerated cases for single system
     480          150 :     int NumNum(0);                         // Used to cycle through input
     481          150 :     int NumNumbers(0);                     // Number of Numbers for each GetObjectItem call
     482          150 :     int NumDisplayCases(0);                // Counter for refrigerated cases in GetInput do loop
     483          150 :     int NumWalkIns(0);                     // Number of walk ins
     484          150 :     int RefrigSysNum(0);
     485          150 :     int RefrigIndex(0);                // Index used in fluid property routines
     486          150 :     Real64 DeltaHPhaseChange(0.0);     // Secondary loop enthalpy change in condenser w overfeed system (J/g)
     487          150 :     Real64 DelTempMin(0.0);            // min temperature for heat rej curve for air cooled condenser (C)
     488          150 :     Real64 DelTempMax(0.0);            // max temperature for heat rej curve for air cooled condenser (C)
     489          150 :     Real64 DensityBrineRated(0.0);     // density of circ fluid in secondary loop
     490          150 :     Real64 DensityPhaseChange(0.0);    // Secondary loop density at condensing temperature w overfeed system (g/m3)
     491          150 :     Real64 NominalTotalCompCapLP(0.0); // Total of nominal low pressure compressor capacities, used for rough input check (W) (Transcritical CO2)
     492          150 :     Real64 NominalTotalCompCapHP(0.0);
     493          150 :     Array1D<Real64> Numbers;   // Numeric items for object
     494          150 :     Array2D<Real64> DayValues; // Array of schedule values
     495              : 
     496          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
     497          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     498          150 :     auto &CaseRAFraction = state.dataRefrigCase->CaseRAFraction;
     499          150 :     auto &System = state.dataRefrigCase->System;
     500          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
     501          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
     502          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
     503          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
     504          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
     505          150 :     auto &CaseAndWalkInList = state.dataRefrigCase->CaseAndWalkInList;
     506          150 :     auto &CompressorLists = state.dataRefrigCase->CompressorLists;
     507          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
     508          150 :     auto &TransferLoadList = state.dataRefrigCase->TransferLoadList;
     509          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
     510          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
     511          150 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
     512          150 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
     513          150 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
     514              : 
     515          300 :     state.dataRefrigCase->NumSimulationCascadeCondensers =
     516          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:Cascade");
     517          150 :     state.dataRefrigCase->NumSimulationCases = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Case");
     518          300 :     state.dataRefrigCase->NumSimulationCaseAndWalkInLists =
     519          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CaseAndWalkInList");
     520          150 :     state.dataRefrigCase->NumRefrigeratedRacks = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorRack");
     521          300 :     state.dataRefrigCase->NumSimulationSecondarySystems =
     522          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:SecondarySystem");
     523          300 :     state.dataRefrigCase->NumSimulationTransferLoadLists =
     524          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TransferLoadList");
     525          150 :     state.dataRefrigCase->NumSimulationWalkIns = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:WalkIn");
     526          150 :     state.dataRefrigCase->NumRefrigSystems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:System");
     527          300 :     state.dataRefrigCase->NumTransRefrigSystems =
     528          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TranscriticalSystem");
     529          300 :     state.dataRefrigCase->NumSimulationCondAir =
     530          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:AirCooled");
     531          300 :     state.dataRefrigCase->NumSimulationCondEvap =
     532          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:EvaporativeCooled");
     533          300 :     state.dataRefrigCase->NumSimulationCondWater =
     534          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:WaterCooled");
     535          300 :     state.dataRefrigCase->NumSimulationGasCooler =
     536          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:GasCooler:AirCooled");
     537          150 :     state.dataRefrigCase->NumRefrigCondensers = state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
     538          150 :                                                 state.dataRefrigCase->NumSimulationCondWater + state.dataRefrigCase->NumSimulationCascadeCondensers;
     539          150 :     state.dataRefrigCase->NumSimulationCompressors = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Compressor");
     540          150 :     state.dataRefrigCase->NumSimulationSubcoolers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Subcooler");
     541          150 :     int NumCompressorLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorList");
     542          300 :     state.dataRefrigCase->NumRefrigChillerSets =
     543          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneHVAC:RefrigerationChillerSet");
     544          300 :     state.dataRefrigCase->NumSimulationRefrigAirChillers =
     545          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:AirChiller");
     546              : 
     547              :     // Set flags used later to avoid unnecessary steps.
     548          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks == 0) {
     549          145 :         state.dataRefrigCase->HaveRefrigRacks = false;
     550              :     }
     551          150 :     if (state.dataRefrigCase->NumRefrigSystems == 0) {
     552          150 :         state.dataRefrigCase->HaveDetailedRefrig = false;
     553              :     }
     554          150 :     if (state.dataRefrigCase->NumTransRefrigSystems == 0) {
     555          150 :         state.dataRefrigCase->HaveDetailedTransRefrig = false;
     556              :     }
     557          150 :     if (state.dataRefrigCase->NumSimulationCases == 0 && state.dataRefrigCase->NumSimulationWalkIns == 0) {
     558          145 :         state.dataRefrigCase->HaveCasesOrWalkins = false;
     559              :     }
     560          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers == 0) {
     561          150 :         state.dataRefrigCase->HaveChillers = false;
     562              :     }
     563              : 
     564          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
     565            5 :         RefrigRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     566            5 :         state.dataHeatBal->HeatReclaimRefrigeratedRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     567              :     }
     568          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
     569            0 :         System.allocate(state.dataRefrigCase->NumRefrigSystems);
     570            0 :         state.dataRefrigCase->ShowUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     571            0 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     572            0 :         state.dataRefrigCase->ShowUnmetEnergyWarning = true;
     573            0 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning = true;
     574              :     }
     575          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
     576            0 :         TransSystem.allocate(state.dataRefrigCase->NumTransRefrigSystems);
     577            0 :         state.dataRefrigCase->ShowUnmetEnergyWarningTrans.dimension(state.dataRefrigCase->NumTransRefrigSystems, true);
     578              :     }
     579          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
     580            0 :         AirChillerSet.allocate(state.dataRefrigCase->NumRefrigChillerSets);
     581              :     }
     582          150 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
     583            0 :         state.dataHeatBal->HeatReclaimRefrigCondenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     584            0 :         Condenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     585            0 :         state.dataRefrigCase->UniqueCondenserNames.reserve(static_cast<unsigned>(state.dataRefrigCase->NumRefrigCondensers));
     586              :     }
     587          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
     588            0 :         GasCooler.allocate(state.dataRefrigCase->NumSimulationGasCooler);
     589              :     }
     590          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     591            3 :         CaseRAFraction.allocate(state.dataGlobal->NumOfZones);
     592            3 :         RefrigCase.allocate(state.dataRefrigCase->NumSimulationCases);
     593              :     }
     594          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
     595            3 :         WalkIn.allocate(state.dataRefrigCase->NumSimulationWalkIns);
     596              :     }
     597          150 :     if ((state.dataRefrigCase->NumSimulationWalkIns > 0) || (state.dataRefrigCase->NumSimulationCases > 0)) {
     598            5 :         CaseWIZoneReport.allocate(state.dataGlobal->NumOfZones);
     599              :     } else {
     600          145 :         state.dataRefrigCase->UseSysTimeStep = true;
     601              :         // needed to avoid accessing unallocated caseWIZoneReport on early call to SumZones
     602              :     }
     603          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
     604            0 :         Secondary.allocate(state.dataRefrigCase->NumSimulationSecondarySystems);
     605            0 :         state.dataRefrigCase->ShowUnmetSecondEnergyWarning.dimension(state.dataRefrigCase->NumSimulationSecondarySystems, true);
     606              :     }
     607          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
     608            0 :         WarehouseCoil.allocate(state.dataRefrigCase->NumSimulationRefrigAirChillers);
     609            0 :         CoilSysCredit.allocate(state.dataGlobal->NumOfZones);
     610              :     }
     611          150 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
     612            0 :         Compressor.allocate(state.dataRefrigCase->NumSimulationCompressors);
     613              :     }
     614          150 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
     615            0 :         Subcooler.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
     616              :     }
     617          150 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
     618            2 :         CaseAndWalkInList.allocate(state.dataRefrigCase->NumSimulationCaseAndWalkInLists);
     619              :     }
     620          150 :     if (NumCompressorLists > 0) {
     621            0 :         CompressorLists.allocate(NumCompressorLists);
     622              :     }
     623          150 :     if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
     624            0 :         TransferLoadList.allocate(state.dataRefrigCase->NumSimulationTransferLoadLists);
     625              :     }
     626              : 
     627          150 :     DayValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay);
     628          150 :     state.dataRefrigCase->RefrigPresentInZone.dimension(state.dataGlobal->NumOfZones, false);
     629              : 
     630          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:Case", MaxNumArgs, MaxNumAlphasCase, MaxNumNumbersCase);
     631          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     632              :         state, "Refrigeration:CaseAndWalkInList", MaxNumArgs, MaxNumAlphasCaseAndWalkInList, MaxNumNumbersCaseAndWalkInList);
     633          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     634              :         state, "Refrigeration:CompressorRack", MaxNumArgs, MaxNumAlphasRack, MaxNumNumbersRack);
     635          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:System", MaxNumArgs, MaxNumAlphasSys, MaxNumNumbersSys);
     636          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     637              :         state, "Refrigeration:TranscriticalSystem", MaxNumArgs, MaxNumAlphasTransSys, MaxNumNumbersTransSys);
     638          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     639              :         state, "Refrigeration:Condenser:AirCooled", MaxNumArgs, MaxNumAlphasConda, MaxNumNumbersConda);
     640          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     641              :         state, "Refrigeration:Condenser:EvaporativeCooled", MaxNumArgs, MaxNumAlphasConde, MaxNumNumbersConde);
     642          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     643              :         state, "Refrigeration:Condenser:WaterCooled", MaxNumArgs, MaxNumAlphasCondw, MaxNumNumbersCondw);
     644          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     645              :         state, "Refrigeration:GasCooler:AirCooled", MaxNumArgs, MaxNumAlphasGasCoolera, MaxNumNumbersGasCoolera);
     646          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     647              :         state, "Refrigeration:Compressor", MaxNumArgs, MaxNumAlphasComp, MaxNumNumbersComp);
     648          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     649              :         state, "Refrigeration:CompressorList", MaxNumArgs, MaxNumAlphasCompressorList, MaxNumNumbersCompressorList);
     650          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     651              :         state, "Refrigeration:WalkIn", MaxNumArgs, MaxNumAlphasWalkIn, MaxNumNumbersWalkIn);
     652          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     653              :         state, "Refrigeration:SecondarySystem", MaxNumArgs, MaxNumAlphasSecond, MaxNumNumbersSecond);
     654          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     655              :         state, "ZoneHVAC:RefrigerationChillerSet", MaxNumArgs, MaxNumAlphasChillerSet, MaxNumNumbersChillerSet);
     656          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     657              :         state, "Refrigeration:AirChiller", MaxNumArgs, MaxNumAlphasAirChiller, MaxNumNumbersAirChiller);
     658              : 
     659          150 :     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          150 :     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          150 :     Alphas.allocate(MaxNumAlphasAll);
     691          150 :     Numbers.dimension(MaxNumNumbersAll, 0.0);
     692          150 :     cAlphaFieldNames.allocate(MaxNumAlphasAll);
     693          150 :     cNumericFieldNames.allocate(MaxNumNumbersAll);
     694          150 :     lAlphaBlanks.dimension(MaxNumAlphasAll, true);
     695          150 :     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          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     698            3 :         CurrentModuleObject = "Refrigeration:Case";
     699            6 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
     700            3 :             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            3 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
     714              : 
     715            3 :             ++NumDisplayCases;
     716              : 
     717            3 :             AlphaNum = 1;
     718            3 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
     719            3 :             RefrigCase(CaseNum).Name = Alphas(AlphaNum);
     720              : 
     721            3 :             AlphaNum = 2;
     722            3 :             if (lAlphaBlanks(AlphaNum)) {
     723            3 :                 RefrigCase(CaseNum).availSched = Sched::GetScheduleAlwaysOn(state);
     724            0 :             } 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            0 :             } 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            3 :             RefrigCase(CaseNum).ZoneName = Alphas(3);
     734            3 :             RefrigCase(CaseNum).ActualZoneNum = Util::FindItemInList(Alphas(3), state.dataHeatBal->Zone);
     735              : 
     736            3 :             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            3 :                 state.dataRefrigCase->RefrigPresentInZone(RefrigCase(CaseNum).ActualZoneNum) = true;
     747              :             }
     748              : 
     749            3 :             RefrigCase(CaseNum).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigCase(CaseNum).ActualZoneNum);
     750              : 
     751            3 :             RefrigCase(CaseNum).RatedAmbientTemp = Numbers(1);
     752            3 :             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            3 :             RefrigCase(CaseNum).RatedAmbientRH = Numbers(2);
     763            3 :             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            6 :             RefrigCase(CaseNum).RatedAmbientDewPoint = Psychrometrics::PsyTdpFnWPb(
     773              :                 state,
     774            3 :                 Psychrometrics::PsyWFnTdbRhPb(
     775            3 :                     state, RefrigCase(CaseNum).RatedAmbientTemp, (RefrigCase(CaseNum).RatedAmbientRH / 100.0), state.dataEnvrn->StdBaroPress),
     776            3 :                 state.dataEnvrn->StdBaroPress);
     777              : 
     778            3 :             RefrigCase(CaseNum).RateTotCapPerLength = Numbers(3);
     779            3 :             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            3 :             RefrigCase(CaseNum).RatedLHR = Numbers(4);
     790            3 :             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            3 :             RefrigCase(CaseNum).RatedRTF = Numbers(5);
     799            3 :             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            3 :             RefrigCase(CaseNum).Length = Numbers(6);
     810            3 :             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            3 :             RefrigCase(CaseNum).Temperature = Numbers(7);
     821            3 :             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            3 :             RefrigCase(CaseNum).LatentEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(4)));
     833            3 :             if (RefrigCase(CaseNum).LatentEnergyCurveType == EnergyEqnForm::Invalid) {
     834            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(4), Alphas(4));
     835            0 :                 ErrorsFound = true;
     836              :             }
     837              : 
     838            3 :             RefrigCase(CaseNum).LatCapCurvePtr = Curve::GetCurveIndex(state, Alphas(5)); // convert curve name to number
     839            3 :             if (RefrigCase(CaseNum).LatCapCurvePtr == 0) {
     840            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
     841            0 :                 ErrorsFound = true;
     842              :             }
     843              : 
     844            9 :             ErrorsFound |= Curve::CheckCurveDims(state,
     845            3 :                                                  RefrigCase(CaseNum).LatCapCurvePtr, // Curve index
     846              :                                                  {1},                                // Valid dimensions
     847              :                                                  RoutineName,                        // Routine name
     848              :                                                  CurrentModuleObject,                // Object Type
     849            3 :                                                  RefrigCase(CaseNum).Name,           // Object Name
     850            3 :                                                  cAlphaFieldNames(5));               // Field Name
     851              : 
     852            3 :             NumNum = 8;
     853            3 :             if (!lNumericBlanks(NumNum)) {
     854            3 :                 RefrigCase(CaseNum).STDFanPower = Numbers(NumNum);
     855            3 :                 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            3 :             NumNum = 9;
     869            3 :             if (!lNumericBlanks(NumNum)) {
     870            3 :                 RefrigCase(CaseNum).OperatingFanPower = Numbers(NumNum);
     871            3 :                 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            3 :             NumNum = 10;
     885            3 :             if (!lNumericBlanks(NumNum)) {
     886            3 :                 RefrigCase(CaseNum).RatedLightingPower = Numbers(NumNum);
     887            3 :                 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            3 :             NumNum = 11;
     901            3 :             if (!lNumericBlanks(NumNum)) {
     902            0 :                 RefrigCase(CaseNum).LightingPower = Numbers(NumNum);
     903            0 :                 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            3 :                 RefrigCase(CaseNum).LightingPower = RefrigCase(CaseNum).RatedLightingPower;
     914              :             } // blank input
     915              : 
     916            3 :             if (lAlphaBlanks(6)) {
     917            0 :                 RefrigCase(CaseNum).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
     918            3 :             } 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            3 :             } 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            3 :             NumNum = 12;
     927            3 :             RefrigCase(CaseNum).LightingFractionToCase = 1.0; // default value
     928            3 :             if (!lNumericBlanks(NumNum)) {
     929            3 :                 RefrigCase(CaseNum).LightingFractionToCase = Numbers(NumNum);
     930              :             } // blank input lighting fraction to case
     931              :             //   check lighting fraction to case input
     932            3 :             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            3 :             NumNum = 13;
     944            3 :             RefrigCase(CaseNum).AntiSweatPower = Numbers(NumNum);
     945            3 :             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            3 :             NumNum = 14;
     956            3 :             RefrigCase(CaseNum).MinimumASPower = Numbers(NumNum);
     957            3 :             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            3 :             RefrigCase(CaseNum).AntiSweatControlType = static_cast<ASHtrCtrlType>(getEnumValue(asHtrCtrlTypeNamesUC, Alphas(7)));
     968            3 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Invalid) {
     969            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(7), Alphas(7));
     970            0 :                 ErrorsFound = true;
     971            3 :             } else if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::None) {
     972            3 :                 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            3 :             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            3 :             NumNum = 15;
     989              :             //  negative values for minimum humidity are allowed
     990            3 :             RefrigCase(CaseNum).HumAtZeroAS = Numbers(NumNum);
     991              : 
     992              :             //   check minimum humidity when linear AS control type is used
     993            3 :             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            3 :             NumNum = 16;
    1007            3 :             RefrigCase(CaseNum).Height = Numbers(NumNum);
    1008            3 :             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            3 :             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            3 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
    1032            0 :                 Real64 Rcase(0.0);      // Case thermal resistance used with anti-sweat heater control
    1033            0 :                 Real64 RcaseDenom(0.0); // Denominator of case thermal resistance calculation for anti-sweat
    1034              : 
    1035            0 :                 if (RefrigCase(CaseNum).Height == 0.0) {
    1036            0 :                     Rcase = 0.0;
    1037              :                 } else {
    1038            0 :                     RcaseDenom = ((RefrigCase(CaseNum).AntiSweatPower / RefrigCase(CaseNum).Height) -
    1039            0 :                                   (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).RatedAmbientTemp) / Rair);
    1040            0 :                     Rcase = (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).Temperature) / RcaseDenom;
    1041              :                 }
    1042            0 :                 RefrigCase(CaseNum).Rcase = max(0.0, Rcase);
    1043            0 :                 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            3 :             NumNum = 17;
    1057            3 :             RefrigCase(CaseNum).ASHeaterFractionToCase = Numbers(NumNum);
    1058            3 :             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            3 :             if (Alphas(8) == "HOTGAS") {
    1070            0 :                 Alphas(8) = "HOTFLUID";
    1071            3 :             } else if (Alphas(8) == "HOTGASWITHTEMPERATURETERMINATION") {
    1072            0 :                 Alphas(8) = "HOTFLUIDWITHTEMPERATURETERMINATION";
    1073              :             }
    1074              : 
    1075            3 :             RefrigCase(CaseNum).defrostType = static_cast<RefCaseDefrostType>(getEnumValue(refCaseDefrostTypeNamesUC, Alphas(8)));
    1076            3 :             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            3 :             RefCaseDefrostType DefType = RefrigCase(CaseNum).defrostType;
    1082            3 :             NumNum = 18;
    1083            3 :             if (!lNumericBlanks(NumNum)) {
    1084            3 :                 RefrigCase(CaseNum).DefrostPower = Numbers(NumNum);
    1085            3 :                 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            3 :                 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            3 :             if ((DefType == RefCaseDefrostType::HotFluid || DefType == RefCaseDefrostType::HotFluidTerm || DefType == RefCaseDefrostType::Electric ||
    1110            6 :                  DefType == RefCaseDefrostType::ElectricTerm) &&
    1111            0 :                 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            3 :             if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::None) {
    1124            0 :             } else if (lAlphaBlanks(9)) {
    1125            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(9));
    1126            0 :                 ErrorsFound = true;
    1127            0 :             } 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            0 :             } 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            3 :             int NumDefCycles = 0;
    1140              : 
    1141            3 :             if (RefrigCase(CaseNum).defrostSched != nullptr) {
    1142            0 :                 bool StartCycle = false;
    1143            0 :                 std::vector<Real64> const &dayVals = RefrigCase(CaseNum).defrostSched->getDayVals(state, 1);
    1144            0 :                 for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) {
    1145            0 :                     if (dayVals[i] == 0.0) {
    1146            0 :                         StartCycle = false;
    1147            0 :                     } else if (!StartCycle) {
    1148            0 :                         ++NumDefCycles;
    1149            0 :                         StartCycle = true;
    1150              :                     }
    1151              :                 }
    1152              :             }
    1153              : 
    1154            3 :             if (NumDefCycles > 0) {
    1155              :                 //     calculate maximum frost formation based on defrost schedule, heat of vaporization+fusion for water = 2833.0 kJ/kg
    1156            0 :                 RefrigCase(CaseNum).MaxKgFrost =
    1157            0 :                     (RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF * Constant::rSecsInHour *
    1158            0 :                      Constant::rHoursInDay / 1000.0 / 2833.0) / // Parenthesize!!!
    1159              :                     (NumDefCycles);
    1160              :             } else {
    1161            3 :                 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            3 :             if (lAlphaBlanks(10)) {
    1166            3 :                 RefrigCase(CaseNum).defrostDripDownSched = RefrigCase(CaseNum).defrostSched;
    1167            0 :             } 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            0 :             } 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            3 :             RefrigCase(CaseNum).DefrostEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(11)));
    1176            3 :             if (RefrigCase(CaseNum).DefrostEnergyCurveType == EnergyEqnForm::Invalid) {
    1177            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(11), Alphas(11));
    1178            0 :                 ErrorsFound = true;
    1179              :             }
    1180              : 
    1181            3 :             RefrigCase(CaseNum).DefCapCurvePtr = Curve::GetCurveIndex(state, Alphas(12)); // convert curve name to number
    1182            3 :             if ((RefrigCase(CaseNum).defrostType == RefCaseDefrostType::ElectricTerm ||
    1183            3 :                  RefrigCase(CaseNum).defrostType == RefCaseDefrostType::HotFluidTerm) &&
    1184            0 :                 (RefrigCase(CaseNum).DefCapCurvePtr == 0)) {
    1185            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(12), Alphas(12));
    1186            0 :                 ErrorsFound = true;
    1187              :             }
    1188              : 
    1189            3 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1190            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1191            0 :                                                      RefrigCase(CaseNum).DefCapCurvePtr, // Curve index
    1192              :                                                      {1},                                // Valid dimensions
    1193              :                                                      RoutineName,                        // Routine name
    1194              :                                                      CurrentModuleObject,                // Object Type
    1195            0 :                                                      RefrigCase(CaseNum).Name,           // Object Name
    1196            0 :                                                      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            3 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1201            0 :                 if (RefrigCase(CaseNum).defrostType != RefCaseDefrostType::ElectricTerm &&
    1202            0 :                     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            3 :             NumNum = 19;
    1213            3 :             RefrigCase(CaseNum).RAFrac = Numbers(NumNum);
    1214            3 :             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            3 :             RefrigCase(CaseNum).ZoneRANode = 0;
    1226            3 :             std::string retNodeName;
    1227            3 :             if (!lAlphaBlanks(15)) {
    1228            0 :                 retNodeName = Alphas(15);
    1229              :             }
    1230            3 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1231            0 :                 std::string callDescription = CurrentModuleObject + "=" + RefrigCase(CaseNum).Name;
    1232            0 :                 RefrigCase(CaseNum).ZoneRANode =
    1233            0 :                     DataZoneEquipment::GetReturnAirNodeForZone(state, RefrigCase(CaseNum).ActualZoneNum, retNodeName, callDescription);
    1234            0 :             }
    1235              : 
    1236            3 :             if (RefrigCase(CaseNum).ActualZoneNum >= 0) {
    1237            3 :                 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            3 :                 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            3 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1266            0 :                 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            3 :             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            3 :             if (RefrigCase(CaseNum).ActualZoneNum != 0) {
    1281            3 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).TotalCaseRAFraction += RefrigCase(CaseNum).RAFrac;
    1282            3 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).ZoneName = RefrigCase(CaseNum).ZoneName;
    1283              :             }
    1284              : 
    1285            3 :             if (lAlphaBlanks(13)) {
    1286            3 :             } 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            3 :             Real64 DesignSensibleCap = RefrigCase(CaseNum).RateTotCapPerLength * (1.0 - RefrigCase(CaseNum).RatedLHR) * RefrigCase(CaseNum).RatedRTF *
    1294            3 :                                        RefrigCase(CaseNum).Length;
    1295              : 
    1296              :             //   calculate case heat gain = lights + fans + anti-sweat
    1297              :             Real64 CaseHeatGain =
    1298            3 :                 ((RefrigCase(CaseNum).RatedLightingPower * RefrigCase(CaseNum).LightingFractionToCase) +
    1299            3 :                  (RefrigCase(CaseNum).AntiSweatPower * RefrigCase(CaseNum).ASHeaterFractionToCase) + RefrigCase(CaseNum).STDFanPower) *
    1300            3 :                 RefrigCase(CaseNum).Length;
    1301              : 
    1302              :             //   sensible case credits are calculated as the difference between the design sensible capacity and the case heat gain
    1303            3 :             RefrigCase(CaseNum).DesignSensCaseCredit = DesignSensibleCap - CaseHeatGain;
    1304              : 
    1305              :             //   compare case loads to design capacity
    1306            3 :             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            3 :             if (lAlphaBlanks(14)) {
    1317            0 :             } 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            0 :             } 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            3 :             RefrigCase(CaseNum).DesignRatedCap = RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).Length;
    1326            3 :             RefrigCase(CaseNum).DesignLatentCap = RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF;
    1327            3 :             RefrigCase(CaseNum).DesignDefrostCap = RefrigCase(CaseNum).DefrostPower * RefrigCase(CaseNum).Length;
    1328            3 :             RefrigCase(CaseNum).DesignLighting = RefrigCase(CaseNum).LightingPower * RefrigCase(CaseNum).Length;
    1329            3 :             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            3 :             NumNum = 20;
    1334            3 :             if (!lNumericBlanks(NumNum)) {
    1335            0 :                 RefrigCase(CaseNum).EvapTempDesign = Numbers(NumNum);
    1336            0 :                 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            3 :                 RefrigCase(CaseNum).EvapTempDesign = RefrigCase(CaseNum).Temperature - DelEvapTDefault;
    1348              :                 //    default 5C less than case operating temperature
    1349              :             }
    1350              : 
    1351            3 :             NumNum = 21;
    1352            3 :             if (!lNumericBlanks(NumNum)) {
    1353            0 :                 RefrigCase(CaseNum).RefrigInventory = Numbers(NumNum);
    1354            0 :                 RefrigCase(CaseNum).DesignRefrigInventory = RefrigCase(CaseNum).RefrigInventory * RefrigCase(CaseNum).Length;
    1355            0 :                 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            3 :                 RefrigCase(CaseNum).RefrigInventory = 0.0;
    1366              :             }
    1367              : 
    1368            3 :         } // Individual refrigerated cases
    1369              :     } //(NumSimulationCases > 0 )
    1370              : 
    1371              :     //************ START WALK IN COOLER INPUT **************
    1372              : 
    1373          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    1374            3 :         CurrentModuleObject = "Refrigeration:WalkIn";
    1375            6 :         for (int WalkInID = 1; WalkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInID) {
    1376            3 :             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            3 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1390              : 
    1391            3 :             WalkIn(WalkInID).Name = Alphas(1);
    1392              : 
    1393            3 :             if (lAlphaBlanks(2)) {
    1394            0 :                 WalkIn(WalkInID).availSched = Sched::GetScheduleAlwaysOn(state);
    1395            3 :             } 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            3 :             } 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            3 :             WalkIn(WalkInID).DesignRatedCap = Numbers(1);
    1404            3 :             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            3 :             if (!lNumericBlanks(2)) {
    1413            3 :                 WalkIn(WalkInID).Temperature = Numbers(2);
    1414              :             } else {
    1415            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(2));
    1416            0 :                 ErrorsFound = true;
    1417              :             }
    1418              : 
    1419            3 :             if (!lNumericBlanks(3)) {
    1420            3 :                 WalkIn(WalkInID).TEvapDesign = Numbers(3);
    1421              :             } else {
    1422            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(3));
    1423            0 :                 ErrorsFound = true;
    1424              :             }
    1425              : 
    1426            3 :             if (!lNumericBlanks(4)) {
    1427            3 :                 WalkIn(WalkInID).HeaterPower = Numbers(4);
    1428              :             } else {
    1429            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(4));
    1430            0 :                 ErrorsFound = true;
    1431              :             }
    1432              : 
    1433            3 :             AlphaNum = 3;
    1434            3 :             if (lAlphaBlanks(AlphaNum)) {
    1435            0 :                 WalkIn(WalkInID).heaterSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1436            3 :             } 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            3 :             } 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            3 :             if (!lNumericBlanks(5) && Numbers(5) > 0.0) {
    1445            3 :                 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            3 :             if (lNumericBlanks(6)) {
    1457            0 :                 WalkIn(WalkInID).CircFanPower = 0.0;
    1458              :             } else {
    1459            3 :                 WalkIn(WalkInID).CircFanPower = Numbers(6);
    1460            3 :                 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            3 :             if (!lNumericBlanks(7)) {
    1472            3 :                 WalkIn(WalkInID).DesignLighting = Numbers(7);
    1473              :             } else {
    1474            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(7));
    1475            0 :                 ErrorsFound = true;
    1476              :             }
    1477              : 
    1478            3 :             AlphaNum = 4;
    1479            3 :             if (lAlphaBlanks(AlphaNum)) {
    1480            0 :                 WalkIn(WalkInID).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1481            3 :             } 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            3 :             } 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            3 :             AlphaNum = 5;
    1491            3 :             if (lAlphaBlanks(AlphaNum)) {
    1492            0 :                 WalkIn(WalkInID).defrostType = DefrostType::Elec;
    1493            3 :             } 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            3 :             AlphaNum = 6;
    1500            3 :             if (lAlphaBlanks(AlphaNum)) {
    1501            0 :                 WalkIn(WalkInID).DefrostControlType = DefrostCtrlType::Sched;
    1502            3 :             } 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            3 :             AlphaNum = 7;
    1510              : 
    1511            3 :             if (lAlphaBlanks(AlphaNum)) {
    1512            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1513            0 :                 ErrorsFound = true;
    1514            3 :             } 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            3 :             } 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            3 :             AlphaNum = 8;
    1525            3 :             if (lAlphaBlanks(AlphaNum)) { // blank input so use drip down schedule for defrost
    1526            3 :                 WalkIn(WalkInID).defrostDripDownSched = WalkIn(WalkInID).defrostSched;
    1527            0 :             } 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            0 :             } 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            3 :             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            3 :                 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            3 :                     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            3 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Elec) {
    1556            3 :                     WalkIn(WalkInID).DefEnergyFraction = 0.7;
    1557              :                 }
    1558            3 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Fluid) {
    1559            0 :                     WalkIn(WalkInID).DefEnergyFraction = 0.3;
    1560              :                 }
    1561            3 :                 if (!lNumericBlanks(9)) {
    1562            0 :                     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            0 :                         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            3 :             AlphaNum = 9;
    1577            3 :             if (lAlphaBlanks(AlphaNum)) {
    1578            0 :             } 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            3 :             WalkIn(WalkInID).DesignRefrigInventory = 0.0;
    1584            3 :             if (!lNumericBlanks(10)) {
    1585            0 :                 WalkIn(WalkInID).DesignRefrigInventory = Numbers(10);
    1586              :             }
    1587              : 
    1588            3 :             if (!lNumericBlanks(11)) {
    1589            3 :                 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            3 :             if (lNumericBlanks(12)) {
    1597            0 :                 WalkIn(WalkInID).FloorUValue = DefaultWISurfaceUValue;
    1598              :             } else {
    1599            3 :                 WalkIn(WalkInID).FloorUValue = Numbers(12);
    1600            3 :                 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            3 :             int NumWIFieldsPerZone = NumWIAlphaFieldsPerZone + NumWINumberFieldsPerZone;
    1611            3 :             int NumWIFieldsTotal = NumNumbers + NumAlphas - NumWIAlphaFieldsBeforeZoneInput - NumWINumberFieldsBeforeZoneInput;
    1612            3 :             int NumZones = 1;
    1613            3 :             if (NumWIFieldsTotal > NumWIFieldsPerZone) {
    1614            0 :                 NumZones = 2;
    1615              :             }
    1616            3 :             if (NumWIFieldsTotal > (2 * NumWIFieldsPerZone)) {
    1617            0 :                 NumZones = 3;
    1618              :             }
    1619            3 :             if (NumWIFieldsTotal > (3 * NumWIFieldsPerZone)) {
    1620            0 :                 NumZones = 4;
    1621              :             }
    1622            3 :             if (NumWIFieldsTotal > (4 * NumWIFieldsPerZone)) {
    1623            0 :                 NumZones = 5;
    1624              :             }
    1625            3 :             if (NumWIFieldsTotal > (5 * NumWIFieldsPerZone)) {
    1626            0 :                 NumZones = 6;
    1627              :             }
    1628            3 :             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            3 :             if (!allocated(WalkIn(WalkInID).ZoneName)) {
    1633            3 :                 WalkIn(WalkInID).ZoneName.allocate(NumZones);
    1634              :             }
    1635            3 :             if (!allocated(WalkIn(WalkInID).ZoneNum)) {
    1636            3 :                 WalkIn(WalkInID).ZoneNum.allocate(NumZones) = 0;
    1637              :             }
    1638            3 :             if (!allocated(WalkIn(WalkInID).ZoneNodeNum)) {
    1639            3 :                 WalkIn(WalkInID).ZoneNodeNum.allocate(NumZones) = 0;
    1640              :             }
    1641            3 :             if (!allocated(WalkIn(WalkInID).SurfaceArea)) {
    1642            3 :                 WalkIn(WalkInID).SurfaceArea.allocate(NumZones) = 0.0;
    1643              :             }
    1644            3 :             if (!allocated(WalkIn(WalkInID).UValue)) {
    1645            3 :                 WalkIn(WalkInID).UValue.allocate(NumZones) = 0.0;
    1646              :             }
    1647            3 :             if (!allocated(WalkIn(WalkInID).UValueGlassDr)) {
    1648            3 :                 WalkIn(WalkInID).UValueGlassDr.allocate(NumZones) = 0.0;
    1649              :             }
    1650            3 :             if (!allocated(WalkIn(WalkInID).glassDoorOpenScheds)) {
    1651            3 :                 WalkIn(WalkInID).glassDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1652              :             }
    1653            3 :             if (!allocated(WalkIn(WalkInID).AreaGlassDr)) {
    1654            3 :                 WalkIn(WalkInID).AreaGlassDr.allocate(NumZones) = 0.0;
    1655              :             }
    1656            3 :             if (!allocated(WalkIn(WalkInID).HeightGlassDr)) {
    1657            3 :                 WalkIn(WalkInID).HeightGlassDr.allocate(NumZones) = 0.0;
    1658              :             }
    1659            3 :             if (!allocated(WalkIn(WalkInID).UValueStockDr)) {
    1660            3 :                 WalkIn(WalkInID).UValueStockDr.allocate(NumZones) = 0.0;
    1661              :             }
    1662            3 :             if (!allocated(WalkIn(WalkInID).stockDoorOpenScheds)) {
    1663            3 :                 WalkIn(WalkInID).stockDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1664              :             }
    1665            3 :             if (!allocated(WalkIn(WalkInID).StockDoorProtectType)) {
    1666            3 :                 WalkIn(WalkInID).StockDoorProtectType.allocate(NumZones) = WIStockDoor::Invalid;
    1667              :             }
    1668            3 :             if (!allocated(WalkIn(WalkInID).AreaStockDr)) {
    1669            3 :                 WalkIn(WalkInID).AreaStockDr.allocate(NumZones) = 0.0;
    1670              :             }
    1671            3 :             if (!allocated(WalkIn(WalkInID).HeightStockDr)) {
    1672            3 :                 WalkIn(WalkInID).HeightStockDr.allocate(NumZones) = 0.0;
    1673              :             }
    1674            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditRate)) {
    1675            3 :                 WalkIn(WalkInID).SensZoneCreditRate.allocate(NumZones) = 0.0;
    1676              :             }
    1677            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCoolRate)) {
    1678            3 :                 WalkIn(WalkInID).SensZoneCreditCoolRate.allocate(NumZones) = 0.0;
    1679              :             }
    1680            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCool)) {
    1681            3 :                 WalkIn(WalkInID).SensZoneCreditCool.allocate(NumZones) = 0.0;
    1682              :             }
    1683            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeatRate)) {
    1684            3 :                 WalkIn(WalkInID).SensZoneCreditHeatRate.allocate(NumZones) = 0.0;
    1685              :             }
    1686            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeat)) {
    1687            3 :                 WalkIn(WalkInID).SensZoneCreditHeat.allocate(NumZones) = 0.0;
    1688              :             }
    1689            3 :             if (!allocated(WalkIn(WalkInID).LatZoneCreditRate)) {
    1690            3 :                 WalkIn(WalkInID).LatZoneCreditRate.allocate(NumZones) = 0.0;
    1691              :             }
    1692            3 :             if (!allocated(WalkIn(WalkInID).LatZoneCredit)) {
    1693            3 :                 WalkIn(WalkInID).LatZoneCredit.allocate(NumZones) = 0.0;
    1694              :             }
    1695              : 
    1696            3 :             int AStart = NumWIAlphaFieldsBeforeZoneInput + 1;
    1697            3 :             int NStart = NumWINumberFieldsBeforeZoneInput + 1;
    1698            6 :             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            3 :                 WalkIn(WalkInID).ZoneName(ZoneID) = Alphas(AStart);
    1702            3 :                 WalkIn(WalkInID).ZoneNum(ZoneID) = Util::FindItemInList(Alphas(AStart), state.dataHeatBal->Zone);
    1703              : 
    1704            3 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) == 0) {
    1705            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart), Alphas(AStart));
    1706            0 :                     ErrorsFound = true;
    1707              :                 } else {
    1708            3 :                     state.dataRefrigCase->RefrigPresentInZone(WalkIn(WalkInID).ZoneNum(ZoneID)) = true;
    1709              :                 }
    1710            3 :                 WalkIn(WalkInID).ZoneNodeNum(ZoneID) = DataZoneEquipment::GetSystemNodeNumberForZone(state, WalkIn(WalkInID).ZoneNum(ZoneID));
    1711            3 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) >= 0) {
    1712            3 :                     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            3 :                 if (!lNumericBlanks(NStart)) {
    1720            3 :                     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            3 :                 if (lNumericBlanks(NStart + 1)) {
    1733            0 :                     WalkIn(WalkInID).UValue(ZoneID) = DefaultWISurfaceUValue;
    1734              :                 } else {
    1735            3 :                     WalkIn(WalkInID).UValue(ZoneID) = Numbers(NStart + 1);
    1736            3 :                     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            3 :                 WalkIn(WalkInID).AreaGlassDr(ZoneID) = 0.0;
    1750            3 :                 WalkIn(WalkInID).HeightGlassDr(ZoneID) = 0.0;
    1751            3 :                 WalkIn(WalkInID).UValueGlassDr(ZoneID) = 0.0;
    1752            3 :                 if (!lNumericBlanks(NStart + 2)) {
    1753            0 :                     WalkIn(WalkInID).AreaGlassDr(ZoneID) = Numbers(NStart + 2);
    1754              : 
    1755            0 :                     WalkIn(WalkInID).HeightGlassDr(ZoneID) = DefaultWIHeightGlassDr;
    1756            0 :                     if (!lNumericBlanks(NStart + 3)) {
    1757            0 :                         WalkIn(WalkInID).HeightGlassDr(ZoneID) = Numbers(NStart + 3);
    1758              :                     }
    1759              : 
    1760            0 :                     WalkIn(WalkInID).UValueGlassDr(ZoneID) = DefaultWIUValueGlassDr;
    1761            0 :                     if (!lNumericBlanks(NStart + 4)) {
    1762            0 :                         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            0 :                     if (lAlphaBlanks(AStart + 1)) {
    1767            0 :                     } 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            0 :                     } 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            3 :                 WalkIn(WalkInID).AreaStockDr(ZoneID) = 0.0;
    1778            3 :                 WalkIn(WalkInID).HeightStockDr(ZoneID) = 0.0;
    1779            3 :                 WalkIn(WalkInID).UValueStockDr(ZoneID) = 0.0;
    1780            3 :                 if (!lNumericBlanks(NStart + 5)) {
    1781            3 :                     WalkIn(WalkInID).AreaStockDr(ZoneID) = Numbers(NStart + 5);
    1782              : 
    1783            3 :                     WalkIn(WalkInID).HeightStockDr(ZoneID) = DefaultWIHeightStockDr;
    1784            3 :                     if (!lNumericBlanks(NStart + 6)) {
    1785            3 :                         WalkIn(WalkInID).HeightStockDr(ZoneID) = Numbers(NStart + 6);
    1786              :                     }
    1787              : 
    1788            3 :                     WalkIn(WalkInID).UValueStockDr(ZoneID) = DefaultWIUValueStockDr;
    1789            3 :                     if (!lNumericBlanks(NStart + 7)) {
    1790            0 :                         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            3 :                     if (lAlphaBlanks(AStart + 2)) {
    1795            0 :                     } 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            0 :                     } 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            3 :                     if (lAlphaBlanks(AStart + 3)) {
    1804              :                         // default air curtain
    1805            0 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::AirCurtain;
    1806            3 :                     } else if ((WalkIn(WalkInID).StockDoorProtectType(ZoneID) =
    1807            6 :                                     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            3 :                 AStart += NumWIAlphaFieldsPerZone;
    1814            3 :                 NStart += NumWINumberFieldsPerZone;
    1815              :             } // Zones for Walk Ins
    1816              :         } // Individual Walk Ins
    1817              :     } //(NumSimulationWalkIns > 0 )
    1818              : 
    1819              :     //************* Start Indiv Refrig Air Chillers
    1820              : 
    1821          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    1822            0 :         CurrentModuleObject = "Refrigeration:AirChiller";
    1823            0 :         for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
    1824              :             // A1
    1825            0 :             AlphaNum = 1;
    1826            0 :             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            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1840              : 
    1841            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1842              : 
    1843            0 :             WarehouseCoil(CoilID).Name = Alphas(AlphaNum);
    1844              : 
    1845              :             // A2
    1846            0 :             ++AlphaNum;
    1847            0 :             if (lAlphaBlanks(AlphaNum)) {
    1848            0 :                 WarehouseCoil(CoilID).availSched = Sched::GetScheduleAlwaysOn(state);
    1849            0 :             } 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            0 :             } 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            0 :             ++AlphaNum;
    1867            0 :             if (lAlphaBlanks(AlphaNum)) {
    1868            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1869            0 :                 ErrorsFound = true;
    1870            0 :             } 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            0 :                 switch (WarehouseCoil(CoilID).ratingType) {
    1881            0 :                 case RatingType::UnitLoadFactorSens: {
    1882              :                     // N1
    1883            0 :                     NumNum = 1;
    1884            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1885            0 :                         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            0 :                 } break;
    1896              : 
    1897            0 :                 case RatingType::RatedCapacityTotal: {
    1898              :                     // N2
    1899            0 :                     NumNum = 2; // advance past rating in W/C to N2 with rating in W
    1900            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1901            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1902              :                         // N3
    1903            0 :                         NumNum = 3; // read rated RH only for this type of rating at N3
    1904            0 :                         if (lNumericBlanks(NumNum)) {
    1905            0 :                             WarehouseCoil(CoilID).RatedRH = 0.85;
    1906              :                         } else {
    1907            0 :                             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            0 :                             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            0 :                 } 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            0 :                 case RatingType::EuropeanSC3Std: {
    2000              :                     // N2
    2001            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2002            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2003            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2004            0 :                         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            0 :                 } 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            0 :             NumNum = 4;
    2111            0 :             if (!lNumericBlanks(NumNum)) {
    2112            0 :                 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            0 :             ++NumNum; // N5
    2122            0 :             if (!lNumericBlanks(NumNum)) {
    2123            0 :                 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            0 :             ++NumNum; // N6
    2134            0 :             if (!lNumericBlanks(NumNum)) {
    2135            0 :                 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            0 :             ++NumNum;                                 // N7
    2150            0 :             WarehouseCoil(CoilID).CorrMaterial = 1.0; // default value
    2151            0 :             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            0 :             ++NumNum;                                    // N8
    2157            0 :             WarehouseCoil(CoilID).CorrRefrigerant = 1.0; // default value
    2158            0 :             if (!lNumericBlanks(NumNum)) {
    2159            0 :                 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            0 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::UnitLoadFactorSens) &&
    2165            0 :                 (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2166            0 :                 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            0 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2172            0 :                 WarehouseCoil(CoilID).UnitLoadFactorSens *= WarehouseCoil(CoilID).CorrMaterial * WarehouseCoil(CoilID).CorrRefrigerant;
    2173              :             }
    2174              :             // First calc of ratedsensiblecap for type type unitloadfactorsens
    2175            0 :             WarehouseCoil(CoilID).RatedSensibleCap = WarehouseCoil(CoilID).UnitLoadFactorSens * WarehouseCoil(CoilID).RatedTemperatureDif;
    2176              :             // A4    Enter capacity correction curve type
    2177            0 :             AlphaNum = 4;
    2178            0 :             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            0 :             } 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            0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::TabularRH_DT1_TRoom;
    2185            0 :                 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            0 :             } else if ((WarehouseCoil(CoilID).SHRCorrType =
    2203            0 :                             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            0 :             ++AlphaNum; // A5
    2209            0 :             ++NumNum;   // N9
    2210            0 :             switch (WarehouseCoil(CoilID).SHRCorrType) {
    2211            0 :             case SHRCorrectionType::SHR60: {
    2212            0 :                 WarehouseCoil(CoilID).SHRCorrection60 = 1.48; // reference Nelson, ASHRAE journal August 2010 Fig 2
    2213            0 :                 if (!lNumericBlanks(NumNum)) {
    2214            0 :                     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            0 :                 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            0 :                 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            0 :             } break;
    2236            0 :             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            0 :             } 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            0 :             case SHRCorrectionType::TabularRH_DT1_TRoom: {
    2258            0 :                 WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    2259            0 :                 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            0 :                 } 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            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2273            0 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2274              :                                                      {3},                                         // Valid dimensions
    2275              :                                                      RoutineName,                                 // Routine name
    2276              :                                                      CurrentModuleObject,                         // Object Type
    2277            0 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2278            0 :                                                      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            0 :             } break;
    2285            0 :             default:
    2286            0 :                 break;
    2287              :             } // SHRCorrectionType
    2288              : 
    2289            0 :             ++NumNum; // N10
    2290            0 :             if (!lNumericBlanks(NumNum)) {
    2291            0 :                 WarehouseCoil(CoilID).HeaterPower = Numbers(NumNum);
    2292              :             } else {
    2293            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(NumNum));
    2294            0 :                 ErrorsFound = true;
    2295              :             }
    2296              : 
    2297            0 :             ++AlphaNum; // A6
    2298            0 :             if (lAlphaBlanks(AlphaNum)) {
    2299            0 :                 WarehouseCoil(CoilID).heaterAvailSched = Sched::GetScheduleAlwaysOn(state);
    2300            0 :             } 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            0 :             } 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            0 :             ++AlphaNum; // A7
    2310            0 :             if (lAlphaBlanks(AlphaNum)) {
    2311            0 :                 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            0 :             ++NumNum; // N11
    2319            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2320            0 :                 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            0 :             ++NumNum; // N12
    2332            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2333            0 :                 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            0 :             ++NumNum;                                       // N13
    2344            0 :             WarehouseCoil(CoilID).FanMinAirFlowRatio = 0.2; // default value
    2345            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2346            0 :                 WarehouseCoil(CoilID).FanMinAirFlowRatio = Numbers(NumNum);
    2347              :             }
    2348              : 
    2349              :             // Input defrost type
    2350            0 :             ++AlphaNum; // A8
    2351            0 :             if (lAlphaBlanks(AlphaNum)) {
    2352            0 :                 WarehouseCoil(CoilID).defrostType = DefrostType::Elec;
    2353            0 :             } 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            0 :             ++AlphaNum; // A9
    2360            0 :             if (lAlphaBlanks(AlphaNum)) {
    2361            0 :                 WarehouseCoil(CoilID).DefrostControlType = DefrostCtrlType::Sched;
    2362            0 :             } else if ((WarehouseCoil(CoilID).DefrostControlType =
    2363            0 :                             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            0 :             ++AlphaNum; // A10
    2370            0 :             if (lAlphaBlanks(AlphaNum)) {
    2371            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    2372            0 :                 ErrorsFound = true;
    2373            0 :             } 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            0 :             } 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            0 :             ++AlphaNum; // A11
    2384            0 :             if (lAlphaBlanks(AlphaNum)) {
    2385            0 :                 WarehouseCoil(CoilID).defrostDripDownSched = WarehouseCoil(CoilID).defrostSched;
    2386            0 :             } 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            0 :             } 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            0 :             ++NumNum; // N14
    2395            0 :             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            0 :                 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            0 :                     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            0 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Elec) {
    2416            0 :                     WarehouseCoil(CoilID).DefEnergyFraction = 0.7;
    2417              :                 }
    2418            0 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Fluid) {
    2419            0 :                     WarehouseCoil(CoilID).DefEnergyFraction = 0.3;
    2420              :                 }
    2421              : 
    2422            0 :                 ++NumNum; // N15
    2423            0 :                 if (!lNumericBlanks(NumNum)) {
    2424            0 :                     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            0 :                         WarehouseCoil(CoilID).DefEnergyFraction = Numbers(NumNum);
    2433              :                     } // number out of range
    2434              :                 } // lnumericblanks
    2435              :             } // defrost type
    2436              : 
    2437            0 :             ++AlphaNum; // A12
    2438            0 :             if (lAlphaBlanks(AlphaNum)) {
    2439            0 :                 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            0 :             ++NumNum; // N16
    2447            0 :             WarehouseCoil(CoilID).DesignRefrigInventory = 0.0;
    2448            0 :             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          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
    2458              : 
    2459            0 :         state.dataRefrigCase->CheckChillerSetName.dimension(state.dataRefrigCase->NumRefrigChillerSets, true);
    2460              : 
    2461            0 :         CurrentModuleObject = "ZoneHVAC:RefrigerationChillerSet";
    2462            0 :         for (int SetID = 1; SetID <= state.dataRefrigCase->NumRefrigChillerSets; ++SetID) {
    2463            0 :             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            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2477              : 
    2478            0 :             AlphaNum = 1;
    2479            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2480              : 
    2481            0 :             AirChillerSet(SetID).Name = Alphas(AlphaNum);
    2482              : 
    2483            0 :             AlphaNum = 2;
    2484            0 :             if (lAlphaBlanks(AlphaNum)) {
    2485            0 :                 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            0 :             ++AlphaNum;
    2495            0 :             AirChillerSet(SetID).ZoneName = Alphas(AlphaNum);
    2496            0 :             AirChillerSet(SetID).ZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    2497              : 
    2498            0 :             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            0 :             AirChillerSet(SetID).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, AirChillerSet(SetID).ZoneNum);
    2509            0 :             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            0 :             state.dataRefrigCase->RefrigPresentInZone(AirChillerSet(SetID).ZoneNum) = true;
    2522              : 
    2523            0 :             ++AlphaNum;
    2524            0 :             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            0 :             ++AlphaNum;
    2539            0 :             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            0 :             int NumChillersInSet = NumAlphas - AlphaNum;
    2556            0 :             int AlphaStartList = AlphaNum; //+ 1
    2557            0 :             AirChillerSet(SetID).NumCoils = NumChillersInSet;
    2558            0 :             if (!allocated(AirChillerSet(SetID).CoilNum)) {
    2559            0 :                 AirChillerSet(SetID).CoilNum.allocate(NumChillersInSet);
    2560              :             }
    2561            0 :             for (int ChillerIndex = 1; ChillerIndex <= NumChillersInSet; ++ChillerIndex) {
    2562            0 :                 int AlphaListNum = AlphaStartList + ChillerIndex;
    2563            0 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2564            0 :                     int CoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2565            0 :                     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            0 :                     AirChillerSet(SetID).CoilNum(ChillerIndex) = CoilNum;
    2576            0 :                     WarehouseCoil(CoilNum).ZoneName = AirChillerSet(SetID).ZoneName;
    2577            0 :                     WarehouseCoil(CoilNum).ZoneNum = AirChillerSet(SetID).ZoneNum;
    2578            0 :                     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          150 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    2587            2 :         CurrentModuleObject = "Refrigeration:CaseAndWalkInList";
    2588            4 :         for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationCaseAndWalkInLists; ++ListNum) {
    2589            2 :             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            2 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2602            2 :             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            2 :             int NumTotalLoadsOnList = NumAlphas - 1;
    2607            2 :             if (!allocated(CaseAndWalkInList(ListNum).WalkInItemNum)) {
    2608            2 :                 CaseAndWalkInList(ListNum).WalkInItemNum.allocate(NumTotalLoadsOnList);
    2609              :             }
    2610            2 :             if (!allocated(CaseAndWalkInList(ListNum).CaseItemNum)) {
    2611            2 :                 CaseAndWalkInList(ListNum).CaseItemNum.allocate(NumTotalLoadsOnList);
    2612              :             }
    2613            2 :             if (!allocated(CaseAndWalkInList(ListNum).CoilItemNum)) {
    2614            2 :                 CaseAndWalkInList(ListNum).CoilItemNum.allocate(NumTotalLoadsOnList);
    2615              :             }
    2616              : 
    2617            2 :             int NumCasesOnList = 0;
    2618            2 :             int NumCoilsOnList = 0;
    2619            2 :             int NumWalkInsOnList = 0;
    2620            2 :             int LoadCount = 0;
    2621            5 :             for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    2622            3 :                 int AlphaListNum = 1 + NumLoad;
    2623            3 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2624            3 :                     ++LoadCount;
    2625            3 :                     int LoadWalkInNum = 0;
    2626            3 :                     int LoadCaseNum = 0;
    2627            3 :                     int LoadCoilNum = 0;
    2628            3 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    2629            3 :                         LoadWalkInNum = Util::FindItemInList(Alphas(AlphaListNum), WalkIn);
    2630              :                     }
    2631            3 :                     if (state.dataRefrigCase->NumSimulationCases > 0) {
    2632            2 :                         LoadCaseNum = Util::FindItemInList(Alphas(AlphaListNum), RefrigCase);
    2633              :                     }
    2634            3 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    2635            0 :                         LoadCoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2636              :                     }
    2637            3 :                     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            3 :                     } 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            3 :                     } else if (LoadWalkInNum != 0) {
    2654            2 :                         ++NumWalkInsOnList;
    2655            2 :                         CaseAndWalkInList(ListNum).WalkInItemNum(NumWalkInsOnList) = LoadWalkInNum;
    2656            1 :                     } else if (LoadCaseNum != 0) {
    2657            1 :                         ++NumCasesOnList;
    2658            1 :                         CaseAndWalkInList(ListNum).CaseItemNum(NumCasesOnList) = LoadCaseNum;
    2659            0 :                     } else if (LoadCoilNum != 0) {
    2660            0 :                         ++NumCoilsOnList;
    2661            0 :                         CaseAndWalkInList(ListNum).CoilItemNum(NumCoilsOnList) = LoadCoilNum;
    2662              :                     }
    2663              :                 } // lAlphaBlanks
    2664              :             } // Num Total Loads on List
    2665            2 :             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            2 :             CaseAndWalkInList(ListNum).NumCases = NumCasesOnList;
    2673            2 :             CaseAndWalkInList(ListNum).NumCoils = NumCoilsOnList;
    2674            2 :             CaseAndWalkInList(ListNum).NumWalkIns = NumWalkInsOnList;
    2675              :         } // ListNum=1,NumSimulationCaseAndWalkInLists
    2676              :     } //(NumSimulationCaseAndWalkInLists > 0)
    2677              : 
    2678              :     //**** End read CaseAndWalkIn Lists **********************************************************
    2679              : 
    2680              :     //************** Start RefrigerationRacks
    2681              : 
    2682          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    2683              : 
    2684            5 :         CurrentModuleObject = "Refrigeration:CompressorRack";
    2685              : 
    2686           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
    2687              : 
    2688            5 :             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            5 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2702            5 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2703              : 
    2704            5 :             RefrigRack(RackNum).Name = Alphas(1);
    2705            5 :             RefrigRack(RackNum).MyIdx = RackNum;
    2706            5 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).Name = Alphas(1);
    2707            5 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).SourceType = CurrentModuleObject;
    2708              : 
    2709            5 :             if (lAlphaBlanks(2)) {
    2710            0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2711            5 :             } 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            5 :             RefrigRack(RackNum).RatedCOP = Numbers(1);
    2718              : 
    2719            5 :             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            5 :             RefrigRack(RackNum).COPFTempPtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    2730            5 :             if (RefrigRack(RackNum).COPFTempPtr == 0) {
    2731            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), Alphas(3));
    2732            0 :                 ErrorsFound = true;
    2733              :             }
    2734              : 
    2735           15 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2736            5 :                                                  RefrigRack(RackNum).COPFTempPtr, // Curve index
    2737              :                                                  {1},                             // Valid dimensions
    2738              :                                                  RoutineName,                     // Routine name
    2739              :                                                  CurrentModuleObject,             // Object Type
    2740            5 :                                                  RefrigRack(RackNum).Name,        // Object Name
    2741            5 :                                                  cAlphaFieldNames(3));            // Field Name
    2742              : 
    2743            5 :             RefrigRack(RackNum).CondenserFanPower = Numbers(2);
    2744            5 :             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            5 :             RefrigRack(RackNum).TotCondFTempPtr = Curve::GetCurveIndex(state, Alphas(4)); // convert curve name to number
    2755            5 :             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            5 :             if (!lAlphaBlanks(4)) {
    2767            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2768            0 :                                                      RefrigRack(RackNum).TotCondFTempPtr, // Curve index
    2769              :                                                      {1},                                 // Valid dimensions
    2770              :                                                      RoutineName,                         // Routine name
    2771              :                                                      CurrentModuleObject,                 // Object Type
    2772            0 :                                                      RefrigRack(RackNum).Name,            // Object Name
    2773            0 :                                                      cAlphaFieldNames(4));                // Field Name
    2774              :             }
    2775              : 
    2776            5 :             if (lAlphaBlanks(5)) {
    2777            0 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2778           10 :             } else if ((RefrigRack(RackNum).CondenserType = static_cast<DataHeatBalance::RefrigCondenserType>(
    2779            5 :                             getEnumValue(DataHeatBalance::refrigCondenserTypeNamesUC, Alphas(5)))) == DataHeatBalance::RefrigCondenserType::Invalid) {
    2780            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    2781            0 :                 ErrorsFound = true;
    2782           10 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap ||
    2783            5 :                        RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2784            0 :                 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           10 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade ||
    2796            5 :                        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            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2802            0 :                 RefrigRack(RackNum).InletNode = NodeInputManager::GetOnlySingleNode(state,
    2803            0 :                                                                                     Alphas(6),
    2804              :                                                                                     ErrorsFound,
    2805              :                                                                                     DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2806            0 :                                                                                     Alphas(1),
    2807              :                                                                                     DataLoopNode::NodeFluidType::Water,
    2808              :                                                                                     DataLoopNode::ConnectionType::Inlet,
    2809              :                                                                                     NodeInputManager::CompFluidStream::Primary,
    2810              :                                                                                     DataLoopNode::ObjectIsNotParent);
    2811            0 :                 RefrigRack(RackNum).OutletNode = NodeInputManager::GetOnlySingleNode(state,
    2812            0 :                                                                                      Alphas(7),
    2813              :                                                                                      ErrorsFound,
    2814              :                                                                                      DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2815            0 :                                                                                      Alphas(1),
    2816              :                                                                                      DataLoopNode::NodeFluidType::Water,
    2817              :                                                                                      DataLoopNode::ConnectionType::Outlet,
    2818              :                                                                                      NodeInputManager::CompFluidStream::Primary,
    2819              :                                                                                      DataLoopNode::ObjectIsNotParent);
    2820              :                 // Check node connections
    2821            0 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(6), Alphas(7), "RefrigRack Nodes");
    2822              :                 // Get loop flow type
    2823            0 :                 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            0 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Variable) {
    2830            0 :                     if (lAlphaBlanks(9)) {
    2831            0 :                     } 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            0 :                 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            0 :                 RefrigRack(RackNum).VolFlowRateMax = Numbers(4);
    2844              : 
    2845              :                 // Check constant flow for max violation, if applicable
    2846            0 :                 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            0 :                 RefrigRack(RackNum).OutletTempMax = Numbers(5);
    2859            0 :                 RefrigRack(RackNum).InletTempMin = Numbers(6);
    2860              :                 // set flow request for plant sizing.
    2861            0 :                 PlantUtilities::RegisterPlantCompDesignFlow(state, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).VolFlowRateMax);
    2862              :             } // Water cooled condenser data
    2863              : 
    2864              :             // Get evaporative cooled condenser input
    2865            5 :             if (lAlphaBlanks(10)) {
    2866            0 :             } 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            0 :             } 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            5 :             RefrigRack(RackNum).EvapEffect = Numbers(7);
    2875            5 :             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            5 :             RefrigRack(RackNum).CondenserAirFlowRate = Numbers(8);
    2886            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).CondenserAirFlowRate <= 0.0 &&
    2887            0 :                 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            5 :             RefrigRack(RackNum).BasinHeaterPowerFTempDiff = Numbers(9);
    2899            5 :             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            5 :             RefrigRack(RackNum).BasinHeaterSetPointTemp = Numbers(10);
    2906            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    2907            0 :                 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            5 :             RefrigRack(RackNum).EvapPumpPower = Numbers(11);
    2916            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).EvapPumpPower < 0.0 &&
    2917            0 :                 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            5 :             RefrigRack(RackNum).SupplyTankName = Alphas(11);
    2929            5 :             if (lAlphaBlanks(11)) {
    2930            5 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    2931              :             } else {
    2932            0 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    2933            0 :                 WaterManager::SetupTankDemandComponent(state,
    2934            0 :                                                        RefrigRack(RackNum).Name,
    2935              :                                                        CurrentModuleObject,
    2936            0 :                                                        RefrigRack(RackNum).SupplyTankName,
    2937              :                                                        ErrorsFound,
    2938            0 :                                                        RefrigRack(RackNum).EvapWaterSupTankID,
    2939            0 :                                                        RefrigRack(RackNum).EvapWaterTankDemandARRID);
    2940              :             }
    2941              : 
    2942              :             // Check condenser air inlet node connection
    2943            5 :             if (lAlphaBlanks(12)) {
    2944            5 :                 RefrigRack(RackNum).OutsideAirNodeNum = 0;
    2945              :             } else {
    2946            0 :                 RefrigRack(RackNum).OutsideAirNodeNum =
    2947            0 :                     NodeInputManager::GetOnlySingleNode(state,
    2948            0 :                                                         Alphas(12),
    2949              :                                                         ErrorsFound,
    2950              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2951            0 :                                                         Alphas(1),
    2952              :                                                         DataLoopNode::NodeFluidType::Air,
    2953              :                                                         DataLoopNode::ConnectionType::OutsideAirReference,
    2954              :                                                         NodeInputManager::CompFluidStream::Primary,
    2955              :                                                         DataLoopNode::ObjectIsParent);
    2956            0 :                 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            5 :             if (!lAlphaBlanks(13)) {
    2970            0 :                 RefrigRack(RackNum).EndUseSubcategory = Alphas(13);
    2971              :             }
    2972              : 
    2973              :             // Read all loads on this rack: cases and walk-ins and coils
    2974            5 :             NumCases = 0;
    2975            5 :             int NumCoils = 0;
    2976            5 :             NumWalkIns = 0;
    2977            5 :             RefrigRack(RackNum).NumCases = 0;
    2978            5 :             RefrigRack(RackNum).NumCoils = 0;
    2979            5 :             RefrigRack(RackNum).NumWalkIns = 0;
    2980            5 :             RefrigRack(RackNum).TotalRackLoad = 0.0;
    2981              : 
    2982              :             //   Read display case and walkin assignments for this rack
    2983            5 :             AlphaNum = 14;
    2984            5 :             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            5 :                 int CaseAndWalkInListNum = 0;
    2996            5 :                 int CaseNum = 0;
    2997            5 :                 int WalkInNum = 0;
    2998            5 :                 int CoilNum = 0;
    2999            5 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    3000            2 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    3001              :                 }
    3002            5 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    3003            3 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    3004              :                 }
    3005            5 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    3006            3 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    3007              :                 }
    3008            5 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    3009            0 :                     CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    3010              :                 }
    3011            5 :                 int NumNameMatches = 0;
    3012            5 :                 if (CaseAndWalkInListNum != 0) {
    3013            2 :                     ++NumNameMatches;
    3014              :                 }
    3015            5 :                 if (CaseNum != 0) {
    3016            2 :                     ++NumNameMatches;
    3017              :                 }
    3018            5 :                 if (WalkInNum != 0) {
    3019            1 :                     ++NumNameMatches;
    3020              :                 }
    3021            5 :                 if (CoilNum != 0) {
    3022            0 :                     ++NumNameMatches;
    3023              :                 }
    3024              : 
    3025            5 :                 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            5 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    3045            2 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    3046            2 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    3047            2 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    3048            2 :                     RefrigRack(RackNum).NumCoils = NumCoils;
    3049            2 :                     RefrigRack(RackNum).NumCases = NumCases;
    3050            2 :                     RefrigRack(RackNum).NumWalkIns = NumWalkIns;
    3051            2 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) {
    3052            2 :                         RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    3053              :                     }
    3054            2 :                     RefrigRack(RackNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    3055            2 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) {
    3056            2 :                         RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3057              :                     }
    3058            2 :                     RefrigRack(RackNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    3059            2 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) {
    3060            2 :                         RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3061              :                     }
    3062            2 :                     RefrigRack(RackNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    3063            3 :                 } 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            3 :                 } else if (CaseNum != 0) { // Name points to a case
    3071            2 :                     NumCases = 1;
    3072            2 :                     RefrigRack(RackNum).NumCases = 1;
    3073            2 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) {
    3074            2 :                         RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3075              :                     }
    3076            2 :                     RefrigRack(RackNum).CaseNum(NumCases) = CaseNum;
    3077            1 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    3078            1 :                     NumWalkIns = 1;
    3079            1 :                     RefrigRack(RackNum).NumWalkIns = 1;
    3080            1 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) {
    3081            1 :                         RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3082              :                     }
    3083            1 :                     RefrigRack(RackNum).WalkInNum(NumWalkIns) = WalkInNum;
    3084              :                 } // NumNameMatches /= 1
    3085              :             } // blank input for loads on rack
    3086              : 
    3087            5 :             if (NumCases > 0) {
    3088            6 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    3089            3 :                     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            3 :                     ++RefrigCase(caseID).NumSysAttach;
    3092              :                     // determine total capacity on rack
    3093            3 :                     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            5 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone && RefrigRack(RackNum).NumCases > 1 &&
    3098            5 :                     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            5 :             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            5 :             if (NumWalkIns > 0) {
    3128            6 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    3129            3 :                     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            3 :                     ++WalkIn(WalkInID).NumSysAttach;
    3132              :                     // determine total capacity on rack
    3133            3 :                     RefrigRack(RackNum).TotalRackLoad += WalkIn(WalkInID).DesignRatedCap;
    3134              :                 } // WalkInIndex=1,NumWalkIns
    3135              :             } // NumWalkins
    3136              : 
    3137            5 :             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            3 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    3140            3 :                     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            3 :                         RefrigRack(RackNum).HeatRejectionZoneNum = Util::FindItemInList(Alphas(15), state.dataHeatBal->Zone);
    3151            6 :                         RefrigRack(RackNum).HeatRejectionZoneNodeNum =
    3152            3 :                             DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigRack(RackNum).HeatRejectionZoneNum);
    3153            3 :                         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            3 :                             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            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3172            0 :                 RefrigRack(RackNum).EvapPumpPower == Constant::AutoCalculate) {
    3173            0 :                 RefrigRack(RackNum).EvapPumpPower = CondPumpRatePower * RefrigRack(RackNum).TotalRackLoad;
    3174              :             }
    3175              :             // autocalculate evap condenser air volume flow rate if needed
    3176            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3177            0 :                 RefrigRack(RackNum).CondenserAirFlowRate == Constant::AutoCalculate) {
    3178            0 :                 RefrigRack(RackNum).CondenserAirFlowRate = AirVolRateEvapCond * RefrigRack(RackNum).TotalRackLoad;
    3179              :             }
    3180              : 
    3181              :         } // RackNum=1,NumRefrigeratedRacks
    3182              : 
    3183            5 :         state.dataRefrigCase->CheckEquipNameRackWaterCondenser.dimension(state.dataRefrigCase->NumRefrigeratedRacks, true);
    3184              :     } //(NumRefrigeratedRacks > 0)
    3185              : 
    3186          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0 || state.dataRefrigCase->NumTransRefrigSystems > 0) {
    3187              : 
    3188            0 :         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            0 :         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            0 :         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            0 :         if (state.dataRefrigCase->NumSimulationCondAir > 0) {
    3212            0 :             CurrentModuleObject = "Refrigeration:Condenser:AirCooled";
    3213            0 :             for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumSimulationCondAir; ++CondNum) {
    3214            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3228              : 
    3229            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3230            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3231            0 :                 Condenser(CondNum).Name = Alphas(1);
    3232            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3233            0 :                 Condenser(CondNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3234            0 :                 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            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3247            0 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3248            0 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3249              :                 }
    3250              : 
    3251              :                 // set CondenserType and rated temperature difference (51.7 - 35)C per ARI 460
    3252            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3253            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3254            0 :                 Condenser(CondNum).RatedDelT = CondARI460DelT; //= 16.7d0 ,Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
    3255            0 :                 Condenser(CondNum).RatedTCondense = CondARI460Tcond;
    3256            0 :                 if (Condenser(CondNum).CapCurvePtr > 0) {
    3257            0 :                     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            0 :                 Condenser(CondNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3261            0 :                 if (Condenser(CondNum).RatedCapacity > 0.0) {
    3262            0 :                     Curve::GetCurveMinMaxValues(state, Condenser(CondNum).CapCurvePtr, DelTempMin, DelTempMax);
    3263            0 :                     Real64 Capmin = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMin) *
    3264            0 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug fix
    3265            0 :                     Real64 Capmax = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMax) *
    3266            0 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug
    3267            0 :                     Condenser(CondNum).TempSlope =
    3268            0 :                         (DelTempMax - DelTempMin) / ((Capmax - Capmin)); // * ( 1.0 - 7.17e-5 * Elevation ) ) //Mar 2011 bug fix
    3269            0 :                     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            0 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3281            0 :                 if (!lNumericBlanks(1)) {
    3282            0 :                     Condenser(CondNum).RatedSubcool = Numbers(1);
    3283              :                 }
    3284              : 
    3285              :                 // Get fan control type
    3286            0 :                 if (lAlphaBlanks(3)) {
    3287            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3288            0 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3289            0 :                                 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            0 :                 if (!lNumericBlanks(2)) {
    3295            0 :                     Condenser(CondNum).RatedFanPower = Numbers(2);
    3296              :                 }
    3297            0 :                 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            0 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3308            0 :                 if (!lNumericBlanks(3)) {
    3309            0 :                     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            0 :                 Condenser(CondNum).CondenserRejectHeatToZone = false;
    3315            0 :                 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            0 :                     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            0 :                     if (Condenser(CondNum).InletAirZoneNum != 0) {
    3322              :                         // set condenser flag (later used to set system flag) and zone flag
    3323            0 :                         Condenser(CondNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, Condenser(CondNum).InletAirZoneNum);
    3324            0 :                         Condenser(CondNum).CondenserRejectHeatToZone = true;
    3325            0 :                         state.dataRefrigCase->RefrigPresentInZone(Condenser(CondNum).InletAirZoneNum) = true;
    3326              :                     } else { // not in a conditioned zone, so see if it's outside
    3327            0 :                         Condenser(CondNum).InletAirNodeNum =
    3328            0 :                             NodeInputManager::GetOnlySingleNode(state,
    3329            0 :                                                                 Alphas(4),
    3330              :                                                                 ErrorsFound,
    3331              :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationCondenserAirCooled,
    3332            0 :                                                                 Alphas(1),
    3333              :                                                                 DataLoopNode::NodeFluidType::Air,
    3334              :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    3335              :                                                                 NodeInputManager::CompFluidStream::Primary,
    3336              :                                                                 DataLoopNode::ObjectIsParent);
    3337            0 :                         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            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3353            0 :                 if (!lAlphaBlanks(5)) {
    3354            0 :                     Condenser(CondNum).EndUseSubcategory = Alphas(5);
    3355              :                 }
    3356              : 
    3357            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3358            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3359            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3360            0 :                 if (!lNumericBlanks(4)) {
    3361            0 :                     Condenser(CondNum).RefOpCharge = Numbers(4);
    3362              :                 }
    3363            0 :                 if (!lNumericBlanks(5)) {
    3364            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3365              :                 }
    3366            0 :                 if (!lNumericBlanks(6)) {
    3367            0 :                     Condenser(CondNum).RefPipingInventory = Numbers(6);
    3368              :                 }
    3369              : 
    3370              :             } // Read input for REFRIGERATION:Condenser:AirCooled
    3371              :         } // NumSimulationCondAir > 0
    3372              : 
    3373            0 :         if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
    3374            0 :             CurrentModuleObject = "Refrigeration:Condenser:EvaporativeCooled";
    3375            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondEvap; ++CondIndex) {
    3376            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir;
    3377            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3391              : 
    3392            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3393            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3394            0 :                 Condenser(CondNum).Name = Alphas(1);
    3395            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3396              : 
    3397              :                 // set start of count for number of systems attached to this condenser
    3398            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3399            0 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3400            0 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3401              :                 }
    3402              : 
    3403              :                 // set CondenserType and rated Heat Rejection per ARI 490 rating
    3404            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    3405            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3406            0 :                 Condenser(CondNum).RatedTCondense = CondARI490Tcond;
    3407            0 :                 Condenser(CondNum).RatedDelT = CondARI490DelT;
    3408              : 
    3409            0 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3410            0 :                     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            0 :                 Condenser(CondNum).EvapElevFact = 1.0 - 3.074e-5 * state.dataEnvrn->Elevation;
    3422              : 
    3423            0 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3424            0 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3425            0 :                     Condenser(CondNum).RatedSubcool = Numbers(2);
    3426              :                 }
    3427              : 
    3428              :                 // Get fan control type
    3429            0 :                 if (lAlphaBlanks(2)) {
    3430            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3431            0 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3432            0 :                                 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            0 :                 Condenser(CondNum).RatedFanPower = Numbers(3);
    3438            0 :                 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            0 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3449            0 :                 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            0 :                 Condenser(CondNum).EvapCoeff1 = 6.63;
    3457            0 :                 Condenser(CondNum).EvapCoeff2 = 0.468;
    3458            0 :                 Condenser(CondNum).EvapCoeff3 = 17.93;
    3459            0 :                 Condenser(CondNum).EvapCoeff4 = -0.322;
    3460            0 :                 Condenser(CondNum).MinCapFacEvap = 0.5;
    3461            0 :                 Condenser(CondNum).MaxCapFacEvap = 5.0;
    3462            0 :                 NumNum = 5; // added warnings if below not blank but unused due to limits
    3463            0 :                 if (!lNumericBlanks(NumNum)) {
    3464            0 :                     if (Numbers(NumNum) >= 0.0) {
    3465            0 :                         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            0 :                 NumNum = 6; // EvapCoeff2 can't be equal to 0 because used in a denominator
    3475            0 :                 if (!lNumericBlanks(NumNum)) {
    3476            0 :                     if (Numbers(NumNum) > 0.0) {
    3477            0 :                         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            0 :                 NumNum = 7;
    3487            0 :                 if (!lNumericBlanks(NumNum)) {
    3488            0 :                     if (Numbers(NumNum) >= 0.0) {
    3489            0 :                         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            0 :                 NumNum = 8;
    3499            0 :                 if (!lNumericBlanks(NumNum)) {
    3500            0 :                     if (Numbers(NumNum) >= -20.0) {
    3501            0 :                         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            0 :                 NumNum = 9;
    3511            0 :                 if (!lNumericBlanks(NumNum)) {
    3512            0 :                     if (Numbers(NumNum) >= 0.0) {
    3513            0 :                         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            0 :                 NumNum = 10;
    3523            0 :                 if (!lNumericBlanks(NumNum)) {
    3524            0 :                     if (Numbers(NumNum) >= 0.0) {
    3525            0 :                         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            0 :                 if (lAlphaBlanks(3)) {
    3537            0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3538              :                 } else {
    3539            0 :                     Condenser(CondNum).InletAirNodeNum =
    3540            0 :                         NodeInputManager::GetOnlySingleNode(state,
    3541            0 :                                                             Alphas(3),
    3542              :                                                             ErrorsFound,
    3543              :                                                             DataLoopNode::ConnectionObjectType::RefrigerationCondenserEvaporativeCooled,
    3544            0 :                                                             Alphas(1),
    3545              :                                                             DataLoopNode::NodeFluidType::Air,
    3546              :                                                             DataLoopNode::ConnectionType::OutsideAirReference,
    3547              :                                                             NodeInputManager::CompFluidStream::Primary,
    3548              :                                                             DataLoopNode::ObjectIsParent);
    3549            0 :                     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            0 :                 NumNum = 11;
    3563            0 :                 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            0 :                 NumNum = 12;
    3569            0 :                 Condenser(CondNum).BasinHeaterPowerFTempDiff = Numbers(NumNum);
    3570            0 :                 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            0 :                 NumNum = 13;
    3579            0 :                 Condenser(CondNum).BasinHeaterSetPointTemp = 2.0; // default
    3580            0 :                 if (!lNumericBlanks(NumNum)) {
    3581            0 :                     Condenser(CondNum).BasinHeaterSetPointTemp = Numbers(NumNum);
    3582              :                 }
    3583            0 :                 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            0 :                 NumNum = 14;
    3592            0 :                 Condenser(CondNum).EvapPumpPower = 1000.0; // default
    3593            0 :                 if (!lNumericBlanks(NumNum)) {
    3594            0 :                     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            0 :                 Condenser(CondNum).SupplyTankName = Alphas(4);
    3601            0 :                 if (lAlphaBlanks(4)) {
    3602            0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    3603              :                 } else {
    3604            0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    3605            0 :                     WaterManager::SetupTankDemandComponent(state,
    3606            0 :                                                            Condenser(CondNum).Name,
    3607              :                                                            CurrentModuleObject,
    3608            0 :                                                            Condenser(CondNum).SupplyTankName,
    3609              :                                                            ErrorsFound,
    3610            0 :                                                            Condenser(CondNum).EvapWaterSupTankID,
    3611            0 :                                                            Condenser(CondNum).EvapWaterTankDemandARRID);
    3612              :                 }
    3613              : 
    3614            0 :                 if (lAlphaBlanks(5)) {
    3615            0 :                 } 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            0 :                 } 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            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3624            0 :                 if (!lAlphaBlanks(6)) {
    3625            0 :                     Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3626              :                 }
    3627              : 
    3628            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3629            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3630            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3631            0 :                 NumNum = 15;
    3632            0 :                 if (!lNumericBlanks(NumNum)) {
    3633            0 :                     Condenser(CondNum).RefOpCharge = Numbers(NumNum);
    3634              :                 }
    3635            0 :                 NumNum = 16;
    3636            0 :                 if (!lNumericBlanks(NumNum)) {
    3637            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(NumNum);
    3638              :                 }
    3639            0 :                 NumNum = 17;
    3640            0 :                 if (!lNumericBlanks(NumNum)) {
    3641            0 :                     Condenser(CondNum).RefPipingInventory = Numbers(NumNum);
    3642              :                 }
    3643              :             } // Read input for CONDENSER:REFRIGERATION:EVAPorativeCooled
    3644              :         } // If NumSimulationCondEvap > 0
    3645              : 
    3646            0 :         if (state.dataRefrigCase->NumSimulationCondWater > 0) {
    3647            0 :             CurrentModuleObject = "Refrigeration:Condenser:WaterCooled";
    3648            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondWater; ++CondIndex) {
    3649            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap;
    3650            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3664              : 
    3665            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3666            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3667            0 :                 Condenser(CondNum).Name = Alphas(1);
    3668            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3669              : 
    3670              :                 // set start of count for number of systems attached to this condenser
    3671            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3672            0 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3673            0 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3674              :                 }
    3675              : 
    3676              :                 // set CondenserType and rated Heat Rejection per ARI 450 rating
    3677            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    3678            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3679            0 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3680            0 :                     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            0 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3692            0 :                     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            0 :                 if (!lNumericBlanks(3)) {
    3704            0 :                     if (Numbers(3) >= 0.0) {
    3705            0 :                         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            0 :                 if ((!lNumericBlanks(4)) && (Numbers(4) > 0.0)) {
    3720            0 :                     Condenser(CondNum).RatedWaterInletT = Numbers(4);
    3721            0 :                     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            0 :                 Condenser(CondNum).InletNode =
    3733            0 :                     NodeInputManager::GetOnlySingleNode(state,
    3734            0 :                                                         Alphas(2),
    3735              :                                                         ErrorsFound,
    3736              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3737            0 :                                                         Alphas(1),
    3738              :                                                         DataLoopNode::NodeFluidType::Water,
    3739              :                                                         DataLoopNode::ConnectionType::Inlet,
    3740              :                                                         NodeInputManager::CompFluidStream::Primary,
    3741              :                                                         DataLoopNode::ObjectIsNotParent);
    3742            0 :                 Condenser(CondNum).OutletNode =
    3743            0 :                     NodeInputManager::GetOnlySingleNode(state,
    3744            0 :                                                         Alphas(3),
    3745              :                                                         ErrorsFound,
    3746              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3747            0 :                                                         Alphas(1),
    3748              :                                                         DataLoopNode::NodeFluidType::Water,
    3749              :                                                         DataLoopNode::ConnectionType::Outlet,
    3750              :                                                         NodeInputManager::CompFluidStream::Primary,
    3751              :                                                         DataLoopNode::ObjectIsNotParent);
    3752              :                 // Check node connections
    3753            0 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Water Cooled Condenser Nodes");
    3754              :                 // Get loop flow type
    3755            0 :                 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            0 :                 if (Condenser(CondNum).FlowType == CndsrFlowType::Variable) {
    3764            0 :                     if (lAlphaBlanks(5)) {
    3765            0 :                     } 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            0 :                 if (Numbers(6) > 0.0) {
    3791            0 :                     Condenser(CondNum).VolFlowRateMax = Numbers(6);
    3792              :                     // Check constant flow for max violation, if applicable
    3793            0 :                     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            0 :                 Condenser(CondNum).OutletTempMax = Numbers(7);
    3816            0 :                 Condenser(CondNum).InletTempMin = Numbers(8);
    3817              : 
    3818            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3819            0 :                 if (!lAlphaBlanks(6)) {
    3820            0 :                     Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3821              :                 }
    3822              : 
    3823            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3824            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3825            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3826            0 :                 if (!lNumericBlanks(9)) {
    3827            0 :                     Condenser(CondNum).RefOpCharge = Numbers(9);
    3828              :                 }
    3829            0 :                 if (!lNumericBlanks(10)) {
    3830            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(10);
    3831              :                 }
    3832            0 :                 if (!lNumericBlanks(11)) {
    3833            0 :                     Condenser(CondNum).RefPipingInventory = Numbers(11);
    3834              :                 }
    3835              : 
    3836              :             } // Read input for CONDENSER:REFRIGERATION:WaterCooled
    3837              : 
    3838            0 :             state.dataRefrigCase->CheckEquipNameWaterCondenser.dimension(state.dataRefrigCase->NumRefrigCondensers, true);
    3839              :         } // NumSimulationCondWater > 0
    3840              : 
    3841              :         // cascade condensers assumed to provide zero subcooling
    3842            0 :         if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
    3843            0 :             CurrentModuleObject = "Refrigeration:Condenser:Cascade";
    3844            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCascadeCondensers; ++CondIndex) {
    3845            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
    3846            0 :                               state.dataRefrigCase->NumSimulationCondWater;
    3847            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3861              : 
    3862            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3863            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3864            0 :                 Condenser(CondNum).Name = Alphas(1);
    3865            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3866              : 
    3867              :                 // set start of count for number of systems attached to this condenser
    3868            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3869            0 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3870            0 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3871              :                 }
    3872              : 
    3873              :                 // set CondenserType
    3874            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Cascade;
    3875              : 
    3876            0 :                 if (!lNumericBlanks(1)) {
    3877            0 :                     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            0 :                 if (!lNumericBlanks(2)) {
    3886            0 :                     if (Numbers(2) >= 0.0) {
    3887            0 :                         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            0 :                 if ((!lNumericBlanks(3)) && (Numbers(3) > 0.0)) {
    3902            0 :                     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            0 :                 if (lAlphaBlanks(2)) {
    3915            0 :                     Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempSet;
    3916            0 :                 } else if ((Condenser(CondNum).CascadeTempControl = static_cast<CascadeCndsrTempCtrlType>(
    3917            0 :                                 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            0 :                 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            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3926            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3927            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3928            0 :                 if (!lNumericBlanks(4)) {
    3929            0 :                     Condenser(CondNum).RefOpCharge = Numbers(4);
    3930              :                 }
    3931            0 :                 if (!lNumericBlanks(5)) {
    3932            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3933              :                 }
    3934            0 :                 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            0 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    3946            0 :             CurrentModuleObject = "Refrigeration:GasCooler:AirCooled";
    3947            0 :             for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    3948            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3961              : 
    3962            0 :                 GasCooler(GCNum).Name = Alphas(1);
    3963              : 
    3964            0 :                 GasCooler(GCNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3965            0 :                 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            0 :                 GasCooler(GCNum).NumSysAttach = 0;
    3972            0 :                 if (!allocated(GasCooler(GCNum).SysNum)) {
    3973            0 :                     GasCooler(GCNum).SysNum.allocate(state.dataRefrigCase->NumTransRefrigSystems);
    3974              :                 }
    3975              : 
    3976            0 :                 GasCooler(GCNum).RatedApproachT = 3.0; // rated CO2 gas cooler approach temperature
    3977            0 :                 if (GasCooler(GCNum).CapCurvePtr > 0) {
    3978            0 :                     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            0 :                 GasCooler(GCNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3982            0 :                 if (GasCooler(GCNum).RatedCapacity > 0.0) {
    3983            0 :                     Curve::GetCurveMinMaxValues(state, GasCooler(GCNum).CapCurvePtr, DelTempMin, DelTempMax);
    3984            0 :                     Real64 Capmin = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMin) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3985            0 :                     Real64 Capmax = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMax) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3986            0 :                     GasCooler(GCNum).TempSlope = (DelTempMax - DelTempMin) / ((Capmax - Capmin));
    3987            0 :                     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            0 :                 if (lAlphaBlanks(3)) {
    4000            0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    4001            0 :                 } 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            0 :                 GasCooler(GCNum).RatedFanPower = 5000.0; // default value
    4009            0 :                 if (!lNumericBlanks(1)) {
    4010            0 :                     GasCooler(GCNum).RatedFanPower = Numbers(1);
    4011              :                 }
    4012            0 :                 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            0 :                 GasCooler(GCNum).FanMinAirFlowRatio = 0.2; // default value
    4024            0 :                 if (!lNumericBlanks(2)) {
    4025            0 :                     GasCooler(GCNum).FanMinAirFlowRatio = Numbers(2);
    4026              :                 }
    4027            0 :                 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            0 :                 GasCooler(GCNum).TransitionTemperature = 2.7e1; // default value
    4039            0 :                 if (!lNumericBlanks(3)) {
    4040            0 :                     GasCooler(GCNum).TransitionTemperature = Numbers(3);
    4041              :                 }
    4042            0 :                 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            0 :                 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            0 :                 GasCooler(GCNum).GasCoolerApproachT = 3.0; // default value
    4064            0 :                 if (!lNumericBlanks(4)) {
    4065            0 :                     GasCooler(GCNum).GasCoolerApproachT = Numbers(4);
    4066              :                 }
    4067            0 :                 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            0 :                 GasCooler(GCNum).SubcriticalTempDiff = 1.0e1; // default value
    4079            0 :                 if (!lNumericBlanks(5)) {
    4080            0 :                     GasCooler(GCNum).SubcriticalTempDiff = Numbers(5);
    4081              :                 }
    4082            0 :                 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            0 :                 GasCooler(GCNum).MinCondTemp = 1.0e1; // default value
    4094            0 :                 if (!lNumericBlanks(6)) {
    4095            0 :                     GasCooler(GCNum).MinCondTemp = Numbers(6);
    4096              :                 }
    4097            0 :                 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            0 :                 GasCooler(GCNum).GasCoolerRejectHeatToZone = false;
    4109            0 :                 if (lAlphaBlanks(4)) {
    4110            0 :                     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            0 :                 GasCooler(GCNum).EndUseSubcategory = "";
    4141            0 :                 if (!lAlphaBlanks(5)) {
    4142            0 :                     GasCooler(GCNum).EndUseSubcategory = Alphas(5);
    4143              :                 }
    4144              : 
    4145            0 :                 GasCooler(GCNum).RefOpCharge = 0.0;
    4146            0 :                 GasCooler(GCNum).RefReceiverInventory = 0.0;
    4147            0 :                 GasCooler(GCNum).RefPipingInventory = 0.0;
    4148            0 :                 if (!lNumericBlanks(7)) {
    4149            0 :                     GasCooler(GCNum).RefOpCharge = Numbers(7);
    4150              :                 }
    4151            0 :                 if (!lNumericBlanks(8)) {
    4152            0 :                     GasCooler(GCNum).RefReceiverInventory = Numbers(8);
    4153              :                 }
    4154            0 :                 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            0 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    4165            0 :             CurrentModuleObject = "Refrigeration:SecondarySystem";
    4166            0 :             for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    4167            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4181            0 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4182              : 
    4183            0 :                 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            0 :                 Real64 NominalTotalCaseCap = 0.0;
    4187            0 :                 NumCases = 0;
    4188            0 :                 Real64 NominalTotalCoilCap = 0.0;
    4189            0 :                 int NumCoils = 0;
    4190            0 :                 NumWalkIns = 0;
    4191            0 :                 Real64 NominalTotalWalkInCap = 0.0;
    4192            0 :                 Secondary(SecondaryNum).RefInventory = 0.0;
    4193              : 
    4194              :                 //   Read display case and walkin assignments for this secondary
    4195            0 :                 AlphaNum = 2;
    4196            0 :                 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            0 :                     int CaseAndWalkInListNum = 0;
    4209            0 :                     int CaseNum = 0;
    4210            0 :                     int WalkInNum = 0;
    4211            0 :                     int CoilNum = 0;
    4212            0 :                     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    4213            0 :                         CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    4214              :                     }
    4215            0 :                     if (state.dataRefrigCase->NumSimulationCases > 0) {
    4216            0 :                         CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    4217              :                     }
    4218            0 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    4219            0 :                         WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    4220              :                     }
    4221            0 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    4222            0 :                         CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    4223              :                     }
    4224            0 :                     int NumNameMatches = 0;
    4225            0 :                     if (CaseAndWalkInListNum != 0) {
    4226            0 :                         ++NumNameMatches;
    4227              :                     }
    4228            0 :                     if (CaseNum != 0) {
    4229            0 :                         ++NumNameMatches;
    4230              :                     }
    4231            0 :                     if (WalkInNum != 0) {
    4232            0 :                         ++NumNameMatches;
    4233              :                     }
    4234            0 :                     if (CoilNum != 0) {
    4235            0 :                         ++NumNameMatches;
    4236              :                     }
    4237              : 
    4238            0 :                     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            0 :                     } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    4258            0 :                         NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    4259            0 :                         NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    4260            0 :                         NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    4261            0 :                         Secondary(SecondaryNum).NumCases = NumCases;
    4262            0 :                         Secondary(SecondaryNum).NumCoils = NumCoils;
    4263            0 :                         Secondary(SecondaryNum).NumWalkIns = NumWalkIns;
    4264            0 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) {
    4265            0 :                             Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4266              :                         }
    4267            0 :                         Secondary(SecondaryNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    4268            0 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) {
    4269            0 :                             Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4270              :                         }
    4271            0 :                         Secondary(SecondaryNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    4272            0 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) {
    4273            0 :                             Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4274              :                         }
    4275            0 :                         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            0 :                 if (NumCases > 0) {
    4301              :                     // Find lowest design T loop fluid out of secondary chiller
    4302              :                     // Sum rated capacity of all cases on Secondary
    4303            0 :                     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            0 :                         int CaseNum = Secondary(SecondaryNum).CaseNum(caseIndex);
    4306            0 :                         ++RefrigCase(CaseNum).NumSysAttach;
    4307            0 :                         NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedRTF;
    4308            0 :                         Secondary(SecondaryNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    4309            0 :                         if (caseIndex == 1) { // look for lowest case design evap T for Secondary
    4310            0 :                             Secondary(SecondaryNum).TMinNeeded = RefrigCase(CaseNum).EvapTempDesign;
    4311              :                         } else {
    4312            0 :                             Secondary(SecondaryNum).TMinNeeded = min(RefrigCase(CaseNum).EvapTempDesign, Secondary(SecondaryNum).TMinNeeded);
    4313              :                         }
    4314              :                     } // CaseIndex=1,NumCases
    4315              :                 } // Numcases > 0
    4316              : 
    4317            0 :                 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            0 :                 if (NumWalkIns > 0) {
    4335              :                     // Find lowest design T loop fluid out of secondary chiller
    4336              :                     // Sum rated capacity of all WalkIns on Secondary
    4337            0 :                     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            0 :                         int WalkInID = Secondary(SecondaryNum).WalkInNum(WalkInIndex);
    4340            0 :                         ++WalkIn(WalkInID).NumSysAttach;
    4341            0 :                         NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    4342            0 :                         Secondary(SecondaryNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    4343            0 :                         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            0 :                             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            0 :                 AlphaNum = 3;
    4353            0 :                 if (lAlphaBlanks(AlphaNum)) {
    4354            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4355            0 :                     ErrorsFound = true;
    4356            0 :                 } 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            0 :                 AlphaNum = 4;
    4363            0 :                 Secondary(SecondaryNum).FluidName = Alphas(AlphaNum);
    4364            0 :                 if (Secondary(SecondaryNum).FluidName.empty()) {
    4365            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4366            0 :                     ErrorsFound = true;
    4367            0 :                 } else if ((Secondary(SecondaryNum).glycol = Fluid::GetGlycol(state, Secondary(SecondaryNum).FluidName)) != nullptr) {
    4368            0 :                 } 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            0 :                 if (!lNumericBlanks(3)) {
    4380            0 :                     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            0 :                 if (!lNumericBlanks(4)) {
    4392            0 :                     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            0 :                 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            0 :                 Real64 CpBrineRated = 0.0;
    4414            0 :                 Real64 PumpTotRatedFlowVol(0.0);   // Rated flow from input pump data, m3/s
    4415            0 :                 Real64 SecondaryFlowVolRated(0.0); // Rated flow of secondary fluid, used to calculate capacity (m3/s)
    4416            0 :                 Real64 TBrineOutRated(0.0);        // Rated temperature of circ fluid LEAVING heat exchanger,C
    4417            0 :                 Real64 TBrineInRated(0.0);         // Rated temperature of circ fluid going INTO heat exchanger, C
    4418              : 
    4419            0 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4420            0 :                     if (!lNumericBlanks(5)) {
    4421            0 :                         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            0 :                     TBrineOutRated = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4435            0 :                     TBrineInRated = TBrineOutRated + Secondary(SecondaryNum).TRangeDifRated;
    4436            0 :                     Real64 TBrineAverage = (TBrineOutRated + TBrineInRated) / 2.0;
    4437            0 :                     Secondary(SecondaryNum).TBrineAverage = TBrineAverage;
    4438            0 :                     DensityBrineRated = Secondary(SecondaryNum).glycol->getDensity(state, TBrineAverage, TrackMessage);
    4439            0 :                     Secondary(SecondaryNum).DensityBrineRated = DensityBrineRated;
    4440            0 :                     CpBrineRated = Secondary(SecondaryNum).glycol->getSpecificHeat(state, TBrineAverage, TrackMessage);
    4441            0 :                     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            0 :                     Real64 FlowMassRated(0.0); // Design mass flow rate of circ fluid in secondary loop(kg/s)
    4447            0 :                     if ((!lNumericBlanks(1)) && (!lNumericBlanks(2))) {
    4448              :                         // Both values input, check for approximate agreement
    4449            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4450            0 :                         SecondaryFlowVolRated = Numbers(2);
    4451            0 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4452            0 :                         Real64 NominalSecondaryCapacity = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4453            0 :                         Real64 TestDelta = (NominalSecondaryCapacity - Secondary(SecondaryNum).CoolingLoadRated) / NominalSecondaryCapacity;
    4454            0 :                         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            0 :                     if (!ErrorsFound) {
    4486              :                         // Calculate heat exchanger effectiveness based on rated flow and temperature differences
    4487            0 :                         Secondary(SecondaryNum).HeatExchangeEta =
    4488            0 :                             Secondary(SecondaryNum).CoolingLoadRated /
    4489            0 :                             (FlowMassRated * CpBrineRated * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign));
    4490            0 :                         Secondary(SecondaryNum).TBrineInRated = TBrineInRated;
    4491            0 :                         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            0 :                     PumpTotRatedFlowVol = SecondaryFlowVolRated;
    4506            0 :                     if (!lNumericBlanks(7)) {
    4507            0 :                         PumpTotRatedFlowVol = Numbers(7);
    4508              :                     }
    4509              : 
    4510              :                 } else { // FluidType = FluidTypePhaseChange     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4511            0 :                     if (!lNumericBlanks(1)) {
    4512            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4513              :                     } else {
    4514            0 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalTotalCaseCap + NominalTotalWalkInCap;
    4515              :                         // first estimate, will later be adjusted to include pump power
    4516              :                     } // input capacity
    4517              : 
    4518            0 :                     Secondary(SecondaryNum).TCondense = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4519            0 :                     Secondary(SecondaryNum).CircRate = DefaultCircRate;
    4520            0 :                     if (!lNumericBlanks(10)) {
    4521            0 :                         Secondary(SecondaryNum).CircRate = Numbers(10);
    4522              :                     }
    4523              : 
    4524              :                     DensityPhaseChange =
    4525            0 :                         Secondary(SecondaryNum).refrig->getSatDensity(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4526            0 :                     DeltaHPhaseChange =
    4527            0 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 1.0, TrackMessageAlt) -
    4528            0 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4529              : 
    4530              :                     // TotRatedFlowVol= capacity*circrate/deltahphasechange/density
    4531              :                     Real64 CalcTotFlowVol =
    4532            0 :                         Secondary(SecondaryNum).CoolingLoadRated * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4533            0 :                     PumpTotRatedFlowVol = CalcTotFlowVol;
    4534            0 :                     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            0 :                     SecondaryFlowVolRated = PumpTotRatedFlowVol;
    4552              : 
    4553              :                 } // fluid type AlwaysLiquid or PhaseChange ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4554              : 
    4555              :                 // Read number of pumps (or pump stages) in secondary loop
    4556            0 :                 int NumPumps = 1; // default value
    4557            0 :                 if ((!lNumericBlanks(6)) && (Numbers(6) >= 1)) {
    4558            0 :                     NumPumps = Numbers(6);
    4559              :                 }
    4560            0 :                 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            0 :                 Real64 PumpTotRatedHead(0.0); // Total pump rated head on secondary loop (Pa)
    4566              : 
    4567            0 :                 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            0 :                 } else if (!lNumericBlanks(8)) {
    4584            0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4585            0 :                 } else if (!lNumericBlanks(9)) {
    4586            0 :                     PumpTotRatedHead = Numbers(9);
    4587            0 :                     Secondary(SecondaryNum).PumpTotRatedPower =
    4588            0 :                         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            0 :                 AlphaNum = 5;
    4602            0 :                 if (lAlphaBlanks(AlphaNum)) {
    4603            0 :                     Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Constant; // default
    4604            0 :                 } 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            0 :                 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            0 :                 if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4625              :                     // Set incremental flow and power amounts for pump dispatch
    4626            0 :                     Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4627            0 :                     Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4628              :                 } else { // Variable speed drive need to read in power curve
    4629            0 :                     AlphaNum = 6;
    4630            0 :                     Secondary(SecondaryNum).VarSpeedCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    4631            0 :                     if (Secondary(SecondaryNum).VarSpeedCurvePtr == 0) {
    4632            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4633            0 :                         ErrorsFound = true;
    4634              :                     }
    4635            0 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    4636            0 :                                                          Secondary(SecondaryNum).VarSpeedCurvePtr, // Curve index
    4637              :                                                          {1},                                      // Valid dimensions
    4638              :                                                          RoutineName,                              // Routine name
    4639              :                                                          CurrentModuleObject,                      // Object Type
    4640            0 :                                                          Secondary(SecondaryNum).Name,             // Object Name
    4641            0 :                                                          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            0 :                 Secondary(SecondaryNum).PumpPowerToHeat = PumpMotorEfficiency;
    4647            0 :                 NumNum = 11;
    4648            0 :                 if (!lNumericBlanks(NumNum)) {
    4649            0 :                     if ((0.5 <= Numbers(NumNum)) && (1.0 >= Numbers(NumNum))) {
    4650            0 :                         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            0 :                 Secondary(SecondaryNum).SumUADistPiping = 0.0;
    4668            0 :                 AlphaNum = 7;
    4669            0 :                 NumNum = 12;
    4670            0 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4671            0 :                     Secondary(SecondaryNum).SumUADistPiping = Numbers(NumNum);
    4672            0 :                     Secondary(SecondaryNum).DistPipeZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4673            0 :                     Secondary(SecondaryNum).DistPipeZoneNodeNum =
    4674            0 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).DistPipeZoneNum);
    4675              : 
    4676            0 :                     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            0 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).DistPipeZoneNum) = true;
    4687              :                     }
    4688              : 
    4689            0 :                     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            0 :                 Secondary(SecondaryNum).SumUAReceiver = 0.0;
    4730            0 :                 AlphaNum = 8;
    4731            0 :                 NumNum = 13;
    4732            0 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4733            0 :                     Secondary(SecondaryNum).SumUAReceiver = Numbers(NumNum);
    4734            0 :                     Secondary(SecondaryNum).ReceiverZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4735            0 :                     Secondary(SecondaryNum).ReceiverZoneNodeNum =
    4736            0 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).ReceiverZoneNum);
    4737              : 
    4738            0 :                     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            0 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).ReceiverZoneNum) = true;
    4749              :                     }
    4750            0 :                     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            0 :                 } 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            0 :                 } 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            0 :                 NumNum = 14;
    4785            0 :                 Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    4786            0 :                 if (!lNumericBlanks(NumNum)) {
    4787            0 :                     Secondary(SecondaryNum).ChillerRefInventory = Numbers(NumNum);
    4788              :                 }
    4789            0 :                 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            0 :                 AlphaNum = 9;
    4800            0 :                 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            0 :                 Secondary(SecondaryNum).MaxVolFlow = min(SecondaryFlowVolRated, PumpTotRatedFlowVol);
    4809            0 :                 Real64 NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4810              : 
    4811            0 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4812            0 :                     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            0 :                     Real64 CapacityAtMaxVolFlow = Secondary(SecondaryNum).MaxVolFlow * Secondary(SecondaryNum).HeatExchangeEta *
    4826            0 :                                                   (CpBrineRated * DensityBrineRated) * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign);
    4827            0 :                     Secondary(SecondaryNum).MaxLoad = min(Secondary(SecondaryNum).CoolingLoadRated, CapacityAtMaxVolFlow);
    4828              :                     Real64 DeltaCap1 =
    4829            0 :                         std::abs((Secondary(SecondaryNum).CoolingLoadRated - CapacityAtMaxVolFlow) / Secondary(SecondaryNum).CoolingLoadRated);
    4830            0 :                     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            0 :                     if (lNumericBlanks(1)) {     // Chiller/evaporator capacity was not specified
    4841            0 :                         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            0 :                             PumpTotRatedFlowVol =
    4845            0 :                                 NominalSecondaryRefLoad * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4846            0 :                             Secondary(SecondaryNum).PumpTotRatedPower =
    4847            0 :                                 PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4848              :                             // need to recalc nominal load with new pump power value
    4849            0 :                             NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4850            0 :                             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            0 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalSecondaryRefLoad;
    4857              :                     } // Chiller/evap capacity was not specified
    4858            0 :                     Secondary(SecondaryNum).MaxLoad = Secondary(SecondaryNum).CoolingLoadRated;
    4859              :                 } // SecFluidType
    4860              : 
    4861              :                 Real64 DeltaCap2 =
    4862            0 :                     std::abs((Secondary(SecondaryNum).CoolingLoadRated - NominalSecondaryRefLoad) / Secondary(SecondaryNum).CoolingLoadRated);
    4863            0 :                 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            0 :                 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            0 :         CurrentModuleObject = "Refrigeration:Compressor";
    4892            0 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    4893            0 :             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            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4906              : 
    4907            0 :             Compressor(CompNum).Name = Alphas(1);
    4908              : 
    4909            0 :             Compressor(CompNum).ElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    4910            0 :             if ((!lAlphaBlanks(2)) && Compressor(CompNum).ElecPowerCurvePtr == 0) {
    4911            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    4912            0 :                 ErrorsFound = true;
    4913              :             }
    4914              : 
    4915            0 :             Compressor(CompNum).CapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    4916            0 :             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            0 :             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            0 :             } else if (!lNumericBlanks(1)) {
    4933            0 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::Superheat;
    4934            0 :                 Compressor(CompNum).RatedSuperheat = Numbers(1);
    4935            0 :             } else if (!lNumericBlanks(2)) {
    4936            0 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::ReturnGasTemperature;
    4937            0 :                 Compressor(CompNum).RatedSuperheat = Numbers(2);
    4938              :             } // Set SuperheatRatingType
    4939              : 
    4940              :             // Get subcool rating type (Either N3 or N4 Must be input)
    4941            0 :             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            0 :             } else if (!lNumericBlanks(3)) {
    4952            0 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::LiquidTemperature;
    4953            0 :                 Compressor(CompNum).RatedSubcool = Numbers(3);
    4954            0 :             } else if (!lNumericBlanks(4)) {
    4955            0 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::Subcooling;
    4956            0 :                 Compressor(CompNum).RatedSubcool = Numbers(4);
    4957              :             } // Set SubcoolRatingType
    4958              : 
    4959            0 :             Compressor(CompNum).EndUseSubcategory = "General";
    4960            0 :             if (!lAlphaBlanks(4)) {
    4961            0 :                 Compressor(CompNum).EndUseSubcategory = Alphas(4);
    4962              :             }
    4963              : 
    4964              :             //  If the compressor is a transcritical CO compressor, get transcritical power and capacity curves
    4965            0 :             if (lAlphaBlanks(5)) {
    4966            0 :                 Compressor(CompNum).TransFlag = false;
    4967              :                 // For some reason, Alkphas(5) is not uppercased?
    4968            0 :             } else if (CriticalType crit = static_cast<CriticalType>(getEnumValue(criticalTypeNamesUC, Util::makeUPPER(Alphas(5))));
    4969              :                        crit != CriticalType::Invalid) {
    4970            0 :                 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            0 :             if (Compressor(CompNum).TransFlag) {
    4977            0 :                 if (lAlphaBlanks(6)) {
    4978            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(6));
    4979            0 :                     ErrorsFound = true;
    4980            0 :                 } 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            0 :                 if (lAlphaBlanks(7)) {
    4986            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(7));
    4987            0 :                     ErrorsFound = true;
    4988            0 :                 } 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            0 :                 if (!lAlphaBlanks(6)) {
    4994            0 :                     ShowWarningNonEmptyField(state, eoh, cAlphaFieldNames(6), cAlphaFieldNames(5), Alphas(5));
    4995              :                 }
    4996            0 :                 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            0 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    5007            0 :             CurrentModuleObject = "Refrigeration:Subcooler";
    5008            0 :             state.dataRefrigCase->NumSimulationMechSubcoolers = 0;
    5009            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    5010            0 :                 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            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    5023            0 :                 Subcooler(SubcoolerNum).Name = Alphas(1);
    5024              : 
    5025              :                 // Get subcooler type
    5026            0 :                 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            0 :                 } else if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::Mechanical) {
    5031            0 :                     ++state.dataRefrigCase->NumSimulationMechSubcoolers;
    5032              :                 }
    5033              : 
    5034            0 :                 switch (Subcooler(SubcoolerNum).subcoolerType) {
    5035            0 :                 case SubcoolerType::LiquidSuction: {
    5036            0 :                     Subcooler(SubcoolerNum).LiqSuctDesignDelT = 10.0; // default value
    5037            0 :                     if (!lNumericBlanks(1)) {
    5038            0 :                         Subcooler(SubcoolerNum).LiqSuctDesignDelT = Numbers(1);
    5039              :                     }
    5040            0 :                     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            0 :                     if (!lNumericBlanks(2)) {
    5051            0 :                         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            0 :                     if (!lNumericBlanks(3)) {
    5063            0 :                         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            0 :                     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            0 :                 } break;
    5084            0 :                 case SubcoolerType::Mechanical: {
    5085            0 :                     Subcooler(SubcoolerNum).MechSourceSys = Alphas(3);
    5086              :                     // Error check on system name comes later after systems have been read
    5087              : 
    5088            0 :                     if (!lNumericBlanks(4)) {
    5089            0 :                         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            0 :                 } 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            0 :         if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    5110            0 :             CurrentModuleObject = "Refrigeration:TransferLoadList";
    5111            0 :             for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationTransferLoadLists; ++ListNum) {
    5112            0 :                 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            0 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5125              : 
    5126            0 :                 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            0 :                 int NumTotalLoadsOnList = NumAlphas - 1;
    5131            0 :                 if (!allocated(TransferLoadList(ListNum).CascadeLoadItemNum)) {
    5132            0 :                     TransferLoadList(ListNum).CascadeLoadItemNum.allocate(NumTotalLoadsOnList);
    5133              :                 }
    5134            0 :                 if (!allocated(TransferLoadList(ListNum).SecondaryItemNum)) {
    5135            0 :                     TransferLoadList(ListNum).SecondaryItemNum.allocate(NumTotalLoadsOnList);
    5136              :                 }
    5137              : 
    5138            0 :                 int NumSecondarysOnList = 0;
    5139            0 :                 int NumCascadeLoadsOnList = 0;
    5140            0 :                 for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    5141            0 :                     int AlphaListNum = 1 + NumLoad;
    5142            0 :                     int LoadCascadeNum = 0;
    5143            0 :                     int LoadSecondaryNum = 0;
    5144            0 :                     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    5145            0 :                         LoadCascadeNum = Util::FindItemInList(Alphas(AlphaListNum), Condenser);
    5146              :                     }
    5147            0 :                     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    5148            0 :                         LoadSecondaryNum = Util::FindItemInList(Alphas(AlphaListNum), Secondary);
    5149              :                     }
    5150            0 :                     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            0 :                     } 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            0 :                     } 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            0 :                     } else if (LoadSecondaryNum != 0) {
    5180            0 :                         ++NumSecondarysOnList;
    5181            0 :                         TransferLoadList(ListNum).SecondaryItemNum(NumSecondarysOnList) = LoadSecondaryNum;
    5182              :                     }
    5183            0 :                     TransferLoadList(ListNum).NumSecondarys = NumSecondarysOnList;
    5184            0 :                     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            0 :         CurrentModuleObject = "Refrigeration:CompressorList";
    5193            0 :         for (int ListNum = 1; ListNum <= NumCompressorLists; ++ListNum) {
    5194            0 :             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            0 :             CompressorLists(ListNum).NumCompressors = NumAlphas - 1;
    5207            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5208              : 
    5209            0 :             CompressorLists(ListNum).Name = Alphas(1);
    5210            0 :             if (!allocated(CompressorLists(ListNum).CompItemNum)) {
    5211            0 :                 CompressorLists(ListNum).CompItemNum.allocate(CompressorLists(ListNum).NumCompressors);
    5212              :             }
    5213              : 
    5214            0 :             for (int CompIndex = 1; CompIndex <= CompressorLists(ListNum).NumCompressors; ++CompIndex) {
    5215            0 :                 int AlphaListNum = CompIndex + 1; // same as do loop from 2 to end of list
    5216            0 :                 if (!lAlphaBlanks(AlphaListNum)) {
    5217            0 :                     CompressorLists(ListNum).CompItemNum(CompIndex) = Util::FindItemInList(Alphas(AlphaListNum), Compressor);
    5218            0 :                     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            0 :         CurrentModuleObject = "Refrigeration:System";
    5236            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    5237              : 
    5238            0 :             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            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    5252            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5253              : 
    5254            0 :             System(RefrigSysNum).Name = Alphas(1);
    5255              : 
    5256              :             // Read all loads on this System: cases, walk-ins, cascade loads, and secondary loops
    5257            0 :             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            0 :             NumCases = 0;
    5269            0 :             System(RefrigSysNum).NumCases = 0;
    5270            0 :             int NumCoils = 0;
    5271            0 :             System(RefrigSysNum).NumCoils = 0;
    5272            0 :             NumWalkIns = 0;
    5273            0 :             System(RefrigSysNum).NumWalkIns = 0;
    5274            0 :             int NumSecondary = 0;
    5275            0 :             System(RefrigSysNum).NumSecondarys = 0;
    5276            0 :             System(RefrigSysNum).NumCascadeLoads = 0;
    5277            0 :             System(RefrigSysNum).NumNonCascadeLoads = 0;
    5278            0 :             Real64 NominalTotalCaseCap = 0.0;
    5279            0 :             Real64 NominalTotalCoilCap = 0.0;
    5280            0 :             Real64 NominalTotalWalkInCap = 0.0;
    5281            0 :             Real64 NominalTotalSecondaryCap = 0.0;
    5282              :             Real64 NominalTotalCoolingCap;
    5283            0 :             Real64 NominalTotalCascadeLoad = 0.0;
    5284            0 :             System(RefrigSysNum).RefInventory = 0.0;
    5285              : 
    5286              :             //   Check for case or walkin or CaseAndWalkInList names
    5287            0 :             AlphaNum = 2;
    5288            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5289              : 
    5290              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    5291            0 :                 int CaseAndWalkInListNum = 0;
    5292            0 :                 int CaseNum = 0;
    5293            0 :                 int WalkInNum = 0;
    5294            0 :                 int CoilNum = 0;
    5295            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    5296            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    5297              :                 }
    5298            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    5299            0 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    5300              :                 }
    5301            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    5302            0 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    5303              :                 }
    5304            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    5305            0 :                     CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    5306              :                 }
    5307            0 :                 int NumNameMatches = 0;
    5308            0 :                 if (CaseAndWalkInListNum != 0) {
    5309            0 :                     ++NumNameMatches;
    5310              :                 }
    5311            0 :                 if (CaseNum != 0) {
    5312            0 :                     ++NumNameMatches;
    5313              :                 }
    5314            0 :                 if (WalkInNum != 0) {
    5315            0 :                     ++NumNameMatches;
    5316              :                 }
    5317            0 :                 if (CoilNum != 0) {
    5318            0 :                     ++NumNameMatches;
    5319              :                 }
    5320              : 
    5321            0 :                 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            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    5341            0 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    5342            0 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    5343            0 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    5344            0 :                     System(RefrigSysNum).NumCases = NumCases;
    5345            0 :                     System(RefrigSysNum).NumWalkIns = NumWalkIns;
    5346            0 :                     System(RefrigSysNum).NumCoils = NumCoils;
    5347            0 :                     if (NumCases > 0) {
    5348            0 :                         if (!allocated(System(RefrigSysNum).CaseNum)) {
    5349            0 :                             System(RefrigSysNum).CaseNum.allocate(NumCases);
    5350              :                         }
    5351            0 :                         System(RefrigSysNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    5352              :                     }
    5353            0 :                     if (NumCoils > 0) {
    5354            0 :                         if (!allocated(System(RefrigSysNum).CoilNum)) {
    5355            0 :                             System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5356              :                         }
    5357            0 :                         System(RefrigSysNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    5358              :                     }
    5359            0 :                     if (NumWalkIns > 0) {
    5360            0 :                         if (!allocated(System(RefrigSysNum).WalkInNum)) {
    5361            0 :                             System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5362              :                         }
    5363            0 :                         System(RefrigSysNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    5364              :                     }
    5365            0 :                 } else if (CaseNum != 0) { // Name points to a case
    5366            0 :                     NumCases = 1;
    5367            0 :                     System(RefrigSysNum).NumCases = 1;
    5368            0 :                     if (!allocated(System(RefrigSysNum).CaseNum)) {
    5369            0 :                         System(RefrigSysNum).CaseNum.allocate(NumCases);
    5370              :                     }
    5371            0 :                     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            0 :             if (NumCases > 0) {
    5390              :                 // Find lowest design evap T
    5391              :                 // Sum rated capacity of all cases on system
    5392            0 :                 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            0 :                     int CaseNum = System(RefrigSysNum).CaseNum(caseIndex);
    5395            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    5396            0 :                     NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap;
    5397            0 :                     System(RefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    5398            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    5399            0 :                         System(RefrigSysNum).TEvapDesign = RefrigCase(CaseNum).EvapTempDesign;
    5400              :                     } else {
    5401            0 :                         System(RefrigSysNum).TEvapDesign = min(RefrigCase(CaseNum).EvapTempDesign, System(RefrigSysNum).TEvapDesign);
    5402              :                     }
    5403              :                 } // CaseIndex=1,NumCases
    5404            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCases;
    5405              :             } // Numcases > 0
    5406              : 
    5407            0 :             if (NumCoils > 0) {
    5408              :                 // Find lowest design evap T
    5409              :                 // Sum rated capacity of all Coils on system
    5410            0 :                 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            0 :                     int CoilNum = System(RefrigSysNum).CoilNum(CoilIndex);
    5413            0 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    5414            0 :                     NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    5415            0 :                     System(RefrigSysNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    5416            0 :                     if ((CoilIndex == 1) && (System(RefrigSysNum).NumCases == 0)) { // look for lowest Coil design evap T for system
    5417            0 :                         System(RefrigSysNum).TEvapDesign = WarehouseCoil(CoilNum).TEvapDesign;
    5418              :                     } else {
    5419            0 :                         System(RefrigSysNum).TEvapDesign = min(WarehouseCoil(CoilNum).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5420              :                     }
    5421              :                 } // CoilIndex=1,NumCoils
    5422            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCoils;
    5423              :             } // NumCoils > 0
    5424              : 
    5425            0 :             if (NumWalkIns > 0) {
    5426            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    5427            0 :                     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            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    5430            0 :                     NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    5431            0 :                     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            0 :                     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            0 :                     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            0 :                         System(RefrigSysNum).TEvapDesign = WalkIn(WalkInID).TEvapDesign;
    5450              :                     } else {
    5451            0 :                         System(RefrigSysNum).TEvapDesign = min(WalkIn(WalkInID).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5452              :                     }
    5453              :                 } // WalkInIndex=1,NumWalkIns
    5454            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumWalkIns;
    5455              :             } // numwalkins > 0
    5456              : 
    5457            0 :             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            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5461              : 
    5462              :                 // Entry for Alphas(AlphaNum) can be either a Secondary, CascadeLoad name or a TransferLoadList name
    5463            0 :                 int TransferLoadListNum = 0;
    5464            0 :                 int SecondaryNum = 0;
    5465            0 :                 int CascadeLoadNum = 0;
    5466            0 :                 if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    5467            0 :                     TransferLoadListNum = Util::FindItemInList(Alphas(AlphaNum), TransferLoadList);
    5468              :                 }
    5469            0 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    5470            0 :                     SecondaryNum = Util::FindItemInList(Alphas(AlphaNum), Secondary);
    5471              :                 }
    5472            0 :                 if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    5473            0 :                     CascadeLoadNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5474              :                 }
    5475            0 :                 int NumNameMatches = 0;
    5476            0 :                 if (TransferLoadListNum != 0) {
    5477            0 :                     ++NumNameMatches;
    5478              :                 }
    5479            0 :                 if (SecondaryNum != 0) {
    5480            0 :                     ++NumNameMatches;
    5481              :                 }
    5482            0 :                 if (CascadeLoadNum != 0) {
    5483            0 :                     ++NumNameMatches;
    5484              :                 }
    5485            0 :                 int NumCascadeLoad = 0;
    5486              : 
    5487            0 :                 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            0 :                 } else if (TransferLoadListNum != 0) { // Name points to a transferLoad list
    5507            0 :                     NumSecondary = TransferLoadList(TransferLoadListNum).NumSecondarys;
    5508            0 :                     NumCascadeLoad = TransferLoadList(TransferLoadListNum).NumCascadeLoads;
    5509            0 :                     System(RefrigSysNum).NumSecondarys = NumSecondary;
    5510            0 :                     System(RefrigSysNum).NumCascadeLoads = NumCascadeLoad;
    5511            0 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) {
    5512            0 :                         System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5513              :                     }
    5514            0 :                     System(RefrigSysNum).SecondaryNum({1, NumSecondary}) = TransferLoadList(TransferLoadListNum).SecondaryItemNum({1, NumSecondary});
    5515            0 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) {
    5516            0 :                         System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5517              :                     }
    5518            0 :                     System(RefrigSysNum).CascadeLoadNum({1, NumCascadeLoad}) =
    5519            0 :                         TransferLoadList(TransferLoadListNum).CascadeLoadItemNum({1, NumCascadeLoad});
    5520            0 :                 } else if (SecondaryNum != 0) { // Name points to a secondary loop load
    5521            0 :                     NumSecondary = 1;
    5522            0 :                     System(RefrigSysNum).NumSecondarys = 1;
    5523            0 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) {
    5524            0 :                         System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5525              :                     }
    5526            0 :                     System(RefrigSysNum).SecondaryNum(NumSecondary) = SecondaryNum;
    5527            0 :                 } else if (CascadeLoadNum != 0) { // Name points to a cascade condenser load
    5528            0 :                     NumCascadeLoad = 1;
    5529            0 :                     System(RefrigSysNum).NumCascadeLoads = 1;
    5530            0 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) {
    5531            0 :                         System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5532              :                     }
    5533            0 :                     System(RefrigSysNum).CascadeLoadNum(NumCascadeLoad) = CascadeLoadNum;
    5534              :                 } // NumNameMatches /= 1
    5535              : 
    5536            0 :                 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            0 :                 if (NumSecondary > 0) {
    5539            0 :                     for (int SecondaryIndex = 1; SecondaryIndex <= NumSecondary; ++SecondaryIndex) {
    5540            0 :                         int SecondaryID = System(RefrigSysNum).SecondaryNum(SecondaryIndex);
    5541            0 :                         if (SecondaryIndex == 1) { // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5542            0 :                             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            0 :                         ++Secondary(SecondaryID).NumSysAttach;
    5558            0 :                         NominalTotalSecondaryCap += Secondary(SecondaryID).CoolingLoadRated;
    5559            0 :                         System(RefrigSysNum).RefInventory += Secondary(SecondaryID).ChillerRefInventory;
    5560              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5561            0 :                         if ((SecondaryIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0) &&
    5562            0 :                             (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            0 :                             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            0 :                     System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumSecondarys;
    5574              :                 } // numsecondary > 0
    5575              : 
    5576            0 :                 if (NumCascadeLoad > 0) {
    5577            0 :                     for (int cascadeLoadIndex = 1; cascadeLoadIndex <= NumCascadeLoad; ++cascadeLoadIndex) {
    5578            0 :                         int CondID = System(RefrigSysNum).CascadeLoadNum(cascadeLoadIndex);
    5579            0 :                         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            0 :                         Condenser(CondID).CascadeSinkSystemID = RefrigSysNum;
    5591            0 :                         NominalTotalCascadeLoad += Condenser(CondID).RatedCapacity;
    5592              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5593            0 :                         if (System(RefrigSysNum).NumNonCascadeLoads == 0) {
    5594            0 :                             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            0 :                                 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            0 :             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            0 :                 if (System(RefrigSysNum).NumCoils > 0) { //(note, coilflag set to .FALSE. for all systems as default above
    5624            0 :                     System(RefrigSysNum).CoilFlag = true;
    5625            0 :                     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            0 :             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            0 :             AlphaNum = 4;
    5642            0 :             int NumCondensers = 1;
    5643            0 :             if (!allocated(System(RefrigSysNum).CondenserNum)) {
    5644            0 :                 System(RefrigSysNum).CondenserNum.allocate(NumCondensers);
    5645              :             }
    5646            0 :             System(RefrigSysNum).NumCondensers = 1;
    5647              :             // Find condenser number, note condensers were read in one of four objects, but all read into same list
    5648            0 :             int CondNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5649            0 :             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            0 :                 System(RefrigSysNum).CondenserNum(NumCondensers) = CondNum;
    5660              :                 // Now take care of case where multiple systems share a condenser
    5661            0 :                 ++Condenser(CondNum).NumSysAttach;
    5662            0 :                 Condenser(CondNum).SysNum(Condenser(CondNum).NumSysAttach) = RefrigSysNum;
    5663              :             }
    5664              : 
    5665            0 :             System(RefrigSysNum).RefInventory +=
    5666            0 :                 Condenser(CondNum).RefReceiverInventory + Condenser(CondNum).RefPipingInventory + Condenser(CondNum).RefOpCharge;
    5667            0 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) {
    5668            0 :                 Condenser(CondNum).CascadeSysID = RefrigSysNum;
    5669              :             }
    5670            0 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) && (Condenser(CondNum).CondenserRejectHeatToZone)) {
    5671            0 :                 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            0 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5676            0 :                 if (Condenser(CondNum).RatedAirFlowRate == Constant::AutoCalculate) {
    5677            0 :                     Condenser(CondNum).RatedAirFlowRate = AirVolRateEvapCond * Condenser(CondNum).RatedCapacity;
    5678              :                 }
    5679            0 :                 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            0 :                 if (Condenser(CondNum).EvapPumpPower == Constant::AutoCalculate) {
    5688            0 :                     Condenser(CondNum).EvapPumpPower = CondPumpRatePower * Condenser(CondNum).RatedCapacity;
    5689              :                 }
    5690            0 :                 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            0 :             AlphaNum = 5;
    5703            0 :             int NumCompressorsSys = 0;
    5704            0 :             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            0 :                 if (NumCompressorLists > 0) {
    5711            0 :                     ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5712              :                 } else {
    5713            0 :                     ListNum = 0;
    5714              :                 }
    5715              :                 int CompNum;
    5716            0 :                 if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    5717            0 :                     CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5718              :                 } else {
    5719            0 :                     CompNum = 0;
    5720              :                 }
    5721            0 :                 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            0 :                 } 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            0 :                 } else if (ListNum != 0) {
    5738            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    5739            0 :                     System(RefrigSysNum).NumCompressors = NumCompressorsSys;
    5740            0 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) {
    5741            0 :                         System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5742              :                     }
    5743            0 :                     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            0 :             if (!lNumericBlanks(1)) {
    5755            0 :                 System(RefrigSysNum).TCondenseMin = Numbers(1);
    5756            0 :                 System(RefrigSysNum).TCondenseMinInput = System(RefrigSysNum).TCondenseMin;
    5757            0 :                 if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5758            0 :                     SetupEMSActuator(state,
    5759              :                                      "Refrigeration:System",
    5760            0 :                                      System(RefrigSysNum).Name,
    5761              :                                      "Minimum Condensing Temperature",
    5762              :                                      "[C]",
    5763            0 :                                      System(RefrigSysNum).EMSOverrideOnTCondenseMin,
    5764            0 :                                      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            0 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) &&
    5773            0 :                 (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            0 :             AlphaNum = 6;
    5782            0 :             System(RefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    5783            0 :             if (System(RefrigSysNum).RefrigerantName.empty()) {
    5784            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    5785            0 :                 ErrorsFound = true;
    5786            0 :             } 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            0 :             AlphaNum = 7;
    5793            0 :             if (lAlphaBlanks(AlphaNum)) {
    5794            0 :                 System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::ConstantSuctionTemperature; // Default for blank
    5795            0 :             } else if ((System(RefrigSysNum).CompSuctControl = static_cast<CompressorSuctionPressureCtrl>(
    5796            0 :                             getEnumValue(compressorSuctionPressureCtrlNamesUC, Alphas(AlphaNum)))) == CompressorSuctionPressureCtrl::Invalid) {
    5797            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5798            0 :                 ErrorsFound = true;
    5799            0 :             } else if (System(RefrigSysNum).CompSuctControl == CompressorSuctionPressureCtrl::FloatSuctionTemperature &&
    5800            0 :                        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            0 :             AlphaNum = 8;
    5810            0 :             System(RefrigSysNum).NumSubcoolers = 0;
    5811            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5812            0 :                 ++System(RefrigSysNum).NumSubcoolers;
    5813              :             }
    5814            0 :             if (!lAlphaBlanks(AlphaNum + 1)) {
    5815            0 :                 ++System(RefrigSysNum).NumSubcoolers;
    5816              :             }
    5817              : 
    5818            0 :             if (System(RefrigSysNum).NumSubcoolers > 0) {
    5819            0 :                 if (!allocated(System(RefrigSysNum).SubcoolerNum)) {
    5820            0 :                     System(RefrigSysNum).SubcoolerNum.allocate(System(RefrigSysNum).NumSubcoolers);
    5821              :                 }
    5822            0 :                 int NumSubcooler = 1;
    5823            0 :                 if (!lAlphaBlanks(AlphaNum)) {
    5824            0 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5825            0 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum));
    5826            0 :                     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            0 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    5837              :                     }
    5838            0 :                     ++NumSubcooler;
    5839              :                 }
    5840            0 :                 if (!lAlphaBlanks(AlphaNum + 1)) {
    5841            0 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5842            0 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum + 1));
    5843            0 :                     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            0 :                         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            0 :             AlphaNum = 10;
    5865            0 :             System(RefrigSysNum).SumUASuctionPiping = 0.0;
    5866            0 :             if (!lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    5867            0 :                 System(RefrigSysNum).SumUASuctionPiping = Numbers(2);
    5868            0 :                 System(RefrigSysNum).SuctionPipeActualZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    5869            0 :                 System(RefrigSysNum).SuctionPipeZoneNodeNum =
    5870            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, System(RefrigSysNum).SuctionPipeActualZoneNum);
    5871            0 :                 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            0 :                     state.dataRefrigCase->RefrigPresentInZone(System(RefrigSysNum).SuctionPipeActualZoneNum) = true;
    5885              :                 }
    5886            0 :             } 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            0 :             } 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            0 :             AlphaNum = 11;
    5906            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5907            0 :                 System(RefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    5908              :             }
    5909              : 
    5910              :             // Single-stage or two-stage compression system
    5911            0 :             if (!lNumericBlanks(3)) {
    5912            0 :                 System(RefrigSysNum).NumStages = Numbers(3);
    5913            0 :                 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            0 :                 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            0 :             AlphaNum = 12;
    5931            0 :             if (lAlphaBlanks(AlphaNum)) {
    5932            0 :                 System(RefrigSysNum).intercoolerType = IntercoolerType::None; // Default for blank
    5933            0 :             } else if ((System(RefrigSysNum).intercoolerType =
    5934            0 :                             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            0 :             if (System(RefrigSysNum).NumStages == 1 && (System(RefrigSysNum).intercoolerType == IntercoolerType::Flash ||
    5940            0 :                                                         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            0 :             } 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            0 :             if (!lNumericBlanks(4)) {
    5956            0 :                 System(RefrigSysNum).IntercoolerEffectiveness = Numbers(4);
    5957            0 :                 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            0 :                 System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    5968              :             }
    5969              : 
    5970              :             // Read the high-stage compressor info, if two-stage compression has been specified.
    5971            0 :             AlphaNum = 13;
    5972            0 :             int NumHiStageCompressorsSys = 0;
    5973            0 :             if (System(RefrigSysNum).NumStages == 2) {
    5974            0 :                 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            0 :                     int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5985            0 :                     int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5986            0 :                     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            0 :                     } 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            0 :                     } else if (ListNum != 0) {
    6005            0 :                         NumHiStageCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6006            0 :                         System(RefrigSysNum).NumHiStageCompressors = NumHiStageCompressorsSys;
    6007            0 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum)) {
    6008            0 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    6009              :                         }
    6010            0 :                         System(RefrigSysNum).HiStageCompressorNum({1, NumHiStageCompressorsSys}) =
    6011            0 :                             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            0 :             if (System(RefrigSysNum).NumStages == 2) {
    6025              :                 Real64 PCond =
    6026            0 :                     System(RefrigSysNum).refrig->getSatPressure(state, Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense, RoutineName);
    6027            0 :                 Real64 PEvap = System(RefrigSysNum).refrig->getSatPressure(state, System(RefrigSysNum).TEvapDesign, RoutineName);
    6028            0 :                 System(RefrigSysNum).PIntercooler = std::sqrt(PCond * PEvap);
    6029            0 :                 System(RefrigSysNum).TIntercooler =
    6030            0 :                     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            0 :             Real64 NominalTotalCompCap = 0.0;
    6035            0 :             for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6036            0 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6037            0 :                 if (!Compressor(CompNum).TransFlag) {          //  Subcritical Compressor
    6038            0 :                     if (System(RefrigSysNum).NumStages == 1) { //  Single-stage compression
    6039            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6040            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6041            0 :                                                                        System(RefrigSysNum).TEvapDesign,
    6042            0 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6043            0 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6044            0 :                         ++Compressor(CompNum).NumSysAttach;
    6045              :                     } else { //  Two-stage compression, low-stage compressors
    6046            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6047            0 :                             state, Compressor(CompNum).CapacityCurvePtr, System(RefrigSysNum).TEvapDesign, System(RefrigSysNum).TIntercooler);
    6048            0 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6049            0 :                         ++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            0 :             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            0 :             if (System(RefrigSysNum).NumStages == 2) {
    6067            0 :                 for (int CompIndex = 1; CompIndex <= NumHiStageCompressorsSys; ++CompIndex) {
    6068            0 :                     int CompNum = System(RefrigSysNum).HiStageCompressorNum(CompIndex);
    6069            0 :                     if (!Compressor(CompNum).TransFlag) { //  Subcritical Compressor
    6070            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6071            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6072            0 :                                                                        System(RefrigSysNum).TIntercooler,
    6073            0 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6074            0 :                         NominalTotalHiStageCompCap += Compressor(CompNum).NomCap;
    6075            0 :                         ++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            0 :             Real64 NominalCondCap = Condenser(System(RefrigSysNum).CondenserNum(1)).RatedCapacity;
    6092            0 :             if (System(RefrigSysNum).SystemRejectHeatToZone) {
    6093            0 :                 NominalCondCap *= 2.0;
    6094              :             }
    6095            0 :             if (System(RefrigSysNum).NumStages == 1) { // Single-stage system
    6096            0 :                 if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6097            0 :                     ShowWarningError(state,
    6098            0 :                                      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            0 :                                             System(RefrigSysNum).Name,
    6102              :                                             NominalTotalCoolingCap,
    6103              :                                             NominalCondCap,
    6104              :                                             NominalTotalCompCap));
    6105              :                 }
    6106            0 :             } else if (System(RefrigSysNum).NumStages == 2) { // Two-stage system
    6107            0 :                 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            0 :         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            0 :             int CondNum = System(RefrigSysNum).CondenserNum(1); // right now only have one condenser per system
    6126            0 :             Condenser(CondNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    6127            0 :             for (int CompIndex = 1; CompIndex <= System(RefrigSysNum).NumCompressors; ++CompIndex) {
    6128            0 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6129            0 :                 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            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems;
    6139              :              ++RefrigSysNum) { // check flags for systems reflect all cascade loads
    6140            0 :             if (System(RefrigSysNum).NumCascadeLoads == 0) {
    6141            0 :                 continue;
    6142              :             }
    6143            0 :             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            0 :                 bool CaseLoads = false;
    6166            0 :                 int NumCascadeLoadsChecked = 0;
    6167            0 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) { // look at All cascade condenser loads on system
    6168            0 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    6169            0 :                         continue;
    6170              :                     }
    6171            0 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) {
    6172            0 :                         continue; // this condenser is not a cascade load on this system
    6173              :                     }
    6174            0 :                     ++NumCascadeLoadsChecked;
    6175            0 :                     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            0 :                     if (NumCascadeLoadsChecked == 1) {
    6181            0 :                         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            0 :                             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          150 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    6210            0 :         for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6211            0 :             if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) {
    6212            0 :                 continue;
    6213              :             }
    6214            0 :             Subcooler(SubcoolerNum).MechSourceSysID =
    6215            0 :                 state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:System", Subcooler(SubcoolerNum).MechSourceSys);
    6216            0 :             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            0 :                 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            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    6239            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6240            0 :                 if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) {
    6241            0 :                     continue;
    6242              :                 }
    6243            0 :                 if (Subcooler(SubcoolerNum).MechSourceSysID == RefrigSysNum) {
    6244            0 :                     ++System(RefrigSysNum).NumMechSCServed;
    6245              :                 }
    6246              :             }
    6247            0 :             if (System(RefrigSysNum).NumMechSCServed > 0) {
    6248            0 :                 if (!allocated(System(RefrigSysNum).MechSCLoad)) {
    6249            0 :                     System(RefrigSysNum).MechSCLoad.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
    6250              :                 }
    6251              :             }
    6252              :         }
    6253              :     } // NumSimulationSubcoolers > 0
    6254              : 
    6255              :     // **********  READ TRANSCRITICAL REFRIGERATION SYSTEMS  **********
    6256              : 
    6257          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    6258            0 :         CurrentModuleObject = "Refrigeration:TranscriticalSystem";
    6259            0 :         for (int TransRefrigSysNum = 1; TransRefrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransRefrigSysNum) {
    6260            0 :             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            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    6274              : 
    6275            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    6276              : 
    6277            0 :             TransSystem(TransRefrigSysNum).Name = Alphas(1);
    6278              : 
    6279              :             // Read refrigerant for this system
    6280            0 :             AlphaNum = 8;
    6281            0 :             TransSystem(TransRefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    6282            0 :             if (TransSystem(TransRefrigSysNum).RefrigerantName.empty()) {
    6283            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    6284            0 :                 ErrorsFound = true;
    6285            0 :             } 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            0 :             if (lAlphaBlanks(2)) {
    6293            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2));
    6294            0 :                 ErrorsFound = true;
    6295            0 :             } 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            0 :             } 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            0 :             } 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            0 :             int NumCasesMT = 0;
    6309            0 :             TransSystem(TransRefrigSysNum).NumCasesMT = 0;
    6310            0 :             int NumCasesLT = 0;
    6311            0 :             TransSystem(TransRefrigSysNum).NumCasesLT = 0;
    6312            0 :             int NumWalkInsMT = 0;
    6313            0 :             TransSystem(TransRefrigSysNum).NumWalkInsMT = 0;
    6314            0 :             int NumWalkInsLT = 0;
    6315            0 :             TransSystem(TransRefrigSysNum).NumWalkInsLT = 0;
    6316            0 :             Real64 NominalTotalCaseCapMT = 0.0;
    6317            0 :             Real64 NominalTotalCaseCapLT = 0.0;
    6318            0 :             Real64 NominalTotalWalkInCapMT = 0.0;
    6319            0 :             Real64 NominalTotalWalkInCapLT = 0.0;
    6320              :             Real64 NominalTotalCoolingCap;
    6321            0 :             TransSystem(TransRefrigSysNum).RefInventory = 0.0;
    6322              : 
    6323              :             //   Check for Medium Temperature Case or Walk-In or CaseAndWalkInList names
    6324            0 :             AlphaNum = 3;
    6325              : 
    6326            0 :             if (!lAlphaBlanks(AlphaNum)) {
    6327              : 
    6328              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6329            0 :                 int CaseAndWalkInListNum = 0;
    6330            0 :                 int CaseNum = 0;
    6331            0 :                 int WalkInNum = 0;
    6332            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    6333            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6334              :                 }
    6335            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    6336            0 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6337              :                 }
    6338            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    6339            0 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6340              :                 }
    6341            0 :                 int NumNameMatches = 0;
    6342            0 :                 if (CaseAndWalkInListNum != 0) {
    6343            0 :                     ++NumNameMatches;
    6344              :                 }
    6345            0 :                 if (CaseNum != 0) {
    6346            0 :                     ++NumNameMatches;
    6347              :                 }
    6348            0 :                 if (WalkInNum != 0) {
    6349            0 :                     ++NumNameMatches;
    6350              :                 }
    6351              : 
    6352            0 :                 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            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6372            0 :                     NumCasesMT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6373            0 :                     NumWalkInsMT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6374            0 :                     TransSystem(TransRefrigSysNum).NumCasesMT = NumCasesMT;
    6375            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = NumWalkInsMT;
    6376            0 :                     if (NumCasesMT > 0) {
    6377            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) {
    6378            0 :                             TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6379              :                         }
    6380            0 :                         TransSystem(TransRefrigSysNum).CaseNumMT({1, NumCasesMT}) =
    6381            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesMT});
    6382              :                     }
    6383            0 :                     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            0 :             if (NumCasesMT > 0) {
    6408              :                 // Find lowest design evap T
    6409              :                 // Sum rated capacity of all MT cases on system
    6410            0 :                 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            0 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumMT(caseIndex);
    6413            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6414            0 :                     NominalTotalCaseCapMT += RefrigCase(CaseNum).DesignRatedCap;
    6415            0 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6416            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6417            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = RefrigCase(CaseNum).EvapTempDesign;
    6418              :                     } else {
    6419            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6420            0 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6421              :                     }
    6422              :                 } // CaseIndex=1,NumCases
    6423              :             } // NumcasesMT > 0
    6424              : 
    6425            0 :             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            0 :             AlphaNum = 4;
    6459            0 :             if (!lAlphaBlanks(AlphaNum)) {
    6460              : 
    6461              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6462            0 :                 int CaseAndWalkInListNum = 0;
    6463            0 :                 int CaseNum = 0;
    6464            0 :                 int WalkInNum = 0;
    6465            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    6466            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6467              :                 }
    6468            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    6469            0 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6470              :                 }
    6471            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    6472            0 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6473              :                 }
    6474            0 :                 int NumNameMatches = 0;
    6475            0 :                 if (CaseAndWalkInListNum != 0) {
    6476            0 :                     ++NumNameMatches;
    6477              :                 }
    6478            0 :                 if (CaseNum != 0) {
    6479            0 :                     ++NumNameMatches;
    6480              :                 }
    6481            0 :                 if (WalkInNum != 0) {
    6482            0 :                     ++NumNameMatches;
    6483              :                 }
    6484              : 
    6485            0 :                 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            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6505            0 :                     NumCasesLT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6506            0 :                     NumWalkInsLT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6507            0 :                     TransSystem(TransRefrigSysNum).NumCasesLT = NumCasesLT;
    6508            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = NumWalkInsLT;
    6509            0 :                     if (NumCasesLT > 0) {
    6510            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) {
    6511            0 :                             TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6512              :                         }
    6513            0 :                         TransSystem(TransRefrigSysNum).CaseNumLT({1, NumCasesLT}) =
    6514            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesLT});
    6515              :                     }
    6516            0 :                     if (NumWalkInsLT > 0) {
    6517            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) {
    6518            0 :                             TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6519              :                         }
    6520            0 :                         TransSystem(TransRefrigSysNum).WalkInNumLT({1, NumWalkInsLT}) =
    6521            0 :                             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            0 :             if (NumCasesLT > 0) {
    6541              :                 // Find lowest design evap T
    6542              :                 // Sum rated capacity of all LT cases on system
    6543            0 :                 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            0 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumLT(caseIndex);
    6546            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6547            0 :                     NominalTotalCaseCapLT += RefrigCase(CaseNum).DesignRatedCap;
    6548            0 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6549            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6550            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = RefrigCase(CaseNum).EvapTempDesign;
    6551              :                     } else {
    6552            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6553            0 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6554              :                     }
    6555              :                 } // CaseIndex=1,NumCases
    6556              :             } // NumcasesLT > 0
    6557              : 
    6558            0 :             if (NumWalkInsLT > 0) {
    6559            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsLT; ++WalkInIndex) {
    6560            0 :                     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            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    6563            0 :                     NominalTotalWalkInCapLT += WalkIn(WalkInID).DesignRatedCap;
    6564            0 :                     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            0 :                     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            0 :                     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            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6585            0 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6586              :                     }
    6587              :                 } // WalkInIndex=1,NumWalkIns
    6588              :             } // NumWalkInsMT > 0
    6589              : 
    6590            0 :             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            0 :             AlphaNum = 5;
    6595            0 :             int NumGasCoolers = 1;
    6596            0 :             if (!allocated(TransSystem(TransRefrigSysNum).GasCoolerNum)) {
    6597            0 :                 TransSystem(TransRefrigSysNum).GasCoolerNum.allocate(NumGasCoolers);
    6598              :             }
    6599            0 :             TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6600              :             // Find gascooler number
    6601            0 :             int GCNum = Util::FindItemInList(Alphas(AlphaNum), GasCooler);
    6602              : 
    6603            0 :             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            0 :             } else if (GCNum != 0) { //  Gas Cooler attached to Transcritical Refrigeration System
    6613            0 :                 TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers) = GCNum;
    6614            0 :                 TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6615              :                 // Now take care of case where multiple systems share a gas cooler
    6616            0 :                 ++GasCooler(GCNum).NumSysAttach;
    6617            0 :                 GasCooler(GCNum).SysNum(GasCooler(GCNum).NumSysAttach) = TransRefrigSysNum;
    6618            0 :                 TransSystem(TransRefrigSysNum).RefInventory +=
    6619            0 :                     GasCooler(GCNum).RefReceiverInventory + GasCooler(GCNum).RefPipingInventory + GasCooler(GCNum).RefOpCharge;
    6620            0 :                 if (GasCooler(GCNum).GasCoolerRejectHeatToZone) {
    6621            0 :                     TransSystem(TransRefrigSysNum).SystemRejectHeatToZone = true;
    6622              :                 }
    6623              :             }
    6624              : 
    6625              :             // Read High Pressure Compressor
    6626            0 :             AlphaNum = 6;
    6627            0 :             int NumCompressorsSys = 0;
    6628            0 :             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            0 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6634            0 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6635            0 :                 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            0 :                 } 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            0 :                 } else if (ListNum != 0) {
    6652            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6653            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = NumCompressorsSys;
    6654            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP)) {
    6655            0 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6656              :                     }
    6657            0 :                     TransSystem(TransRefrigSysNum).CompressorNumHP({1, NumCompressorsSys}) =
    6658            0 :                         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            0 :                 NominalTotalCompCapHP = 0.0;
    6669            0 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6670            0 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumHP(CompIndex);
    6671              : 
    6672            0 :                     if (Compressor(CompNum).TransFlag) { //  Calculate nominal capacity of transcritical Compressor
    6673            0 :                         Real64 GCOutletH = TransSystem(TransRefrigSysNum)
    6674            0 :                                                .refrig->getSupHeatEnthalpy(state,
    6675            0 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletT,
    6676            0 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletP,
    6677              :                                                                            routineName);
    6678            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6679            0 :                             state, Compressor(CompNum).TransCapacityCurvePtr, TransSystem(TransRefrigSysNum).TEvapDesignMT, GCOutletH);
    6680            0 :                         NominalTotalCompCapHP += Compressor(CompNum).NomCap;
    6681            0 :                         ++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            0 :             AlphaNum = 7;
    6696            0 :             NumCompressorsSys = 0;
    6697              : 
    6698            0 :             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            0 :             } 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            0 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage)) {
    6718              :                 // TwoStage system with low pressure compressors specified
    6719            0 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6720            0 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6721            0 :                 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            0 :                 } 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            0 :                 } else if (ListNum != 0) {
    6738            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6739            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = NumCompressorsSys;
    6740            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP)) {
    6741            0 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6742              :                     }
    6743            0 :                     TransSystem(TransRefrigSysNum).CompressorNumLP({1, NumCompressorsSys}) =
    6744            0 :                         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            0 :                 NominalTotalCompCapLP = 0.0;
    6755            0 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6756            0 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumLP(CompIndex);
    6757            0 :                     if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage) { //  Calculate capacity of LP compressors
    6758            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6759            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6760            0 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignLT,
    6761            0 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6762            0 :                         NominalTotalCompCapLP += Compressor(CompNum).NomCap;
    6763            0 :                         ++Compressor(CompNum).NumSysAttach;
    6764              :                     }
    6765              :                 }
    6766              :             }
    6767              : 
    6768              :             // Read Receiver Pressure
    6769            0 :             if (!lNumericBlanks(1)) {
    6770            0 :                 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            0 :             TransSystem(TransRefrigSysNum).TReceiver =
    6777            0 :                 TransSystem(TransRefrigSysNum).refrig->getSatTemperature(state, TransSystem(TransRefrigSysNum).PReceiver, routineName);
    6778            0 :             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            0 :             if (NominalTotalCompCapLP > 0.0) {
    6791            0 :                 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            0 :             if (NominalTotalCompCapHP > 0.0) {
    6809            0 :                 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            0 :             if (!lNumericBlanks(2)) {
    6829            0 :                 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            0 :             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            0 :             AlphaNum = 9; // Medium temperature suction piping
    6851            0 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = 0.0;
    6852            0 :             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            0 :             } 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            0 :             } 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            0 :             AlphaNum = 10; // Low temperature suction piping
    6895            0 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = 0.0;
    6896            0 :             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            0 :             } 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            0 :             } 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            0 :             AlphaNum = 11;
    6939            0 :             if (!lAlphaBlanks(AlphaNum)) {
    6940            0 :                 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            0 :             Real64 NominalCondCap = GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedCapacity;
    6946            0 :             Real64 NominalTotalCompCap = NominalTotalCompCapHP + NominalTotalCompCapLP;
    6947            0 :             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          150 :     DayValues.deallocate();
    6963          150 :     Alphas.deallocate();
    6964          150 :     Numbers.deallocate();
    6965          150 :     cAlphaFieldNames.deallocate();
    6966          150 :     cNumericFieldNames.deallocate();
    6967          150 :     lAlphaBlanks.deallocate();
    6968          150 :     lNumericBlanks.deallocate();
    6969              : 
    6970          150 :     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            6 :         for (int ZoneIndex = 1; ZoneIndex <= state.dataGlobal->NumOfZones; ++ZoneIndex) { // numofzones from dataglobals
    6974            3 :             Real64 TempRAFraction = CaseRAFraction(ZoneIndex).TotalCaseRAFraction;
    6975            6 :             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            3 :                 if (RefrigCase(CaseNum).ActualZoneNum != ZoneIndex || RefrigCase(CaseNum).NumSysAttach > 0) {
    6979            3 :                     continue;
    6980              :                 }
    6981            0 :                 TempRAFraction -= RefrigCase(CaseNum).RAFrac;
    6982              :             } // NumSimulationCases
    6983            3 :             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            3 :         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            3 :         state.dataRefrigCase->NumUnusedRefrigCases = 0;
    6999            6 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    7000            3 :             if (RefrigCase(CaseNum).NumSysAttach == 1) {
    7001            3 :                 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            3 :         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          150 :     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            0 :         state.dataRefrigCase->NumUnusedCompressors = 0;
    7035            0 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    7036            0 :             if (Compressor(CompNum).NumSysAttach == 1) {
    7037            0 :                 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            0 :         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          150 :     int NumUnusedWalkIns = 0;
    7070          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7071              :         // check for refrigeration WalkIns not connected to any systems and
    7072              :         //  refrigeration WalkIns connected more than once
    7073            6 :         for (int WalkInNum = 1; WalkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInNum) {
    7074            3 :             if (WalkIn(WalkInNum).NumSysAttach == 1) {
    7075            3 :                 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            3 :         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          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7106              :         // check for air chillers not connected to any systems and
    7107              :         //  air chillers connected more than once
    7108            0 :         state.dataRefrigCase->NumUnusedCoils = 0;
    7109            0 :         for (int CoilNum = 1; CoilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilNum) {
    7110            0 :             if (WarehouseCoil(CoilNum).NumSysAttach == 1) {
    7111            0 :                 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            0 :         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          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    7145              :         // check for refrigeration Secondarys not connected to detailed systems and
    7146              :         //  refrigeration Secondarys connected more than once
    7147            0 :         state.dataRefrigCase->NumUnusedSecondarys = 0;
    7148            0 :         for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    7149            0 :             if (Secondary(SecondaryNum).NumSysAttach == 1) {
    7150            0 :                 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            0 :         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          150 :     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            0 :         state.dataRefrigCase->NumSimulationSharedCondensers = 0;
    7187            0 :         state.dataRefrigCase->NumUnusedCondensers = 0;
    7188            0 :         for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumRefrigCondensers; ++CondNum) {
    7189            0 :             if (Condenser(CondNum).NumSysAttach == 1) {
    7190            0 :                 continue;
    7191              :             }
    7192            0 :             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            0 :             if (Condenser(CondNum).NumSysAttach > 1) {
    7200            0 :                 ++state.dataRefrigCase->NumSimulationSharedCondensers;
    7201              :             } // looking for shared condensers
    7202              :         } // CondNum
    7203              : 
    7204            0 :         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          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    7218              :         // Check for presence of shared gas coolers and for unused gas coolers
    7219            0 :         state.dataRefrigCase->NumSimulationSharedGasCoolers = 0;
    7220            0 :         state.dataRefrigCase->NumUnusedGasCoolers = 0;
    7221            0 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    7222            0 :             if (GasCooler(GCNum).NumSysAttach == 1) {
    7223            0 :                 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            0 :         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          150 :     ReportRefrigerationComponents(state);
    7252              : 
    7253          150 :     if (ErrorsFound) {
    7254            0 :         ShowFatalError(state, format("{} Previous errors cause program termination", RoutineName));
    7255              :     }
    7256          150 : }
    7257              : 
    7258          150 : 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          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
    7271          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
    7272          150 :     auto &System = state.dataRefrigCase->System;
    7273          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
    7274          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
    7275          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
    7276          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
    7277          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
    7278          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
    7279          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
    7280          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
    7281          150 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
    7282          150 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
    7283              : 
    7284          150 :     std::string Walkin_and_zone_name; // concat name for walk-in/zone credit reporting
    7285              : 
    7286          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    7287              :         // Setup Report Variables for simulated Refrigerated Case (do not report unused cases)
    7288              :         // CurrentModuleObject='Refrigeration:Case'
    7289            6 :         for (int caseNum = 1; caseNum <= state.dataRefrigCase->NumSimulationCases; ++caseNum) {
    7290            3 :             auto &thisCase = RefrigCase(caseNum);
    7291            3 :             if (thisCase.NumSysAttach == 1) {
    7292            6 :                 SetupOutputVariable(state,
    7293              :                                     "Refrigeration Case Evaporator Total Cooling Rate",
    7294              :                                     Constant::Units::W,
    7295            3 :                                     thisCase.TotalCoolingLoad,
    7296              :                                     OutputProcessor::TimeStepType::Zone,
    7297              :                                     OutputProcessor::StoreType::Average,
    7298            3 :                                     thisCase.Name);
    7299            6 :                 SetupOutputVariable(state,
    7300              :                                     "Refrigeration Case Evaporator Total Cooling Energy",
    7301              :                                     Constant::Units::J,
    7302            3 :                                     thisCase.TotalCoolingEnergy,
    7303              :                                     OutputProcessor::TimeStepType::Zone,
    7304              :                                     OutputProcessor::StoreType::Sum,
    7305            3 :                                     thisCase.Name,
    7306              :                                     Constant::eResource::EnergyTransfer,
    7307              :                                     OutputProcessor::Group::Building,
    7308              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7309              :                                     "", // End-use sub category
    7310            3 :                                     thisCase.ZoneName);
    7311            6 :                 SetupOutputVariable(state,
    7312              :                                     "Refrigeration Case Evaporator Sensible Cooling Rate",
    7313              :                                     Constant::Units::W,
    7314            3 :                                     thisCase.SensCoolingEnergyRate,
    7315              :                                     OutputProcessor::TimeStepType::Zone,
    7316              :                                     OutputProcessor::StoreType::Average,
    7317            3 :                                     thisCase.Name);
    7318            6 :                 SetupOutputVariable(state,
    7319              :                                     "Refrigeration Case Evaporator Sensible Cooling Energy",
    7320              :                                     Constant::Units::J,
    7321            3 :                                     thisCase.SensCoolingEnergy,
    7322              :                                     OutputProcessor::TimeStepType::Zone,
    7323              :                                     OutputProcessor::StoreType::Sum,
    7324            3 :                                     thisCase.Name);
    7325            6 :                 SetupOutputVariable(state,
    7326              :                                     "Refrigeration Case Evaporator Latent Cooling Rate",
    7327              :                                     Constant::Units::W,
    7328            3 :                                     thisCase.LatCoolingEnergyRate,
    7329              :                                     OutputProcessor::TimeStepType::Zone,
    7330              :                                     OutputProcessor::StoreType::Average,
    7331            3 :                                     thisCase.Name);
    7332            6 :                 SetupOutputVariable(state,
    7333              :                                     "Refrigeration Case Evaporator Latent Cooling Energy",
    7334              :                                     Constant::Units::J,
    7335            3 :                                     thisCase.LatCoolingEnergy,
    7336              :                                     OutputProcessor::TimeStepType::Zone,
    7337              :                                     OutputProcessor::StoreType::Sum,
    7338            3 :                                     thisCase.Name);
    7339              : 
    7340            6 :                 SetupOutputVariable(state,
    7341              :                                     "Refrigeration Case Zone Sensible Cooling Rate",
    7342              :                                     Constant::Units::W,
    7343            3 :                                     thisCase.SensZoneCreditCoolRate,
    7344              :                                     OutputProcessor::TimeStepType::Zone,
    7345              :                                     OutputProcessor::StoreType::Average,
    7346            3 :                                     thisCase.Name);
    7347            6 :                 SetupOutputVariable(state,
    7348              :                                     "Refrigeration Case Zone Sensible Cooling Energy",
    7349              :                                     Constant::Units::J,
    7350            3 :                                     thisCase.SensZoneCreditCool,
    7351              :                                     OutputProcessor::TimeStepType::Zone,
    7352              :                                     OutputProcessor::StoreType::Sum,
    7353            3 :                                     thisCase.Name);
    7354            6 :                 SetupOutputVariable(state,
    7355              :                                     "Refrigeration Case Zone Sensible Heating Rate",
    7356              :                                     Constant::Units::W,
    7357            3 :                                     thisCase.SensZoneCreditHeatRate,
    7358              :                                     OutputProcessor::TimeStepType::Zone,
    7359              :                                     OutputProcessor::StoreType::Average,
    7360            3 :                                     thisCase.Name);
    7361            6 :                 SetupOutputVariable(state,
    7362              :                                     "Refrigeration Case Zone Sensible Heating Energy",
    7363              :                                     Constant::Units::J,
    7364            3 :                                     thisCase.SensZoneCreditHeat,
    7365              :                                     OutputProcessor::TimeStepType::Zone,
    7366              :                                     OutputProcessor::StoreType::Sum,
    7367            3 :                                     thisCase.Name);
    7368              : 
    7369            6 :                 SetupOutputVariable(state,
    7370              :                                     "Refrigeration Case Zone Latent Rate",
    7371              :                                     Constant::Units::W,
    7372            3 :                                     thisCase.LatZoneCreditRate,
    7373              :                                     OutputProcessor::TimeStepType::Zone,
    7374              :                                     OutputProcessor::StoreType::Average,
    7375            3 :                                     thisCase.Name);
    7376            6 :                 SetupOutputVariable(state,
    7377              :                                     "Refrigeration Case Zone Latent Energy",
    7378              :                                     Constant::Units::J,
    7379            3 :                                     thisCase.LatZoneCredit,
    7380              :                                     OutputProcessor::TimeStepType::Zone,
    7381              :                                     OutputProcessor::StoreType::Sum,
    7382            3 :                                     thisCase.Name);
    7383              : 
    7384            6 :                 SetupOutputVariable(state,
    7385              :                                     "Refrigeration Case Return Air Sensible Cooling Rate",
    7386              :                                     Constant::Units::W,
    7387            3 :                                     thisCase.SensHVACCreditCoolRate,
    7388              :                                     OutputProcessor::TimeStepType::Zone,
    7389              :                                     OutputProcessor::StoreType::Average,
    7390            3 :                                     thisCase.Name);
    7391            6 :                 SetupOutputVariable(state,
    7392              :                                     "Refrigeration Case Return Air Sensible Cooling Energy",
    7393              :                                     Constant::Units::J,
    7394            3 :                                     thisCase.SensHVACCreditCool,
    7395              :                                     OutputProcessor::TimeStepType::Zone,
    7396              :                                     OutputProcessor::StoreType::Sum,
    7397            3 :                                     thisCase.Name);
    7398            6 :                 SetupOutputVariable(state,
    7399              :                                     "Refrigeration Case Return Air Sensible Heating Rate",
    7400              :                                     Constant::Units::W,
    7401            3 :                                     thisCase.SensHVACCreditHeatRate,
    7402              :                                     OutputProcessor::TimeStepType::Zone,
    7403              :                                     OutputProcessor::StoreType::Average,
    7404            3 :                                     thisCase.Name);
    7405            6 :                 SetupOutputVariable(state,
    7406              :                                     "Refrigeration Case Return Air Sensible Heating Energy",
    7407              :                                     Constant::Units::J,
    7408            3 :                                     thisCase.SensHVACCreditHeat,
    7409              :                                     OutputProcessor::TimeStepType::Zone,
    7410              :                                     OutputProcessor::StoreType::Sum,
    7411            3 :                                     thisCase.Name);
    7412              : 
    7413            6 :                 SetupOutputVariable(state,
    7414              :                                     "Refrigeration Case Return Air Latent Rate",
    7415              :                                     Constant::Units::W,
    7416            3 :                                     thisCase.LatHVACCreditRate,
    7417              :                                     OutputProcessor::TimeStepType::Zone,
    7418              :                                     OutputProcessor::StoreType::Average,
    7419            3 :                                     thisCase.Name);
    7420            6 :                 SetupOutputVariable(state,
    7421              :                                     "Refrigeration Case Return Air Latent Energy",
    7422              :                                     Constant::Units::J,
    7423            3 :                                     thisCase.LatHVACCredit,
    7424              :                                     OutputProcessor::TimeStepType::Zone,
    7425              :                                     OutputProcessor::StoreType::Sum,
    7426            3 :                                     thisCase.Name);
    7427              : 
    7428            6 :                 SetupOutputVariable(state,
    7429              :                                     "Refrigeration Case Evaporator Fan Electricity Rate",
    7430              :                                     Constant::Units::W,
    7431            3 :                                     thisCase.ElecFanPower,
    7432              :                                     OutputProcessor::TimeStepType::Zone,
    7433              :                                     OutputProcessor::StoreType::Average,
    7434            3 :                                     thisCase.Name);
    7435            6 :                 SetupOutputVariable(state,
    7436              :                                     "Refrigeration Case Evaporator Fan Electricity Energy",
    7437              :                                     Constant::Units::J,
    7438            3 :                                     thisCase.ElecFanConsumption,
    7439              :                                     OutputProcessor::TimeStepType::Zone,
    7440              :                                     OutputProcessor::StoreType::Sum,
    7441            3 :                                     thisCase.Name,
    7442              :                                     Constant::eResource::Electricity,
    7443              :                                     OutputProcessor::Group::Building,
    7444              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7445              :                                     "General",
    7446            3 :                                     thisCase.ZoneName);
    7447            6 :                 SetupOutputVariable(state,
    7448              :                                     "Refrigeration Case Lighting Electricity Rate",
    7449              :                                     Constant::Units::W,
    7450            3 :                                     thisCase.ElecLightingPower,
    7451              :                                     OutputProcessor::TimeStepType::Zone,
    7452              :                                     OutputProcessor::StoreType::Average,
    7453            3 :                                     thisCase.Name);
    7454            6 :                 SetupOutputVariable(state,
    7455              :                                     "Refrigeration Case Lighting Electricity Energy",
    7456              :                                     Constant::Units::J,
    7457            3 :                                     thisCase.ElecLightingConsumption,
    7458              :                                     OutputProcessor::TimeStepType::Zone,
    7459              :                                     OutputProcessor::StoreType::Sum,
    7460            3 :                                     thisCase.Name,
    7461              :                                     Constant::eResource::Electricity,
    7462              :                                     OutputProcessor::Group::Building,
    7463              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7464              :                                     "General",
    7465            3 :                                     thisCase.ZoneName);
    7466              : 
    7467              :                 // Report defrost energy curve value only for cases having electric or hot-gas defrost with temperature termination
    7468            3 :                 if (thisCase.defrostType == RefCaseDefrostType::ElectricTerm || thisCase.defrostType == RefCaseDefrostType::HotFluidTerm) {
    7469            0 :                     SetupOutputVariable(state,
    7470              :                                         "Refrigeration Case Defrost Energy Correction Curve Value",
    7471              :                                         Constant::Units::None,
    7472            0 :                                         thisCase.DefEnergyCurveValue,
    7473              :                                         OutputProcessor::TimeStepType::Zone,
    7474              :                                         OutputProcessor::StoreType::Average,
    7475            0 :                                         thisCase.Name);
    7476              :                 }
    7477              : 
    7478            6 :                 SetupOutputVariable(state,
    7479              :                                     "Refrigeration Case Latent Credit Curve Value",
    7480              :                                     Constant::Units::None,
    7481            3 :                                     thisCase.LatEnergyCurveValue,
    7482              :                                     OutputProcessor::TimeStepType::Zone,
    7483              :                                     OutputProcessor::StoreType::Average,
    7484            3 :                                     thisCase.Name);
    7485              : 
    7486              :                 // Report only for cases having anti-sweat heaters
    7487            3 :                 if (thisCase.AntiSweatControlType > ASHtrCtrlType::None) {
    7488            0 :                     SetupOutputVariable(state,
    7489              :                                         "Refrigeration Case Anti Sweat Electricity Rate",
    7490              :                                         Constant::Units::W,
    7491            0 :                                         thisCase.ElecAntiSweatPower,
    7492              :                                         OutputProcessor::TimeStepType::Zone,
    7493              :                                         OutputProcessor::StoreType::Average,
    7494            0 :                                         thisCase.Name);
    7495            0 :                     SetupOutputVariable(state,
    7496              :                                         "Refrigeration Case Anti Sweat Electricity Energy",
    7497              :                                         Constant::Units::J,
    7498            0 :                                         thisCase.ElecAntiSweatConsumption,
    7499              :                                         OutputProcessor::TimeStepType::Zone,
    7500              :                                         OutputProcessor::StoreType::Sum,
    7501            0 :                                         thisCase.Name,
    7502              :                                         Constant::eResource::Electricity,
    7503              :                                         OutputProcessor::Group::Building,
    7504              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7505              :                                         "General",
    7506            0 :                                         thisCase.ZoneName);
    7507              :                 }
    7508              : 
    7509              :                 // Report only for cases using electric defrost
    7510              : 
    7511            3 :                 if (thisCase.defrostType == RefCaseDefrostType::Electric || thisCase.defrostType == RefCaseDefrostType::ElectricOnDemand ||
    7512            3 :                     thisCase.defrostType == RefCaseDefrostType::ElectricTerm) {
    7513            0 :                     SetupOutputVariable(state,
    7514              :                                         "Refrigeration Case Defrost Electricity Rate",
    7515              :                                         Constant::Units::W,
    7516            0 :                                         thisCase.ElecDefrostPower,
    7517              :                                         OutputProcessor::TimeStepType::Zone,
    7518              :                                         OutputProcessor::StoreType::Average,
    7519            0 :                                         thisCase.Name);
    7520            0 :                     SetupOutputVariable(state,
    7521              :                                         "Refrigeration Case Defrost Electricity Energy",
    7522              :                                         Constant::Units::J,
    7523            0 :                                         thisCase.ElecDefrostConsumption,
    7524              :                                         OutputProcessor::TimeStepType::Zone,
    7525              :                                         OutputProcessor::StoreType::Sum,
    7526            0 :                                         thisCase.Name,
    7527              :                                         Constant::eResource::Electricity,
    7528              :                                         OutputProcessor::Group::Building,
    7529              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7530              :                                         "General",
    7531            0 :                                         thisCase.ZoneName);
    7532              :                 }
    7533              : 
    7534              :                 // register refrigeration case credits as internal gains
    7535            3 :                 if (thisCase.ActualZoneNum > 0) {
    7536            3 :                     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          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7554              :         // Setup Report Variables for simulated  Walk In (do not report unused WalkIns)
    7555              :         // CurrentModuleObject='Refrigeration:WalkIn'
    7556            6 :         for (int walkInNum = 1; walkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInNum) {
    7557            3 :             auto &walkin = WalkIn(walkInNum);
    7558            3 :             if (walkin.NumSysAttach == 1) { // ensure no unuseds reported
    7559            6 :                 SetupOutputVariable(state,
    7560              :                                     "Refrigeration Walk In Evaporator Total Cooling Rate",
    7561              :                                     Constant::Units::W,
    7562            3 :                                     walkin.TotalCoolingLoad,
    7563              :                                     OutputProcessor::TimeStepType::Zone,
    7564              :                                     OutputProcessor::StoreType::Average,
    7565            3 :                                     walkin.Name);
    7566            6 :                 SetupOutputVariable(state,
    7567              :                                     "Refrigeration Walk In Evaporator Total Cooling Energy",
    7568              :                                     Constant::Units::J,
    7569            3 :                                     walkin.TotalCoolingEnergy,
    7570              :                                     OutputProcessor::TimeStepType::Zone,
    7571              :                                     OutputProcessor::StoreType::Sum,
    7572            3 :                                     walkin.Name);
    7573            6 :                 SetupOutputVariable(state,
    7574              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Rate",
    7575              :                                     Constant::Units::W,
    7576            3 :                                     walkin.TotSensCoolingEnergyRate,
    7577              :                                     OutputProcessor::TimeStepType::Zone,
    7578              :                                     OutputProcessor::StoreType::Average,
    7579            3 :                                     walkin.Name);
    7580            6 :                 SetupOutputVariable(state,
    7581              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Energy",
    7582              :                                     Constant::Units::J,
    7583            3 :                                     walkin.TotSensCoolingEnergy,
    7584              :                                     OutputProcessor::TimeStepType::Zone,
    7585              :                                     OutputProcessor::StoreType::Sum,
    7586            3 :                                     walkin.Name);
    7587            6 :                 SetupOutputVariable(state,
    7588              :                                     "Refrigeration Walk In Evaporator Latent Cooling Rate",
    7589              :                                     Constant::Units::W,
    7590            3 :                                     walkin.TotLatCoolingEnergyRate,
    7591              :                                     OutputProcessor::TimeStepType::Zone,
    7592              :                                     OutputProcessor::StoreType::Average,
    7593            3 :                                     walkin.Name);
    7594            6 :                 SetupOutputVariable(state,
    7595              :                                     "Refrigeration Walk In Evaporator Latent Cooling Energy",
    7596              :                                     Constant::Units::J,
    7597            3 :                                     walkin.TotLatCoolingEnergy,
    7598              :                                     OutputProcessor::TimeStepType::Zone,
    7599              :                                     OutputProcessor::StoreType::Sum,
    7600            3 :                                     walkin.Name);
    7601            6 :                 SetupOutputVariable(state,
    7602              :                                     "Refrigeration Walk In Ancillary Electricity Rate",
    7603              :                                     Constant::Units::W,
    7604            3 :                                     walkin.TotalElecPower,
    7605              :                                     OutputProcessor::TimeStepType::Zone,
    7606              :                                     OutputProcessor::StoreType::Average,
    7607            3 :                                     walkin.Name);
    7608            6 :                 SetupOutputVariable(state,
    7609              :                                     "Refrigeration Walk In Ancillary Electricity Energy",
    7610              :                                     Constant::Units::J,
    7611            3 :                                     walkin.TotalElecConsumption,
    7612              :                                     OutputProcessor::TimeStepType::Zone,
    7613              :                                     OutputProcessor::StoreType::Sum,
    7614            3 :                                     walkin.Name);
    7615            6 :                 SetupOutputVariable(state,
    7616              :                                     "Refrigeration Walk In Fan Electricity Rate",
    7617              :                                     Constant::Units::W,
    7618            3 :                                     walkin.ElecFanPower,
    7619              :                                     OutputProcessor::TimeStepType::Zone,
    7620              :                                     OutputProcessor::StoreType::Average,
    7621            3 :                                     walkin.Name);
    7622            6 :                 SetupOutputVariable(state,
    7623              :                                     "Refrigeration Walk In Fan Electricity Energy",
    7624              :                                     Constant::Units::J,
    7625            3 :                                     walkin.ElecFanConsumption,
    7626              :                                     OutputProcessor::TimeStepType::Zone,
    7627              :                                     OutputProcessor::StoreType::Sum,
    7628            3 :                                     walkin.Name,
    7629              :                                     Constant::eResource::Electricity,
    7630              :                                     OutputProcessor::Group::Building,
    7631              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7632              :                                     "General");
    7633            6 :                 SetupOutputVariable(state,
    7634              :                                     "Refrigeration Walk In Lighting Electricity Rate",
    7635              :                                     Constant::Units::W,
    7636            3 :                                     walkin.ElecLightingPower,
    7637              :                                     OutputProcessor::TimeStepType::Zone,
    7638              :                                     OutputProcessor::StoreType::Average,
    7639            3 :                                     walkin.Name);
    7640            6 :                 SetupOutputVariable(state,
    7641              :                                     "Refrigeration Walk In Lighting Electricity Energy",
    7642              :                                     Constant::Units::J,
    7643            3 :                                     walkin.ElecLightingConsumption,
    7644              :                                     OutputProcessor::TimeStepType::Zone,
    7645              :                                     OutputProcessor::StoreType::Sum,
    7646            3 :                                     walkin.Name,
    7647              :                                     Constant::eResource::Electricity,
    7648              :                                     OutputProcessor::Group::Building,
    7649              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7650              :                                     "General");
    7651            6 :                 SetupOutputVariable(state,
    7652              :                                     "Refrigeration Walk In Heater Electricity Rate",
    7653              :                                     Constant::Units::W,
    7654            3 :                                     walkin.ElecHeaterPower,
    7655              :                                     OutputProcessor::TimeStepType::Zone,
    7656              :                                     OutputProcessor::StoreType::Average,
    7657            3 :                                     walkin.Name);
    7658            6 :                 SetupOutputVariable(state,
    7659              :                                     "Refrigeration Walk In Heater Electricity Energy",
    7660              :                                     Constant::Units::J,
    7661            3 :                                     walkin.ElecHeaterConsumption,
    7662              :                                     OutputProcessor::TimeStepType::Zone,
    7663              :                                     OutputProcessor::StoreType::Sum,
    7664            3 :                                     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            3 :                 if (walkin.defrostType == DefrostType::Elec) {
    7672            6 :                     SetupOutputVariable(state,
    7673              :                                         "Refrigeration Walk In Defrost Electricity Rate",
    7674              :                                         Constant::Units::W,
    7675            3 :                                         walkin.ElecDefrostPower,
    7676              :                                         OutputProcessor::TimeStepType::Zone,
    7677              :                                         OutputProcessor::StoreType::Average,
    7678            3 :                                         walkin.Name);
    7679            6 :                     SetupOutputVariable(state,
    7680              :                                         "Refrigeration Walk In Defrost Electricity Energy",
    7681              :                                         Constant::Units::J,
    7682            3 :                                         walkin.ElecDefrostConsumption,
    7683              :                                         OutputProcessor::TimeStepType::Zone,
    7684              :                                         OutputProcessor::StoreType::Sum,
    7685            3 :                                         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            6 :                 for (int zoneId = 1; zoneId <= walkin.NumZones; ++zoneId) {
    7697              : 
    7698            3 :                     Walkin_and_zone_name = walkin.Name + "InZone" + walkin.ZoneName(zoneId);
    7699              : 
    7700            6 :                     SetupOutputVariable(state,
    7701              :                                         "Refrigeration Walk In Zone Sensible Cooling Rate",
    7702              :                                         Constant::Units::W,
    7703            3 :                                         walkin.SensZoneCreditCoolRate(zoneId),
    7704              :                                         OutputProcessor::TimeStepType::Zone,
    7705              :                                         OutputProcessor::StoreType::Average,
    7706              :                                         Walkin_and_zone_name);
    7707            6 :                     SetupOutputVariable(state,
    7708              :                                         "Refrigeration Walk In Zone Sensible Cooling Energy",
    7709              :                                         Constant::Units::J,
    7710            3 :                                         walkin.SensZoneCreditCool(zoneId),
    7711              :                                         OutputProcessor::TimeStepType::Zone,
    7712              :                                         OutputProcessor::StoreType::Sum,
    7713              :                                         Walkin_and_zone_name);
    7714            6 :                     SetupOutputVariable(state,
    7715              :                                         "Refrigeration Walk In Zone Sensible Heating Rate",
    7716              :                                         Constant::Units::W,
    7717            3 :                                         walkin.SensZoneCreditHeatRate(zoneId),
    7718              :                                         OutputProcessor::TimeStepType::Zone,
    7719              :                                         OutputProcessor::StoreType::Average,
    7720              :                                         Walkin_and_zone_name);
    7721            6 :                     SetupOutputVariable(state,
    7722              :                                         "Refrigeration Walk In Zone Sensible Heating Energy",
    7723              :                                         Constant::Units::J,
    7724            3 :                                         walkin.SensZoneCreditHeat(zoneId),
    7725              :                                         OutputProcessor::TimeStepType::Zone,
    7726              :                                         OutputProcessor::StoreType::Sum,
    7727              :                                         Walkin_and_zone_name);
    7728            6 :                     SetupOutputVariable(state,
    7729              :                                         "Refrigeration Walk In Zone Latent Rate",
    7730              :                                         Constant::Units::W,
    7731            3 :                                         walkin.LatZoneCreditRate(zoneId),
    7732              :                                         OutputProcessor::TimeStepType::Zone,
    7733              :                                         OutputProcessor::StoreType::Average,
    7734              :                                         Walkin_and_zone_name);
    7735            6 :                     SetupOutputVariable(state,
    7736              :                                         "Refrigeration Walk In Zone Latent Energy",
    7737              :                                         Constant::Units::J,
    7738            3 :                                         walkin.LatZoneCredit(zoneId),
    7739              :                                         OutputProcessor::TimeStepType::Zone,
    7740              :                                         OutputProcessor::StoreType::Sum,
    7741              :                                         Walkin_and_zone_name);
    7742              : 
    7743            3 :                     if (walkin.ZoneNum(zoneId) > 0) {
    7744            6 :                         SetupZoneInternalGain(state,
    7745            3 :                                               walkin.ZoneNum(zoneId),
    7746              :                                               Walkin_and_zone_name,
    7747              :                                               DataHeatBalance::IntGainType::RefrigerationWalkIn,
    7748            3 :                                               &walkin.SensZoneCreditRate(zoneId),
    7749              :                                               nullptr,
    7750              :                                               nullptr,
    7751            3 :                                               &walkin.LatZoneCreditRate(zoneId));
    7752              :                     }
    7753              : 
    7754              :                 } // ZoneID
    7755              :             } //(.NOT.  WalkIn( WalkInNum)%unusedWalkIn)
    7756              :         } // NumSimulationWalkIns
    7757              :     } // NumSimulationWalkIns > 0
    7758              : 
    7759          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7760              :         // Setup Report Variables for simulated Warehouse coils (do not report unused warehouse coils)
    7761              :         // CurrentModuleObject='Refrigeration:AirChiller'
    7762            0 :         for (int coilNum = 1; coilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilNum) {
    7763            0 :             auto &coil = WarehouseCoil(coilNum);
    7764            0 :             if (coil.NumSysAttach == 1) { // ensure no unuseds reported
    7765            0 :                 SetupOutputVariable(state,
    7766              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    7767              :                                     Constant::Units::W,
    7768            0 :                                     coil.TotalCoolingLoad,
    7769              :                                     OutputProcessor::TimeStepType::System,
    7770              :                                     OutputProcessor::StoreType::Average,
    7771            0 :                                     coil.Name);
    7772            0 :                 SetupOutputVariable(state,
    7773              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    7774              :                                     Constant::Units::J,
    7775            0 :                                     coil.TotalCoolingEnergy,
    7776              :                                     OutputProcessor::TimeStepType::System,
    7777              :                                     OutputProcessor::StoreType::Sum,
    7778            0 :                                     coil.Name);
    7779            0 :                 SetupOutputVariable(state,
    7780              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    7781              :                                     Constant::Units::W,
    7782            0 :                                     coil.SensCoolingEnergyRate,
    7783              :                                     OutputProcessor::TimeStepType::System,
    7784              :                                     OutputProcessor::StoreType::Average,
    7785            0 :                                     coil.Name);
    7786            0 :                 SetupOutputVariable(state,
    7787              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    7788              :                                     Constant::Units::J,
    7789            0 :                                     coil.SensCoolingEnergy,
    7790              :                                     OutputProcessor::TimeStepType::System,
    7791              :                                     OutputProcessor::StoreType::Sum,
    7792            0 :                                     coil.Name);
    7793            0 :                 SetupOutputVariable(state,
    7794              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    7795              :                                     Constant::Units::W,
    7796            0 :                                     coil.LatCreditRate,
    7797              :                                     OutputProcessor::TimeStepType::System,
    7798              :                                     OutputProcessor::StoreType::Average,
    7799            0 :                                     coil.Name);
    7800            0 :                 SetupOutputVariable(state,
    7801              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    7802              :                                     Constant::Units::J,
    7803            0 :                                     coil.LatCreditEnergy,
    7804              :                                     OutputProcessor::TimeStepType::System,
    7805              :                                     OutputProcessor::StoreType::Sum,
    7806            0 :                                     coil.Name);
    7807            0 :                 SetupOutputVariable(state,
    7808              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    7809              :                                     Constant::Units::kg_s,
    7810            0 :                                     coil.LatKgPerS_ToZone,
    7811              :                                     OutputProcessor::TimeStepType::System,
    7812              :                                     OutputProcessor::StoreType::Average,
    7813            0 :                                     coil.Name);
    7814            0 :                 SetupOutputVariable(state,
    7815              :                                     "Refrigeration Zone Air Chiller Total Electricity Rate",
    7816              :                                     Constant::Units::W,
    7817            0 :                                     coil.TotalElecPower,
    7818              :                                     OutputProcessor::TimeStepType::System,
    7819              :                                     OutputProcessor::StoreType::Average,
    7820            0 :                                     coil.Name);
    7821            0 :                 SetupOutputVariable(state,
    7822              :                                     "Refrigeration Zone Air Chiller Total Electricity Energy",
    7823              :                                     Constant::Units::J,
    7824            0 :                                     coil.TotalElecConsumption,
    7825              :                                     OutputProcessor::TimeStepType::System,
    7826              :                                     OutputProcessor::StoreType::Sum,
    7827            0 :                                     coil.Name); // components are metered separately
    7828            0 :                 SetupOutputVariable(state,
    7829              :                                     "Refrigeration Zone Air Chiller Fan Electricity Rate",
    7830              :                                     Constant::Units::W,
    7831            0 :                                     coil.ElecFanPower,
    7832              :                                     OutputProcessor::TimeStepType::System,
    7833              :                                     OutputProcessor::StoreType::Average,
    7834            0 :                                     coil.Name);
    7835            0 :                 SetupOutputVariable(state,
    7836              :                                     "Refrigeration Zone Air Chiller Fan Electric Energy",
    7837              :                                     Constant::Units::J,
    7838            0 :                                     coil.ElecFanConsumption,
    7839              :                                     OutputProcessor::TimeStepType::System,
    7840              :                                     OutputProcessor::StoreType::Sum,
    7841            0 :                                     coil.Name,
    7842              :                                     Constant::eResource::Electricity,
    7843              :                                     OutputProcessor::Group::Building,
    7844              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7845              :                                     "General");
    7846            0 :                 SetupOutputVariable(state,
    7847              :                                     "Refrigeration Zone Air Chiller Heater Electricity Rate",
    7848              :                                     Constant::Units::W,
    7849            0 :                                     coil.ElecHeaterPower,
    7850              :                                     OutputProcessor::TimeStepType::System,
    7851              :                                     OutputProcessor::StoreType::Average,
    7852            0 :                                     coil.Name);
    7853            0 :                 SetupOutputVariable(state,
    7854              :                                     "Refrigeration Zone Air Chiller Heater Electricity Energy",
    7855              :                                     Constant::Units::J,
    7856            0 :                                     coil.ElecHeaterConsumption,
    7857              :                                     OutputProcessor::TimeStepType::System,
    7858              :                                     OutputProcessor::StoreType::Sum,
    7859            0 :                                     coil.Name,
    7860              :                                     Constant::eResource::Electricity,
    7861              :                                     OutputProcessor::Group::Building,
    7862              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7863              :                                     "General");
    7864            0 :                 SetupOutputVariable(state,
    7865              :                                     "Refrigeration Zone Air Chiller Sensible Heat Ratio",
    7866              :                                     Constant::Units::None,
    7867            0 :                                     coil.SensHeatRatio,
    7868              :                                     OutputProcessor::TimeStepType::System,
    7869              :                                     OutputProcessor::StoreType::Average,
    7870            0 :                                     coil.Name);
    7871            0 :                 SetupOutputVariable(state,
    7872              :                                     "Refrigeration Zone Air Chiller Frost Accumulation Mass",
    7873              :                                     Constant::Units::kg,
    7874            0 :                                     coil.KgFrost,
    7875              :                                     OutputProcessor::TimeStepType::System,
    7876              :                                     OutputProcessor::StoreType::Average,
    7877            0 :                                     coil.Name);
    7878            0 :                 SetupOutputVariable(state,
    7879              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Rate",
    7880              :                                     Constant::Units::W,
    7881            0 :                                     coil.ReportTotalCoolCreditRate,
    7882              :                                     OutputProcessor::TimeStepType::System,
    7883              :                                     OutputProcessor::StoreType::Average,
    7884            0 :                                     coil.Name);
    7885            0 :                 SetupOutputVariable(state,
    7886              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Energy",
    7887              :                                     Constant::Units::J,
    7888            0 :                                     coil.ReportTotalCoolCreditEnergy,
    7889              :                                     OutputProcessor::TimeStepType::System,
    7890              :                                     OutputProcessor::StoreType::Sum,
    7891            0 :                                     coil.Name);
    7892            0 :                 SetupOutputVariable(state,
    7893              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Rate",
    7894              :                                     Constant::Units::W,
    7895            0 :                                     coil.ReportSensCoolCreditRate,
    7896              :                                     OutputProcessor::TimeStepType::System,
    7897              :                                     OutputProcessor::StoreType::Average,
    7898            0 :                                     coil.Name);
    7899            0 :                 SetupOutputVariable(state,
    7900              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Energy",
    7901              :                                     Constant::Units::J,
    7902            0 :                                     coil.ReportSensCoolCreditEnergy,
    7903              :                                     OutputProcessor::TimeStepType::System,
    7904              :                                     OutputProcessor::StoreType::Sum,
    7905            0 :                                     coil.Name);
    7906            0 :                 SetupOutputVariable(state,
    7907              :                                     "Refrigeration Zone Air Chiller Zone Heating Rate",
    7908              :                                     Constant::Units::W,
    7909            0 :                                     coil.ReportHeatingCreditRate,
    7910              :                                     OutputProcessor::TimeStepType::System,
    7911              :                                     OutputProcessor::StoreType::Average,
    7912            0 :                                     coil.Name);
    7913            0 :                 SetupOutputVariable(state,
    7914              :                                     "Refrigeration Zone Air Chiller Zone Heating Energy",
    7915              :                                     Constant::Units::J,
    7916            0 :                                     coil.ReportHeatingCreditEnergy,
    7917              :                                     OutputProcessor::TimeStepType::System,
    7918              :                                     OutputProcessor::StoreType::Sum,
    7919            0 :                                     coil.Name);
    7920              : 
    7921              :                 // Report only for Warehouse coils using electric defrost
    7922            0 :                 if (coil.defrostType == DefrostType::Elec) {
    7923            0 :                     SetupOutputVariable(state,
    7924              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Rate",
    7925              :                                         Constant::Units::W,
    7926            0 :                                         coil.ElecDefrostPower,
    7927              :                                         OutputProcessor::TimeStepType::System,
    7928              :                                         OutputProcessor::StoreType::Average,
    7929            0 :                                         coil.Name);
    7930            0 :                     SetupOutputVariable(state,
    7931              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Energy",
    7932              :                                         Constant::Units::J,
    7933            0 :                                         coil.ElecDefrostConsumption,
    7934              :                                         OutputProcessor::TimeStepType::System,
    7935              :                                         OutputProcessor::StoreType::Sum,
    7936            0 :                                         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          302 :     for (int zoneID = 1; zoneID <= state.dataGlobal->NumOfZones; ++zoneID) {
    7953          152 :         if (state.dataRefrigCase->RefrigPresentInZone(zoneID)) {
    7954            5 :             if (state.dataRefrigCase->HaveCasesOrWalkins) {
    7955           10 :                 SetupOutputVariable(state,
    7956              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Rate",
    7957              :                                     Constant::Units::W,
    7958            5 :                                     state.dataHeatBal->RefrigCaseCredit(zoneID).SenCaseCreditToZone,
    7959              :                                     OutputProcessor::TimeStepType::Zone,
    7960              :                                     OutputProcessor::StoreType::Average,
    7961            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7962           10 :                 SetupOutputVariable(state,
    7963              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Energy",
    7964              :                                     Constant::Units::J,
    7965            5 :                                     CaseWIZoneReport(zoneID).SenCaseCreditToZoneEnergy,
    7966              :                                     OutputProcessor::TimeStepType::Zone,
    7967              :                                     OutputProcessor::StoreType::Sum,
    7968            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7969           10 :                 SetupOutputVariable(state,
    7970              :                                     "Refrigeration Zone Case and Walk In Heating Rate",
    7971              :                                     Constant::Units::W,
    7972            5 :                                     CaseWIZoneReport(zoneID).HeatingToZoneRate,
    7973              :                                     OutputProcessor::TimeStepType::Zone,
    7974              :                                     OutputProcessor::StoreType::Average,
    7975            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7976           10 :                 SetupOutputVariable(state,
    7977              :                                     "Refrigeration Zone Case and Walk In Heating Energy",
    7978              :                                     Constant::Units::J,
    7979            5 :                                     CaseWIZoneReport(zoneID).HeatingToZoneEnergy,
    7980              :                                     OutputProcessor::TimeStepType::Zone,
    7981              :                                     OutputProcessor::StoreType::Sum,
    7982            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7983           10 :                 SetupOutputVariable(state,
    7984              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Rate",
    7985              :                                     Constant::Units::W,
    7986            5 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneRate,
    7987              :                                     OutputProcessor::TimeStepType::Zone,
    7988              :                                     OutputProcessor::StoreType::Average,
    7989            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7990           10 :                 SetupOutputVariable(state,
    7991              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Energy",
    7992              :                                     Constant::Units::J,
    7993            5 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneEnergy,
    7994              :                                     OutputProcessor::TimeStepType::Zone,
    7995              :                                     OutputProcessor::StoreType::Sum,
    7996            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7997           10 :                 SetupOutputVariable(state,
    7998              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Rate",
    7999              :                                     Constant::Units::W,
    8000            5 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneRate,
    8001              :                                     OutputProcessor::TimeStepType::Zone,
    8002              :                                     OutputProcessor::StoreType::Average,
    8003            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8004           10 :                 SetupOutputVariable(state,
    8005              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Energy",
    8006              :                                     Constant::Units::J,
    8007            5 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneEnergy,
    8008              :                                     OutputProcessor::TimeStepType::Zone,
    8009              :                                     OutputProcessor::StoreType::Sum,
    8010            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8011           10 :                 SetupOutputVariable(state,
    8012              :                                     "Refrigeration Zone Case and Walk In Total Cooling Rate",
    8013              :                                     Constant::Units::W,
    8014            5 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneRate,
    8015              :                                     OutputProcessor::TimeStepType::Zone,
    8016              :                                     OutputProcessor::StoreType::Average,
    8017            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8018           10 :                 SetupOutputVariable(state,
    8019              :                                     "Refrigeration Zone Case and Walk In Total Cooling Energy",
    8020              :                                     Constant::Units::J,
    8021            5 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneEnergy,
    8022              :                                     OutputProcessor::TimeStepType::Zone,
    8023              :                                     OutputProcessor::StoreType::Sum,
    8024            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8025           10 :                 SetupOutputVariable(state,
    8026              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Rate",
    8027              :                                     Constant::Units::W,
    8028            5 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneRate,
    8029              :                                     OutputProcessor::TimeStepType::Zone,
    8030              :                                     OutputProcessor::StoreType::Average,
    8031            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8032           10 :                 SetupOutputVariable(state,
    8033              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Energy",
    8034              :                                     Constant::Units::J,
    8035            5 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneEnergy,
    8036              :                                     OutputProcessor::TimeStepType::Zone,
    8037              :                                     OutputProcessor::StoreType::Sum,
    8038            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8039              :             } // HaveCasesOrWalkIns
    8040              : 
    8041            5 :             if (state.dataRefrigCase->HaveChillers) {
    8042            0 :                 SetupOutputVariable(state,
    8043              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Rate",
    8044              :                                     Constant::Units::W,
    8045            0 :                                     CoilSysCredit(zoneID).SenCreditToZoneRate,
    8046              :                                     OutputProcessor::TimeStepType::System,
    8047              :                                     OutputProcessor::StoreType::Average,
    8048            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8049            0 :                 SetupOutputVariable(state,
    8050              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Energy",
    8051              :                                     Constant::Units::J,
    8052            0 :                                     CoilSysCredit(zoneID).SenCreditToZoneEnergy,
    8053              :                                     OutputProcessor::TimeStepType::System,
    8054              :                                     OutputProcessor::StoreType::Sum,
    8055            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8056            0 :                 SetupOutputVariable(state,
    8057              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    8058              :                                     Constant::Units::W,
    8059            0 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneRate,
    8060              :                                     OutputProcessor::TimeStepType::System,
    8061              :                                     OutputProcessor::StoreType::Average,
    8062            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8063            0 :                 SetupOutputVariable(state,
    8064              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    8065              :                                     Constant::Units::J,
    8066            0 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneEnergy,
    8067              :                                     OutputProcessor::TimeStepType::System,
    8068              :                                     OutputProcessor::StoreType::Sum,
    8069            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8070            0 :                 SetupOutputVariable(state,
    8071              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    8072              :                                     Constant::Units::W,
    8073            0 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneRate,
    8074              :                                     OutputProcessor::TimeStepType::System,
    8075              :                                     OutputProcessor::StoreType::Average,
    8076            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8077            0 :                 SetupOutputVariable(state,
    8078              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    8079              :                                     Constant::Units::J,
    8080            0 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneEnergy,
    8081              :                                     OutputProcessor::TimeStepType::System,
    8082              :                                     OutputProcessor::StoreType::Sum,
    8083            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8084            0 :                 SetupOutputVariable(state,
    8085              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    8086              :                                     Constant::Units::kg_s,
    8087            0 :                                     CoilSysCredit(zoneID).ReportH2ORemovedKgPerS_FromZoneRate,
    8088              :                                     OutputProcessor::TimeStepType::System,
    8089              :                                     OutputProcessor::StoreType::Average,
    8090            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8091            0 :                 SetupOutputVariable(state,
    8092              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    8093              :                                     Constant::Units::W,
    8094            0 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneRate,
    8095              :                                     OutputProcessor::TimeStepType::System,
    8096              :                                     OutputProcessor::StoreType::Average,
    8097            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8098            0 :                 SetupOutputVariable(state,
    8099              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    8100              :                                     Constant::Units::J,
    8101            0 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneEnergy,
    8102              :                                     OutputProcessor::TimeStepType::System,
    8103              :                                     OutputProcessor::StoreType::Sum,
    8104            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8105            0 :                 SetupOutputVariable(state,
    8106              :                                     "Refrigeration Zone Air Chiller Heating Rate",
    8107              :                                     Constant::Units::W,
    8108            0 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneRate,
    8109              :                                     OutputProcessor::TimeStepType::System,
    8110              :                                     OutputProcessor::StoreType::Average,
    8111            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8112            0 :                 SetupOutputVariable(state,
    8113              :                                     "Refrigeration Zone Air Chiller Heating Energy",
    8114              :                                     Constant::Units::J,
    8115            0 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneEnergy,
    8116              :                                     OutputProcessor::TimeStepType::System,
    8117              :                                     OutputProcessor::StoreType::Sum,
    8118            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8119              :             } // HaveChillers
    8120              :         } // RefrigPresentInZone(ZoneID)
    8121              :     } // ZoneID
    8122              : 
    8123          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    8124              :         // CurrentModuleObject='Refrigeration:SecondarySystem'
    8125            0 :         for (int secondNum = 1; secondNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondNum) {
    8126            0 :             auto &secondary = Secondary(secondNum);
    8127            0 :             if (secondary.NumSysAttach == 1) {
    8128            0 :                 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            0 :                     SetupOutputVariable(state,
    8219              :                                         "Refrigeration Secondary Loop Pump Electricity Rate",
    8220              :                                         Constant::Units::W,
    8221            0 :                                         secondary.PumpPowerTotal,
    8222              :                                         OutputProcessor::TimeStepType::Zone,
    8223              :                                         OutputProcessor::StoreType::Average,
    8224            0 :                                         secondary.Name);
    8225            0 :                     SetupOutputVariable(state,
    8226              :                                         "Refrigeration Secondary Loop Pump Electricity Energy",
    8227              :                                         Constant::Units::J,
    8228            0 :                                         secondary.PumpElecEnergyTotal,
    8229              :                                         OutputProcessor::TimeStepType::Zone,
    8230              :                                         OutputProcessor::StoreType::Sum,
    8231            0 :                                         secondary.Name,
    8232              :                                         Constant::eResource::Electricity,
    8233              :                                         OutputProcessor::Group::Plant,
    8234              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8235              :                                         secondary.EndUseSubcategory);
    8236            0 :                     SetupOutputVariable(state,
    8237              :                                         "Refrigeration Secondary Loop Load Heat Transfer Rate",
    8238              :                                         Constant::Units::W,
    8239            0 :                                         secondary.TotalRefrigLoad,
    8240              :                                         OutputProcessor::TimeStepType::Zone,
    8241              :                                         OutputProcessor::StoreType::Average,
    8242            0 :                                         secondary.Name);
    8243            0 :                     SetupOutputVariable(state,
    8244              :                                         "Refrigeration Secondary Loop Load Heat Transfer Energy",
    8245              :                                         Constant::Units::J,
    8246            0 :                                         secondary.TotalRefrigEnergy,
    8247              :                                         OutputProcessor::TimeStepType::Zone,
    8248              :                                         OutputProcessor::StoreType::Sum,
    8249            0 :                                         secondary.Name);
    8250            0 :                     SetupOutputVariable(state,
    8251              :                                         "Refrigeration Secondary Loop Total Heat Transfer Rate",
    8252              :                                         Constant::Units::W,
    8253            0 :                                         secondary.TotalCoolingLoad,
    8254              :                                         OutputProcessor::TimeStepType::Zone,
    8255              :                                         OutputProcessor::StoreType::Average,
    8256            0 :                                         secondary.Name);
    8257            0 :                     SetupOutputVariable(state,
    8258              :                                         "Refrigeration Secondary Loop Total Heat Transfer Energy",
    8259              :                                         Constant::Units::J,
    8260            0 :                                         secondary.TotalCoolingEnergy,
    8261              :                                         OutputProcessor::TimeStepType::Zone,
    8262              :                                         OutputProcessor::StoreType::Sum,
    8263            0 :                                         secondary.Name);
    8264            0 :                     SetupOutputVariable(state,
    8265              :                                         "Refrigeration Secondary Loop Estimated Refrigerant Inventory Mass",
    8266              :                                         Constant::Units::kg,
    8267            0 :                                         secondary.RefInventory,
    8268              :                                         OutputProcessor::TimeStepType::Zone,
    8269              :                                         OutputProcessor::StoreType::Average,
    8270            0 :                                         secondary.Name);
    8271            0 :                     SetupOutputVariable(state,
    8272              :                                         "Refrigeration Secondary Loop Volume Flow Rate",
    8273              :                                         Constant::Units::m3_s,
    8274            0 :                                         secondary.FlowVolActual,
    8275              :                                         OutputProcessor::TimeStepType::Zone,
    8276              :                                         OutputProcessor::StoreType::Average,
    8277            0 :                                         secondary.Name);
    8278            0 :                     SetupOutputVariable(state,
    8279              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Rate",
    8280              :                                         Constant::Units::W,
    8281            0 :                                         secondary.DistPipeHeatGain,
    8282              :                                         OutputProcessor::TimeStepType::Zone,
    8283              :                                         OutputProcessor::StoreType::Average,
    8284            0 :                                         secondary.Name);
    8285            0 :                     SetupOutputVariable(state,
    8286              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Energy",
    8287              :                                         Constant::Units::J,
    8288            0 :                                         secondary.DistPipeHeatGainEnergy,
    8289              :                                         OutputProcessor::TimeStepType::Zone,
    8290              :                                         OutputProcessor::StoreType::Sum,
    8291            0 :                                         secondary.Name);
    8292            0 :                     SetupOutputVariable(state,
    8293              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Rate",
    8294              :                                         Constant::Units::W,
    8295            0 :                                         secondary.ReceiverHeatGain,
    8296              :                                         OutputProcessor::TimeStepType::Zone,
    8297              :                                         OutputProcessor::StoreType::Average,
    8298            0 :                                         secondary.Name);
    8299            0 :                     SetupOutputVariable(state,
    8300              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Energy",
    8301              :                                         Constant::Units::J,
    8302            0 :                                         secondary.ReceiverHeatGainEnergy,
    8303              :                                         OutputProcessor::TimeStepType::Zone,
    8304              :                                         OutputProcessor::StoreType::Sum,
    8305            0 :                                         secondary.Name);
    8306              :                 } // NOT coilflag so on Zone timestep
    8307            0 :                 if (secondary.ReceiverZoneNum > 0) {
    8308            0 :                     SetupZoneInternalGain(state,
    8309              :                                           secondary.ReceiverZoneNum,
    8310              :                                           secondary.Name,
    8311              :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryReceiver,
    8312              :                                           &secondary.ReceiverZoneHeatGain);
    8313              :                 }
    8314            0 :                 if (secondary.DistPipeZoneNum > 0) {
    8315            0 :                     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          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    8327              :         // CurrentModuleObject='Refrigeration:CompressorRack'
    8328           10 :         for (int rackNum = 1; rackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++rackNum) {
    8329            5 :             auto &rack = RefrigRack(rackNum);
    8330            5 :             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           10 :                 SetupOutputVariable(state,
    8494              :                                     "Refrigeration Compressor Rack Electricity Rate",
    8495              :                                     Constant::Units::W,
    8496            5 :                                     rack.RackCompressorPower,
    8497              :                                     OutputProcessor::TimeStepType::Zone,
    8498              :                                     OutputProcessor::StoreType::Average,
    8499            5 :                                     rack.Name);
    8500           10 :                 SetupOutputVariable(state,
    8501              :                                     "Refrigeration Compressor Rack Electricity Energy",
    8502              :                                     Constant::Units::J,
    8503            5 :                                     rack.RackElecConsumption,
    8504              :                                     OutputProcessor::TimeStepType::Zone,
    8505              :                                     OutputProcessor::StoreType::Sum,
    8506            5 :                                     rack.Name,
    8507              :                                     Constant::eResource::Electricity,
    8508              :                                     OutputProcessor::Group::Plant,
    8509              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8510              :                                     rack.EndUseSubcategory);
    8511           10 :                 SetupOutputVariable(state,
    8512              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Rate",
    8513              :                                     Constant::Units::W,
    8514            5 :                                     rack.ActualCondenserFanPower,
    8515              :                                     OutputProcessor::TimeStepType::Zone,
    8516              :                                     OutputProcessor::StoreType::Average,
    8517            5 :                                     rack.Name);
    8518           10 :                 SetupOutputVariable(state,
    8519              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Energy",
    8520              :                                     Constant::Units::J,
    8521            5 :                                     rack.CondenserFanConsumption,
    8522              :                                     OutputProcessor::TimeStepType::Zone,
    8523              :                                     OutputProcessor::StoreType::Sum,
    8524            5 :                                     rack.Name,
    8525              :                                     Constant::eResource::Electricity,
    8526              :                                     OutputProcessor::Group::Plant,
    8527              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8528              :                                     rack.EndUseSubcategory);
    8529           10 :                 SetupOutputVariable(state,
    8530              :                                     "Refrigeration Compressor Rack Total Heat Transfer Rate",
    8531              :                                     Constant::Units::W,
    8532            5 :                                     rack.RackCapacity,
    8533              :                                     OutputProcessor::TimeStepType::Zone,
    8534              :                                     OutputProcessor::StoreType::Average,
    8535            5 :                                     rack.Name);
    8536           10 :                 SetupOutputVariable(state,
    8537              :                                     "Refrigeration Compressor Rack Total Heat Transfer Energy",
    8538              :                                     Constant::Units::J,
    8539            5 :                                     rack.RackCoolingEnergy,
    8540              :                                     OutputProcessor::TimeStepType::Zone,
    8541              :                                     OutputProcessor::StoreType::Sum,
    8542            5 :                                     rack.Name,
    8543              :                                     Constant::eResource::EnergyTransfer,
    8544              :                                     OutputProcessor::Group::Plant,
    8545              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8546              :                                     rack.EndUseSubcategory);
    8547           10 :                 SetupOutputVariable(state,
    8548              :                                     "Refrigeration Compressor Rack COP",
    8549              :                                     Constant::Units::W_W,
    8550            5 :                                     rack.RackCompressorCOP,
    8551              :                                     OutputProcessor::TimeStepType::Zone,
    8552              :                                     OutputProcessor::StoreType::Average,
    8553            5 :                                     rack.Name);
    8554              : 
    8555            5 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8556            0 :                     SetupOutputVariable(state,
    8557              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8558              :                                         Constant::Units::W,
    8559            0 :                                         rack.ActualEvapPumpPower,
    8560              :                                         OutputProcessor::TimeStepType::Zone,
    8561              :                                         OutputProcessor::StoreType::Average,
    8562            0 :                                         rack.Name);
    8563            0 :                     SetupOutputVariable(state,
    8564              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8565              :                                         Constant::Units::J,
    8566            0 :                                         rack.EvapPumpConsumption,
    8567              :                                         OutputProcessor::TimeStepType::Zone,
    8568              :                                         OutputProcessor::StoreType::Sum,
    8569            0 :                                         rack.Name,
    8570              :                                         Constant::eResource::Electricity,
    8571              :                                         OutputProcessor::Group::Plant,
    8572              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8573              :                                         rack.EndUseSubcategory);
    8574            0 :                     SetupOutputVariable(state,
    8575              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8576              :                                         Constant::Units::W,
    8577            0 :                                         rack.BasinHeaterPower,
    8578              :                                         OutputProcessor::TimeStepType::Zone,
    8579              :                                         OutputProcessor::StoreType::Average,
    8580            0 :                                         rack.Name);
    8581            0 :                     SetupOutputVariable(state,
    8582              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8583              :                                         Constant::Units::J,
    8584            0 :                                         rack.BasinHeaterConsumption,
    8585              :                                         OutputProcessor::TimeStepType::Zone,
    8586              :                                         OutputProcessor::StoreType::Sum,
    8587            0 :                                         rack.Name,
    8588              :                                         Constant::eResource::Electricity,
    8589              :                                         OutputProcessor::Group::Plant,
    8590              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8591              :                                         rack.EndUseSubcategory);
    8592            0 :                     SetupOutputVariable(state,
    8593              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8594              :                                         Constant::Units::m3_s,
    8595            0 :                                         rack.EvapWaterConsumpRate,
    8596              :                                         OutputProcessor::TimeStepType::Zone,
    8597              :                                         OutputProcessor::StoreType::Average,
    8598            0 :                                         rack.Name);
    8599            0 :                     SetupOutputVariable(state,
    8600              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume",
    8601              :                                         Constant::Units::m3,
    8602            0 :                                         rack.EvapWaterConsumption,
    8603              :                                         OutputProcessor::TimeStepType::Zone,
    8604              :                                         OutputProcessor::StoreType::Sum,
    8605            0 :                                         rack.Name,
    8606              :                                         Constant::eResource::Water,
    8607              :                                         OutputProcessor::Group::Plant,
    8608              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8609              :                                         rack.EndUseSubcategory);
    8610              :                 } // condenser evap
    8611              : 
    8612            5 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8613            8 :                     SetupOutputVariable(state,
    8614              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Rate",
    8615              :                                         Constant::Units::W,
    8616            4 :                                         rack.SensZoneCreditHeatRate,
    8617              :                                         OutputProcessor::TimeStepType::Zone,
    8618              :                                         OutputProcessor::StoreType::Average,
    8619            4 :                                         rack.Name);
    8620            8 :                     SetupOutputVariable(state,
    8621              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Energy",
    8622              :                                         Constant::Units::J,
    8623            4 :                                         rack.SensZoneCreditHeat,
    8624              :                                         OutputProcessor::TimeStepType::Zone,
    8625              :                                         OutputProcessor::StoreType::Sum,
    8626            4 :                                         rack.Name);
    8627              : 
    8628            8 :                     SetupOutputVariable(state,
    8629              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Rate",
    8630              :                                         Constant::Units::W,
    8631            4 :                                         rack.SensHVACCreditHeatRate,
    8632              :                                         OutputProcessor::TimeStepType::Zone,
    8633              :                                         OutputProcessor::StoreType::Average,
    8634            4 :                                         rack.Name);
    8635            8 :                     SetupOutputVariable(state,
    8636              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Energy",
    8637              :                                         Constant::Units::J,
    8638            4 :                                         rack.SensHVACCreditHeat,
    8639              :                                         OutputProcessor::TimeStepType::Zone,
    8640              :                                         OutputProcessor::StoreType::Sum,
    8641            4 :                                         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            4 :                     int rackZoneNum = -1;
    8647            4 :                     if (rack.HeatRejectionZoneNum > 0) {
    8648            3 :                         rackZoneNum = rack.HeatRejectionZoneNum;
    8649              :                     } else {
    8650            1 :                         rackZoneNum = RefrigCase(rack.CaseNum(1)).ActualZoneNum;
    8651              :                     }
    8652            4 :                     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            5 :             if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) { // on HVAC time step no matter what
    8663            0 :                 SetupOutputVariable(state,
    8664              :                                     "Refrigeration Compressor Rack Condenser Mass Flow Rate",
    8665              :                                     Constant::Units::kg_s,
    8666            0 :                                     rack.MassFlowRate,
    8667              :                                     OutputProcessor::TimeStepType::System,
    8668              :                                     OutputProcessor::StoreType::Average,
    8669            0 :                                     rack.Name);
    8670              : 
    8671            0 :                 SetupOutputVariable(state,
    8672              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Rate",
    8673              :                                     Constant::Units::W,
    8674            0 :                                     rack.CondLoad,
    8675              :                                     OutputProcessor::TimeStepType::System,
    8676              :                                     OutputProcessor::StoreType::Average,
    8677            0 :                                     rack.Name);
    8678              : 
    8679            0 :                 SetupOutputVariable(state,
    8680              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Energy",
    8681              :                                     Constant::Units::J,
    8682            0 :                                     rack.CondEnergy,
    8683              :                                     OutputProcessor::TimeStepType::System,
    8684              :                                     OutputProcessor::StoreType::Sum,
    8685            0 :                                     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          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
    8695              :         // CurrentModuleObject='Refrigeration:System'
    8696            0 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++refrigSysNum) {
    8697            0 :             auto &sys = System(refrigSysNum);
    8698            0 :             if (sys.CoilFlag) { // system serves chillers and is solved on HVAC time step
    8699            0 :                 if (sys.NumStages == 1) {
    8700            0 :                     SetupOutputVariable(state,
    8701              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Rate",
    8702              :                                         Constant::Units::W,
    8703            0 :                                         sys.TotCompPower,
    8704              :                                         OutputProcessor::TimeStepType::System,
    8705              :                                         OutputProcessor::StoreType::Average,
    8706            0 :                                         sys.Name);
    8707            0 :                     SetupOutputVariable(state,
    8708              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Energy",
    8709              :                                         Constant::Units::J,
    8710            0 :                                         sys.TotCompElecConsump,
    8711              :                                         OutputProcessor::TimeStepType::System,
    8712              :                                         OutputProcessor::StoreType::Sum,
    8713            0 :                                         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            0 :                 SetupOutputVariable(state,
    8752              :                                     "Refrigeration Air Chiller System Average Compressor COP",
    8753              :                                     Constant::Units::W_W,
    8754            0 :                                     sys.AverageCompressorCOP,
    8755              :                                     OutputProcessor::TimeStepType::System,
    8756              :                                     OutputProcessor::StoreType::Average,
    8757            0 :                                     sys.Name);
    8758            0 :                 SetupOutputVariable(state,
    8759              :                                     "Refrigeration Air Chiller System Total Air Chiller Heat Transfer Rate",
    8760              :                                     Constant::Units::W,
    8761            0 :                                     sys.TotalCoolingLoad,
    8762              :                                     OutputProcessor::TimeStepType::System,
    8763              :                                     OutputProcessor::StoreType::Average,
    8764            0 :                                     sys.Name);
    8765            0 :                 SetupOutputVariable(state,
    8766              :                                     "Refrigeration Air Chiller System Total Case and Walk In Heat Transfer Energy",
    8767              :                                     Constant::Units::J,
    8768            0 :                                     sys.TotalCoolingEnergy,
    8769              :                                     OutputProcessor::TimeStepType::System,
    8770              :                                     OutputProcessor::StoreType::Sum,
    8771            0 :                                     sys.Name);
    8772            0 :                 SetupOutputVariable(state,
    8773              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Rate",
    8774              :                                     Constant::Units::W,
    8775            0 :                                     sys.TotTransferLoad,
    8776              :                                     OutputProcessor::TimeStepType::System,
    8777              :                                     OutputProcessor::StoreType::Average,
    8778            0 :                                     sys.Name);
    8779            0 :                 SetupOutputVariable(state,
    8780              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Energy",
    8781              :                                     Constant::Units::J,
    8782            0 :                                     sys.TotTransferEnergy,
    8783              :                                     OutputProcessor::TimeStepType::System,
    8784              :                                     OutputProcessor::StoreType::Sum,
    8785            0 :                                     sys.Name);
    8786            0 :                 SetupOutputVariable(state,
    8787              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Rate",
    8788              :                                     Constant::Units::W,
    8789            0 :                                     sys.PipeHeatLoad,
    8790              :                                     OutputProcessor::TimeStepType::System,
    8791              :                                     OutputProcessor::StoreType::Average,
    8792            0 :                                     sys.Name);
    8793            0 :                 SetupOutputVariable(state,
    8794              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Energy",
    8795              :                                     Constant::Units::J,
    8796            0 :                                     sys.PipeHeatEnergy,
    8797              :                                     OutputProcessor::TimeStepType::System,
    8798              :                                     OutputProcessor::StoreType::Sum,
    8799            0 :                                     sys.Name);
    8800            0 :                 if (sys.NumStages == 1) {
    8801            0 :                     SetupOutputVariable(state,
    8802              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Rate",
    8803              :                                         Constant::Units::W,
    8804            0 :                                         sys.TotCompCapacity,
    8805              :                                         OutputProcessor::TimeStepType::System,
    8806              :                                         OutputProcessor::StoreType::Average,
    8807            0 :                                         sys.Name);
    8808            0 :                     SetupOutputVariable(state,
    8809              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Energy",
    8810              :                                         Constant::Units::J,
    8811            0 :                                         sys.TotCompCoolingEnergy,
    8812              :                                         OutputProcessor::TimeStepType::System,
    8813              :                                         OutputProcessor::StoreType::Sum,
    8814            0 :                                         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            0 :                 SetupOutputVariable(state,
    8846              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Rate",
    8847              :                                     Constant::Units::W,
    8848            0 :                                     sys.NetHeatRejectLoad,
    8849              :                                     OutputProcessor::TimeStepType::System,
    8850              :                                     OutputProcessor::StoreType::Average,
    8851            0 :                                     sys.Name);
    8852            0 :                 SetupOutputVariable(state,
    8853              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Energy",
    8854              :                                     Constant::Units::J,
    8855            0 :                                     sys.NetHeatRejectEnergy,
    8856              :                                     OutputProcessor::TimeStepType::System,
    8857              :                                     OutputProcessor::StoreType::Sum,
    8858            0 :                                     sys.Name);
    8859            0 :                 SetupOutputVariable(state,
    8860              :                                     "Refrigeration Air Chiller System Estimated Refrigerant Inventory Mass",
    8861              :                                     Constant::Units::kg,
    8862            0 :                                     sys.RefInventory,
    8863              :                                     OutputProcessor::TimeStepType::System,
    8864              :                                     OutputProcessor::StoreType::Average,
    8865            0 :                                     sys.Name);
    8866            0 :                 if (sys.NumStages == 1) {
    8867            0 :                     SetupOutputVariable(state,
    8868              :                                         "Refrigeration Air Chiller System Estimated Refrigerant Mass Flow Rate",
    8869              :                                         Constant::Units::kg_s,
    8870            0 :                                         sys.RefMassFlowComps,
    8871              :                                         OutputProcessor::TimeStepType::System,
    8872              :                                         OutputProcessor::StoreType::Average,
    8873            0 :                                         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            0 :                 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            0 :                 SetupOutputVariable(state,
    8907              :                                     "Refrigeration Air Chiller System Condensing Temperature",
    8908              :                                     Constant::Units::C,
    8909            0 :                                     sys.TCondense,
    8910              :                                     OutputProcessor::TimeStepType::System,
    8911              :                                     OutputProcessor::StoreType::Average,
    8912            0 :                                     sys.Name);
    8913            0 :                 SetupOutputVariable(state,
    8914              :                                     "Refrigeration Air Chiller System Evaporating Temperature",
    8915              :                                     Constant::Units::C,
    8916            0 :                                     sys.TEvapNeeded,
    8917              :                                     OutputProcessor::TimeStepType::System,
    8918              :                                     OutputProcessor::StoreType::Average,
    8919            0 :                                     sys.Name);
    8920            0 :                 SetupOutputVariable(state,
    8921              :                                     "Refrigeration Air Chiller System Suction Temperature",
    8922              :                                     Constant::Units::C,
    8923            0 :                                     sys.TCompIn,
    8924              :                                     OutputProcessor::TimeStepType::System,
    8925              :                                     OutputProcessor::StoreType::Average,
    8926            0 :                                     sys.Name);
    8927            0 :                 SetupOutputVariable(state,
    8928              :                                     "Refrigeration Air Chiller System TXV Liquid Temperature",
    8929              :                                     Constant::Units::C,
    8930            0 :                                     sys.TLiqInActual,
    8931              :                                     OutputProcessor::TimeStepType::System,
    8932              :                                     OutputProcessor::StoreType::Average,
    8933            0 :                                     sys.Name);
    8934            0 :                 SetupOutputVariable(state,
    8935              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Rate",
    8936              :                                     Constant::Units::W,
    8937            0 :                                     sys.LSHXTrans,
    8938              :                                     OutputProcessor::TimeStepType::System,
    8939              :                                     OutputProcessor::StoreType::Average,
    8940            0 :                                     sys.Name);
    8941            0 :                 SetupOutputVariable(state,
    8942              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Energy",
    8943              :                                     Constant::Units::J,
    8944            0 :                                     sys.LSHXTransEnergy,
    8945              :                                     OutputProcessor::TimeStepType::System,
    8946              :                                     OutputProcessor::StoreType::Sum,
    8947            0 :                                     sys.Name);
    8948              :             } else { // NOT System(SysNum)%CoilFlag, so serving loads on zone timestep
    8949            0 :                 if (sys.NumStages == 1) {
    8950            0 :                     SetupOutputVariable(state,
    8951              :                                         "Refrigeration System Total Compressor Electricity Rate",
    8952              :                                         Constant::Units::W,
    8953            0 :                                         sys.TotCompPower,
    8954              :                                         OutputProcessor::TimeStepType::Zone,
    8955              :                                         OutputProcessor::StoreType::Average,
    8956            0 :                                         sys.Name);
    8957            0 :                     SetupOutputVariable(state,
    8958              :                                         "Refrigeration System Total Compressor Electricity Energy",
    8959              :                                         Constant::Units::J,
    8960            0 :                                         sys.TotCompElecConsump,
    8961              :                                         OutputProcessor::TimeStepType::Zone,
    8962              :                                         OutputProcessor::StoreType::Sum,
    8963            0 :                                         sys.Name);
    8964            0 :                 } else if (sys.NumStages == 2) {
    8965            0 :                     SetupOutputVariable(state,
    8966              :                                         "Refrigeration System Total Low Stage Compressor Electricity Rate",
    8967              :                                         Constant::Units::W,
    8968            0 :                                         sys.TotCompPower,
    8969              :                                         OutputProcessor::TimeStepType::Zone,
    8970              :                                         OutputProcessor::StoreType::Average,
    8971            0 :                                         sys.Name);
    8972            0 :                     SetupOutputVariable(state,
    8973              :                                         "Refrigeration System Total Low Stage Compressor Electricity Energy",
    8974              :                                         Constant::Units::J,
    8975            0 :                                         sys.TotCompElecConsump,
    8976              :                                         OutputProcessor::TimeStepType::Zone,
    8977              :                                         OutputProcessor::StoreType::Sum,
    8978            0 :                                         sys.Name);
    8979            0 :                     SetupOutputVariable(state,
    8980              :                                         "Refrigeration System Total High Stage Compressor Electricity Rate",
    8981              :                                         Constant::Units::W,
    8982            0 :                                         sys.TotHiStageCompPower,
    8983              :                                         OutputProcessor::TimeStepType::Zone,
    8984              :                                         OutputProcessor::StoreType::Average,
    8985            0 :                                         sys.Name);
    8986            0 :                     SetupOutputVariable(state,
    8987              :                                         "Refrigeration System Total High Stage Compressor Electricity Energy",
    8988              :                                         Constant::Units::J,
    8989            0 :                                         sys.TotHiStageCompElecConsump,
    8990              :                                         OutputProcessor::TimeStepType::Zone,
    8991              :                                         OutputProcessor::StoreType::Sum,
    8992            0 :                                         sys.Name);
    8993            0 :                     SetupOutputVariable(state,
    8994              :                                         "Refrigeration System Total Low and High Stage Compressor Electricity Energy",
    8995              :                                         Constant::Units::J,
    8996            0 :                                         sys.TotCompElecConsumpTwoStage,
    8997              :                                         OutputProcessor::TimeStepType::Zone,
    8998              :                                         OutputProcessor::StoreType::Sum,
    8999            0 :                                         sys.Name);
    9000              :                 } // NumStages
    9001            0 :                 SetupOutputVariable(state,
    9002              :                                     "Refrigeration System Average Compressor COP",
    9003              :                                     Constant::Units::W_W,
    9004            0 :                                     sys.AverageCompressorCOP,
    9005              :                                     OutputProcessor::TimeStepType::Zone,
    9006              :                                     OutputProcessor::StoreType::Average,
    9007            0 :                                     sys.Name);
    9008            0 :                 SetupOutputVariable(state,
    9009              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Rate",
    9010              :                                     Constant::Units::W,
    9011            0 :                                     sys.TotalCoolingLoad,
    9012              :                                     OutputProcessor::TimeStepType::Zone,
    9013              :                                     OutputProcessor::StoreType::Average,
    9014            0 :                                     sys.Name);
    9015            0 :                 SetupOutputVariable(state,
    9016              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Energy",
    9017              :                                     Constant::Units::J,
    9018            0 :                                     sys.TotalCoolingEnergy,
    9019              :                                     OutputProcessor::TimeStepType::Zone,
    9020              :                                     OutputProcessor::StoreType::Sum,
    9021            0 :                                     sys.Name);
    9022            0 :                 SetupOutputVariable(state,
    9023              :                                     "Refrigeration System Total Transferred Load Heat Transfer Rate",
    9024              :                                     Constant::Units::W,
    9025            0 :                                     sys.TotTransferLoad,
    9026              :                                     OutputProcessor::TimeStepType::Zone,
    9027              :                                     OutputProcessor::StoreType::Average,
    9028            0 :                                     sys.Name);
    9029            0 :                 SetupOutputVariable(state,
    9030              :                                     "Refrigeration System Total Transferred Load Heat Transfer Energy",
    9031              :                                     Constant::Units::J,
    9032            0 :                                     sys.TotTransferEnergy,
    9033              :                                     OutputProcessor::TimeStepType::Zone,
    9034              :                                     OutputProcessor::StoreType::Sum,
    9035            0 :                                     sys.Name);
    9036            0 :                 SetupOutputVariable(state,
    9037              :                                     "Refrigeration System Total Suction Pipe Heat Gain Rate",
    9038              :                                     Constant::Units::W,
    9039            0 :                                     sys.PipeHeatLoad,
    9040              :                                     OutputProcessor::TimeStepType::Zone,
    9041              :                                     OutputProcessor::StoreType::Average,
    9042            0 :                                     sys.Name);
    9043            0 :                 SetupOutputVariable(state,
    9044              :                                     "Refrigeration System Total Suction Pipe Heat Gain Energy",
    9045              :                                     Constant::Units::J,
    9046            0 :                                     sys.PipeHeatEnergy,
    9047              :                                     OutputProcessor::TimeStepType::Zone,
    9048              :                                     OutputProcessor::StoreType::Sum,
    9049            0 :                                     sys.Name);
    9050            0 :                 if (sys.NumStages == 1) {
    9051            0 :                     SetupOutputVariable(state,
    9052              :                                         "Refrigeration System Total Compressor Heat Transfer Rate",
    9053              :                                         Constant::Units::W,
    9054            0 :                                         sys.TotCompCapacity,
    9055              :                                         OutputProcessor::TimeStepType::Zone,
    9056              :                                         OutputProcessor::StoreType::Average,
    9057            0 :                                         sys.Name);
    9058            0 :                     SetupOutputVariable(state,
    9059              :                                         "Refrigeration System Total Compressor Heat Transfer Energy",
    9060              :                                         Constant::Units::J,
    9061            0 :                                         sys.TotCompCoolingEnergy,
    9062              :                                         OutputProcessor::TimeStepType::Zone,
    9063              :                                         OutputProcessor::StoreType::Sum,
    9064            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9065            0 :                 } else if (sys.NumStages == 2) {
    9066            0 :                     SetupOutputVariable(state,
    9067              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Rate",
    9068              :                                         Constant::Units::W,
    9069            0 :                                         sys.TotCompCapacity,
    9070              :                                         OutputProcessor::TimeStepType::Zone,
    9071              :                                         OutputProcessor::StoreType::Average,
    9072            0 :                                         sys.Name);
    9073            0 :                     SetupOutputVariable(state,
    9074              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Energy",
    9075              :                                         Constant::Units::J,
    9076            0 :                                         sys.TotCompCoolingEnergy,
    9077              :                                         OutputProcessor::TimeStepType::Zone,
    9078              :                                         OutputProcessor::StoreType::Sum,
    9079            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9080            0 :                     SetupOutputVariable(state,
    9081              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Rate",
    9082              :                                         Constant::Units::W,
    9083            0 :                                         sys.TotHiStageCompCapacity,
    9084              :                                         OutputProcessor::TimeStepType::Zone,
    9085              :                                         OutputProcessor::StoreType::Average,
    9086            0 :                                         sys.Name);
    9087            0 :                     SetupOutputVariable(state,
    9088              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Energy",
    9089              :                                         Constant::Units::J,
    9090            0 :                                         sys.TotHiStageCompCoolingEnergy,
    9091              :                                         OutputProcessor::TimeStepType::Zone,
    9092              :                                         OutputProcessor::StoreType::Sum,
    9093            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9094              :                 } // NumStages
    9095            0 :                 SetupOutputVariable(state,
    9096              :                                     "Refrigeration System Net Rejected Heat Transfer Rate",
    9097              :                                     Constant::Units::W,
    9098            0 :                                     sys.NetHeatRejectLoad,
    9099              :                                     OutputProcessor::TimeStepType::Zone,
    9100              :                                     OutputProcessor::StoreType::Average,
    9101            0 :                                     sys.Name);
    9102            0 :                 SetupOutputVariable(state,
    9103              :                                     "Refrigeration System Net Rejected Heat Transfer Energy",
    9104              :                                     Constant::Units::J,
    9105            0 :                                     sys.NetHeatRejectEnergy,
    9106              :                                     OutputProcessor::TimeStepType::Zone,
    9107              :                                     OutputProcessor::StoreType::Sum,
    9108            0 :                                     sys.Name);
    9109            0 :                 SetupOutputVariable(state,
    9110              :                                     "Refrigeration System Estimated Refrigerant Inventory Mass",
    9111              :                                     Constant::Units::kg,
    9112            0 :                                     sys.RefInventory,
    9113              :                                     OutputProcessor::TimeStepType::Zone,
    9114              :                                     OutputProcessor::StoreType::Average,
    9115            0 :                                     sys.Name);
    9116            0 :                 if (sys.NumStages == 1) {
    9117            0 :                     SetupOutputVariable(state,
    9118              :                                         "Refrigeration System Estimated Refrigerant Mass Flow Rate",
    9119              :                                         Constant::Units::kg_s,
    9120            0 :                                         sys.RefMassFlowComps,
    9121              :                                         OutputProcessor::TimeStepType::Zone,
    9122              :                                         OutputProcessor::StoreType::Average,
    9123            0 :                                         sys.Name);
    9124            0 :                 } else if (sys.NumStages == 2) {
    9125            0 :                     SetupOutputVariable(state,
    9126              :                                         "Refrigeration System Estimated Low Stage Refrigerant Mass Flow Rate",
    9127              :                                         Constant::Units::kg_s,
    9128            0 :                                         sys.RefMassFlowComps,
    9129              :                                         OutputProcessor::TimeStepType::Zone,
    9130              :                                         OutputProcessor::StoreType::Average,
    9131            0 :                                         sys.Name);
    9132            0 :                     SetupOutputVariable(state,
    9133              :                                         "Refrigeration System Estimated High Stage Refrigerant Mass Flow Rate",
    9134              :                                         Constant::Units::kg_s,
    9135            0 :                                         sys.RefMassFlowHiStageComps,
    9136              :                                         OutputProcessor::TimeStepType::Zone,
    9137              :                                         OutputProcessor::StoreType::Average,
    9138            0 :                                         sys.Name);
    9139              :                 } // NumStages
    9140            0 :                 if (sys.NumStages == 2) {
    9141            0 :                     SetupOutputVariable(state,
    9142              :                                         "Refrigeration System Intercooler Temperature",
    9143              :                                         Constant::Units::C,
    9144            0 :                                         sys.TIntercooler,
    9145              :                                         OutputProcessor::TimeStepType::Zone,
    9146              :                                         OutputProcessor::StoreType::Average,
    9147            0 :                                         sys.Name);
    9148            0 :                     SetupOutputVariable(state,
    9149              :                                         "Refrigeration System Intercooler Pressure",
    9150              :                                         Constant::Units::Pa,
    9151            0 :                                         sys.PIntercooler,
    9152              :                                         OutputProcessor::TimeStepType::Zone,
    9153              :                                         OutputProcessor::StoreType::Average,
    9154            0 :                                         sys.Name);
    9155              :                 }
    9156            0 :                 SetupOutputVariable(state,
    9157              :                                     "Refrigeration System Condensing Temperature",
    9158              :                                     Constant::Units::C,
    9159            0 :                                     sys.TCondense,
    9160              :                                     OutputProcessor::TimeStepType::Zone,
    9161              :                                     OutputProcessor::StoreType::Average,
    9162            0 :                                     sys.Name);
    9163            0 :                 SetupOutputVariable(state,
    9164              :                                     "Refrigeration System Evaporating Temperature",
    9165              :                                     Constant::Units::C,
    9166            0 :                                     sys.TEvapNeeded,
    9167              :                                     OutputProcessor::TimeStepType::Zone,
    9168              :                                     OutputProcessor::StoreType::Average,
    9169            0 :                                     sys.Name);
    9170            0 :                 SetupOutputVariable(state,
    9171              :                                     "Refrigeration System Suction Pipe Suction Temperature",
    9172              :                                     Constant::Units::C,
    9173            0 :                                     sys.TCompIn,
    9174              :                                     OutputProcessor::TimeStepType::Zone,
    9175              :                                     OutputProcessor::StoreType::Average,
    9176            0 :                                     sys.Name);
    9177            0 :                 SetupOutputVariable(state,
    9178              :                                     "Refrigeration System Thermostatic Expansion Valve Liquid Temperature",
    9179              :                                     Constant::Units::C,
    9180            0 :                                     sys.TLiqInActual,
    9181              :                                     OutputProcessor::TimeStepType::Zone,
    9182              :                                     OutputProcessor::StoreType::Average,
    9183            0 :                                     sys.Name);
    9184            0 :                 SetupOutputVariable(state,
    9185              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Rate",
    9186              :                                     Constant::Units::W,
    9187            0 :                                     sys.LSHXTrans,
    9188              :                                     OutputProcessor::TimeStepType::Zone,
    9189              :                                     OutputProcessor::StoreType::Average,
    9190            0 :                                     sys.Name);
    9191            0 :                 SetupOutputVariable(state,
    9192              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Energy",
    9193              :                                     Constant::Units::J,
    9194            0 :                                     sys.LSHXTransEnergy,
    9195              :                                     OutputProcessor::TimeStepType::Zone,
    9196              :                                     OutputProcessor::StoreType::Sum,
    9197            0 :                                     sys.Name);
    9198              :             } // System(coilflag)
    9199              : 
    9200            0 :             if (sys.SystemRejectHeatToZone) {
    9201            0 :                 if (Condenser(sys.CondenserNum(1)).InletAirZoneNum > 0) {
    9202            0 :                     SetupZoneInternalGain(state,
    9203            0 :                                           Condenser(sys.CondenserNum(1)).InletAirZoneNum,
    9204              :                                           sys.Name,
    9205              :                                           DataHeatBalance::IntGainType::RefrigerationSystemAirCooledCondenser,
    9206              :                                           &sys.NetHeatRejectLoad);
    9207              :                 }
    9208              : 
    9209            0 :                 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            0 :         for (int compNum = 1; compNum <= state.dataRefrigCase->NumSimulationCompressors; ++compNum) {
    9221            0 :             auto &comp = Compressor(compNum);
    9222              :             // CurrentModuleObject='Refrigeration:Compressor'
    9223            0 :             if (comp.NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9224            0 :                 if (comp.CoilFlag) {      // Compressor serving system with chillers on HVAC time step
    9225            0 :                     SetupOutputVariable(state,
    9226              :                                         "Refrigeration Air Chiller System Compressor Electricity Rate",
    9227              :                                         Constant::Units::W,
    9228            0 :                                         comp.Power,
    9229              :                                         OutputProcessor::TimeStepType::System,
    9230              :                                         OutputProcessor::StoreType::Average,
    9231            0 :                                         comp.Name);
    9232            0 :                     SetupOutputVariable(state,
    9233              :                                         "Refrigeration Air Chiller System Compressor Electricity Energy",
    9234              :                                         Constant::Units::J,
    9235            0 :                                         comp.ElecConsumption,
    9236              :                                         OutputProcessor::TimeStepType::System,
    9237              :                                         OutputProcessor::StoreType::Sum,
    9238            0 :                                         comp.Name,
    9239              :                                         Constant::eResource::Electricity,
    9240              :                                         OutputProcessor::Group::Plant,
    9241              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9242              :                                         comp.EndUseSubcategory);
    9243            0 :                     SetupOutputVariable(state,
    9244              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Rate",
    9245              :                                         Constant::Units::W,
    9246            0 :                                         comp.Capacity,
    9247              :                                         OutputProcessor::TimeStepType::System,
    9248              :                                         OutputProcessor::StoreType::Average,
    9249            0 :                                         comp.Name);
    9250            0 :                     SetupOutputVariable(state,
    9251              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Energy",
    9252              :                                         Constant::Units::J,
    9253            0 :                                         comp.CoolingEnergy,
    9254              :                                         OutputProcessor::TimeStepType::System,
    9255              :                                         OutputProcessor::StoreType::Sum,
    9256            0 :                                         comp.Name);
    9257            0 :                     SetupOutputVariable(state,
    9258              :                                         "Refrigeration Air Chiller System Compressor Runtime Fraction",
    9259              :                                         Constant::Units::None,
    9260            0 :                                         comp.LoadFactor,
    9261              :                                         OutputProcessor::TimeStepType::System,
    9262              :                                         OutputProcessor::StoreType::Average,
    9263            0 :                                         comp.Name);
    9264              :                 } else { // serve cases/walkins on zone time step
    9265            0 :                     SetupOutputVariable(state,
    9266              :                                         "Refrigeration Compressor Electricity Rate",
    9267              :                                         Constant::Units::W,
    9268            0 :                                         comp.Power,
    9269              :                                         OutputProcessor::TimeStepType::Zone,
    9270              :                                         OutputProcessor::StoreType::Average,
    9271            0 :                                         comp.Name);
    9272            0 :                     SetupOutputVariable(state,
    9273              :                                         "Refrigeration Compressor Electricity Energy",
    9274              :                                         Constant::Units::J,
    9275            0 :                                         comp.ElecConsumption,
    9276              :                                         OutputProcessor::TimeStepType::Zone,
    9277              :                                         OutputProcessor::StoreType::Sum,
    9278            0 :                                         comp.Name,
    9279              :                                         Constant::eResource::Electricity,
    9280              :                                         OutputProcessor::Group::Plant,
    9281              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9282              :                                         comp.EndUseSubcategory);
    9283            0 :                     SetupOutputVariable(state,
    9284              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9285              :                                         Constant::Units::W,
    9286            0 :                                         comp.Capacity,
    9287              :                                         OutputProcessor::TimeStepType::Zone,
    9288              :                                         OutputProcessor::StoreType::Average,
    9289            0 :                                         comp.Name);
    9290            0 :                     SetupOutputVariable(state,
    9291              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9292              :                                         Constant::Units::J,
    9293            0 :                                         comp.CoolingEnergy,
    9294              :                                         OutputProcessor::TimeStepType::Zone,
    9295              :                                         OutputProcessor::StoreType::Sum,
    9296            0 :                                         comp.Name);
    9297            0 :                     SetupOutputVariable(state,
    9298              :                                         "Refrigeration Compressor Runtime Fraction",
    9299              :                                         Constant::Units::None,
    9300            0 :                                         comp.LoadFactor,
    9301              :                                         OutputProcessor::TimeStepType::Zone,
    9302              :                                         OutputProcessor::StoreType::Average,
    9303            0 :                                         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            0 :         for (int condNum = 1; condNum <= state.dataRefrigCase->NumRefrigCondensers; ++condNum) {
    9310            0 :             auto &cond = Condenser(condNum);
    9311              :             // CurrentModuleObject='Refrigeration:Condenser:*'
    9312            0 :             if (cond.CoilFlag) { // Condenser serving system with chillers on HVAC time step
    9313            0 :                 SetupOutputVariable(state,
    9314              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Rate",
    9315              :                                     Constant::Units::W,
    9316            0 :                                     cond.CondLoad,
    9317              :                                     OutputProcessor::TimeStepType::System,
    9318              :                                     OutputProcessor::StoreType::Average,
    9319            0 :                                     cond.Name);
    9320            0 :                 SetupOutputVariable(state,
    9321              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Energy",
    9322              :                                     Constant::Units::J,
    9323            0 :                                     cond.CondEnergy,
    9324              :                                     OutputProcessor::TimeStepType::System,
    9325              :                                     OutputProcessor::StoreType::Sum,
    9326            0 :                                     cond.Name);
    9327              : 
    9328            0 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9329            0 :                     SetupOutputVariable(state,
    9330              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Rate",
    9331              :                                         Constant::Units::W,
    9332            0 :                                         cond.TotalHeatRecoveredLoad,
    9333              :                                         OutputProcessor::TimeStepType::System,
    9334              :                                         OutputProcessor::StoreType::Average,
    9335            0 :                                         cond.Name);
    9336            0 :                     SetupOutputVariable(state,
    9337              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Energy",
    9338              :                                         Constant::Units::J,
    9339            0 :                                         cond.TotalHeatRecoveredEnergy,
    9340              :                                         OutputProcessor::TimeStepType::System,
    9341              :                                         OutputProcessor::StoreType::Sum,
    9342            0 :                                         cond.Name);
    9343            0 :                     SetupOutputVariable(state,
    9344              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9345              :                                         Constant::Units::W,
    9346            0 :                                         cond.ExternalHeatRecoveredLoad,
    9347              :                                         OutputProcessor::TimeStepType::System,
    9348              :                                         OutputProcessor::StoreType::Average,
    9349            0 :                                         cond.Name);
    9350            0 :                     SetupOutputVariable(state,
    9351              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9352              :                                         Constant::Units::J,
    9353            0 :                                         cond.ExternalEnergyRecovered,
    9354              :                                         OutputProcessor::TimeStepType::System,
    9355              :                                         OutputProcessor::StoreType::Sum,
    9356            0 :                                         cond.Name);
    9357            0 :                     SetupOutputVariable(state,
    9358              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Rate",
    9359              :                                         Constant::Units::W,
    9360            0 :                                         cond.InternalHeatRecoveredLoad,
    9361              :                                         OutputProcessor::TimeStepType::System,
    9362              :                                         OutputProcessor::StoreType::Average,
    9363            0 :                                         cond.Name);
    9364            0 :                     SetupOutputVariable(state,
    9365              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Energy",
    9366              :                                         Constant::Units::J,
    9367            0 :                                         cond.InternalEnergyRecovered,
    9368              :                                         OutputProcessor::TimeStepType::System,
    9369              :                                         OutputProcessor::StoreType::Sum,
    9370            0 :                                         cond.Name);
    9371              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9372              : 
    9373            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9374            0 :                     SetupOutputVariable(state,
    9375              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    9376              :                                         Constant::Units::W,
    9377            0 :                                         cond.ActualFanPower,
    9378              :                                         OutputProcessor::TimeStepType::System,
    9379              :                                         OutputProcessor::StoreType::Average,
    9380            0 :                                         cond.Name);
    9381            0 :                     SetupOutputVariable(state,
    9382              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    9383              :                                         Constant::Units::J,
    9384            0 :                                         cond.FanElecEnergy,
    9385              :                                         OutputProcessor::TimeStepType::System,
    9386              :                                         OutputProcessor::StoreType::Sum,
    9387            0 :                                         cond.Name,
    9388              :                                         Constant::eResource::Electricity,
    9389              :                                         OutputProcessor::Group::Plant,
    9390              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9391              :                                         cond.EndUseSubcategory);
    9392              :                 } // Air cooled
    9393              : 
    9394            0 :                 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            0 :                 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            0 :                 SetupOutputVariable(state,
    9483              :                                     "Refrigeration System Condenser Heat Transfer Rate",
    9484              :                                     Constant::Units::W,
    9485            0 :                                     cond.CondLoad,
    9486              :                                     OutputProcessor::TimeStepType::Zone,
    9487              :                                     OutputProcessor::StoreType::Average,
    9488            0 :                                     cond.Name);
    9489            0 :                 SetupOutputVariable(state,
    9490              :                                     "Refrigeration System Condenser Heat Transfer Energy",
    9491              :                                     Constant::Units::J,
    9492            0 :                                     cond.CondEnergy,
    9493              :                                     OutputProcessor::TimeStepType::Zone,
    9494              :                                     OutputProcessor::StoreType::Sum,
    9495            0 :                                     cond.Name);
    9496              : 
    9497            0 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9498            0 :                     SetupOutputVariable(state,
    9499              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Rate",
    9500              :                                         Constant::Units::W,
    9501            0 :                                         cond.TotalHeatRecoveredLoad,
    9502              :                                         OutputProcessor::TimeStepType::Zone,
    9503              :                                         OutputProcessor::StoreType::Average,
    9504            0 :                                         cond.Name);
    9505            0 :                     SetupOutputVariable(state,
    9506              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Energy",
    9507              :                                         Constant::Units::J,
    9508            0 :                                         cond.TotalHeatRecoveredEnergy,
    9509              :                                         OutputProcessor::TimeStepType::Zone,
    9510              :                                         OutputProcessor::StoreType::Sum,
    9511            0 :                                         cond.Name);
    9512            0 :                     SetupOutputVariable(state,
    9513              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9514              :                                         Constant::Units::W,
    9515            0 :                                         cond.ExternalHeatRecoveredLoad,
    9516              :                                         OutputProcessor::TimeStepType::Zone,
    9517              :                                         OutputProcessor::StoreType::Average,
    9518            0 :                                         cond.Name);
    9519            0 :                     SetupOutputVariable(state,
    9520              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9521              :                                         Constant::Units::J,
    9522            0 :                                         cond.ExternalEnergyRecovered,
    9523              :                                         OutputProcessor::TimeStepType::Zone,
    9524              :                                         OutputProcessor::StoreType::Sum,
    9525            0 :                                         cond.Name);
    9526            0 :                     SetupOutputVariable(state,
    9527              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Rate",
    9528              :                                         Constant::Units::W,
    9529            0 :                                         cond.InternalHeatRecoveredLoad,
    9530              :                                         OutputProcessor::TimeStepType::Zone,
    9531              :                                         OutputProcessor::StoreType::Average,
    9532            0 :                                         cond.Name);
    9533            0 :                     SetupOutputVariable(state,
    9534              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Energy",
    9535              :                                         Constant::Units::J,
    9536            0 :                                         cond.InternalEnergyRecovered,
    9537              :                                         OutputProcessor::TimeStepType::Zone,
    9538              :                                         OutputProcessor::StoreType::Sum,
    9539            0 :                                         cond.Name);
    9540              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9541              : 
    9542            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9543            0 :                     SetupOutputVariable(state,
    9544              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9545              :                                         Constant::Units::W,
    9546            0 :                                         cond.ActualFanPower,
    9547              :                                         OutputProcessor::TimeStepType::Zone,
    9548              :                                         OutputProcessor::StoreType::Average,
    9549            0 :                                         cond.Name);
    9550            0 :                     SetupOutputVariable(state,
    9551              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9552              :                                         Constant::Units::J,
    9553            0 :                                         cond.FanElecEnergy,
    9554              :                                         OutputProcessor::TimeStepType::Zone,
    9555              :                                         OutputProcessor::StoreType::Sum,
    9556            0 :                                         cond.Name,
    9557              :                                         Constant::eResource::Electricity,
    9558              :                                         OutputProcessor::Group::Plant,
    9559              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9560              :                                         cond.EndUseSubcategory);
    9561              :                 } // Air cooled
    9562              : 
    9563            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9564            0 :                     SetupOutputVariable(state,
    9565              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9566              :                                         Constant::Units::W,
    9567            0 :                                         cond.ActualFanPower,
    9568              :                                         OutputProcessor::TimeStepType::Zone,
    9569              :                                         OutputProcessor::StoreType::Average,
    9570            0 :                                         cond.Name);
    9571            0 :                     SetupOutputVariable(state,
    9572              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9573              :                                         Constant::Units::J,
    9574            0 :                                         cond.FanElecEnergy,
    9575              :                                         OutputProcessor::TimeStepType::Zone,
    9576              :                                         OutputProcessor::StoreType::Sum,
    9577            0 :                                         cond.Name,
    9578              :                                         Constant::eResource::Electricity,
    9579              :                                         OutputProcessor::Group::Plant,
    9580              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9581              :                                         cond.EndUseSubcategory);
    9582            0 :                     SetupOutputVariable(state,
    9583              :                                         "Refrigeration System Condenser Pump Electricity Rate",
    9584              :                                         Constant::Units::W,
    9585            0 :                                         cond.ActualEvapPumpPower,
    9586              :                                         OutputProcessor::TimeStepType::Zone,
    9587              :                                         OutputProcessor::StoreType::Average,
    9588            0 :                                         cond.Name);
    9589            0 :                     SetupOutputVariable(state,
    9590              :                                         "Refrigeration System Condenser Pump Electricity Energy",
    9591              :                                         Constant::Units::J,
    9592            0 :                                         cond.EvapPumpConsumption,
    9593              :                                         OutputProcessor::TimeStepType::Zone,
    9594              :                                         OutputProcessor::StoreType::Sum,
    9595            0 :                                         cond.Name,
    9596              :                                         Constant::eResource::Electricity,
    9597              :                                         OutputProcessor::Group::Plant,
    9598              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9599              :                                         cond.EndUseSubcategory);
    9600            0 :                     SetupOutputVariable(state,
    9601              :                                         "Refrigeration System Condenser Basin Heater Electricity Rate",
    9602              :                                         Constant::Units::W,
    9603            0 :                                         cond.BasinHeaterPower,
    9604              :                                         OutputProcessor::TimeStepType::Zone,
    9605              :                                         OutputProcessor::StoreType::Average,
    9606            0 :                                         cond.Name);
    9607            0 :                     SetupOutputVariable(state,
    9608              :                                         "Refrigeration System Condenser Basin Heater Electricity Energy",
    9609              :                                         Constant::Units::J,
    9610            0 :                                         cond.BasinHeaterConsumption,
    9611              :                                         OutputProcessor::TimeStepType::Zone,
    9612              :                                         OutputProcessor::StoreType::Sum,
    9613            0 :                                         cond.Name,
    9614              :                                         Constant::eResource::Electricity,
    9615              :                                         OutputProcessor::Group::Plant,
    9616              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9617              :                                         cond.EndUseSubcategory);
    9618            0 :                     SetupOutputVariable(state,
    9619              :                                         "Refrigeration System Condenser Evaporated Water Volume Flow Rate",
    9620              :                                         Constant::Units::m3_s,
    9621            0 :                                         cond.EvapWaterConsumpRate,
    9622              :                                         OutputProcessor::TimeStepType::Zone,
    9623              :                                         OutputProcessor::StoreType::Average,
    9624            0 :                                         cond.Name);
    9625            0 :                     SetupOutputVariable(state,
    9626              :                                         "Refrigeration System Condenser Evaporated Water Volume",
    9627              :                                         Constant::Units::m3,
    9628            0 :                                         cond.EvapWaterConsumption,
    9629              :                                         OutputProcessor::TimeStepType::Zone,
    9630              :                                         OutputProcessor::StoreType::Sum,
    9631            0 :                                         cond.Name,
    9632              :                                         Constant::eResource::Water,
    9633              :                                         OutputProcessor::Group::Plant,
    9634              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9635              :                                         cond.EndUseSubcategory);
    9636              :                 } // Evaporative Condenser Variables
    9637              : 
    9638            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9639            0 :                     SetupOutputVariable(state,
    9640              :                                         "Refrigeration System Condenser Water Mass Flow Rate",
    9641              :                                         Constant::Units::kg_s,
    9642            0 :                                         cond.MassFlowRate,
    9643              :                                         OutputProcessor::TimeStepType::System,
    9644              :                                         OutputProcessor::StoreType::Average,
    9645            0 :                                         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            0 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    9652            0 :             for (int subcoolNum = 1; subcoolNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++subcoolNum) {
    9653            0 :                 auto &cooler = Subcooler(subcoolNum);
    9654              :                 // CurrentModuleObject='Refrigeration:Subcooler'
    9655            0 :                 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            0 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9674            0 :                         SetupOutputVariable(state,
    9675              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Rate",
    9676              :                                             Constant::Units::W,
    9677            0 :                                             cooler.MechSCTransLoad,
    9678              :                                             OutputProcessor::TimeStepType::System,
    9679              :                                             OutputProcessor::StoreType::Average,
    9680            0 :                                             cooler.Name);
    9681            0 :                         SetupOutputVariable(state,
    9682              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Energy",
    9683              :                                             Constant::Units::J,
    9684            0 :                                             cooler.MechSCTransEnergy,
    9685              :                                             OutputProcessor::TimeStepType::System,
    9686              :                                             OutputProcessor::StoreType::Sum,
    9687            0 :                                             cooler.Name);
    9688              :                     }
    9689              :                 } // Subcoolers on system serving chillers
    9690              :             } // Subcoolnum on NumSimulationSubcoolers
    9691              :         } // NumSimulationSubcoolers > 0
    9692              : 
    9693              :     } // NumRefrigSystems > 0
    9694              : 
    9695          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9696              :         // CurrentModuleObject='Refrigeration:TranscriticalSystem'
    9697            0 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++refrigSysNum) {
    9698            0 :             auto &sys = TransSystem(refrigSysNum);
    9699              :             // for both SingleStage and TwoStage systems (medium temperature loads present)
    9700            0 :             SetupOutputVariable(state,
    9701              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Rate",
    9702              :                                 Constant::Units::W,
    9703            0 :                                 sys.TotCompPowerHP,
    9704              :                                 OutputProcessor::TimeStepType::Zone,
    9705              :                                 OutputProcessor::StoreType::Average,
    9706            0 :                                 sys.Name);
    9707            0 :             SetupOutputVariable(state,
    9708              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Energy",
    9709              :                                 Constant::Units::J,
    9710            0 :                                 sys.TotCompElecConsumpHP,
    9711              :                                 OutputProcessor::TimeStepType::Zone,
    9712              :                                 OutputProcessor::StoreType::Sum,
    9713            0 :                                 sys.Name);
    9714            0 :             SetupOutputVariable(state,
    9715              :                                 "Refrigeration Transcritical System Total Compressor Electricity Energy",
    9716              :                                 Constant::Units::J,
    9717            0 :                                 sys.TotCompElecConsump,
    9718              :                                 OutputProcessor::TimeStepType::Zone,
    9719              :                                 OutputProcessor::StoreType::Sum,
    9720            0 :                                 sys.Name);
    9721            0 :             SetupOutputVariable(state,
    9722              :                                 "Refrigeration Transcritical System Average COP",
    9723              :                                 Constant::Units::W_W,
    9724            0 :                                 sys.AverageCompressorCOP,
    9725              :                                 OutputProcessor::TimeStepType::Zone,
    9726              :                                 OutputProcessor::StoreType::Average,
    9727            0 :                                 sys.Name);
    9728            0 :             SetupOutputVariable(state,
    9729              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Rate",
    9730              :                                 Constant::Units::W,
    9731            0 :                                 sys.TotalCoolingLoadMT,
    9732              :                                 OutputProcessor::TimeStepType::Zone,
    9733              :                                 OutputProcessor::StoreType::Average,
    9734            0 :                                 sys.Name);
    9735            0 :             SetupOutputVariable(state,
    9736              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Energy",
    9737              :                                 Constant::Units::J,
    9738            0 :                                 sys.TotalCoolingEnergyMT,
    9739              :                                 OutputProcessor::TimeStepType::Zone,
    9740              :                                 OutputProcessor::StoreType::Sum,
    9741            0 :                                 sys.Name);
    9742            0 :             SetupOutputVariable(state,
    9743              :                                 "Refrigeration Transcritical System Total Cases and Walk Ins Heat Transfer Energy",
    9744              :                                 Constant::Units::J,
    9745            0 :                                 sys.TotalCoolingEnergy,
    9746              :                                 OutputProcessor::TimeStepType::Zone,
    9747              :                                 OutputProcessor::StoreType::Sum,
    9748            0 :                                 sys.Name);
    9749            0 :             SetupOutputVariable(state,
    9750              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Rate",
    9751              :                                 Constant::Units::W,
    9752            0 :                                 sys.PipeHeatLoadMT,
    9753              :                                 OutputProcessor::TimeStepType::Zone,
    9754              :                                 OutputProcessor::StoreType::Average,
    9755            0 :                                 sys.Name);
    9756            0 :             SetupOutputVariable(state,
    9757              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Energy",
    9758              :                                 Constant::Units::J,
    9759            0 :                                 sys.PipeHeatEnergyMT,
    9760              :                                 OutputProcessor::TimeStepType::Zone,
    9761              :                                 OutputProcessor::StoreType::Sum,
    9762            0 :                                 sys.Name);
    9763            0 :             SetupOutputVariable(state,
    9764              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Rate",
    9765              :                                 Constant::Units::W,
    9766            0 :                                 sys.TotCompCapacityHP,
    9767              :                                 OutputProcessor::TimeStepType::Zone,
    9768              :                                 OutputProcessor::StoreType::Average,
    9769            0 :                                 sys.Name);
    9770            0 :             SetupOutputVariable(state,
    9771              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Energy",
    9772              :                                 Constant::Units::J,
    9773            0 :                                 sys.TotCompCoolingEnergyHP,
    9774              :                                 OutputProcessor::TimeStepType::Zone,
    9775              :                                 OutputProcessor::StoreType::Sum,
    9776            0 :                                 sys.Name); // indiv compressors go to meter, not system sum
    9777            0 :             SetupOutputVariable(state,
    9778              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Rate",
    9779              :                                 Constant::Units::W,
    9780            0 :                                 sys.NetHeatRejectLoad,
    9781              :                                 OutputProcessor::TimeStepType::Zone,
    9782              :                                 OutputProcessor::StoreType::Average,
    9783            0 :                                 sys.Name);
    9784            0 :             SetupOutputVariable(state,
    9785              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Energy",
    9786              :                                 Constant::Units::J,
    9787            0 :                                 sys.NetHeatRejectEnergy,
    9788              :                                 OutputProcessor::TimeStepType::Zone,
    9789              :                                 OutputProcessor::StoreType::Sum,
    9790            0 :                                 sys.Name);
    9791            0 :             SetupOutputVariable(state,
    9792              :                                 "Refrigeration Transcritical System Estimated Refrigerant Inventory Mass",
    9793              :                                 Constant::Units::kg,
    9794            0 :                                 sys.RefInventory,
    9795              :                                 OutputProcessor::TimeStepType::Zone,
    9796              :                                 OutputProcessor::StoreType::Average,
    9797            0 :                                 sys.Name);
    9798            0 :             SetupOutputVariable(state,
    9799              :                                 "Refrigeration Transcritical System Refrigerant Mass Flow Rate",
    9800              :                                 Constant::Units::kg_s,
    9801            0 :                                 sys.RefMassFlowComps,
    9802              :                                 OutputProcessor::TimeStepType::Zone,
    9803              :                                 OutputProcessor::StoreType::Average,
    9804            0 :                                 sys.Name);
    9805            0 :             SetupOutputVariable(state,
    9806              :                                 "Refrigeration Transcritical System Medium Temperature Evaporating Temperature",
    9807              :                                 Constant::Units::C,
    9808            0 :                                 sys.TEvapNeededMT,
    9809              :                                 OutputProcessor::TimeStepType::Zone,
    9810              :                                 OutputProcessor::StoreType::Average,
    9811            0 :                                 sys.Name);
    9812            0 :             SetupOutputVariable(state,
    9813              :                                 "Refrigeration Transcritical System Medium Temperature Suction Temperature",
    9814              :                                 Constant::Units::C,
    9815            0 :                                 sys.TCompInHP,
    9816              :                                 OutputProcessor::TimeStepType::Zone,
    9817              :                                 OutputProcessor::StoreType::Average,
    9818            0 :                                 sys.Name);
    9819            0 :             if (sys.transSysType == TransSysType::TwoStage) { // for TwoStage system only (low temperature loads present)
    9820            0 :                 SetupOutputVariable(state,
    9821              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Rate",
    9822              :                                     Constant::Units::W,
    9823            0 :                                     sys.TotCompPowerLP,
    9824              :                                     OutputProcessor::TimeStepType::Zone,
    9825              :                                     OutputProcessor::StoreType::Average,
    9826            0 :                                     sys.Name);
    9827            0 :                 SetupOutputVariable(state,
    9828              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Energy",
    9829              :                                     Constant::Units::J,
    9830            0 :                                     sys.TotCompElecConsumpLP,
    9831              :                                     OutputProcessor::TimeStepType::Zone,
    9832              :                                     OutputProcessor::StoreType::Sum,
    9833            0 :                                     sys.Name);
    9834            0 :                 SetupOutputVariable(state,
    9835              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Rate",
    9836              :                                     Constant::Units::W,
    9837            0 :                                     sys.TotalCoolingLoadLT,
    9838              :                                     OutputProcessor::TimeStepType::Zone,
    9839              :                                     OutputProcessor::StoreType::Average,
    9840            0 :                                     sys.Name);
    9841            0 :                 SetupOutputVariable(state,
    9842              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Energy",
    9843              :                                     Constant::Units::J,
    9844            0 :                                     sys.TotalCoolingEnergyLT,
    9845              :                                     OutputProcessor::TimeStepType::Zone,
    9846              :                                     OutputProcessor::StoreType::Sum,
    9847            0 :                                     sys.Name);
    9848            0 :                 SetupOutputVariable(state,
    9849              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Rate",
    9850              :                                     Constant::Units::W,
    9851            0 :                                     sys.PipeHeatLoadLT,
    9852              :                                     OutputProcessor::TimeStepType::Zone,
    9853              :                                     OutputProcessor::StoreType::Average,
    9854            0 :                                     sys.Name);
    9855            0 :                 SetupOutputVariable(state,
    9856              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Energy",
    9857              :                                     Constant::Units::J,
    9858            0 :                                     sys.PipeHeatEnergyLT,
    9859              :                                     OutputProcessor::TimeStepType::Zone,
    9860              :                                     OutputProcessor::StoreType::Sum,
    9861            0 :                                     sys.Name);
    9862            0 :                 SetupOutputVariable(state,
    9863              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Rate",
    9864              :                                     Constant::Units::W,
    9865            0 :                                     sys.TotCompCapacityLP,
    9866              :                                     OutputProcessor::TimeStepType::Zone,
    9867              :                                     OutputProcessor::StoreType::Average,
    9868            0 :                                     sys.Name);
    9869            0 :                 SetupOutputVariable(state,
    9870              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Energy",
    9871              :                                     Constant::Units::J,
    9872            0 :                                     sys.TotCompCoolingEnergyLP,
    9873              :                                     OutputProcessor::TimeStepType::Zone,
    9874              :                                     OutputProcessor::StoreType::Sum,
    9875            0 :                                     sys.Name); // indiv compressors go to meter, not system sum
    9876            0 :                 SetupOutputVariable(state,
    9877              :                                     "Refrigeration Transcritical System Low Temperature Evaporating Temperature",
    9878              :                                     Constant::Units::C,
    9879            0 :                                     sys.TEvapNeededLT,
    9880              :                                     OutputProcessor::TimeStepType::Zone,
    9881              :                                     OutputProcessor::StoreType::Average,
    9882            0 :                                     sys.Name);
    9883            0 :                 SetupOutputVariable(state,
    9884              :                                     "Refrigeration Transcritical System Low Temperature Suction Temperature",
    9885              :                                     Constant::Units::C,
    9886            0 :                                     sys.TCompInLP,
    9887              :                                     OutputProcessor::TimeStepType::Zone,
    9888              :                                     OutputProcessor::StoreType::Average,
    9889            0 :                                     sys.Name);
    9890              :             } // (sys%TransSysType == 2)
    9891              : 
    9892            0 :             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            0 :             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            0 :             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            0 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsLP; ++compIndex) {
    9919            0 :                 int compNum = sys.CompressorNumLP(compIndex);
    9920              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9921            0 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9922            0 :                     SetupOutputVariable(state,
    9923              :                                         "Refrigeration Compressor Electricity Rate",
    9924              :                                         Constant::Units::W,
    9925            0 :                                         Compressor(compNum).Power,
    9926              :                                         OutputProcessor::TimeStepType::Zone,
    9927              :                                         OutputProcessor::StoreType::Average,
    9928            0 :                                         Compressor(compNum).Name);
    9929            0 :                     SetupOutputVariable(state,
    9930              :                                         "Refrigeration Compressor Electricity Energy",
    9931              :                                         Constant::Units::J,
    9932            0 :                                         Compressor(compNum).ElecConsumption,
    9933              :                                         OutputProcessor::TimeStepType::Zone,
    9934              :                                         OutputProcessor::StoreType::Sum,
    9935            0 :                                         Compressor(compNum).Name,
    9936              :                                         Constant::eResource::Electricity,
    9937              :                                         OutputProcessor::Group::Plant,
    9938              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9939            0 :                                         Compressor(compNum).EndUseSubcategory);
    9940            0 :                     SetupOutputVariable(state,
    9941              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9942              :                                         Constant::Units::W,
    9943            0 :                                         Compressor(compNum).Capacity,
    9944              :                                         OutputProcessor::TimeStepType::Zone,
    9945              :                                         OutputProcessor::StoreType::Average,
    9946            0 :                                         Compressor(compNum).Name);
    9947            0 :                     SetupOutputVariable(state,
    9948              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9949              :                                         Constant::Units::J,
    9950            0 :                                         Compressor(compNum).CoolingEnergy,
    9951              :                                         OutputProcessor::TimeStepType::Zone,
    9952              :                                         OutputProcessor::StoreType::Sum,
    9953            0 :                                         Compressor(compNum).Name);
    9954            0 :                     SetupOutputVariable(state,
    9955              :                                         "Refrigeration Compressor Runtime Fraction",
    9956              :                                         Constant::Units::None,
    9957            0 :                                         Compressor(compNum).LoadFactor,
    9958              :                                         OutputProcessor::TimeStepType::Zone,
    9959              :                                         OutputProcessor::StoreType::Average,
    9960            0 :                                         Compressor(compNum).Name);
    9961              :                 } // NumSysAttach
    9962              :             } // sys%NumCompressorsLP
    9963              : 
    9964              :             // HP compressors
    9965            0 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsHP; ++compIndex) {
    9966            0 :                 int compNum = sys.CompressorNumHP(compIndex);
    9967              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9968            0 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9969            0 :                     SetupOutputVariable(state,
    9970              :                                         "Refrigeration Compressor Electricity Rate",
    9971              :                                         Constant::Units::W,
    9972            0 :                                         Compressor(compNum).Power,
    9973              :                                         OutputProcessor::TimeStepType::Zone,
    9974              :                                         OutputProcessor::StoreType::Average,
    9975            0 :                                         Compressor(compNum).Name);
    9976            0 :                     SetupOutputVariable(state,
    9977              :                                         "Refrigeration Compressor Electricity Energy",
    9978              :                                         Constant::Units::J,
    9979            0 :                                         Compressor(compNum).ElecConsumption,
    9980              :                                         OutputProcessor::TimeStepType::Zone,
    9981              :                                         OutputProcessor::StoreType::Sum,
    9982            0 :                                         Compressor(compNum).Name,
    9983              :                                         Constant::eResource::Electricity,
    9984              :                                         OutputProcessor::Group::Plant,
    9985              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9986            0 :                                         Compressor(compNum).EndUseSubcategory);
    9987            0 :                     SetupOutputVariable(state,
    9988              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9989              :                                         Constant::Units::W,
    9990            0 :                                         Compressor(compNum).Capacity,
    9991              :                                         OutputProcessor::TimeStepType::Zone,
    9992              :                                         OutputProcessor::StoreType::Average,
    9993            0 :                                         Compressor(compNum).Name);
    9994            0 :                     SetupOutputVariable(state,
    9995              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9996              :                                         Constant::Units::J,
    9997            0 :                                         Compressor(compNum).CoolingEnergy,
    9998              :                                         OutputProcessor::TimeStepType::Zone,
    9999              :                                         OutputProcessor::StoreType::Sum,
   10000            0 :                                         Compressor(compNum).Name);
   10001            0 :                     SetupOutputVariable(state,
   10002              :                                         "Refrigeration Compressor Runtime Fraction",
   10003              :                                         Constant::Units::None,
   10004            0 :                                         Compressor(compNum).LoadFactor,
   10005              :                                         OutputProcessor::TimeStepType::Zone,
   10006              :                                         OutputProcessor::StoreType::Average,
   10007            0 :                                         Compressor(compNum).Name);
   10008              :                 } // NumSysAttach
   10009              :             } // sys%NumCompressorsHP
   10010              : 
   10011              :         } // NumTransRefrigSystems
   10012              :     } // (NumTransRefrigSystems > 0)
   10013              : 
   10014          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10015            0 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
   10016            0 :             auto &cooler = GasCooler(GCNum);
   10017              :             // CurrentModuleObject='Refrigeration:GasCooler:AirCooled'
   10018            0 :             SetupOutputVariable(state,
   10019              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Rate",
   10020              :                                 Constant::Units::W,
   10021            0 :                                 cooler.GasCoolerLoad,
   10022              :                                 OutputProcessor::TimeStepType::Zone,
   10023              :                                 OutputProcessor::StoreType::Average,
   10024            0 :                                 cooler.Name);
   10025            0 :             SetupOutputVariable(state,
   10026              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Energy",
   10027              :                                 Constant::Units::J,
   10028            0 :                                 cooler.GasCoolerEnergy,
   10029              :                                 OutputProcessor::TimeStepType::Zone,
   10030              :                                 OutputProcessor::StoreType::Sum,
   10031            0 :                                 cooler.Name);
   10032            0 :             SetupOutputVariable(state,
   10033              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Rate",
   10034              :                                 Constant::Units::W,
   10035            0 :                                 cooler.ActualFanPower,
   10036              :                                 OutputProcessor::TimeStepType::Zone,
   10037              :                                 OutputProcessor::StoreType::Average,
   10038            0 :                                 cooler.Name);
   10039            0 :             SetupOutputVariable(state,
   10040              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Energy",
   10041              :                                 Constant::Units::J,
   10042            0 :                                 cooler.FanElecEnergy,
   10043              :                                 OutputProcessor::TimeStepType::Zone,
   10044              :                                 OutputProcessor::StoreType::Sum,
   10045            0 :                                 cooler.Name,
   10046              :                                 Constant::eResource::Electricity,
   10047              :                                 OutputProcessor::Group::Plant,
   10048              :                                 OutputProcessor::EndUseCat::Refrigeration,
   10049              :                                 cooler.EndUseSubcategory);
   10050            0 :             SetupOutputVariable(state,
   10051              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Temperature",
   10052              :                                 Constant::Units::C,
   10053            0 :                                 cooler.TGasCoolerOut,
   10054              :                                 OutputProcessor::TimeStepType::Zone,
   10055              :                                 OutputProcessor::StoreType::Average,
   10056            0 :                                 cooler.Name);
   10057            0 :             SetupOutputVariable(state,
   10058              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Pressure",
   10059              :                                 Constant::Units::Pa,
   10060            0 :                                 cooler.PGasCoolerOut,
   10061              :                                 OutputProcessor::TimeStepType::Zone,
   10062              :                                 OutputProcessor::StoreType::Average,
   10063            0 :                                 cooler.Name);
   10064            0 :             SetupOutputVariable(state,
   10065              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Rate",
   10066              :                                 Constant::Units::W,
   10067            0 :                                 cooler.InternalHeatRecoveredLoad,
   10068              :                                 OutputProcessor::TimeStepType::Zone,
   10069              :                                 OutputProcessor::StoreType::Average,
   10070            0 :                                 cooler.Name);
   10071            0 :             SetupOutputVariable(state,
   10072              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Energy",
   10073              :                                 Constant::Units::J,
   10074            0 :                                 cooler.InternalEnergyRecovered,
   10075              :                                 OutputProcessor::TimeStepType::Zone,
   10076              :                                 OutputProcessor::StoreType::Sum,
   10077            0 :                                 cooler.Name);
   10078              :         } // GCNum on NumSimulationGasCooler
   10079              :     } // (NumSimulationGasCooler >0)
   10080          150 : }
   10081              : 
   10082            5 : 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            5 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10119            5 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10120            5 :     auto &System = state.dataRefrigCase->System;
   10121            5 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   10122            5 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10123            5 :     auto &Compressor = state.dataRefrigCase->Compressor;
   10124            5 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   10125            5 :     auto &Secondary = state.dataRefrigCase->Secondary;
   10126            5 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10127            5 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10128            5 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   10129            5 :     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            5 :     if (state.dataGlobal->NumOfZones > 0) {
   10137            5 :         if (state.dataRefrigCase->UseSysTimeStep) {
   10138            0 :             for (int i = CoilSysCredit.l(), e = CoilSysCredit.u(); i <= e; ++i) {
   10139            0 :                 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           10 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10145            5 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10146              : 
   10147           10 :             for (auto &credit : state.dataHeatBal->RefrigCaseCredit) {
   10148            5 :                 credit.reset();
   10149            5 :             }
   10150           10 :             for (auto &zoneReport : CaseWIZoneReport) {
   10151            5 :                 zoneReport.reset();
   10152              :             }
   10153              :         }
   10154              :     }
   10155              : 
   10156            5 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   10157              :         // RefrigCase ALLOCATED to NumSimulationCases
   10158            6 :         for (auto &refrig : RefrigCase) {
   10159            3 :             refrig.reset_init();
   10160              :         }
   10161              :     } // NumSimulationCases
   10162              : 
   10163            5 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10164              :         // WalkIn ALLOCATED to NumSimulationWalkIns
   10165            6 :         for (int i = WalkIn.l(), e = WalkIn.u(); i <= e; ++i) {
   10166            3 :             WalkIn(i).reset_init();
   10167              :         }
   10168              :     }
   10169              : 
   10170            5 :     if (state.dataRefrigCase->HaveChillers) {
   10171              :         // HaveChillers is TRUE when NumSimulationRefrigAirChillers > 0
   10172              :         // WarehouseCoil ALLOCATED to NumSimulationRefrigAirChillers
   10173            0 :         for (int i = WarehouseCoil.l(), e = WarehouseCoil.u(); i <= e; ++i) {
   10174            0 :             WarehouseCoil(i).reset_init();
   10175              :         }
   10176              :     }
   10177              : 
   10178            5 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   10179              :         // HaveRefrigRacks TRUE when NumRefrigeratedRacks > 0
   10180              :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   10181           10 :         for (int i = RefrigRack.l(), e = RefrigRack.u(); i <= e; ++i) {
   10182            5 :             RefrigRack(i).reset_init();
   10183              :         }
   10184           10 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
   10185            5 :             e.AvailCapacity = 0.0;
   10186            5 :         }
   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            5 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10193              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   10194            0 :         for (int i = Condenser.l(), e = Condenser.u(); i <= e; ++i) {
   10195            0 :             Condenser(i).reset_init();
   10196              :         }
   10197              :         // N don't reset basin heat to zero when no load because heater would remain on
   10198            0 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10199            0 :             e.AvailCapacity = 0.0;
   10200            0 :             e.AvailTemperature = 0.0;
   10201            0 :         }
   10202              :     }
   10203              : 
   10204            5 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10205              :         // GasCooler ALLOCATED to NumSimulationGasCooler
   10206            0 :         for (int i = GasCooler.l(), e = GasCooler.u(); i <= e; ++i) {
   10207            0 :             GasCooler(i).reset_init();
   10208              :         }
   10209              :     }
   10210              : 
   10211            5 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
   10212              :         // Compressor ALLOCATED to NumSimulationCompressors
   10213            0 :         for (int i = Compressor.l(), e = Compressor.u(); i <= e; ++i) {
   10214            0 :             Compressor(i).reset_init();
   10215              :         }
   10216              :     }
   10217              : 
   10218            5 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
   10219              :         // HaveDetailedRefrig is TRUE when NumRefrigSystems > 0
   10220              :         // System is ALLOCATED to NumRefrigSystems
   10221            0 :         for (int i = System.l(), e = System.u(); i <= e; ++i) {
   10222            0 :             System(i).reset_init();
   10223              :         }
   10224              :     }
   10225              : 
   10226            5 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
   10227              :         // HaveDetailedTransRefrig is TRUE when NumTransRefrigSystems > 0
   10228              :         // TransSystem is ALLOCATED to NumTransRefrigSystems
   10229            0 :         for (int i = TransSystem.l(), e = TransSystem.u(); i <= e; ++i) {
   10230            0 :             TransSystem(i).reset_init();
   10231              :         }
   10232              :     }
   10233              : 
   10234            5 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10235              :         // Secondary is ALLOCATED to NumSimulationSecondarySystems
   10236            0 :         for (int i = Secondary.l(), e = Secondary.u(); i <= e; ++i) {
   10237            0 :             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            5 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag) {
   10243            0 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   10244            0 :             for (int i = RefrigCase.l(), e = RefrigCase.u(); i <= e; ++i) {
   10245            0 :                 RefrigCase(i).reset_init_accum();
   10246              :             }
   10247              :         }
   10248            0 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10249            0 :             for (auto &e : System) {
   10250            0 :                 e.UnmetEnergy = 0.0;
   10251              :             }
   10252              :         }
   10253            0 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10254            0 :             for (auto &e : WalkIn) {
   10255            0 :                 e.KgFrost = 0.0;
   10256            0 :                 e.StoredEnergy = 0.0;
   10257              :             }
   10258            0 :             for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10259            0 :                 WalkIn(walkInID).IceTemp = WalkIn(walkInID).TEvapDesign;
   10260              :             }
   10261              :         }
   10262            0 :         if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10263            0 :             for (auto &e : WarehouseCoil) {
   10264            0 :                 e.KgFrost = 0.0;
   10265            0 :                 e.KgFrostSaved = 0.0;
   10266              :             }
   10267            0 :             for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10268            0 :                 WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).TEvapDesign;
   10269            0 :                 WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).TEvapDesign;
   10270              :             }
   10271              :         }
   10272            0 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10273            0 :             for (auto &e : Secondary) {
   10274            0 :                 e.UnmetEnergy = 0.0;
   10275              :             }
   10276              :         }
   10277            0 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   10278            0 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
   10279            0 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10280            0 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10281            0 :             }
   10282            0 :             for (auto &e : RefrigRack) {
   10283            0 :                 e.LaggedUsedWaterHeater = 0.0;
   10284            0 :                 e.LaggedUsedHVACCoil = 0.0;
   10285              :             }
   10286              :         }
   10287            0 :         if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10288            0 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10289            0 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10290            0 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10291            0 :             }
   10292            0 :             for (auto &e : Condenser) {
   10293            0 :                 e.LaggedUsedWaterHeater = 0.0;
   10294            0 :                 e.LaggedUsedHVACCoil = 0.0;
   10295              :             }
   10296              :         }
   10297            0 :         for (int systemId = 1; systemId <= state.dataRefrigCase->NumRefrigSystems; ++systemId) {
   10298            0 :             if (allocated(System(systemId).MechSCLoad)) {
   10299            0 :                 System(systemId).MechSCLoad = 0.0;
   10300              :             }
   10301            0 :             System(systemId).LSHXTrans = 0.0;
   10302            0 :             System(systemId).LSHXTransEnergy = 0.0;
   10303              :         }
   10304              : 
   10305            0 :         if (state.dataGlobal->TimeStepsInHour > 0.0) {
   10306            0 :             state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->TimeStepsInHour);
   10307              :         }
   10308            0 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = false;
   10309              : 
   10310              :     } // ( DataGlobals::BeginEnvrnFlag && MyBeginEnvrnFlag )
   10311              : 
   10312            5 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   10313            5 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = true;
   10314              :     }
   10315              : 
   10316              :     // Avoid multiplying accumulation if go through zone/load time step more than once.
   10317            5 :     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           10 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10320            5 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10321              :             // Used to determine whether the zone time step is a repetition
   10322            5 :             Real64 MyCurrentTime = (state.dataGlobal->HourOfDay - 1) + state.dataGlobal->TimeStep * state.dataRefrigCase->TimeStepFraction;
   10323            5 :             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            5 :                 state.dataRefrigCase->MyCurrentTimeSaved = MyCurrentTime;
   10367            5 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
   10368            6 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
   10369            3 :                         RefrigCase(caseID).DefrostEnergySaved = RefrigCase(caseID).DefrostEnergy;
   10370            3 :                         RefrigCase(caseID).StockingEnergySaved = RefrigCase(caseID).StockingEnergy;
   10371            3 :                         RefrigCase(caseID).WarmEnvEnergySaved = RefrigCase(caseID).WarmEnvEnergy;
   10372            3 :                         RefrigCase(caseID).KgFrostSaved = RefrigCase(caseID).KgFrost;
   10373            3 :                         RefrigCase(caseID).StoredEnergySaved = RefrigCase(caseID).StoredEnergy;
   10374              :                     } // caseid
   10375              :                 } // numsimulationcases
   10376            5 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10377            6 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10378            3 :                         WalkIn(walkInID).KgFrostSaved = WalkIn(walkInID).KgFrost;
   10379            3 :                         WalkIn(walkInID).StoredEnergySaved = WalkIn(walkInID).StoredEnergy;
   10380            3 :                         WalkIn(walkInID).IceTempSaved = WalkIn(walkInID).IceTemp;
   10381              :                     }
   10382              :                 }
   10383            5 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10384            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10385            0 :                         if (System(systemID).CoilFlag) {
   10386            0 :                             continue;
   10387              :                         }
   10388            0 :                         System(systemID).UnmetEnergySaved = System(systemID).UnmetEnergy;
   10389              :                     }
   10390              :                 }
   10391            5 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   10392            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
   10393            0 :                         TransSystem(systemID).UnmetEnergySavedMT = TransSystem(systemID).UnmetEnergyMT;
   10394            0 :                         TransSystem(systemID).UnmetEnergySavedLT = TransSystem(systemID).UnmetEnergyLT;
   10395              :                     }
   10396              :                 }
   10397            5 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10398            0 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
   10399            0 :                         if (Secondary(secondID).CoilFlag) {
   10400            0 :                             continue;
   10401              :                         }
   10402            0 :                         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            5 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
   10407           10 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
   10408           10 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
   10409            5 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
   10410            5 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
   10411            5 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10412              :                     }
   10413              :                 }
   10414            5 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10415            0 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10416            0 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10417            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10418            0 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10419            0 :                             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            0 :             Real64 MyStepStartTime = state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed;
   10428            0 :             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            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10431            0 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10432            0 :                         WarehouseCoil(coilID).KgFrost = WarehouseCoil(coilID).KgFrostSaved;
   10433            0 :                         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            0 :                 state.dataRefrigCase->MyStepStartTimeSaved = MyStepStartTime;
   10439            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10440            0 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10441            0 :                         WarehouseCoil(coilID).KgFrostSaved = WarehouseCoil(coilID).KgFrost;
   10442            0 :                         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            0 :                 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            0 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10455            0 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10456            0 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10457            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10458            0 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10459            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10460              :                     }
   10461              :                 }
   10462              :             } // if first time
   10463              :         } //(.NOT. UseSysTimeStep)
   10464              : 
   10465              :     } // warm up flag
   10466              : 
   10467            5 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
   10468            0 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10469            0 :             for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10470            0 :                 if (System(systemID).EMSOverrideOnTCondenseMin) {
   10471            0 :                     System(systemID).TCondenseMin = System(systemID).EMSOverrideValueTCondenseMin;
   10472              :                 } else {
   10473            0 :                     System(systemID).TCondenseMin = System(systemID).TCondenseMinInput;
   10474              :                 }
   10475              :             }
   10476              :         }
   10477              :     }
   10478            5 : }
   10479              : 
   10480            0 : 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            0 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10496            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10497              : 
   10498              :     // initialize plant topology information, if applicable
   10499            0 :     if (state.dataRefrigCase->MyReferPlantScanFlag && allocated(state.dataPlnt->PlantLoop)) {
   10500            0 :         for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10501            0 :             if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10502            0 :                 continue;
   10503              :             }
   10504              : 
   10505            0 :             bool errFlag = false;
   10506            0 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10507            0 :                                                     Condenser(RefCondLoop).Name,
   10508              :                                                     DataPlant::PlantEquipmentType::RefrigSystemWaterCondenser,
   10509            0 :                                                     Condenser(RefCondLoop).plantLoc,
   10510              :                                                     errFlag,
   10511              :                                                     _,
   10512              :                                                     _,
   10513              :                                                     _,
   10514              :                                                     _,
   10515              :                                                     _);
   10516            0 :             if (errFlag) {
   10517            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10518              :             }
   10519              : 
   10520            0 :             Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10521              : 
   10522            0 :             if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10523            0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10524            0 :             } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10525            0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10526              :             }
   10527              :         }
   10528              : 
   10529            0 :         for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10530            0 :             if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10531            0 :                 continue;
   10532              :             }
   10533              : 
   10534            0 :             bool errFlag = false;
   10535            0 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10536            0 :                                                     RefrigRack(RefCompRackLoop).Name,
   10537              :                                                     DataPlant::PlantEquipmentType::RefrigerationWaterCoolRack,
   10538            0 :                                                     RefrigRack(RefCompRackLoop).plantLoc,
   10539              :                                                     errFlag,
   10540              :                                                     _,
   10541              :                                                     _,
   10542              :                                                     _,
   10543              :                                                     _,
   10544              :                                                     _);
   10545            0 :             if (errFlag) {
   10546            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10547              :             }
   10548              : 
   10549            0 :             Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10550              : 
   10551            0 :             if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10552            0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10553            0 :             } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10554            0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10555              :             }
   10556              :         }
   10557              : 
   10558            0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10559            0 :     } else if (state.dataRefrigCase->MyReferPlantScanFlag && !state.dataGlobal->AnyPlantInModel) {
   10560            0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10561              :     }
   10562              : 
   10563            0 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag) {
   10564              : 
   10565              :         // do plant inits, if applicable
   10566            0 :         if (!state.dataRefrigCase->MyReferPlantScanFlag) {
   10567            0 :             for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10568            0 :                 if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10569            0 :                     continue;
   10570              :                 }
   10571              : 
   10572            0 :                 Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10573              : 
   10574            0 :                 if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10575            0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10576            0 :                 } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10577            0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10578              :                 }
   10579              : 
   10580            0 :                 PlantUtilities::InitComponentNodes(
   10581            0 :                     state, 0.0, Condenser(RefCondLoop).MassFlowRateMax, Condenser(RefCondLoop).InletNode, Condenser(RefCondLoop).OutletNode);
   10582              :             }
   10583            0 :             for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10584            0 :                 if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10585            0 :                     continue;
   10586              :                 }
   10587              : 
   10588            0 :                 Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10589              : 
   10590            0 :                 if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10591            0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10592            0 :                 } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10593            0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10594              :                 }
   10595              : 
   10596            0 :                 PlantUtilities::InitComponentNodes(state,
   10597              :                                                    0.0,
   10598            0 :                                                    RefrigRack(RefCompRackLoop).MassFlowRateMax,
   10599            0 :                                                    RefrigRack(RefCompRackLoop).InletNode,
   10600            0 :                                                    RefrigRack(RefCompRackLoop).OutletNode);
   10601              :             }
   10602              :         }
   10603            0 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = false;
   10604              : 
   10605              :     } //(DataGlobals::BeginEnvrnFlag .AND. MyBeginEnvrnFlag)
   10606              : 
   10607            0 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   10608            0 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = true;
   10609              :     }
   10610            0 : }
   10611              : 
   10612            5 : 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            5 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10645            5 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10646            5 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10647            5 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   10648              : 
   10649            5 :     state.dataRefrigCase->TotalRackDeliveredCapacity = 0.0;
   10650            5 :     state.dataRefrigCase->CompressorCOPactual = 0.0;
   10651            5 :     state.dataRefrigCase->TotalCompressorPower = 0.0;
   10652            5 :     state.dataRefrigCase->TotalCondenserFanPower = 0.0;
   10653            5 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   10654            5 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   10655            5 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   10656            5 :     TotalHeatRejectedToZone = 0.0;
   10657            5 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   10658            5 :     state.dataRefrigCase->RackSenCreditToZone = 0.0;
   10659            5 :     state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10660            5 :     CondenserFrac = 0.0;
   10661            5 :     EvapAvail = true;
   10662            5 :     HeatRejectZoneNum = 0;
   10663            5 :     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            5 :     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            5 :     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            5 :     if (this->NumCases > 0) {
   10692            6 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   10693            3 :             int CaseID = this->CaseNum(caseNum);
   10694            3 :             RefrigCase(CaseID).CalculateCase(state);
   10695              : 
   10696              :             //   add evaporator load for all cases connected to rack
   10697            3 :             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            3 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10705            2 :                 if (this->NumWalkIns == 0) {
   10706            1 :                     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            1 :                     HeatRejectZoneNum = RefrigCase(this->CaseNum(1)).ActualZoneNum;
   10711            1 :                     HeatRejectZoneNodeNum = RefrigCase(this->CaseNum(1)).ZoneNodeNum;
   10712              :                 } else { // have walk ins so no reduction in condenser heat rejection for caseRA factor
   10713            1 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad;
   10714              :                 } // no walk ins
   10715              :             }
   10716              :         } // NumCases
   10717              :     } // Numcases on rack > 0
   10718              : 
   10719            5 :     if (this->NumWalkIns > 0) {
   10720            6 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   10721            3 :             int WalkInID = this->WalkInNum(WalkInIndex);
   10722            3 :             WalkIn(WalkInID).CalculateWalkIn(state);
   10723            3 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WalkIn(WalkInID).TotalCoolingLoad;
   10724            3 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10725            3 :                 TotalHeatRejectedToZone += WalkIn(WalkInID).TotalCoolingLoad;
   10726            3 :                 HeatRejectZoneNum = this->HeatRejectionZoneNum;
   10727            3 :                 HeatRejectZoneNodeNum = this->HeatRejectionZoneNodeNum;
   10728              :             } // reject heat to zone
   10729              :         } // WalkInIndex
   10730              :     } // NumWalkIns>0
   10731              : 
   10732            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10733            4 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp);
   10734            4 :         EvapAvail = false;
   10735              :     } else {
   10736            1 :         if (this->OutsideAirNodeNum != 0) {
   10737            0 :             OutDbTemp = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Temp;
   10738            0 :             BPress = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Press;
   10739              :         } else {
   10740            1 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   10741            1 :             BPress = state.dataEnvrn->OutBaroPress;
   10742              :         }
   10743            1 :         EffectTemp = OutDbTemp;
   10744              : 
   10745              :         // IF schedule exists, evap condenser can be scheduled OFF
   10746              :         // Check schedule to determine evap condenser availability
   10747            1 :         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            1 :         if (OutDbTemp < EvapCutOutTdb) {
   10758            1 :             EvapAvail = false;
   10759              :         }
   10760              : 
   10761            1 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10762              :             // determine temps for evap cooling
   10763            0 :             if (this->OutsideAirNodeNum != 0) {
   10764            0 :                 HumRatIn = state.dataLoopNodes->Node(this->OutsideAirNodeNum).HumRat;
   10765              :             } else {
   10766            0 :                 HumRatIn = state.dataEnvrn->OutHumRat;
   10767              :             } // outsideairnode
   10768            0 :             OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   10769            0 :             EffectTemp = OutWbTemp + (1.0 - this->EvapEffect) * (OutDbTemp - OutWbTemp);
   10770              :         } // evapAvail
   10771              : 
   10772              :         // Obtain water-cooled condenser inlet/outlet temps
   10773            1 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   10774            0 :             this->InletTemp = state.dataLoopNodes->Node(this->InletNode).Temp;
   10775            0 :             EffectTemp = state.dataLoopNodes->Node(this->InletNode).Temp + 5.0; // includes approach temp
   10776            0 :             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            1 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, EffectTemp);
   10792              :     } // Location Zone
   10793              : 
   10794            5 :     state.dataRefrigCase->CompressorCOPactual = this->RatedCOP * COPFTempOutput;
   10795              : 
   10796            5 :     if (state.dataRefrigCase->CompressorCOPactual > 0.0) {
   10797            5 :         state.dataRefrigCase->TotalCompressorPower = state.dataRefrigCase->TotalRackDeliveredCapacity / state.dataRefrigCase->CompressorCOPactual;
   10798            5 :         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            5 :     if (state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0 && this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10811            1 :         if (this->TotCondFTempPtr != 0) {
   10812            0 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10813              :                 CondenserFrac =
   10814            0 :                     max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp)));
   10815            0 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10816            0 :                 state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += this->CondenserFanPower * CondenserFrac;
   10817              :             } else {
   10818            0 :                 CondenserFrac = max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, EffectTemp)));
   10819            0 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10820              :             } // location zone
   10821              :         } else {
   10822            1 :             CondenserFrac = 1.0;
   10823            1 :             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            5 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10830            0 :         state.dataRefrigCase->TotalCondenserPumpPower = this->EvapPumpPower;
   10831            0 :         HumRatOut = Psychrometrics::PsyWFnTdbTwbPb(state, EffectTemp, OutWbTemp, BPress);
   10832            0 :         state.dataRefrigCase->TotalEvapWaterUseRate = this->CondenserAirFlowRate * CondenserFrac *
   10833            0 :                                                       Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn) * (HumRatOut - HumRatIn) /
   10834            0 :                                                       Psychrometrics::RhoH2O(EffectTemp);
   10835              :     } // evapAvail
   10836              :     // calculate basin water heater load
   10837            5 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   10838            0 :         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            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10862            4 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalRackDeliveredCapacity + state.dataRefrigCase->TotalCompressorPower +
   10863            4 :                                                    state.dataRefrigCase->TotalCondenserFanPower;
   10864            4 :         if (HeatRejectZoneNum > 0 && state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0) {
   10865            0 :             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            0 :                 state.dataRefrigCase->RackSenCreditToZone =
   10869            0 :                     state.dataRefrigCase->TotalCondenserHeat * (TotalHeatRejectedToZone / state.dataRefrigCase->TotalRackDeliveredCapacity);
   10870            0 :                 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            0 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += state.dataRefrigCase->RackSenCreditToZone;
   10877              : 
   10878            0 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToHVAC += state.dataRefrigCase->RackSenCreditToHVAC;
   10879              :         } // zone # > 0 and tot del cap > 0
   10880              :     } // rack heat rejection to zone
   10881            5 : }
   10882              : 
   10883            5 : 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            5 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   10896            5 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   10897              : 
   10898            5 :     this->RackCompressorPower = state.dataRefrigCase->TotalCompressorPower;
   10899            5 :     this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * localTimeStepSec;
   10900            5 :     this->ActualCondenserFanPower = state.dataRefrigCase->TotalCondenserFanPower;
   10901            5 :     this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * localTimeStepSec;
   10902            5 :     this->RackCapacity = state.dataRefrigCase->TotalRackDeliveredCapacity;
   10903            5 :     this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * localTimeStepSec;
   10904            5 :     this->RackCompressorCOP = state.dataRefrigCase->CompressorCOPactual;
   10905            5 :     this->SensHVACCreditHeatRate = state.dataRefrigCase->RackSenCreditToHVAC;
   10906            5 :     this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * localTimeStepSec;
   10907            5 :     this->SensZoneCreditHeatRate = state.dataRefrigCase->RackSenCreditToZone;
   10908            5 :     this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * localTimeStepSec;
   10909            5 :     this->EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   10910            5 :     this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   10911            5 :     this->ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   10912            5 :     this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   10913            5 :     this->BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   10914            5 :     this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   10915            5 :     this->CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   10916            5 :     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            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10919            4 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity = 0.0;
   10920              :     } else {
   10921            1 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity =
   10922            1 :             state.dataRefrigCase->TotalRackDeliveredCapacity * (1.0 + 1.0 / state.dataRefrigCase->CompressorCOPactual);
   10923              :     }
   10924              : 
   10925              :     // set water system demand request (if needed)
   10926            5 :     if (this->EvapWaterSupplyMode == WaterSupply::FromTank) {
   10927            0 :         int DemandARRID = this->EvapWaterTankDemandARRID;
   10928            0 :         int RackTankID = this->EvapWaterSupTankID;
   10929            0 :         state.dataWaterData->WaterStorage(RackTankID).VdotRequestDemand(DemandARRID) = this->EvapWaterConsumpRate;
   10930              :     }
   10931              : 
   10932            5 :     SumZoneImpacts(state);
   10933            5 : }
   10934              : 
   10935            3 : 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            3 :     Real64 CaseCreditFraction(0.0);      // Reduction in case credits due to e.g., reduced door openings at night
   10973            3 :     Real64 DefrostSchedule(0.0);         // Display case defrost schedule
   10974            3 :     Real64 DefrostDripDownSchedule(0.0); // Display case drip-down schedule (allows coil to drain after defrost)
   10975            3 :     Real64 DefrostRatio(0.0);            // ratio of defrost energy at current zone temp/humrat to defrost
   10976              :     //    capacity at design condition
   10977            3 :     Real64 LatentRatio(0.0); // ratio of latent capacity at current zone temp/humrat to
   10978              :     //    latent capacity at design condition
   10979            3 :     Real64 LatentCap_Actual(0.0);   // Refrigerated case latent capacity at specific operating conditions
   10980            3 :     Real64 LatentCaseCredit(0.0);   // Latent case credit delivered to zone (W)
   10981            3 :     Real64 SensibleCap_Actual(0.0); // Refrigerated case sensible capacity at specific operating conditions
   10982            3 :     Real64 SensibleLoadPrime(0.0);  // Sensible load due to cond, conv, rad, infil (W)
   10983            3 :     Real64 TotalCap_Actual(0.0);    // Refrigerated case total capacity at specific operating conditions
   10984            3 :     Real64 TotalLightingLoad(0.0);  // Total lighting energy rate (W)
   10985            3 :     Real64 TotalFan(0.0);           // Total fan energy rate (W)
   10986            3 :     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            3 :     state.dataRefrigCase->CaseRAFactor = 0.0;
   10999              : 
   11000              :     // Zone relative humidity (%)
   11001            3 :     Real64 ZoneRHPercent = Psychrometrics::PsyRhFnTdbWPb(state,
   11002            3 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).Temp,
   11003            3 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat,
   11004            3 :                                                          state.dataEnvrn->OutBaroPress) *
   11005            3 :                            100.0;
   11006              : 
   11007              :     // Zone dew point (C)
   11008            3 :     Real64 ZoneDewPoint = Psychrometrics::PsyTdpFnWPb(state, state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat, state.dataEnvrn->OutBaroPress);
   11009              : 
   11010              :     // Display case operating temperature
   11011            3 :     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            3 :     Real64 CaseSchedule = this->availSched->getCurrentVal();
   11018            3 :     if (CaseSchedule <= 0) {
   11019            0 :         return;
   11020              :     }
   11021              :     // get defrost schedule
   11022            3 :     if (this->defrostType > RefCaseDefrostType::None) {
   11023            0 :         DefrostSchedule = this->defrostSched->getCurrentVal();
   11024            0 :         DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   11025              :         // next statement In case user doesn't understand concept of drip down schedule
   11026            0 :         DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   11027              :     } else {
   11028            3 :         DefrostSchedule = 0.0;
   11029            3 :         DefrostDripDownSchedule = 0.0;
   11030              :     }
   11031              : 
   11032              :     // get product stocking schedule and load due to product stocking, if no schedule exists load is 0
   11033            3 :     Real64 StockingSchedule = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   11034              : 
   11035              :     // get lighting schedule and total load due to lighting
   11036            3 :     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            3 :     CaseCreditFraction = (this->caseCreditFracSched != nullptr) ? this->caseCreditFracSched->getCurrentVal() : 1.0;
   11041              : 
   11042              :     // CALCULATE AUX LOADS DUE TO LIGHTS, FAN AND STOCKING
   11043            3 :     TotalLightingLoad = this->DesignLighting * LightingSchedule;
   11044              : 
   11045              :     // Lighting energy to case
   11046            3 :     Real64 TotalLightToCase = TotalLightingLoad * this->LightingFractionToCase;
   11047              : 
   11048              :     // Lighting energy to zone
   11049            3 :     Real64 TotalLightToZone = TotalLightingLoad - TotalLightToCase;
   11050              :     // cycle fan according to defrost schedule
   11051              :     // turn fan on for none or off-cycle defrost types
   11052            3 :     if (this->defrostType == RefCaseDefrostType::None || this->defrostType == RefCaseDefrostType::OffCycle) {
   11053            3 :         TotalFan = this->DesignFanPower;
   11054              :     } else {
   11055            0 :         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            3 :     Real64 StockingLoad = StockingSchedule * this->Length;
   11063            3 :     if (!state.dataGlobal->WarmupFlag) {
   11064            3 :         Real64 DeltaStockingEnergy = (StockingLoad * state.dataGlobal->TimeStepZoneSec);
   11065            3 :         this->StockingEnergy += DeltaStockingEnergy;
   11066              :     } // warm up
   11067              :     // CALCULTE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   11068              :     // Anti-sweat heater capacity
   11069            3 :     switch (this->AntiSweatControlType) {
   11070            3 :     case ASHtrCtrlType::None: {
   11071            3 :         TotalAntiSweat = 0.0;
   11072            3 :     } break;
   11073            0 :     case ASHtrCtrlType::Constant: {
   11074            0 :         TotalAntiSweat = this->AntiSweatPower;
   11075            0 :     } break;
   11076            0 :     case ASHtrCtrlType::Linear: {
   11077            0 :         TotalAntiSweat =
   11078            0 :             this->AntiSweatPower * min(1.0, max(0.0, 1.0 - (this->RatedAmbientRH - ZoneRHPercent) / (this->RatedAmbientRH - this->HumAtZeroAS)));
   11079            0 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   11080            0 :     } 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            0 :     case ASHtrCtrlType::HeatBalance: {
   11086            0 :         if (this->Rcase > 0.0) {
   11087            0 :             TotalAntiSweat = (((ZoneDewPoint - state.dataLoopNodes->Node(this->ZoneNodeNum).Temp) * this->Height / Rair) +
   11088            0 :                               ((ZoneDewPoint - TCase) * this->Height / this->Rcase));
   11089            0 :             TotalAntiSweat = min(this->AntiSweatPower, max(this->MinimumASPower, TotalAntiSweat));
   11090              :         } else {
   11091            0 :             TotalAntiSweat = 0.0;
   11092              :         }
   11093            0 :     } break;
   11094            0 :     default: {
   11095              :         // should never execute this CASE statement
   11096            0 :         TotalAntiSweat = 0.0;
   11097            0 :     } break;
   11098              :     }
   11099            3 :     TotalAntiSweat *= this->Length;
   11100              : 
   11101              :     // Anti-sweat heater energy to case
   11102            3 :     Real64 TotalASHeaterToCase = this->ASHeaterFractionToCase * TotalAntiSweat;
   11103              : 
   11104              :     // Anti-sweat heater energy to zone
   11105            3 :     Real64 TotalASHeaterToZone = TotalAntiSweat - TotalASHeaterToCase;
   11106              : 
   11107              :     // latent capacity correction term at off-design conditions
   11108            3 :     switch (this->LatentEnergyCurveType) {
   11109            3 :     case EnergyEqnForm::CaseTemperatureMethod: {
   11110            3 :         Real64 LatCapModFrac = Curve::CurveValue(state, this->LatCapCurvePtr, TCase);
   11111            3 :         LatentRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * LatCapModFrac));
   11112            3 :     } break;
   11113            0 :     case EnergyEqnForm::RHCubic: {
   11114            0 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneRHPercent));
   11115            0 :     } break;
   11116            0 :     case EnergyEqnForm::DPCubic: {
   11117            0 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneDewPoint));
   11118            0 :     } 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            3 :     Real64 LatentLoad = this->DesignLatentCap * LatentRatio * CaseCreditFraction * (1.0 - DefrostDripDownSchedule);
   11129            3 :     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            3 :     Real64 ZoneTempFactor = (state.dataLoopNodes->Node(ZoneNodeNum).Temp - TCase) / (this->RatedAmbientTemp - TCase);
   11137            3 :     SensibleLoadPrime = this->DesignSensCaseCredit * ZoneTempFactor * CaseCreditFraction;
   11138              : 
   11139              :     // Sensible load due to heaters, lighting (W)
   11140            3 :     Real64 SensibleLoadAux = TotalLightToCase + TotalASHeaterToCase + TotalFan + StockingLoad;
   11141              : 
   11142              :     // Total sensible load on case, may not = capacity applied (W)
   11143            3 :     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            3 :     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            3 :     if (!state.dataGlobal->WarmupFlag) {
   11152            3 :         Real64 DeltaFreezeKgFrost = LatentLoad * state.dataGlobal->TimeStepZoneSec / IcetoVaporEnthalpy;
   11153            3 :         this->KgFrost += DeltaFreezeKgFrost;
   11154              :     }
   11155              : 
   11156            3 :     if (TCase > TempTooHotToFrost) {
   11157            3 :         this->KgFrost = 0.0;
   11158              :     }
   11159              : 
   11160            3 :     Real64 DefrostLoad_Actual(0.0); // heat load on case due to defrost (W)
   11161            3 :     Real64 DefrostCap_Actual(0.0);  // power used to defrost (W)
   11162              : 
   11163              :     // DEFROST CALCULATIONS
   11164            3 :     if (DefrostSchedule > 0.0) {
   11165            0 :         if (this->defrostType != RefCaseDefrostType::None && this->defrostType != RefCaseDefrostType::OffCycle) {
   11166            0 :             DefrostCap_Actual = this->DesignDefrostCap * DefrostSchedule;
   11167            0 :             if (this->defrostType == RefCaseDefrostType::ElectricTerm || this->defrostType == RefCaseDefrostType::HotFluidTerm) {
   11168              :                 // calculate correction term for temperature termination defrost control
   11169            0 :                 switch (this->DefrostEnergyCurveType) {
   11170            0 :                 case EnergyEqnForm::CaseTemperatureMethod: {
   11171            0 :                     Real64 DefCapModFrac = Curve::CurveValue(state, this->DefCapCurvePtr, TCase);
   11172            0 :                     DefrostRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * DefCapModFrac));
   11173            0 :                 } 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            0 :                 DefrostCap_Actual *= DefrostRatio;
   11187              :             }
   11188              : 
   11189              :             // frost load at start of time step (kg of ice)
   11190            0 :             Real64 StartFrostKg = this->KgFrost;
   11191              : 
   11192              :             // Energy form of defrost capacity (J)
   11193            0 :             Real64 defrostEnergy = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11194              : 
   11195              :             // Frost melted by defrost during a time step (kg)
   11196            0 :             Real64 FrostMeltedKg = min(defrostEnergy / IceMeltEnthalpy, StartFrostKg);
   11197            0 :             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            0 :             DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   11203              : 
   11204            0 :             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            0 :                 this->DeltaDefrostEnergy = max(0.0, (defrostEnergy - (FrostMeltedKg * IceMeltEnthalpy)));
   11208            0 :                 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            0 :             if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11213            0 :                 this->defrostType != RefCaseDefrostType::ElectricTerm) {
   11214            0 :                 this->HotDefrostCondCredit = DefrostCap_Actual * DefrostSchedule;
   11215              :             }
   11216            0 :         } else { // no defrost or off-cycle defrost
   11217            0 :             DefrostCap_Actual = 0.0;
   11218            0 :             DefrostLoad_Actual = 0.0;
   11219            0 :             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            3 :         DefrostLoad_Actual = 0.0;
   11225            3 :         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            3 :     Real64 TotalLoad_Actual = SensibleLoadTotal + LatentLoad + DefrostLoad_Actual;
   11231              : 
   11232              :     // Rate needed to serve all stored energy during single time step (W)
   11233            3 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   11234            3 :     Real64 LoadRequested = TotalLoad_Actual + StoredEnergyRate;
   11235              : 
   11236              :     // prorate available cooling capacity for portion of time off due to drip down.
   11237            3 :     Real64 CapAvail = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule);
   11238            3 :     if (CapAvail >= LoadRequested) {
   11239              :         // Have more at least as much capacity available as needed, even counting stored energy
   11240            3 :         TotalCap_Actual = LoadRequested;
   11241            3 :         SensibleCap_Actual = SensibleLoadTotal + StoredEnergyRate;
   11242            3 :         LatentCap_Actual = LatentLoad;
   11243            3 :         this->StoredEnergy = 0.0;
   11244              :     } else {
   11245              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   11246            0 :         TotalCap_Actual = CapAvail;
   11247            0 :         LatentCap_Actual = min(LatentLoad, CapAvail); // Latent load should never be > capavail, but just in case...
   11248            0 :         SensibleCap_Actual = TotalCap_Actual - LatentCap_Actual;
   11249            0 :         if (!state.dataGlobal->WarmupFlag) {
   11250            0 :             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            3 :     if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11256            3 :         this->defrostType != RefCaseDefrostType::ElectricTerm) {
   11257            3 :         DefrostCap_Actual = 0.0;
   11258              :     }
   11259              : 
   11260            3 :     Real64 caseRAFraction = min(0.8, this->RAFrac);
   11261            3 :     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            3 :     Real64 CaseSenCreditToZone = SensibleCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11271              : 
   11272              :     // Amount of latent case credit applied to zone load (W)
   11273            3 :     Real64 CaseLatCreditToZone = LatentCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11274              : 
   11275              :     // Amount of sensible case credit applied to HVAC RA duct (W)
   11276            3 :     Real64 CaseSenCreditToHVAC = SensibleCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11277              : 
   11278              :     // Amount of latent case credit applied to HVAC RA duct (W)
   11279            3 :     Real64 CaseLatCreditToHVAC = LatentCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11280              : 
   11281            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToZone += CaseSenCreditToZone;
   11282            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToZone += CaseLatCreditToZone;
   11283            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToHVAC += CaseSenCreditToHVAC;
   11284            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToHVAC += CaseLatCreditToHVAC;
   11285              : 
   11286              :     // ReportRefrigeratedCase(CaseID)
   11287            3 :     this->TotalCoolingLoad = TotalCap_Actual;
   11288            3 :     this->TotalCoolingEnergy = TotalCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11289            3 :     this->SensCoolingEnergyRate = SensibleCap_Actual;
   11290            3 :     this->SensCoolingEnergy = SensibleCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11291            3 :     this->LatCoolingEnergyRate = LatentCap_Actual;
   11292            3 :     this->LatCoolingEnergy = LatentCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11293              : 
   11294            3 :     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            3 :     if (CaseSenCreditToZone <= 0.0) {
   11297            1 :         this->SensZoneCreditCoolRate = -CaseSenCreditToZone;
   11298            1 :         this->SensZoneCreditCool = -CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11299            1 :         this->SensZoneCreditHeatRate = 0.0;
   11300            1 :         this->SensZoneCreditHeat = 0.0;
   11301              :     } else {
   11302            2 :         this->SensZoneCreditHeatRate = CaseSenCreditToZone;
   11303            2 :         this->SensZoneCreditHeat = CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11304            2 :         this->SensZoneCreditCoolRate = 0.0;
   11305            2 :         this->SensZoneCreditCool = 0.0;
   11306              :     }
   11307              : 
   11308              :     // This rate should always be negative
   11309            3 :     this->LatZoneCreditRate = CaseLatCreditToZone;
   11310            3 :     this->LatZoneCredit = CaseLatCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11311              : 
   11312            3 :     this->SensHVACCreditRate = CaseSenCreditToHVAC;
   11313              :     // This rate can be positive or negative, split into separate output variables and always report positive value
   11314            3 :     if (CaseSenCreditToHVAC <= 0.0) {
   11315            3 :         this->SensHVACCreditCoolRate = -CaseSenCreditToHVAC;
   11316            3 :         this->SensHVACCreditCool = -CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11317            3 :         this->SensHVACCreditHeatRate = 0.0;
   11318            3 :         this->SensHVACCreditHeat = 0.0;
   11319              :     } else {
   11320            0 :         this->SensHVACCreditHeatRate = CaseSenCreditToHVAC;
   11321            0 :         this->SensHVACCreditHeat = CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11322            0 :         this->SensHVACCreditCoolRate = 0.0;
   11323            0 :         this->SensHVACCreditCool = 0.0;
   11324              :     }
   11325              : 
   11326              :     // This rate should always be negative
   11327            3 :     this->LatHVACCreditRate = CaseLatCreditToHVAC;
   11328            3 :     this->LatHVACCredit = CaseLatCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11329              : 
   11330            3 :     this->ElecFanPower = TotalFan;
   11331            3 :     this->ElecFanConsumption = TotalFan * state.dataGlobal->TimeStepZoneSec;
   11332            3 :     this->ElecAntiSweatPower = TotalAntiSweat;
   11333            3 :     this->ElecAntiSweatConsumption = TotalAntiSweat * state.dataGlobal->TimeStepZoneSec;
   11334            3 :     this->ElecLightingPower = TotalLightingLoad;
   11335            3 :     this->ElecLightingConsumption = TotalLightingLoad * state.dataGlobal->TimeStepZoneSec;
   11336            3 :     this->ElecDefrostPower = DefrostCap_Actual;
   11337            3 :     this->ElecDefrostConsumption = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11338              : 
   11339            3 :     this->DefEnergyCurveValue = DefrostRatio;
   11340            3 :     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            3 :     if ((ZoneTempFactor * CaseCreditFraction) > 1.0) {
   11349            1 :         if (!state.dataGlobal->WarmupFlag) {
   11350            1 :             Real64 DeltaWarmEnvEnergy = (SensibleLoadPrime - this->DesignSensCaseCredit) * state.dataGlobal->TimeStepZoneSec;
   11351            1 :             this->WarmEnvEnergy += DeltaWarmEnvEnergy;
   11352              :         }
   11353              :     }
   11354              : 
   11355            3 :     if (this->DefrostEnergy > MyLargeNumber) {
   11356            0 :         this->DefrostEnergy = MyLargeNumber;
   11357              :     }
   11358            3 :     if (this->WarmEnvEnergy > MyLargeNumber) {
   11359            0 :         this->WarmEnvEnergy = MyLargeNumber;
   11360              :     }
   11361            3 :     if (this->StockingEnergy > MyLargeNumber) {
   11362            0 :         this->StockingEnergy = MyLargeNumber;
   11363              :     }
   11364            3 :     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            3 :     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            0 : 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            0 :     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            0 :     for (auto &obj : state.dataRefrigCase->Condenser) {
   11418            0 :         if (obj.Name == objectName) {
   11419            0 :             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            0 : void RefrigCondenserData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11429              : {
   11430            0 :     InitRefrigeration(state);
   11431            0 :     InitRefrigerationPlantConnections(state);
   11432            0 : }
   11433              : 
   11434            0 : 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            0 :     int PlantInletNode(0);
   11461            0 :     int PlantOutletNode(0);
   11462            0 :     PlantLocation PlantLoc{};
   11463              : 
   11464            0 :     InitRefrigerationPlantConnections(state);
   11465              : 
   11466            0 :     std::string TypeName;
   11467            0 :     std::string ErrIntro;
   11468              : 
   11469              :     // set variables depending upon system type
   11470            0 :     PlantInletNode = this->InletNode;
   11471            0 :     PlantOutletNode = this->OutletNode;
   11472            0 :     PlantLoc = this->plantLoc;
   11473              : 
   11474            0 :     state.dataRefrigCase->TotalCondenserHeat = this->CondLoad;
   11475            0 :     TypeName = "Refrigeration:Condenser:WaterCooled";
   11476            0 :     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            0 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11483            0 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11484              : 
   11485            0 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11486              : 
   11487            0 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11488              : 
   11489            0 :         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            0 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11504            0 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11505              :             // Check for maximum flow in the component
   11506            0 :             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            0 :     } 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            0 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11525            0 :         this->MassFlowRate = 0.0;
   11526              : 
   11527              :     } // on flow type
   11528              :     // check against plant, might get changed.
   11529            0 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11530              : 
   11531            0 :     this->VolFlowRate = this->MassFlowRate / rho;
   11532              : 
   11533            0 :     if (this->MassFlowRate > 0) {
   11534            0 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11535              :     } else {
   11536            0 :         this->OutletTemp = this->InletTemp;
   11537            0 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11538              : 
   11539            0 :             ShowRecurringWarningErrorAtEnd(
   11540              :                 state,
   11541            0 :                 TypeName + this->Name +
   11542              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11543            0 :                 this->NoFlowWarnIndex);
   11544              :         }
   11545              :     }
   11546              :     // Check outlet water temp for max value
   11547            0 :     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            0 :     this->UpdateCondenserOutletNode(state);
   11558            0 : }
   11559              : 
   11560            0 : 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            0 :     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            0 :     for (auto &obj : state.dataRefrigCase->RefrigRack) {
   11569            0 :         if (obj.Name == objectName) {
   11570            0 :             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            0 : void RefrigRackData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11580              : {
   11581            0 :     InitRefrigeration(state);
   11582            0 :     InitRefrigerationPlantConnections(state);
   11583            0 : }
   11584              : 
   11585            0 : 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            0 :     int PlantInletNode(0);
   11612            0 :     int PlantOutletNode(0);
   11613            0 :     PlantLocation PlantLoc{};
   11614              : 
   11615            0 :     InitRefrigerationPlantConnections(state);
   11616              : 
   11617            0 :     std::string TypeName;
   11618            0 :     std::string ErrIntro;
   11619              : 
   11620              :     // set variables depending upon system type
   11621            0 :     PlantInletNode = this->InletNode;
   11622            0 :     PlantOutletNode = this->OutletNode;
   11623            0 :     PlantLoc = this->plantLoc;
   11624              : 
   11625            0 :     state.dataRefrigCase->TotalCondenserHeat =
   11626            0 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(this->MyIdx).AvailCapacity - this->LaggedUsedWaterHeater - this->LaggedUsedHVACCoil;
   11627            0 :     TypeName = "Refrigeration:CompressorRack:";
   11628            0 :     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            0 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11635            0 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11636              : 
   11637            0 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11638            0 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11639              : 
   11640            0 :         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            0 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11655            0 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11656              :             // Check for maximum flow in the component
   11657            0 :             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            0 :     } 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            0 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11676            0 :         this->MassFlowRate = 0.0;
   11677              : 
   11678              :     } // on flow type
   11679              :     // check against plant, might get changed.
   11680            0 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11681              : 
   11682            0 :     this->VolFlowRate = this->MassFlowRate / rho;
   11683              : 
   11684            0 :     if (this->MassFlowRate > 0) {
   11685            0 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11686              :     } else {
   11687            0 :         this->OutletTemp = this->InletTemp;
   11688            0 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11689              : 
   11690            0 :             ShowRecurringWarningErrorAtEnd(
   11691              :                 state,
   11692            0 :                 TypeName + this->Name +
   11693              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11694            0 :                 this->NoFlowWarnIndex);
   11695              :         }
   11696              :     }
   11697              :     // Check outlet water temp for max value
   11698            0 :     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            0 :     this->UpdateCondenserOutletNode(state);
   11709            0 : }
   11710              : 
   11711            0 : 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            0 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11725              : 
   11726              :     // Set outlet node variables that are possibly changed
   11727            0 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11728            0 : }
   11729            0 : void RefrigCondenserData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11730              : {
   11731            0 : }
   11732            0 : void RefrigCondenserData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11733              : {
   11734            0 : }
   11735              : 
   11736            0 : 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            0 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11750              : 
   11751              :     // Set outlet node variables that are possibly changed
   11752            0 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11753            0 : }
   11754            0 : void RefrigRackData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11755              : {
   11756            0 : }
   11757              : 
   11758            0 : void RefrigRackData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11759              : {
   11760            0 : }
   11761              : 
   11762            0 : 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            0 :     Real64 constexpr MaxDelTFloatFrac = 0.5; // max fraction allowed for difference between case and evaporator temperature
   11785              : 
   11786            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   11787            0 :     auto &System = state.dataRefrigCase->System;
   11788            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   11789            0 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   11790            0 :     auto &Secondary = state.dataRefrigCase->Secondary;
   11791            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   11792            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   11793            0 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   11794            0 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   11795              : 
   11796            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   11797            0 :     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            0 :     if (state.dataRefrigCase->UseSysTimeStep) {
   11812            0 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   11813            0 :             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            0 :     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            0 :         if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11823            0 :             if (thisSys.NumCases > 0) {
   11824            0 :                 for (int CaseIndex = 1; CaseIndex <= thisSys.NumCases; ++CaseIndex) {
   11825            0 :                     auto &thisCase = RefrigCase(thisSys.CaseNum(CaseIndex));
   11826            0 :                     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            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11832            0 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11833              :                     } else { // calculate floating T evap
   11834            0 :                         Real64 LoadFrac = min(1.0, (thisCase.TotalCoolingLoad / thisCase.DesignRatedCap));
   11835            0 :                         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            0 :                         if (CaseIndex == 1) { // note use case index, not caseid here to get first case on this suction group/system
   11839            0 :                             thisSys.TEvapNeeded = MaxTEvap;
   11840              :                         } else {
   11841            0 :                             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            0 :                     thisSys.TotalCoolingLoad += thisCase.TotalCoolingLoad;
   11846            0 :                     thisSys.TotalCondDefrostCredit += thisCase.HotDefrostCondCredit;
   11847              :                 } // NumCases
   11848              :             } // Num of cases > 0
   11849              : 
   11850            0 :             if (thisSys.NumWalkIns > 0) {
   11851            0 :                 for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkIns; ++WalkInIndex) {
   11852            0 :                     auto &thisWalkIn = WalkIn(thisSys.WalkInNum(WalkInIndex));
   11853            0 :                     thisWalkIn.CalculateWalkIn(state);
   11854            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11855            0 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11856              :                     } else { // calculate floating T evap
   11857            0 :                         Real64 LoadFrac = min(1.0, (thisWalkIn.TotalCoolingLoad / thisWalkIn.DesignRatedCap));
   11858              :                         Real64 MaxTEvap =
   11859            0 :                             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            0 :                         if (WalkInIndex == 1 && thisSys.NumCases == 0) {
   11863            0 :                             thisSys.TEvapNeeded = MaxTEvap;
   11864              :                         } else {
   11865            0 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11866              :                         }
   11867              :                     } // floating or constant evap temperature
   11868              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11869            0 :                     thisSys.TotalCoolingLoad += thisWalkIn.TotalCoolingLoad;
   11870            0 :                     thisSys.TotalCondDefrostCredit += thisWalkIn.HotDefrostCondCredit;
   11871              :                 } // NumWalkIns systems
   11872              :             } // thisSys%NumWalkIns > 0
   11873              : 
   11874            0 :             if (thisSys.NumCoils > 0) {
   11875            0 :                 for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   11876            0 :                     int CoilID = thisSys.CoilNum(CoilIndex);
   11877              :                     // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   11878            0 :                     thisSys.TEvapNeeded = thisSys.TEvapDesign; // floating or constant evap temperature
   11879              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11880            0 :                     thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   11881            0 :                     thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   11882              :                 } // NumCoils systems
   11883              :             } // thisSys%NumCoils > 0
   11884              : 
   11885            0 :             if (thisSys.NumSecondarys > 0) {
   11886            0 :                 for (int SecondIndex = 1; SecondIndex <= thisSys.NumSecondarys; ++SecondIndex) {
   11887            0 :                     int SecondID = thisSys.SecondaryNum(SecondIndex);
   11888            0 :                     Secondary(SecondID).CalculateSecondary(state, SecondID);
   11889            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11890            0 :                         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            0 :                     thisSys.SumSecondaryLoopLoad += Secondary(SecondID).TotalCoolingLoad;
   11904            0 :                     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            0 :             thisSys.PipeHeatLoad = 0.0;
   11913            0 :             if (thisSys.SumUASuctionPiping > MySmallNumber) {
   11914            0 :                 Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNum)
   11915            0 :                                                  .Temp; // Temperature for zone identified as environment for suction pipe heat gains, C
   11916            0 :                 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            0 :                 int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNum;
   11920            0 :                 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            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11926            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11927            0 :                     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            0 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system,
   11938            0 :     if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) || (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) ||
   11939            0 :         (state.dataRefrigCase->NumSimulationSharedCondensers > 0) || (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0)) {
   11940            0 :         StartMechSubcoolLoop = 1;
   11941              :     }
   11942              : 
   11943            0 :     bool FirstSCLoop = true; // Flag first time through multi-system loop used when mech subcoolers present
   11944              : 
   11945            0 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3;
   11946              :          ++LoopNum) { // Note, for cascade cond loads compared requiring 5 iterations to 3, no difference.
   11947              : 
   11948            0 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   11949            0 :             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            0 :             if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11952            0 :                 thisSys.SumMechSCLoad = 0.0;
   11953            0 :                 thisSys.SumCascadeLoad = 0.0;
   11954            0 :                 thisSys.SumCascadeCondCredit = 0.0;
   11955            0 :                 thisSys.SumMechSCBenefit = 0.0;
   11956              : 
   11957            0 :                 if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) && (!FirstSCLoop)) {
   11958              :                     // This loop places load on system providing mechanical subcooling
   11959            0 :                     for (int SubcoolID = 1; SubcoolID <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolID) {
   11960            0 :                         if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) {
   11961            0 :                             continue;
   11962              :                         }
   11963            0 :                         if (Subcooler(SubcoolID).MechSourceSysID != SysNum) {
   11964            0 :                             continue;
   11965              :                         }
   11966              :                         // don't have summechscload until second subcooler pass, set to zero on first pass
   11967            0 :                         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            0 :                         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            0 :                     if (thisSys.NumSubcoolers > 0) {
   11978            0 :                         for (int SubcoolerIndex = 1; SubcoolerIndex <= thisSys.NumSubcoolers; ++SubcoolerIndex) {
   11979            0 :                             int SubcoolID = thisSys.SubcoolerNum(SubcoolerIndex);
   11980            0 :                             if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) {
   11981            0 :                                 continue;
   11982              :                             }
   11983            0 :                             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            0 :                 if ((thisSys.NumCascadeLoads > 0) && (!FirstSCLoop)) {
   11991            0 :                     for (int CascadeLoadIndex = 1; CascadeLoadIndex <= thisSys.NumCascadeLoads; ++CascadeLoadIndex) {
   11992            0 :                         int CascadeLoadID = thisSys.CascadeLoadNum(CascadeLoadIndex);
   11993            0 :                         if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11994            0 :                             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            0 :                         thisSys.SumCascadeLoad += Condenser(CascadeLoadID).CondLoad;
   12012            0 :                         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            0 :                 thisSys.TotalSystemLoad = thisSys.TotalCoolingLoad + thisSys.SumSecondaryLoopLoad + thisSys.SumMechSCLoad + thisSys.SumCascadeLoad;
   12019            0 :                 if (thisSys.TotalSystemLoad > 0.0) {
   12020            0 :                     thisSys.CpSatVapEvap = thisSys.refrig->getSatSpecificHeat(state, thisSys.TEvapNeeded, 1.0, RoutineName);
   12021            0 :                     thisSys.HCaseOut =
   12022            0 :                         thisSys.refrig->getSatEnthalpy(state, thisSys.TEvapNeeded, 1.0, RoutineName) + thisSys.CpSatVapEvap * CaseSuperheat;
   12023              :                     // Establish estimates to start solution loop
   12024            0 :                     switch (Condenser(thisSys.CondenserNum(1)).CondenserType) {
   12025            0 :                     case DataHeatBalance::RefrigCondenserType::Air: {
   12026            0 :                         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            0 :                     } break;
   12029            0 :                     case DataHeatBalance::RefrigCondenserType::Evap: {
   12030            0 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 15.0;
   12031              :                         // 15C is delta T at rating point for evap-cooled condensers
   12032            0 :                     } break;
   12033            0 :                     case DataHeatBalance::RefrigCondenserType::Water: {
   12034              :                         // define starting estimate at temperature of water exiting condenser
   12035            0 :                         thisSys.TCondense = state.dataLoopNodes->Node(Condenser(thisSys.CondenserNum(1)).OutletNode).Temp;
   12036            0 :                     } break;
   12037            0 :                     case DataHeatBalance::RefrigCondenserType::Cascade: {
   12038              :                         //?Don't need estimate for cascade condenser because it doesn't iterate?
   12039            0 :                     } break;
   12040            0 :                     default:
   12041            0 :                         break;
   12042              :                     }
   12043              : 
   12044              :                     // Produce first time step estimates, assume no subcoolers
   12045            0 :                     thisSys.HSatLiqCond = thisSys.refrig->getSatEnthalpy(state, thisSys.TCondense, 0.0, RoutineName);
   12046            0 :                     thisSys.CpSatLiqCond = thisSys.refrig->getSatSpecificHeat(state, thisSys.TCondense, 0.0, RoutineName);
   12047            0 :                     thisSys.HCaseIn = thisSys.HSatLiqCond - thisSys.CpSatLiqCond * Condenser(thisSys.CondenserNum(1)).RatedSubcool;
   12048            0 :                     thisSys.RefMassFlowtoLoads = thisSys.TotalSystemLoad / (thisSys.HCaseOut - thisSys.HCaseIn);
   12049            0 :                     thisSys.RefMassFlowComps = thisSys.RefMassFlowtoLoads;
   12050              : 
   12051            0 :                     if (thisSys.NumStages == 2) { // Two-stage compression system
   12052              :                         // Initial guess for high-stage mass flow rate in two-stage compression systems
   12053            0 :                         thisSys.RefMassFlowHiStageComps = thisSys.RefMassFlowComps / 0.65;
   12054              :                     }
   12055              : 
   12056            0 :                     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            0 :                     Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12063            0 :                     if ((thisSys.CoilFlag) && (CurrentLoads > (thisSys.TotCompCapacity * 1.001))) {
   12064            0 :                         DeRate = true;
   12065            0 :                         FinalRateCoils(state, DeRate, SourceType::DetailedSystem, SysNum, CurrentLoads, thisSys.TotCompCapacity);
   12066            0 :                         thisSys.TotalCoolingLoad = 0.0;
   12067            0 :                         thisSys.TotalCondDefrostCredit = 0.0;
   12068            0 :                         for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   12069            0 :                             int CoilID = thisSys.CoilNum(CoilIndex);
   12070              :                             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   12071            0 :                             if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12072            0 :                                 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            0 :                             thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   12080            0 :                             thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   12081              :                         } // NumCoils systems
   12082            0 :                         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            0 :         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            0 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   12103            0 :         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            0 :         if ((((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) &&
   12106            0 :             (!state.dataGlobal->WarmupFlag)) {
   12107            0 :             Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12108            0 :             Real64 CurrentHiStageLoads(0.0); // Current loads on high-stage compressor, exclusive of unmet loads from
   12109            0 :             if (thisSys.NumStages == 2) {
   12110            0 :                 CurrentHiStageLoads = CurrentLoads + thisSys.TotCompPower;
   12111              :             } // NumStages==2
   12112            0 :             if (thisSys.CoilFlag) {
   12113              :                 // don't use 'unmet energy' with air chillers, see 'derate'
   12114            0 :                 thisSys.UnmetEnergy = 0.0;
   12115            0 :                 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            0 :                 thisSys.UnmetEnergy += (CurrentLoads - thisSys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12122            0 :                 if (thisSys.NumStages == 2) {
   12123            0 :                     thisSys.UnmetHiStageEnergy += (CurrentHiStageLoads - thisSys.TotHiStageCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12124              :                 }
   12125            0 :                 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            0 :                 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            0 :             if (thisSys.SystemRejectHeatToZone) {
   12148            0 :                 int CondInletAirZoneNum = Condenser(thisSys.CondenserNum(1)).InletAirZoneNum;
   12149            0 :                 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            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12155            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12156            0 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone +=
   12157            0 :                         thisSys.NetHeatRejectLoad; // Adding heat is positive
   12158              :                 } // UseSystimestep
   12159              :             } // Reject heat to zone
   12160              : 
   12161              :             // Report variables
   12162            0 :             thisSys.TotTransferLoad = thisSys.SumMechSCLoad - thisSys.SumMechSCBenefit + thisSys.SumSecondaryLoopLoad + thisSys.SumCascadeLoad;
   12163            0 :             thisSys.TotTransferEnergy = thisSys.TotTransferLoad * localTimeStepSec;
   12164            0 :             thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * localTimeStepSec;
   12165            0 :             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            0 :     if (state.dataRefrigCase->UseSysTimeStep) {
   12176            0 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12177            0 :             auto &zoneCredit = CoilSysCredit(ZoneNum);
   12178            0 :             for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
   12179            0 :                 auto &coil = WarehouseCoil(CoilID);
   12180            0 :                 if (coil.ZoneNum != ZoneNum) {
   12181            0 :                     continue;
   12182              :                 }
   12183            0 :                 zoneCredit.SenCreditToZoneRate -= coil.SensCreditRate;
   12184            0 :                 zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * localTimeStepSec;
   12185            0 :                 zoneCredit.LatKgPerS_ToZoneRate -= coil.LatKgPerS_ToZone;
   12186            0 :                 zoneCredit.LatCreditToZoneRate -= coil.LatCreditRate;
   12187            0 :                 zoneCredit.LatCreditToZoneEnergy -= coil.LatCreditEnergy;
   12188              :             }
   12189              :         }
   12190              :     }
   12191              : 
   12192            0 :     SumZoneImpacts(state);
   12193            0 : }
   12194              : 
   12195            0 : 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            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   12215            0 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   12216            0 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   12217            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   12218              : 
   12219            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12220            0 :     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            0 :     for (auto &thisSys : TransSystem) {
   12228              :         // Only do those systems appropriate for this analysis, supermarket type on load time step
   12229            0 :         if (thisSys.NumCasesMT > 0) {
   12230            0 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesMT; ++CaseIndex) {
   12231            0 :                 int CaseID = thisSys.CaseNumMT(CaseIndex);
   12232            0 :                 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            0 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   12236              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12237            0 :                 thisSys.TotalCoolingLoadMT += RefrigCase(CaseID).TotalCoolingLoad;
   12238            0 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12239              :             } // NumCasesMT
   12240              :         } // Num of MT cases > 0
   12241              : 
   12242            0 :         if (thisSys.NumCasesLT > 0) {
   12243            0 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesLT; ++CaseIndex) {
   12244            0 :                 int CaseID = thisSys.CaseNumLT(CaseIndex);
   12245            0 :                 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            0 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12249              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12250            0 :                 thisSys.TotalCoolingLoadLT += RefrigCase(CaseID).TotalCoolingLoad;
   12251            0 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12252              :             } // NumCasesLT
   12253              :         } // Num of LT cases > 0
   12254              : 
   12255            0 :         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            0 :         if (thisSys.NumWalkInsLT > 0) {
   12269            0 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsLT; ++WalkInIndex) {
   12270            0 :                 int WalkInID = thisSys.WalkInNumLT(WalkInIndex);
   12271            0 :                 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            0 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12275              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   12276            0 :                 thisSys.TotalCoolingLoadLT += WalkIn(WalkInID).TotalCoolingLoad;
   12277            0 :                 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            0 :         thisSys.PipeHeatLoadMT = 0.0;
   12285            0 :         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            0 :         thisSys.PipeHeatLoadLT = 0.0;
   12299            0 :         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            0 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system, don't loop
   12319            0 :     if (state.dataRefrigCase->NumSimulationSharedGasCoolers > 0) {
   12320            0 :         StartMechSubcoolLoop = 1;
   12321              :     }
   12322              : 
   12323            0 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3; ++LoopNum) {
   12324            0 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12325            0 :             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            0 :             sys.TotalSystemLoadMT = sys.TotalCoolingLoadMT;
   12329            0 :             if (sys.transSysType == TransSysType::TwoStage) {
   12330            0 :                 sys.TotalSystemLoadLT = sys.TotalCoolingLoadLT;
   12331              :             }
   12332            0 :             sys.TotalSystemLoad = sys.TotalSystemLoadLT + sys.TotalSystemLoadMT;
   12333            0 :             if (sys.TotalSystemLoad > 0.0) {
   12334            0 :                 if (sys.transSysType == TransSysType::TwoStage) {
   12335            0 :                     sys.CpSatVapEvapLT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededLT, 1.0, RoutineName);
   12336            0 :                     sys.HCaseOutLT = sys.refrig->getSatEnthalpy(state, sys.TEvapNeededLT, 1.0, RoutineName) + sys.CpSatVapEvapLT * TransCaseSuperheat;
   12337              :                 }
   12338            0 :                 sys.CpSatVapEvapMT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededMT, 1.0, RoutineName);
   12339            0 :                 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            0 :                 sys.TReceiver = sys.refrig->getSatTemperature(state, sys.PReceiver, RoutineName);
   12344            0 :                 sys.HSatLiqReceiver = sys.refrig->getSatEnthalpy(state, sys.TReceiver, 0.0, RoutineName);
   12345            0 :                 sys.CpSatLiqReceiver = sys.refrig->getSatSpecificHeat(state, sys.TReceiver, 0.0, RoutineName);
   12346            0 :                 sys.HCaseInMT = sys.HSatLiqReceiver;
   12347            0 :                 sys.HCaseInLT = sys.HSatLiqReceiver;
   12348            0 :                 sys.RefMassFlowtoLTLoads = 0.0;
   12349            0 :                 sys.RefMassFlowCompsLP = 0.0;
   12350            0 :                 sys.DelHSubcoolerDis = 0.0;
   12351            0 :                 sys.DelHSubcoolerSuc = 0.0;
   12352            0 :                 if (sys.transSysType == TransSysType::TwoStage) {
   12353            0 :                     sys.RefMassFlowtoLTLoads = sys.TotalSystemLoadLT / (sys.HCaseOutLT - sys.HCaseInLT);
   12354            0 :                     sys.RefMassFlowCompsLP = sys.RefMassFlowtoLTLoads;
   12355              :                 } // (thisSys%TransSysType == 2)
   12356            0 :                 sys.RefMassFlowtoMTLoads = sys.TotalSystemLoadMT / (sys.HCaseOutMT - sys.HCaseInMT);
   12357            0 :                 sys.RefMassFlowCompsHP = sys.RefMassFlowtoLTLoads + sys.RefMassFlowtoMTLoads;
   12358              : 
   12359            0 :                 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            0 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12368            0 :         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            0 :         if ((!state.dataRefrigCase->UseSysTimeStep) && (!state.dataGlobal->WarmupFlag)) {
   12371            0 :             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            0 :             sys.UnmetEnergy += (CurrentLoads - sys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12377              : 
   12378            0 :             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            0 :             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            0 :             sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * localTimeStepSec;
   12400            0 :             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            0 :     SumZoneImpacts(state);
   12407            0 : }
   12408              : 
   12409            0 : 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            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12443              : 
   12444            0 :     bool NotBalanced = true;
   12445            0 :     int NumIter = 0;
   12446            0 :     Real64 ErrorMassFlowComps(0.0);        // Error in calculated low stage compressor mass flow (single- or two-stage systems)
   12447            0 :     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            0 :     Real64 MassFlowHiStageCompsStart(0.0); // Mass flow through high-stage compressors (two-stage systems only)
   12451              : 
   12452            0 :     while (NotBalanced) {
   12453              :         // Set values for iteration convergence tolerance check
   12454            0 :         ++NumIter;
   12455              :         // Mass flow through (low-stage) compressors (single- or two-stage systems)
   12456            0 :         Real64 MassFlowCompsStart = this->RefMassFlowComps;
   12457              : 
   12458            0 :         if (this->NumStages == 2) { // Two-stage systems
   12459            0 :             MassFlowHiStageCompsStart = this->RefMassFlowHiStageComps;
   12460              :         }
   12461              : 
   12462            0 :         if (this->NumSubcoolers > 0) {
   12463            0 :             this->CalculateSubcoolers(state);
   12464              :         }
   12465            0 :         this->CalculateCompressors(state);
   12466            0 :         this->CalculateCondensers(state, SysNum);
   12467            0 :         this->RefMassFlowtoLoads = this->TotalSystemLoad / (this->HCaseOut - this->HCaseIn);
   12468            0 :         if (NumIter < 2) {
   12469            0 :             continue;
   12470              :         }
   12471              :         // Previously did error check on calculated Tcondense, but not sensitive enough
   12472            0 :         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            0 :             ErrorMassFlowComps = std::abs(MassFlowCompsStart - this->RefMassFlowComps) / MassFlowCompsStart;
   12476            0 :             if (this->NumStages == 2) { // Two-stage systems
   12477            0 :                 ErrorMassFlowHiStageComps = std::abs(MassFlowHiStageCompsStart - this->RefMassFlowHiStageComps) / MassFlowCompsStart;
   12478              :             }
   12479              :         } // denominator zero check
   12480            0 :         if (NumIter > 20) {
   12481            0 :             break;
   12482              :         }
   12483            0 :         if (ErrorMassFlowComps < ErrorTol) {
   12484            0 :             if (this->NumStages == 1 || (this->NumStages == 2 && ErrorMassFlowHiStageComps < ErrorTol)) {
   12485            0 :                 NotBalanced = false;
   12486              :             }
   12487              :         }
   12488              :     } // error check
   12489            0 : }
   12490              : 
   12491            0 : 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            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12514              : 
   12515            0 :     int NumIter(0);            // Iteration counter
   12516            0 :     bool NotBalanced(true);    // Flag to indicate convergence, based on system balance
   12517            0 :     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            0 :     while (NotBalanced) {
   12521            0 :         ++NumIter;
   12522              : 
   12523            0 :         if (this->NumGasCoolers >= 1) {
   12524            0 :             this->CalcGasCooler(state, SysNum);
   12525              :         }
   12526            0 :         this->CalculateTransCompressors(state);
   12527            0 :         if (NumIter < 2) {
   12528            0 :             continue;
   12529              :         }
   12530            0 :         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            0 :             ErrorMassFlow = std::abs(MassFlowStart - this->RefMassFlowReceiverBypass) / MassFlowStart;
   12537            0 :             MassFlowStart = this->RefMassFlowReceiverBypass;
   12538              :         } // denominator zero check
   12539            0 :         if (NumIter > 20) {
   12540            0 :             break;
   12541              :         }
   12542            0 :         if (ErrorMassFlow < ErrorTol) {
   12543            0 :             NotBalanced = false;
   12544              :         }
   12545              :     } // error check
   12546            0 : }
   12547              : 
   12548            0 : 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            0 :     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            0 :     auto &System = state.dataRefrigCase->System;
   12589            0 :     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            0 :     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            0 :     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            0 :     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            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12633            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12634              : 
   12635              :     // Initialize this condenser for this time step
   12636            0 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   12637            0 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   12638            0 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12639            0 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   12640            0 :     ActualFanPower = 0.0;
   12641            0 :     TotalCondDefrostCreditLocal = 0.0;
   12642            0 :     TotalLoadFromSystems = 0.0;
   12643            0 :     EvapAvail = true;
   12644            0 :     CondID = this->CondenserNum(1);
   12645            0 :     auto &condenser = Condenser(CondID);
   12646            0 :     RatedFanPower = condenser.RatedFanPower;
   12647            0 :     RatedAirFlowRate = condenser.RatedAirFlowRate;
   12648            0 :     FanMinAirFlowRatio = condenser.FanMinAirFlowRatio;
   12649            0 :     CondCreditWarnIndex1 = condenser.CondCreditWarnIndex1;
   12650            0 :     CondCreditWarnIndex2 = condenser.CondCreditWarnIndex2;
   12651            0 :     CondCreditWarnIndex3 = condenser.CondCreditWarnIndex3;
   12652            0 :     CondCreditWarnIndex4 = condenser.CondCreditWarnIndex4;
   12653            0 :     CondCreditWarnIndex5 = condenser.CondCreditWarnIndex5;
   12654            0 :     CondCreditWarnIndex6 = condenser.CondCreditWarnIndex6;
   12655            0 :     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            0 :     for (Sysloop = 1; Sysloop <= condenser.NumSysAttach; ++Sysloop) {
   12662            0 :         SystemID = condenser.SysNum(Sysloop);
   12663            0 :         TotalCondDefCredfromSysID = System(SystemID).TotalCondDefrostCredit + System(SystemID).SumCascadeCondCredit;
   12664            0 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   12665              :         // total heat rejection load from a single detailed system [W]
   12666              :         Real64 TotalLoadFromSysID =
   12667            0 :             System(SystemID).TotalSystemLoad + System(SystemID).TotCompPower + System(SystemID).TotHiStageCompPower + System(SystemID).PipeHeatLoad;
   12668            0 :         TotalLoadFromSystems += TotalLoadFromSysID;
   12669            0 :         if (SystemID == SysNum) {
   12670            0 :             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            0 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) {
   12676            0 :         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            0 :     condenser.ExternalHeatRecoveredLoad = condenser.LaggedUsedWaterHeater + condenser.LaggedUsedHVACCoil;
   12684            0 :     condenser.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12685            0 :     condenser.TotalHeatRecoveredLoad = condenser.ExternalHeatRecoveredLoad + TotalCondDefrostCreditLocal;
   12686              : 
   12687            0 :     state.dataRefrigCase->TotalCondenserHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal - condenser.ExternalHeatRecoveredLoad;
   12688            0 :     if (state.dataRefrigCase->TotalCondenserHeat < 0.0) {
   12689              : 
   12690            0 :         state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12691            0 :         if (!state.dataGlobal->WarmupFlag) {
   12692            0 :             ShowRecurringWarningErrorAtEnd(state,
   12693            0 :                                            "Refrigeration:System: " + this->Name +
   12694              :                                                ":heat reclaimed(defrost,other purposes) >current condenser load. ",
   12695              :                                            CondCreditWarnIndex1);
   12696            0 :             ShowRecurringContinueErrorAtEnd(
   12697              :                 state, "For heat recovered for defrost: ASHRAE rule of thumb: <= 25% of the load on a rack ", CondCreditWarnIndex2);
   12698            0 :             ShowRecurringContinueErrorAtEnd(
   12699              :                 state, "should be in defrost at the same time. Consider diversifying defrost schedules.", CondCreditWarnIndex3);
   12700            0 :             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            0 :             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            0 :             ShowRecurringContinueErrorAtEnd(
   12709              :                 state, "(relative to the number of time steps in the simulation), there may be a mis-match between the", CondCreditWarnIndex6);
   12710            0 :             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            0 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   12720              :         // Obtain water-cooled condenser inlet/outlet temps
   12721            0 :         condenser.InletTemp = state.dataLoopNodes->Node(condenser.InletNode).Temp;
   12722            0 :         TCondCalc = state.dataLoopNodes->Node(condenser.InletNode).Temp + condenser.RatedApproachT;
   12723            0 :         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            0 :             this->TCondense = TCondCalc;
   12739              :         }
   12740              : 
   12741            0 :     } else if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) ||
   12742            0 :                (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            0 :         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            0 :         if (condenser.InletAirNodeNum != 0) {
   12752            0 :             OutDbTemp = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Temp;
   12753            0 :             BPress = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Press;
   12754            0 :             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            0 :         AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn);
   12761            0 :         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            0 :         if (OutDbTemp < EvapCutOutTdb) {
   12770            0 :             EvapAvail = false;
   12771              :         }
   12772              : 
   12773              :         // Check schedule to determine evap condenser availability
   12774              :         // IF schedule exists, evap condenser can be scheduled OFF
   12775            0 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (condenser.evapAvailSched != nullptr) &&
   12776            0 :             (condenser.evapAvailSched->getCurrentVal() == 0)) {
   12777            0 :             EvapAvail = false;
   12778              :         }
   12779              : 
   12780              :         // Calculate condensing temperatures for air-cooled and evap-cooled
   12781            0 :         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            0 :             if (CapFac > 0.0) {
   12787            0 :                 HRCF = condenser.EvapElevFact / CapFac;
   12788              :                 // Condenser(CondNum)%EvapElevFact=1.0d0-3.074D-5*Elevation
   12789              :             } else {
   12790            0 :                 HRCF = MyLargeNumber;
   12791              :             }
   12792            0 :             HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12793            0 :             HRCF = max(HRCF, condenser.MinCapFacEvap);
   12794            0 :             if (EvapAvail) {
   12795            0 :                 OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   12796            0 :                 SinkTemp = OutWbTemp;
   12797              :             } else {         // evaporative condenser with water spray scheduled off so use Tdb
   12798            0 :                 HRCF /= 3.0; // reference Menske, cap of evap cond operating dry about 1/3 of rated cap
   12799            0 :                 HRCF = max(HRCF, condenser.MinCapFacEvap);
   12800            0 :                 SinkTemp = OutDbTemp;
   12801              :             } // evap avail, still in evap condenser
   12802            0 :             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            0 :             TCondCalc = OutDbTemp + (state.dataRefrigCase->TotalCondenserHeat - condenser.MinCondLoad) * condenser.TempSlope;
   12806            0 :             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            0 :         if (TCondCalc >= this->TCondenseMin) {
   12812            0 :             this->TCondense = TCondCalc;
   12813            0 :             ActualFanPower = RatedFanPower;
   12814            0 :             AirVolRatio = 1.0;
   12815              : 
   12816              :         } else { // need to reduce fan speed to reduce air flow and keep Tcond at or above Tcond min
   12817            0 :             this->TCondense = this->TCondenseMin;
   12818            0 :             TCondCalc = this->TCondenseMin;
   12819              :             // recalculate CapFac at current delta T
   12820            0 :             if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
   12821              :                 // current maximum condenser capacity at delta T present for minimum condensing temperature [W]
   12822            0 :                 Real64 CurMaxCapacity = Curve::CurveValue(state, condenser.CapCurvePtr, (this->TCondenseMin - OutDbTemp));
   12823            0 :                 CapFac = state.dataRefrigCase->TotalCondenserHeat / CurMaxCapacity;
   12824            0 :                 AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   12825            0 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12826              :             } else { // condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap
   12827            0 :                 HRCFFullFlow = HRCF;
   12828              :                 // if evap condenser need to back calculate the operating capacity using HRCF relationship, given known Tcond
   12829            0 :                 Real64 QuadBterm = condenser.EvapCoeff1 - (this->TCondense - SinkTemp) + condenser.EvapCoeff4 * SinkTemp;
   12830            0 :                 Real64 Sqrtterm = pow_2(QuadBterm) - 4.0 * condenser.EvapCoeff2 * condenser.EvapCoeff3;
   12831            0 :                 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            0 :                     HRCF = condenser.EvapElevFact * (-QuadBterm - std::sqrt(Sqrtterm)) / (2.0 * condenser.EvapCoeff2);
   12839            0 :                     if (!EvapAvail) {
   12840            0 :                         HRCF /= 3.0;
   12841              :                     }
   12842            0 :                     HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12843            0 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12844              :                 } // sqrtterm
   12845            0 :                 CapFac = HRCF / HRCFFullFlow; // note, HRCFFullFlow previously limited between min and max,so can't be zero
   12846            0 :                 if (EvapAvail) {
   12847            0 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentEvap)); // Fans limited by minimum air flow ratio
   12848              :                 } else {                                                                             // evap not available
   12849            0 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry));  // Fans limited by minimum air flow ratio
   12850              :                 } // evap available
   12851            0 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12852              :             } // condenser type = DataHeatBalance::RefrigCondenserType::Air with else for evap
   12853              : 
   12854            0 :             switch (condenser.FanSpeedControlType) {
   12855            0 :             case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   12856            0 :                 FanPowerRatio = std::pow(AirVolRatio, 2.5);
   12857            0 :                 ActualFanPower = FanPowerRatio * RatedFanPower;
   12858            0 :             } break;
   12859            0 :             case FanSpeedCtrlType::ConstantSpeed: {
   12860            0 :                 ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12861            0 :             } break;
   12862            0 :             case FanSpeedCtrlType::ConstantSpeedLinear: {
   12863            0 :                 ActualFanPower = AirVolRatio * RatedFanPower;
   12864            0 :             } break;
   12865            0 :             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            0 :                 Real64 const air_vol_fan_power_fac(std::exp(1.0 - AirVolRatio) * RatedFanPower);
   12870            0 :                 ActualFanPower = AirVolRatio * air_vol_fan_power_fac;
   12871            0 :                 if (CapFac < CapFac60Percent) {
   12872            0 :                     ActualFanPower = ((AirVolRatio + 0.4) * FanHalfSpeedRatio) * air_vol_fan_power_fac;
   12873              :                 }
   12874            0 :             } break;
   12875            0 :             default:
   12876            0 :                 break;
   12877              :             } // fan speed control type
   12878              :         } // Tcondense >= Tcondense minimum
   12879              : 
   12880            0 :         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            0 :             PurgeRate = state.dataRefrigCase->TotalCondenserHeat * BleedRateConstant;
   12888            0 :             EnthalpyAirIn = Psychrometrics::PsyHFnTdbW(OutDbTemp, HumRatIn);
   12889              :             // calculate effectiveness at rated conditions, so use Tcondcalc)
   12890            0 :             EnthalpyAtTcond = Psychrometrics::PsyHFnTdbRhPb(state, TCondCalc, 1.0, BPress);
   12891            0 :             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            0 :             Effectiveness = min(Effectiveness, 0.9);
   12894            0 :             EnthalpyAirOut = EnthalpyAirIn + Effectiveness * (EnthalpyAtTcond - EnthalpyAirIn);
   12895              :             // Air leaving the evaporative condenser is saturated
   12896            0 :             Real64 TAirOut = Psychrometrics::PsyTsatFnHPb(state, EnthalpyAirOut, BPress);
   12897            0 :             HumRatOut = Psychrometrics::PsyWFnTdpPb(state, TAirOut, BPress);
   12898            0 :             state.dataRefrigCase->TotalEvapWaterUseRate =
   12899            0 :                 PurgeRate + RatedAirFlowRate * AirVolRatio * AirDensityDry * (HumRatOut - HumRatIn) / Psychrometrics::RhoH2O(OutWbTemp);
   12900              :             // assumes evap water pump runs whenever evap cooling is available to minimize scaling
   12901            0 :             state.dataRefrigCase->TotalCondenserPumpPower = condenser.EvapPumpPower;
   12902              :             // calculate basin water heater load
   12903            0 :             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            0 :     } 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            0 :         this->TCondense = condenser.RatedTCondense;
   12932              : 
   12933            0 :         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            0 :     condenser.ActualFanPower = ActualFanPower;
   12948            0 :     condenser.FanElecEnergy = ActualFanPower * localTimeStepSec;
   12949            0 :     condenser.EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   12950            0 :     condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   12951            0 :     condenser.ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   12952            0 :     condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   12953            0 :     condenser.BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   12954            0 :     condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   12955            0 :     condenser.CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   12956            0 :     condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec;
   12957            0 :     condenser.CondCreditWarnIndex1 = CondCreditWarnIndex1;
   12958            0 :     condenser.CondCreditWarnIndex2 = CondCreditWarnIndex2;
   12959            0 :     condenser.CondCreditWarnIndex3 = CondCreditWarnIndex3;
   12960            0 :     condenser.CondCreditWarnIndex4 = CondCreditWarnIndex4;
   12961            0 :     condenser.CondCreditWarnIndex5 = CondCreditWarnIndex5;
   12962            0 :     condenser.CondCreditWarnIndex6 = CondCreditWarnIndex6;
   12963            0 :     condenser.CondCreditWarnIndex7 = CondCreditWarnIndex7;
   12964            0 :     condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * localTimeStepSec;
   12965            0 :     condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * localTimeStepSec;
   12966            0 :     condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * localTimeStepSec;
   12967            0 :     this->NetHeatRejectLoad = state.dataRefrigCase->TotalCondenserHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   12968            0 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   12969              : 
   12970              :     // set water system demand request (if needed)
   12971            0 :     if (condenser.EvapWaterSupplyMode == WaterSupply::FromTank) {
   12972            0 :         state.dataWaterData->WaterStorage(condenser.EvapWaterSupTankID).VdotRequestDemand(condenser.EvapWaterTankDemandARRID) =
   12973            0 :             condenser.EvapWaterConsumpRate;
   12974              :     }
   12975            0 : }
   12976              : 
   12977            0 : 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            0 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   13014            0 :     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            0 :     Real64 TotalLoadFromThisSystem(0.0); // Total heat rejection load from the detailed system identified in subroutine call [W]
   13030              : 
   13031            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13032            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13033              : 
   13034              :     // Initialize this gas cooler for this time step
   13035            0 :     ActualFanPower = 0.0;
   13036            0 :     TotalCondDefrostCreditLocal = 0.0;
   13037            0 :     TotalLoadFromSystems = 0.0;
   13038            0 :     int GasCoolerID = this->GasCoolerNum(1);
   13039            0 :     auto &cooler = GasCooler(GasCoolerID);
   13040            0 :     RatedFanPower = cooler.RatedFanPower;
   13041            0 :     FanMinAirFlowRatio = cooler.FanMinAirFlowRatio;
   13042            0 :     GasCoolerCreditWarnIndex = cooler.GasCoolerCreditWarnIndex;
   13043              : 
   13044            0 :     for (int Sysloop = 1; Sysloop <= cooler.NumSysAttach; ++Sysloop) {
   13045            0 :         int SystemID = cooler.SysNum(Sysloop);
   13046            0 :         TotalCondDefCredfromSysID = TransSystem(SystemID).TotalCondDefrostCredit;
   13047            0 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   13048            0 :         TotalLoadFromSysID = TransSystem(SystemID).TotalSystemLoadLT + TransSystem(SystemID).TotalSystemLoadMT +
   13049            0 :                              TransSystem(SystemID).TotCompPowerLP + TransSystem(SystemID).TotCompPowerHP + TransSystem(SystemID).PipeHeatLoadLT +
   13050            0 :                              TransSystem(SystemID).PipeHeatLoadMT;
   13051            0 :         TotalLoadFromSystems += TotalLoadFromSysID;
   13052            0 :         if (SystemID == SysNum) {
   13053            0 :             TotalLoadFromThisSystem = TotalLoadFromSysID;
   13054              :         }
   13055              :     } // Sysloop over every system connected to this gas cooler
   13056              : 
   13057              :     // Calculate Total Heat rejection needed.
   13058            0 :     cooler.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13059            0 :     cooler.TotalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13060            0 :     TotalGasCoolerHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal;
   13061              : 
   13062            0 :     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            0 :     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            0 :     if (cooler.InletAirNodeNum != 0) {
   13079            0 :         OutDbTemp = state.dataLoopNodes->Node(cooler.InletAirNodeNum).Temp;
   13080              :     } else {
   13081            0 :         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            0 :     if (OutDbTemp > cooler.TransitionTemperature) { // Gas cooler in transcritical operation
   13089            0 :         cooler.TGasCoolerOut = OutDbTemp + cooler.GasCoolerApproachT;
   13090            0 :         cooler.PGasCoolerOut = 1.0e5 * (2.3083 * state.dataEnvrn->OutDryBulbTemp + 11.9);
   13091            0 :         if (cooler.PGasCoolerOut < 7.5e6) { // Ensure gas cooler pressure is at least 7.5 MPa for transcritical operation
   13092            0 :             cooler.PGasCoolerOut = 7.5e6;
   13093              :         }
   13094            0 :         cooler.HGasCoolerOut = this->refrig->getSupHeatEnthalpy(state, cooler.TGasCoolerOut, cooler.PGasCoolerOut, RoutineName);
   13095            0 :         cooler.TransOpFlag = true;
   13096              :     } else { // Gas cooler in subcritical operation
   13097            0 :         cooler.TGasCoolerOut = OutDbTemp + cooler.SubcriticalTempDiff;
   13098            0 :         if (cooler.TGasCoolerOut > 30.978) { //  Gas temperature should be less than critical temperature
   13099            0 :             cooler.PGasCoolerOut = 7.2e6;    //  Fix the pressure to be subcritical
   13100            0 :             cooler.TGasCoolerOut = this->refrig->getSatTemperature(state, cooler.PGasCoolerOut, RoutineName);
   13101            0 :         } else if (cooler.TGasCoolerOut > cooler.MinCondTemp) { //  Allow condensing temperature to float above the minimum
   13102            0 :             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            0 :         cooler.HGasCoolerOut = this->refrig->getSatEnthalpy(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   13108            0 :         cooler.TransOpFlag = false;
   13109              :     } // (OutDbTemp > TransitionTemperature)
   13110              : 
   13111            0 :     if (cooler.TGasCoolerOut < 30.978) {
   13112            0 :         cooler.CpGasCoolerOut = this->refrig->getSatSpecificHeat(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   13113              :     } else {
   13114            0 :         cooler.CpGasCoolerOut = 0.0;
   13115              :     }
   13116              : 
   13117              :     // Gas cooler fan energy calculations
   13118            0 :     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   13119              : 
   13120            0 :     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            0 :     case FanSpeedCtrlType::ConstantSpeed: {
   13126            0 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13127            0 :     } 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            0 :     cooler.ActualFanPower = ActualFanPower;
   13145            0 :     cooler.FanElecEnergy = ActualFanPower * localTimeStepSec;
   13146            0 :     cooler.GasCoolerLoad = TotalGasCoolerHeat;
   13147            0 :     cooler.GasCoolerEnergy = TotalGasCoolerHeat * localTimeStepSec;
   13148            0 :     cooler.GasCoolerCreditWarnIndex = GasCoolerCreditWarnIndex;
   13149            0 :     cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * localTimeStepSec;
   13150            0 :     cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * localTimeStepSec;
   13151            0 :     this->NetHeatRejectLoad = TotalGasCoolerHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   13152            0 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   13153            0 : }
   13154              : 
   13155            0 : 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            0 :     Real64 constexpr DelTSuctPipes(1.0);  // Tsat drop corresponding to P drop in suction pipes, ASHRAE 2006 p 2.4 (C)
   13184            0 :     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            0 :     Real64 HCompInRated(0.0);         // Enthalpy entering compressor at rated superheat, J/kg //Autodesk:Init
   13193            0 :     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            0 :     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            0 :     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            0 :     Real64 HCaseInRated_base(0.0), HCompInRated_base(0.0); // Autodesk:Tuned Intermediate values for performance tuning
   13210              : 
   13211            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13212            0 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13213              : 
   13214            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13215            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13216              : 
   13217            0 :     int CondID = this->CondenserNum(1);
   13218            0 :     auto const &Condenser1 = Condenser(CondID);
   13219            0 :     Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / localTimeStepSec)); // Load due to previously unmet compressor loads
   13220            0 :     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            0 :     this->TotCompCapacity = 0.0;
   13224            0 :     this->RefMassFlowComps = 0.0;
   13225            0 :     this->TotCompPower = 0.0;
   13226            0 :     if (this->NumStages == 2) {
   13227            0 :         this->TotHiStageCompCapacity = 0.0;
   13228            0 :         this->RefMassFlowHiStageComps = 0.0;
   13229            0 :         this->TotHiStageCompPower = 0.0;
   13230              :     }
   13231              : 
   13232            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressors; ++CompIndex) {
   13233            0 :         int CompID = this->CompressorNum(CompIndex);
   13234            0 :         auto &compressor = Compressor(CompID);
   13235            0 :         compressor.Power = 0.0;
   13236            0 :         compressor.MassFlow = 0.0;
   13237            0 :         compressor.Capacity = 0.0;
   13238            0 :         compressor.ElecConsumption = 0.0;
   13239            0 :         compressor.CoolingEnergy = 0.0;
   13240            0 :         compressor.LoadFactor = 0.0;
   13241              :     }
   13242            0 :     if (this->NumStages == 2) {
   13243            0 :         for (int CompIndex = 1; CompIndex <= this->NumHiStageCompressors; ++CompIndex) {
   13244            0 :             int CompID = this->HiStageCompressorNum(CompIndex);
   13245            0 :             auto &compressor = Compressor(CompID);
   13246            0 :             compressor.Power = 0.0;
   13247            0 :             compressor.MassFlow = 0.0;
   13248            0 :             compressor.Capacity = 0.0;
   13249            0 :             compressor.ElecConsumption = 0.0;
   13250            0 :             compressor.CoolingEnergy = 0.0;
   13251            0 :             compressor.LoadFactor = 0.0;
   13252              :         }
   13253              :     }
   13254              : 
   13255              :     // Determine properties at case inlet and compressor inlet
   13256            0 :     for (int StageIndex = 1; StageIndex <= min(2, this->NumStages); ++StageIndex) {
   13257            0 :         if (StageIndex == 1) {                                    // Do single-stage or low-stage calculations
   13258            0 :             if (this->NumStages == 1) {                           // Single-stage system
   13259            0 :                 NeededCapacity = NeededCapacity_base;             // because compressor capacity rated from txv to comp inlet
   13260            0 :                 TsatforPdisch = this->TCondense + DelTDischPipes; // need (Psat of (Tcond + delT corresponding to delP disch Pipes))
   13261            0 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes; // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13262            0 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   13263            0 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13264            0 :                 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            0 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   13271            0 :                     this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13272            0 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13273            0 :                     this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool;
   13274            0 :                     this->HCompIn = this->HCaseOut;
   13275              :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   13276            0 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   13277              :                 } // whether or not subcooler routine used
   13278            0 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13279            0 :                 NumComps = this->NumCompressors;
   13280              :             } else { // Low-stage side of two-stage system
   13281            0 :                 PCond = this->refrig->getSatPressure(state, this->TCondense, RoutineName);
   13282            0 :                 PEvap = this->refrig->getSatPressure(state, this->TEvapNeeded, RoutineName);
   13283            0 :                 this->PIntercooler = std::sqrt(PCond * PEvap);
   13284            0 :                 this->TIntercooler = this->refrig->getSatTemperature(state, this->PIntercooler, RoutineName);
   13285            0 :                 NeededCapacity = NeededCapacity_base;                // because compressor capacity rated from txv to comp inlet
   13286            0 :                 TsatforPdisch = this->TIntercooler + DelTDischPipes; // need (Psat of (Tinter + delT corresponding to delP disch Pipes))
   13287            0 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes;    // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13288            0 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   13289            0 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13290            0 :                 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            0 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   13296            0 :                     if (this->intercoolerType == IntercoolerType::Flash) {
   13297            0 :                         this->HCaseIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13298            0 :                         this->TLiqInActual = this->TIntercooler;
   13299            0 :                     } else if (this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13300            0 :                         this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool -
   13301            0 :                                              this->IntercoolerEffectiveness * (this->TCondense - Condenser1.RatedSubcool - this->TIntercooler);
   13302            0 :                         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - this->TLiqInActual);
   13303              :                     } // IntercoolerType
   13304            0 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13305            0 :                     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            0 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13310            0 :                 NumComps = this->NumCompressors;
   13311              :             } // NumStages
   13312              :         } else { // Two-stage system, high-stage side
   13313            0 :             NeededCapacity = NeededCapacity_base + this->TotCompPower;
   13314            0 :             TsatforPdisch = this->TCondense + DelTDischPipes;
   13315            0 :             TsatforPsuct = this->TIntercooler;
   13316            0 :             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            0 :             this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13325            0 :             this->TCompIn = this->TIntercooler;
   13326              :             //      System(SysNum)%TLiqInActual = System(SysNum)%TCondense-Condenser(System(SysNum)%CondenserNum(1))%RatedSubcool
   13327            0 :             this->HCompIn = HsatVaporforTevapneeded;
   13328            0 :             PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13329            0 :             NumComps = this->NumHiStageCompressors;
   13330              :         } // StageIndex
   13331              : 
   13332              :         // dispatch compressors to meet load, note they were listed in compressor list in dispatch order
   13333            0 :         DensityActual = this->refrig->getSupHeatDensity(state, this->TCompIn, PSuction, RoutineName); // Autodesk:Tuned Hoisted out of CompIndex loop
   13334            0 :         TotalEnthalpyChangeActual = this->HCompIn - this->HCaseIn;                                    // Autodesk:Tuned Hoisted out of CompIndex loop
   13335            0 :         if (this->NumStages == 2) {                                                                   // Autodesk:Tuned Hoisted out of CompIndex loop
   13336            0 :             if (StageIndex == 1) {
   13337            0 :                 HCaseInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13338            0 :             } else if (StageIndex == 2) {
   13339            0 :                 HCompInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   13340              :             }
   13341              :         }
   13342            0 :         for (int CompIndex = 1; CompIndex <= NumComps; ++CompIndex) {
   13343              :             int CompID;
   13344            0 :             if (StageIndex == 1) {
   13345            0 :                 CompID = this->CompressorNum(CompIndex);
   13346              :             } else {
   13347            0 :                 CompID = this->HiStageCompressorNum(CompIndex);
   13348              :             } // StageIndex
   13349            0 :             auto &compressor = Compressor(CompID);
   13350              : 
   13351              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13352            0 :             switch (compressor.SubcoolRatingType) {
   13353            0 :             case CompRatingType::Subcooling: {
   13354            0 :                 if (this->NumStages == 1) { // Single-stage system
   13355            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13356            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13357            0 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * compressor.RatedSubcool;
   13358            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13359            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13360              :                 } // NumStages
   13361            0 :             } break;
   13362            0 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13363            0 :                 if (this->NumStages == 1) {           // Single-stage system
   13364            0 :                     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            0 :             } break;
   13371            0 :             default:
   13372            0 :                 break;
   13373              :             } // Compressor SubcoolRatingType
   13374            0 :             switch (compressor.SuperheatRatingType) {
   13375            0 :             case CompRatingType::Superheat: {
   13376            0 :                 if (this->NumStages == 1) { // Single-stage system
   13377            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13378            0 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   13379            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13380            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13381            0 :                     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            0 :             } break;
   13387            0 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13388            0 :                 if (this->NumStages == 1) {              // Single-stage system
   13389            0 :                     TempInRated = compressor.RatedSuperheat;
   13390            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   13391            0 :                 } 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            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13395            0 :                     TempInRated = compressor.RatedSuperheat;
   13396            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TIntercooler);
   13397              :                 } // NumStages
   13398            0 :             } break;
   13399            0 :             default:
   13400            0 :                 break;
   13401              :             } // Compressor SuperheatRatingType
   13402              : 
   13403            0 :             CaseEnthalpyChangeRated = HCompInRated - HCaseInRated;
   13404            0 :             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            0 :             MassCorrection = DensityActual / DensityRated;
   13408            0 :             CapacityCorrection = MassCorrection * TotalEnthalpyChangeActual / CaseEnthalpyChangeRated;
   13409            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsuct, TsatforPdisch);
   13410            0 :             compressor.Capacity = CapacityCorrection * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsuct, TsatforPdisch);
   13411            0 :             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            0 :             if (StageIndex == 1) { // Single-stage or low-stage compressors
   13416            0 :                 if ((this->TotCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13417            0 :                     LFLastComp = (NeededCapacity - this->TotCompCapacity) / compressor.Capacity;
   13418            0 :                     compressor.Power *= LFLastComp;
   13419            0 :                     compressor.MassFlow *= LFLastComp;
   13420            0 :                     compressor.Capacity *= LFLastComp;
   13421            0 :                     this->TotCompCapacity += compressor.Capacity;
   13422            0 :                     this->RefMassFlowComps += compressor.MassFlow;
   13423            0 :                     this->TotCompPower += compressor.Power;
   13424            0 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13425            0 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13426            0 :                     compressor.LoadFactor = LFLastComp;
   13427            0 :                     break; // numcomps do
   13428              :                 } else {   //>= needed capacity
   13429            0 :                     this->TotCompCapacity += compressor.Capacity;
   13430            0 :                     this->RefMassFlowComps += compressor.MassFlow;
   13431            0 :                     this->TotCompPower += compressor.Power;
   13432              :                 } //>= needed capacity
   13433              :             } else { // high-stage compressors (for two-stage systems only)
   13434            0 :                 if ((this->TotHiStageCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13435            0 :                     LFLastComp = (NeededCapacity - this->TotHiStageCompCapacity) / compressor.Capacity;
   13436            0 :                     compressor.Power *= LFLastComp;
   13437            0 :                     compressor.MassFlow *= LFLastComp;
   13438            0 :                     compressor.Capacity *= LFLastComp;
   13439            0 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13440            0 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13441            0 :                     this->TotHiStageCompPower += compressor.Power;
   13442            0 :                     this->FlowRatioIntercooler = this->RefMassFlowComps / this->RefMassFlowHiStageComps;
   13443            0 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13444            0 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13445            0 :                     compressor.LoadFactor = LFLastComp;
   13446            0 :                     break; // numcomps do
   13447              :                 } else {   //>= needed capacity
   13448            0 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13449            0 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13450            0 :                     this->TotHiStageCompPower += compressor.Power;
   13451              :                 } //>= needed capacity
   13452              :             } // StageIndex
   13453            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13454            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13455            0 :             compressor.LoadFactor = 1.0;
   13456              :         } // NumComps
   13457              :     }
   13458              : 
   13459              :     // Calculate enthalpy at compressor discharge
   13460            0 :     if (this->NumStages == 1) { // Single-stage or low-stage compressors
   13461            0 :         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            0 :         HHiStageCompIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   13465            0 :         this->HCompOut = HHiStageCompIn + this->TotHiStageCompPower / this->RefMassFlowHiStageComps;
   13466              :     }
   13467              : 
   13468              :     // Calculate superheat energy available for desuperheaters
   13469            0 :     HSatVapCondense = this->refrig->getSatEnthalpy(state, this->TCondense, 1.0, RoutineName);
   13470            0 :     CpSatVapCondense = this->refrig->getSatSpecificHeat(state, this->TCondense, 1.0, RoutineName);
   13471            0 :     if (this->NumStages == 1) { // Single-stage systems
   13472            0 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowComps * (this->HCompOut - HSatVapCondense);
   13473              :     } else { // Two-stage systems
   13474            0 :         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            0 :     TCompOutEstimate = this->TCondense + (this->HCompOut - HSatVapCondense) / CpSatVapCondense;
   13480              : 
   13481            0 :     state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailTemperature = (TsatforPdisch + TCompOutEstimate) / 2.0;
   13482            0 :     this->AverageCompressorCOP = this->TotCompCapacity / (this->TotCompPower + this->TotHiStageCompPower);
   13483            0 :     this->TotCompElecConsump = this->TotCompPower * localTimeStepSec;
   13484            0 :     if (this->NumStages == 2) {
   13485            0 :         this->TotHiStageCompElecConsump = this->TotHiStageCompPower * localTimeStepSec;
   13486            0 :         this->TotCompElecConsumpTwoStage = this->TotCompElecConsump + this->TotHiStageCompElecConsump;
   13487              :     }
   13488            0 :     this->TotCompCoolingEnergy = this->TotCompCapacity * localTimeStepSec;
   13489            0 :     this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * localTimeStepSec;
   13490            0 : }
   13491              : 
   13492            0 : 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            0 :     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            0 :     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            0 :     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            0 :     Real64 Xnew(0.0);                   // New guess for iterative search
   13576              : 
   13577            0 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13578            0 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13579              : 
   13580            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13581            0 :     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            0 :     NeededCapacityLT = 0.0;
   13587            0 :     if (this->transSysType == TransSysType::TwoStage) {
   13588            0 :         AccumLoadLT = max(0.0, (this->UnmetEnergyLT / localTimeStep / Constant::rSecsInHour)); // localTimeStep / rSecsInHour?
   13589            0 :         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            0 :     Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / localTimeStep / Constant::rSecsInHour));
   13594            0 :     NeededCapacityMT = this->TotalSystemLoadMT + AccumLoadMT + this->PipeHeatLoadMT;
   13595              : 
   13596              :     // Determine refrigerant properties at receiver
   13597            0 :     this->CpSatLiqReceiver = this->refrig->getSatSpecificHeat(state, this->TReceiver, 0.0, RoutineName);
   13598              : 
   13599              :     // Enthalpy at the receiver bypass, J/kg
   13600            0 :     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            0 :     if (this->transSysType == TransSysType::TwoStage) { // LT side of TwoStage transcritical system
   13605            0 :         this->HCaseInLT = this->HSatLiqReceiver;
   13606              :         // TCompInLP and HCompInLP include case superheat plus effect of suction line heat gain
   13607            0 :         this->TCompInLP = this->TEvapNeededLT + TransCaseSuperheat + this->PipeHeatLoadLT / (this->CpSatVapEvapLT * this->RefMassFlowtoLTLoads);
   13608            0 :         this->HCompInLP = this->HCaseOutLT + this->PipeHeatLoadLT / this->RefMassFlowtoLTLoads;
   13609            0 :         TsatforPsucLT = this->TEvapNeededLT;
   13610            0 :         TsatforPdisLT = this->TEvapNeededMT;
   13611            0 :         HsatVaporforTevapneededLT = this->refrig->getSatEnthalpy(state, this->TEvapNeededLT, 1.0, RoutineName);
   13612            0 :         HsatLiqforTevapNeededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 0.0, RoutineName);
   13613            0 :         PSuctionLT = this->refrig->getSatPressure(state, TsatforPsucLT, RoutineName);
   13614            0 :         DensityActualLT = this->refrig->getSupHeatDensity(state, this->TCompInLP, PSuctionLT, RoutineName);
   13615            0 :         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            0 :         this->TotCompCapacityLP = 0.0;
   13620            0 :         this->RefMassFlowCompsLP = 0.0;
   13621            0 :         this->TotCompPowerLP = 0.0;
   13622              : 
   13623            0 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13624            0 :             int CompID = this->CompressorNumLP(CompIndex);
   13625            0 :             Compressor(CompID).Power = 0.0;
   13626            0 :             Compressor(CompID).MassFlow = 0.0;
   13627            0 :             Compressor(CompID).Capacity = 0.0;
   13628            0 :             Compressor(CompID).ElecConsumption = 0.0;
   13629            0 :             Compressor(CompID).CoolingEnergy = 0.0;
   13630            0 :             Compressor(CompID).LoadFactor = 0.0;
   13631              :         }
   13632              : 
   13633            0 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13634            0 :             int CompID = this->CompressorNumLP(CompIndex);
   13635            0 :             auto &compressor = Compressor(CompID);
   13636              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13637            0 :             switch (compressor.SubcoolRatingType) {
   13638            0 :             case CompRatingType::Subcooling: {
   13639            0 :                 HCaseInRatedLT = HsatLiqforTevapNeededMT - this->CpSatLiqReceiver * compressor.RatedSubcool;
   13640            0 :             } 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            0 :             switch (compressor.SuperheatRatingType) {
   13648            0 :             case CompRatingType::Superheat: {
   13649            0 :                 HCompInRatedLP = HsatVaporforTevapneededLT + this->CpSatVapEvapLT * compressor.RatedSuperheat;
   13650            0 :                 TempInRatedLP = this->TEvapNeededLT + compressor.RatedSuperheat;
   13651            0 :             } 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            0 :             CaseEnthalpyChangeRatedLT = HCompInRatedLP - HCaseInRatedLT;
   13662            0 :             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            0 :             MassCorrectionLT = DensityActualLT / DensityRatedLP;
   13667              :             // Capacity at existing subcool/superheat over cap at rated conditions for LT loads
   13668            0 :             Real64 CapacityCorrectionLT = MassCorrectionLT * TotalEnthalpyChangeActualLT / CaseEnthalpyChangeRatedLT;
   13669            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13670            0 :             compressor.Capacity = CapacityCorrectionLT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13671            0 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActualLT;
   13672            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13673            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13674            0 :             compressor.LoadFactor = 1.0;
   13675            0 :             if ((this->TotCompCapacityLP + compressor.Capacity) >= NeededCapacityLT) {
   13676            0 :                 LFLastComp = (NeededCapacityLT - this->TotCompCapacityLP) / compressor.Capacity;
   13677            0 :                 compressor.Power *= LFLastComp;
   13678            0 :                 compressor.MassFlow *= LFLastComp;
   13679            0 :                 compressor.Capacity *= LFLastComp;
   13680            0 :                 this->TotCompCapacityLP += compressor.Capacity;
   13681            0 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13682            0 :                 this->TotCompPowerLP += compressor.Power;
   13683            0 :                 compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13684            0 :                 compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13685            0 :                 compressor.LoadFactor = LFLastComp;
   13686            0 :                 break;
   13687              :             } else {
   13688            0 :                 this->TotCompCapacityLP += compressor.Capacity;
   13689            0 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13690            0 :                 this->TotCompPowerLP += compressor.Power;
   13691              :             }
   13692              :         } // NumCompressorsLP
   13693            0 :         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            0 :     TsatforPsucMT = this->TEvapNeededMT;
   13699            0 :     if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Transcritical system is operating in transcritical region
   13700            0 :         HGCOutlet = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13701              :     } else { // Transcritical system is operating in subcritical region
   13702            0 :         TsatforPdisMT = GasCooler(this->GasCoolerNum(1)).TGasCoolerOut;
   13703              :     }
   13704            0 :     PSuctionMT = this->refrig->getSatPressure(state, TsatforPsucMT, RoutineName);
   13705            0 :     PGCOutlet = GasCooler(this->GasCoolerNum(1)).PGasCoolerOut;
   13706            0 :     HsatVaporforTevapneededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 1.0, RoutineName);
   13707            0 :     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            0 :     Real64 HCaseOutLTMT = (this->RefMassFlowtoLTLoads * this->HCompOutLP + this->RefMassFlowtoMTLoads * this->HCaseOutMT + this->PipeHeatLoadMT) /
   13712            0 :                           (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            0 :     Xu = 1.0; // upper bound on quality
   13718            0 :     Xl = 0.0; // lower bound on quality
   13719            0 :     if ((GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis) > this->HSatLiqReceiver) {
   13720            0 :         for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations to find receiver quality
   13721            0 :             QualityReceiver = (Xu + Xl) / 2.0;
   13722            0 :             Real64 Hnew = this->refrig->getSatEnthalpy(state, this->TReceiver, QualityReceiver, RoutineName);
   13723              : 
   13724              :             // estimated QualityReceiver is too high
   13725            0 :             if (Hnew > (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) {
   13726            0 :                 Xu = QualityReceiver;
   13727              :             } else { // estimated QualityReceiver is too low
   13728            0 :                 Xl = QualityReceiver;
   13729              :             }
   13730            0 :             if (std::abs((Hnew - (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) / Hnew) < ErrorTol) {
   13731            0 :                 break;
   13732              :             }
   13733              :         }
   13734            0 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) / (1.0 - QualityReceiver);
   13735            0 :         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            0 :     this->HCompInHP = (HCaseOutLTMT * (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) + HReceiverBypass * this->RefMassFlowReceiverBypass) /
   13742            0 :                       (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads + this->RefMassFlowReceiverBypass);
   13743              : 
   13744              :     // Iterate to find the suction temperature entering subcooler
   13745            0 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13746            0 :     Xu = Xl + 50.0;
   13747            0 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13748            0 :         Xnew = (Xu + Xl) / 2.0;
   13749            0 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13750            0 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13751            0 :             Xu = Xnew;
   13752              :         } else { // xnew is too low
   13753            0 :             Xl = Xnew;
   13754              :         }
   13755            0 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) {
   13756            0 :             break;
   13757              :         }
   13758              :     }
   13759            0 :     TSubcoolerColdIn = Xnew;
   13760              : 
   13761              :     // Modify receiver inlet enthalpy and HP compressor inlet enthalpy to account for subcooler
   13762            0 :     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            0 :     if (TSubcoolerColdIn < GasCooler(this->GasCoolerNum(1)).TGasCoolerOut) {
   13765            0 :         SubcoolEffect = this->SCEffectiveness;
   13766              :     } else {
   13767            0 :         SubcoolEffect = 0.0;
   13768              :     } // (TSubcoolerColdIn < GasCooler(SysNum)%TGasCoolerOut)
   13769            0 :     this->DelHSubcoolerSuc = SubcoolEffect * (HIdeal - this->HCompInHP);
   13770            0 :     this->HCompInHP += this->DelHSubcoolerSuc;
   13771            0 :     this->DelHSubcoolerDis = -this->DelHSubcoolerSuc;
   13772              : 
   13773              :     // Iterate to find the temperature at the inlet of the high pressure (HP) compressors
   13774            0 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13775            0 :     Xu = Xl + 50.0;
   13776            0 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13777            0 :         Xnew = (Xu + Xl) / 2.0;
   13778            0 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13779            0 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13780            0 :             Xu = Xnew;
   13781              :         } else { // xnew is too low
   13782            0 :             Xl = Xnew;
   13783              :         }
   13784            0 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) {
   13785            0 :             break;
   13786              :         }
   13787              :     }
   13788            0 :     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            0 :     DensityActualMT = this->refrig->getSupHeatDensity(state, this->TCompInHP, PSuctionMT, RoutineName);
   13794            0 :     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            0 :     this->TotCompCapacityHP = 0.0;
   13799            0 :     this->RefMassFlowCompsHP = 0.0;
   13800            0 :     this->TotCompPowerHP = 0.0;
   13801              : 
   13802            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13803            0 :         int CompID = this->CompressorNumHP(CompIndex);
   13804            0 :         auto &compressor = Compressor(CompID);
   13805            0 :         compressor.Power = 0.0;
   13806            0 :         compressor.MassFlow = 0.0;
   13807            0 :         compressor.Capacity = 0.0;
   13808            0 :         compressor.ElecConsumption = 0.0;
   13809            0 :         compressor.CoolingEnergy = 0.0;
   13810            0 :         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            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13815            0 :         int CompID = this->CompressorNumHP(CompIndex);
   13816            0 :         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            0 :         switch (compressor.SubcoolRatingType) {
   13821            0 :         case CompRatingType::Subcooling: {
   13822            0 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13823            0 :                 HCaseInRatedMT =
   13824            0 :                     GasCooler(this->GasCoolerNum(1)).HGasCoolerOut - GasCooler(this->GasCoolerNum(1)).CpGasCoolerOut * compressor.RatedSubcool;
   13825              :             } else { // Transcritical operation
   13826            0 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13827              :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13828            0 :         } 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            0 :         switch (compressor.SuperheatRatingType) {
   13840            0 :         case CompRatingType::Superheat: {
   13841            0 :             HCompInRatedHP = HsatVaporforTevapneededMT + this->CpSatVapEvapMT * compressor.RatedSuperheat;
   13842            0 :             TempInRatedHP = this->TEvapNeededMT + compressor.RatedSuperheat;
   13843            0 :         } 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            0 :         CaseEnthalpyChangeRatedMT = HCompInRatedHP - HCaseInRatedMT;
   13853            0 :         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            0 :         MassCorrectionMT = DensityActualMT / DensityRatedHP;
   13857            0 :         CapacityCorrectionMT = MassCorrectionMT * TotalEnthalpyChangeActualMT / CaseEnthalpyChangeRatedMT;
   13858              : 
   13859            0 :         if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // System is operating in transcritical region
   13860            0 :             compressor.Power = Curve::CurveValue(state, compressor.TransElecPowerCurvePtr, TsatforPsucMT, PGCOutlet);
   13861            0 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.TransCapacityCurvePtr, TsatforPsucMT, HGCOutlet);
   13862              :         } else { // System is operating in subcritical region
   13863            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucMT, TsatforPdisMT);
   13864            0 :             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            0 :         compressor.MassFlow = TotalRefMassFlow * compressor.Capacity / (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP);
   13868            0 :         compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13869            0 :         compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13870            0 :         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            0 :         if ((this->TotCompCapacityHP + compressor.Capacity) >= (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP)) {
   13874            0 :             LFLastComp = ((NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP) - this->TotCompCapacityHP) / compressor.Capacity;
   13875            0 :             compressor.Power *= LFLastComp;
   13876            0 :             compressor.MassFlow *= LFLastComp;
   13877            0 :             compressor.Capacity *= LFLastComp;
   13878            0 :             this->TotCompCapacityHP += compressor.Capacity;
   13879            0 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13880            0 :             this->TotCompPowerHP += compressor.Power;
   13881            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13882            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13883            0 :             compressor.LoadFactor = LFLastComp;
   13884            0 :             break;
   13885              :         } else {
   13886            0 :             this->TotCompCapacityHP += compressor.Capacity;
   13887            0 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13888            0 :             this->TotCompPowerHP += compressor.Power;
   13889              :         }
   13890              : 
   13891              :     } // NumCompressorsHP
   13892              : 
   13893            0 :     this->HCompOutHP = this->HCompInHP + this->TotCompPowerHP / this->RefMassFlowCompsHP;
   13894            0 :     this->RefMassFlowComps = this->RefMassFlowCompsLP + this->RefMassFlowCompsHP;
   13895            0 :     this->TotCompCapacity = this->TotCompCapacityHP + this->TotCompCapacityLP;
   13896            0 :     this->AverageCompressorCOP = (this->TotCompCapacityHP - this->TotCompPowerLP) / (this->TotCompPowerLP + this->TotCompPowerHP);
   13897            0 :     this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * localTimeStepSec;
   13898            0 :     this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * localTimeStepSec;
   13899            0 : }
   13900              : 
   13901            0 : 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            0 :     Real64 TLiqInActualLocal = 0.0; // Liquid T in, after condenser, before any mechanical subcooler
   13923              : 
   13924            0 :     auto &System = state.dataRefrigCase->System;
   13925            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13926            0 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   13927              : 
   13928            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13929            0 :     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            0 :     if (this->NumStages == 1) { // Single-stage compression system
   13934            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13935            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13936            0 :         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            0 :     for (int SubcoolerIndex = 1; SubcoolerIndex <= this->NumSubcoolers; ++SubcoolerIndex) {
   13954            0 :         int SubcoolerID = this->SubcoolerNum(SubcoolerIndex);
   13955            0 :         auto &cooler = Subcooler(SubcoolerID);
   13956              :         // set up local variables for convenience
   13957            0 :         Real64 DelTLiqDes = cooler.LiqSuctDesignDelT;
   13958            0 :         Real64 TVapInDes = cooler.LiqSuctDesignTvapIn;
   13959            0 :         Real64 TLiqInDes = cooler.LiqSuctDesignTliqIn;
   13960            0 :         Real64 ControlTLiqOut = cooler.MechControlTliqOut;
   13961            0 :         Real64 CpLiquid = this->CpSatLiqCond;
   13962            0 :         Real64 CpVapor = this->CpSatVapEvap;
   13963            0 :         if (this->NumStages == 1) { // Single-stage compression system
   13964            0 :             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            0 :         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            0 :         case SubcoolerType::Mechanical: {
   13981            0 :             Real64 mechSCLoad = this->RefMassFlowtoLoads * CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13982            0 :             this->HCaseIn -= CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13983              :             // refrigeration benefit to System(sysnum)
   13984              :             // refrigeration load must be assigned properly according to input
   13985            0 :             int SysProvideID = cooler.MechSourceSysID;
   13986            0 :             System(SysProvideID).MechSCLoad(SubcoolerID) = mechSCLoad;
   13987            0 :             cooler.MechSCTransLoad = mechSCLoad;
   13988            0 :             cooler.MechSCTransEnergy = mechSCLoad * localTimeStepSec;
   13989              :             // Reset inlet temperature for any LSHX that follows this mech subcooler
   13990            0 :             TLiqInActualLocal = ControlTLiqOut;
   13991            0 :             this->TCompIn = this->TEvapNeeded + CaseSuperheat;
   13992            0 :         } break;
   13993            0 :         case SubcoolerType::LiquidSuction: {
   13994            0 :             Real64 LSHXeffectiveness = DelTLiqDes / (TLiqInDes - TVapInDes);
   13995            0 :             Real64 TVapInActual = this->TEvapNeeded + CaseSuperheat;
   13996            0 :             Real64 DelTempActual = LSHXeffectiveness * (TLiqInActualLocal - TVapInActual);
   13997            0 :             TLiqInActualLocal -= DelTempActual;
   13998            0 :             Real64 SubcoolLoad = this->RefMassFlowtoLoads * CpLiquid * DelTempActual;
   13999            0 :             Real64 SubcoolerSupHeat = SubcoolLoad / CpVapor / this->RefMassFlowComps;
   14000            0 :             this->TCompIn = TVapInActual + SubcoolerSupHeat;
   14001            0 :             this->HCaseIn -= SubcoolLoad / this->RefMassFlowtoLoads;
   14002            0 :             this->LSHXTrans = SubcoolLoad;
   14003            0 :             this->LSHXTransEnergy = SubcoolLoad * localTimeStepSec;
   14004            0 :         } break;
   14005            0 :         default:
   14006            0 :             break;
   14007              :         }
   14008              : 
   14009            0 :         this->TLiqInActual = TLiqInActualLocal;
   14010              :     }
   14011            0 : }
   14012              : 
   14013            1 : 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            1 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14032            1 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14033              : 
   14034            1 :     CheckRefrigerationInput(state);
   14035              : 
   14036            1 :     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            0 :     case DataHeatBalance::RefrigSystemType::Detailed: {
   14057            0 :         IndexPtr = Util::FindItemInList(Name, Condenser);
   14058            0 :         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            0 :         ErrorsFound = true;
   14070            0 :     } break;
   14071            0 :     default:
   14072            0 :         break;
   14073              :     }
   14074            1 : }
   14075              : 
   14076          150 : 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          150 :     std::string ChrOut;
   14091          150 :     std::string ChrOut2;
   14092              : 
   14093          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   14094          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14095          150 :     auto &System = state.dataRefrigCase->System;
   14096          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   14097          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14098          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
   14099          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   14100          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   14101          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
   14102          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   14103          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   14104          150 :     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          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14177            5 :         print(state.files.eio, "{}\n", Format_109); // Intro to refrigeration case racks
   14178            5 :         print(state.files.eio, "{}\n", Format_104); // Refrigeration Rack header
   14179              :     } //(NumRefrigeratedRacks > 0)
   14180          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14181            0 :         print(state.files.eio, "{}\n", Format_117); // Intro to detailed systems
   14182            0 :         print(state.files.eio, "{}\n", Format_118); // Detailed system header
   14183            0 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   14184              :     } //(NumRefrigSystems > 0)
   14185          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14186            0 :         print(state.files.eio, "{}\n", Format_142); // Intro to Secondary systems
   14187            0 :         int CountSecPhase = 0;
   14188            0 :         int CountSecBrine = 0;
   14189            0 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14190            0 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::AlwaysLiquid) && (CountSecBrine == 0)) {
   14191            0 :                 print(state.files.eio, "{}\n", Format_133); // Secondary system header for brine type systems
   14192            0 :                 ++CountSecBrine;
   14193              :             }
   14194            0 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::PhaseChange) && (CountSecPhase == 0)) {
   14195            0 :                 print(state.files.eio, "{}\n", Format_146); // Secondary system header for liquid overfeed/phase change systems
   14196            0 :                 ++CountSecPhase;
   14197              :             }
   14198              :         }
   14199            0 :         print(state.files.eio, "{}\n", Format_123); //  Secondary system load header
   14200              :     } //(NumSimulationSecondarySystems > 0)
   14201          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14202            0 :         print(state.files.eio, "{}\n", Format_148); // Intro to Chiller set
   14203            0 :         print(state.files.eio, "{}\n", Format_149); // Chiller set header
   14204            0 :         print(state.files.eio, "{}\n", Format_151); // Intro to Air Chiller
   14205            0 :         print(state.files.eio, "{}\n", Format_152); // Air chiller header
   14206              :     } //(NumRefrigSystems > 0)
   14207          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   14208            3 :         print(state.files.eio, "{}\n", Format_105); //  Case header
   14209              :     } //(NumSimulationCases > 0)
   14210          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14211            3 :         print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14212            3 :         print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14213              :     } //(NumSimulationWalkIns > 0)
   14214          150 :     if (state.dataRefrigCase->NumSimulationCondAir > 0) {
   14215            0 :         print(state.files.eio, "{}\n", Format_129); //  Condenser, Air-Cooled header
   14216              :     } //(NumSimulationCondAir > 0)
   14217          150 :     if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
   14218            0 :         print(state.files.eio, "{}\n", Format_131); //  Condenser, Evaporative-Cooled header
   14219              :     } //(NumSimulationCondEvap > 0)
   14220          150 :     if (state.dataRefrigCase->NumSimulationCondWater > 0) {
   14221            0 :         print(state.files.eio, "{}\n", Format_130); //  Condenser, Water-Cooled header
   14222              :     } //(NumSimulationCondWater > 0)
   14223          150 :     if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
   14224            0 :         print(state.files.eio, "{}\n", Format_132); //  Condenser, Cascade header
   14225            0 :         print(state.files.eio, "{}\n", Format_128); //  Cascade Load header
   14226              :     } //(NumSimulationCascadeCondensers > 0)
   14227          150 :     if (state.dataRefrigCase->NumSimulationMechSubcoolers > 0) {
   14228            0 :         print(state.files.eio, "{}\n", Format_141); //  Mech subcooler loads served header
   14229            0 :         print(state.files.eio, "{}\n", Format_126); //  Mechanical Subcooler header
   14230              :     } //(NumSimulationMechSubcoolers > 0)
   14231          150 :     if ((state.dataRefrigCase->NumSimulationSubcoolers - state.dataRefrigCase->NumSimulationMechSubcoolers) > 0) {
   14232            0 :         print(state.files.eio, "{}\n", Format_127); //  LSHX Subcooler header
   14233              :     } //((NumSimulationSubcoolers - NumSimulationMechSubcoolers) > 0)
   14234              : 
   14235          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14236            0 :         print(state.files.eio, "{}\n", Format_120); // Intro to detailed transcritical refrigeration system
   14237            0 :         print(state.files.eio, "{}\n", Format_121); // Detailed system header
   14238            0 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   14239            0 :             print(state.files.eio, "{}\n", Format_105); //  Case header
   14240              :         } //(NumSimulationCases > 0)
   14241            0 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14242            0 :             print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14243            0 :             print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14244              :         } //(NumSimulationWalkIns > 0)
   14245            0 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   14246            0 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   14247            0 :             print(state.files.eio, "{}\n", Format_160); //  Gas Cooler, Air-Cooled header
   14248              :         } //(NumSimulationGasCooler > 0)
   14249              :     } //(NumTransRefrigSystems > 0)
   14250              : 
   14251          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14252            5 :         print(state.files.eio, "#Refrigeration Compressor Racks, {}\n", state.dataRefrigCase->NumRefrigeratedRacks);
   14253           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   14254            5 :             if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Outdoors) {
   14255            1 :                 ChrOut = "Outdoors";
   14256              :             } else {
   14257            4 :                 ChrOut = "Zone";
   14258              :             }
   14259            5 :             switch (RefrigRack(RackNum).CondenserType) {
   14260            5 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14261            5 :                 ChrOut2 = "Air-Cooled";
   14262            5 :             } break;
   14263            0 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14264            0 :                 ChrOut2 = "Evap-Cooled";
   14265            0 :             } break;
   14266            0 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14267            0 :                 ChrOut2 = "Water-Cooled";
   14268            0 :             } break;
   14269            0 :             default:
   14270            0 :                 break;
   14271              :             }
   14272            5 :             print(state.files.eio,
   14273              :                   " Refrigeration Compressor Rack,{},{},{},{},{},{:.3R}\n",
   14274            5 :                   RefrigRack(RackNum).Name,
   14275            5 :                   RefrigRack(RackNum).NumCases,
   14276            5 :                   RefrigRack(RackNum).NumWalkIns,
   14277              :                   ChrOut,
   14278              :                   ChrOut2,
   14279            5 :                   RefrigRack(RackNum).RatedCOP);
   14280            8 :             for (int CaseNum = 1; CaseNum <= RefrigRack(RackNum).NumCases; ++CaseNum) {
   14281            3 :                 int CaseID = RefrigRack(RackNum).CaseNum(CaseNum);
   14282            3 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14283            3 :                     print(state.files.eio,
   14284              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14285              :                           CaseID,
   14286            3 :                           RefrigCase(CaseID).Name,
   14287            3 :                           RefrigCase(CaseID).ZoneName,
   14288            3 :                           RefrigCase(CaseID).ZoneNodeNum,
   14289            3 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14290            3 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14291            3 :                           RefrigCase(CaseID).RatedLHR,
   14292            3 :                           RefrigCase(CaseID).Temperature,
   14293            3 :                           RefrigCase(CaseID).Length,
   14294            3 :                           RefrigCase(CaseID).OperatingFanPower,
   14295            3 :                           RefrigCase(CaseID).LightingPower,
   14296            3 :                           RefrigCase(CaseID).AntiSweatPower,
   14297            3 :                           RefrigCase(CaseID).DefrostPower); // Installed lighting power, may not be rated power
   14298              :                 }
   14299              :             } // numcases
   14300              : 
   14301            8 :             for (int WalkInNum = 1; WalkInNum <= RefrigRack(RackNum).NumWalkIns; ++WalkInNum) {
   14302            3 :                 int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInNum);
   14303            3 :                 print(state.files.eio,
   14304              :                       "   Refrigeration Walk In Cooler,  {},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14305              :                       WalkInID,
   14306            3 :                       WalkIn(WalkInID).Name,
   14307            3 :                       WalkIn(WalkInID).DesignRatedCap,
   14308            3 :                       WalkIn(WalkInID).Temperature,
   14309            3 :                       WalkIn(WalkInID).CoilFanPower,
   14310            3 :                       WalkIn(WalkInID).CircFanPower,
   14311            3 :                       WalkIn(WalkInID).ElecFanPower,
   14312            3 :                       WalkIn(WalkInID).DesignLighting,
   14313            3 :                       WalkIn(WalkInID).HeaterPower,
   14314            3 :                       WalkIn(WalkInID).DefrostCapacity,
   14315            3 :                       WalkIn(WalkInID).NumZones);
   14316            6 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14317            3 :                     print(state.files.eio,
   14318              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14319            3 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14320            3 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14321            3 :                           WalkIn(WalkInID).UValue(ZoneID),
   14322            3 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14323            3 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14324            3 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14325            3 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14326            3 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14327            3 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14328              :                 } // zones for walk ins on rack
   14329              :             } // walk ins on rack
   14330              : 
   14331            5 :             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          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14339            0 :         print(state.files.eio, "#Detailed Refrigeration Systems,{}\n", state.dataRefrigCase->NumRefrigSystems);
   14340            0 :         for (int SystemNum = 1; SystemNum <= state.dataRefrigCase->NumRefrigSystems; ++SystemNum) {
   14341            0 :             print(state.files.eio,
   14342              :                   " Detailed Refrigeration System,{},{},{},{},{},{},{},{},{},{},{},{:.2R},{},{:.1R}\n",
   14343            0 :                   System(SystemNum).Name,
   14344            0 :                   System(SystemNum).RefrigerantName,
   14345            0 :                   System(SystemNum).NumCases,
   14346            0 :                   System(SystemNum).NumWalkIns,
   14347            0 :                   System(SystemNum).NumCoils,
   14348            0 :                   System(SystemNum).NumSecondarys,
   14349            0 :                   System(SystemNum).NumCascadeLoads,
   14350            0 :                   System(SystemNum).NumMechSCServed,
   14351            0 :                   System(SystemNum).NumCompressors + System(SystemNum).NumHiStageCompressors,
   14352            0 :                   System(SystemNum).NumStages,
   14353            0 :                   System(SystemNum).intercoolerType,
   14354            0 :                   System(SystemNum).IntercoolerEffectiveness,
   14355            0 :                   System(SystemNum).NumSubcoolers,
   14356            0 :                   System(SystemNum).TCondenseMin);
   14357              : 
   14358            0 :             for (int CaseNum = 1; CaseNum <= System(SystemNum).NumCases; ++CaseNum) {
   14359            0 :                 int CaseID = System(SystemNum).CaseNum(CaseNum);
   14360            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14361            0 :                     print(state.files.eio,
   14362              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14363              :                           CaseID,
   14364            0 :                           RefrigCase(CaseID).Name,
   14365            0 :                           RefrigCase(CaseID).ZoneName,
   14366            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14367            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14368            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14369            0 :                           RefrigCase(CaseID).RatedLHR,
   14370            0 :                           RefrigCase(CaseID).Temperature,
   14371            0 :                           RefrigCase(CaseID).Length,
   14372            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14373            0 :                           RefrigCase(CaseID).LightingPower,
   14374            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14375            0 :                           RefrigCase(CaseID).DefrostPower);
   14376              :                 }
   14377              :             } // NumCases on system
   14378            0 :             for (int WalkInNum = 1; WalkInNum <= System(SystemNum).NumWalkIns; ++WalkInNum) {
   14379            0 :                 int WalkInID = System(SystemNum).WalkInNum(WalkInNum);
   14380            0 :                 print(state.files.eio,
   14381              :                       "   Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14382              :                       WalkInID,
   14383            0 :                       WalkIn(WalkInID).Name,
   14384            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14385            0 :                       WalkIn(WalkInID).Temperature,
   14386            0 :                       WalkIn(WalkInID).CoilFanPower,
   14387            0 :                       WalkIn(WalkInID).CircFanPower,
   14388            0 :                       WalkIn(WalkInID).DesignLighting,
   14389            0 :                       WalkIn(WalkInID).HeaterPower,
   14390            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14391            0 :                       WalkIn(WalkInID).NumZones);
   14392            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14393            0 :                     print(state.files.eio,
   14394              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14395            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14396            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14397            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14398            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14399            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14400            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14401            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14402            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14403            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14404              :                 } // Num zones for each walk in on system
   14405              :             } // NumWalkIns on system
   14406              : 
   14407            0 :             for (int CoilNum = 1; CoilNum <= System(SystemNum).NumCoils; ++CoilNum) {
   14408            0 :                 int CoilID = System(SystemNum).CoilNum(CoilNum);
   14409            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14410              :             } // numairchillers
   14411              : 
   14412            0 :             for (int CascadeLoadNum = 1; CascadeLoadNum <= System(SystemNum).NumCascadeLoads; ++CascadeLoadNum) {
   14413            0 :                 int CascadeLoadID = System(SystemNum).CascadeLoadNum(CascadeLoadNum);
   14414            0 :                 print(state.files.eio,
   14415              :                       "   Cascade Load,{},{},{}\n",
   14416            0 :                       System(Condenser(CascadeLoadID).CascadeSysID).Name,
   14417              :                       CascadeLoadID,
   14418            0 :                       Condenser(CascadeLoadID).Name);
   14419              :             } // cascade load on detailed system
   14420              : 
   14421            0 :             for (int SecondaryNum = 1; SecondaryNum <= System(SystemNum).NumSecondarys; ++SecondaryNum) {
   14422            0 :                 int SecondaryID = System(SystemNum).SecondaryNum(SecondaryNum);
   14423            0 :                 print(state.files.eio, "   Secondary Load,{},{}\n", Secondary(SecondaryID).Name, SecondaryID);
   14424              :             } // secondary load on detailed system
   14425              : 
   14426            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
   14427            0 :                 if (Subcooler(SubcoolerNum).MechSourceSysID != SystemNum) {
   14428            0 :                     continue;
   14429              :                 }
   14430            0 :                 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            0 :             if (System(SystemNum).NumStages == 1) { // Single-stage compression system
   14434            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14435            0 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14436            0 :                     print(state.files.eio, "   Refrigeration Compressor,{},{},{:.0R}\n", CompID, Compressor(CompID).Name, Compressor(CompID).NomCap);
   14437              :                 } // NumCompressors
   14438            0 :             } else if (System(SystemNum).NumStages == 2) { // Two-stage compression system
   14439              :                 // Low-stage compressors
   14440            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14441            0 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14442            0 :                     print(state.files.eio,
   14443              :                           "   Refrigeration Low-Stage Compressor,{},{},{:.0R}\n",
   14444              :                           CompID,
   14445            0 :                           Compressor(CompID).Name,
   14446            0 :                           Compressor(CompID).NomCap);
   14447              :                 } // NumCompressors
   14448              :                 // High-stage compressors
   14449            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumHiStageCompressors; ++CompressorNum) {
   14450            0 :                     int CompID = System(SystemNum).HiStageCompressorNum(CompressorNum);
   14451            0 :                     print(state.files.eio,
   14452              :                           "   Refrigeration High-Stage Compressor,{},{},{:.0R}\n",
   14453              :                           CompID,
   14454            0 :                           Compressor(CompID).Name,
   14455            0 :                           Compressor(CompID).NomCap);
   14456              :                 } // NumHiStageCompressors
   14457              :             } // NumStages
   14458              : 
   14459            0 :             int CondID = System(SystemNum).CondenserNum(1);
   14460            0 :             switch (Condenser(CondID).CondenserType) {
   14461            0 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14462            0 :                 print(state.files.eio,
   14463              :                       "   Refrigeration Condenser:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R}\n",
   14464              :                       CondID,
   14465            0 :                       Condenser(CondID).Name,
   14466            0 :                       Condenser(CondID).RatedTCondense,
   14467            0 :                       Condenser(CondID).RatedCapacity,
   14468            0 :                       Condenser(CondID).RatedFanPower);
   14469            0 :             } break;
   14470            0 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14471            0 :                 print(state.files.eio,
   14472              :                       "   Refrigeration Condenser:Evaporative-Cooled,{},{},{:.1R},{:.1R}\n",
   14473              :                       CondID,
   14474            0 :                       Condenser(CondID).Name,
   14475            0 :                       Condenser(CondID).RatedCapacity,
   14476            0 :                       Condenser(CondID).RatedFanPower);
   14477            0 :             } break;
   14478            0 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14479            0 :                 print(state.files.eio,
   14480              :                       "   Refrigeration Condenser:Water-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14481              :                       CondID,
   14482            0 :                       Condenser(CondID).Name,
   14483            0 :                       Condenser(CondID).RatedTCondense,
   14484            0 :                       Condenser(CondID).RatedCapacity,
   14485            0 :                       Condenser(CondID).InletTemp,
   14486            0 :                       Condenser(CondID).DesVolFlowRate);
   14487            0 :             } break;
   14488            0 :             case DataHeatBalance::RefrigCondenserType::Cascade: {
   14489              : 
   14490            0 :                 switch (Condenser(CondID).CascadeTempControl) {
   14491            0 :                 case CascadeCndsrTempCtrlType::TempSet: {
   14492            0 :                     ChrOut = "Fixed";
   14493            0 :                 } break;
   14494            0 :                 case CascadeCndsrTempCtrlType::TempFloat: {
   14495            0 :                     ChrOut = "Floating";
   14496            0 :                 } break;
   14497            0 :                 default:
   14498            0 :                     break;
   14499              :                 } // cascade temperature control
   14500            0 :                 print(state.files.eio,
   14501              :                       "   Refrigeration Condenser:Cascade,{},{},{},{:.1R},{:.1R},{:.1R}\n",
   14502              :                       CondID,
   14503            0 :                       Condenser(CondID).Name,
   14504              :                       ChrOut,
   14505            0 :                       Condenser(CondID).RatedTCondense,
   14506            0 :                       Condenser(CondID).RatedCapacity,
   14507            0 :                       Condenser(CondID).RatedApproachT);
   14508            0 :             } break;
   14509            0 :             default:
   14510            0 :                 break;
   14511              :             } // condenser type
   14512              : 
   14513            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= System(SystemNum).NumSubcoolers; ++SubcoolerNum) {
   14514            0 :                 int SubcoolerID = System(SystemNum).SubcoolerNum(SubcoolerNum);
   14515            0 :                 switch (Subcooler(SubcoolerID).subcoolerType) {
   14516            0 :                 case SubcoolerType::LiquidSuction: {
   14517            0 :                     print(state.files.eio,
   14518              :                           "   Refrigeration Liquid Suction Subcooler,{},{},{:.1R},{:.1R},{:.1R}\n",
   14519              :                           SubcoolerID,
   14520            0 :                           Subcooler(SubcoolerID).Name,
   14521            0 :                           Subcooler(SubcoolerID).LiqSuctDesignDelT,
   14522            0 :                           Subcooler(SubcoolerID).LiqSuctDesignTliqIn,
   14523            0 :                           Subcooler(SubcoolerID).LiqSuctDesignTvapIn);
   14524            0 :                 } break;
   14525            0 :                 case SubcoolerType::Mechanical: {
   14526            0 :                     print(state.files.eio,
   14527              :                           "   Refrigeration Mechanical Subcooler,{},{},{},{:.1R}\n",
   14528              :                           SubcoolerID,
   14529            0 :                           Subcooler(SubcoolerID).Name,
   14530            0 :                           Subcooler(SubcoolerID).MechSourceSys,
   14531            0 :                           Subcooler(SubcoolerID).MechControlTliqOut);
   14532            0 :                 } break;
   14533            0 :                 default:
   14534            0 :                     break;
   14535              :                 }
   14536              :             } // NumSubcoolers
   14537              : 
   14538              :         } // NumRefrigSystems
   14539              :     } //(NumRefrigSystems > 0)
   14540              : 
   14541          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14542            0 :         print(state.files.eio, "#Detailed Transcritical Refrigeration Systems,{}\n", state.dataRefrigCase->NumTransRefrigSystems);
   14543            0 :         for (int TransSystemNum = 1; TransSystemNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransSystemNum) {
   14544            0 :             print(state.files.eio,
   14545              :                   " Detailed Transcritical Refrigeration System,{},{},{},{},{},{},{},{},{:.1R}\n",
   14546            0 :                   TransSystem(TransSystemNum).Name,
   14547            0 :                   TransSystem(TransSystemNum).RefrigerantName,
   14548            0 :                   TransSystem(TransSystemNum).NumCasesMT,
   14549            0 :                   TransSystem(TransSystemNum).NumCasesLT,
   14550            0 :                   TransSystem(TransSystemNum).NumWalkInsMT,
   14551            0 :                   TransSystem(TransSystemNum).NumWalkInsLT,
   14552            0 :                   TransSystem(TransSystemNum).NumCompressorsHP,
   14553            0 :                   TransSystem(TransSystemNum).NumCompressorsLP,
   14554            0 :                   GasCooler(TransSystem(TransSystemNum).GasCoolerNum(1)).MinCondTemp);
   14555              : 
   14556            0 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesMT; ++CaseNum) {
   14557            0 :                 int CaseID = TransSystem(TransSystemNum).CaseNumMT(CaseNum);
   14558            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14559            0 :                     print(state.files.eio,
   14560              :                           "   Medium Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14561              :                           CaseID,
   14562            0 :                           RefrigCase(CaseID).Name,
   14563            0 :                           RefrigCase(CaseID).ZoneName,
   14564            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14565            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14566            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14567            0 :                           RefrigCase(CaseID).RatedLHR,
   14568            0 :                           RefrigCase(CaseID).Temperature,
   14569            0 :                           RefrigCase(CaseID).Length,
   14570            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14571            0 :                           RefrigCase(CaseID).LightingPower,
   14572            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14573            0 :                           RefrigCase(CaseID).DefrostPower);
   14574              :                 }
   14575              :             } // NumCasesMT on system
   14576            0 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesLT; ++CaseNum) {
   14577            0 :                 int CaseID = TransSystem(TransSystemNum).CaseNumLT(CaseNum);
   14578            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14579            0 :                     print(state.files.eio,
   14580              :                           "   Low Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14581              :                           CaseID,
   14582            0 :                           RefrigCase(CaseID).Name,
   14583            0 :                           RefrigCase(CaseID).ZoneName,
   14584            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14585            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14586            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14587            0 :                           RefrigCase(CaseID).RatedLHR,
   14588            0 :                           RefrigCase(CaseID).Temperature,
   14589            0 :                           RefrigCase(CaseID).Length,
   14590            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14591            0 :                           RefrigCase(CaseID).LightingPower,
   14592            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14593            0 :                           RefrigCase(CaseID).DefrostPower);
   14594              :                 }
   14595              :             } // NumCasesLT on system
   14596            0 :             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            0 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsLT; ++WalkInNum) {
   14625            0 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumLT(WalkInNum);
   14626            0 :                 print(state.files.eio,
   14627              :                       "   Low Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14628              :                       WalkInID,
   14629            0 :                       WalkIn(WalkInID).Name,
   14630            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14631            0 :                       WalkIn(WalkInID).Temperature,
   14632            0 :                       WalkIn(WalkInID).CoilFanPower,
   14633            0 :                       WalkIn(WalkInID).CircFanPower,
   14634            0 :                       WalkIn(WalkInID).DesignLighting,
   14635            0 :                       WalkIn(WalkInID).HeaterPower,
   14636            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14637            0 :                       WalkIn(WalkInID).NumZones);
   14638            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14639            0 :                     print(state.files.eio,
   14640              :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14641            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14642            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14643            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14644            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14645            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14646            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14647            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14648            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14649            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14650              :                 } // Num zones for each walk in on system
   14651              :             } // NumWalkInsLT on system
   14652              : 
   14653            0 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsHP; ++CompressorNum) {
   14654            0 :                 int CompID = TransSystem(TransSystemNum).CompressorNumHP(CompressorNum);
   14655            0 :                 print(state.files.eio,
   14656              :                       "   High Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14657              :                       CompID,
   14658            0 :                       Compressor(CompID).Name,
   14659            0 :                       Compressor(CompID).NomCap);
   14660              :             } // NumCompressorsHP
   14661            0 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsLP; ++CompressorNum) {
   14662            0 :                 int CompID = TransSystem(TransSystemNum).CompressorNumLP(CompressorNum);
   14663            0 :                 print(state.files.eio,
   14664              :                       "   Low Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14665              :                       CompID,
   14666            0 :                       Compressor(CompID).Name,
   14667            0 :                       Compressor(CompID).NomCap);
   14668              :             } // NumCompressorsLP
   14669              : 
   14670            0 :             if (TransSystem(TransSystemNum).NumGasCoolers >= 1) {
   14671            0 :                 int GasCoolerID = TransSystem(TransSystemNum).GasCoolerNum(1);
   14672            0 :                 print(state.files.eio,
   14673              :                       "   Refrigeration GasCooler:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14674              :                       GasCoolerID,
   14675            0 :                       GasCooler(GasCoolerID).Name,
   14676            0 :                       GasCooler(GasCoolerID).RatedOutletP,
   14677            0 :                       GasCooler(GasCoolerID).RatedOutletT,
   14678            0 :                       GasCooler(GasCoolerID).RatedApproachT,
   14679            0 :                       GasCooler(GasCoolerID).RatedCapacity,
   14680            0 :                       GasCooler(GasCoolerID).RatedFanPower);
   14681              :             } // System(SystemNum)%NumGasCoolers >= 1
   14682              : 
   14683              :         } // NumTransRefrigSystems
   14684              :     } //(NumTransRefrigSystems > 0)
   14685              : 
   14686          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14687            0 :         print(state.files.eio, "#Secondary Refrigeration Systems,{}\n", state.dataRefrigCase->NumSimulationSecondarySystems);
   14688            0 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14689            0 :             switch (Secondary(SecondaryID).FluidType) {
   14690            0 :             case SecFluidType::AlwaysLiquid: {
   14691            0 :                 print(state.files.eio,
   14692              :                       "Secondary Refrigeration System: Fluid Always Liquid,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14693              :                       SecondaryID,
   14694            0 :                       Secondary(SecondaryID).Name,
   14695            0 :                       Secondary(SecondaryID).NumCases,
   14696            0 :                       Secondary(SecondaryID).NumWalkIns,
   14697            0 :                       Secondary(SecondaryID).FluidName,
   14698            0 :                       Secondary(SecondaryID).CoolingLoadRated,
   14699            0 :                       Secondary(SecondaryID).TEvapDesign,
   14700            0 :                       Secondary(SecondaryID).TApproachDifRated,
   14701            0 :                       Secondary(SecondaryID).TRangeDifRated,
   14702            0 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14703            0 :             } break;
   14704            0 :             case SecFluidType::PhaseChange: {
   14705            0 :                 print(state.files.eio,
   14706              :                       "Secondary Refrigeration System: Liquid Overfeed,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14707              :                       SecondaryID,
   14708            0 :                       Secondary(SecondaryID).Name,
   14709            0 :                       Secondary(SecondaryID).NumCases,
   14710            0 :                       Secondary(SecondaryID).NumWalkIns,
   14711            0 :                       Secondary(SecondaryID).FluidName,
   14712            0 :                       Secondary(SecondaryID).CoolingLoadRated,
   14713            0 :                       Secondary(SecondaryID).TEvapDesign,
   14714            0 :                       Secondary(SecondaryID).TApproachDifRated,
   14715            0 :                       Secondary(SecondaryID).CircRate,
   14716            0 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14717            0 :             } break;
   14718            0 :             default:
   14719            0 :                 break;
   14720              :             }
   14721            0 :             for (int CaseNum = 1; CaseNum <= Secondary(SecondaryID).NumCases; ++CaseNum) {
   14722            0 :                 int CaseID = Secondary(SecondaryID).CaseNum(CaseNum);
   14723            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14724            0 :                     print(state.files.eio,
   14725              :                           "  Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14726              :                           CaseID,
   14727            0 :                           RefrigCase(CaseID).Name,
   14728            0 :                           RefrigCase(CaseID).ZoneName,
   14729            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14730            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14731            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14732            0 :                           RefrigCase(CaseID).RatedLHR,
   14733            0 :                           RefrigCase(CaseID).Temperature,
   14734            0 :                           RefrigCase(CaseID).Length,
   14735            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14736            0 :                           RefrigCase(CaseID).LightingPower,
   14737            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14738            0 :                           RefrigCase(CaseID).DefrostPower);
   14739              :                 }
   14740              :             } // NumCases on secondary on secondary system
   14741              : 
   14742            0 :             for (int WalkInNum = 1; WalkInNum <= Secondary(SecondaryID).NumWalkIns; ++WalkInNum) {
   14743            0 :                 int WalkInID = Secondary(SecondaryID).WalkInNum(WalkInNum);
   14744            0 :                 print(state.files.eio,
   14745              :                       "  Walk In,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14746              :                       WalkInID,
   14747            0 :                       WalkIn(WalkInID).Name,
   14748            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14749            0 :                       WalkIn(WalkInID).Temperature,
   14750            0 :                       WalkIn(WalkInID).CoilFanPower,
   14751            0 :                       WalkIn(WalkInID).CircFanPower,
   14752            0 :                       WalkIn(WalkInID).DesignLighting,
   14753            0 :                       WalkIn(WalkInID).HeaterPower,
   14754            0 :                       WalkIn(WalkInID).DefrostCapacity);
   14755            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14756            0 :                     print(state.files.eio,
   14757              :                           "    Walk In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14758            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14759            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14760            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14761            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14762            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14763            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14764            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14765            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14766            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14767              :                 } // zones for walk ins on secondary
   14768              :             } // walk ins on secondary
   14769              : 
   14770            0 :             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          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14778            0 :         print(state.files.eio, "#ZoneHVAC/Refrigeration Air Chiller Sets,{}\n", state.dataRefrigCase->NumRefrigChillerSets);
   14779            0 :         for (int ChillerSetNum = 1; ChillerSetNum <= state.dataRefrigCase->NumRefrigChillerSets; ++ChillerSetNum) {
   14780            0 :             print(state.files.eio,
   14781              :                   "ZoneHVAC/Refrigeration Air Chiller Set,{},{},{},{}\n",
   14782            0 :                   AirChillerSet(ChillerSetNum).Name,
   14783              :                   ChillerSetNum,
   14784            0 :                   AirChillerSet(ChillerSetNum).NumCoils,
   14785            0 :                   AirChillerSet(ChillerSetNum).ZoneName);
   14786              : 
   14787            0 :             for (int CoilNum = 1; CoilNum <= AirChillerSet(ChillerSetNum).NumCoils; ++CoilNum) {
   14788            0 :                 int CoilID = AirChillerSet(ChillerSetNum).CoilNum(CoilNum);
   14789            0 :                 print(state.files.eio,
   14790              :                       "   Refrigeration Air Chiller,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14791              :                       CoilID,
   14792            0 :                       WarehouseCoil(CoilID).Name,
   14793            0 :                       WarehouseCoil(CoilID).ZoneName,
   14794            0 :                       WarehouseCoil(CoilID).ZoneNodeNum,
   14795            0 :                       state.dataLoopNodes->NodeID(WarehouseCoil(CoilID).ZoneNodeNum),
   14796            0 :                       WarehouseCoil(CoilID).UnitLoadFactorSens,
   14797            0 :                       WarehouseCoil(CoilID).RatedSensibleCap,
   14798            0 :                       WarehouseCoil(CoilID).TEvapDesign,
   14799            0 :                       WarehouseCoil(CoilID).RatedTemperatureDif,
   14800            0 :                       WarehouseCoil(CoilID).RatedFanPower,
   14801            0 :                       WarehouseCoil(CoilID).HeaterPower,
   14802            0 :                       WarehouseCoil(CoilID).DefrostCapacity,
   14803            0 :                       WarehouseCoil(CoilID).RatedAirVolumeFlow);
   14804              :             } // numairchillers
   14805              :         } // DataHeatBalance::NumRefrigChillerSets
   14806              :     } // DataHeatBalance::NumRefrigChillerSets
   14807          150 : }
   14808              : 
   14809            3 : 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            3 :     Real64 constexpr DefaultWalkInDoorOpenFactor(0.05); // walk in door open factor (fraction time open)
   14844              : 
   14845              :     static constexpr std::string_view RoutineName("CalculateWalkIn");
   14846            3 :     Real64 CapApplied(0.0);          // Walk In total capacity at specific operating conditions
   14847            3 :     Real64 DefrostSchedule(0.0);     // WalkIn defrost schedule, between 0 and 1
   14848            3 :     Real64 DefrostEnergyNeeded(0.0); // Energy needed to melt all ice, used with temperature termination (J)
   14849            3 :     Real64 DensityFactorFm(0.0);     // called Fm in ASHRAE 2010 eq 13 page 24.5 for door infiltration
   14850            3 :     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            3 :     Real64 WalkInSchedule = this->availSched->getCurrentVal();
   14854            3 :     if (WalkInSchedule <= 0) {
   14855            0 :         return;
   14856              :     }
   14857              :     // GET OTHER SCHEDULES
   14858            3 :     DefrostSchedule = this->defrostSched->getCurrentVal();
   14859            3 :     Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   14860              :     // next statement In case user doesn't understand concept of drip down schedule
   14861            3 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   14862              : 
   14863              :     // next four values optional, so set to default before checking for schedule
   14864            3 :     Real64 StockingLoad = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   14865            3 :     Real64 LightingSchedule = (this->lightingSched != nullptr) ? this->lightingSched->getCurrentVal() : 1.0;
   14866            3 :     Real64 HeaterSchedule = (this->heaterSched != nullptr) ? this->heaterSched->getCurrentVal() : 1.0;
   14867            3 :     Real64 CircFanSchedule = (this->circFanAvailSched != nullptr) ? this->circFanAvailSched->getCurrentVal() : 1.0;
   14868              : 
   14869              :     // Set local subroutine variables for convenience
   14870            3 :     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            3 :     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            3 :     Real64 HumRatioAirWalkIn = Psychrometrics::PsyWFnTdbH(state, TWalkIn, EnthalpyAirWalkIn);
   14877            3 :     Real64 DensityAirWalkIn = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TWalkIn, HumRatioAirWalkIn);
   14878            3 :     Real64 Conv = state.dataEnvrn->Latitude * 2.0 * Constant::Pi / 360.0; // Convert DataEnvironment::Latitude to radians
   14879            3 :     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            3 :     Real64 SensibleLoadTotal(0.0); // Total sensible load on WalkIn over all zones (W)
   14884            3 :     Real64 LatentLoadTotal(0.0);   // total latent load on WalkIn over all zones (W)
   14885            3 :     Real64 ZoneLatentLoad(0.0);    // Latent WalkIn credit delivered to zone (W)
   14886              : 
   14887            3 :     this->SensZoneCreditRate = 0.0;
   14888            3 :     this->SensZoneCreditCoolRate = 0.0;
   14889            3 :     this->SensZoneCreditCool = 0.0;
   14890            3 :     this->SensZoneCreditHeatRate = 0.0;
   14891            3 :     this->SensZoneCreditHeat = 0.0;
   14892            3 :     this->LatZoneCreditRate = 0.0;
   14893              : 
   14894              :     // Start zone loop:
   14895            6 :     for (int ZoneID = 1; ZoneID <= this->NumZones; ++ZoneID) {
   14896            3 :         int zoneNum = this->ZoneNum(ZoneID);
   14897            3 :         int zoneNodeNum = this->ZoneNodeNum(ZoneID);
   14898            3 :         Real64 ZoneDryBulb = state.dataLoopNodes->Node(zoneNodeNum).Temp; // Dry Bulb Temperature of adjacent zone
   14899            3 :         Real64 WalkInLatLoad = -ZoneLatentLoad;                           // Walk in cooler latent load facing particular zone (W)
   14900            3 :         Real64 DelTemp = ZoneDryBulb - TWalkIn;                           // Difference between zone and walk in temperatures (C)
   14901            3 :         Real64 StockDoorArea = this->AreaStockDr(ZoneID);
   14902            3 :         Real64 GlassDoorArea = this->AreaGlassDr(ZoneID);                          // facing a particular zone (m2)
   14903            3 :         Real64 UAOtherSurfaces = this->SurfaceArea(ZoneID) * this->UValue(ZoneID); // UA for non-door surfaces facing a certain zone (W/C)
   14904            3 :         Real64 ZInfilSensLoad(0.0);                                                // Sensible load due to infiltration in one zone
   14905            3 :         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            3 :         Real64 DoorFlowFactor = 0.8; // see ASHRAE Refrigeration, p13.5, 2006
   14909            3 :         if (DelTemp <= 11.0) {
   14910            3 :             DoorFlowFactor = 1.1; // from ASHRAE Refrigeration Loads
   14911              :         }
   14912              : 
   14913              :         // Get infiltration loads if either type of door is present in this zone
   14914            3 :         if (StockDoorArea > 0.0 || GlassDoorArea > 0.0) {
   14915              :             // Zone relative humidity fraction (decimal)
   14916           12 :             Real64 ZoneRHFrac = Psychrometrics::PsyRhFnTdbWPb(state,
   14917            3 :                                                               state.dataLoopNodes->Node(zoneNodeNum).Temp,
   14918            3 :                                                               state.dataLoopNodes->Node(zoneNodeNum).HumRat,
   14919            3 :                                                               state.dataEnvrn->OutBaroPress,
   14920              :                                                               RoutineName);
   14921              :             // Enthalpy of the air in a particular zone (J/kg)
   14922            3 :             Real64 EnthalpyZoneAir = Psychrometrics::PsyHFnTdbRhPb(state, ZoneDryBulb, ZoneRHFrac, state.dataEnvrn->OutBaroPress, RoutineName);
   14923            3 :             Real64 HumRatioZoneAir = Psychrometrics::PsyWFnTdbH(state, ZoneDryBulb, EnthalpyZoneAir, RoutineName);
   14924              :             Real64 DensityZoneAir =
   14925            3 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneDryBulb, HumRatioZoneAir, RoutineName);
   14926            3 :             if (DensityZoneAir < DensityAirWalkIn) { // usual case when walk in is colder than zone
   14927            0 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityZoneAir / DensityAirWalkIn);
   14928            0 :                 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            3 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityAirWalkIn / DensityZoneAir);
   14934            3 :                 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            3 :             Real64 StockDoorInfLoad = 0.0;  // infiltration through stock doors in a particular zone (W)
   14938            3 :             Real64 StockDoorSensHeat = 0.0; // sensible heat gain through stock doors (UA*delta T) (W)
   14939            3 :             Real64 DoorProtectEff(0.0);     // Door protection effectiveness
   14940            3 :             Real64 DrHeight(0.0);           // Door height (m)
   14941            3 :             Real64 DrArea(0.0);             // Door area (m2)
   14942            3 :             Real64 FullFlowInfLoad(0.0);    // Total load (lat + sens) due to 100% open doors w/ fully developed flow (W)
   14943              : 
   14944            3 :             if (StockDoorArea > 0.0) {
   14945            3 :                 std::array<Real64, (int)WIStockDoor::Num> doorProtectEffs = {0.0, 0.5, 0.9}; // Values from ASHRAE Ref p 13.6
   14946            3 :                 DoorProtectEff = doorProtectEffs[(int)this->StockDoorProtectType(ZoneID)];
   14947            3 :                 DrHeight = this->HeightStockDr(ZoneID);
   14948            3 :                 DrArea = StockDoorArea;
   14949              :                 // if exists, get Stock Door Zone schedule
   14950            3 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor;
   14951            3 :                 if (this->stockDoorOpenScheds(ZoneID) != nullptr) {
   14952            0 :                     DoorOpenFactor = this->stockDoorOpenScheds(ZoneID)->getCurrentVal();
   14953              :                 }
   14954              : 
   14955            3 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   14956            3 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   14957            3 :                 StockDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   14958            3 :                 StockDoorSensHeat = DrArea * this->UValueStockDr(ZoneID) * DelTemp;
   14959              :             } // have stock doors
   14960              : 
   14961            3 :             Real64 GlassDoorSensHeat(0.0); // sensible heat gain through glass reach-in doors (UA*delta T) (W)
   14962            3 :             Real64 GlassDoorInfLoad = 0.0; // infiltration through glass reach-in doors in a particular zone (W)
   14963              : 
   14964            3 :             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            3 :             Real64 ZoneInfilLoad = -StockDoorInfLoad - GlassDoorInfLoad; // Walk in cooler infiltration load (sens + latent) in certain zone (W)
   14983            3 :             Real64 MassDryAirRate =
   14984            3 :                 -ZoneInfilLoad / (EnthalpyZoneAir - EnthalpyAirWalkIn); // Mass dry air infiltrating into/out-of walkin through doors (kg/s)
   14985            3 :             Real64 WaterRemovRate =
   14986            3 :                 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            3 :             ZoneLatentLoad = -WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   14993            3 :             ZInfilSensLoad = ZoneInfilLoad - (-WaterRemovRate * IcetoVaporEnthalpy); // done to avoid moving latent to sens during dripdown
   14994            3 :             ZdoorSensLoad = -GlassDoorSensHeat - StockDoorSensHeat;
   14995            3 :             WalkInLatLoad = -ZoneLatentLoad;
   14996            3 :             if (this->TEvapDesign <= 0.0) { // water turned to ice on coil
   14997            3 :                 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            3 :                 if (!state.dataGlobal->WarmupFlag) {
   15001            3 :                     Real64 FrostChangekg = (WaterRemovRate * state.dataGlobal->TimeStepZoneSec) * (1.0 - DefrostDripDownSchedule);
   15002            3 :                     this->KgFrost += FrostChangekg;
   15003              :                 }
   15004              :             } // water to ice
   15005              :         } // No doors
   15006              : 
   15007              :         // Sensible WalkIn credit delivered to a particular zone (W)
   15008            3 :         Real64 ZoneSensLoad = ZInfilSensLoad + ZdoorSensLoad - UAOtherSurfaces * DelTemp;
   15009            3 :         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            3 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).SenCaseCreditToZone += ZoneSensLoad;
   15016            3 :         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            3 :         this->SensZoneCreditRate(ZoneID) = ZoneSensLoad;
   15021            3 :         if (ZoneSensLoad <= 0.0) {
   15022            0 :             this->SensZoneCreditCoolRate(ZoneID) = -ZoneSensLoad;
   15023            0 :             this->SensZoneCreditCool(ZoneID) = -ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15024            0 :             this->SensZoneCreditHeatRate(ZoneID) = 0.0;
   15025            0 :             this->SensZoneCreditHeat(ZoneID) = 0.0;
   15026              :         } else {
   15027            3 :             this->SensZoneCreditHeatRate(ZoneID) = ZoneSensLoad;
   15028            3 :             this->SensZoneCreditHeat(ZoneID) = ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15029            3 :             this->SensZoneCreditCoolRate(ZoneID) = 0.0;
   15030            3 :             this->SensZoneCreditCool(ZoneID) = 0.0;
   15031              :         }
   15032              :         // This rate should always be negative
   15033            3 :         this->LatZoneCreditRate(ZoneID) = ZoneLatentLoad;
   15034            3 :         this->LatZoneCredit(ZoneID) = ZoneLatentLoad * state.dataGlobal->TimeStepZoneSec;
   15035              : 
   15036              :         // Running total over all zones, use later to dispatch capacity
   15037            3 :         SensibleLoadTotal += WalkInSensLoad;
   15038            3 :         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            3 :     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            3 :     Real64 FanLoad = this->CircFanPower * CircFanSchedule + this->CoilFanPower * (1.0 - DefrostDripDownSchedule);
   15050            3 :     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            3 :         this->FloorArea * this->FloorUValue * (state.dataEnvrn->GroundTemp[(int)DataEnvironment::GroundTempType::BuildingSurface] - TWalkIn);
   15056              : 
   15057              :     Real64 DefrostLoad;
   15058              : 
   15059              :     // DEFROST CALCULATIONS
   15060            3 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   15061            0 :         DefrostLoad = this->DefrostCapacity * DefrostSchedule;                  // W
   15062            0 :         Real64 StartFrostKg = this->KgFrost;                                    // frost load at start of time step (kg of ice)
   15063            0 :         Real64 DefrostEnergy = DefrostLoad * state.dataGlobal->TimeStepZoneSec; // Joules
   15064            0 :         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            0 :             Real64 FrostChangekg = min(DefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15114              :             // Reduce defrost heat load on walkin by amount of ice melted during time step
   15115            0 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   15116            0 :             if (!state.dataGlobal->WarmupFlag) {
   15117            0 :                 this->KgFrost = StartFrostKg - FrostChangekg;
   15118              :             }
   15119              :             // DefrostSchedule not changed
   15120              :         } // Temperature termination control type
   15121              : 
   15122            0 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   15123            3 :         DefrostLoad = 0.0;
   15124              :     } // Defrost calculations
   15125              : 
   15126            3 :     if (this->defrostType == DefrostType::Elec) {
   15127            3 :         this->ElecDefrostConsumption = this->DefrostCapacity * DefrostSchedule * state.dataGlobal->TimeStepZoneSec;
   15128            3 :         this->ElecDefrostPower = this->DefrostCapacity * DefrostSchedule;
   15129              :     } else {
   15130            0 :         this->ElecDefrostConsumption = 0.0;
   15131            0 :         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            3 :     if (this->defrostType == DefrostType::Fluid) {
   15136            0 :         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            3 :     SensibleLoadTotal += LightLoad + HeaterLoad + FanLoad + StockingLoad + DefrostLoad + FloorLoad;
   15144            3 :     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            3 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   15158            3 :     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            3 :     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            3 :     Real64 MaxCap = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule); // Design chilling capacity reduced according to drip-down schedule (W)
   15165              : 
   15166            3 :     if (MaxCap >= LoadRequested) {
   15167              :         // Have more at least as much capacity available as needed, even counting stored energy
   15168            3 :         CapApplied = LoadRequested;
   15169            3 :         SensibleCapApplied = SensibleLoadTotal + StoredEnergyRate;
   15170            3 :         LatentCapApplied = LatentLoadTotal;
   15171            3 :         this->StoredEnergy = 0.0;
   15172              :     } else {
   15173              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   15174            0 :         CapApplied = MaxCap;
   15175            0 :         LatentCapApplied = min(LatentLoadTotal, MaxCap); // Latent load should never be > capavail, but just in case...
   15176            0 :         SensibleCapApplied = CapApplied - LatentCapApplied;
   15177            0 :         if (!state.dataGlobal->WarmupFlag) {
   15178            0 :             this->StoredEnergy += (LoadTotal - MaxCap) * state.dataGlobal->TimeStepZoneSec;
   15179              :         }
   15180              :     } // CapAvail vs Load requested
   15181              : 
   15182              :     // ReportWalkIn( WalkInID)
   15183            3 :     this->TotalCoolingLoad = CapApplied;
   15184            3 :     this->TotalCoolingEnergy = CapApplied * state.dataGlobal->TimeStepZoneSec;
   15185            3 :     this->TotSensCoolingEnergyRate = SensibleCapApplied;
   15186            3 :     this->TotSensCoolingEnergy = SensibleCapApplied * state.dataGlobal->TimeStepZoneSec;
   15187            3 :     this->TotLatCoolingEnergyRate = LatentCapApplied;
   15188            3 :     this->TotLatCoolingEnergy = LatentCapApplied * state.dataGlobal->TimeStepZoneSec;
   15189              : 
   15190            3 :     this->ElecFanPower = FanLoad;
   15191            3 :     this->ElecFanConsumption = FanLoad * state.dataGlobal->TimeStepZoneSec;
   15192            3 :     this->ElecHeaterPower = HeaterLoad;
   15193            3 :     this->ElecHeaterConsumption = HeaterLoad * state.dataGlobal->TimeStepZoneSec;
   15194            3 :     this->ElecLightingPower = LightLoad;
   15195            3 :     this->ElecLightingConsumption = LightLoad * state.dataGlobal->TimeStepZoneSec;
   15196            3 :     this->TotalElecPower = FanLoad + HeaterLoad + LightLoad + this->ElecDefrostPower;
   15197            3 :     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            3 :     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            3 :     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            0 : 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            0 :     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            0 :     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            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   15285            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   15286            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15287              : 
   15288            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   15289            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   15290              : 
   15291            0 :     switch (this->FluidType) {
   15292            0 :     case SecFluidType::AlwaysLiquid: {
   15293            0 :         CpBrine = this->CpBrineRated;
   15294            0 :         DensityBrine = this->DensityBrineRated;
   15295            0 :         TBrineIn = this->TBrineInRated;
   15296            0 :         TPipesReceiver = this->TBrineAverage;
   15297            0 :     } break;
   15298            0 :     case SecFluidType::PhaseChange: {
   15299            0 :         TPipesReceiver = this->TCondense;
   15300            0 :     } break;
   15301            0 :     default:
   15302            0 :         break;
   15303              :     } // Fluid type
   15304              : 
   15305              :     // Initialize this secondary for this time step
   15306            0 :     TotalPumpPower = 0.0;
   15307            0 :     RefrigerationLoad = 0.0;
   15308            0 :     TotalHotDefrostCondCredit = 0.0;
   15309            0 :     FlowVolNeeded = 0.0;
   15310            0 :     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            0 :     distPipeHeatGain = 0.0;
   15318            0 :     if (this->SumUADistPiping > MySmallNumber) {
   15319            0 :         int ZoneNodeNum = this->DistPipeZoneNodeNum;
   15320            0 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15321            0 :         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            0 :         this->DistPipeZoneHeatGain = -distPipeHeatGain;
   15325            0 :         state.dataHeatBal->RefrigCaseCredit(this->DistPipeZoneNum).SenCaseCreditToZone -= distPipeHeatGain;
   15326              :     } // calc distribution piping heat gains
   15327              : 
   15328            0 :     Real64 receiverHeatGain = 0.0;
   15329            0 :     if (this->SumUAReceiver > MySmallNumber) {
   15330            0 :         int ZoneNodeNum = this->ReceiverZoneNodeNum;
   15331            0 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15332            0 :         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            0 :         this->ReceiverZoneHeatGain = -receiverHeatGain;
   15336            0 :         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            0 :     if (this->NumCases > 0) {
   15341            0 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   15342            0 :             int CaseID = this->CaseNum(caseNum);
   15343            0 :             RefrigCase(CaseID).CalculateCase(state);
   15344              :             // increment TotalCoolingLoad Hot gas/brine defrost credits for each secondary loop
   15345            0 :             RefrigerationLoad += RefrigCase(CaseID).TotalCoolingLoad;
   15346            0 :             TotalHotDefrostCondCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   15347              :         } // CaseNum
   15348              :     } // NumCases > 0
   15349            0 :     if (this->NumWalkIns > 0) {
   15350            0 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   15351            0 :             int WalkInID = this->WalkInNum(WalkInIndex);
   15352            0 :             WalkIn(WalkInID).CalculateWalkIn(state);
   15353              :             // increment TotalCoolingLoad for  each system
   15354            0 :             RefrigerationLoad += WalkIn(WalkInID).TotalCoolingLoad;
   15355            0 :             TotalHotDefrostCondCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   15356              :         } // NumWalkIns systems
   15357              :     } // Secondary(SecondaryNum)%NumWalkIns > 0
   15358              : 
   15359            0 :     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            0 :     TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain;
   15371            0 :     AtPartLoad = true;
   15372              :     // Check to see if load is already >+ maxload without pump heat
   15373            0 :     if (this->FluidType == SecFluidType::AlwaysLiquid) { //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15374            0 :         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            0 :         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            0 :             VolFlowRate = this->MaxVolFlow;
   15381            0 :             TotalPumpPower = this->PumpTotRatedPower;
   15382            0 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15383            0 :             AtPartLoad = false;
   15384            0 :             if (this->NumCoils > 0) {
   15385            0 :                 DeRate = true;
   15386              :             }
   15387              :         } // flowvolneeded >= maxvolflow
   15388              :     } else { // have SecFluidTypePhaseChange !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15389            0 :         if (TotalLoad >= this->MaxLoad) {
   15390            0 :             TotalPumpPower = this->PumpTotRatedPower;
   15391            0 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15392            0 :             VolFlowRate = this->MaxVolFlow;
   15393            0 :             AtPartLoad = false;
   15394            0 :             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            0 :     if (AtPartLoad) {
   15404            0 :         for (Iter = 1; Iter <= 10; ++Iter) {
   15405            0 :             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            0 :             PrevTotalLoad = TotalLoad;
   15413            0 :             if (this->FluidType == SecFluidType::AlwaysLiquid) {
   15414            0 :                 FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   15415            0 :                 PartLdFrac = FlowVolNeeded / this->MaxVolFlow;
   15416              :             } else {
   15417            0 :                 PartLdFrac = TotalLoad / this->MaxLoad;
   15418              :             }
   15419            0 :             if (this->PumpControlType == SecPumpCtrl::Constant) {
   15420            0 :                 VolFlowRate = 0.0;
   15421            0 :                 TotalPumpPower = 0.0;
   15422            0 :                 for (int PumpID = 1; PumpID <= this->NumPumps; ++PumpID) { // dispatch pumps to meet needed flow rate
   15423            0 :                     if (this->FluidType == SecFluidType::AlwaysLiquid) {   //>>>>>>>>>>>>>>>>>>>>>
   15424            0 :                         VolFlowRate += this->PumpIncrementFlowVol;
   15425            0 :                         TotalPumpPower += this->PumpIncrementPower;
   15426            0 :                         if (VolFlowRate >= FlowVolNeeded) {
   15427            0 :                             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            0 :                 VarFrac = max(0.1, Curve::CurveValue(state, this->VarSpeedCurvePtr, PartLdFrac));
   15440            0 :                 TotalPumpPower = this->PumpTotRatedPower * VarFrac;
   15441            0 :                 VolFlowRate = this->MaxVolFlow * PartLdFrac;
   15442              :             } // pump type
   15443              : 
   15444            0 :             TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain + TotalPumpPower * this->PumpPowerToHeat;
   15445            0 :             Error = std::abs((TotalLoad - PrevTotalLoad) / PrevTotalLoad);
   15446            0 :             if (Error < ErrorTol) {
   15447            0 :                 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            0 :     if (this->NumCoils == 0) {
   15467            0 :         StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour));
   15468              :         // Load necessary to meet current and all stored energy needs (W)
   15469            0 :         Real64 LoadRequested = TotalLoad + StoredEnergyRate;
   15470            0 :         if (this->MaxLoad > LoadRequested) {
   15471              :             // Have at least as much capacity avail as needed, even counting stored energy
   15472            0 :             this->TotalCoolingLoad = LoadRequested;
   15473            0 :             RefrigerationLoad += StoredEnergyRate;
   15474            0 :             this->UnmetEnergy = 0.0;
   15475              :         } else {
   15476              :             // Don't have as much capacity as needed (likely following defrost periods)
   15477            0 :             this->TotalCoolingLoad = this->MaxLoad;
   15478            0 :             RefrigerationLoad -= (TotalLoad - this->MaxLoad);
   15479            0 :             if (!state.dataGlobal->WarmupFlag) {
   15480            0 :                 this->UnmetEnergy += ((TotalLoad - this->MaxLoad) * state.dataGlobal->TimeStepZoneSec);
   15481              :             }
   15482              :         } // load requested greater than MaxLoad
   15483            0 :         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            0 :     this->PumpPowerTotal = TotalPumpPower;
   15502            0 :     this->PumpElecEnergyTotal = TotalPumpPower * localTimeStepSec;
   15503            0 :     this->TotalRefrigLoad = RefrigerationLoad;
   15504            0 :     this->TotalRefrigEnergy = RefrigerationLoad * localTimeStepSec;
   15505            0 :     this->TotalCoolingEnergy = TotalCoolingLoad * localTimeStepSec;
   15506            0 :     this->FlowVolActual = VolFlowRate;
   15507            0 :     this->HotDefrostCondCredit = TotalHotDefrostCondCredit;
   15508            0 :     this->DistPipeHeatGain = distPipeHeatGain;
   15509            0 :     this->DistPipeHeatGainEnergy = distPipeHeatGain * localTimeStepSec;
   15510            0 :     this->ReceiverHeatGain = receiverHeatGain;
   15511            0 :     this->ReceiverHeatGainEnergy = receiverHeatGain * localTimeStepSec;
   15512            0 : }
   15513              : 
   15514            5 : 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            5 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15533            5 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   15534              : 
   15535            5 :     if (state.dataRefrigCase->UseSysTimeStep) { // air chillers
   15536            0 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15537            0 :             auto &credit = CoilSysCredit(ZoneNum);
   15538            0 :             credit.ReportH2ORemovedKgPerS_FromZoneRate = -credit.LatKgPerS_ToZoneRate;
   15539            0 :             credit.ReportLatCreditToZoneRate = -credit.LatCreditToZoneRate;
   15540            0 :             credit.ReportLatCreditToZoneEnergy = -credit.LatCreditToZoneEnergy;
   15541              :             // Sensible rate can be positive or negative, split into separate output variables and
   15542              :             //   always report positive value
   15543            0 :             if (credit.SenCreditToZoneRate <= 0.0) {
   15544            0 :                 credit.ReportSenCoolingToZoneRate = -credit.SenCreditToZoneRate;
   15545            0 :                 credit.ReportSenCoolingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15546            0 :                 credit.ReportHeatingToZoneRate = 0.0;
   15547            0 :                 credit.ReportHeatingToZoneEnergy = 0.0;
   15548              :             } else {
   15549            0 :                 credit.ReportSenCoolingToZoneRate = 0.0;
   15550            0 :                 credit.ReportSenCoolingToZoneEnergy = 0.0;
   15551            0 :                 credit.ReportHeatingToZoneRate = credit.SenCreditToZoneRate;
   15552            0 :                 credit.ReportHeatingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15553              :             }
   15554            0 :             credit.ReportTotCoolingToZoneRate = credit.ReportLatCreditToZoneRate + credit.ReportSenCoolingToZoneRate;
   15555            0 :             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           10 :     if ((!state.dataRefrigCase->UseSysTimeStep) &&
   15561            5 :         ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   15562           10 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15563            5 :             auto &report = CaseWIZoneReport(ZoneNum);
   15564            5 :             report.SenCaseCreditToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15565              :             // Latent always negative
   15566            5 :             report.LatCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15567            5 :             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            5 :             if (state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone <= 0.0) {
   15571            1 :                 report.SenCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15572            1 :                 report.SenCoolingToZoneEnergy = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15573            1 :                 report.HeatingToZoneRate = 0.0;
   15574            1 :                 report.HeatingToZoneEnergy = 0.0;
   15575              :             } else {
   15576            4 :                 report.SenCoolingToZoneRate = 0.0;
   15577            4 :                 report.SenCoolingToZoneEnergy = 0.0;
   15578            4 :                 report.HeatingToZoneRate = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15579            4 :                 report.HeatingToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15580              :             }
   15581            5 :             report.TotCoolingToZoneRate = report.SenCoolingToZoneRate + report.LatCoolingToZoneRate;
   15582            5 :             report.TotCoolingToZoneEnergy = report.SenCoolingToZoneEnergy + report.LatCoolingToZoneEnergy;
   15583            5 :             report.TotHtXferToZoneRate =
   15584            5 :                 state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone + state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15585            5 :             report.TotHtXferToZoneEnergy = report.TotHtXferToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15586              :         } // over zones for cases and walkins
   15587              :     }
   15588            5 : }
   15589              : 
   15590       250036 : 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       250036 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   15604              : 
   15605          150 :         GetRefrigerationInput(state);
   15606          150 :         SetupReportInput(state);
   15607          150 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   15608              : 
   15609          150 :         if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->HaveChillers)) {
   15610          145 :             state.dataRefrigCase->ManageRefrigeration = false;
   15611          145 :             return;
   15612              :         }
   15613            5 :         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            0 : 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            0 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   15644            0 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15645              : 
   15646              :     int ChillerSetID;
   15647              :     Real64 RemainingOutputToCoolingSP; // Remaining requested load in zone
   15648              : 
   15649            0 :     CheckRefrigerationInput(state);
   15650              : 
   15651              :     // Find the correct Chiller set
   15652            0 :     if (AirChillerSetPtr == 0) {
   15653            0 :         ChillerSetID = Util::FindItemInList(AirChillerSetName, AirChillerSet);
   15654            0 :         if (ChillerSetID == 0) {
   15655            0 :             ShowFatalError(state, format("SimAirChillerSet: Unit not found={}", AirChillerSetName));
   15656              :         } // chillersetid ==0 because not in list
   15657            0 :         AirChillerSetPtr = ChillerSetID;
   15658              :     } else { // airchllersetpointer passed in call to subroutine not ==0
   15659            0 :         ChillerSetID = AirChillerSetPtr;
   15660            0 :         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            0 :         if (state.dataRefrigCase->CheckChillerSetName(ChillerSetID)) {
   15668            0 :             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            0 :             state.dataRefrigCase->CheckChillerSetName(ChillerSetID) = false;
   15676              :         } // CheckChillerSetName logical test
   15677              :     } //(AirChillerSetPtr == 0 or else not == 0
   15678              : 
   15679            0 :     if (FirstHVACIteration) {
   15680            0 :         for (ChillerSetID = 1; ChillerSetID <= state.dataRefrigCase->NumRefrigChillerSets;
   15681              :              ++ChillerSetID) { // bbb what point of do loop, only set one (airchillersetptr) to zero
   15682            0 :             AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15683              :         }
   15684              :     } // FirstHVACIteration
   15685              : 
   15686            0 :     RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
   15687              :     // RemainingOutputToCoolingSP in Watts, < 0 for cooling demand
   15688              : 
   15689            0 :     if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) {
   15690            0 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = RemainingOutputToCoolingSP;
   15691              :     } else {
   15692            0 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15693              :     }
   15694              : 
   15695            0 :     state.dataRefrigCase->UseSysTimeStep = true;
   15696              : 
   15697            0 :     ManageRefrigeratedCaseRacks(state);
   15698              : 
   15699            0 :     state.dataRefrigCase->UseSysTimeStep = false;
   15700              : 
   15701              :     // Return values to Zone Equipment Manager.
   15702            0 :     LatOutputProvided = CoilSysCredit(ZoneNum).LatKgPerS_ToZoneRate;
   15703            0 :     SysOutputProvided = CoilSysCredit(ZoneNum).SenCreditToZoneRate;
   15704            0 : }
   15705              : 
   15706            0 : 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            0 :     Real64 AirChillerSetSchedule = 0.0; // Schedule value for air chiller SET
   15725            0 :     Real64 QZNReqSens = 0.0;            // Amount of sensible heat needed by the zone, NEGATIVE when cooling needed [W]
   15726            0 :     Real64 RemainQZNReqSens = 0.0;      // Remaining amount of sensible heat needed by the zone [W]
   15727              : 
   15728            0 :     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            0 :     AirChillerSetSchedule = this->availSched->getCurrentVal();
   15734              : 
   15735            0 :     if (AirChillerSetSchedule <= 0.0) {
   15736            0 :         return;
   15737              :     }
   15738            0 :     QZNReqSens = this->QZnReqSens;
   15739            0 :     RemainQZNReqSens = QZNReqSens;
   15740              : 
   15741            0 :     for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15742            0 :         int CoilID = this->CoilNum(CoilIndex);
   15743              : 
   15744            0 :         WarehouseCoil(CoilID).CalculateCoil(state, RemainQZNReqSens);
   15745            0 :         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            0 :         if (RemainQZNReqSens > 0.0) {
   15750            0 :             RemainQZNReqSens = 0.0;
   15751              :         }
   15752              :     } // CoilIndex
   15753              : }
   15754              : 
   15755            0 : 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            0 :     auto &System = state.dataRefrigCase->System;
   15777            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15778              : 
   15779            0 :     int NumCoils = 0;
   15780            0 :     Real64 DeRateFactor = 0.0;        // Ratio of energy available from system or secondary loop
   15781            0 :     Real64 InitLatCreditEnergy = 0.0; // Latent credit energy before derate [W]
   15782            0 :     Real64 FrostReduction = 0.0;      // Change in frost on coils based on derated latent load [kg]
   15783              : 
   15784              :     {
   15785            0 :         switch (SystemSourceType) {
   15786            0 :         case SourceType::DetailedSystem:
   15787            0 :             NumCoils = System(SystemID).NumCoils;
   15788            0 :             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            0 :     if (DeRate) {
   15798            0 :         ShowRecurringWarningErrorAtEnd(
   15799              :             state,
   15800            0 :             "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            0 :             System(SystemID).InsuffCapWarn);
   15803              : 
   15804            0 :         DeRateFactor = AvailableTotalLoad / InitialTotalLoad;
   15805            0 :         Real64 const time_step_sec(state.dataHVACGlobal->TimeStepSysSec);
   15806            0 :         for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
   15807            0 :             int CoilID = System(SystemID).CoilNum(CoilIndex);
   15808            0 :             auto &warehouse_coil = WarehouseCoil(CoilID);
   15809              : 
   15810              :             // need to adjust ice on coil due to reduction in latent load met by coil
   15811            0 :             InitLatCreditEnergy = warehouse_coil.LatCreditEnergy;
   15812              : 
   15813            0 :             warehouse_coil.TotalCoolingLoad *= DeRateFactor;
   15814            0 :             warehouse_coil.TotalCoolingEnergy *= DeRateFactor;
   15815            0 :             warehouse_coil.SensCoolingEnergyRate *= DeRateFactor;
   15816            0 :             warehouse_coil.SensCoolingEnergy *= DeRateFactor;
   15817            0 :             warehouse_coil.LatCreditRate *= DeRateFactor;
   15818            0 :             warehouse_coil.LatCreditEnergy *= DeRateFactor;
   15819            0 :             warehouse_coil.LatKgPerS_ToZone *= DeRateFactor;
   15820            0 :             warehouse_coil.SensCreditRate = warehouse_coil.SensCoolingEnergyRate - warehouse_coil.ElecFanPower - warehouse_coil.ElecHeaterPower -
   15821            0 :                                             warehouse_coil.ThermalDefrostPower;
   15822            0 :             warehouse_coil.SensCreditEnergy = warehouse_coil.SensCreditRate * time_step_sec;
   15823              : 
   15824            0 :             FrostReduction = (InitLatCreditEnergy - warehouse_coil.LatCreditEnergy) / IcetoVaporEnthalpy;
   15825            0 :             warehouse_coil.KgFrost = max(0.0, warehouse_coil.KgFrost - FrostReduction);
   15826              : 
   15827            0 :             if (warehouse_coil.SensCreditRate >= 0.0) {
   15828            0 :                 warehouse_coil.ReportSensCoolCreditRate = warehouse_coil.SensCreditRate;
   15829            0 :                 warehouse_coil.ReportHeatingCreditRate = 0.0;
   15830              :             } else {
   15831            0 :                 warehouse_coil.ReportSensCoolCreditRate = 0.0;
   15832            0 :                 warehouse_coil.ReportHeatingCreditRate = -warehouse_coil.SensCreditRate;
   15833              :             }
   15834            0 :             warehouse_coil.ReportSensCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditRate * time_step_sec;
   15835            0 :             warehouse_coil.ReportHeatingCreditEnergy = warehouse_coil.ReportHeatingCreditRate * time_step_sec;
   15836            0 :             warehouse_coil.ReportTotalCoolCreditRate = warehouse_coil.ReportSensCoolCreditRate + warehouse_coil.LatCreditRate;
   15837            0 :             warehouse_coil.ReportTotalCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditEnergy + warehouse_coil.LatCreditEnergy;
   15838              :         }
   15839              :     } // DeRate == true
   15840            0 : }
   15841              : 
   15842            0 : 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            0 :     Real64 CoilSchedule = this->availSched->getCurrentVal(); // Current value of Coil operating (availability) schedule
   15879            0 :     if (CoilSchedule <= 0.0) {
   15880            0 :         return;
   15881              :     }
   15882              : 
   15883            0 :     Real64 DefrostSchedule = this->defrostSched->getCurrentVal();                 // Coil defrost schedule, between 0 and 1
   15884            0 :     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            0 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   15887              :     // next value optional, so set to default before checking for schedule
   15888            0 :     Real64 HeaterSchedule = 1.0; // zero to one
   15889            0 :     if (this->heaterAvailSched != nullptr) {
   15890            0 :         HeaterSchedule = this->heaterAvailSched->getCurrentVal();
   15891              :     }
   15892              : 
   15893              :     // Set local subroutine variables for convenience
   15894            0 :     FanSpeedCtrlType FanSpeedControlType = this->FanType;
   15895            0 :     Real64 AirVolumeFlowRated = this->RatedAirVolumeFlow;   // Coil rated air flow (m3/s)
   15896            0 :     Real64 FanPowerRated = this->RatedFanPower;             // (W)
   15897            0 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   15898            0 :     Real64 DefrostCap = this->DefrostCapacity;              // Design defrost capacity of Coil (W)
   15899            0 :     Real64 TEvap = this->TEvapDesign;                       // Evaporating temperature in the coil (C)
   15900              : 
   15901            0 :     Real64 CoilCapTotEstimate(0.0); // Part of loop to solve for total coil capacity as a function of inlet air conditions (W)
   15902            0 :     Real64 AirVolumeFlowMax(0.0);   // Coil air flow limited by drip down schedule (m3/s)
   15903            0 :     Real64 CoilCapTotal(0.0);       // Sensible plus latent load (W)
   15904            0 :     Real64 CoilInletDensity(0.0);   // Coil air inlet density (kg/m3)
   15905            0 :     Real64 CoilInletDryAirCp(0.0);  // Dry air specific heat at coil inlet temperature (J/kg-C)
   15906            0 :     Real64 CoilInletHumRatio(0.0);  // Coil air inlet humidity ratio (kg water/kg air)
   15907            0 :     Real64 CoilInletTemp(0.0);      // Inlet temperature of air to coil, not mixed zone temperature unless "middle" location selected (C)
   15908            0 :     Real64 CoilInletEnthalpy(0.0);  // Coil inlet air enthalpy (J/kg)
   15909            0 :     Real64 CoilInletRHFrac(0.0);    // Coil inlet air relative humidity expressed as a fraction (0 to 1)
   15910            0 :     Real64 DefrostLoad(0.0);
   15911            0 :     Real64 DryAirMassFlowMax(0.0);      // Rated volume flow rate times dry air density adjusted for schedules (kg/s)
   15912            0 :     Real64 FanPowerActual(0.0);         // (W)
   15913            0 :     Real64 FrostChangekg(0.0);          // Amount of frost added or melted  (kg)
   15914            0 :     Real64 latLoadServed(0.0);          // Energy rate used to remove water from zone air (W)
   15915            0 :     Real64 SensLoadRequestedGross(0.0); // Gross sensible load removed by coil
   15916            0 :     Real64 SensLoadGross(0.0);          // Sensible load met by coil (W)
   15917            0 :     Real64 SHR(0.0);                    // Sensible heat ratio, sensible load/total load
   15918            0 :     Real64 SHRCorrection(0.0);          // Actual total/sensible load, NOT = Inverse SHR (unless coil efficiency = 1.0)
   15919            0 :     Real64 WaterRemovRate(0.0);         // Walk in cooler removes water at this rate in this zone (kg/s)
   15920              : 
   15921            0 :     if (DefrostDripDownSchedule == 1.0) {
   15922            0 :         AirVolumeFlowMax = 0.0;
   15923            0 :         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            0 :         Real64 SensLoadRequested = -QZnReq; // here let cooling demand be positive within subroutine
   15927            0 :         if (SensLoadRequested <= 0.0) {     // No load so assume control keeps off, except that scheduled defrost still occurs
   15928            0 :             AirVolumeFlowMax = 0.0;
   15929            0 :             DryAirMassFlowMax = 0.0;
   15930              :         } else {
   15931            0 :             SensLoadRequestedGross = SensLoadRequested + HeaterLoad + FanPowerRated;
   15932            0 :             Real64 ZoneMixedAirDryBulb = state.dataLoopNodes->Node(this->ZoneNodeNum).Temp;    // (C)
   15933            0 :             Real64 ZoneMixedAirHumRatio = state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat; // kg water/kg air in the zone mixed air
   15934              :             Real64 ZoneMixedAirRHFrac =
   15935            0 :                 Psychrometrics::PsyRhFnTdbWPb(state, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, state.dataEnvrn->OutBaroPress, TrackMessage);
   15936              :             Real64 ZoneMixedAirEnthalpy =
   15937            0 :                 Psychrometrics::PsyHFnTdbRhPb(state, ZoneMixedAirDryBulb, ZoneMixedAirRHFrac, state.dataEnvrn->OutBaroPress, TrackMessage);
   15938              :             Real64 ZoneMixedAirDensity =
   15939            0 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, TrackMessage);
   15940              :             Real64 ZoneDryAirDensity =
   15941            0 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, 0.0, TrackMessage);
   15942            0 :             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            0 :             switch (this->VerticalLocation) {
   15948            0 :             case VerticalLoc::Floor:
   15949              :                 // purposely fall through
   15950              :             case VerticalLoc::Ceiling:
   15951              :                 // purposely fall through
   15952              :             case VerticalLoc::Middle:
   15953            0 :                 CoilInletTemp = ZoneMixedAirDryBulb;
   15954            0 :                 CoilInletEnthalpy = ZoneMixedAirEnthalpy;
   15955            0 :                 CoilInletRHFrac = ZoneMixedAirRHFrac;
   15956            0 :                 CoilInletDensity = ZoneMixedAirDensity;
   15957            0 :                 CoilInletHumRatio = ZoneMixedAirHumRatio;
   15958            0 :                 CoilInletDryAirCp = Psychrometrics::PsyCpAirFnW(0.0);
   15959            0 :                 break;
   15960            0 :             default:
   15961            0 :                 assert(false);
   15962              :             }
   15963            0 :             AirVolumeFlowMax = AirVolumeFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15964            0 :             DryAirMassFlowMax = DryAirMassFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15965              : 
   15966              :         } // Sens load requested is non-zero
   15967              :     } // DefrostDripDownSchedule == 1.0d0
   15968              : 
   15969            0 :     if (AirVolumeFlowMax > 0.0) {
   15970              : 
   15971              :         Real64 TemperatureDif =
   15972            0 :             min(this->MaxTemperatureDif, (CoilInletTemp - TEvap)); // difference between inlet air and evaporating temperature (deltaC)
   15973              : 
   15974            0 :         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            0 :             CoilCapTotEstimate = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, CoilInletTemp, TemperatureDif, CoilInletRHFrac) *
   15981            0 :                                  this->RatedCapTotal * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15982              : 
   15983              :         } else { // work with unit load factor (sensible only), function of DT1 (Tair in drybulb-Tevap)
   15984            0 :             Real64 SensibleCapacityMax = this->UnitLoadFactorSens * TemperatureDif * (1.0 - DefrostDripDownSchedule) *
   15985              :                                          CoilSchedule; // Sensible capacity adjusted for any time in dripdown state (W)
   15986              : 
   15987            0 :             if (SensibleCapacityMax > 0.0) {
   15988            0 :                 Real64 ExitTemperatureEstimate =
   15989            0 :                     CoilInletTemp - (SensibleCapacityMax / (DryAirMassFlowMax * CoilInletDryAirCp)); // Estimated Air temperature leaving the coil (C)
   15990            0 :                 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            0 :                 Real64 ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbRhPb(state,
   15995              :                                                                             ExitTemperatureEstimate,
   15996              :                                                                             1.0,
   15997            0 :                                                                             state.dataEnvrn->OutBaroPress,
   15998              :                                                                             TrackMessage); // Estimated Air enthalpy leaving the coil (J/kg)
   15999            0 :                 if (ExitEnthalpyEstimate <= CoilInletEnthalpy) {
   16000            0 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16001              :                 } else {
   16002              :                     // Assume no water is extracted from flow
   16003            0 :                     ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbW(ExitTemperatureEstimate, CoilInletHumRatio);
   16004            0 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16005              :                 }
   16006            0 :                 if (SensibleCapacityMax > CoilCapTotEstimate) {
   16007            0 :                     SensibleCapacityMax = CoilCapTotEstimate;
   16008              :                 }
   16009            0 :                 if (std::abs(CoilCapTotEstimate) > 0.0) {
   16010            0 :                     SHR = SensibleCapacityMax / (CoilCapTotEstimate);
   16011              :                 } else {
   16012              :                     // will occur whenever defrost or dripdown
   16013            0 :                     SHR = 0.0;
   16014              :                 }
   16015              : 
   16016            0 :                 switch (this->SHRCorrType) {
   16017            0 :                 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            0 :                     Real64 Slope = (this->SHRCorrection60 - 1.0) / (0.6 - 1.0); // Part of linear SHR60 correction factor, dimensionless
   16020            0 :                     Real64 Yint = this->SHRCorrection60 - (Slope * 0.6);        // Part of linear SHR60 correction factor, dimensionless
   16021            0 :                     SHRCorrection = Slope * SHR + Yint;
   16022            0 :                 } break;
   16023            0 :                 case SHRCorrectionType::QuadraticSHR: {
   16024            0 :                     SHRCorrection = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, SHR);
   16025            0 :                 } break;
   16026            0 :                 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            0 :                     if (CoilInletTemp <= -25.0) {
   16041            0 :                         SHRCorrection = 1.0;
   16042            0 :                     } else if (CoilInletTemp > -25.0 && CoilInletTemp <= 0.0) {
   16043            0 :                         SHRCorrection = (EuropeanWetCoilFactor[1] - EuropeanWetCoilFactor[3]) / (EuropeanAirInletTemp[1] - EuropeanAirInletTemp[3]) *
   16044            0 :                                             (EuropeanAirInletTemp[1] - CoilInletTemp) +
   16045            0 :                                         EuropeanWetCoilFactor[3];
   16046            0 :                     } else if (CoilInletTemp > 0.0 && CoilInletTemp <= 5.0) {
   16047            0 :                         SHRCorrection = (EuropeanWetCoilFactor[0] - EuropeanWetCoilFactor[1]) / (EuropeanAirInletTemp[0] - EuropeanAirInletTemp[1]) *
   16048            0 :                                             (EuropeanAirInletTemp[0] - CoilInletTemp) +
   16049            0 :                                         EuropeanWetCoilFactor[1];
   16050            0 :                     } else if (CoilInletTemp > 5.0) {
   16051            0 :                         SHRCorrection = EuropeanWetCoilFactor[0];
   16052              :                     } // calc correction as a function of coil inlet temperature
   16053            0 :                 } break;
   16054            0 :                 default:
   16055            0 :                     break;
   16056              :                 }
   16057            0 :                 CoilCapTotEstimate = SHRCorrection * SensibleCapacityMax;
   16058              :             } else { // NOT (SensibleCapacityMax > 0.0d0)
   16059            0 :                 CoilCapTotEstimate = 0.0;
   16060              :             } //  (SensibleCapacityMax > 0.0d0)
   16061              :         } // Rating type : CapacityTotalSpecificConditions or Sensible Unit Load Factor
   16062              : 
   16063            0 :         if (CoilCapTotEstimate > 0.0) {
   16064            0 :             Real64 ExitEnthalpy =
   16065            0 :                 CoilInletEnthalpy - (CoilCapTotEstimate / (AirVolumeFlowMax * CoilInletDensity)); // Air enthalpy leaving the coil (J/kg)
   16066            0 :             Real64 ExitTemperature = Psychrometrics::PsyTsatFnHPb(
   16067            0 :                 state, ExitEnthalpy, state.dataEnvrn->OutBaroPress, TrackMessage); // RH =1.0 at Tsat // Air temperature leaving the coil (C)
   16068            0 :             Real64 ExitHumRatio = Psychrometrics::PsyWFnTdbH(state, ExitTemperature, ExitEnthalpy, TrackMessage); // kg water/kg air
   16069            0 :             if (ExitHumRatio > CoilInletHumRatio) {
   16070            0 :                 ExitHumRatio = CoilInletHumRatio;
   16071              :             }
   16072            0 :             WaterRemovRate = DryAirMassFlowMax * (CoilInletHumRatio - ExitHumRatio);
   16073            0 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16074            0 :             SensLoadGross = CoilCapTotEstimate - latLoadServed;
   16075            0 :             FanPowerActual = FanPowerRated;
   16076            0 :             if (SensLoadGross < 0.0) {
   16077              :                 // Could rarely happen during initial cooldown of a warm environment
   16078            0 :                 SensLoadGross = 0.0;
   16079            0 :                 latLoadServed = CoilCapTotEstimate;
   16080            0 :                 WaterRemovRate = latLoadServed / IcetoVaporEnthalpy;
   16081              :             } // SensLoadGross < 0
   16082              :         } else { // NOT (SensibleCapacityMax > 0.0d0)
   16083            0 :             WaterRemovRate = 0.0;
   16084            0 :             latLoadServed = 0.0;
   16085            0 :             SensLoadGross = 0.0;
   16086            0 :             FanPowerActual = 0.0;
   16087              :         } //(CoilCapTotEstimate > 0.0d0)
   16088              : 
   16089            0 :         Real64 FanPowerMax = FanPowerRated * (1.0 - DefrostDripDownSchedule); // Total fan energy rate, limited by dripdown period (W)
   16090            0 :         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            0 :             Real64 CapFac = SensLoadRequestedGross / SensLoadGross; // used to reduce fan power when don't need full coil capacity
   16094            0 :             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            0 :             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            0 :             case FanSpeedCtrlType::ConstantSpeed: {
   16103            0 :                 FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16104            0 :             } 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            0 :             WaterRemovRate *= AirVolRatio;
   16125            0 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16126            0 :             SensLoadGross = SensLoadRequestedGross;
   16127              :         } else { // at full load
   16128            0 :             FanPowerActual = FanPowerMax;
   16129              :         } // part load and sensload served > 0.
   16130              : 
   16131            0 :         CoilCapTotal = SensLoadGross + latLoadServed;
   16132            0 :         if (CoilCapTotal > 0.0) {
   16133            0 :             SHR = SensLoadGross / CoilCapTotal;
   16134              :         } else {
   16135            0 :             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            0 :         if (!state.dataGlobal->WarmupFlag) {
   16142            0 :             FrostChangekg = (WaterRemovRate * state.dataHVACGlobal->TimeStepSysSec);
   16143            0 :             this->KgFrost += FrostChangekg;
   16144              :         }
   16145              : 
   16146              :     } else { // NOT (AirVolumeFlowMax > 0.0d0)
   16147            0 :         WaterRemovRate = 0.0;
   16148            0 :         latLoadServed = 0.0;
   16149            0 :         SensLoadGross = 0.0;
   16150            0 :         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            0 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   16159            0 :         DefrostLoad = DefrostCap * DefrostSchedule;                                // Part of the defrost that is a heat load on the zone (W)
   16160            0 :         Real64 DefrostEnergy = DefrostLoad * state.dataHVACGlobal->TimeStepSysSec; // Joules
   16161            0 :         Real64 StartFrostKg = this->KgFrost;                                       // frost load at start of time step (kg of ice)
   16162              : 
   16163            0 :         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            0 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // available to melt ice with temp term control (J)
   16171            0 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   16172            0 :             if (StartFrostKg > 0.0) {
   16173            0 :                 if (this->IceTemp < 0.0) {
   16174            0 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   16175            0 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   16176            0 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   16177            0 :                         this->IceTemp = 0.0;
   16178            0 :                         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            0 :                 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   16186            0 :                 if (FrostChangekg < StartFrostKg) {
   16187            0 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   16188            0 :                     if (!state.dataGlobal->WarmupFlag) {
   16189            0 :                         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            0 :                     this->KgFrost = 0.0;
   16195            0 :                     Real64 DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   16196            0 :                                                  this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   16197            0 :                     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            0 :                     Real64 DefrostRateNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / (state.dataHVACGlobal->TimeStepSysSec);
   16201            0 :                     DefrostLoad = max(0.0, (DefrostSchedule * DefrostCap - DefrostRateNeeded));
   16202            0 :                     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            0 :                 DefrostLoad = 0.0;
   16208            0 :                 DefrostSchedule = 0.0;
   16209            0 :                 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            0 :             FrostChangekg = max(0.0, min((DefrostEnergy / IceMeltEnthalpy), StartFrostKg));
   16217            0 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   16218            0 :             if (!state.dataGlobal->WarmupFlag) {
   16219            0 :                 this->KgFrost = StartFrostKg - FrostChangekg;
   16220              :             }
   16221              :         } // Temperature termination vs. time-clock control type
   16222              : 
   16223            0 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   16224            0 :         DefrostLoad = 0.0;
   16225              :     } // Defrost calculations
   16226              : 
   16227            0 :     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            0 :     this->ThermalDefrostPower = DefrostLoad;
   16232            0 :     if (this->defrostType == DefrostType::Elec) {
   16233            0 :         this->ElecDefrostConsumption = DefrostCap * DefrostSchedule * state.dataHVACGlobal->TimeStepSysSec;
   16234            0 :         this->ElecDefrostPower = DefrostCap * DefrostSchedule;
   16235              :     } else {
   16236            0 :         this->ElecDefrostConsumption = 0.0;
   16237            0 :         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            0 :     if (this->defrostType == DefrostType::Fluid) {
   16242            0 :         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            0 :     this->SensCreditRate = SensLoadFromZone;
   16247            0 :     this->SensCreditEnergy = SensLoadFromZone * state.dataHVACGlobal->TimeStepSysSec;
   16248            0 :     this->LatCreditRate = latLoadServed;
   16249            0 :     this->LatCreditEnergy = latLoadServed * state.dataHVACGlobal->TimeStepSysSec;
   16250            0 :     this->LatKgPerS_ToZone = WaterRemovRate;
   16251            0 :     this->TotalCoolingLoad = CoilCapTotal;
   16252            0 :     this->TotalCoolingEnergy = CoilCapTotal * state.dataHVACGlobal->TimeStepSysSec;
   16253            0 :     this->SensCoolingEnergyRate = SensLoadGross;
   16254            0 :     this->SensCoolingEnergy = SensLoadGross * state.dataHVACGlobal->TimeStepSysSec;
   16255            0 :     this->SensHeatRatio = SHR;
   16256            0 :     this->ElecFanPower = FanPowerActual;
   16257            0 :     this->ElecFanConsumption = FanPowerActual * state.dataHVACGlobal->TimeStepSysSec;
   16258            0 :     this->ElecHeaterPower = HeaterLoad;
   16259            0 :     this->ElecHeaterConsumption = HeaterLoad * state.dataHVACGlobal->TimeStepSysSec;
   16260              : 
   16261            0 :     this->TotalElecPower = FanPowerActual + HeaterLoad + this->ElecDefrostPower;
   16262            0 :     this->TotalElecConsumption = this->TotalElecPower * state.dataHVACGlobal->TimeStepSysSec;
   16263              : 
   16264            0 :     if (this->SensCreditRate >= 0.0) {
   16265            0 :         this->ReportSensCoolCreditRate = this->SensCreditRate;
   16266            0 :         this->ReportHeatingCreditRate = 0.0;
   16267              :     } else {
   16268            0 :         this->ReportSensCoolCreditRate = 0.0;
   16269            0 :         this->ReportHeatingCreditRate = -this->SensCreditRate;
   16270              :     }
   16271            0 :     this->ReportSensCoolCreditEnergy = this->ReportSensCoolCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16272            0 :     this->ReportHeatingCreditEnergy = this->ReportHeatingCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16273            0 :     this->ReportTotalCoolCreditRate = this->ReportSensCoolCreditRate + this->LatCreditRate;
   16274            0 :     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            0 :     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       249958 : 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       249958 :     auto &System = state.dataRefrigCase->System;
   16305       249958 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   16306       249958 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16307       249958 :     auto &Secondary = state.dataRefrigCase->Secondary;
   16308       249958 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   16309       249958 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   16310              : 
   16311       249958 :     CheckRefrigerationInput(state);
   16312              : 
   16313       249958 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag) {
   16314              : 
   16315          483 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   16316            0 :             for (auto &e : System) {
   16317            0 :                 e.PipeHeatLoad = 0.0;
   16318            0 :                 e.NetHeatRejectLoad = 0.0;
   16319              :             }
   16320              :         }
   16321              : 
   16322          483 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   16323            0 :             for (auto &e : TransSystem) {
   16324            0 :                 e.PipeHeatLoadMT = 0.0;
   16325            0 :                 e.PipeHeatLoadLT = 0.0;
   16326            0 :                 e.NetHeatRejectLoad = 0.0;
   16327              :             }
   16328              :         }
   16329              : 
   16330          483 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   16331            0 :             for (auto &e : RefrigRack) {
   16332            0 :                 e.SensZoneCreditHeatRate = 0.0;
   16333            0 :                 e.SensHVACCreditHeatRate = 0.0;
   16334              :             }
   16335              :         }
   16336              : 
   16337          483 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   16338            0 :             for (auto &e : Secondary) {
   16339            0 :                 e.DistPipeZoneHeatGain = 0.0;
   16340            0 :                 e.ReceiverZoneHeatGain = 0.0;
   16341              :             }
   16342              :         }
   16343              : 
   16344          483 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   16345            0 :             for (int loop = 1; loop <= state.dataRefrigCase->NumSimulationWalkIns; ++loop) {
   16346            0 :                 WalkIn(loop).SensZoneCreditRate = 0.0;
   16347            0 :                 WalkIn(loop).LatZoneCreditRate = 0.0;
   16348              :             }
   16349              :         }
   16350          483 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   16351            0 :             for (auto &e : RefrigCase) {
   16352            0 :                 e.SensZoneCreditRate = 0.0;
   16353            0 :                 e.SensHVACCreditRate = 0.0;
   16354            0 :                 e.LatZoneCreditRate = 0.0;
   16355            0 :                 e.LatHVACCreditRate = 0.0;
   16356              :             }
   16357              :         }
   16358          483 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = false;
   16359              :     }
   16360       249958 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   16361       249475 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = true;
   16362              :     }
   16363       249958 : }
   16364              : 
   16365            0 : 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            0 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16380            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   16381              : 
   16382            0 :     int DemandARRID = 0; // Index to water tank Demand used for evap condenser
   16383              : 
   16384            0 :     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            0 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   16404              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   16405            0 :         for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
   16406            0 :             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            0 :             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            0 : }
   16421              : 
   16422              : } // namespace EnergyPlus::RefrigeratedCase
        

Generated by: LCOV version 2.0-1