LCOV - code coverage report
Current view: top level - EnergyPlus - RefrigeratedCase.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 19.0 % 8039 1525
Test Date: 2025-05-22 16:09:37 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) return;
     346              : 
     347            5 :     CheckRefrigerationInput(state);
     348              : 
     349            5 :     InitRefrigeration(state);
     350              : 
     351              :     // ManageRefrigeratedCaseRacks is called on each zone time step.
     352              :     //  However, if have chillers, ManageRefrigeration will be .TRUE. and will
     353              :     //  need to bounce back. (InitRefrig has to be called anyway to zero values at zone time step.)
     354              :     //  Therefore...
     355            5 :     if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->UseSysTimeStep)) {
     356              :         // Zero requests for cooling water from plant or tank
     357            0 :         ZeroHVACValues(state);
     358            0 :         return;
     359              :     }
     360              :     // Following case should never occur, but just for completeness:
     361            5 :     if ((!state.dataRefrigCase->HaveChillers) && (state.dataRefrigCase->UseSysTimeStep)) return;
     362              : 
     363              :     // Refrigerated cases are not simulated the first time through, replicate this on beginning of next environment
     364            5 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->MyEnvrnFlag) {
     365            0 :         state.dataRefrigCase->MyEnvrnFlag = false;
     366            0 :         return;
     367              :     }
     368            5 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->MyEnvrnFlag = true;
     369              : 
     370            5 :     if (state.dataRefrigCase->HaveRefrigRacks) {
     371           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
     372            5 :             RefrigRack(RackNum).CalcRackSystem(state);
     373            5 :             RefrigRack(RackNum).ReportRackSystem(state, RackNum);
     374              :         }
     375              :     }
     376              : 
     377            5 :     if (state.dataRefrigCase->HaveDetailedRefrig) SimulateDetailedRefrigerationSystems(state);
     378            5 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) SimulateDetailedTransRefrigSystems(state);
     379              : }
     380              : 
     381          150 : void GetRefrigerationInput(EnergyPlusData &state)
     382              : {
     383              : 
     384              :     // SUBROUTINE INFORMATION:
     385              :     //       AUTHOR         Richard Raustad, FSEC
     386              :     //       DATE WRITTEN   Oct/Nov 2004
     387              :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
     388              :     //       MODIFIED       Stovall, ORNL April 2008, Assisted by Hugh Henderson
     389              :     //       RE-ENGINEERED  na
     390              : 
     391              :     // PURPOSE OF THIS SUBROUTINE:
     392              :     // GetObjectItem is called to read refrigerated case, rack, compressor, and condenser information
     393              :     // Lists of cases and compressors are then correlated to the appropriate system.
     394              :     // The nominal ratings of all components are then compared and a warning is printed if the system is not balanced
     395              : 
     396              :     // METHODOLOGY EMPLOYED:
     397              :     // GetObjectItem is called to read refrigerated case information
     398              : 
     399              :     static constexpr std::string_view TrackMessage("from refrigerated case");
     400              :     static constexpr std::string_view RoutineName("GetRefrigerationInput: ");
     401              :     static constexpr std::string_view routineName = "GetRefrigerationInput";
     402              :     static constexpr std::string_view TrackMessageAlt("GetInput in RefrigeratedCase");
     403              : 
     404              :     //     input in both watts and flow rate
     405          150 :     int constexpr NumWIAlphaFieldsBeforeZoneInput(9);   // Used to cycle through zones on input for walk in coolers
     406          150 :     int constexpr NumWIAlphaFieldsPerZone(4);           // Used to cycle through zones on input for walk in coolers
     407          150 :     int constexpr NumWINumberFieldsBeforeZoneInput(12); // Used to cycle through zones on input for walk in coolers
     408          150 :     int constexpr NumWINumberFieldsPerZone(8);          // Used to cycle through zones on input for walk in coolers
     409          150 :     Real64 constexpr CondARI460DelT(16.7);              // Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
     410          150 :     Real64 constexpr CondARI460Tcond(51.7);             // Rated sat cond temp for air-cooled cond, ARI 460
     411          150 :     Real64 constexpr CondARI490DelT(15.0);              // Rated sat cond temp - wet bulb air T for evap-cooled Cond w R22, ARI490
     412          150 :     Real64 constexpr CondARI490Tcond(40.6);             // Rated sat cond temp for evap-cooled cond with R22, ARI 490
     413          150 :     Real64 constexpr DelEvapTDefault(5.0);              // default difference between case T and evap T (C)
     414          150 :     Real64 constexpr DefaultCascadeCondApproach(3.0);   // Cascade condenser approach temperature difference (deltaC)
     415          150 :     Real64 constexpr DefaultCircRate(2.5);              // Phase change liquid overfeed circulating rate (ASHRAE definition)
     416          150 :     Real64 constexpr DefaultWISurfaceUValue(0.3154);    // equiv R18 in Archaic American units (W/m2-delta T)
     417          150 :     Real64 constexpr DefaultWIUValueGlassDr(1.136);     // equiv R5 in Archaic American units (W/m2-delta T)
     418          150 :     Real64 constexpr DefaultWIUValueStockDr(0.3785);    // equiv R15 in Archaic American units (W/m2-delta T)
     419          150 :     Real64 constexpr DefaultWIHeightGlassDr(1.5);       // glass door height in walk-in cooler (m)
     420          150 :     Real64 constexpr DefaultWIHeightStockDr(3.0);       // stock door height in walk-in cooler (m)
     421          150 :     Real64 constexpr PumpImpellerEfficiency(0.78);      // same as used in pump auto-sizing, dimensionless
     422          150 :     Real64 constexpr PumpMotorEfficiency(0.85);         // suggested as average value in ITT/Gould pump references,
     423              : 
     424          150 :     Array1D_string Alphas;             // Alpha items for object
     425          150 :     Array1D_string cAlphaFieldNames;   // Alpha field names (from input processor)
     426          150 :     Array1D_string cNumericFieldNames; // Numeric field names (from input processor)
     427          150 :     std::string CurrentModuleObject;   // Object type for getting and error messages
     428              : 
     429          150 :     Array1D_bool lAlphaBlanks;   // Logic array, alpha input blank = .TRUE.
     430          150 :     Array1D_bool lNumericBlanks; // Logic array, numeric input blank = .TRUE.
     431          150 :     bool ErrorsFound(false);     // Set to true if errors in input, fatal at end of routine
     432              : 
     433          150 :     int AlphaNum(0);                       // Used to cycle through input
     434          150 :     int IOStatus(0);                       // Used in GetObjectItem
     435          150 :     int MaxNumAlphasRack(0);               // Maximum number of alphas for rack object
     436          150 :     int MaxNumAlphasAirChiller(0);         // Maximum number of alphas for air chiller
     437          150 :     int MaxNumAlphasAll(0);                // Maximum number of alphas for all objects
     438          150 :     int MaxNumAlphasSys(0);                // Maximum number of alphas for system object
     439          150 :     int MaxNumAlphasTransSys(0);           // Maximum number of alphas for transcritical system object
     440          150 :     int MaxNumAlphasChillerSet(0);         // Maximum number of alphas for chiller set
     441          150 :     int MaxNumAlphasConda(0);              // Maximum number of alphas for air-cooled condenser object
     442          150 :     int MaxNumAlphasConde(0);              // Maximum number of alphas for evap-cooled condenser object
     443          150 :     int MaxNumAlphasCondw(0);              // Maximum number of alphas for water-cooled condenser object
     444          150 :     int MaxNumAlphasGasCoolera(0);         // Maximum number of alphas for air-cooled gas cooler object
     445          150 :     int MaxNumAlphasComp(0);               // Maximum number of alphas for compressor object
     446          150 :     int MaxNumAlphasCompressorList(0);     // Maximum number of alphas for compressor list objects
     447          150 :     int MaxNumAlphasCase(0);               // Maximum number of alphas for case object
     448          150 :     int MaxNumAlphasCaseAndWalkInList(0);  // Maximum number of alphas in CaseAndWalkInList
     449          150 :     int MaxNumAlphasWalkIn(0);             // Maximum number of alphas for walkin object
     450          150 :     int MaxNumAlphasSecond(0);             // Maximum number of alphas for air chiller object
     451          150 :     int MaxNumNumbersAirChiller(0);        // Maximum number of numbers for air chiller object
     452          150 :     int MaxNumNumbersSecond(0);            // Maximum number of numbers for secondary system object
     453          150 :     int MaxNumNumbersWalkIn(0);            // Maximum number of numbers for walkin object
     454          150 :     int MaxNumNumbersCase(0);              // Maximum number of numbers for case object
     455          150 :     int MaxNumNumbersCaseAndWalkInList(0); // Maximum number of numbers in CaseAndWalkInList
     456          150 :     int MaxNumNumbersRack(0);              // Maximum number of numbers for rack object
     457          150 :     int MaxNumNumbersAll(0);               // Maximum number of numeric inputs for all objects
     458          150 :     int MaxNumNumbersSys(0);               // Maximum number of numbers for system object
     459          150 :     int MaxNumNumbersTransSys(0);          // Maximum number of numbers for transcritical system object
     460          150 :     int MaxNumNumbersChillerSet(0);        // Maximum number of numbers for chiller set object
     461          150 :     int MaxNumNumbersConda(0);             // Maximum number of numbers for air-cooled condenser object
     462          150 :     int MaxNumNumbersConde(0);             // Maximum number of numbers for evap-cooled condenser object
     463          150 :     int MaxNumNumbersCondw(0);             // Maximum number of numbers for water-cooled condenser object
     464          150 :     int MaxNumNumbersGasCoolera(0);        // Maximum number of numbers for air-cooled gas cooler object
     465          150 :     int MaxNumNumbersComp(0);              // Maximum number of numbers for compressor object
     466          150 :     int MaxNumNumbersCompressorList(0);    // Maximum number of numbers
     467          150 :     int MaxNumArgs(0);                     // Max number of alphas and numbers (arguments) for rack object
     468          150 :     int NumAlphas(0);                      // Number of Alphas for each GetObjectItem call
     469          150 :     int NumCases(0);                       // Number of refrigerated cases for single system
     470          150 :     int NumNum(0);                         // Used to cycle through input
     471          150 :     int NumNumbers(0);                     // Number of Numbers for each GetObjectItem call
     472          150 :     int NumDisplayCases(0);                // Counter for refrigerated cases in GetInput do loop
     473          150 :     int NumWalkIns(0);                     // Number of walk ins
     474          150 :     int RefrigSysNum(0);
     475          150 :     int RefrigIndex(0);                // Index used in fluid property routines
     476          150 :     Real64 DeltaHPhaseChange(0.0);     // Secondary loop enthalpy change in condenser w overfeed system (J/g)
     477          150 :     Real64 DelTempMin(0.0);            // min temperature for heat rej curve for air cooled condenser (C)
     478          150 :     Real64 DelTempMax(0.0);            // max temperature for heat rej curve for air cooled condenser (C)
     479          150 :     Real64 DensityBrineRated(0.0);     // density of circ fluid in secondary loop
     480          150 :     Real64 DensityPhaseChange(0.0);    // Secondary loop density at condensing temperature w overfeed system (g/m3)
     481          150 :     Real64 NominalTotalCompCapLP(0.0); // Total of nominal low pressure compressor capacities, used for rough input check (W) (Transcritical CO2)
     482          150 :     Real64 NominalTotalCompCapHP(0.0);
     483          150 :     Array1D<Real64> Numbers;   // Numeric items for object
     484          150 :     Array2D<Real64> DayValues; // Array of schedule values
     485              : 
     486          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
     487          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     488          150 :     auto &CaseRAFraction = state.dataRefrigCase->CaseRAFraction;
     489          150 :     auto &System = state.dataRefrigCase->System;
     490          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
     491          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
     492          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
     493          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
     494          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
     495          150 :     auto &CaseAndWalkInList = state.dataRefrigCase->CaseAndWalkInList;
     496          150 :     auto &CompressorLists = state.dataRefrigCase->CompressorLists;
     497          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
     498          150 :     auto &TransferLoadList = state.dataRefrigCase->TransferLoadList;
     499          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
     500          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
     501          150 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
     502          150 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
     503          150 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
     504              : 
     505          300 :     state.dataRefrigCase->NumSimulationCascadeCondensers =
     506          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:Cascade");
     507          150 :     state.dataRefrigCase->NumSimulationCases = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Case");
     508          300 :     state.dataRefrigCase->NumSimulationCaseAndWalkInLists =
     509          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CaseAndWalkInList");
     510          150 :     state.dataRefrigCase->NumRefrigeratedRacks = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorRack");
     511          300 :     state.dataRefrigCase->NumSimulationSecondarySystems =
     512          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:SecondarySystem");
     513          300 :     state.dataRefrigCase->NumSimulationTransferLoadLists =
     514          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TransferLoadList");
     515          150 :     state.dataRefrigCase->NumSimulationWalkIns = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:WalkIn");
     516          150 :     state.dataRefrigCase->NumRefrigSystems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:System");
     517          300 :     state.dataRefrigCase->NumTransRefrigSystems =
     518          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TranscriticalSystem");
     519          300 :     state.dataRefrigCase->NumSimulationCondAir =
     520          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:AirCooled");
     521          300 :     state.dataRefrigCase->NumSimulationCondEvap =
     522          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:EvaporativeCooled");
     523          300 :     state.dataRefrigCase->NumSimulationCondWater =
     524          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:WaterCooled");
     525          300 :     state.dataRefrigCase->NumSimulationGasCooler =
     526          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:GasCooler:AirCooled");
     527          150 :     state.dataRefrigCase->NumRefrigCondensers = state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
     528          150 :                                                 state.dataRefrigCase->NumSimulationCondWater + state.dataRefrigCase->NumSimulationCascadeCondensers;
     529          150 :     state.dataRefrigCase->NumSimulationCompressors = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Compressor");
     530          150 :     state.dataRefrigCase->NumSimulationSubcoolers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Subcooler");
     531          150 :     int NumCompressorLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorList");
     532          300 :     state.dataRefrigCase->NumRefrigChillerSets =
     533          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneHVAC:RefrigerationChillerSet");
     534          300 :     state.dataRefrigCase->NumSimulationRefrigAirChillers =
     535          150 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:AirChiller");
     536              : 
     537              :     // Set flags used later to avoid unnecessary steps.
     538          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks == 0) state.dataRefrigCase->HaveRefrigRacks = false;
     539          150 :     if (state.dataRefrigCase->NumRefrigSystems == 0) state.dataRefrigCase->HaveDetailedRefrig = false;
     540          150 :     if (state.dataRefrigCase->NumTransRefrigSystems == 0) state.dataRefrigCase->HaveDetailedTransRefrig = false;
     541          150 :     if (state.dataRefrigCase->NumSimulationCases == 0 && state.dataRefrigCase->NumSimulationWalkIns == 0)
     542          145 :         state.dataRefrigCase->HaveCasesOrWalkins = false;
     543          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers == 0) state.dataRefrigCase->HaveChillers = false;
     544              : 
     545          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
     546            5 :         RefrigRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     547            5 :         state.dataHeatBal->HeatReclaimRefrigeratedRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     548              :     }
     549          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
     550            0 :         System.allocate(state.dataRefrigCase->NumRefrigSystems);
     551            0 :         state.dataRefrigCase->ShowUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     552            0 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     553            0 :         state.dataRefrigCase->ShowUnmetEnergyWarning = true;
     554            0 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning = true;
     555              :     }
     556          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
     557            0 :         TransSystem.allocate(state.dataRefrigCase->NumTransRefrigSystems);
     558            0 :         state.dataRefrigCase->ShowUnmetEnergyWarningTrans.dimension(state.dataRefrigCase->NumTransRefrigSystems, true);
     559              :     }
     560          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) AirChillerSet.allocate(state.dataRefrigCase->NumRefrigChillerSets);
     561          150 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
     562            0 :         state.dataHeatBal->HeatReclaimRefrigCondenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     563            0 :         Condenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     564            0 :         state.dataRefrigCase->UniqueCondenserNames.reserve(static_cast<unsigned>(state.dataRefrigCase->NumRefrigCondensers));
     565              :     }
     566          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
     567            0 :         GasCooler.allocate(state.dataRefrigCase->NumSimulationGasCooler);
     568              :     }
     569          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     570            3 :         CaseRAFraction.allocate(state.dataGlobal->NumOfZones);
     571            3 :         RefrigCase.allocate(state.dataRefrigCase->NumSimulationCases);
     572              :     }
     573          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
     574            3 :         WalkIn.allocate(state.dataRefrigCase->NumSimulationWalkIns);
     575              :     }
     576          150 :     if ((state.dataRefrigCase->NumSimulationWalkIns > 0) || (state.dataRefrigCase->NumSimulationCases > 0)) {
     577            5 :         CaseWIZoneReport.allocate(state.dataGlobal->NumOfZones);
     578              :     } else {
     579          145 :         state.dataRefrigCase->UseSysTimeStep = true;
     580              :         // needed to avoid accessing unallocated caseWIZoneReport on early call to SumZones
     581              :     }
     582          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
     583            0 :         Secondary.allocate(state.dataRefrigCase->NumSimulationSecondarySystems);
     584            0 :         state.dataRefrigCase->ShowUnmetSecondEnergyWarning.dimension(state.dataRefrigCase->NumSimulationSecondarySystems, true);
     585              :     }
     586          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
     587            0 :         WarehouseCoil.allocate(state.dataRefrigCase->NumSimulationRefrigAirChillers);
     588            0 :         CoilSysCredit.allocate(state.dataGlobal->NumOfZones);
     589              :     }
     590          150 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) Compressor.allocate(state.dataRefrigCase->NumSimulationCompressors);
     591          150 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) Subcooler.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
     592          150 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) CaseAndWalkInList.allocate(state.dataRefrigCase->NumSimulationCaseAndWalkInLists);
     593          150 :     if (NumCompressorLists > 0) CompressorLists.allocate(NumCompressorLists);
     594          150 :     if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) TransferLoadList.allocate(state.dataRefrigCase->NumSimulationTransferLoadLists);
     595              : 
     596          150 :     DayValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay);
     597          150 :     state.dataRefrigCase->RefrigPresentInZone.dimension(state.dataGlobal->NumOfZones, false);
     598              : 
     599          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:Case", MaxNumArgs, MaxNumAlphasCase, MaxNumNumbersCase);
     600          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     601              :         state, "Refrigeration:CaseAndWalkInList", MaxNumArgs, MaxNumAlphasCaseAndWalkInList, MaxNumNumbersCaseAndWalkInList);
     602          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     603              :         state, "Refrigeration:CompressorRack", MaxNumArgs, MaxNumAlphasRack, MaxNumNumbersRack);
     604          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:System", MaxNumArgs, MaxNumAlphasSys, MaxNumNumbersSys);
     605          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     606              :         state, "Refrigeration:TranscriticalSystem", MaxNumArgs, MaxNumAlphasTransSys, MaxNumNumbersTransSys);
     607          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     608              :         state, "Refrigeration:Condenser:AirCooled", MaxNumArgs, MaxNumAlphasConda, MaxNumNumbersConda);
     609          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     610              :         state, "Refrigeration:Condenser:EvaporativeCooled", MaxNumArgs, MaxNumAlphasConde, MaxNumNumbersConde);
     611          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     612              :         state, "Refrigeration:Condenser:WaterCooled", MaxNumArgs, MaxNumAlphasCondw, MaxNumNumbersCondw);
     613          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     614              :         state, "Refrigeration:GasCooler:AirCooled", MaxNumArgs, MaxNumAlphasGasCoolera, MaxNumNumbersGasCoolera);
     615          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     616              :         state, "Refrigeration:Compressor", MaxNumArgs, MaxNumAlphasComp, MaxNumNumbersComp);
     617          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     618              :         state, "Refrigeration:CompressorList", MaxNumArgs, MaxNumAlphasCompressorList, MaxNumNumbersCompressorList);
     619          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     620              :         state, "Refrigeration:WalkIn", MaxNumArgs, MaxNumAlphasWalkIn, MaxNumNumbersWalkIn);
     621          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     622              :         state, "Refrigeration:SecondarySystem", MaxNumArgs, MaxNumAlphasSecond, MaxNumNumbersSecond);
     623          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     624              :         state, "ZoneHVAC:RefrigerationChillerSet", MaxNumArgs, MaxNumAlphasChillerSet, MaxNumNumbersChillerSet);
     625          150 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     626              :         state, "Refrigeration:AirChiller", MaxNumArgs, MaxNumAlphasAirChiller, MaxNumNumbersAirChiller);
     627              : 
     628          150 :     MaxNumAlphasAll = max(MaxNumAlphasCase,
     629              :                           MaxNumAlphasCaseAndWalkInList,
     630              :                           MaxNumAlphasRack,
     631              :                           MaxNumAlphasSys,
     632              :                           MaxNumAlphasTransSys,
     633              :                           MaxNumAlphasConda,
     634              :                           MaxNumAlphasConde,
     635              :                           MaxNumAlphasCondw,
     636              :                           MaxNumAlphasGasCoolera,
     637              :                           MaxNumAlphasComp,
     638              :                           MaxNumAlphasCompressorList,
     639              :                           MaxNumAlphasSecond,
     640              :                           MaxNumAlphasWalkIn,
     641              :                           MaxNumAlphasChillerSet,
     642              :                           MaxNumAlphasAirChiller);
     643          150 :     MaxNumNumbersAll = max(MaxNumNumbersCase,
     644              :                            MaxNumNumbersCaseAndWalkInList,
     645              :                            MaxNumNumbersRack,
     646              :                            MaxNumNumbersSys,
     647              :                            MaxNumNumbersTransSys,
     648              :                            MaxNumNumbersConda,
     649              :                            MaxNumNumbersConde,
     650              :                            MaxNumNumbersCondw,
     651              :                            MaxNumNumbersGasCoolera,
     652              :                            MaxNumNumbersComp,
     653              :                            MaxNumNumbersCompressorList,
     654              :                            MaxNumNumbersSecond,
     655              :                            MaxNumNumbersWalkIn,
     656              :                            MaxNumNumbersChillerSet,
     657              :                            MaxNumNumbersAirChiller);
     658              : 
     659          150 :     Alphas.allocate(MaxNumAlphasAll);
     660          150 :     Numbers.dimension(MaxNumNumbersAll, 0.0);
     661          150 :     cAlphaFieldNames.allocate(MaxNumAlphasAll);
     662          150 :     cNumericFieldNames.allocate(MaxNumNumbersAll);
     663          150 :     lAlphaBlanks.dimension(MaxNumAlphasAll, true);
     664          150 :     lNumericBlanks.dimension(MaxNumNumbersAll, true);
     665              :     // bbb stovall note for future - for all curve entries, see if need fail on type or if can allow table input
     666          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     667            3 :         CurrentModuleObject = "Refrigeration:Case";
     668            6 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
     669            3 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     670              :                                                                      CurrentModuleObject,
     671              :                                                                      CaseNum,
     672              :                                                                      Alphas,
     673              :                                                                      NumAlphas,
     674              :                                                                      Numbers,
     675              :                                                                      NumNumbers,
     676              :                                                                      IOStatus,
     677              :                                                                      lNumericBlanks,
     678              :                                                                      lAlphaBlanks,
     679              :                                                                      cAlphaFieldNames,
     680              :                                                                      cNumericFieldNames);
     681              : 
     682            3 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
     683              : 
     684            3 :             ++NumDisplayCases;
     685              : 
     686            3 :             AlphaNum = 1;
     687            3 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
     688            3 :             RefrigCase(CaseNum).Name = Alphas(AlphaNum);
     689              : 
     690            3 :             AlphaNum = 2;
     691            3 :             if (lAlphaBlanks(AlphaNum)) {
     692            3 :                 RefrigCase(CaseNum).availSched = Sched::GetScheduleAlwaysOn(state);
     693            0 :             } else if ((RefrigCase(CaseNum).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
     694            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
     695            0 :                 ErrorsFound = true;
     696            0 :             } else if (!RefrigCase(CaseNum).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
     697            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
     698            0 :                 ErrorsFound = true;
     699              :             }
     700              : 
     701              :             // Get the Zone node number from the zone name entered by the user
     702            3 :             RefrigCase(CaseNum).ZoneName = Alphas(3);
     703            3 :             RefrigCase(CaseNum).ActualZoneNum = Util::FindItemInList(Alphas(3), state.dataHeatBal->Zone);
     704              : 
     705            3 :             if (RefrigCase(CaseNum).ActualZoneNum == 0) {
     706            0 :                 ShowSevereError(state,
     707            0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
     708              :                                        RoutineName,
     709              :                                        CurrentModuleObject,
     710            0 :                                        RefrigCase(CaseNum).Name,
     711              :                                        cAlphaFieldNames(3),
     712              :                                        Alphas(3)));
     713            0 :                 ErrorsFound = true;
     714              :             } else {
     715            3 :                 state.dataRefrigCase->RefrigPresentInZone(RefrigCase(CaseNum).ActualZoneNum) = true;
     716              :             }
     717              : 
     718            3 :             RefrigCase(CaseNum).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigCase(CaseNum).ActualZoneNum);
     719              : 
     720            3 :             RefrigCase(CaseNum).RatedAmbientTemp = Numbers(1);
     721            3 :             if (Numbers(1) <= 0.0) {
     722            0 :                 ShowSevereError(state,
     723            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 C",
     724              :                                        RoutineName,
     725              :                                        CurrentModuleObject,
     726            0 :                                        RefrigCase(CaseNum).Name,
     727              :                                        cNumericFieldNames(1)));
     728            0 :                 ErrorsFound = true;
     729              :             }
     730              : 
     731            3 :             RefrigCase(CaseNum).RatedAmbientRH = Numbers(2);
     732            3 :             if (Numbers(2) <= 0.0 || Numbers(2) >= 100.0) {
     733            0 :                 ShowSevereError(state,
     734            0 :                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
     735              :                                        RoutineName,
     736              :                                        CurrentModuleObject,
     737            0 :                                        RefrigCase(CaseNum).Name,
     738              :                                        cNumericFieldNames(2)));
     739            0 :                 ErrorsFound = true;
     740              :             }
     741            6 :             RefrigCase(CaseNum).RatedAmbientDewPoint = Psychrometrics::PsyTdpFnWPb(
     742              :                 state,
     743            3 :                 Psychrometrics::PsyWFnTdbRhPb(
     744            3 :                     state, RefrigCase(CaseNum).RatedAmbientTemp, (RefrigCase(CaseNum).RatedAmbientRH / 100.0), state.dataEnvrn->StdBaroPress),
     745            3 :                 state.dataEnvrn->StdBaroPress);
     746              : 
     747            3 :             RefrigCase(CaseNum).RateTotCapPerLength = Numbers(3);
     748            3 :             if (Numbers(3) <= 0.0) {
     749            0 :                 ShowSevereError(state,
     750            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m",
     751              :                                        RoutineName,
     752              :                                        CurrentModuleObject,
     753            0 :                                        RefrigCase(CaseNum).Name,
     754              :                                        cNumericFieldNames(3)));
     755            0 :                 ErrorsFound = true;
     756              :             }
     757              : 
     758            3 :             RefrigCase(CaseNum).RatedLHR = Numbers(4);
     759            3 :             if (Numbers(4) < 0.0 || Numbers(4) > 1.0) {
     760            0 :                 ShowSevereError(
     761              :                     state,
     762            0 :                     format(
     763            0 :                         "{}{}=\"{}\", {} must be >= 0 and <= 1", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name, cNumericFieldNames(4)));
     764            0 :                 ErrorsFound = true;
     765              :             }
     766              : 
     767            3 :             RefrigCase(CaseNum).RatedRTF = Numbers(5);
     768            3 :             if (Numbers(5) <= 0.0 || Numbers(5) > 1.0) {
     769            0 :                 ShowSevereError(state,
     770            0 :                                 format("{}{}=\"{}\", {} must be > 0 and <= to 1",
     771              :                                        RoutineName,
     772              :                                        CurrentModuleObject,
     773            0 :                                        RefrigCase(CaseNum).Name,
     774              :                                        cNumericFieldNames(5)));
     775            0 :                 ErrorsFound = true;
     776              :             }
     777              : 
     778            3 :             RefrigCase(CaseNum).Length = Numbers(6);
     779            3 :             if (Numbers(6) <= 0.0) {
     780            0 :                 ShowSevereError(state,
     781            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 m",
     782              :                                        RoutineName,
     783              :                                        CurrentModuleObject,
     784            0 :                                        RefrigCase(CaseNum).Name,
     785              :                                        cNumericFieldNames(6)));
     786            0 :                 ErrorsFound = true;
     787              :             }
     788              : 
     789            3 :             RefrigCase(CaseNum).Temperature = Numbers(7);
     790            3 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientTemp) {
     791            0 :                 ShowSevereError(state,
     792            0 :                                 format("{}{}=\"{}\", {} must be below {}",
     793              :                                        RoutineName,
     794              :                                        CurrentModuleObject,
     795            0 :                                        RefrigCase(CaseNum).Name,
     796              :                                        cNumericFieldNames(7),
     797              :                                        cNumericFieldNames(1)));
     798            0 :                 ErrorsFound = true;
     799              :             }
     800              : 
     801            3 :             RefrigCase(CaseNum).LatentEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(4)));
     802            3 :             if (RefrigCase(CaseNum).LatentEnergyCurveType == EnergyEqnForm::Invalid) {
     803            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(4), Alphas(4));
     804            0 :                 ErrorsFound = true;
     805              :             }
     806              : 
     807            3 :             RefrigCase(CaseNum).LatCapCurvePtr = Curve::GetCurveIndex(state, Alphas(5)); // convert curve name to number
     808            3 :             if (RefrigCase(CaseNum).LatCapCurvePtr == 0) {
     809            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
     810            0 :                 ErrorsFound = true;
     811              :             }
     812              : 
     813            9 :             ErrorsFound |= Curve::CheckCurveDims(state,
     814            3 :                                                  RefrigCase(CaseNum).LatCapCurvePtr, // Curve index
     815              :                                                  {1},                                // Valid dimensions
     816              :                                                  RoutineName,                        // Routine name
     817              :                                                  CurrentModuleObject,                // Object Type
     818            3 :                                                  RefrigCase(CaseNum).Name,           // Object Name
     819            3 :                                                  cAlphaFieldNames(5));               // Field Name
     820              : 
     821            3 :             NumNum = 8;
     822            3 :             if (!lNumericBlanks(NumNum)) {
     823            3 :                 RefrigCase(CaseNum).STDFanPower = Numbers(NumNum);
     824            3 :                 if (Numbers(NumNum) < 0.0) {
     825            0 :                     ShowSevereError(state,
     826            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     827              :                                            RoutineName,
     828              :                                            CurrentModuleObject,
     829            0 :                                            RefrigCase(CaseNum).Name,
     830              :                                            cNumericFieldNames(NumNum)));
     831            0 :                     ErrorsFound = true;
     832              :                 }
     833              :             } else { // blank use default of 75 W/m
     834            0 :                 RefrigCase(CaseNum).STDFanPower = 75.0;
     835              :             } // blank input
     836              : 
     837            3 :             NumNum = 9;
     838            3 :             if (!lNumericBlanks(NumNum)) {
     839            3 :                 RefrigCase(CaseNum).OperatingFanPower = Numbers(NumNum);
     840            3 :                 if (Numbers(NumNum) < 0.0) {
     841            0 :                     ShowSevereError(state,
     842            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     843              :                                            RoutineName,
     844              :                                            CurrentModuleObject,
     845            0 :                                            RefrigCase(CaseNum).Name,
     846              :                                            cNumericFieldNames(NumNum)));
     847            0 :                     ErrorsFound = true;
     848              :                 }
     849              :             } else { // if blank set = to std fan power
     850            0 :                 RefrigCase(CaseNum).OperatingFanPower = RefrigCase(CaseNum).STDFanPower;
     851              :             } // if blank
     852              : 
     853            3 :             NumNum = 10;
     854            3 :             if (!lNumericBlanks(NumNum)) {
     855            3 :                 RefrigCase(CaseNum).RatedLightingPower = Numbers(NumNum);
     856            3 :                 if (Numbers(NumNum) < 0.0) {
     857            0 :                     ShowSevereError(state,
     858            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     859              :                                            RoutineName,
     860              :                                            CurrentModuleObject,
     861            0 :                                            RefrigCase(CaseNum).Name,
     862              :                                            cNumericFieldNames(NumNum)));
     863            0 :                     ErrorsFound = true;
     864              :                 }
     865              :             } else { // blank input - use default of 90 W/m
     866            0 :                 RefrigCase(CaseNum).RatedLightingPower = 90.0;
     867              :             } // blank input
     868              : 
     869            3 :             NumNum = 11;
     870            3 :             if (!lNumericBlanks(NumNum)) {
     871            0 :                 RefrigCase(CaseNum).LightingPower = Numbers(NumNum);
     872            0 :                 if (Numbers(NumNum) < 0.0) {
     873            0 :                     ShowSevereError(state,
     874            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     875              :                                            RoutineName,
     876              :                                            CurrentModuleObject,
     877            0 :                                            RefrigCase(CaseNum).Name,
     878              :                                            cNumericFieldNames(NumNum)));
     879            0 :                     ErrorsFound = true;
     880              :                 }
     881              :             } else { // blank input so set lighting power equal to rated/std lighting power
     882            3 :                 RefrigCase(CaseNum).LightingPower = RefrigCase(CaseNum).RatedLightingPower;
     883              :             } // blank input
     884              : 
     885            3 :             if (lAlphaBlanks(6)) {
     886            0 :                 RefrigCase(CaseNum).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
     887            3 :             } else if ((RefrigCase(CaseNum).lightingSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) {
     888            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), Alphas(6));
     889            0 :                 ErrorsFound = true;
     890            3 :             } else if (!RefrigCase(CaseNum).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
     891            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(6), Alphas(6), Clusive::In, 0.0, Clusive::In, 1.0);
     892            0 :                 ErrorsFound = true;
     893              :             }
     894              : 
     895            3 :             NumNum = 12;
     896            3 :             RefrigCase(CaseNum).LightingFractionToCase = 1.0; // default value
     897            3 :             if (!lNumericBlanks(NumNum)) {
     898            3 :                 RefrigCase(CaseNum).LightingFractionToCase = Numbers(NumNum);
     899              :             } // blank input lighting fraction to case
     900              :             //   check lighting fraction to case input
     901            3 :             if (RefrigCase(CaseNum).LightingFractionToCase < 0.0 || RefrigCase(CaseNum).LightingFractionToCase > 1.0) {
     902            0 :                 ShowSevereError(state,
     903            0 :                                 format("{}{}=\"{}\", {} has a value outside the valid range",
     904              :                                        RoutineName,
     905              :                                        CurrentModuleObject,
     906            0 :                                        RefrigCase(CaseNum).Name,
     907              :                                        cNumericFieldNames(NumNum)));
     908            0 :                 ShowContinueError(state, "  Minimum should be >= 0.0 and Maximum should be <= 1.0");
     909            0 :                 ErrorsFound = true;
     910              :             }
     911              : 
     912            3 :             NumNum = 13;
     913            3 :             RefrigCase(CaseNum).AntiSweatPower = Numbers(NumNum);
     914            3 :             if (Numbers(NumNum) < 0.0) {
     915            0 :                 ShowSevereError(state,
     916            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     917              :                                        RoutineName,
     918              :                                        CurrentModuleObject,
     919            0 :                                        RefrigCase(CaseNum).Name,
     920              :                                        cNumericFieldNames(NumNum)));
     921            0 :                 ErrorsFound = true;
     922              :             }
     923              : 
     924            3 :             NumNum = 14;
     925            3 :             RefrigCase(CaseNum).MinimumASPower = Numbers(NumNum);
     926            3 :             if (Numbers(NumNum) < 0.0) {
     927            0 :                 ShowSevereError(state,
     928            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     929              :                                        RoutineName,
     930              :                                        CurrentModuleObject,
     931            0 :                                        RefrigCase(CaseNum).Name,
     932              :                                        cNumericFieldNames(NumNum)));
     933            0 :                 ErrorsFound = true;
     934              :             }
     935              : 
     936            3 :             RefrigCase(CaseNum).AntiSweatControlType = static_cast<ASHtrCtrlType>(getEnumValue(asHtrCtrlTypeNamesUC, Alphas(7)));
     937            3 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Invalid) {
     938            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(7), Alphas(7));
     939            0 :                 ErrorsFound = true;
     940            3 :             } else if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::None) {
     941            3 :                 RefrigCase(CaseNum).AntiSweatPower = 0.0;
     942              :             }
     943              : 
     944              :             //   Assure that case temperature is below the rated dew point when anti-sweat heater control type is dew point method
     945            3 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientDewPoint &&
     946            0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::DewPoint) {
     947            0 :                 ShowSevereError(state,
     948            0 :                                 format("{}{}=\"{}\", {} must be below the Rated Ambient Dew Point when {} is Dew Point Method",
     949              :                                        RoutineName,
     950              :                                        CurrentModuleObject,
     951            0 :                                        RefrigCase(CaseNum).Name,
     952              :                                        cNumericFieldNames(7),
     953              :                                        cAlphaFieldNames(7)));
     954            0 :                 ErrorsFound = true;
     955              :             }
     956              : 
     957            3 :             NumNum = 15;
     958              :             //  negative values for minimum humidity are allowed
     959            3 :             RefrigCase(CaseNum).HumAtZeroAS = Numbers(NumNum);
     960              : 
     961              :             //   check minimum humidity when linear AS control type is used
     962            3 :             if (RefrigCase(CaseNum).HumAtZeroAS >= RefrigCase(CaseNum).RatedAmbientRH &&
     963            0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Linear) {
     964            0 :                 ShowSevereError(state,
     965            0 :                                 format("{}{}=\"{}\", {} must be less than {}",
     966              :                                        RoutineName,
     967              :                                        CurrentModuleObject,
     968            0 :                                        RefrigCase(CaseNum).Name,
     969              :                                        cNumericFieldNames(NumNum),
     970              :                                        cNumericFieldNames(2)));
     971            0 :                 ShowContinueError(state, format(" for Linear {}.", cAlphaFieldNames(7)));
     972            0 :                 ErrorsFound = true;
     973              :             }
     974              : 
     975            3 :             NumNum = 16;
     976            3 :             RefrigCase(CaseNum).Height = Numbers(NumNum);
     977            3 :             if (Numbers(NumNum) < 0.0) {
     978            0 :                 ShowSevereError(state,
     979            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 m",
     980              :                                        RoutineName,
     981              :                                        CurrentModuleObject,
     982            0 :                                        RefrigCase(CaseNum).Name,
     983              :                                        cNumericFieldNames(NumNum)));
     984            0 :                 ErrorsFound = true;
     985              :             }
     986              : 
     987            3 :             if (RefrigCase(CaseNum).Height <= 0.0 && RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
     988            0 :                 ShowSevereError(state,
     989            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 when {} is Heat Balance Method.",
     990              :                                        RoutineName,
     991              :                                        CurrentModuleObject,
     992            0 :                                        RefrigCase(CaseNum).Name,
     993              :                                        cNumericFieldNames(NumNum),
     994              :                                        cAlphaFieldNames(7)));
     995            0 :                 ShowContinueError(state, format("..given {} was: {:.3R}", cNumericFieldNames(NumNum), RefrigCase(CaseNum).Height));
     996            0 :                 ErrorsFound = true;
     997              :             }
     998              : 
     999              :             //   initialize case resistance for anti-sweat heater control type = Heat Balance Method
    1000            3 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
    1001            0 :                 Real64 Rcase(0.0);      // Case thermal resistance used with anti-sweat heater control
    1002            0 :                 Real64 RcaseDenom(0.0); // Denominator of case thermal resistance calculation for anti-sweat
    1003              : 
    1004            0 :                 if (RefrigCase(CaseNum).Height == 0.0) {
    1005            0 :                     Rcase = 0.0;
    1006              :                 } else {
    1007            0 :                     RcaseDenom = ((RefrigCase(CaseNum).AntiSweatPower / RefrigCase(CaseNum).Height) -
    1008            0 :                                   (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).RatedAmbientTemp) / Rair);
    1009            0 :                     Rcase = (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).Temperature) / RcaseDenom;
    1010              :                 }
    1011            0 :                 RefrigCase(CaseNum).Rcase = max(0.0, Rcase);
    1012            0 :                 if (RefrigCase(CaseNum).Rcase == 0.0) {
    1013            0 :                     ShowWarningError(state,
    1014            0 :                                      format("{}=\"{}\" A case thermal resistance of 0 was calculated for anti-sweat heater performance using the",
    1015              :                                             CurrentModuleObject,
    1016            0 :                                             RefrigCase(CaseNum).Name));
    1017            0 :                     ShowContinueError(state,
    1018            0 :                                       format(" Heat Balance Method control type. Anti-sweat heater performance cannot be calculated and {} will be "
    1019              :                                              "set to None and simulation continues.",
    1020              :                                              cAlphaFieldNames(7)));
    1021            0 :                     ShowContinueError(state, " See Engineering Documentation for anti-sweat heater control of refrigerated cases.");
    1022              :                 }
    1023              :             }
    1024              : 
    1025            3 :             NumNum = 17;
    1026            3 :             RefrigCase(CaseNum).ASHeaterFractionToCase = Numbers(NumNum);
    1027            3 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
    1028            0 :                 ShowSevereError(state,
    1029            0 :                                 format("{}{}=\"{}\", {} must be >= 0 and <= 1",
    1030              :                                        RoutineName,
    1031              :                                        CurrentModuleObject,
    1032            0 :                                        RefrigCase(CaseNum).Name,
    1033              :                                        cNumericFieldNames(NumNum)));
    1034            0 :                 ErrorsFound = true;
    1035              :             }
    1036              : 
    1037              :             // Multiple strings mapping to the same enum is not good
    1038            3 :             if (Alphas(8) == "HOTGAS")
    1039            0 :                 Alphas(8) = "HOTFLUID";
    1040            3 :             else if (Alphas(8) == "HOTGASWITHTEMPERATURETERMINATION")
    1041            0 :                 Alphas(8) = "HOTFLUIDWITHTEMPERATURETERMINATION";
    1042              : 
    1043            3 :             RefrigCase(CaseNum).defrostType = static_cast<RefCaseDefrostType>(getEnumValue(refCaseDefrostTypeNamesUC, Alphas(8)));
    1044            3 :             if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::Invalid) {
    1045            0 :                 ShowWarningInvalidKey(state, eoh, cAlphaFieldNames(8), Alphas(8), "None");
    1046            0 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::None;
    1047              :             }
    1048              : 
    1049            3 :             RefCaseDefrostType DefType = RefrigCase(CaseNum).defrostType;
    1050            3 :             NumNum = 18;
    1051            3 :             if (!lNumericBlanks(NumNum)) {
    1052            3 :                 RefrigCase(CaseNum).DefrostPower = Numbers(NumNum);
    1053            3 :                 if (Numbers(NumNum) < 0.0) {
    1054            0 :                     ShowSevereError(state,
    1055            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
    1056              :                                            RoutineName,
    1057              :                                            CurrentModuleObject,
    1058            0 :                                            RefrigCase(CaseNum).Name,
    1059              :                                            cNumericFieldNames(NumNum)));
    1060            0 :                     ErrorsFound = true;
    1061              :                 }
    1062              :                 //   disregard defrost power for Off-Cycle or None defrost types
    1063            3 :                 if ((DefType == RefCaseDefrostType::OffCycle || DefType == RefCaseDefrostType::None) && (RefrigCase(CaseNum).DefrostPower > 0.0)) {
    1064            0 :                     RefrigCase(CaseNum).DefrostPower = 0.0;
    1065            0 :                     ShowWarningError(state,
    1066            0 :                                      format("{}=\"{}\", {} for {} None or Off-Cycle will be set to 0 and simulation continues.",
    1067              :                                             CurrentModuleObject,
    1068            0 :                                             RefrigCase(CaseNum).Name,
    1069              :                                             cNumericFieldNames(NumNum),
    1070              :                                             cAlphaFieldNames(8)));
    1071              :                 }
    1072              :             } else {
    1073            0 :                 RefrigCase(CaseNum).DefrostPower = 0.0;
    1074              :             }
    1075              : 
    1076              :             // defrost power needed to calculate heat gain to case even if not needed for electric consumption
    1077            3 :             if ((DefType == RefCaseDefrostType::HotFluid || DefType == RefCaseDefrostType::HotFluidTerm || DefType == RefCaseDefrostType::Electric ||
    1078            6 :                  DefType == RefCaseDefrostType::ElectricTerm) &&
    1079            0 :                 RefrigCase(CaseNum).DefrostPower <= 0.0) {
    1080            0 :                 ShowSevereError(state,
    1081            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m for {} {}",
    1082              :                                        RoutineName,
    1083              :                                        CurrentModuleObject,
    1084            0 :                                        RefrigCase(CaseNum).Name,
    1085              :                                        cNumericFieldNames(NumNum),
    1086              :                                        cAlphaFieldNames(8),
    1087              :                                        Alphas(8)));
    1088            0 :                 ErrorsFound = true;
    1089              :             }
    1090              : 
    1091            3 :             if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::None) {
    1092            0 :             } else if (lAlphaBlanks(9)) {
    1093            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(9));
    1094            0 :                 ErrorsFound = true;
    1095            0 :             } else if ((RefrigCase(CaseNum).defrostSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) {
    1096            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9));
    1097            0 :                 ErrorsFound = true;
    1098            0 :             } else if (!RefrigCase(CaseNum).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1099            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), Alphas(9), Clusive::In, 0.0, Clusive::In, 1.0);
    1100            0 :                 ErrorsFound = true;
    1101              :             }
    1102              : 
    1103              :             //   Note that next section counting number cycles and setting maxkgfrost not used now, but may be in the future.
    1104              :             //   count the number of defrost cycles
    1105              : 
    1106              :             // Flag for counting defrost cycles
    1107            3 :             int NumDefCycles = 0;
    1108              : 
    1109            3 :             if (RefrigCase(CaseNum).defrostSched != nullptr) {
    1110            0 :                 bool StartCycle = false;
    1111            0 :                 std::vector<Real64> const &dayVals = RefrigCase(CaseNum).defrostSched->getDayVals(state, 1);
    1112            0 :                 for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) {
    1113            0 :                     if (dayVals[i] == 0.0) {
    1114            0 :                         StartCycle = false;
    1115            0 :                     } else if (!StartCycle) {
    1116            0 :                         ++NumDefCycles;
    1117            0 :                         StartCycle = true;
    1118              :                     }
    1119              :                 }
    1120              :             }
    1121              : 
    1122            3 :             if (NumDefCycles > 0) {
    1123              :                 //     calculate maximum frost formation based on defrost schedule, heat of vaporization+fusion for water = 2833.0 kJ/kg
    1124            0 :                 RefrigCase(CaseNum).MaxKgFrost =
    1125            0 :                     (RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF * Constant::rSecsInHour *
    1126            0 :                      Constant::rHoursInDay / 1000.0 / 2833.0) / // Parenthesize!!!
    1127              :                     (NumDefCycles);
    1128              :             } else {
    1129            3 :                 RefrigCase(CaseNum).MaxKgFrost = 9999999.9;
    1130              :             }
    1131              : 
    1132              :             //   some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1133            3 :             if (lAlphaBlanks(10)) {
    1134            3 :                 RefrigCase(CaseNum).defrostDripDownSched = RefrigCase(CaseNum).defrostSched;
    1135            0 :             } else if ((RefrigCase(CaseNum).defrostDripDownSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) {
    1136            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10));
    1137            0 :                 ErrorsFound = true;
    1138            0 :             } else if (!RefrigCase(CaseNum).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1139            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0, Clusive::In, 1.0);
    1140            0 :                 ErrorsFound = true;
    1141              :             }
    1142              : 
    1143            3 :             RefrigCase(CaseNum).DefrostEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(11)));
    1144            3 :             if (RefrigCase(CaseNum).DefrostEnergyCurveType == EnergyEqnForm::Invalid) {
    1145            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(11), Alphas(11));
    1146            0 :                 ErrorsFound = true;
    1147              :             }
    1148              : 
    1149            3 :             RefrigCase(CaseNum).DefCapCurvePtr = Curve::GetCurveIndex(state, Alphas(12)); // convert curve name to number
    1150            3 :             if ((RefrigCase(CaseNum).defrostType == RefCaseDefrostType::ElectricTerm ||
    1151            3 :                  RefrigCase(CaseNum).defrostType == RefCaseDefrostType::HotFluidTerm) &&
    1152            0 :                 (RefrigCase(CaseNum).DefCapCurvePtr == 0)) {
    1153            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(12), Alphas(12));
    1154            0 :                 ErrorsFound = true;
    1155              :             }
    1156              : 
    1157            3 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1158            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1159            0 :                                                      RefrigCase(CaseNum).DefCapCurvePtr, // Curve index
    1160              :                                                      {1},                                // Valid dimensions
    1161              :                                                      RoutineName,                        // Routine name
    1162              :                                                      CurrentModuleObject,                // Object Type
    1163            0 :                                                      RefrigCase(CaseNum).Name,           // Object Name
    1164            0 :                                                      cAlphaFieldNames(12));              // Field Name
    1165              :             }
    1166              : 
    1167              :             //  warn user if defrost energy curve is entered that it is only used for temperature termination types
    1168            3 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1169            0 :                 if (RefrigCase(CaseNum).defrostType != RefCaseDefrostType::ElectricTerm &&
    1170            0 :                     RefrigCase(CaseNum).defrostType != RefCaseDefrostType::HotFluidTerm) {
    1171            0 :                     ShowWarningError(state,
    1172            0 :                                      format("{}=\"{}\", invalid  {} is only applicable to Defrost Temperature Termination types.",
    1173              :                                             CurrentModuleObject,
    1174            0 :                                             RefrigCase(CaseNum).Name,
    1175              :                                             cAlphaFieldNames(12)));
    1176            0 :                     ShowContinueError(state, format("{} will be disregarded and simulation continues.", cAlphaFieldNames(12)));
    1177              :                 }
    1178              :             }
    1179              : 
    1180            3 :             NumNum = 19;
    1181            3 :             RefrigCase(CaseNum).RAFrac = Numbers(NumNum);
    1182            3 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
    1183            0 :                 ShowSevereError(state,
    1184            0 :                                 format("{}{}=\"{}\", {} must be >= 0 or <= 1 ",
    1185              :                                        RoutineName,
    1186              :                                        CurrentModuleObject,
    1187            0 :                                        RefrigCase(CaseNum).Name,
    1188              :                                        cNumericFieldNames(NumNum)));
    1189            0 :                 ErrorsFound = true;
    1190              :             }
    1191              : 
    1192              :             // Set return air node number
    1193            3 :             RefrigCase(CaseNum).ZoneRANode = 0;
    1194            3 :             std::string retNodeName;
    1195            3 :             if (!lAlphaBlanks(15)) {
    1196            0 :                 retNodeName = Alphas(15);
    1197              :             }
    1198            3 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1199            0 :                 std::string callDescription = CurrentModuleObject + "=" + RefrigCase(CaseNum).Name;
    1200            0 :                 RefrigCase(CaseNum).ZoneRANode =
    1201            0 :                     DataZoneEquipment::GetReturnAirNodeForZone(state, RefrigCase(CaseNum).ActualZoneNum, retNodeName, callDescription);
    1202            0 :             }
    1203              : 
    1204            3 :             if (RefrigCase(CaseNum).ActualZoneNum >= 0) {
    1205            3 :                 if (RefrigCase(CaseNum).ZoneNodeNum == 0) {
    1206            0 :                     ShowSevereError(state,
    1207            0 :                                     format("{}{}=\"{}\", System Node Number not found for {} = {}",
    1208              :                                            RoutineName,
    1209              :                                            CurrentModuleObject,
    1210            0 :                                            RefrigCase(CaseNum).Name,
    1211              :                                            cAlphaFieldNames(3),
    1212              :                                            Alphas(3)));
    1213            0 :                     ShowContinueError(state,
    1214              :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object).");
    1215            0 :                     ErrorsFound = true;
    1216              :                 }
    1217            3 :                 if ((RefrigCase(CaseNum).RAFrac > 0.0) && (RefrigCase(CaseNum).ZoneRANode == 0)) {
    1218            0 :                     ShowSevereError(state,
    1219            0 :                                     format("{}{}=\"{}\", Under Case HVAC Return Air Node number not found for {} = {}",
    1220              :                                            RoutineName,
    1221              :                                            CurrentModuleObject,
    1222            0 :                                            RefrigCase(CaseNum).Name,
    1223              :                                            cAlphaFieldNames(3),
    1224              :                                            Alphas(3)));
    1225            0 :                     ShowContinueError(state,
    1226              :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object) "
    1227              :                                       "with at least one return air node.");
    1228            0 :                     ErrorsFound = true;
    1229              :                 }
    1230              :             }
    1231              : 
    1232              :             // set flag in Zone Data if RAFrac > 0
    1233            3 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1234            0 :                 state.dataHeatBal->Zone(RefrigCase(CaseNum).ActualZoneNum).RefrigCaseRA = true;
    1235              :             }
    1236              : 
    1237              :             //   Make sure RA node exists for display cases with under case HVAC returns
    1238            3 :             if (RefrigCase(CaseNum).ZoneRANode == 0 && RefrigCase(CaseNum).RAFrac > 0.0) {
    1239            0 :                 ShowSevereError(state,
    1240            0 :                                 format("{}{}=\"{}\", {} not applicable to zones without return air systems.",
    1241              :                                        RoutineName,
    1242              :                                        CurrentModuleObject,
    1243            0 :                                        RefrigCase(CaseNum).Name,
    1244              :                                        cNumericFieldNames(19)));
    1245            0 :                 ErrorsFound = true;
    1246              :             }
    1247              : 
    1248            3 :             if (RefrigCase(CaseNum).ActualZoneNum != 0) {
    1249            3 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).TotalCaseRAFraction += RefrigCase(CaseNum).RAFrac;
    1250            3 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).ZoneName = RefrigCase(CaseNum).ZoneName;
    1251              :             }
    1252              : 
    1253            3 :             if (lAlphaBlanks(13)) {
    1254            3 :             } else if ((RefrigCase(CaseNum).stockingSched = Sched::GetSchedule(state, Alphas(13))) == nullptr) {
    1255            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(13), Alphas(13));
    1256            0 :                 ErrorsFound = true;
    1257              :             }
    1258              : 
    1259              :             //   calculate sensible case load at design conditions
    1260              :             // Case sensible capacity used for error messages
    1261            3 :             Real64 DesignSensibleCap = RefrigCase(CaseNum).RateTotCapPerLength * (1.0 - RefrigCase(CaseNum).RatedLHR) * RefrigCase(CaseNum).RatedRTF *
    1262            3 :                                        RefrigCase(CaseNum).Length;
    1263              : 
    1264              :             //   calculate case heat gain = lights + fans + anti-sweat
    1265              :             Real64 CaseHeatGain =
    1266            3 :                 ((RefrigCase(CaseNum).RatedLightingPower * RefrigCase(CaseNum).LightingFractionToCase) +
    1267            3 :                  (RefrigCase(CaseNum).AntiSweatPower * RefrigCase(CaseNum).ASHeaterFractionToCase) + RefrigCase(CaseNum).STDFanPower) *
    1268            3 :                 RefrigCase(CaseNum).Length;
    1269              : 
    1270              :             //   sensible case credits are calculated as the difference between the design sensible capacity and the case heat gain
    1271            3 :             RefrigCase(CaseNum).DesignSensCaseCredit = DesignSensibleCap - CaseHeatGain;
    1272              : 
    1273              :             //   compare case loads to design capacity
    1274            3 :             if (DesignSensibleCap < CaseHeatGain) {
    1275            0 :                 ShowSevereError(
    1276              :                     state,
    1277            0 :                     format("{}{}=\"{}\", the sum of lighting, fan, and anti-sweat heater energy is greater than refrigerated case sensible capacity",
    1278              :                            RoutineName,
    1279              :                            CurrentModuleObject,
    1280            0 :                            RefrigCase(CaseNum).Name));
    1281            0 :                 ErrorsFound = true;
    1282              :             }
    1283              : 
    1284            3 :             if (lAlphaBlanks(14)) {
    1285            0 :             } else if ((RefrigCase(CaseNum).caseCreditFracSched = Sched::GetSchedule(state, Alphas(14))) == nullptr) {
    1286            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(14), Alphas(14));
    1287            0 :                 ErrorsFound = true;
    1288            0 :             } else if (!RefrigCase(CaseNum).caseCreditFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1289            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(14), Alphas(14), Clusive::In, 0.0, Clusive::In, 1.0);
    1290            0 :                 ErrorsFound = true;
    1291              :             }
    1292              : 
    1293            3 :             RefrigCase(CaseNum).DesignRatedCap = RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).Length;
    1294            3 :             RefrigCase(CaseNum).DesignLatentCap = RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF;
    1295            3 :             RefrigCase(CaseNum).DesignDefrostCap = RefrigCase(CaseNum).DefrostPower * RefrigCase(CaseNum).Length;
    1296            3 :             RefrigCase(CaseNum).DesignLighting = RefrigCase(CaseNum).LightingPower * RefrigCase(CaseNum).Length;
    1297            3 :             RefrigCase(CaseNum).DesignFanPower = RefrigCase(CaseNum).OperatingFanPower * RefrigCase(CaseNum).Length;
    1298              : 
    1299              :             // Design evaporating temperature:  for a DX system, saturated temperature for pressure leaving case
    1300              :             //                              :  for a liquid system, liquid temperature entering case
    1301            3 :             NumNum = 20;
    1302            3 :             if (!lNumericBlanks(NumNum)) {
    1303            0 :                 RefrigCase(CaseNum).EvapTempDesign = Numbers(NumNum);
    1304            0 :                 if (RefrigCase(CaseNum).EvapTempDesign >= RefrigCase(CaseNum).Temperature) {
    1305            0 :                     ShowSevereError(state,
    1306            0 :                                     format("{}{}=\"{}\" {} must be below {}",
    1307              :                                            RoutineName,
    1308              :                                            CurrentModuleObject,
    1309            0 :                                            RefrigCase(CaseNum).Name,
    1310              :                                            cNumericFieldNames(NumNum),
    1311              :                                            cNumericFieldNames(7)));
    1312            0 :                     ErrorsFound = true;
    1313              :                 }
    1314              :             } else {
    1315            3 :                 RefrigCase(CaseNum).EvapTempDesign = RefrigCase(CaseNum).Temperature - DelEvapTDefault;
    1316              :                 //    default 5C less than case operating temperature
    1317              :             }
    1318              : 
    1319            3 :             NumNum = 21;
    1320            3 :             if (!lNumericBlanks(NumNum)) {
    1321            0 :                 RefrigCase(CaseNum).RefrigInventory = Numbers(NumNum);
    1322            0 :                 RefrigCase(CaseNum).DesignRefrigInventory = RefrigCase(CaseNum).RefrigInventory * RefrigCase(CaseNum).Length;
    1323            0 :                 if (RefrigCase(CaseNum).RefrigInventory < 0.0) {
    1324            0 :                     ShowSevereError(state,
    1325            0 :                                     format("{}{}=\"{}\" {} must be a positive number.",
    1326              :                                            RoutineName,
    1327              :                                            CurrentModuleObject,
    1328            0 :                                            RefrigCase(CaseNum).Name,
    1329              :                                            cNumericFieldNames(NumNum)));
    1330            0 :                     ErrorsFound = true;
    1331              :                 }
    1332              :             } else {
    1333            3 :                 RefrigCase(CaseNum).RefrigInventory = 0.0;
    1334              :             }
    1335              : 
    1336            3 :         } // Individual refrigerated cases
    1337              :     }     //(NumSimulationCases > 0 )
    1338              : 
    1339              :     //************ START WALK IN COOLER INPUT **************
    1340              : 
    1341          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    1342            3 :         CurrentModuleObject = "Refrigeration:WalkIn";
    1343            6 :         for (int WalkInID = 1; WalkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInID) {
    1344            3 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1345              :                                                                      CurrentModuleObject,
    1346              :                                                                      WalkInID,
    1347              :                                                                      Alphas,
    1348              :                                                                      NumAlphas,
    1349              :                                                                      Numbers,
    1350              :                                                                      NumNumbers,
    1351              :                                                                      IOStatus,
    1352              :                                                                      lNumericBlanks,
    1353              :                                                                      lAlphaBlanks,
    1354              :                                                                      cAlphaFieldNames,
    1355              :                                                                      cNumericFieldNames);
    1356              : 
    1357            3 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1358              : 
    1359            3 :             WalkIn(WalkInID).Name = Alphas(1);
    1360              : 
    1361            3 :             if (lAlphaBlanks(2)) {
    1362            0 :                 WalkIn(WalkInID).availSched = Sched::GetScheduleAlwaysOn(state);
    1363            3 :             } else if ((WalkIn(WalkInID).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) {
    1364            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    1365            0 :                 ErrorsFound = true;
    1366            3 :             } else if (!WalkIn(WalkInID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1367            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(2), Alphas(2), Clusive::In, 0.0, Clusive::In, 1.0);
    1368            0 :                 ErrorsFound = true;
    1369              :             }
    1370              : 
    1371            3 :             WalkIn(WalkInID).DesignRatedCap = Numbers(1);
    1372            3 :             if (Numbers(1) <= 0.0) {
    1373            0 :                 ShowSevereError(
    1374              :                     state,
    1375            0 :                     format(
    1376            0 :                         "{}{}=\"{}\", {} must be greater than 0 W", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(1)));
    1377            0 :                 ErrorsFound = true;
    1378              :             }
    1379              : 
    1380            3 :             if (!lNumericBlanks(2)) {
    1381            3 :                 WalkIn(WalkInID).Temperature = Numbers(2);
    1382              :             } else {
    1383            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(2));
    1384            0 :                 ErrorsFound = true;
    1385              :             }
    1386              : 
    1387            3 :             if (!lNumericBlanks(3)) {
    1388            3 :                 WalkIn(WalkInID).TEvapDesign = Numbers(3);
    1389              :             } else {
    1390            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(3));
    1391            0 :                 ErrorsFound = true;
    1392              :             }
    1393              : 
    1394            3 :             if (!lNumericBlanks(4)) {
    1395            3 :                 WalkIn(WalkInID).HeaterPower = Numbers(4);
    1396              :             } else {
    1397            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(4));
    1398            0 :                 ErrorsFound = true;
    1399              :             }
    1400              : 
    1401            3 :             AlphaNum = 3;
    1402            3 :             if (lAlphaBlanks(AlphaNum)) {
    1403            0 :                 WalkIn(WalkInID).heaterSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1404            3 :             } else if ((WalkIn(WalkInID).heaterSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1405            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1406            0 :                 ErrorsFound = true;
    1407            3 :             } else if (!WalkIn(WalkInID).heaterSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1408            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1409            0 :                 ErrorsFound = true;
    1410              :             }
    1411              : 
    1412            3 :             if (!lNumericBlanks(5) && Numbers(5) > 0.0) {
    1413            3 :                 WalkIn(WalkInID).CoilFanPower = Numbers(5);
    1414              :             } else {
    1415            0 :                 ShowWarningError(state,
    1416            0 :                                  format("{}{}=\"{}\", {} was not input or was less than 0 and default of 375.0 W will be used ",
    1417              :                                         RoutineName,
    1418              :                                         CurrentModuleObject,
    1419            0 :                                         WalkIn(WalkInID).Name,
    1420              :                                         cNumericFieldNames(5)));
    1421            0 :                 WalkIn(WalkInID).CoilFanPower = 375.0; // default value = 1/2 hp
    1422              :             }
    1423              : 
    1424            3 :             if (lNumericBlanks(6)) {
    1425            0 :                 WalkIn(WalkInID).CircFanPower = 0.0;
    1426              :             } else {
    1427            3 :                 WalkIn(WalkInID).CircFanPower = Numbers(6);
    1428            3 :                 if (Numbers(7) < 0.0) {
    1429            0 :                     ShowSevereError(state,
    1430            0 :                                     format("{}{}=\"{}\", {} must be greater than >= 0 W",
    1431              :                                            RoutineName,
    1432              :                                            CurrentModuleObject,
    1433            0 :                                            WalkIn(WalkInID).Name,
    1434              :                                            cNumericFieldNames(6)));
    1435            0 :                     ErrorsFound = true;
    1436              :                 }
    1437              :             }
    1438              : 
    1439            3 :             if (!lNumericBlanks(7)) {
    1440            3 :                 WalkIn(WalkInID).DesignLighting = Numbers(7);
    1441              :             } else {
    1442            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(7));
    1443            0 :                 ErrorsFound = true;
    1444              :             }
    1445              : 
    1446            3 :             AlphaNum = 4;
    1447            3 :             if (lAlphaBlanks(AlphaNum)) {
    1448            0 :                 WalkIn(WalkInID).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1449            3 :             } else if ((WalkIn(WalkInID).lightingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1450            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1451            0 :                 ErrorsFound = true;
    1452            3 :             } else if (!WalkIn(WalkInID).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1453            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1454            0 :                 ErrorsFound = true;
    1455              :             }
    1456              : 
    1457              :             // Input walk-in cooler defrost information
    1458            3 :             AlphaNum = 5;
    1459            3 :             if (lAlphaBlanks(AlphaNum)) {
    1460            0 :                 WalkIn(WalkInID).defrostType = DefrostType::Elec;
    1461            3 :             } else if ((WalkIn(WalkInID).defrostType = static_cast<DefrostType>(getEnumValue(defrostTypeNamesUC, Alphas(AlphaNum)))) ==
    1462              :                        DefrostType::Invalid) {
    1463            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1464            0 :                 ErrorsFound = true;
    1465              :             }
    1466              : 
    1467            3 :             AlphaNum = 6;
    1468            3 :             if (lAlphaBlanks(AlphaNum)) {
    1469            0 :                 WalkIn(WalkInID).DefrostControlType = DefrostCtrlType::Sched;
    1470            3 :             } else if ((WalkIn(WalkInID).DefrostControlType = static_cast<DefrostCtrlType>(getEnumValue(defrostCtrlTypeNamesUC, Alphas(AlphaNum)))) ==
    1471              :                        DefrostCtrlType::Invalid) {
    1472            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1473            0 :                 ErrorsFound = true;
    1474              :             } // defrost control type
    1475              : 
    1476              :             // convert defrost schedule name to pointer
    1477            3 :             AlphaNum = 7;
    1478              : 
    1479            3 :             if (lAlphaBlanks(AlphaNum)) {
    1480            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1481            0 :                 ErrorsFound = true;
    1482            3 :             } else if ((WalkIn(WalkInID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1483            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1484            0 :                 ErrorsFound = true;
    1485            3 :             } else if (!WalkIn(WalkInID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1486            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1487            0 :                 ErrorsFound = true;
    1488              :             }
    1489              : 
    1490              :             // convert defrost drip-down schedule name to pointer
    1491              :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1492            3 :             AlphaNum = 8;
    1493            3 :             if (lAlphaBlanks(AlphaNum)) { // blank input so use drip down schedule for defrost
    1494            3 :                 WalkIn(WalkInID).defrostDripDownSched = WalkIn(WalkInID).defrostSched;
    1495            0 :             } else if ((WalkIn(WalkInID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1496            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1497            0 :                 ErrorsFound = true;
    1498            0 :             } else if (!WalkIn(WalkInID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1499            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1500            0 :                 ErrorsFound = true;
    1501              :             }
    1502              : 
    1503            3 :             if (WalkIn(WalkInID).defrostType == DefrostType::OffCycle || WalkIn(WalkInID).defrostType == DefrostType::None) {
    1504            0 :                 WalkIn(WalkInID).DefrostCapacity = 0.0;
    1505              :                 // Don't even need to read N8 or N9 for those two defrost types.
    1506              :             } else { // have electric or hot gas/brine defrost
    1507            3 :                 if ((lNumericBlanks(8)) || (Numbers(8) <= 0.0)) {
    1508            0 :                     ShowSevereError(state,
    1509            0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    1510              :                                            RoutineName,
    1511              :                                            CurrentModuleObject,
    1512            0 :                                            WalkIn(WalkInID).Name,
    1513              :                                            cNumericFieldNames(8),
    1514              :                                            cAlphaFieldNames(5),
    1515              :                                            Alphas(5)));
    1516            0 :                     ErrorsFound = true;
    1517              :                 } else {
    1518            3 :                     WalkIn(WalkInID).DefrostCapacity = Numbers(8);
    1519              :                 } // Blank  or negative N8
    1520              : 
    1521              :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    1522              :                 // note this value is only used for temperature terminated defrost control type
    1523            3 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Elec) WalkIn(WalkInID).DefEnergyFraction = 0.7;
    1524            3 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Fluid) WalkIn(WalkInID).DefEnergyFraction = 0.3;
    1525            3 :                 if (!lNumericBlanks(9)) {
    1526            0 :                     if ((Numbers(9) > 1.0) || (Numbers(9) < 0.0)) {
    1527            0 :                         ShowWarningError(state,
    1528            0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    1529              :                                                 RoutineName,
    1530              :                                                 CurrentModuleObject,
    1531            0 :                                                 WalkIn(WalkInID).Name,
    1532              :                                                 cNumericFieldNames(9)));
    1533              :                     } else {
    1534            0 :                         WalkIn(WalkInID).DefEnergyFraction = Numbers(9);
    1535              :                     } // number out of range
    1536              :                 }     // lnumericblanks
    1537              :             }         // defrost type
    1538              : 
    1539              :             // convert restocking schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1540            3 :             AlphaNum = 9;
    1541            3 :             if (lAlphaBlanks(AlphaNum)) {
    1542            0 :             } else if ((WalkIn(WalkInID).stockingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1543            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1544            0 :                 ErrorsFound = true;
    1545              :             }
    1546              : 
    1547            3 :             WalkIn(WalkInID).DesignRefrigInventory = 0.0;
    1548            3 :             if (!lNumericBlanks(10)) WalkIn(WalkInID).DesignRefrigInventory = Numbers(10);
    1549              : 
    1550            3 :             if (!lNumericBlanks(11)) {
    1551            3 :                 WalkIn(WalkInID).FloorArea = Numbers(11);
    1552              :             } else {
    1553            0 :                 ShowSevereError(
    1554            0 :                     state, format("{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(11)));
    1555            0 :                 ErrorsFound = true;
    1556              :             }
    1557              : 
    1558            3 :             if (lNumericBlanks(12)) {
    1559            0 :                 WalkIn(WalkInID).FloorUValue = DefaultWISurfaceUValue;
    1560              :             } else {
    1561            3 :                 WalkIn(WalkInID).FloorUValue = Numbers(12);
    1562            3 :                 if (Numbers(12) <= 0.0) {
    1563            0 :                     ShowSevereError(
    1564              :                         state,
    1565            0 :                         format("{}{}=\"{}\", {} must be > 0.", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(12)));
    1566            0 :                     ErrorsFound = true;
    1567              :                 }
    1568              :             }
    1569              : 
    1570              :             // Calculate the number of zones exposed to walk-in based on number of input fields, all integer math,
    1571              :             // This approach used because last zone could have less than NumWIFieldsPerZone due to optional values
    1572            3 :             int NumWIFieldsPerZone = NumWIAlphaFieldsPerZone + NumWINumberFieldsPerZone;
    1573            3 :             int NumWIFieldsTotal = NumNumbers + NumAlphas - NumWIAlphaFieldsBeforeZoneInput - NumWINumberFieldsBeforeZoneInput;
    1574            3 :             int NumZones = 1;
    1575            3 :             if (NumWIFieldsTotal > NumWIFieldsPerZone) NumZones = 2;
    1576            3 :             if (NumWIFieldsTotal > (2 * NumWIFieldsPerZone)) NumZones = 3;
    1577            3 :             if (NumWIFieldsTotal > (3 * NumWIFieldsPerZone)) NumZones = 4;
    1578            3 :             if (NumWIFieldsTotal > (4 * NumWIFieldsPerZone)) NumZones = 5;
    1579            3 :             if (NumWIFieldsTotal > (5 * NumWIFieldsPerZone)) NumZones = 6;
    1580            3 :             WalkIn(WalkInID).NumZones = NumZones;
    1581              : 
    1582              :             // All variables for walk-in/zone interactions need to be allocated after know number of zones
    1583              :             // Autodesk Missing initialization added below: At least SensZoneCreditRate was used uninitialized
    1584            3 :             if (!allocated(WalkIn(WalkInID).ZoneName)) WalkIn(WalkInID).ZoneName.allocate(NumZones);
    1585            3 :             if (!allocated(WalkIn(WalkInID).ZoneNum)) WalkIn(WalkInID).ZoneNum.allocate(NumZones) = 0;
    1586            3 :             if (!allocated(WalkIn(WalkInID).ZoneNodeNum)) WalkIn(WalkInID).ZoneNodeNum.allocate(NumZones) = 0;
    1587            3 :             if (!allocated(WalkIn(WalkInID).SurfaceArea)) WalkIn(WalkInID).SurfaceArea.allocate(NumZones) = 0.0;
    1588            3 :             if (!allocated(WalkIn(WalkInID).UValue)) WalkIn(WalkInID).UValue.allocate(NumZones) = 0.0;
    1589            3 :             if (!allocated(WalkIn(WalkInID).UValueGlassDr)) WalkIn(WalkInID).UValueGlassDr.allocate(NumZones) = 0.0;
    1590            3 :             if (!allocated(WalkIn(WalkInID).glassDoorOpenScheds)) WalkIn(WalkInID).glassDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1591            3 :             if (!allocated(WalkIn(WalkInID).AreaGlassDr)) WalkIn(WalkInID).AreaGlassDr.allocate(NumZones) = 0.0;
    1592            3 :             if (!allocated(WalkIn(WalkInID).HeightGlassDr)) WalkIn(WalkInID).HeightGlassDr.allocate(NumZones) = 0.0;
    1593            3 :             if (!allocated(WalkIn(WalkInID).UValueStockDr)) WalkIn(WalkInID).UValueStockDr.allocate(NumZones) = 0.0;
    1594            3 :             if (!allocated(WalkIn(WalkInID).stockDoorOpenScheds)) WalkIn(WalkInID).stockDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1595            3 :             if (!allocated(WalkIn(WalkInID).StockDoorProtectType)) WalkIn(WalkInID).StockDoorProtectType.allocate(NumZones) = WIStockDoor::Invalid;
    1596            3 :             if (!allocated(WalkIn(WalkInID).AreaStockDr)) WalkIn(WalkInID).AreaStockDr.allocate(NumZones) = 0.0;
    1597            3 :             if (!allocated(WalkIn(WalkInID).HeightStockDr)) WalkIn(WalkInID).HeightStockDr.allocate(NumZones) = 0.0;
    1598            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditRate)) WalkIn(WalkInID).SensZoneCreditRate.allocate(NumZones) = 0.0;
    1599            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCoolRate)) WalkIn(WalkInID).SensZoneCreditCoolRate.allocate(NumZones) = 0.0;
    1600            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCool)) WalkIn(WalkInID).SensZoneCreditCool.allocate(NumZones) = 0.0;
    1601            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeatRate)) WalkIn(WalkInID).SensZoneCreditHeatRate.allocate(NumZones) = 0.0;
    1602            3 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeat)) WalkIn(WalkInID).SensZoneCreditHeat.allocate(NumZones) = 0.0;
    1603            3 :             if (!allocated(WalkIn(WalkInID).LatZoneCreditRate)) WalkIn(WalkInID).LatZoneCreditRate.allocate(NumZones) = 0.0;
    1604            3 :             if (!allocated(WalkIn(WalkInID).LatZoneCredit)) WalkIn(WalkInID).LatZoneCredit.allocate(NumZones) = 0.0;
    1605              : 
    1606            3 :             int AStart = NumWIAlphaFieldsBeforeZoneInput + 1;
    1607            3 :             int NStart = NumWINumberFieldsBeforeZoneInput + 1;
    1608            6 :             for (int ZoneID = 1; ZoneID <= NumZones; ++ZoneID) {
    1609              :                 // Get the Zone node number from the zone name
    1610              :                 // The Zone Node is needed to get the zone's ambient conditions, DataGlobals::NumOfZones from dataglobals
    1611            3 :                 WalkIn(WalkInID).ZoneName(ZoneID) = Alphas(AStart);
    1612            3 :                 WalkIn(WalkInID).ZoneNum(ZoneID) = Util::FindItemInList(Alphas(AStart), state.dataHeatBal->Zone);
    1613              : 
    1614            3 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) == 0) {
    1615            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart), Alphas(AStart));
    1616            0 :                     ErrorsFound = true;
    1617              :                 } else {
    1618            3 :                     state.dataRefrigCase->RefrigPresentInZone(WalkIn(WalkInID).ZoneNum(ZoneID)) = true;
    1619              :                 }
    1620            3 :                 WalkIn(WalkInID).ZoneNodeNum(ZoneID) = DataZoneEquipment::GetSystemNodeNumberForZone(state, WalkIn(WalkInID).ZoneNum(ZoneID));
    1621            3 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) >= 0) {
    1622            3 :                     if (WalkIn(WalkInID).ZoneNodeNum(ZoneID) == 0) {
    1623            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart), Alphas(AStart));
    1624            0 :                         ShowContinueError(state, ".. Walk Ins must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    1625            0 :                         ErrorsFound = true;
    1626              :                     }
    1627              :                 }
    1628              : 
    1629            3 :                 if (!lNumericBlanks(NStart)) {
    1630            3 :                     WalkIn(WalkInID).SurfaceArea(ZoneID) = Numbers(NStart);
    1631              :                 } else {
    1632            0 :                     ShowSevereError(state,
    1633            0 :                                     format("{}{}=\"{}\", {} must be input for Zone: {}",
    1634              :                                            RoutineName,
    1635              :                                            CurrentModuleObject,
    1636            0 :                                            WalkIn(WalkInID).Name,
    1637              :                                            cNumericFieldNames(NStart),
    1638            0 :                                            WalkIn(WalkInID).ZoneName(ZoneID)));
    1639            0 :                     ErrorsFound = true;
    1640              :                 }
    1641              : 
    1642            3 :                 if (lNumericBlanks(NStart + 1)) {
    1643            0 :                     WalkIn(WalkInID).UValue(ZoneID) = DefaultWISurfaceUValue;
    1644              :                 } else {
    1645            3 :                     WalkIn(WalkInID).UValue(ZoneID) = Numbers(NStart + 1);
    1646            3 :                     if (Numbers(NStart + 1) <= 0.0) {
    1647            0 :                         ShowSevereError(state,
    1648            0 :                                         format(R"({}{}="{}", Zone="{}", {} must be > 0.)",
    1649              :                                                RoutineName,
    1650              :                                                CurrentModuleObject,
    1651            0 :                                                WalkIn(WalkInID).Name,
    1652            0 :                                                WalkIn(WalkInID).ZoneName(ZoneID),
    1653              :                                                cNumericFieldNames(NStart + 1)));
    1654            0 :                         ErrorsFound = true;
    1655              :                     }
    1656              :                 }
    1657              : 
    1658              :                 // start IF set for glass doors in this zone
    1659            3 :                 WalkIn(WalkInID).AreaGlassDr(ZoneID) = 0.0;
    1660            3 :                 WalkIn(WalkInID).HeightGlassDr(ZoneID) = 0.0;
    1661            3 :                 WalkIn(WalkInID).UValueGlassDr(ZoneID) = 0.0;
    1662            3 :                 if (!lNumericBlanks(NStart + 2)) {
    1663            0 :                     WalkIn(WalkInID).AreaGlassDr(ZoneID) = Numbers(NStart + 2);
    1664              : 
    1665            0 :                     WalkIn(WalkInID).HeightGlassDr(ZoneID) = DefaultWIHeightGlassDr;
    1666            0 :                     if (!lNumericBlanks(NStart + 3)) WalkIn(WalkInID).HeightGlassDr(ZoneID) = Numbers(NStart + 3);
    1667              : 
    1668            0 :                     WalkIn(WalkInID).UValueGlassDr(ZoneID) = DefaultWIUValueGlassDr;
    1669            0 :                     if (!lNumericBlanks(NStart + 4)) WalkIn(WalkInID).UValueGlassDr(ZoneID) = Numbers(NStart + 4);
    1670              : 
    1671              :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1672            0 :                     if (lAlphaBlanks(AStart + 1)) {
    1673            0 :                     } else if ((WalkIn(WalkInID).glassDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 1))) == nullptr) {
    1674            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1));
    1675            0 :                         ErrorsFound = true;
    1676            0 :                     } else if (!WalkIn(WalkInID).glassDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1677            0 :                         Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1), Clusive::In, 0.0, Clusive::In, 1.0);
    1678            0 :                         ErrorsFound = true;
    1679              :                     } // blank on door opening schedule (AStart + 1)
    1680              :                 }     // have glassdoor area facing zone (blank on lNumericBlanks(NStart+2))
    1681              : 
    1682              :                 // start IF set for stock doors in this zone
    1683            3 :                 WalkIn(WalkInID).AreaStockDr(ZoneID) = 0.0;
    1684            3 :                 WalkIn(WalkInID).HeightStockDr(ZoneID) = 0.0;
    1685            3 :                 WalkIn(WalkInID).UValueStockDr(ZoneID) = 0.0;
    1686            3 :                 if (!lNumericBlanks(NStart + 5)) {
    1687            3 :                     WalkIn(WalkInID).AreaStockDr(ZoneID) = Numbers(NStart + 5);
    1688              : 
    1689            3 :                     WalkIn(WalkInID).HeightStockDr(ZoneID) = DefaultWIHeightStockDr;
    1690            3 :                     if (!lNumericBlanks(NStart + 6)) WalkIn(WalkInID).HeightStockDr(ZoneID) = Numbers(NStart + 6);
    1691              : 
    1692            3 :                     WalkIn(WalkInID).UValueStockDr(ZoneID) = DefaultWIUValueStockDr;
    1693            3 :                     if (!lNumericBlanks(NStart + 7)) WalkIn(WalkInID).UValueStockDr(ZoneID) = Numbers(NStart + 7);
    1694              : 
    1695              :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1696            3 :                     if (lAlphaBlanks(AStart + 2)) {
    1697            0 :                     } else if ((WalkIn(WalkInID).stockDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 2))) == nullptr) {
    1698            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2));
    1699            0 :                         ErrorsFound = true;
    1700            0 :                     } else if (!WalkIn(WalkInID).stockDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1701            0 :                         Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2), Clusive::In, 0.0, Clusive::In, 1.0);
    1702            0 :                         ErrorsFound = true;
    1703              :                     } // blank on door opening schedule (AStart + 2)
    1704              : 
    1705            3 :                     if (lAlphaBlanks(AStart + 3)) {
    1706              :                         // default air curtain
    1707            0 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::AirCurtain;
    1708            3 :                     } else if ((WalkIn(WalkInID).StockDoorProtectType(ZoneID) =
    1709            6 :                                     static_cast<WIStockDoor>(getEnumValue(wiStockDoorNamesUC, Alphas(AStart + 3)))) == WIStockDoor::Invalid) {
    1710            0 :                         ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AStart + 3), Alphas(AStart + 3));
    1711            0 :                         ErrorsFound = true;
    1712              :                     } // stock door protection (AStart + 3) blank
    1713              :                 }     // have Stockdoor area facing zone
    1714              : 
    1715            3 :                 AStart += NumWIAlphaFieldsPerZone;
    1716            3 :                 NStart += NumWINumberFieldsPerZone;
    1717              :             } // Zones for Walk Ins
    1718              :         }     // Individual Walk Ins
    1719              :     }         //(NumSimulationWalkIns > 0 )
    1720              : 
    1721              :     //************* Start Indiv Refrig Air Chillers
    1722              : 
    1723          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    1724            0 :         CurrentModuleObject = "Refrigeration:AirChiller";
    1725            0 :         for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
    1726              :             // A1
    1727            0 :             AlphaNum = 1;
    1728            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1729              :                                                                      CurrentModuleObject,
    1730              :                                                                      CoilID,
    1731              :                                                                      Alphas,
    1732              :                                                                      NumAlphas,
    1733              :                                                                      Numbers,
    1734              :                                                                      NumNumbers,
    1735              :                                                                      IOStatus,
    1736              :                                                                      lNumericBlanks,
    1737              :                                                                      lAlphaBlanks,
    1738              :                                                                      cAlphaFieldNames,
    1739              :                                                                      cNumericFieldNames);
    1740              : 
    1741            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1742              : 
    1743            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1744              : 
    1745            0 :             WarehouseCoil(CoilID).Name = Alphas(AlphaNum);
    1746              : 
    1747              :             // A2
    1748            0 :             ++AlphaNum;
    1749            0 :             if (lAlphaBlanks(AlphaNum)) {
    1750            0 :                 WarehouseCoil(CoilID).availSched = Sched::GetScheduleAlwaysOn(state);
    1751            0 :             } else if ((WarehouseCoil(CoilID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1752            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1753            0 :                 ErrorsFound = true;
    1754            0 :             } else if (!WarehouseCoil(CoilID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1755            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1756            0 :                 ErrorsFound = true;
    1757              :             }
    1758              : 
    1759              :             // Input capacity rating type
    1760              :             // bbbbb input values (DT1 or DTM type)translate DT1 to DTm here because node will give avg temp?
    1761              :             //      ask whether ceiling or floor mounted? - effects translation from DT1 to DTM
    1762              :             //      input coil condition, wet or dry OR input rating basis, European SC1, SC2 etc., have to combine with refrigerant factor)
    1763              :             //      rated capacity, BAC give W/C, European gives W
    1764              :             //      fin material factor, default 1
    1765              :             //      refrigerant factor (factor of both refrigerant and Tevap)
    1766              : 
    1767              :             // A3
    1768            0 :             ++AlphaNum;
    1769            0 :             if (lAlphaBlanks(AlphaNum)) {
    1770            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1771            0 :                 ErrorsFound = true;
    1772            0 :             } else if ((WarehouseCoil(CoilID).ratingType = static_cast<RatingType>(getEnumValue(ratingTypeNamesUC, Alphas(AlphaNum)))) ==
    1773              :                        RatingType::Invalid) {
    1774              : 
    1775            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1776            0 :                 ErrorsFound = true;
    1777              :             }
    1778              : 
    1779              :             // Here have to do select case with one numeric field with units of W and the second with units of W/deltaC,
    1780              :             //  (RatedRH field only used for RatedCapacityTotal type)
    1781              :             { // Why is this a new scope
    1782            0 :                 switch (WarehouseCoil(CoilID).ratingType) {
    1783            0 :                 case RatingType::UnitLoadFactorSens: {
    1784              :                     // N1
    1785            0 :                     NumNum = 1;
    1786            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1787            0 :                         WarehouseCoil(CoilID).UnitLoadFactorSens = Numbers(NumNum);
    1788              :                     } else {
    1789            0 :                         ShowSevereError(state,
    1790            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W/C",
    1791              :                                                RoutineName,
    1792              :                                                CurrentModuleObject,
    1793            0 :                                                WarehouseCoil(CoilID).Name,
    1794              :                                                cNumericFieldNames(NumNum)));
    1795            0 :                         ErrorsFound = true;
    1796              :                     }
    1797            0 :                 } break;
    1798              : 
    1799            0 :                 case RatingType::RatedCapacityTotal: {
    1800              :                     // N2
    1801            0 :                     NumNum = 2; // advance past rating in W/C to N2 with rating in W
    1802            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1803            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1804              :                         // N3
    1805            0 :                         NumNum = 3; // read rated RH only for this type of rating at N3
    1806            0 :                         if (lNumericBlanks(NumNum)) {
    1807            0 :                             WarehouseCoil(CoilID).RatedRH = 0.85;
    1808              :                         } else {
    1809            0 :                             if (Numbers(NumNum) <= 0.0 || Numbers(NumNum) >= 100.0) {
    1810            0 :                                 ShowSevereError(state,
    1811            0 :                                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
    1812              :                                                        RoutineName,
    1813              :                                                        CurrentModuleObject,
    1814            0 :                                                        WarehouseCoil(CoilID).Name,
    1815              :                                                        cNumericFieldNames(NumNum)));
    1816            0 :                                 ErrorsFound = true;
    1817              :                             }
    1818            0 :                             WarehouseCoil(CoilID).RatedRH = Numbers(NumNum) / 100.0;
    1819              :                         }
    1820              :                     } else {
    1821            0 :                         ShowSevereError(state,
    1822            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1823              :                                                RoutineName,
    1824              :                                                CurrentModuleObject,
    1825            0 :                                                WarehouseCoil(CoilID).Name,
    1826              :                                                cNumericFieldNames(NumNum)));
    1827            0 :                         ErrorsFound = true;
    1828              :                     }
    1829            0 :                 } break;
    1830              : 
    1831            0 :                 case RatingType::EuropeanSC1Std: {
    1832              :                     // N2
    1833            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1834            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1835            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1836            0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    1837              :                     } else {
    1838            0 :                         ShowSevereError(state,
    1839            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1840              :                                                RoutineName,
    1841              :                                                CurrentModuleObject,
    1842            0 :                                                WarehouseCoil(CoilID).Name,
    1843              :                                                cNumericFieldNames(NumNum)));
    1844            0 :                         ErrorsFound = true;
    1845              :                     }
    1846            0 :                 } break;
    1847              : 
    1848            0 :                 case RatingType::EuropeanSC1Nom: {
    1849              :                     // N2
    1850            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1851            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1852            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1853            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[0];
    1854            0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    1855              :                     } else {
    1856            0 :                         ShowSevereError(state,
    1857            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1858              :                                                RoutineName,
    1859              :                                                CurrentModuleObject,
    1860            0 :                                                WarehouseCoil(CoilID).Name,
    1861              :                                                cNumericFieldNames(NumNum)));
    1862            0 :                         ErrorsFound = true;
    1863              :                     }
    1864            0 :                 } break;
    1865              : 
    1866            0 :                 case RatingType::EuropeanSC2Std: {
    1867              :                     // N2
    1868            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1869            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1870            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1871            0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    1872              :                     } else {
    1873            0 :                         ShowSevereError(state,
    1874            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1875              :                                                RoutineName,
    1876              :                                                CurrentModuleObject,
    1877            0 :                                                WarehouseCoil(CoilID).Name,
    1878              :                                                cNumericFieldNames(NumNum)));
    1879            0 :                         ErrorsFound = true;
    1880              :                     }
    1881            0 :                 } break;
    1882              : 
    1883            0 :                 case RatingType::EuropeanSC2Nom: {
    1884              :                     // N2
    1885            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1886            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1887            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1888            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[1];
    1889            0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    1890              :                     } else {
    1891            0 :                         ShowSevereError(state,
    1892            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1893              :                                                RoutineName,
    1894              :                                                CurrentModuleObject,
    1895            0 :                                                WarehouseCoil(CoilID).Name,
    1896              :                                                cNumericFieldNames(NumNum)));
    1897            0 :                         ErrorsFound = true;
    1898              :                     }
    1899            0 :                 } break;
    1900              : 
    1901            0 :                 case RatingType::EuropeanSC3Std: {
    1902              :                     // N2
    1903            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1904            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1905            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1906            0 :                         WarehouseCoil(CoilID).SCIndex = 3;
    1907              :                     } else {
    1908            0 :                         ShowSevereError(state,
    1909            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1910              :                                                RoutineName,
    1911              :                                                CurrentModuleObject,
    1912            0 :                                                WarehouseCoil(CoilID).Name,
    1913              :                                                cNumericFieldNames(NumNum)));
    1914            0 :                         ErrorsFound = true;
    1915              :                     }
    1916            0 :                 } break;
    1917              : 
    1918            0 :                 case RatingType::EuropeanSC3Nom: {
    1919              :                     // N2
    1920            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1921            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1922            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1923            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[2];
    1924            0 :                         WarehouseCoil(CoilID).SCIndex = 3;
    1925              :                     } else {
    1926            0 :                         ShowSevereError(state,
    1927            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1928              :                                                RoutineName,
    1929              :                                                CurrentModuleObject,
    1930            0 :                                                WarehouseCoil(CoilID).Name,
    1931              :                                                cNumericFieldNames(NumNum)));
    1932            0 :                         ErrorsFound = true;
    1933              :                     }
    1934            0 :                 } break;
    1935              : 
    1936            0 :                 case RatingType::EuropeanSC4Std: {
    1937              :                     // N2
    1938            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1939            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1940            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1941            0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    1942              :                     } else {
    1943            0 :                         ShowSevereError(state,
    1944            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1945              :                                                RoutineName,
    1946              :                                                CurrentModuleObject,
    1947            0 :                                                WarehouseCoil(CoilID).Name,
    1948              :                                                cNumericFieldNames(NumNum)));
    1949            0 :                         ErrorsFound = true;
    1950              :                     }
    1951            0 :                 } break;
    1952              : 
    1953            0 :                 case RatingType::EuropeanSC4Nom: {
    1954              :                     // N2
    1955            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1956            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1957            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1958            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[3];
    1959            0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    1960              :                     } else {
    1961            0 :                         ShowSevereError(state,
    1962            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1963              :                                                RoutineName,
    1964              :                                                CurrentModuleObject,
    1965            0 :                                                WarehouseCoil(CoilID).Name,
    1966              :                                                cNumericFieldNames(NumNum)));
    1967            0 :                         ErrorsFound = true;
    1968              :                     }
    1969            0 :                 } break;
    1970              : 
    1971            0 :                 case RatingType::EuropeanSC5Std: {
    1972              :                     // N2
    1973            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1974            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1975            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1976            0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    1977              :                     } else {
    1978            0 :                         ShowSevereError(state,
    1979            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1980              :                                                RoutineName,
    1981              :                                                CurrentModuleObject,
    1982            0 :                                                WarehouseCoil(CoilID).Name,
    1983              :                                                cNumericFieldNames(NumNum)));
    1984            0 :                         ErrorsFound = true;
    1985              :                     }
    1986            0 :                 } break;
    1987              : 
    1988            0 :                 case RatingType::EuropeanSC5Nom: {
    1989              :                     // N2
    1990            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1991            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1992            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1993            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[4];
    1994            0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    1995              :                     } else {
    1996            0 :                         ShowSevereError(state,
    1997            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1998              :                                                RoutineName,
    1999              :                                                CurrentModuleObject,
    2000            0 :                                                WarehouseCoil(CoilID).Name,
    2001              :                                                cNumericFieldNames(NumNum)));
    2002            0 :                         ErrorsFound = true;
    2003              :                     }
    2004            0 :                 } break;
    2005              : 
    2006            0 :                 default: {
    2007            0 :                 } break;
    2008              :                 }
    2009              :             } // WarehouseCoil(CoilID)%RatingType
    2010              : 
    2011              :             // N4
    2012            0 :             NumNum = 4;
    2013            0 :             if (!lNumericBlanks(NumNum)) {
    2014            0 :                 WarehouseCoil(CoilID).TEvapDesign = Numbers(NumNum); // also used to rep inlet brine T later when add that option
    2015              :             } else {
    2016            0 :                 ShowSevereError(
    2017              :                     state,
    2018            0 :                     format(
    2019            0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2020            0 :                 ErrorsFound = true;
    2021              :             }
    2022              : 
    2023            0 :             ++NumNum; // N5
    2024            0 :             if (!lNumericBlanks(NumNum)) {
    2025            0 :                 WarehouseCoil(CoilID).RatedTemperatureDif = Numbers(NumNum);
    2026              :                 // INLET temperature - evaporating temperature, NOT room temp - evap temp
    2027              :             } else {
    2028            0 :                 ShowSevereError(
    2029              :                     state,
    2030            0 :                     format(
    2031            0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2032            0 :                 ErrorsFound = true;
    2033              :             }
    2034              : 
    2035            0 :             ++NumNum; // N6
    2036            0 :             if (!lNumericBlanks(NumNum)) {
    2037            0 :                 WarehouseCoil(CoilID).MaxTemperatureDif = Numbers(NumNum);
    2038              :                 // Maximum difference between INLET temperature - evaporating temperature, NOT room temp - evap temp
    2039              :                 // Important when cooling down space at start of environment or if large stocking loads imposed.
    2040              :             } else {
    2041            0 :                 WarehouseCoil(CoilID).MaxTemperatureDif = 1.3 * WarehouseCoil(CoilID).RatedTemperatureDif;
    2042            0 :                 ShowWarningError(state,
    2043            0 :                                  format("{}{}=\"{}\", {} not entered, default 1.3 times rated temperature difference will be used.",
    2044              :                                         RoutineName,
    2045              :                                         CurrentModuleObject,
    2046            0 :                                         WarehouseCoil(CoilID).Name,
    2047              :                                         cNumericFieldNames(NumNum)));
    2048              :             }
    2049              : 
    2050              :             // Correction factor from manufacturer's rating for coil material, default 1.0
    2051            0 :             ++NumNum;                                 // N7
    2052            0 :             WarehouseCoil(CoilID).CorrMaterial = 1.0; // default value
    2053            0 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).CorrMaterial = Numbers(NumNum);
    2054              : 
    2055              :             // Correction factor from manufacturer's rating for refrigerant, default 1.0
    2056            0 :             ++NumNum;                                    // N8
    2057            0 :             WarehouseCoil(CoilID).CorrRefrigerant = 1.0; // default value
    2058            0 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).CorrRefrigerant = Numbers(NumNum);
    2059              :             // ONLY used if the Capacity Rating Type is CapacityTotalSpecificConditions
    2060              : 
    2061              :             // Convert all European sensible capacities to sensible load factors
    2062            0 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::UnitLoadFactorSens) &&
    2063            0 :                 (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal))
    2064            0 :                 WarehouseCoil(CoilID).UnitLoadFactorSens = WarehouseCoil(CoilID).RatedSensibleCap / WarehouseCoil(CoilID).RatedTemperatureDif;
    2065              :             // Now have UnitLoadFactorSens for all except RatingType == RatedCapacityTotal
    2066              : 
    2067              :             // Apply material and refrigerant correction factors to sensible load factors
    2068            0 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal))
    2069            0 :                 WarehouseCoil(CoilID).UnitLoadFactorSens *= WarehouseCoil(CoilID).CorrMaterial * WarehouseCoil(CoilID).CorrRefrigerant;
    2070              :             // First calc of ratedsensiblecap for type type unitloadfactorsens
    2071            0 :             WarehouseCoil(CoilID).RatedSensibleCap = WarehouseCoil(CoilID).UnitLoadFactorSens * WarehouseCoil(CoilID).RatedTemperatureDif;
    2072              :             // A4    Enter capacity correction curve type
    2073            0 :             AlphaNum = 4;
    2074            0 :             if ((lAlphaBlanks(AlphaNum)) && (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2075              :                 // For all except RatedCapacityTotal - default to linear capacity factor approximating Nelson August 2010 ASHRAE journal
    2076            0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::SHR60;
    2077            0 :             } else if (WarehouseCoil(CoilID).ratingType == RatingType::RatedCapacityTotal) {
    2078              :                 // For RatedCapacityTotal, the manufacturer's coil performance map is required
    2079              :                 // Specify the performance map with TabularRHxDT1xTRoom
    2080            0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::TabularRH_DT1_TRoom;
    2081            0 :                 if (!(Util::SameString(Alphas(AlphaNum), "TabularRHxDT1xTRoom"))) {
    2082            0 :                     ShowWarningError(state,
    2083            0 :                                      format(R"({}{}="{}", invalid {}="{}".)",
    2084              :                                             RoutineName,
    2085              :                                             CurrentModuleObject,
    2086            0 :                                             WarehouseCoil(CoilID).Name,
    2087              :                                             cAlphaFieldNames(AlphaNum),
    2088              :                                             Alphas(AlphaNum)));
    2089            0 :                     ShowContinueError(state,
    2090              :                                       "The \"CapacityTotalSpecificConditions\" Capacity Rating Type has been specified for this air chiller.  "
    2091              :                                       "This rating type requires ");
    2092            0 :                     ShowContinueError(
    2093              :                         state,
    2094            0 :                         format(
    2095              :                             R"(the "TabularRHxDT1xTRoom" correction curve.  Verify that a valid "TabularRHxDT1xTRoom" curve is specified in "{}".)",
    2096              :                             cAlphaFieldNames(AlphaNum + 1)));
    2097              :                 }
    2098            0 :             } else if ((WarehouseCoil(CoilID).SHRCorrType =
    2099            0 :                             static_cast<SHRCorrectionType>(getEnumValue(shrCorrectionTypeNamesUC, Alphas(AlphaNum)))) == SHRCorrectionType::Invalid) {
    2100            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2101            0 :                 ErrorsFound = true;
    2102              :             }
    2103              : 
    2104            0 :             ++AlphaNum; // A5
    2105            0 :             ++NumNum;   // N9
    2106            0 :             switch (WarehouseCoil(CoilID).SHRCorrType) {
    2107            0 :             case SHRCorrectionType::SHR60: {
    2108            0 :                 WarehouseCoil(CoilID).SHRCorrection60 = 1.48; // reference Nelson, ASHRAE journal August 2010 Fig 2
    2109            0 :                 if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).SHRCorrection60 = Numbers(NumNum);
    2110              :                 //(1.66667 would be a perfect effectiveness, 1.0 would be artificial coil that does only sensible)
    2111            0 :                 if (WarehouseCoil(CoilID).SHRCorrection60 > 1.67) {
    2112            0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.67;
    2113            0 :                     ShowWarningError(state,
    2114            0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.67 will be used.",
    2115              :                                             RoutineName,
    2116              :                                             CurrentModuleObject,
    2117            0 :                                             WarehouseCoil(CoilID).Name,
    2118              :                                             cNumericFieldNames(NumNum)));
    2119              :                 }
    2120            0 :                 if (WarehouseCoil(CoilID).SHRCorrection60 < 1.0) {
    2121            0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.0;
    2122            0 :                     ShowWarningError(state,
    2123            0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.00 will be used.",
    2124              :                                             RoutineName,
    2125              :                                             CurrentModuleObject,
    2126            0 :                                             WarehouseCoil(CoilID).Name,
    2127              :                                             cNumericFieldNames(NumNum)));
    2128              :                 }
    2129            0 :             } break;
    2130            0 :             case SHRCorrectionType::European: {
    2131              :                 // WarehouseCoil(CoilID)%SHRCorrectionCurvePtr = CurveManager::GetCurveIndex(state, 'ChillerEuropeanWetCoilFactor')
    2132              :                 // This is a place holder, currently use embedded constants for European ratings, future may want a curve
    2133            0 :             } break;
    2134            0 :             case SHRCorrectionType::QuadraticSHR: {
    2135            0 :                 if (lAlphaBlanks(AlphaNum)) {
    2136            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    2137            0 :                     ErrorsFound = true;
    2138            0 :                 } else if ((WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum))) == 0) {
    2139            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2140            0 :                     ErrorsFound = true;
    2141              :                 }
    2142              :                 // error checks for curve type entered and curve name
    2143            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2144            0 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2145              :                                                      {1},                                         // Valid dimensions
    2146              :                                                      RoutineName,                                 // Routine name
    2147              :                                                      CurrentModuleObject,                         // Object Type
    2148            0 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2149            0 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2150            0 :             } break;
    2151            0 :             case SHRCorrectionType::TabularRH_DT1_TRoom: {
    2152            0 :                 WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    2153            0 :                 if (lAlphaBlanks(AlphaNum)) {
    2154            0 :                     ShowSevereError(state,
    2155            0 :                                     format("{}{}=\"{}\", invalid  {} is blank, required.",
    2156              :                                            RoutineName,
    2157              :                                            CurrentModuleObject,
    2158            0 :                                            WarehouseCoil(CoilID).Name,
    2159              :                                            cAlphaFieldNames(AlphaNum)));
    2160            0 :                     ErrorsFound = true;
    2161            0 :                 } else if (WarehouseCoil(CoilID).SHRCorrectionCurvePtr == 0) {
    2162            0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid  ", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2163            0 :                     ShowContinueError(state, format("...invalid curve {}=\"{}\".", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2164            0 :                     ErrorsFound = true;
    2165              :                 }
    2166            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2167            0 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2168              :                                                      {3},                                         // Valid dimensions
    2169              :                                                      RoutineName,                                 // Routine name
    2170              :                                                      CurrentModuleObject,                         // Object Type
    2171            0 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2172            0 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2173              :                 //        IF(WarehouseCoil(CoilID)%SHRCorrectionCurvePtr == 0) THEN
    2174              :                 //          CALL ShowSevereError(state, RoutineName//TRIM(CurrentModuleObject)//'="'//TRIM(WarehouseCoil(CoilID)%Name)//&
    2175              :                 //                           '", not found  '//TRIM(cAlphaFieldNames(AlphaNum)))
    2176              :                 //          ErrorsFound = .TRUE.
    2177              :                 //        END IF !valid table name
    2178            0 :             } break;
    2179            0 :             default:
    2180            0 :                 break;
    2181              :             } // SHRCorrectionType
    2182              : 
    2183            0 :             ++NumNum; // N10
    2184            0 :             if (!lNumericBlanks(NumNum)) {
    2185            0 :                 WarehouseCoil(CoilID).HeaterPower = Numbers(NumNum);
    2186              :             } else {
    2187            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(NumNum));
    2188            0 :                 ErrorsFound = true;
    2189              :             }
    2190              : 
    2191            0 :             ++AlphaNum; // A6
    2192            0 :             if (lAlphaBlanks(AlphaNum)) {
    2193            0 :                 WarehouseCoil(CoilID).heaterAvailSched = Sched::GetScheduleAlwaysOn(state);
    2194            0 :             } else if ((WarehouseCoil(CoilID).heaterAvailSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2195            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2196            0 :                 ErrorsFound = true;
    2197            0 :             } else if (!WarehouseCoil(CoilID).heaterAvailSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2198            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2199            0 :                 ErrorsFound = true;
    2200              :             }
    2201              : 
    2202              :             // Input fan control type
    2203            0 :             ++AlphaNum; // A7
    2204            0 :             if (lAlphaBlanks(AlphaNum)) {
    2205            0 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::ConstantSpeed;
    2206            0 :             } else if ((WarehouseCoil(CoilID).FanType = static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(AlphaNum)))) ==
    2207              :                        FanSpeedCtrlType::Invalid) {
    2208            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2209            0 :                 ErrorsFound = true;
    2210              :             } // fan control type
    2211              : 
    2212            0 :             ++NumNum; // N11
    2213            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2214            0 :                 WarehouseCoil(CoilID).RatedFanPower = Numbers(NumNum);
    2215              :             } else {
    2216            0 :                 ShowSevereError(state,
    2217            0 :                                 format("{}{}=\"{}\", {} was not input or was less than 0 ",
    2218              :                                        RoutineName,
    2219              :                                        CurrentModuleObject,
    2220            0 :                                        WarehouseCoil(CoilID).Name,
    2221              :                                        cNumericFieldNames(NumNum)));
    2222            0 :                 ErrorsFound = true;
    2223              :             } // coil fan power
    2224              : 
    2225            0 :             ++NumNum; // N12
    2226            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2227            0 :                 WarehouseCoil(CoilID).RatedAirVolumeFlow = Numbers(NumNum);
    2228              :             } else {
    2229            0 :                 ShowSevereError(state,
    2230            0 :                                 format("{}{}=\"{}\", {} is required and was not input or was less than 0  ",
    2231              :                                        RoutineName,
    2232              :                                        CurrentModuleObject,
    2233            0 :                                        WarehouseCoil(CoilID).Name,
    2234              :                                        cNumericFieldNames(NumNum)));
    2235              :             } // air volume flow
    2236              : 
    2237            0 :             ++NumNum;                                       // N13
    2238            0 :             WarehouseCoil(CoilID).FanMinAirFlowRatio = 0.2; // default value
    2239            0 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) WarehouseCoil(CoilID).FanMinAirFlowRatio = Numbers(NumNum);
    2240              : 
    2241              :             // Input defrost type
    2242            0 :             ++AlphaNum; // A8
    2243            0 :             if (lAlphaBlanks(AlphaNum)) {
    2244            0 :                 WarehouseCoil(CoilID).defrostType = DefrostType::Elec;
    2245            0 :             } else if ((WarehouseCoil(CoilID).defrostType = static_cast<DefrostType>(getEnumValue(defrostTypeNamesUC, Alphas(AlphaNum)))) ==
    2246              :                        DefrostType::Invalid) {
    2247            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2248            0 :                 ErrorsFound = true;
    2249              :             } // defrost type
    2250              : 
    2251            0 :             ++AlphaNum; // A9
    2252            0 :             if (lAlphaBlanks(AlphaNum)) {
    2253            0 :                 WarehouseCoil(CoilID).DefrostControlType = DefrostCtrlType::Sched;
    2254            0 :             } else if ((WarehouseCoil(CoilID).DefrostControlType =
    2255            0 :                             static_cast<DefrostCtrlType>(getEnumValue(defrostCtrlTypeNamesUC, Alphas(AlphaNum)))) == DefrostCtrlType::Invalid) {
    2256            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2257            0 :                 ErrorsFound = true;
    2258              :             } // defrost control type
    2259              : 
    2260              :             // convert defrost schedule name to pointer
    2261            0 :             ++AlphaNum; // A10
    2262            0 :             if (lAlphaBlanks(AlphaNum)) {
    2263            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    2264            0 :                 ErrorsFound = true;
    2265            0 :             } else if ((WarehouseCoil(CoilID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2266            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2267            0 :                 ErrorsFound = true;
    2268            0 :             } else if (!WarehouseCoil(CoilID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2269            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2270            0 :                 ErrorsFound = true;
    2271              :             } // check for valid schedule name
    2272              : 
    2273              :             // convert defrost drip-down schedule name to pointer
    2274              :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    2275            0 :             ++AlphaNum; // A11
    2276            0 :             if (lAlphaBlanks(AlphaNum)) {
    2277            0 :                 WarehouseCoil(CoilID).defrostDripDownSched = WarehouseCoil(CoilID).defrostSched;
    2278            0 :             } else if ((WarehouseCoil(CoilID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2279            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2280            0 :                 ErrorsFound = true;
    2281            0 :             } else if (!WarehouseCoil(CoilID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2282            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2283            0 :                 ErrorsFound = true;
    2284              :             } // check for valid schedule name
    2285              : 
    2286            0 :             ++NumNum; // N14
    2287            0 :             if (WarehouseCoil(CoilID).defrostType == DefrostType::OffCycle || WarehouseCoil(CoilID).defrostType == DefrostType::None) {
    2288            0 :                 WarehouseCoil(CoilID).DefrostCapacity = 0.0;
    2289              :                 // Don't even need to read Defrost capacity for those two defrost types.
    2290              :             } else { // have electric or hot gas/brine defrost
    2291            0 :                 if ((lNumericBlanks(NumNum)) || (Numbers(NumNum) <= 0.0)) {
    2292            0 :                     ShowSevereError(state,
    2293            0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    2294              :                                            RoutineName,
    2295              :                                            CurrentModuleObject,
    2296            0 :                                            WarehouseCoil(CoilID).Name,
    2297              :                                            cNumericFieldNames(NumNum),
    2298              :                                            cAlphaFieldNames(AlphaNum),
    2299              :                                            Alphas(AlphaNum)));
    2300            0 :                     ErrorsFound = true;
    2301              :                 } else {
    2302            0 :                     WarehouseCoil(CoilID).DefrostCapacity = Numbers(NumNum);
    2303              :                 } // Blank  or negative Defrost Capacity
    2304              : 
    2305              :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    2306              :                 // note this value is only used for temperature terminated defrost control type
    2307            0 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Elec) WarehouseCoil(CoilID).DefEnergyFraction = 0.7;
    2308            0 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Fluid) WarehouseCoil(CoilID).DefEnergyFraction = 0.3;
    2309              : 
    2310            0 :                 ++NumNum; // N15
    2311            0 :                 if (!lNumericBlanks(NumNum)) {
    2312            0 :                     if ((Numbers(NumNum) > 1.0) || (Numbers(NumNum) < 0.0)) {
    2313            0 :                         ShowWarningError(state,
    2314            0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    2315              :                                                 RoutineName,
    2316              :                                                 CurrentModuleObject,
    2317            0 :                                                 WarehouseCoil(CoilID).Name,
    2318              :                                                 cNumericFieldNames(NumNum)));
    2319              :                     } else {
    2320            0 :                         WarehouseCoil(CoilID).DefEnergyFraction = Numbers(NumNum);
    2321              :                     } // number out of range
    2322              :                 }     // lnumericblanks
    2323              :             }         // defrost type
    2324              : 
    2325            0 :             ++AlphaNum; // A12
    2326            0 :             if (lAlphaBlanks(AlphaNum)) {
    2327            0 :                 WarehouseCoil(CoilID).VerticalLocation = VerticalLoc::Middle; // default position
    2328            0 :             } else if ((WarehouseCoil(CoilID).VerticalLocation = static_cast<VerticalLoc>(getEnumValue(verticalLocNamesUC, Alphas(AlphaNum)))) ==
    2329              :                        VerticalLoc::Invalid) {
    2330            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2331            0 :                 ErrorsFound = true;
    2332              :             } // Vertical location class
    2333              : 
    2334            0 :             ++NumNum; // N16
    2335            0 :             WarehouseCoil(CoilID).DesignRefrigInventory = 0.0;
    2336            0 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).DesignRefrigInventory = Numbers(NumNum);
    2337              :         } // NumRefrigAirChillers
    2338              :     }     // NumRefrigerationAirChillers > 0
    2339              : 
    2340              :     //************ START Warehouse Coil SET INPUT **************
    2341              :     // One Set allowed per zone, but indiv coils within zone can be served by different compressor/condenser systems
    2342              : 
    2343          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
    2344              : 
    2345            0 :         state.dataRefrigCase->CheckChillerSetName.dimension(state.dataRefrigCase->NumRefrigChillerSets, true);
    2346              : 
    2347            0 :         CurrentModuleObject = "ZoneHVAC:RefrigerationChillerSet";
    2348            0 :         for (int SetID = 1; SetID <= state.dataRefrigCase->NumRefrigChillerSets; ++SetID) {
    2349            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2350              :                                                                      CurrentModuleObject,
    2351              :                                                                      SetID,
    2352              :                                                                      Alphas,
    2353              :                                                                      NumAlphas,
    2354              :                                                                      Numbers,
    2355              :                                                                      NumNumbers,
    2356              :                                                                      IOStatus,
    2357              :                                                                      lNumericBlanks,
    2358              :                                                                      lAlphaBlanks,
    2359              :                                                                      cAlphaFieldNames,
    2360              :                                                                      cNumericFieldNames);
    2361              : 
    2362            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2363              : 
    2364            0 :             AlphaNum = 1;
    2365            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2366              : 
    2367            0 :             AirChillerSet(SetID).Name = Alphas(AlphaNum);
    2368              : 
    2369            0 :             AlphaNum = 2;
    2370            0 :             if (lAlphaBlanks(AlphaNum)) {
    2371            0 :                 AirChillerSet(SetID).availSched = Sched::GetScheduleAlwaysOn(state);
    2372            0 :             } else if ((AirChillerSet(SetID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2373            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2374            0 :                 ErrorsFound = true;
    2375            0 :             } else if (!AirChillerSet(SetID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2376            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2377            0 :                 ErrorsFound = true;
    2378              :             }
    2379              : 
    2380            0 :             ++AlphaNum;
    2381            0 :             AirChillerSet(SetID).ZoneName = Alphas(AlphaNum);
    2382            0 :             AirChillerSet(SetID).ZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    2383              : 
    2384            0 :             if (AirChillerSet(SetID).ZoneNum == 0) {
    2385            0 :                 ShowSevereError(state,
    2386            0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
    2387              :                                        RoutineName,
    2388              :                                        CurrentModuleObject,
    2389            0 :                                        AirChillerSet(SetID).Name,
    2390              :                                        cAlphaFieldNames(AlphaNum),
    2391              :                                        Alphas(AlphaNum)));
    2392            0 :                 ErrorsFound = true;
    2393              :             }
    2394            0 :             AirChillerSet(SetID).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, AirChillerSet(SetID).ZoneNum);
    2395            0 :             if (AirChillerSet(SetID).ZoneNodeNum == 0) {
    2396            0 :                 ShowSevereError(state,
    2397            0 :                                 format("{}{}=\"{}\" System Node Number not found for {} = {}",
    2398              :                                        RoutineName,
    2399              :                                        CurrentModuleObject,
    2400            0 :                                        AirChillerSet(SetID).Name,
    2401              :                                        cAlphaFieldNames(AlphaNum),
    2402              :                                        Alphas(AlphaNum)));
    2403            0 :                 ShowContinueError(state,
    2404              :                                   ".. Refrigeration chillers must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    2405            0 :                 ErrorsFound = true;
    2406              :             }
    2407            0 :             state.dataRefrigCase->RefrigPresentInZone(AirChillerSet(SetID).ZoneNum) = true;
    2408              : 
    2409            0 :             ++AlphaNum;
    2410            0 :             if (!lAlphaBlanks(AlphaNum)) {
    2411            0 :                 ShowMessage(state,
    2412            0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2413              :                                    "any air system. ",
    2414              :                                    RoutineName,
    2415              :                                    CurrentModuleObject,
    2416            0 :                                    AirChillerSet(SetID).Name,
    2417              :                                    cAlphaFieldNames(AlphaNum)));
    2418              :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2419              :                 // AirChillerSet(SetID)%NodeNumInlet = &
    2420              :                 //       NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2421              :                 //                    AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Inlet,1,DataLoopNode::ObjectIsNotParent)
    2422              :             }
    2423              : 
    2424            0 :             ++AlphaNum;
    2425            0 :             if (!lAlphaBlanks(AlphaNum)) {
    2426            0 :                 ShowMessage(state,
    2427            0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2428              :                                    "any air system. ",
    2429              :                                    RoutineName,
    2430              :                                    CurrentModuleObject,
    2431            0 :                                    AirChillerSet(SetID).Name,
    2432              :                                    cAlphaFieldNames(AlphaNum)));
    2433              :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2434              :                 // AirChillerSet(SetID)%NodeNumOutlet = &
    2435              :                 //         NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2436              :                 //                      AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Outlet,1,DataLoopNode::ObjectIsNotParent)
    2437              :             }
    2438              : 
    2439              :             // An extensible list is used to enter the individual names of each chiller in the set.
    2440              :             // These chillers will be dispatched in this list order to meet the required zone load
    2441            0 :             int NumChillersInSet = NumAlphas - AlphaNum;
    2442            0 :             int AlphaStartList = AlphaNum; //+ 1
    2443            0 :             AirChillerSet(SetID).NumCoils = NumChillersInSet;
    2444            0 :             if (!allocated(AirChillerSet(SetID).CoilNum)) AirChillerSet(SetID).CoilNum.allocate(NumChillersInSet);
    2445            0 :             for (int ChillerIndex = 1; ChillerIndex <= NumChillersInSet; ++ChillerIndex) {
    2446            0 :                 int AlphaListNum = AlphaStartList + ChillerIndex;
    2447            0 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2448            0 :                     int CoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2449            0 :                     if (CoilNum == 0) {
    2450            0 :                         ShowSevereError(state,
    2451            0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    2452              :                                                RoutineName,
    2453              :                                                CurrentModuleObject,
    2454            0 :                                                AirChillerSet(SetID).Name,
    2455              :                                                cAlphaFieldNames(AlphaListNum),
    2456              :                                                Alphas(AlphaListNum)));
    2457            0 :                         ErrorsFound = true;
    2458              :                     } // == 0
    2459            0 :                     AirChillerSet(SetID).CoilNum(ChillerIndex) = CoilNum;
    2460            0 :                     WarehouseCoil(CoilNum).ZoneName = AirChillerSet(SetID).ZoneName;
    2461            0 :                     WarehouseCoil(CoilNum).ZoneNum = AirChillerSet(SetID).ZoneNum;
    2462            0 :                     WarehouseCoil(CoilNum).ZoneNodeNum = AirChillerSet(SetID).ZoneNodeNum;
    2463              :                 } // ! = alphablanks
    2464              :             }     // CoilID over NumChillersInSet
    2465              :         }         // NumChillerSets
    2466              :     }             // NumChillerSets > 0
    2467              :     //************* End Air Chiller Sets
    2468              : 
    2469              :     //**** Read CaseAndWalkIn Lists **********************************************************
    2470          150 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    2471            2 :         CurrentModuleObject = "Refrigeration:CaseAndWalkInList";
    2472            4 :         for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationCaseAndWalkInLists; ++ListNum) {
    2473            2 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2474              :                                                                      CurrentModuleObject,
    2475              :                                                                      ListNum,
    2476              :                                                                      Alphas,
    2477              :                                                                      NumAlphas,
    2478              :                                                                      Numbers,
    2479              :                                                                      NumNumbers,
    2480              :                                                                      IOStatus,
    2481              :                                                                      lNumericBlanks,
    2482              :                                                                      lAlphaBlanks,
    2483              :                                                                      cAlphaFieldNames,
    2484              :                                                                      cNumericFieldNames);
    2485            2 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2486            2 :             CaseAndWalkInList(ListNum).Name = Alphas(1);
    2487              : 
    2488              :             // CaseAndWalkInList alphas include CaseAndWalkInList name and one name for each Case or WalkIn in list
    2489              :             // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    2490            2 :             int NumTotalLoadsOnList = NumAlphas - 1;
    2491            2 :             if (!allocated(CaseAndWalkInList(ListNum).WalkInItemNum)) CaseAndWalkInList(ListNum).WalkInItemNum.allocate(NumTotalLoadsOnList);
    2492            2 :             if (!allocated(CaseAndWalkInList(ListNum).CaseItemNum)) CaseAndWalkInList(ListNum).CaseItemNum.allocate(NumTotalLoadsOnList);
    2493            2 :             if (!allocated(CaseAndWalkInList(ListNum).CoilItemNum)) CaseAndWalkInList(ListNum).CoilItemNum.allocate(NumTotalLoadsOnList);
    2494              : 
    2495            2 :             int NumCasesOnList = 0;
    2496            2 :             int NumCoilsOnList = 0;
    2497            2 :             int NumWalkInsOnList = 0;
    2498            2 :             int LoadCount = 0;
    2499            5 :             for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    2500            3 :                 int AlphaListNum = 1 + NumLoad;
    2501            3 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2502            3 :                     ++LoadCount;
    2503            3 :                     int LoadWalkInNum = 0;
    2504            3 :                     int LoadCaseNum = 0;
    2505            3 :                     int LoadCoilNum = 0;
    2506            3 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) LoadWalkInNum = Util::FindItemInList(Alphas(AlphaListNum), WalkIn);
    2507            3 :                     if (state.dataRefrigCase->NumSimulationCases > 0) LoadCaseNum = Util::FindItemInList(Alphas(AlphaListNum), RefrigCase);
    2508            3 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0)
    2509            0 :                         LoadCoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2510            3 :                     if ((LoadWalkInNum == 0) && (LoadCaseNum == 0) && (LoadCoilNum == 0)) {
    2511            0 :                         ShowSevereError(state,
    2512            0 :                                         format("{}{}=\"{}\", has an invalid value of {}",
    2513              :                                                RoutineName,
    2514              :                                                CurrentModuleObject,
    2515              :                                                cAlphaFieldNames(AlphaListNum),
    2516              :                                                Alphas(AlphaListNum)));
    2517            0 :                         ErrorsFound = true;
    2518            3 :                     } else if ((LoadWalkInNum != 0) && (LoadCaseNum != 0) && (LoadCoilNum != 0)) {
    2519            0 :                         ShowSevereError(state,
    2520            0 :                                         format("{}{}=\"{}\", {} Case and WalkIns and Refrigerated Coils cannot have the same name.",
    2521              :                                                RoutineName,
    2522              :                                                CurrentModuleObject,
    2523              :                                                cAlphaFieldNames(AlphaListNum),
    2524              :                                                Alphas(AlphaListNum)));
    2525            0 :                         ErrorsFound = true;
    2526            3 :                     } else if (LoadWalkInNum != 0) {
    2527            2 :                         ++NumWalkInsOnList;
    2528            2 :                         CaseAndWalkInList(ListNum).WalkInItemNum(NumWalkInsOnList) = LoadWalkInNum;
    2529            1 :                     } else if (LoadCaseNum != 0) {
    2530            1 :                         ++NumCasesOnList;
    2531            1 :                         CaseAndWalkInList(ListNum).CaseItemNum(NumCasesOnList) = LoadCaseNum;
    2532            0 :                     } else if (LoadCoilNum != 0) {
    2533            0 :                         ++NumCoilsOnList;
    2534            0 :                         CaseAndWalkInList(ListNum).CoilItemNum(NumCoilsOnList) = LoadCoilNum;
    2535              :                     }
    2536              :                 } // lAlphaBlanks
    2537              :             }     // Num Total Loads on List
    2538            2 :             if (LoadCount == 0) {
    2539            0 :                 ShowSevereError(
    2540              :                     state,
    2541            0 :                     format(
    2542            0 :                         "{}{}, \"{}\" : degenerate list All entries were blank.", RoutineName, CurrentModuleObject, CaseAndWalkInList(ListNum).Name));
    2543            0 :                 ErrorsFound = true;
    2544              :             } // loadcount == 0
    2545            2 :             CaseAndWalkInList(ListNum).NumCases = NumCasesOnList;
    2546            2 :             CaseAndWalkInList(ListNum).NumCoils = NumCoilsOnList;
    2547            2 :             CaseAndWalkInList(ListNum).NumWalkIns = NumWalkInsOnList;
    2548              :         } // ListNum=1,NumSimulationCaseAndWalkInLists
    2549              :     }     //(NumSimulationCaseAndWalkInLists > 0)
    2550              : 
    2551              :     //**** End read CaseAndWalkIn Lists **********************************************************
    2552              : 
    2553              :     //************** Start RefrigerationRacks
    2554              : 
    2555          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    2556              : 
    2557            5 :         CurrentModuleObject = "Refrigeration:CompressorRack";
    2558              : 
    2559           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
    2560              : 
    2561            5 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2562              :                                                                      CurrentModuleObject,
    2563              :                                                                      RackNum,
    2564              :                                                                      Alphas,
    2565              :                                                                      NumAlphas,
    2566              :                                                                      Numbers,
    2567              :                                                                      NumNumbers,
    2568              :                                                                      IOStatus,
    2569              :                                                                      lNumericBlanks,
    2570              :                                                                      lAlphaBlanks,
    2571              :                                                                      cAlphaFieldNames,
    2572              :                                                                      cNumericFieldNames);
    2573              : 
    2574            5 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2575            5 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2576              : 
    2577            5 :             RefrigRack(RackNum).Name = Alphas(1);
    2578            5 :             RefrigRack(RackNum).MyIdx = RackNum;
    2579            5 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).Name = Alphas(1);
    2580            5 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).SourceType = CurrentModuleObject;
    2581              : 
    2582            5 :             if (lAlphaBlanks(2)) {
    2583            0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2584            5 :             } else if ((RefrigRack(RackNum).HeatRejectionLocation = static_cast<HeatRejLocation>(getEnumValue(heatRejLocationNamesUC, Alphas(2)))) ==
    2585              :                        HeatRejLocation::Invalid) {
    2586            0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2587            0 :                 ShowWarningInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2), "Outdoors");
    2588              :             }
    2589              : 
    2590            5 :             RefrigRack(RackNum).RatedCOP = Numbers(1);
    2591              : 
    2592            5 :             if (RefrigRack(RackNum).RatedCOP <= 0.0) {
    2593            0 :                 ShowSevereError(state,
    2594            0 :                                 format("{}{}=\"{}\" {} must be greater than 0.0",
    2595              :                                        RoutineName,
    2596              :                                        CurrentModuleObject,
    2597            0 :                                        RefrigRack(RackNum).Name,
    2598              :                                        cNumericFieldNames(1)));
    2599            0 :                 ErrorsFound = true;
    2600              :             }
    2601              : 
    2602            5 :             RefrigRack(RackNum).COPFTempPtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    2603            5 :             if (RefrigRack(RackNum).COPFTempPtr == 0) {
    2604            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), Alphas(3));
    2605            0 :                 ErrorsFound = true;
    2606              :             }
    2607              : 
    2608           15 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2609            5 :                                                  RefrigRack(RackNum).COPFTempPtr, // Curve index
    2610              :                                                  {1},                             // Valid dimensions
    2611              :                                                  RoutineName,                     // Routine name
    2612              :                                                  CurrentModuleObject,             // Object Type
    2613            5 :                                                  RefrigRack(RackNum).Name,        // Object Name
    2614            5 :                                                  cAlphaFieldNames(3));            // Field Name
    2615              : 
    2616            5 :             RefrigRack(RackNum).CondenserFanPower = Numbers(2);
    2617            5 :             if (Numbers(2) < 0.0) {
    2618            0 :                 ShowSevereError(state,
    2619            0 :                                 format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    2620              :                                        RoutineName,
    2621              :                                        CurrentModuleObject,
    2622            0 :                                        RefrigRack(RackNum).Name,
    2623              :                                        cNumericFieldNames(2)));
    2624            0 :                 ErrorsFound = true;
    2625              :             }
    2626              : 
    2627            5 :             RefrigRack(RackNum).TotCondFTempPtr = Curve::GetCurveIndex(state, Alphas(4)); // convert curve name to number
    2628            5 :             if ((!lAlphaBlanks(4)) && RefrigRack(RackNum).TotCondFTempPtr == 0) {
    2629            0 :                 ShowSevereError(state,
    2630            0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
    2631              :                                        RoutineName,
    2632              :                                        CurrentModuleObject,
    2633            0 :                                        RefrigRack(RackNum).Name,
    2634              :                                        cAlphaFieldNames(4),
    2635              :                                        Alphas(4)));
    2636            0 :                 ErrorsFound = true;
    2637              :             }
    2638              : 
    2639            5 :             if (!lAlphaBlanks(4)) {
    2640            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2641            0 :                                                      RefrigRack(RackNum).TotCondFTempPtr, // Curve index
    2642              :                                                      {1},                                 // Valid dimensions
    2643              :                                                      RoutineName,                         // Routine name
    2644              :                                                      CurrentModuleObject,                 // Object Type
    2645            0 :                                                      RefrigRack(RackNum).Name,            // Object Name
    2646            0 :                                                      cAlphaFieldNames(4));                // Field Name
    2647              :             }
    2648              : 
    2649            5 :             if (lAlphaBlanks(5)) {
    2650            0 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2651           10 :             } else if ((RefrigRack(RackNum).CondenserType = static_cast<DataHeatBalance::RefrigCondenserType>(
    2652            5 :                             getEnumValue(DataHeatBalance::refrigCondenserTypeNamesUC, Alphas(5)))) == DataHeatBalance::RefrigCondenserType::Invalid) {
    2653            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    2654            0 :                 ErrorsFound = true;
    2655           10 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap ||
    2656            5 :                        RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2657            0 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    2658            0 :                     ShowWarningError(state,
    2659            0 :                                      format("{}=\"{}\" {}=\"{}\" not available with {} = Zone.",
    2660              :                                             CurrentModuleObject,
    2661            0 :                                             RefrigRack(RackNum).Name,
    2662              :                                             cAlphaFieldNames(5),
    2663              :                                             Alphas(5),
    2664              :                                             cAlphaFieldNames(2)));
    2665            0 :                     ShowContinueError(state, format("{} reset to Air Cooled and simulation continues.", cAlphaFieldNames(5)));
    2666            0 :                     RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2667              :                 }
    2668           10 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade ||
    2669            5 :                        RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::WaterHeater) {
    2670            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    2671            0 :                 ErrorsFound = true;
    2672              :             }
    2673              :             // Get water-cooled condenser input, if applicable
    2674            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2675            0 :                 RefrigRack(RackNum).InletNode = NodeInputManager::GetOnlySingleNode(state,
    2676            0 :                                                                                     Alphas(6),
    2677              :                                                                                     ErrorsFound,
    2678              :                                                                                     DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2679            0 :                                                                                     Alphas(1),
    2680              :                                                                                     DataLoopNode::NodeFluidType::Water,
    2681              :                                                                                     DataLoopNode::ConnectionType::Inlet,
    2682              :                                                                                     NodeInputManager::CompFluidStream::Primary,
    2683              :                                                                                     DataLoopNode::ObjectIsNotParent);
    2684            0 :                 RefrigRack(RackNum).OutletNode = NodeInputManager::GetOnlySingleNode(state,
    2685            0 :                                                                                      Alphas(7),
    2686              :                                                                                      ErrorsFound,
    2687              :                                                                                      DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2688            0 :                                                                                      Alphas(1),
    2689              :                                                                                      DataLoopNode::NodeFluidType::Water,
    2690              :                                                                                      DataLoopNode::ConnectionType::Outlet,
    2691              :                                                                                      NodeInputManager::CompFluidStream::Primary,
    2692              :                                                                                      DataLoopNode::ObjectIsNotParent);
    2693              :                 // Check node connections
    2694            0 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(6), Alphas(7), "RefrigRack Nodes");
    2695              :                 // Get loop flow type
    2696            0 :                 if ((RefrigRack(RackNum).FlowType = static_cast<CndsrFlowType>(getEnumValue(cndsrFlowTypeNamesUC, Alphas(8)))) ==
    2697              :                     CndsrFlowType::Invalid) {
    2698            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(8), Alphas(8));
    2699            0 :                     ErrorsFound = true;
    2700              :                 }
    2701              :                 // Get outlet temperature schedule for variable flow case
    2702            0 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Variable) {
    2703            0 :                     if (lAlphaBlanks(9)) {
    2704            0 :                     } else if ((RefrigRack(RackNum).outletTempSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) {
    2705            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9));
    2706            0 :                         ErrorsFound = true;
    2707              :                     }
    2708              :                 }
    2709              : 
    2710              :                 // Get volumetric flow rate if applicable
    2711            0 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Constant) {
    2712            0 :                     RefrigRack(RackNum).DesVolFlowRate = Numbers(3);
    2713            0 :                     RefrigRack(RackNum).VolFlowRate = Numbers(3);
    2714              :                 }
    2715              :                 // Get maximum flow rates
    2716            0 :                 RefrigRack(RackNum).VolFlowRateMax = Numbers(4);
    2717              : 
    2718              :                 // Check constant flow for max violation, if applicable
    2719            0 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Constant && RefrigRack(RackNum).VolFlowRate > Numbers(4)) {
    2720            0 :                     ShowSevereError(state,
    2721            0 :                                     format("{}{}=\"{}\" {} > {}.",
    2722              :                                            RoutineName,
    2723              :                                            CurrentModuleObject,
    2724            0 :                                            RefrigRack(RackNum).Name,
    2725              :                                            cNumericFieldNames(3),
    2726              :                                            cNumericFieldNames(4)));
    2727            0 :                     ShowContinueError(state, "Revise flow rates.");
    2728            0 :                     ErrorsFound = true;
    2729              :                 }
    2730              :                 // Get max/min allowed water temps
    2731            0 :                 RefrigRack(RackNum).OutletTempMax = Numbers(5);
    2732            0 :                 RefrigRack(RackNum).InletTempMin = Numbers(6);
    2733              :                 // set flow request for plant sizing.
    2734            0 :                 PlantUtilities::RegisterPlantCompDesignFlow(state, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).VolFlowRateMax);
    2735              :             } // Water cooled condenser data
    2736              : 
    2737              :             // Get evaporative cooled condenser input
    2738            5 :             if (lAlphaBlanks(10)) {
    2739            0 :             } else if ((RefrigRack(RackNum).evapAvailSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) {
    2740            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10));
    2741            0 :                 ErrorsFound = true;
    2742            0 :             } else if (!RefrigRack(RackNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) {
    2743            0 :                 Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0);
    2744            0 :                 ErrorsFound = true;
    2745              :             }
    2746              : 
    2747            5 :             RefrigRack(RackNum).EvapEffect = Numbers(7);
    2748            5 :             if (RefrigRack(RackNum).EvapEffect < 0.0 || RefrigRack(RackNum).EvapEffect > 1.0) {
    2749            0 :                 ShowSevereError(state,
    2750            0 :                                 format("{}{}=\"{}\" {} cannot be less than zero or greater than 1.0.",
    2751              :                                        RoutineName,
    2752              :                                        CurrentModuleObject,
    2753            0 :                                        RefrigRack(RackNum).Name,
    2754              :                                        cNumericFieldNames(7)));
    2755            0 :                 ErrorsFound = true;
    2756              :             }
    2757              : 
    2758            5 :             RefrigRack(RackNum).CondenserAirFlowRate = Numbers(8);
    2759            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).CondenserAirFlowRate <= 0.0 &&
    2760            0 :                 RefrigRack(RackNum).CondenserAirFlowRate != Constant::AutoCalculate) {
    2761            0 :                 ShowSevereError(state,
    2762            0 :                                 format("{}{}=\"{}\", {} cannot be less than or equal to zero.",
    2763              :                                        RoutineName,
    2764              :                                        CurrentModuleObject,
    2765            0 :                                        RefrigRack(RackNum).Name,
    2766              :                                        cNumericFieldNames(8)));
    2767            0 :                 ErrorsFound = true;
    2768              :             }
    2769              : 
    2770              :             //   Basin heater power as a function of temperature must be greater than or equal to 0
    2771            5 :             RefrigRack(RackNum).BasinHeaterPowerFTempDiff = Numbers(9);
    2772            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && Numbers(9) < 0.0) {
    2773            0 :                 ShowSevereError(
    2774            0 :                     state, format("{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, RefrigRack(RackNum).Name, cNumericFieldNames(9)));
    2775            0 :                 ErrorsFound = true;
    2776              :             }
    2777              : 
    2778            5 :             RefrigRack(RackNum).BasinHeaterSetPointTemp = Numbers(10);
    2779            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    2780            0 :                 RefrigRack(RackNum).BasinHeaterSetPointTemp < 2.0) {
    2781            0 :                 ShowWarningError(state,
    2782            0 :                                  format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    2783              :                                         CurrentModuleObject,
    2784            0 :                                         RefrigRack(RackNum).Name,
    2785              :                                         cNumericFieldNames(10)));
    2786              :             }
    2787              : 
    2788            5 :             RefrigRack(RackNum).EvapPumpPower = Numbers(11);
    2789            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).EvapPumpPower < 0.0 &&
    2790            0 :                 RefrigRack(RackNum).EvapPumpPower != Constant::AutoCalculate) {
    2791            0 :                 ShowSevereError(state,
    2792            0 :                                 format("{}{}=\"{}\", {} cannot be less than zero.",
    2793              :                                        RoutineName,
    2794              :                                        CurrentModuleObject,
    2795            0 :                                        RefrigRack(RackNum).Name,
    2796              :                                        cNumericFieldNames(11)));
    2797            0 :                 ErrorsFound = true;
    2798              :             }
    2799              : 
    2800              :             // Get Water System tank connections
    2801            5 :             RefrigRack(RackNum).SupplyTankName = Alphas(11);
    2802            5 :             if (lAlphaBlanks(11)) {
    2803            5 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    2804              :             } else {
    2805            0 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    2806            0 :                 WaterManager::SetupTankDemandComponent(state,
    2807            0 :                                                        RefrigRack(RackNum).Name,
    2808              :                                                        CurrentModuleObject,
    2809            0 :                                                        RefrigRack(RackNum).SupplyTankName,
    2810              :                                                        ErrorsFound,
    2811            0 :                                                        RefrigRack(RackNum).EvapWaterSupTankID,
    2812            0 :                                                        RefrigRack(RackNum).EvapWaterTankDemandARRID);
    2813              :             }
    2814              : 
    2815              :             // Check condenser air inlet node connection
    2816            5 :             if (lAlphaBlanks(12)) {
    2817            5 :                 RefrigRack(RackNum).OutsideAirNodeNum = 0;
    2818              :             } else {
    2819            0 :                 RefrigRack(RackNum).OutsideAirNodeNum =
    2820            0 :                     NodeInputManager::GetOnlySingleNode(state,
    2821            0 :                                                         Alphas(12),
    2822              :                                                         ErrorsFound,
    2823              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2824            0 :                                                         Alphas(1),
    2825              :                                                         DataLoopNode::NodeFluidType::Air,
    2826              :                                                         DataLoopNode::ConnectionType::OutsideAirReference,
    2827              :                                                         NodeInputManager::CompFluidStream::Primary,
    2828              :                                                         DataLoopNode::ObjectIsParent);
    2829            0 :                 if (!OutAirNodeManager::CheckOutAirNodeNumber(state, RefrigRack(RackNum).OutsideAirNodeNum)) {
    2830            0 :                     ShowSevereError(state,
    2831            0 :                                     format("{}{}=\"{}\", {} not found: {}",
    2832              :                                            RoutineName,
    2833              :                                            CurrentModuleObject,
    2834            0 :                                            RefrigRack(RackNum).Name,
    2835              :                                            cAlphaFieldNames(12),
    2836              :                                            Alphas(12)));
    2837            0 :                     ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    2838            0 :                     ErrorsFound = true;
    2839              :                 }
    2840              :             }
    2841              : 
    2842            5 :             if (!lAlphaBlanks(13)) RefrigRack(RackNum).EndUseSubcategory = Alphas(13);
    2843              : 
    2844              :             // Read all loads on this rack: cases and walk-ins and coils
    2845            5 :             NumCases = 0;
    2846            5 :             int NumCoils = 0;
    2847            5 :             NumWalkIns = 0;
    2848            5 :             RefrigRack(RackNum).NumCases = 0;
    2849            5 :             RefrigRack(RackNum).NumCoils = 0;
    2850            5 :             RefrigRack(RackNum).NumWalkIns = 0;
    2851            5 :             RefrigRack(RackNum).TotalRackLoad = 0.0;
    2852              : 
    2853              :             //   Read display case and walkin assignments for this rack
    2854            5 :             AlphaNum = 14;
    2855            5 :             if (lAlphaBlanks(AlphaNum)) {
    2856              :                 // No cases or walkins or coils specified, ie, rack has no load
    2857            0 :                 ShowSevereError(state,
    2858            0 :                                 format("{}{}=\"{}\" : has no loads, must have at least one of: {}",
    2859              :                                        RoutineName,
    2860              :                                        CurrentModuleObject,
    2861            0 :                                        RefrigRack(RackNum).Name,
    2862              :                                        cAlphaFieldNames(14)));
    2863            0 :                 ErrorsFound = true;
    2864              :             } else { // (.NOT. lAlphaBlanks(AlphaNum))
    2865              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn, Coil, or CaseAndWalkInList name
    2866            5 :                 int CaseAndWalkInListNum = 0;
    2867            5 :                 int CaseNum = 0;
    2868            5 :                 int WalkInNum = 0;
    2869            5 :                 int CoilNum = 0;
    2870            5 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    2871            2 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    2872            5 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    2873            5 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    2874            5 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    2875            5 :                 int NumNameMatches = 0;
    2876            5 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    2877            5 :                 if (CaseNum != 0) ++NumNameMatches;
    2878            5 :                 if (WalkInNum != 0) ++NumNameMatches;
    2879            5 :                 if (CoilNum != 0) ++NumNameMatches;
    2880              : 
    2881            5 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin
    2882            0 :                     ErrorsFound = true;
    2883            0 :                     if (NumNameMatches == 0) {
    2884            0 :                         ShowSevereError(state,
    2885            0 :                                         format("{}{}=\"{}\" : has an invalid {}: {}",
    2886              :                                                RoutineName,
    2887              :                                                CurrentModuleObject,
    2888            0 :                                                RefrigRack(RackNum).Name,
    2889              :                                                cAlphaFieldNames(AlphaNum),
    2890              :                                                Alphas(AlphaNum)));
    2891            0 :                     } else if (NumNameMatches > 1) {
    2892            0 :                         ShowSevereError(state,
    2893            0 :                                         format("{}{}=\"{}\" : has a non-unique name that could be either a {}: {}",
    2894              :                                                RoutineName,
    2895              :                                                CurrentModuleObject,
    2896            0 :                                                RefrigRack(RackNum).Name,
    2897              :                                                cAlphaFieldNames(AlphaNum),
    2898              :                                                Alphas(AlphaNum)));
    2899              :                     }                                   // num matches = 0 or > 1
    2900            5 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    2901            2 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    2902            2 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    2903            2 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    2904            2 :                     RefrigRack(RackNum).NumCoils = NumCoils;
    2905            2 :                     RefrigRack(RackNum).NumCases = NumCases;
    2906            2 :                     RefrigRack(RackNum).NumWalkIns = NumWalkIns;
    2907            2 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    2908            2 :                     RefrigRack(RackNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    2909            2 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) RefrigRack(RackNum).CaseNum.allocate(NumCases);
    2910            2 :                     RefrigRack(RackNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    2911            2 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    2912            2 :                     RefrigRack(RackNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    2913            3 :                 } else if (CoilNum != 0) { // Name points to a coil
    2914            0 :                     NumCoils = 1;
    2915            0 :                     RefrigRack(RackNum).NumCoils = 1;
    2916            0 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    2917            0 :                     RefrigRack(RackNum).CoilNum(NumCoils) = CoilNum;
    2918            3 :                 } else if (CaseNum != 0) { // Name points to a case
    2919            2 :                     NumCases = 1;
    2920            2 :                     RefrigRack(RackNum).NumCases = 1;
    2921            2 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) RefrigRack(RackNum).CaseNum.allocate(NumCases);
    2922            2 :                     RefrigRack(RackNum).CaseNum(NumCases) = CaseNum;
    2923            1 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    2924            1 :                     NumWalkIns = 1;
    2925            1 :                     RefrigRack(RackNum).NumWalkIns = 1;
    2926            1 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    2927            1 :                     RefrigRack(RackNum).WalkInNum(NumWalkIns) = WalkInNum;
    2928              :                 } // NumNameMatches /= 1
    2929              :             }     // blank input for loads on rack
    2930              : 
    2931            5 :             if (NumCases > 0) {
    2932            6 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    2933            3 :                     int caseID = RefrigRack(RackNum).CaseNum(caseIndex);
    2934              :                     // mark all cases on rack as used by this system (checking for unused or non-unique cases)
    2935            3 :                     ++RefrigCase(caseID).NumSysAttach;
    2936              :                     // determine total capacity on rack
    2937            3 :                     RefrigRack(RackNum).TotalRackLoad += RefrigCase(caseID).DesignRatedCap;
    2938              :                 } // CaseIndex=1,NumCases
    2939              :                 //     check that all refrigerated cases attached to a rack are to the same zone if heat rejection location is "Zone"
    2940              :                 //     however, won't matter if walk-in specified
    2941            5 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone && RefrigRack(RackNum).NumCases > 1 &&
    2942            5 :                     RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum != 0 && NumWalkIns < 1 && NumCoils < 1) {
    2943            0 :                     int ZoneNum = RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum;
    2944            0 :                     for (int caseIndex = 2; caseIndex <= RefrigRack(RackNum).NumCases; ++caseIndex) {
    2945            0 :                         if (RefrigCase(RefrigRack(RackNum).CaseNum(caseIndex)).ActualZoneNum == ZoneNum) continue;
    2946            0 :                         ShowSevereError(state,
    2947            0 :                                         format(R"({}{}="{}" : All cases attached to a rack must be in the same zone when {} equals "Zone".)",
    2948              :                                                RoutineName,
    2949              :                                                CurrentModuleObject,
    2950            0 :                                                RefrigRack(RackNum).Name,
    2951              :                                                cAlphaFieldNames(2)));
    2952            0 :                         ErrorsFound = true;
    2953            0 :                         break;
    2954              :                     }
    2955              :                 } // heat rejection location is zone
    2956              :             }     // numcases > 0
    2957              : 
    2958            5 :             if (NumCoils > 0) {
    2959            0 :                 RefrigRack(RackNum).CoilFlag = true;
    2960            0 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    2961            0 :                     int CoilNum = RefrigRack(RackNum).CoilNum(CoilIndex);
    2962              :                     // mark all Coils on rack as used by this system (checking for unused or non-unique Coils)
    2963            0 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    2964              :                     // determine total capacity on rack
    2965            0 :                     RefrigRack(RackNum).TotalRackLoad += WarehouseCoil(CoilNum).RatedSensibleCap;
    2966              :                 } // CoilIndex=1,NumCoils
    2967              :             }     // numcoils > 0
    2968              : 
    2969            5 :             if (NumWalkIns > 0) {
    2970            6 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    2971            3 :                     int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInIndex);
    2972              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    2973            3 :                     ++WalkIn(WalkInID).NumSysAttach;
    2974              :                     // determine total capacity on rack
    2975            3 :                     RefrigRack(RackNum).TotalRackLoad += WalkIn(WalkInID).DesignRatedCap;
    2976              :                 } // WalkInIndex=1,NumWalkIns
    2977              :             }     // NumWalkins
    2978              : 
    2979            5 :             if (NumWalkIns > 0 || NumCoils > 0) {
    2980              :                 // Get the heat rejection Zone node number from the zone name entered by the user (if heatrej location = zone)
    2981            3 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    2982            3 :                     if (lAlphaBlanks(15)) {
    2983            0 :                         ShowSevereError(
    2984              :                             state,
    2985            0 :                             format("{}{}=\"{}{} must be input if walkins or AirChillers connected to rack and heat rejection location = zone.",
    2986              :                                    RoutineName,
    2987              :                                    CurrentModuleObject,
    2988            0 :                                    RefrigRack(RackNum).Name,
    2989              :                                    cAlphaFieldNames(15)));
    2990            0 :                         ErrorsFound = true;
    2991              :                     } else { // alpha (15) not blank
    2992            3 :                         RefrigRack(RackNum).HeatRejectionZoneNum = Util::FindItemInList(Alphas(15), state.dataHeatBal->Zone);
    2993            6 :                         RefrigRack(RackNum).HeatRejectionZoneNodeNum =
    2994            3 :                             DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigRack(RackNum).HeatRejectionZoneNum);
    2995            3 :                         if (RefrigRack(RackNum).HeatRejectionZoneNum == 0) {
    2996            0 :                             ShowSevereError(state,
    2997            0 :                                             format("{}{}=\"{}\", invalid  {} not valid: {}",
    2998              :                                                    RoutineName,
    2999              :                                                    CurrentModuleObject,
    3000            0 :                                                    RefrigRack(RackNum).Name,
    3001              :                                                    cAlphaFieldNames(15),
    3002              :                                                    Alphas(15)));
    3003            0 :                             ErrorsFound = true;
    3004              :                         } else {
    3005            3 :                             state.dataRefrigCase->RefrigPresentInZone(RefrigRack(RackNum).HeatRejectionZoneNum) = true;
    3006              :                         } // zonenum == 0
    3007              :                     }     // alpha 15 blank
    3008              :                 }         // zone heat rej and walk-ins or coils present, must input heat rejection zone
    3009              :             }             // numwalkins or coils > 0
    3010              : 
    3011              :             // set condenser air flow and evap water pump power if autocalculated
    3012              :             // autocalculate condenser evap water pump if needed
    3013            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3014            0 :                 RefrigRack(RackNum).EvapPumpPower == Constant::AutoCalculate) {
    3015            0 :                 RefrigRack(RackNum).EvapPumpPower = CondPumpRatePower * RefrigRack(RackNum).TotalRackLoad;
    3016              :             }
    3017              :             // autocalculate evap condenser air volume flow rate if needed
    3018            5 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3019            0 :                 RefrigRack(RackNum).CondenserAirFlowRate == Constant::AutoCalculate) {
    3020            0 :                 RefrigRack(RackNum).CondenserAirFlowRate = AirVolRateEvapCond * RefrigRack(RackNum).TotalRackLoad;
    3021              :             }
    3022              : 
    3023              :         } // RackNum=1,NumRefrigeratedRacks
    3024              : 
    3025            5 :         state.dataRefrigCase->CheckEquipNameRackWaterCondenser.dimension(state.dataRefrigCase->NumRefrigeratedRacks, true);
    3026              :     } //(NumRefrigeratedRacks > 0)
    3027              : 
    3028          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0 || state.dataRefrigCase->NumTransRefrigSystems > 0) {
    3029              : 
    3030            0 :         if (state.dataRefrigCase->NumRefrigSystems > 0 && state.dataRefrigCase->NumRefrigCondensers == 0) {
    3031            0 :             ShowSevereError(state,
    3032              :                             "Refrigeration:System objects were found during input processing, however no Refrigeration condenser objects (which "
    3033              :                             "may be either: ");
    3034            0 :             ShowContinueError(state,
    3035              :                               " Refrigeration:Condenser:AirCooled, Refrigeration:Condenser:WaterCooled, "
    3036              :                               "Refrigeration:Condenser:EvaporativeCooled,or Refrigeration:Condenser:CascadeCooled) were found.");
    3037            0 :             ErrorsFound = true;
    3038              :         }
    3039            0 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0 && state.dataRefrigCase->NumSimulationGasCooler == 0) {
    3040            0 :             ShowSevereError(state,
    3041              :                             "Refrigeration:TranscriticalSystem objects were found during input processing, however no Refrigeration gas cooler "
    3042              :                             "objects (Refrigeration:GasCooler:AirCooled) were found.");
    3043            0 :             ErrorsFound = true;
    3044              :         }
    3045            0 :         if (state.dataRefrigCase->NumSimulationCompressors == 0) {
    3046            0 :             ShowSevereError(
    3047              :                 state, "Refrigeration:System objects were found during input processing, however no Refrigeration:Compressor objects were found.");
    3048            0 :             ErrorsFound = true;
    3049              :         }
    3050              : 
    3051              :         //************ START CONDENSER INPUT  **************
    3052              : 
    3053            0 :         if (state.dataRefrigCase->NumSimulationCondAir > 0) {
    3054            0 :             CurrentModuleObject = "Refrigeration:Condenser:AirCooled";
    3055            0 :             for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumSimulationCondAir; ++CondNum) {
    3056            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3057              :                                                                          CurrentModuleObject,
    3058              :                                                                          CondNum,
    3059              :                                                                          Alphas,
    3060              :                                                                          NumAlphas,
    3061              :                                                                          Numbers,
    3062              :                                                                          NumNumbers,
    3063              :                                                                          IOStatus,
    3064              :                                                                          lNumericBlanks,
    3065              :                                                                          lAlphaBlanks,
    3066              :                                                                          cAlphaFieldNames,
    3067              :                                                                          cNumericFieldNames);
    3068              : 
    3069            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3070              : 
    3071            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3072            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3073            0 :                 Condenser(CondNum).Name = Alphas(1);
    3074            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3075            0 :                 Condenser(CondNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3076            0 :                 if (Condenser(CondNum).CapCurvePtr == 0) {
    3077            0 :                     ShowSevereError(state,
    3078            0 :                                     format("{}{}=\"{}\", invalid  {} not found:{}",
    3079              :                                            RoutineName,
    3080              :                                            CurrentModuleObject,
    3081            0 :                                            Condenser(CondNum).Name,
    3082              :                                            cAlphaFieldNames(2),
    3083              :                                            Alphas(2)));
    3084            0 :                     ErrorsFound = true;
    3085              :                 }
    3086              : 
    3087              :                 // set start of count for number of systems attached to this condenser
    3088            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3089            0 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3090              : 
    3091              :                 // set CondenserType and rated temperature difference (51.7 - 35)C per ARI 460
    3092            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3093            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3094            0 :                 Condenser(CondNum).RatedDelT = CondARI460DelT; //= 16.7d0 ,Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
    3095            0 :                 Condenser(CondNum).RatedTCondense = CondARI460Tcond;
    3096            0 :                 if (Condenser(CondNum).CapCurvePtr > 0) {
    3097            0 :                     Condenser(CondNum).RatedCapacity = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, CondARI460DelT);
    3098              :                 }
    3099              :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    3100            0 :                 Condenser(CondNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3101            0 :                 if (Condenser(CondNum).RatedCapacity > 0.0) {
    3102            0 :                     Curve::GetCurveMinMaxValues(state, Condenser(CondNum).CapCurvePtr, DelTempMin, DelTempMax);
    3103            0 :                     Real64 Capmin = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMin) *
    3104            0 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug fix
    3105            0 :                     Real64 Capmax = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMax) *
    3106            0 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug
    3107            0 :                     Condenser(CondNum).TempSlope =
    3108            0 :                         (DelTempMax - DelTempMin) / ((Capmax - Capmin)); // * ( 1.0 - 7.17e-5 * Elevation ) ) //Mar 2011 bug fix
    3109            0 :                     Condenser(CondNum).MinCondLoad = Capmax - DelTempMax / Condenser(CondNum).TempSlope;
    3110              :                 } else {
    3111            0 :                     ShowSevereError(state,
    3112            0 :                                     format("{}{}=\"{}\" Condenser capacity curve per ARI 460 must be input and must be greater than 0 Watts at "
    3113              :                                            "16.7C temperature difference.",
    3114              :                                            RoutineName,
    3115              :                                            CurrentModuleObject,
    3116            0 :                                            Condenser(CondNum).Name));
    3117            0 :                     ErrorsFound = true;
    3118              :                 }
    3119              : 
    3120            0 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3121            0 :                 if (!lNumericBlanks(1)) Condenser(CondNum).RatedSubcool = Numbers(1);
    3122              : 
    3123              :                 // Get fan control type
    3124            0 :                 if (lAlphaBlanks(3)) {
    3125            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3126            0 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3127            0 :                                 static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(3)))) == FanSpeedCtrlType::Invalid) {
    3128            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(3), Alphas(3));
    3129            0 :                     ErrorsFound = true;
    3130              :                 } // Set fan control type
    3131              : 
    3132            0 :                 if (!lNumericBlanks(2)) Condenser(CondNum).RatedFanPower = Numbers(2);
    3133            0 :                 if ((lNumericBlanks(2)) || (Numbers(2) < 0.0)) {
    3134            0 :                     ShowSevereError(state,
    3135            0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    3136              :                                            RoutineName,
    3137              :                                            CurrentModuleObject,
    3138            0 :                                            Condenser(CondNum).Name,
    3139              :                                            cNumericFieldNames(2)));
    3140            0 :                     ErrorsFound = true;
    3141              :                 }
    3142              : 
    3143            0 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3144            0 :                 if (!lNumericBlanks(3)) Condenser(CondNum).FanMinAirFlowRatio = Numbers(3);
    3145              : 
    3146              :                 // Check condenser air inlet node connection
    3147              :                 // Jan 2011 - added ability to reject heat to a zone from air-cooled condenser
    3148            0 :                 Condenser(CondNum).CondenserRejectHeatToZone = false;
    3149            0 :                 if (lAlphaBlanks(4)) {
    3150            0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3151              :                 } else { // see if it's an outside air node name or an indoor zone name,
    3152              :                     // have to check inside first because outside check automatically generates an error message
    3153            0 :                     Condenser(CondNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    3154              :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    3155            0 :                     if (Condenser(CondNum).InletAirZoneNum != 0) {
    3156              :                         // set condenser flag (later used to set system flag) and zone flag
    3157            0 :                         Condenser(CondNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, Condenser(CondNum).InletAirZoneNum);
    3158            0 :                         Condenser(CondNum).CondenserRejectHeatToZone = true;
    3159            0 :                         state.dataRefrigCase->RefrigPresentInZone(Condenser(CondNum).InletAirZoneNum) = true;
    3160              :                     } else { // not in a conditioned zone, so see if it's outside
    3161            0 :                         Condenser(CondNum).InletAirNodeNum =
    3162            0 :                             NodeInputManager::GetOnlySingleNode(state,
    3163            0 :                                                                 Alphas(4),
    3164              :                                                                 ErrorsFound,
    3165              :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationCondenserAirCooled,
    3166            0 :                                                                 Alphas(1),
    3167              :                                                                 DataLoopNode::NodeFluidType::Air,
    3168              :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    3169              :                                                                 NodeInputManager::CompFluidStream::Primary,
    3170              :                                                                 DataLoopNode::ObjectIsParent);
    3171            0 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3172              :                             // not outside and not a zone
    3173            0 :                             ShowSevereError(state,
    3174            0 :                                             format("{}{}=\"{}\", {} not found: {}",
    3175              :                                                    RoutineName,
    3176              :                                                    CurrentModuleObject,
    3177            0 :                                                    Condenser(CondNum).Name,
    3178              :                                                    cAlphaFieldNames(4),
    3179              :                                                    Alphas(4)));
    3180            0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    3181            0 :                             ErrorsFound = true;
    3182              :                         } // checkoutairnodenumber
    3183              :                     }     // InletAirZoneNum \=0
    3184              :                 }         // Condenser air inlet node connection
    3185              : 
    3186            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3187            0 :                 if (!lAlphaBlanks(5)) Condenser(CondNum).EndUseSubcategory = Alphas(5);
    3188              : 
    3189            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3190            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3191            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3192            0 :                 if (!lNumericBlanks(4)) Condenser(CondNum).RefOpCharge = Numbers(4);
    3193            0 :                 if (!lNumericBlanks(5)) Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3194            0 :                 if (!lNumericBlanks(6)) Condenser(CondNum).RefPipingInventory = Numbers(6);
    3195              : 
    3196              :             } // Read input for REFRIGERATION:Condenser:AirCooled
    3197              :         }     // NumSimulationCondAir > 0
    3198              : 
    3199            0 :         if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
    3200            0 :             CurrentModuleObject = "Refrigeration:Condenser:EvaporativeCooled";
    3201            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondEvap; ++CondIndex) {
    3202            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir;
    3203            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3204              :                                                                          CurrentModuleObject,
    3205              :                                                                          CondIndex,
    3206              :                                                                          Alphas,
    3207              :                                                                          NumAlphas,
    3208              :                                                                          Numbers,
    3209              :                                                                          NumNumbers,
    3210              :                                                                          IOStatus,
    3211              :                                                                          lNumericBlanks,
    3212              :                                                                          lAlphaBlanks,
    3213              :                                                                          cAlphaFieldNames,
    3214              :                                                                          cNumericFieldNames);
    3215              : 
    3216            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3217              : 
    3218            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3219            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3220            0 :                 Condenser(CondNum).Name = Alphas(1);
    3221            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3222              : 
    3223              :                 // set start of count for number of systems attached to this condenser
    3224            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3225            0 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3226              : 
    3227              :                 // set CondenserType and rated Heat Rejection per ARI 490 rating
    3228            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    3229            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3230            0 :                 Condenser(CondNum).RatedTCondense = CondARI490Tcond;
    3231            0 :                 Condenser(CondNum).RatedDelT = CondARI490DelT;
    3232              : 
    3233            0 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3234            0 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3235              :                 } else {
    3236            0 :                     ShowSevereError(state,
    3237            0 :                                     format("{}{}=\"{}\" {} per ARI 490 must be input and must be greater than 0 Watts.",
    3238              :                                            RoutineName,
    3239              :                                            CurrentModuleObject,
    3240            0 :                                            Condenser(CondNum).Name,
    3241              :                                            cNumericFieldNames(1)));
    3242            0 :                     ErrorsFound = true;
    3243              :                 }
    3244              :                 // Calculate capacity elevation derate factor per ARI 490 barometric pressure correction factor
    3245            0 :                 Condenser(CondNum).EvapElevFact = 1.0 - 3.074e-5 * state.dataEnvrn->Elevation;
    3246              : 
    3247            0 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3248            0 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) Condenser(CondNum).RatedSubcool = Numbers(2);
    3249              : 
    3250              :                 // Get fan control type
    3251            0 :                 if (lAlphaBlanks(2)) {
    3252            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3253            0 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3254            0 :                                 static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(2)))) == FanSpeedCtrlType::Invalid) {
    3255            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3256            0 :                     ErrorsFound = true;
    3257              :                 } // Set fan control type
    3258              : 
    3259            0 :                 Condenser(CondNum).RatedFanPower = Numbers(3);
    3260            0 :                 if (Numbers(3) < 0.0) {
    3261            0 :                     ShowSevereError(state,
    3262            0 :                                     format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    3263              :                                            RoutineName,
    3264              :                                            CurrentModuleObject,
    3265            0 :                                            Condenser(CondNum).Name,
    3266              :                                            cNumericFieldNames(3)));
    3267            0 :                     ErrorsFound = true;
    3268              :                 }
    3269              : 
    3270            0 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3271            0 :                 if (!lNumericBlanks(4)) Condenser(CondNum).FanMinAirFlowRatio = Numbers(4);
    3272              : 
    3273              :                 // Enter min and max and default coefficients for evap condenser HRCF correlation
    3274              :                 // Defaults taken from 2008 BAC equipment for R22, R134a, series CXV
    3275              :                 // Correlation coefficients for other manufacturers are very similar per Hugh Henderson's work
    3276            0 :                 Condenser(CondNum).EvapCoeff1 = 6.63;
    3277            0 :                 Condenser(CondNum).EvapCoeff2 = 0.468;
    3278            0 :                 Condenser(CondNum).EvapCoeff3 = 17.93;
    3279            0 :                 Condenser(CondNum).EvapCoeff4 = -0.322;
    3280            0 :                 Condenser(CondNum).MinCapFacEvap = 0.5;
    3281            0 :                 Condenser(CondNum).MaxCapFacEvap = 5.0;
    3282            0 :                 NumNum = 5; // added warnings if below not blank but unused due to limits
    3283            0 :                 if (!lNumericBlanks(NumNum)) {
    3284            0 :                     if (Numbers(NumNum) >= 0.0) {
    3285            0 :                         Condenser(CondNum).EvapCoeff1 = Numbers(NumNum);
    3286              :                     } else {
    3287            0 :                         ShowWarningError(state,
    3288            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3289              :                                                 CurrentModuleObject,
    3290            0 :                                                 Condenser(CondNum).Name,
    3291              :                                                 cNumericFieldNames(NumNum)));
    3292              :                     }
    3293              :                 }
    3294            0 :                 NumNum = 6; // EvapCoeff2 can't be equal to 0 because used in a denominator
    3295            0 :                 if (!lNumericBlanks(NumNum)) {
    3296            0 :                     if (Numbers(NumNum) > 0.0) {
    3297            0 :                         Condenser(CondNum).EvapCoeff2 = Numbers(NumNum);
    3298              :                     } else {
    3299            0 :                         ShowWarningError(state,
    3300            0 :                                          format("{}=\"{}\", {} is less than or equal to 0 and was not used. Default was used.",
    3301              :                                                 CurrentModuleObject,
    3302            0 :                                                 Condenser(CondNum).Name,
    3303              :                                                 cNumericFieldNames(NumNum)));
    3304              :                     }
    3305              :                 }
    3306            0 :                 NumNum = 7;
    3307            0 :                 if (!lNumericBlanks(NumNum)) {
    3308            0 :                     if (Numbers(NumNum) >= 0.0) {
    3309            0 :                         Condenser(CondNum).EvapCoeff3 = Numbers(NumNum);
    3310              :                     } else {
    3311            0 :                         ShowWarningError(state,
    3312            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3313              :                                                 CurrentModuleObject,
    3314            0 :                                                 Condenser(CondNum).Name,
    3315              :                                                 cNumericFieldNames(NumNum)));
    3316              :                     }
    3317              :                 }
    3318            0 :                 NumNum = 8;
    3319            0 :                 if (!lNumericBlanks(NumNum)) {
    3320            0 :                     if (Numbers(NumNum) >= -20.0) {
    3321            0 :                         Condenser(CondNum).EvapCoeff4 = Numbers(NumNum);
    3322              :                     } else {
    3323            0 :                         ShowWarningError(state,
    3324            0 :                                          format("{}=\"{}\", {} is less than -20 and was not used. Default was used.",
    3325              :                                                 CurrentModuleObject,
    3326            0 :                                                 Condenser(CondNum).Name,
    3327              :                                                 cNumericFieldNames(NumNum)));
    3328              :                     }
    3329              :                 }
    3330            0 :                 NumNum = 9;
    3331            0 :                 if (!lNumericBlanks(NumNum)) {
    3332            0 :                     if (Numbers(NumNum) >= 0.0) {
    3333            0 :                         Condenser(CondNum).MinCapFacEvap = Numbers(NumNum);
    3334              :                     } else {
    3335            0 :                         ShowWarningError(state,
    3336            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3337              :                                                 CurrentModuleObject,
    3338            0 :                                                 Condenser(CondNum).Name,
    3339              :                                                 cNumericFieldNames(NumNum)));
    3340              :                     }
    3341              :                 }
    3342            0 :                 NumNum = 10;
    3343            0 :                 if (!lNumericBlanks(NumNum)) {
    3344            0 :                     if (Numbers(NumNum) >= 0.0) {
    3345            0 :                         Condenser(CondNum).MaxCapFacEvap = Numbers(NumNum);
    3346              :                     } else {
    3347            0 :                         ShowWarningError(state,
    3348            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3349              :                                                 CurrentModuleObject,
    3350            0 :                                                 Condenser(CondNum).Name,
    3351              :                                                 cNumericFieldNames(NumNum)));
    3352              :                     }
    3353              :                 }
    3354              : 
    3355              :                 // Check condenser air inlet node connection
    3356            0 :                 if (lAlphaBlanks(3)) {
    3357            0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3358              :                 } else {
    3359            0 :                     Condenser(CondNum).InletAirNodeNum =
    3360            0 :                         NodeInputManager::GetOnlySingleNode(state,
    3361            0 :                                                             Alphas(3),
    3362              :                                                             ErrorsFound,
    3363              :                                                             DataLoopNode::ConnectionObjectType::RefrigerationCondenserEvaporativeCooled,
    3364            0 :                                                             Alphas(1),
    3365              :                                                             DataLoopNode::NodeFluidType::Air,
    3366              :                                                             DataLoopNode::ConnectionType::OutsideAirReference,
    3367              :                                                             NodeInputManager::CompFluidStream::Primary,
    3368              :                                                             DataLoopNode::ObjectIsParent);
    3369            0 :                     if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3370            0 :                         ShowSevereError(state,
    3371            0 :                                         format("{}{}=\"{}\", {} not found: {}",
    3372              :                                                RoutineName,
    3373              :                                                CurrentModuleObject,
    3374            0 :                                                Condenser(CondNum).Name,
    3375              :                                                cAlphaFieldNames(3),
    3376              :                                                Alphas(3)));
    3377            0 :                         ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    3378            0 :                         ErrorsFound = true;
    3379              :                     }
    3380              :                 } // Condenser air inlet node connection
    3381              : 
    3382            0 :                 NumNum = 11;
    3383            0 :                 Condenser(CondNum).RatedAirFlowRate = Numbers(NumNum);
    3384              :                 // Note the autocalculate feature for this value takes place in the system section because
    3385              :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3386              : 
    3387              :                 // Evaporative condensers basin heater power as a function of temperature must be greater than or equal to 0
    3388            0 :                 NumNum = 12;
    3389            0 :                 Condenser(CondNum).BasinHeaterPowerFTempDiff = Numbers(NumNum);
    3390            0 :                 if (Numbers(NumNum) < 0.0) {
    3391            0 :                     ShowSevereError(
    3392              :                         state,
    3393            0 :                         format(
    3394            0 :                             "{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(NumNum)));
    3395            0 :                     ErrorsFound = true;
    3396              :                 }
    3397              : 
    3398            0 :                 NumNum = 13;
    3399            0 :                 Condenser(CondNum).BasinHeaterSetPointTemp = 2.0; // default
    3400            0 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).BasinHeaterSetPointTemp = Numbers(NumNum);
    3401            0 :                 if (Condenser(CondNum).BasinHeaterSetPointTemp < 2.0) {
    3402            0 :                     ShowWarningError(state,
    3403            0 :                                      format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    3404              :                                             CurrentModuleObject,
    3405            0 :                                             Condenser(CondNum).Name,
    3406              :                                             cNumericFieldNames(NumNum)));
    3407              :                 }
    3408              : 
    3409            0 :                 NumNum = 14;
    3410            0 :                 Condenser(CondNum).EvapPumpPower = 1000.0; // default
    3411            0 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).EvapPumpPower = Numbers(NumNum);
    3412              :                 // Note the autocalculate feature for this value takes place in the system section because
    3413              :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3414              : 
    3415              :                 // Get Evaporative Water System tank connections
    3416            0 :                 Condenser(CondNum).SupplyTankName = Alphas(4);
    3417            0 :                 if (lAlphaBlanks(4)) {
    3418            0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    3419              :                 } else {
    3420            0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    3421            0 :                     WaterManager::SetupTankDemandComponent(state,
    3422            0 :                                                            Condenser(CondNum).Name,
    3423              :                                                            CurrentModuleObject,
    3424            0 :                                                            Condenser(CondNum).SupplyTankName,
    3425              :                                                            ErrorsFound,
    3426            0 :                                                            Condenser(CondNum).EvapWaterSupTankID,
    3427            0 :                                                            Condenser(CondNum).EvapWaterTankDemandARRID);
    3428              :                 }
    3429              : 
    3430            0 :                 if (lAlphaBlanks(5)) {
    3431            0 :                 } else if ((Condenser(CondNum).evapAvailSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) {
    3432            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
    3433            0 :                     ErrorsFound = true;
    3434            0 :                 } else if (!Condenser(CondNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) {
    3435            0 :                     Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(5), Alphas(5), Clusive::In, 0.0);
    3436            0 :                     ErrorsFound = true;
    3437              :                 }
    3438              : 
    3439            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3440            0 :                 if (!lAlphaBlanks(6)) Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3441              : 
    3442            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3443            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3444            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3445            0 :                 NumNum = 15;
    3446            0 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefOpCharge = Numbers(NumNum);
    3447            0 :                 NumNum = 16;
    3448            0 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefReceiverInventory = Numbers(NumNum);
    3449            0 :                 NumNum = 17;
    3450            0 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefPipingInventory = Numbers(NumNum);
    3451              :             } // Read input for CONDENSER:REFRIGERATION:EVAPorativeCooled
    3452              :         }     // If NumSimulationCondEvap > 0
    3453              : 
    3454            0 :         if (state.dataRefrigCase->NumSimulationCondWater > 0) {
    3455            0 :             CurrentModuleObject = "Refrigeration:Condenser:WaterCooled";
    3456            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondWater; ++CondIndex) {
    3457            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap;
    3458            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3459              :                                                                          CurrentModuleObject,
    3460              :                                                                          CondIndex,
    3461              :                                                                          Alphas,
    3462              :                                                                          NumAlphas,
    3463              :                                                                          Numbers,
    3464              :                                                                          NumNumbers,
    3465              :                                                                          IOStatus,
    3466              :                                                                          lNumericBlanks,
    3467              :                                                                          lAlphaBlanks,
    3468              :                                                                          cAlphaFieldNames,
    3469              :                                                                          cNumericFieldNames);
    3470              : 
    3471            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3472              : 
    3473            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3474            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3475            0 :                 Condenser(CondNum).Name = Alphas(1);
    3476            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3477              : 
    3478              :                 // set start of count for number of systems attached to this condenser
    3479            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3480            0 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3481              : 
    3482              :                 // set CondenserType and rated Heat Rejection per ARI 450 rating
    3483            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    3484            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3485            0 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3486            0 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3487              :                 } else {
    3488            0 :                     ShowSevereError(state,
    3489            0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 Watts.",
    3490              :                                            RoutineName,
    3491              :                                            CurrentModuleObject,
    3492            0 :                                            Condenser(CondNum).Name,
    3493              :                                            cNumericFieldNames(1)));
    3494            0 :                     ErrorsFound = true;
    3495              :                 }
    3496              : 
    3497            0 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3498            0 :                     Condenser(CondNum).RatedTCondense = Numbers(2);
    3499              :                 } else {
    3500            0 :                     ShowSevereError(state,
    3501            0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 C.",
    3502              :                                            RoutineName,
    3503              :                                            CurrentModuleObject,
    3504            0 :                                            Condenser(CondNum).Name,
    3505              :                                            cNumericFieldNames(2)));
    3506            0 :                     ErrorsFound = true;
    3507              :                 }
    3508              : 
    3509            0 :                 if (!lNumericBlanks(3)) {
    3510            0 :                     if (Numbers(3) >= 0.0) {
    3511            0 :                         Condenser(CondNum).RatedSubcool = Numbers(3);
    3512              :                     } else {
    3513            0 :                         ShowSevereError(state,
    3514            0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    3515              :                                                RoutineName,
    3516              :                                                CurrentModuleObject,
    3517            0 :                                                Condenser(CondNum).Name,
    3518              :                                                cNumericFieldNames(3)));
    3519            0 :                         ErrorsFound = true;
    3520              :                     }
    3521              :                 } else {
    3522            0 :                     Condenser(CondNum).RatedSubcool = 0.0; // default value
    3523              :                 }
    3524              : 
    3525            0 :                 if ((!lNumericBlanks(4)) && (Numbers(4) > 0.0)) {
    3526            0 :                     Condenser(CondNum).RatedWaterInletT = Numbers(4);
    3527            0 :                     Condenser(CondNum).RatedApproachT = Condenser(CondNum).RatedTCondense - Numbers(4);
    3528              :                 } else {
    3529            0 :                     ShowSevereError(state,
    3530            0 :                                     format("{}{}=\"{}\" {} must be input and greater than zero.",
    3531              :                                            RoutineName,
    3532              :                                            CurrentModuleObject,
    3533            0 :                                            Condenser(CondNum).Name,
    3534              :                                            cNumericFieldNames(4)));
    3535            0 :                     ErrorsFound = true;
    3536              :                 }
    3537              : 
    3538            0 :                 Condenser(CondNum).InletNode =
    3539            0 :                     NodeInputManager::GetOnlySingleNode(state,
    3540            0 :                                                         Alphas(2),
    3541              :                                                         ErrorsFound,
    3542              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3543            0 :                                                         Alphas(1),
    3544              :                                                         DataLoopNode::NodeFluidType::Water,
    3545              :                                                         DataLoopNode::ConnectionType::Inlet,
    3546              :                                                         NodeInputManager::CompFluidStream::Primary,
    3547              :                                                         DataLoopNode::ObjectIsNotParent);
    3548            0 :                 Condenser(CondNum).OutletNode =
    3549            0 :                     NodeInputManager::GetOnlySingleNode(state,
    3550            0 :                                                         Alphas(3),
    3551              :                                                         ErrorsFound,
    3552              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3553            0 :                                                         Alphas(1),
    3554              :                                                         DataLoopNode::NodeFluidType::Water,
    3555              :                                                         DataLoopNode::ConnectionType::Outlet,
    3556              :                                                         NodeInputManager::CompFluidStream::Primary,
    3557              :                                                         DataLoopNode::ObjectIsNotParent);
    3558              :                 // Check node connections
    3559            0 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Water Cooled Condenser Nodes");
    3560              :                 // Get loop flow type
    3561            0 :                 if ((Condenser(CondNum).FlowType = static_cast<CndsrFlowType>(getEnumValue(cndsrFlowTypeNamesUC, Alphas(4)))) ==
    3562              :                     CndsrFlowType::Invalid) {
    3563              : 
    3564            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(4), Alphas(4));
    3565            0 :                     ErrorsFound = true;
    3566              :                 } // Set FlowType
    3567              : 
    3568              :                 // Get outlet temperature schedule for variable flow case
    3569            0 :                 if (Condenser(CondNum).FlowType == CndsrFlowType::Variable) {
    3570            0 :                     if (lAlphaBlanks(5)) {
    3571            0 :                     } else if ((Condenser(CondNum).outletTempSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) {
    3572            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
    3573            0 :                         ErrorsFound = true;
    3574              :                     }
    3575              :                 } // Outlet temperature schedule
    3576              : 
    3577              :                 // Get volumetric flow rate if applicable
    3578            0 :                 else if (Condenser(CondNum).FlowType == CndsrFlowType::Constant) {
    3579            0 :                     if ((!lNumericBlanks(5)) && (Numbers(5) > 0.0)) {
    3580            0 :                         Condenser(CondNum).DesVolFlowRate = Numbers(5);
    3581            0 :                         Condenser(CondNum).VolFlowRate = Numbers(5);
    3582              :                     } else {
    3583            0 :                         ShowSevereError(state,
    3584            0 :                                         format("{}{}=\"{}\" {} must be greater than zero.",
    3585              :                                                RoutineName,
    3586              :                                                CurrentModuleObject,
    3587            0 :                                                Condenser(CondNum).Name,
    3588              :                                                cNumericFieldNames(5)));
    3589            0 :                         ShowContinueError(state, "Revise flow rates.");
    3590            0 :                         ErrorsFound = true;
    3591              :                     }
    3592            0 :                     PlantUtilities::RegisterPlantCompDesignFlow(state, Condenser(CondNum).InletNode, Condenser(CondNum).DesVolFlowRate);
    3593              :                 }
    3594              : 
    3595              :                 // Get maximum flow rates
    3596            0 :                 if (Numbers(6) > 0.0) {
    3597            0 :                     Condenser(CondNum).VolFlowRateMax = Numbers(6);
    3598              :                     // Check constant flow for max violation, if applicable
    3599            0 :                     if (Condenser(CondNum).FlowType == CndsrFlowType::Constant && Condenser(CondNum).VolFlowRate > Numbers(6)) {
    3600            0 :                         ShowSevereError(state,
    3601            0 :                                         format("{}{}=\"{}\" {} > {} .",
    3602              :                                                RoutineName,
    3603              :                                                CurrentModuleObject,
    3604            0 :                                                Condenser(CondNum).Name,
    3605              :                                                cNumericFieldNames(5),
    3606              :                                                cNumericFieldNames(6)));
    3607            0 :                         ShowContinueError(state, "Revise flow rates.");
    3608            0 :                         ErrorsFound = true;
    3609              :                     } // Error check on max flow rate
    3610              :                 } else {
    3611            0 :                     ShowSevereError(state,
    3612            0 :                                     format("{}{}=\"{}\" {} must be greater than zero.",
    3613              :                                            RoutineName,
    3614              :                                            CurrentModuleObject,
    3615            0 :                                            Condenser(CondNum).Name,
    3616              :                                            cNumericFieldNames(6)));
    3617            0 :                     ErrorsFound = true;
    3618              :                 }
    3619              : 
    3620              :                 // Get max/min allowed water temps
    3621            0 :                 Condenser(CondNum).OutletTempMax = Numbers(7);
    3622            0 :                 Condenser(CondNum).InletTempMin = Numbers(8);
    3623              : 
    3624            0 :                 Condenser(CondNum).EndUseSubcategory = "";
    3625            0 :                 if (!lAlphaBlanks(6)) Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3626              : 
    3627            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3628            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3629            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3630            0 :                 if (!lNumericBlanks(9)) Condenser(CondNum).RefOpCharge = Numbers(9);
    3631            0 :                 if (!lNumericBlanks(10)) Condenser(CondNum).RefReceiverInventory = Numbers(10);
    3632            0 :                 if (!lNumericBlanks(11)) Condenser(CondNum).RefPipingInventory = Numbers(11);
    3633              : 
    3634              :             } // Read input for CONDENSER:REFRIGERATION:WaterCooled
    3635              : 
    3636            0 :             state.dataRefrigCase->CheckEquipNameWaterCondenser.dimension(state.dataRefrigCase->NumRefrigCondensers, true);
    3637              :         } // NumSimulationCondWater > 0
    3638              : 
    3639              :         // cascade condensers assumed to provide zero subcooling
    3640            0 :         if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
    3641            0 :             CurrentModuleObject = "Refrigeration:Condenser:Cascade";
    3642            0 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCascadeCondensers; ++CondIndex) {
    3643            0 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
    3644            0 :                               state.dataRefrigCase->NumSimulationCondWater;
    3645            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3646              :                                                                          CurrentModuleObject,
    3647              :                                                                          CondIndex,
    3648              :                                                                          Alphas,
    3649              :                                                                          NumAlphas,
    3650              :                                                                          Numbers,
    3651              :                                                                          NumNumbers,
    3652              :                                                                          IOStatus,
    3653              :                                                                          lNumericBlanks,
    3654              :                                                                          lAlphaBlanks,
    3655              :                                                                          cAlphaFieldNames,
    3656              :                                                                          cNumericFieldNames);
    3657              : 
    3658            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3659              : 
    3660            0 :                 GlobalNames::VerifyUniqueInterObjectName(
    3661            0 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3662            0 :                 Condenser(CondNum).Name = Alphas(1);
    3663            0 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3664              : 
    3665              :                 // set start of count for number of systems attached to this condenser
    3666            0 :                 Condenser(CondNum).NumSysAttach = 0;
    3667            0 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3668              : 
    3669              :                 // set CondenserType
    3670            0 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Cascade;
    3671              : 
    3672            0 :                 if (!lNumericBlanks(1)) {
    3673            0 :                     Condenser(CondNum).RatedTCondense = Numbers(1);
    3674              :                 } else {
    3675            0 :                     ShowSevereError(
    3676              :                         state,
    3677            0 :                         format("{}{}=\"{}\" {} must be input.", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(1)));
    3678            0 :                     ErrorsFound = true;
    3679              :                 }
    3680              : 
    3681            0 :                 if (!lNumericBlanks(2)) {
    3682            0 :                     if (Numbers(2) >= 0.0) {
    3683            0 :                         Condenser(CondNum).RatedApproachT = Numbers(2);
    3684              :                     } else {
    3685            0 :                         ShowSevereError(state,
    3686            0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    3687              :                                                RoutineName,
    3688              :                                                CurrentModuleObject,
    3689            0 :                                                Condenser(CondNum).Name,
    3690              :                                                cNumericFieldNames(2)));
    3691            0 :                         ErrorsFound = true;
    3692              :                     }
    3693              :                 } else {
    3694            0 :                     Condenser(CondNum).RatedApproachT = DefaultCascadeCondApproach;
    3695              :                 }
    3696              : 
    3697            0 :                 if ((!lNumericBlanks(3)) && (Numbers(3) > 0.0)) {
    3698            0 :                     Condenser(CondNum).RatedCapacity = Numbers(3);
    3699              :                 } else {
    3700            0 :                     ShowSevereError(state,
    3701            0 :                                     format("{}{}=\"{}\" {} must be in put and must be greater than or equal to zero.",
    3702              :                                            RoutineName,
    3703              :                                            CurrentModuleObject,
    3704            0 :                                            Condenser(CondNum).Name,
    3705              :                                            cNumericFieldNames(3)));
    3706            0 :                     ErrorsFound = true;
    3707              :                 }
    3708              : 
    3709              :                 // Get condensing temperature type, either fixed by design or allowed to float to match other loads on supply system
    3710            0 :                 if (lAlphaBlanks(2)) {
    3711            0 :                     Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempSet;
    3712            0 :                 } else if ((Condenser(CondNum).CascadeTempControl = static_cast<CascadeCndsrTempCtrlType>(
    3713            0 :                                 getEnumValue(cascaseCndsrTempCtrlTypeNamesUC, Alphas(2)))) == CascadeCndsrTempCtrlType::Invalid) {
    3714            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3715            0 :                     ErrorsFound = true;
    3716              :                 } // string comparison to key choices
    3717              : 
    3718            0 :                 Condenser(CondNum).CascadeRatedEvapTemp = Condenser(CondNum).RatedTCondense - Condenser(CondNum).RatedApproachT;
    3719              : 
    3720              :                 // future - add refrigerant inventory on system side accepting reject heat (as was done for secondary)
    3721            0 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3722            0 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3723            0 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3724            0 :                 if (!lNumericBlanks(4)) Condenser(CondNum).RefOpCharge = Numbers(4);
    3725            0 :                 if (!lNumericBlanks(5)) Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3726            0 :                 if (!lNumericBlanks(6)) Condenser(CondNum).RefPipingInventory = Numbers(6);
    3727              : 
    3728              :             } // Read input for CONDENSER:REFRIGERATION:Cascade
    3729              :         }     // NumSimulationCascadeCondensers > 0
    3730              : 
    3731              :         //************ END CONDENSER INPUT   **************
    3732              : 
    3733              :         //**********  START GAS COOLER INPUT  **********
    3734              : 
    3735            0 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    3736            0 :             CurrentModuleObject = "Refrigeration:GasCooler:AirCooled";
    3737            0 :             for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    3738            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3739              :                                                                          CurrentModuleObject,
    3740              :                                                                          GCNum,
    3741              :                                                                          Alphas,
    3742              :                                                                          NumAlphas,
    3743              :                                                                          Numbers,
    3744              :                                                                          NumNumbers,
    3745              :                                                                          IOStatus,
    3746              :                                                                          lNumericBlanks,
    3747              :                                                                          lAlphaBlanks,
    3748              :                                                                          cAlphaFieldNames,
    3749              :                                                                          cNumericFieldNames);
    3750            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3751              : 
    3752            0 :                 GasCooler(GCNum).Name = Alphas(1);
    3753              : 
    3754            0 :                 GasCooler(GCNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3755            0 :                 if (GasCooler(GCNum).CapCurvePtr == 0) {
    3756            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3757            0 :                     ErrorsFound = true;
    3758              :                 }
    3759              : 
    3760              :                 // set start of count for number of systems attached to this gas cooler
    3761            0 :                 GasCooler(GCNum).NumSysAttach = 0;
    3762            0 :                 if (!allocated(GasCooler(GCNum).SysNum)) GasCooler(GCNum).SysNum.allocate(state.dataRefrigCase->NumTransRefrigSystems);
    3763              : 
    3764            0 :                 GasCooler(GCNum).RatedApproachT = 3.0; // rated CO2 gas cooler approach temperature
    3765            0 :                 if (GasCooler(GCNum).CapCurvePtr > 0) {
    3766            0 :                     GasCooler(GCNum).RatedCapacity = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, GasCooler(GCNum).RatedApproachT);
    3767              :                 }
    3768              :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    3769            0 :                 GasCooler(GCNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3770            0 :                 if (GasCooler(GCNum).RatedCapacity > 0.0) {
    3771            0 :                     Curve::GetCurveMinMaxValues(state, GasCooler(GCNum).CapCurvePtr, DelTempMin, DelTempMax);
    3772            0 :                     Real64 Capmin = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMin) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3773            0 :                     Real64 Capmax = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMax) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3774            0 :                     GasCooler(GCNum).TempSlope = (DelTempMax - DelTempMin) / ((Capmax - Capmin));
    3775            0 :                     GasCooler(GCNum).MinCondLoad = Capmax - DelTempMax / GasCooler(GCNum).TempSlope;
    3776              :                 } else {
    3777            0 :                     ShowSevereError(
    3778              :                         state,
    3779            0 :                         format("{}{}=\"{}\" Gas Cooler capacity curve must be input and must be greater than 0 Watts at 3C temperature difference.",
    3780              :                                RoutineName,
    3781              :                                CurrentModuleObject,
    3782            0 :                                GasCooler(GCNum).Name));
    3783            0 :                     ErrorsFound = true;
    3784              :                 }
    3785              : 
    3786              :                 // Get fan control type
    3787            0 :                 if (lAlphaBlanks(3)) {
    3788            0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3789            0 :                 } else if ((GasCooler(GCNum).FanSpeedControlType = static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(3)))) ==
    3790              :                            FanSpeedCtrlType::Invalid) {
    3791            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(3), Alphas(3));
    3792            0 :                     ErrorsFound = true;
    3793              :                 }
    3794              : 
    3795              :                 // Gas cooler fan power
    3796            0 :                 GasCooler(GCNum).RatedFanPower = 5000.0; // default value
    3797            0 :                 if (!lNumericBlanks(1)) GasCooler(GCNum).RatedFanPower = Numbers(1);
    3798            0 :                 if (Numbers(1) < 0.0) {
    3799            0 :                     ShowSevereError(state,
    3800            0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    3801              :                                            RoutineName,
    3802              :                                            CurrentModuleObject,
    3803            0 :                                            GasCooler(GCNum).Name,
    3804              :                                            cNumericFieldNames(1)));
    3805            0 :                     ErrorsFound = true;
    3806              :                 }
    3807              : 
    3808              :                 // Gas cooler minimum fan air flow ratio
    3809            0 :                 GasCooler(GCNum).FanMinAirFlowRatio = 0.2; // default value
    3810            0 :                 if (!lNumericBlanks(2)) GasCooler(GCNum).FanMinAirFlowRatio = Numbers(2);
    3811            0 :                 if ((GasCooler(GCNum).FanMinAirFlowRatio < 0.0) || (GasCooler(GCNum).FanMinAirFlowRatio > 1.0)) {
    3812            0 :                     ShowSevereError(state,
    3813            0 :                                     format("{}{}=\"{}\" {} must be a value between zero and one.  The default value (0.2) will be used.",
    3814              :                                            RoutineName,
    3815              :                                            CurrentModuleObject,
    3816            0 :                                            GasCooler(GCNum).Name,
    3817              :                                            cNumericFieldNames(2)));
    3818            0 :                     GasCooler(GCNum).FanMinAirFlowRatio = 0.2;
    3819              :                 }
    3820              : 
    3821              :                 // Gas cooler transition temperature
    3822            0 :                 GasCooler(GCNum).TransitionTemperature = 2.7e1; // default value
    3823            0 :                 if (!lNumericBlanks(3)) GasCooler(GCNum).TransitionTemperature = Numbers(3);
    3824            0 :                 if (GasCooler(GCNum).TransitionTemperature < 2.5e1) {
    3825            0 :                     ShowWarningError(state,
    3826            0 :                                      format("{}{}=\"{}\" {} is low (less than 25C).  Consider raising the transition temperature to operate for "
    3827              :                                             "longer periods of time in the subcritical region.",
    3828              :                                             RoutineName,
    3829              :                                             CurrentModuleObject,
    3830            0 :                                             GasCooler(GCNum).Name,
    3831              :                                             cNumericFieldNames(3)));
    3832              :                 }
    3833            0 :                 if (GasCooler(GCNum).TransitionTemperature > 30.978) {
    3834            0 :                     ShowWarningError(
    3835              :                         state,
    3836            0 :                         format("{}{}=\"{}\" {} is greater than the critical temperature of carbon dioxide.  The default value (27C) will be used.",
    3837              :                                RoutineName,
    3838              :                                CurrentModuleObject,
    3839            0 :                                GasCooler(GCNum).Name,
    3840              :                                cNumericFieldNames(3)));
    3841            0 :                     GasCooler(GCNum).TransitionTemperature = 2.7e1;
    3842              :                 }
    3843              : 
    3844              :                 // Gas cooler approach temperature for transcritical operation
    3845            0 :                 GasCooler(GCNum).GasCoolerApproachT = 3.0; // default value
    3846            0 :                 if (!lNumericBlanks(4)) GasCooler(GCNum).GasCoolerApproachT = Numbers(4);
    3847            0 :                 if (GasCooler(GCNum).GasCoolerApproachT < 0.0) {
    3848            0 :                     ShowSevereError(state,
    3849            0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    3850              :                                            RoutineName,
    3851              :                                            CurrentModuleObject,
    3852            0 :                                            GasCooler(GCNum).Name,
    3853              :                                            cNumericFieldNames(4)));
    3854            0 :                     ErrorsFound = true;
    3855              :                 }
    3856              : 
    3857              :                 // Gas cooler temperature difference for subcritical operation
    3858            0 :                 GasCooler(GCNum).SubcriticalTempDiff = 1.0e1; // default value
    3859            0 :                 if (!lNumericBlanks(5)) GasCooler(GCNum).SubcriticalTempDiff = Numbers(5);
    3860            0 :                 if (GasCooler(GCNum).SubcriticalTempDiff < 0.0) {
    3861            0 :                     ShowSevereError(state,
    3862            0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    3863              :                                            RoutineName,
    3864              :                                            CurrentModuleObject,
    3865            0 :                                            GasCooler(GCNum).Name,
    3866              :                                            cNumericFieldNames(5)));
    3867            0 :                     ErrorsFound = true;
    3868              :                 }
    3869              : 
    3870              :                 // Gas cooler minimum condensing temperature for subcritical operation
    3871            0 :                 GasCooler(GCNum).MinCondTemp = 1.0e1; // default value
    3872            0 :                 if (!lNumericBlanks(6)) GasCooler(GCNum).MinCondTemp = Numbers(6);
    3873            0 :                 if (GasCooler(GCNum).MinCondTemp > 30.9) {
    3874            0 :                     ShowSevereError(state,
    3875            0 :                                     format("{}{}=\"{}\" {} must be less than the critical temperature of carbon dioxide (31C).",
    3876              :                                            RoutineName,
    3877              :                                            CurrentModuleObject,
    3878            0 :                                            GasCooler(GCNum).Name,
    3879              :                                            cNumericFieldNames(6)));
    3880            0 :                     ErrorsFound = true;
    3881              :                 }
    3882              : 
    3883              :                 // Check GasCooler air inlet node connection
    3884            0 :                 GasCooler(GCNum).GasCoolerRejectHeatToZone = false;
    3885            0 :                 if (lAlphaBlanks(4)) {
    3886            0 :                     GasCooler(GCNum).InletAirNodeNum = 0;
    3887              :                 } else { // see if it's an outside air node name or an indoor zone name,
    3888              :                     // have to check inside first because outside check automatically generates an error message
    3889            0 :                     GasCooler(GCNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    3890              :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    3891            0 :                     if (GasCooler(GCNum).InletAirZoneNum != 0) {
    3892              :                         // set condenser flag (later used to set system flag) and zone flag
    3893            0 :                         GasCooler(GCNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, GasCooler(GCNum).InletAirZoneNum);
    3894            0 :                         GasCooler(GCNum).GasCoolerRejectHeatToZone = true;
    3895            0 :                         state.dataRefrigCase->RefrigPresentInZone(GasCooler(GCNum).InletAirZoneNum) = true;
    3896              :                     } else { // not in a conditioned zone, so see if it's outside
    3897            0 :                         GasCooler(GCNum).InletAirNodeNum =
    3898            0 :                             NodeInputManager::GetOnlySingleNode(state,
    3899            0 :                                                                 Alphas(4),
    3900              :                                                                 ErrorsFound,
    3901              :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationGasCoolerAirCooled,
    3902            0 :                                                                 Alphas(1),
    3903              :                                                                 DataLoopNode::NodeFluidType::Air,
    3904              :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    3905              :                                                                 NodeInputManager::CompFluidStream::Primary,
    3906              :                                                                 DataLoopNode::ObjectIsParent);
    3907            0 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, GasCooler(GCNum).InletAirNodeNum)) {
    3908              :                             // not outside and not a zone
    3909            0 :                             ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), Alphas(4));
    3910            0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    3911            0 :                             ErrorsFound = true;
    3912              :                         } // checkoutairnodenumber
    3913              :                     }     // InletAirZoneNum \=0
    3914              :                 }         // Gas cooler air inlet node connection
    3915              : 
    3916            0 :                 GasCooler(GCNum).EndUseSubcategory = "";
    3917            0 :                 if (!lAlphaBlanks(5)) GasCooler(GCNum).EndUseSubcategory = Alphas(5);
    3918              : 
    3919            0 :                 GasCooler(GCNum).RefOpCharge = 0.0;
    3920            0 :                 GasCooler(GCNum).RefReceiverInventory = 0.0;
    3921            0 :                 GasCooler(GCNum).RefPipingInventory = 0.0;
    3922            0 :                 if (!lNumericBlanks(7)) GasCooler(GCNum).RefOpCharge = Numbers(7);
    3923            0 :                 if (!lNumericBlanks(8)) GasCooler(GCNum).RefReceiverInventory = Numbers(8);
    3924            0 :                 if (!lNumericBlanks(9)) GasCooler(GCNum).RefPipingInventory = Numbers(9);
    3925              : 
    3926              :             } // Read input for REFRIGERATION:GasCooler:AirCooled
    3927              :         }     // NumSimulationGasCooler > 0
    3928              : 
    3929              :         //**********  END GAS COOLER INPUT  **********
    3930              : 
    3931              :         //************ START SECONDARY LOOP INPUT (before system input) **************
    3932            0 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    3933            0 :             CurrentModuleObject = "Refrigeration:SecondarySystem";
    3934            0 :             for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    3935            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3936              :                                                                          CurrentModuleObject,
    3937              :                                                                          SecondaryNum,
    3938              :                                                                          Alphas,
    3939              :                                                                          NumAlphas,
    3940              :                                                                          Numbers,
    3941              :                                                                          NumNumbers,
    3942              :                                                                          IOStatus,
    3943              :                                                                          lNumericBlanks,
    3944              :                                                                          lAlphaBlanks,
    3945              :                                                                          cAlphaFieldNames,
    3946              :                                                                          cNumericFieldNames);
    3947              : 
    3948            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3949            0 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    3950              : 
    3951            0 :                 Secondary(SecondaryNum).Name = Alphas(1);
    3952              : 
    3953              :                 //   Find the loads on the secondary loop: can be input in form of case or walkin or CaseAndWalkInList names
    3954            0 :                 Real64 NominalTotalCaseCap = 0.0;
    3955            0 :                 NumCases = 0;
    3956            0 :                 Real64 NominalTotalCoilCap = 0.0;
    3957            0 :                 int NumCoils = 0;
    3958            0 :                 NumWalkIns = 0;
    3959            0 :                 Real64 NominalTotalWalkInCap = 0.0;
    3960            0 :                 Secondary(SecondaryNum).RefInventory = 0.0;
    3961              : 
    3962              :                 //   Read display case and walkin assignments for this secondary
    3963            0 :                 AlphaNum = 2;
    3964            0 :                 if (lAlphaBlanks(AlphaNum)) {
    3965              :                     // No cases or walkins specified, ie, secondary has no load
    3966            0 :                     ShowSevereError(state,
    3967            0 :                                     format("{}{}=\"{}\", has no loads, must have at least one of: {}",
    3968              :                                            RoutineName,
    3969              :                                            CurrentModuleObject,
    3970            0 :                                            Secondary(SecondaryNum).Name,
    3971              :                                            cAlphaFieldNames(AlphaNum)));
    3972            0 :                     ErrorsFound = true;
    3973              :                 } else { // (.NOT. lAlphaBlanks(AlphaNum))
    3974              : 
    3975              :                     // Entry for Alphas(AlphaNum) can be either a Case, WalkIn Coil, or CaseAndWalkInList name
    3976            0 :                     int CaseAndWalkInListNum = 0;
    3977            0 :                     int CaseNum = 0;
    3978            0 :                     int WalkInNum = 0;
    3979            0 :                     int CoilNum = 0;
    3980            0 :                     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    3981            0 :                         CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    3982            0 :                     if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    3983            0 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    3984            0 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    3985            0 :                     int NumNameMatches = 0;
    3986            0 :                     if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    3987            0 :                     if (CaseNum != 0) ++NumNameMatches;
    3988            0 :                     if (WalkInNum != 0) ++NumNameMatches;
    3989            0 :                     if (CoilNum != 0) ++NumNameMatches;
    3990              : 
    3991            0 :                     if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    3992            0 :                         ErrorsFound = true;
    3993            0 :                         if (NumNameMatches == 0) {
    3994            0 :                             ShowSevereError(state,
    3995            0 :                                             format("{}{}=\"{}\", has an invalid {}: {}",
    3996              :                                                    RoutineName,
    3997              :                                                    CurrentModuleObject,
    3998            0 :                                                    Secondary(SecondaryNum).Name,
    3999              :                                                    cAlphaFieldNames(AlphaNum),
    4000              :                                                    Alphas(AlphaNum)));
    4001            0 :                         } else if (NumNameMatches > 1) {
    4002            0 :                             ShowSevereError(state,
    4003            0 :                                             format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    4004              :                                                    RoutineName,
    4005              :                                                    CurrentModuleObject,
    4006            0 :                                                    Secondary(SecondaryNum).Name,
    4007              :                                                    cAlphaFieldNames(AlphaNum),
    4008              :                                                    Alphas(AlphaNum)));
    4009              :                         }                                   // num matches = 0 or > 1
    4010            0 :                     } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    4011            0 :                         NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    4012            0 :                         NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    4013            0 :                         NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    4014            0 :                         Secondary(SecondaryNum).NumCases = NumCases;
    4015            0 :                         Secondary(SecondaryNum).NumCoils = NumCoils;
    4016            0 :                         Secondary(SecondaryNum).NumWalkIns = NumWalkIns;
    4017            0 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4018            0 :                         Secondary(SecondaryNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    4019            0 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4020            0 :                         Secondary(SecondaryNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    4021            0 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4022            0 :                         Secondary(SecondaryNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    4023            0 :                     } else if (CaseNum != 0) { // Name points to a case
    4024            0 :                         NumCases = 1;
    4025            0 :                         Secondary(SecondaryNum).NumCases = 1;
    4026            0 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4027            0 :                         Secondary(SecondaryNum).CaseNum(NumCases) = CaseNum;
    4028            0 :                     } else if (CoilNum != 0) { // Name points to a coil
    4029            0 :                         NumCoils = 1;
    4030            0 :                         Secondary(SecondaryNum).NumCoils = 1;
    4031            0 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4032            0 :                         Secondary(SecondaryNum).CoilNum(NumCoils) = CoilNum;
    4033            0 :                     } else if (WalkInNum != 0) { // Name points to a walkin
    4034            0 :                         NumWalkIns = 1;
    4035            0 :                         Secondary(SecondaryNum).NumWalkIns = 1;
    4036            0 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4037            0 :                         Secondary(SecondaryNum).WalkInNum(NumWalkIns) = WalkInNum;
    4038              :                     } // NumNameMatches /= 1
    4039              :                 }     // blank input for loads on secondary
    4040              : 
    4041            0 :                 if (NumCases > 0) {
    4042              :                     // Find lowest design T loop fluid out of secondary chiller
    4043              :                     // Sum rated capacity of all cases on Secondary
    4044            0 :                     for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    4045              :                         // mark all cases on Secondary as used by this Secondary - checking for unused or non-unique cases
    4046            0 :                         int CaseNum = Secondary(SecondaryNum).CaseNum(caseIndex);
    4047            0 :                         ++RefrigCase(CaseNum).NumSysAttach;
    4048            0 :                         NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedRTF;
    4049            0 :                         Secondary(SecondaryNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    4050            0 :                         if (caseIndex == 1) { // look for lowest case design evap T for Secondary
    4051            0 :                             Secondary(SecondaryNum).TMinNeeded = RefrigCase(CaseNum).EvapTempDesign;
    4052              :                         } else {
    4053            0 :                             Secondary(SecondaryNum).TMinNeeded = min(RefrigCase(CaseNum).EvapTempDesign, Secondary(SecondaryNum).TMinNeeded);
    4054              :                         }
    4055              :                     } // CaseIndex=1,NumCases
    4056              :                 }     // Numcases > 0
    4057              : 
    4058            0 :                 if (NumCoils > 0) {
    4059              :                     // Find lowest design T loop fluid out of secondary chiller
    4060              :                     // Sum rated capacity of all Coils on Secondary
    4061            0 :                     for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    4062              :                         // mark all Coils on Secondary as used by this Secondary - checking for unused or non-unique Coils
    4063            0 :                         int CoilNum = Secondary(SecondaryNum).CoilNum(CoilIndex);
    4064            0 :                         ++WarehouseCoil(CoilNum).NumSysAttach;
    4065            0 :                         NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    4066            0 :                         Secondary(SecondaryNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    4067            0 :                         if ((CoilIndex == 1) && (NumCases == 0)) { // look for lowest Coil design evap T for Secondary
    4068            0 :                             Secondary(SecondaryNum).TMinNeeded = WarehouseCoil(CoilNum).TEvapDesign;
    4069              :                         } else {
    4070            0 :                             Secondary(SecondaryNum).TMinNeeded = min(WarehouseCoil(CoilNum).TEvapDesign, Secondary(SecondaryNum).TMinNeeded);
    4071              :                         }
    4072              :                     } // CoilIndex=1,NumCoils
    4073              :                 }     // NumCoils > 0
    4074              : 
    4075            0 :                 if (NumWalkIns > 0) {
    4076              :                     // Find lowest design T loop fluid out of secondary chiller
    4077              :                     // Sum rated capacity of all WalkIns on Secondary
    4078            0 :                     for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    4079              :                         // mark all WalkIns on Secondary as used by this Secondary - checking for unused or non-unique WalkIns
    4080            0 :                         int WalkInID = Secondary(SecondaryNum).WalkInNum(WalkInIndex);
    4081            0 :                         ++WalkIn(WalkInID).NumSysAttach;
    4082            0 :                         NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    4083            0 :                         Secondary(SecondaryNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    4084            0 :                         if ((WalkInIndex == 1) && (NumCases == 0) && (NumCoils == 0)) { // look for lowest load design evap T for Secondary
    4085            0 :                             Secondary(SecondaryNum).TMinNeeded = WalkIn(WalkInID).TEvapDesign;
    4086              :                         } else {
    4087            0 :                             Secondary(SecondaryNum).TMinNeeded = min(Secondary(SecondaryNum).TMinNeeded, WalkIn(WalkInID).TEvapDesign);
    4088              :                         }
    4089              :                     } // WalkInIndex=1,NumWalkIns
    4090              :                 }     // Numwalkins > 0
    4091              : 
    4092              :                 // Get circulating fluid type
    4093            0 :                 AlphaNum = 3;
    4094            0 :                 if (lAlphaBlanks(AlphaNum)) {
    4095            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4096            0 :                     ErrorsFound = true;
    4097            0 :                 } else if ((Secondary(SecondaryNum).FluidType = static_cast<SecFluidType>(getEnumValue(secFluidTypeNamesUC, Alphas(AlphaNum)))) ==
    4098              :                            SecFluidType::Invalid) {
    4099            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4100            0 :                     ErrorsFound = true;
    4101              :                 } // Set FluidType
    4102              : 
    4103            0 :                 AlphaNum = 4;
    4104            0 :                 Secondary(SecondaryNum).FluidName = Alphas(AlphaNum);
    4105            0 :                 if (Secondary(SecondaryNum).FluidName.empty()) {
    4106            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4107            0 :                     ErrorsFound = true;
    4108            0 :                 } else if ((Secondary(SecondaryNum).glycol = Fluid::GetGlycol(state, Secondary(SecondaryNum).FluidName)) != nullptr) {
    4109            0 :                 } else if ((Secondary(SecondaryNum).refrig = Fluid::GetRefrig(state, Secondary(SecondaryNum).FluidName)) != nullptr) {
    4110              :                 } else {
    4111            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4112            0 :                     ErrorsFound = true;
    4113              :                 }
    4114              : 
    4115              :                 // Error messages for refrigerants and glycols already found in fluidproperties
    4116              : 
    4117              :                 // Note remainder of inputs for secondary don't follow IDD input order because of different interpretations
    4118              :                 //   and intermediate calculations used to assign default values for brine type vs. liquid overfeed/phase change loops
    4119              : 
    4120            0 :                 if (!lNumericBlanks(3)) {
    4121            0 :                     Secondary(SecondaryNum).TEvapDesign = Numbers(3);
    4122              :                 } else {
    4123            0 :                     ShowSevereError(state,
    4124            0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4125              :                                            RoutineName,
    4126              :                                            CurrentModuleObject,
    4127            0 :                                            Secondary(SecondaryNum).Name,
    4128              :                                            cNumericFieldNames(3)));
    4129            0 :                     ErrorsFound = true;
    4130              :                 } // blank on N3
    4131              : 
    4132            0 :                 if (!lNumericBlanks(4)) {
    4133            0 :                     Secondary(SecondaryNum).TApproachDifRated = Numbers(4);
    4134              :                 } else {
    4135            0 :                     ShowSevereError(state,
    4136            0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4137              :                                            RoutineName,
    4138              :                                            CurrentModuleObject,
    4139            0 :                                            Secondary(SecondaryNum).Name,
    4140              :                                            cNumericFieldNames(4)));
    4141            0 :                     ErrorsFound = true;
    4142              :                 } // blank on N4
    4143              : 
    4144              :                 //^^^^^^^Now look at input and once-only calculations required only for liquid/brine secondary loops^^^^^^^^^^^^^^^^^^^^^^
    4145              :                 //   Ensure that required input data is not missing prior to performing the following once-only calculations
    4146            0 :                 if (ErrorsFound) {
    4147            0 :                     ShowFatalError(state,
    4148            0 :                                    format("{}{}=\"{}\", Program terminated due to previous condition(s).",
    4149              :                                           RoutineName,
    4150              :                                           CurrentModuleObject,
    4151            0 :                                           Secondary(SecondaryNum).Name));
    4152              :                 } // ErrorsFound
    4153              : 
    4154            0 :                 Real64 CpBrineRated = 0.0;
    4155            0 :                 Real64 PumpTotRatedFlowVol(0.0);   // Rated flow from input pump data, m3/s
    4156            0 :                 Real64 SecondaryFlowVolRated(0.0); // Rated flow of secondary fluid, used to calculate capacity (m3/s)
    4157            0 :                 Real64 TBrineOutRated(0.0);        // Rated temperature of circ fluid LEAVING heat exchanger,C
    4158            0 :                 Real64 TBrineInRated(0.0);         // Rated temperature of circ fluid going INTO heat exchanger, C
    4159              : 
    4160            0 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4161            0 :                     if (!lNumericBlanks(5)) {
    4162            0 :                         Secondary(SecondaryNum).TRangeDifRated = Numbers(5);
    4163              :                     } else {
    4164            0 :                         ShowSevereError(state,
    4165            0 :                                         format("{}{}=\"{}\", {} must be specified.",
    4166              :                                                RoutineName,
    4167              :                                                CurrentModuleObject,
    4168            0 :                                                Secondary(SecondaryNum).Name,
    4169              :                                                cNumericFieldNames(5)));
    4170            0 :                         ShowContinueError(state, format("...when {}=\"FluidAlwaysLiquid\".", cAlphaFieldNames(3)));
    4171            0 :                         ErrorsFound = true;
    4172              :                     } // blank on N5
    4173              : 
    4174              :                     // Get fluid properties at rated conditions, will be used to calculate ht exchgr effectiveness
    4175            0 :                     TBrineOutRated = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4176            0 :                     TBrineInRated = TBrineOutRated + Secondary(SecondaryNum).TRangeDifRated;
    4177            0 :                     Real64 TBrineAverage = (TBrineOutRated + TBrineInRated) / 2.0;
    4178            0 :                     Secondary(SecondaryNum).TBrineAverage = TBrineAverage;
    4179            0 :                     DensityBrineRated = Secondary(SecondaryNum).glycol->getDensity(state, TBrineAverage, TrackMessage);
    4180            0 :                     Secondary(SecondaryNum).DensityBrineRated = DensityBrineRated;
    4181            0 :                     CpBrineRated = Secondary(SecondaryNum).glycol->getSpecificHeat(state, TBrineAverage, TrackMessage);
    4182            0 :                     Secondary(SecondaryNum).CpBrineRated = CpBrineRated;
    4183              : 
    4184              :                     // Users can input either design brine flow (m3/s), or capacity in W, or both.  Now have
    4185              :                     //  temperatures needed to calculate either the loop cooling capacity or fluid flow rate, if one was not input
    4186              :                     //  Don't need to save as a flow vol as a permanent var because calc whichever is missing here
    4187            0 :                     Real64 FlowMassRated(0.0); // Design mass flow rate of circ fluid in secondary loop(kg/s)
    4188            0 :                     if ((!lNumericBlanks(1)) && (!lNumericBlanks(2))) {
    4189              :                         // Both values input, check for approximate agreement
    4190            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4191            0 :                         SecondaryFlowVolRated = Numbers(2);
    4192            0 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4193            0 :                         Real64 NominalSecondaryCapacity = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4194            0 :                         Real64 TestDelta = (NominalSecondaryCapacity - Secondary(SecondaryNum).CoolingLoadRated) / NominalSecondaryCapacity;
    4195            0 :                         if (std::abs(TestDelta) > 0.2) {
    4196            0 :                             ShowWarningError(state,
    4197            0 :                                              format("{}=\"{} You may wish to check the system definition. Based upon the design flow rate and "
    4198              :                                                     "range temperature difference,  The nominal secondary loop heat exchanger capacity is, "
    4199              :                                                     "{:.0R} but the specified design capacity is,  {:.0R}",
    4200              :                                                     CurrentModuleObject,
    4201            0 :                                                     Secondary(SecondaryNum).Name,
    4202              :                                                     NominalSecondaryCapacity,
    4203            0 :                                                     Secondary(SecondaryNum).CoolingLoadRated));
    4204              :                         }
    4205            0 :                     } else if (!lNumericBlanks(1)) {
    4206            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4207              :                         // Calc flow vol rated
    4208            0 :                         FlowMassRated = Secondary(SecondaryNum).CoolingLoadRated / (CpBrineRated * Secondary(SecondaryNum).TRangeDifRated);
    4209            0 :                         SecondaryFlowVolRated = FlowMassRated / DensityBrineRated;
    4210            0 :                     } else if (!lNumericBlanks(2)) {
    4211            0 :                         SecondaryFlowVolRated = Numbers(2);
    4212              :                         // Calc rated load
    4213            0 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4214            0 :                         Secondary(SecondaryNum).CoolingLoadRated = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4215              :                     } else {
    4216            0 :                         ShowSevereError(state,
    4217            0 :                                         format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4218              :                                                RoutineName,
    4219              :                                                CurrentModuleObject,
    4220            0 :                                                Secondary(SecondaryNum).Name,
    4221              :                                                cNumericFieldNames(1),
    4222              :                                                cNumericFieldNames(2)));
    4223            0 :                         ErrorsFound = true;
    4224              :                     } // Capacity Input via either or both options
    4225              : 
    4226            0 :                     if (!ErrorsFound) {
    4227              :                         // Calculate heat exchanger effectiveness based on rated flow and temperature differences
    4228            0 :                         Secondary(SecondaryNum).HeatExchangeEta =
    4229            0 :                             Secondary(SecondaryNum).CoolingLoadRated /
    4230            0 :                             (FlowMassRated * CpBrineRated * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign));
    4231            0 :                         Secondary(SecondaryNum).TBrineInRated = TBrineInRated;
    4232            0 :                         if (Secondary(SecondaryNum).HeatExchangeEta > 0.99) {
    4233            0 :                             ShowWarningError(
    4234              :                                 state,
    4235            0 :                                 format("{}=\"{} You may wish to check the system definition.  The heat exchanger effectiveness is, {:.2R}",
    4236              :                                        CurrentModuleObject,
    4237            0 :                                        Secondary(SecondaryNum).Name,
    4238            0 :                                        Secondary(SecondaryNum).HeatExchangeEta));
    4239            0 :                             Secondary(SecondaryNum).HeatExchangeEta = 0.99;
    4240              :                         }
    4241              :                     } else {
    4242            0 :                         ShowContinueError(state, "...remainder of this object input skipped due to previous errors");
    4243            0 :                         continue;
    4244              :                     }
    4245              : 
    4246            0 :                     PumpTotRatedFlowVol = SecondaryFlowVolRated;
    4247            0 :                     if (!lNumericBlanks(7)) PumpTotRatedFlowVol = Numbers(7);
    4248              : 
    4249              :                 } else { // FluidType = FluidTypePhaseChange     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4250            0 :                     if (!lNumericBlanks(1)) {
    4251            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4252              :                     } else {
    4253            0 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalTotalCaseCap + NominalTotalWalkInCap;
    4254              :                         // first estimate, will later be adjusted to include pump power
    4255              :                     } // input capacity
    4256              : 
    4257            0 :                     Secondary(SecondaryNum).TCondense = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4258            0 :                     Secondary(SecondaryNum).CircRate = DefaultCircRate;
    4259            0 :                     if (!lNumericBlanks(10)) Secondary(SecondaryNum).CircRate = Numbers(10);
    4260              : 
    4261              :                     DensityPhaseChange =
    4262            0 :                         Secondary(SecondaryNum).refrig->getSatDensity(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4263            0 :                     DeltaHPhaseChange =
    4264            0 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 1.0, TrackMessageAlt) -
    4265            0 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4266              : 
    4267              :                     // TotRatedFlowVol= capacity*circrate/deltahphasechange/density
    4268              :                     Real64 CalcTotFlowVol =
    4269            0 :                         Secondary(SecondaryNum).CoolingLoadRated * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4270            0 :                     PumpTotRatedFlowVol = CalcTotFlowVol;
    4271            0 :                     if (!lNumericBlanks(7)) {
    4272            0 :                         PumpTotRatedFlowVol = Numbers(7);
    4273            0 :                         Real64 CalcCircRate = DensityPhaseChange * DeltaHPhaseChange * PumpTotRatedFlowVol / Secondary(SecondaryNum).CoolingLoadRated;
    4274            0 :                         Real64 DiffCircRates = (CalcCircRate - Secondary(SecondaryNum).CircRate) / Secondary(SecondaryNum).CircRate;
    4275            0 :                         if (std::abs(DiffCircRates) > 0.3) {
    4276            0 :                             ShowWarningError(state,
    4277            0 :                                              format("{}=\"{} {} Produces a circulating rate of {:.2R} ;  A circulating rate of {:.2R} would need "
    4278              :                                                     "a {} of {:.2R} m3/s",
    4279              :                                                     CurrentModuleObject,
    4280            0 :                                                     Secondary(SecondaryNum).Name,
    4281              :                                                     cNumericFieldNames(7),
    4282              :                                                     CalcCircRate,
    4283            0 :                                                     Secondary(SecondaryNum).CircRate,
    4284              :                                                     cNumericFieldNames(7),
    4285              :                                                     CalcTotFlowVol));
    4286              :                         } // warning check on pump flow rate vs circ rate input
    4287              :                     }     // blank pump flow rate
    4288            0 :                     SecondaryFlowVolRated = PumpTotRatedFlowVol;
    4289              : 
    4290              :                 } // fluid type AlwaysLiquid or PhaseChange ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4291              : 
    4292              :                 // Read number of pumps (or pump stages) in secondary loop
    4293            0 :                 int NumPumps = 1; // default value
    4294            0 :                 if ((!lNumericBlanks(6)) && (Numbers(6) >= 1)) NumPumps = Numbers(6);
    4295            0 :                 Secondary(SecondaryNum).NumPumps = NumPumps;
    4296              :                 // Get pump power (users can input either power in W or head in Pa or both)
    4297              :                 // Assume pump impeller efficiency is 0.78 (consistent with E+ Pump auto-sizing assumption)
    4298              :                 // Assume pump motor efficiency is 0.85 (Goulds Pumps motor data sheet)
    4299              :                 // It is important that tot rated head must be for specific fluid
    4300            0 :                 Real64 PumpTotRatedHead(0.0); // Total pump rated head on secondary loop (Pa)
    4301              : 
    4302            0 :                 if ((!lNumericBlanks(8)) && (!lNumericBlanks(9))) {
    4303            0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4304            0 :                     PumpTotRatedHead = Numbers(9);
    4305            0 :                     Real64 ErrSecondPumpPower = (Secondary(SecondaryNum).PumpTotRatedPower -
    4306            0 :                                                  PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency)) /
    4307            0 :                                                 Secondary(SecondaryNum).PumpTotRatedPower;
    4308            0 :                     if (std::abs(ErrSecondPumpPower) > 0.35)
    4309            0 :                         ShowWarningError(
    4310              :                             state,
    4311            0 :                             format("{}=\"{} Input value for {} not consistent with input value for {}. {} will be used",
    4312              :                                    CurrentModuleObject,
    4313            0 :                                    Secondary(SecondaryNum).Name,
    4314              :                                    cNumericFieldNames(9),
    4315              :                                    cNumericFieldNames(8),
    4316              :                                    cNumericFieldNames(8))); // generous diff allowed because comparing to my assumed impeller and motor effs
    4317            0 :                 } else if (!lNumericBlanks(8)) {
    4318            0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4319            0 :                 } else if (!lNumericBlanks(9)) {
    4320            0 :                     PumpTotRatedHead = Numbers(9);
    4321            0 :                     Secondary(SecondaryNum).PumpTotRatedPower =
    4322            0 :                         PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4323              :                 } else {
    4324            0 :                     ShowSevereError(state,
    4325            0 :                                     format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4326              :                                            RoutineName,
    4327              :                                            CurrentModuleObject,
    4328            0 :                                            Secondary(SecondaryNum).Name,
    4329              :                                            cNumericFieldNames(8),
    4330              :                                            cNumericFieldNames(9)));
    4331            0 :                     ErrorsFound = true;
    4332              :                 } // Either or pump power Input variations (head or power)
    4333              : 
    4334              :                 // Get pump drive type
    4335            0 :                 AlphaNum = 5;
    4336            0 :                 if (lAlphaBlanks(AlphaNum)) {
    4337            0 :                     Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Constant; // default
    4338            0 :                 } else if ((Secondary(SecondaryNum).PumpControlType = static_cast<SecPumpCtrl>(getEnumValue(secPumpCtrlNamesUC, Alphas(AlphaNum)))) ==
    4339              :                            SecPumpCtrl::Invalid) {
    4340            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4341            0 :                     ErrorsFound = true;
    4342              :                 }
    4343              : 
    4344              :                 //  Print warning if Pump Control = Constant and Variable Speed Curve is specified.
    4345            0 :                 if ((Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) && (!lAlphaBlanks(AlphaNum + 1))) {
    4346            0 :                     ShowWarningError(state,
    4347            0 :                                      format(R"({}{}="{}", A {} is specified even though {} is "CONSTANT".)",
    4348              :                                             RoutineName,
    4349              :                                             CurrentModuleObject,
    4350            0 :                                             Secondary(SecondaryNum).Name,
    4351              :                                             cAlphaFieldNames(AlphaNum + 1),
    4352              :                                             cAlphaFieldNames(AlphaNum)));
    4353            0 :                     ShowContinueError(state,
    4354            0 :                                       format("The secondary loop pump(s) will be modeled as constant speed and the {} will be ignored.",
    4355              :                                              cAlphaFieldNames(AlphaNum + 1)));
    4356              :                 }
    4357              : 
    4358            0 :                 if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4359              :                     // Set incremental flow and power amounts for pump dispatch
    4360            0 :                     Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4361            0 :                     Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4362              :                 } else { // Variable speed drive need to read in power curve
    4363            0 :                     AlphaNum = 6;
    4364            0 :                     Secondary(SecondaryNum).VarSpeedCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    4365            0 :                     if (Secondary(SecondaryNum).VarSpeedCurvePtr == 0) {
    4366            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4367            0 :                         ErrorsFound = true;
    4368              :                     }
    4369            0 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    4370            0 :                                                          Secondary(SecondaryNum).VarSpeedCurvePtr, // Curve index
    4371              :                                                          {1},                                      // Valid dimensions
    4372              :                                                          RoutineName,                              // Routine name
    4373              :                                                          CurrentModuleObject,                      // Object Type
    4374            0 :                                                          Secondary(SecondaryNum).Name,             // Object Name
    4375            0 :                                                          cAlphaFieldNames(AlphaNum));              // Field Name
    4376              :                 } // input power conditions/levels for constant or variable speed pump drives
    4377              : 
    4378              :                 // Default non-hermetic motor eff at 85% and all shaft power goes to heat in fluid
    4379              :                 // In a semi-hermetic motor, assume all power to motor goes to heat in fluid
    4380            0 :                 Secondary(SecondaryNum).PumpPowerToHeat = PumpMotorEfficiency;
    4381            0 :                 NumNum = 11;
    4382            0 :                 if (!lNumericBlanks(NumNum)) {
    4383            0 :                     if ((0.5 <= Numbers(NumNum)) && (1.0 >= Numbers(NumNum))) {
    4384            0 :                         Secondary(SecondaryNum).PumpPowerToHeat = Numbers(NumNum);
    4385              :                     } else {
    4386            0 :                         ShowWarningError(state,
    4387            0 :                                          format("{}{}=\"{}\" {} must be between 0.5 and 1.0. Default value of : {:.3R} will be used",
    4388              :                                                 RoutineName,
    4389              :                                                 CurrentModuleObject,
    4390            0 :                                                 Secondary(SecondaryNum).Name,
    4391              :                                                 cNumericFieldNames(NumNum),
    4392              :                                                 PumpMotorEfficiency));
    4393              :                     } // range of pump moter heat to fluid
    4394              :                 }     // blank input for pumppowertoheat
    4395              : 
    4396              :                 // Distribution piping heat gain - optional
    4397              :                 //  Input UA and Zone containing the bulk of the secondary coolant distribution piping
    4398              :                 //  This Zone ID will be used to determine the temperature used for distribution piping heat gain.
    4399              :                 //  Zone Id is only required if Sum UA Distribution Piping >0.0
    4400              :                 //  Get the Zone node number from the zone name entered by the user
    4401            0 :                 Secondary(SecondaryNum).SumUADistPiping = 0.0;
    4402            0 :                 AlphaNum = 7;
    4403            0 :                 NumNum = 12;
    4404            0 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4405            0 :                     Secondary(SecondaryNum).SumUADistPiping = Numbers(NumNum);
    4406            0 :                     Secondary(SecondaryNum).DistPipeZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4407            0 :                     Secondary(SecondaryNum).DistPipeZoneNodeNum =
    4408            0 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).DistPipeZoneNum);
    4409              : 
    4410            0 :                     if (Secondary(SecondaryNum).DistPipeZoneNum == 0) {
    4411            0 :                         ShowSevereError(state,
    4412            0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4413              :                                                RoutineName,
    4414              :                                                CurrentModuleObject,
    4415            0 :                                                Secondary(SecondaryNum).Name,
    4416              :                                                cAlphaFieldNames(AlphaNum),
    4417              :                                                Alphas(AlphaNum)));
    4418            0 :                         ErrorsFound = true;
    4419              :                     } else {
    4420            0 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).DistPipeZoneNum) = true;
    4421              :                     }
    4422              : 
    4423            0 :                     if (Secondary(SecondaryNum).DistPipeZoneNodeNum == 0) {
    4424            0 :                         ShowSevereError(
    4425              :                             state,
    4426            0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Distribution "
    4427              :                                    "piping heat gain cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections "
    4428              :                                    "object.) is defined to determine the environmental temperature surrounding the piping.",
    4429              :                                    RoutineName,
    4430              :                                    CurrentModuleObject,
    4431            0 :                                    Secondary(SecondaryNum).Name,
    4432              :                                    cAlphaFieldNames(AlphaNum),
    4433              :                                    Alphas(AlphaNum),
    4434              :                                    cNumericFieldNames(NumNum)));
    4435            0 :                         ErrorsFound = true;
    4436              :                     }
    4437            0 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    4438            0 :                     ShowWarningError(
    4439              :                         state,
    4440            0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Distribution piping heat gain will not be "
    4441              :                                "calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    4442              :                                RoutineName,
    4443              :                                CurrentModuleObject,
    4444            0 :                                Secondary(SecondaryNum).Name,
    4445              :                                cAlphaFieldNames(AlphaNum),
    4446              :                                cNumericFieldNames(NumNum)));
    4447            0 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4448            0 :                     ShowWarningError(
    4449              :                         state,
    4450            0 :                         format("{}{}=\"{}\", {} will not be used and distribution piping heat gain will not be calculated because {} was blank.",
    4451              :                                RoutineName,
    4452              :                                CurrentModuleObject,
    4453            0 :                                Secondary(SecondaryNum).Name,
    4454              :                                cAlphaFieldNames(AlphaNum),
    4455              :                                cNumericFieldNames(NumNum)));
    4456              :                 } // distribution piping
    4457              : 
    4458              :                 // Separator/receiver heat gain - optional
    4459              :                 //  Input UA and Zone containing the Separator/receiver
    4460              :                 //  This Zone ID will be used to determine the temperature used for Separator/receiver heat gain.
    4461              :                 //  Zone Id is only required if Sum UA Separator/receiver >0.0
    4462              :                 //  Get the Zone node number from the zone name entered by the user
    4463            0 :                 Secondary(SecondaryNum).SumUAReceiver = 0.0;
    4464            0 :                 AlphaNum = 8;
    4465            0 :                 NumNum = 13;
    4466            0 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4467            0 :                     Secondary(SecondaryNum).SumUAReceiver = Numbers(NumNum);
    4468            0 :                     Secondary(SecondaryNum).ReceiverZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4469            0 :                     Secondary(SecondaryNum).ReceiverZoneNodeNum =
    4470            0 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).ReceiverZoneNum);
    4471              : 
    4472            0 :                     if (Secondary(SecondaryNum).ReceiverZoneNum == 0) {
    4473            0 :                         ShowSevereError(state,
    4474            0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4475              :                                                RoutineName,
    4476              :                                                CurrentModuleObject,
    4477            0 :                                                Secondary(SecondaryNum).Name,
    4478              :                                                cAlphaFieldNames(AlphaNum),
    4479              :                                                Alphas(AlphaNum)));
    4480            0 :                         ErrorsFound = true;
    4481              :                     } else {
    4482            0 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).ReceiverZoneNum) = true;
    4483              :                     }
    4484            0 :                     if (Secondary(SecondaryNum).ReceiverZoneNodeNum == 0) {
    4485            0 :                         ShowSevereError(
    4486              :                             state,
    4487            0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Receiver heat gain "
    4488              :                                    "cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.) is defined "
    4489              :                                    "to determine the environmental temperature surrounding the Receiver.",
    4490              :                                    RoutineName,
    4491              :                                    CurrentModuleObject,
    4492            0 :                                    Secondary(SecondaryNum).Name,
    4493              :                                    cAlphaFieldNames(AlphaNum),
    4494              :                                    Alphas(AlphaNum),
    4495              :                                    cNumericFieldNames(NumNum)));
    4496            0 :                         ErrorsFound = true;
    4497              :                     }
    4498            0 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    4499            0 :                     ShowWarningError(
    4500              :                         state,
    4501            0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Receiver heat gain will not be calculated unless "
    4502              :                                "a Zone is defined to determine the environmental temperature surrounding the Receiver.",
    4503              :                                RoutineName,
    4504              :                                CurrentModuleObject,
    4505            0 :                                Secondary(SecondaryNum).Name,
    4506              :                                cAlphaFieldNames(AlphaNum),
    4507              :                                cNumericFieldNames(NumNum)));
    4508            0 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4509            0 :                     ShowWarningError(state,
    4510            0 :                                      format("{}{}=\"{}\", {} will not be used and Receiver heat gain will not be calculated because {} was blank.",
    4511              :                                             RoutineName,
    4512              :                                             CurrentModuleObject,
    4513            0 :                                             Secondary(SecondaryNum).Name,
    4514              :                                             cAlphaFieldNames(AlphaNum),
    4515              :                                             cNumericFieldNames(NumNum)));
    4516              :                 } // Receiver
    4517              : 
    4518            0 :                 NumNum = 14;
    4519            0 :                 Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    4520            0 :                 if (!lNumericBlanks(NumNum)) Secondary(SecondaryNum).ChillerRefInventory = Numbers(NumNum);
    4521            0 :                 if (Secondary(SecondaryNum).ChillerRefInventory < 0.0) {
    4522            0 :                     Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    4523            0 :                     ShowWarningError(state,
    4524            0 :                                      format("{}{}=\"{}\", The value specified for {} is less than zero. The default value of zero will be used.",
    4525              :                                             RoutineName,
    4526              :                                             CurrentModuleObject,
    4527            0 :                                             Secondary(SecondaryNum).Name,
    4528              :                                             cNumericFieldNames(NumNum)));
    4529              :                 }
    4530              : 
    4531            0 :                 AlphaNum = 9;
    4532            0 :                 if (!lAlphaBlanks(AlphaNum)) Secondary(SecondaryNum).EndUseSubcategory = Alphas(AlphaNum);
    4533              : 
    4534              :                 // Error checks on secondary loop:
    4535              :                 // Note, rated capacities can be far off from operating capacities, but rough checks here
    4536              :                 //       (don't include dist piping or receiver heat gains).
    4537              :                 // Load limit logic here (maxvolflow and maxload used in calcs later)
    4538            0 :                 Secondary(SecondaryNum).MaxVolFlow = min(SecondaryFlowVolRated, PumpTotRatedFlowVol);
    4539            0 :                 Real64 NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4540              : 
    4541            0 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4542            0 :                     if (TBrineOutRated > (Secondary(SecondaryNum).TMinNeeded + 0.5)) {
    4543            0 :                         ShowWarningError(state,
    4544            0 :                                          format("{}=\"{} The design brine temperature to the refrigeration loads: {:.1R} ;",
    4545              :                                                 CurrentModuleObject,
    4546            0 :                                                 Secondary(SecondaryNum).Name,
    4547              :                                                 TBrineOutRated));
    4548            0 :                         ShowContinueError(state,
    4549            0 :                                           format(" is greater than the design inlet temperature for at least one of the cases or walkins: {:.1R}",
    4550            0 :                                                  Secondary(SecondaryNum).TMinNeeded));
    4551            0 :                         ShowContinueError(
    4552              :                             state, " Compare your Approach and Evaporating Temperature to the design inlet temperatures needed for the loads.");
    4553              :                         // ErrorsFound = .TRUE.
    4554              :                     } // Tbrine out warning
    4555            0 :                     Real64 CapacityAtMaxVolFlow = Secondary(SecondaryNum).MaxVolFlow * Secondary(SecondaryNum).HeatExchangeEta *
    4556            0 :                                                   (CpBrineRated * DensityBrineRated) * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign);
    4557            0 :                     Secondary(SecondaryNum).MaxLoad = min(Secondary(SecondaryNum).CoolingLoadRated, CapacityAtMaxVolFlow);
    4558              :                     Real64 DeltaCap1 =
    4559            0 :                         std::abs((Secondary(SecondaryNum).CoolingLoadRated - CapacityAtMaxVolFlow) / Secondary(SecondaryNum).CoolingLoadRated);
    4560            0 :                     if (DeltaCap1 > (0.3)) { // diff between chiller rating and capacity at max flow > 30%
    4561            0 :                         ShowWarningError(state,
    4562            0 :                                          format("{}=\"{}\" You may wish to check the system sizing.  The nominal secondary loop heat exchanger "
    4563              :                                                 "capacity is {:.0R} But the capacity based upon the maximum flow rate is {:.0R}",
    4564              :                                                 CurrentModuleObject,
    4565            0 :                                                 Secondary(SecondaryNum).Name,
    4566            0 :                                                 Secondary(SecondaryNum).CoolingLoadRated,
    4567              :                                                 CapacityAtMaxVolFlow));
    4568              :                     }                            // DeltaCap1 > .3
    4569              :                 } else {                         // Fluid type phase change                !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4570            0 :                     if (lNumericBlanks(1)) {     // Chiller/evaporator capacity was not specified
    4571            0 :                         if (lNumericBlanks(7)) { // Pump power was not input, calc based on flow and head
    4572              :                             // need to refine because capacity calculated, but needs to include pump power (which was prev
    4573              :                             //   estimated based upon capacity which had been estimated as sum of case and walk-in capacities)
    4574            0 :                             PumpTotRatedFlowVol =
    4575            0 :                                 NominalSecondaryRefLoad * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4576            0 :                             Secondary(SecondaryNum).PumpTotRatedPower =
    4577            0 :                                 PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4578              :                             // need to recalc nominal load with new pump power value
    4579            0 :                             NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4580            0 :                             if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4581              :                                 // Set incremental flow and power amounts for pump dispatch
    4582            0 :                                 Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4583            0 :                                 Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4584              :                             } // constant speed pump
    4585              :                         }     // Pump power was not specified
    4586            0 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalSecondaryRefLoad;
    4587              :                     } // Chiller/evap capacity was not specified
    4588            0 :                     Secondary(SecondaryNum).MaxLoad = Secondary(SecondaryNum).CoolingLoadRated;
    4589              :                 } // SecFluidType
    4590              : 
    4591              :                 Real64 DeltaCap2 =
    4592            0 :                     std::abs((Secondary(SecondaryNum).CoolingLoadRated - NominalSecondaryRefLoad) / Secondary(SecondaryNum).CoolingLoadRated);
    4593            0 :                 if (DeltaCap2 > (0.3)) { // diff between chiller rating and sum of nominal loads > 30%
    4594            0 :                     ShowWarningError(
    4595              :                         state,
    4596            0 :                         format("{}=\"{}\" You may wish to check the system sizing. Total nominal refrigerating load is {:.0R} (Including cases, "
    4597              :                                "walk-ins, and pump heat).  The nominal secondary loop heat exchanger capacity is {:.0R}",
    4598              :                                CurrentModuleObject,
    4599            0 :                                Secondary(SecondaryNum).Name,
    4600              :                                NominalSecondaryRefLoad,
    4601            0 :                                Secondary(SecondaryNum).CoolingLoadRated));
    4602              :                 }
    4603              :                 // compare rated xt xchanger brine flow to the total rated pump flow
    4604            0 :                 if (SecondaryFlowVolRated > (1.1 * PumpTotRatedFlowVol)) {
    4605            0 :                     ShowWarningError(state,
    4606            0 :                                      format("{}=\"{}\" You may wish to check the pump sizing. Total nominal brine flow is {:.0R} m3/s, but the "
    4607              :                                             "total nominal pump flow rate is:  {:.0R} m3/s. ",
    4608              :                                             CurrentModuleObject,
    4609            0 :                                             Secondary(SecondaryNum).Name,
    4610              :                                             SecondaryFlowVolRated,
    4611              :                                             PumpTotRatedFlowVol));
    4612              :                 }
    4613              : 
    4614              :             } // Secondary Loops
    4615              :         }     //(  IF (NumSimulationSecondarySystems > 0)
    4616              : 
    4617              :         //************ END SECONDARY SYSTEM INPUT  **************
    4618              : 
    4619              :         //************ START Compressor INPUT  **************
    4620              : 
    4621            0 :         CurrentModuleObject = "Refrigeration:Compressor";
    4622            0 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    4623            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4624              :                                                                      CurrentModuleObject,
    4625              :                                                                      CompNum,
    4626              :                                                                      Alphas,
    4627              :                                                                      NumAlphas,
    4628              :                                                                      Numbers,
    4629              :                                                                      NumNumbers,
    4630              :                                                                      IOStatus,
    4631              :                                                                      lNumericBlanks,
    4632              :                                                                      lAlphaBlanks,
    4633              :                                                                      cAlphaFieldNames,
    4634              :                                                                      cNumericFieldNames);
    4635            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4636              : 
    4637            0 :             Compressor(CompNum).Name = Alphas(1);
    4638              : 
    4639            0 :             Compressor(CompNum).ElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    4640            0 :             if ((!lAlphaBlanks(2)) && Compressor(CompNum).ElecPowerCurvePtr == 0) {
    4641            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    4642            0 :                 ErrorsFound = true;
    4643              :             }
    4644              : 
    4645            0 :             Compressor(CompNum).CapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    4646            0 :             if ((!lAlphaBlanks(3)) && Compressor(CompNum).CapacityCurvePtr == 0) {
    4647            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), Alphas(3));
    4648            0 :                 ErrorsFound = true;
    4649              :             }
    4650              : 
    4651              :             // Get superheat rating type (Either N1 or N2 Must be input)
    4652            0 :             if (((!lNumericBlanks(1)) && (!lNumericBlanks(2))) || (lNumericBlanks(1) && lNumericBlanks(2))) {
    4653            0 :                 ShowSevereError(state,
    4654            0 :                                 format("{}{}=\"{}\"One, and Only One of {} or {}",
    4655              :                                        RoutineName,
    4656              :                                        CurrentModuleObject,
    4657            0 :                                        Compressor(CompNum).Name,
    4658              :                                        cNumericFieldNames(1),
    4659              :                                        cNumericFieldNames(2)));
    4660            0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    4661            0 :                 ErrorsFound = true;
    4662            0 :             } else if (!lNumericBlanks(1)) {
    4663            0 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::Superheat;
    4664            0 :                 Compressor(CompNum).RatedSuperheat = Numbers(1);
    4665            0 :             } else if (!lNumericBlanks(2)) {
    4666            0 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::ReturnGasTemperature;
    4667            0 :                 Compressor(CompNum).RatedSuperheat = Numbers(2);
    4668              :             } // Set SuperheatRatingType
    4669              : 
    4670              :             // Get subcool rating type (Either N3 or N4 Must be input)
    4671            0 :             if (((!lNumericBlanks(3)) && (!lNumericBlanks(4))) || (lNumericBlanks(3) && lNumericBlanks(4))) {
    4672            0 :                 ShowSevereError(state,
    4673            0 :                                 format("{}{}=\"{}\" One, and Only One of {} or {}",
    4674              :                                        RoutineName,
    4675              :                                        CurrentModuleObject,
    4676            0 :                                        Compressor(CompNum).Name,
    4677              :                                        cNumericFieldNames(3),
    4678              :                                        cNumericFieldNames(4)));
    4679            0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    4680            0 :                 ErrorsFound = true;
    4681            0 :             } else if (!lNumericBlanks(3)) {
    4682            0 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::LiquidTemperature;
    4683            0 :                 Compressor(CompNum).RatedSubcool = Numbers(3);
    4684            0 :             } else if (!lNumericBlanks(4)) {
    4685            0 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::Subcooling;
    4686            0 :                 Compressor(CompNum).RatedSubcool = Numbers(4);
    4687              :             } // Set SubcoolRatingType
    4688              : 
    4689            0 :             Compressor(CompNum).EndUseSubcategory = "General";
    4690            0 :             if (!lAlphaBlanks(4)) Compressor(CompNum).EndUseSubcategory = Alphas(4);
    4691              : 
    4692              :             //  If the compressor is a transcritical CO compressor, get transcritical power and capacity curves
    4693            0 :             if (lAlphaBlanks(5)) {
    4694            0 :                 Compressor(CompNum).TransFlag = false;
    4695              :                 // For some reason, Alkphas(5) is not uppercased?
    4696            0 :             } else if (CriticalType crit = static_cast<CriticalType>(getEnumValue(criticalTypeNamesUC, Util::makeUPPER(Alphas(5))));
    4697              :                        crit != CriticalType::Invalid) {
    4698            0 :                 Compressor(CompNum).TransFlag = static_cast<bool>(crit);
    4699              :             } else {
    4700            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    4701            0 :                 ErrorsFound = true;
    4702              :             }
    4703              : 
    4704            0 :             if (Compressor(CompNum).TransFlag) {
    4705            0 :                 if (lAlphaBlanks(6)) {
    4706            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(6));
    4707            0 :                     ErrorsFound = true;
    4708            0 :                 } else if ((Compressor(CompNum).TransElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(6))) == 0) {
    4709            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), Alphas(6));
    4710            0 :                     ErrorsFound = true;
    4711              :                 }
    4712              : 
    4713            0 :                 if (lAlphaBlanks(7)) {
    4714            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(7));
    4715            0 :                     ErrorsFound = true;
    4716            0 :                 } else if ((Compressor(CompNum).TransCapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(7))) == 0) {
    4717            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(7), Alphas(7));
    4718            0 :                     ErrorsFound = true;
    4719              :                 }
    4720              :             } else {
    4721            0 :                 if (!lAlphaBlanks(6)) ShowWarningNonEmptyField(state, eoh, cAlphaFieldNames(6), cAlphaFieldNames(5), Alphas(5));
    4722            0 :                 if (!lAlphaBlanks(7)) ShowWarningNonEmptyField(state, eoh, cAlphaFieldNames(7), cAlphaFieldNames(5), Alphas(5));
    4723              :             }
    4724              : 
    4725              :         } // RefrigCompressor
    4726              : 
    4727              :         //************ END Compressor INPUT         **************
    4728              : 
    4729              :         //************ START Subcooler INPUT        **************
    4730            0 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    4731            0 :             CurrentModuleObject = "Refrigeration:Subcooler";
    4732            0 :             state.dataRefrigCase->NumSimulationMechSubcoolers = 0;
    4733            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    4734            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4735              :                                                                          CurrentModuleObject,
    4736              :                                                                          SubcoolerNum,
    4737              :                                                                          Alphas,
    4738              :                                                                          NumAlphas,
    4739              :                                                                          Numbers,
    4740              :                                                                          NumNumbers,
    4741              :                                                                          IOStatus,
    4742              :                                                                          lNumericBlanks,
    4743              :                                                                          lAlphaBlanks,
    4744              :                                                                          cAlphaFieldNames,
    4745              :                                                                          cNumericFieldNames);
    4746            0 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4747            0 :                 Subcooler(SubcoolerNum).Name = Alphas(1);
    4748              : 
    4749              :                 // Get subcooler type
    4750            0 :                 if ((Subcooler(SubcoolerNum).subcoolerType = static_cast<SubcoolerType>(getEnumValue(subcoolerTypeNamesUC, Alphas(2)))) ==
    4751              :                     SubcoolerType::Invalid) {
    4752            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    4753            0 :                     ErrorsFound = true;
    4754            0 :                 } else if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::Mechanical) {
    4755            0 :                     ++state.dataRefrigCase->NumSimulationMechSubcoolers;
    4756              :                 }
    4757              : 
    4758            0 :                 switch (Subcooler(SubcoolerNum).subcoolerType) {
    4759            0 :                 case SubcoolerType::LiquidSuction: {
    4760            0 :                     Subcooler(SubcoolerNum).LiqSuctDesignDelT = 10.0; // default value
    4761            0 :                     if (!lNumericBlanks(1)) Subcooler(SubcoolerNum).LiqSuctDesignDelT = Numbers(1);
    4762            0 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignDelT < 0.0) {
    4763            0 :                         ShowSevereError(state,
    4764            0 :                                         format("{}{}=\"{}\" {} cannot be less than zero.",
    4765              :                                                RoutineName,
    4766              :                                                CurrentModuleObject,
    4767            0 :                                                Subcooler(SubcoolerNum).Name,
    4768              :                                                cNumericFieldNames(1)));
    4769            0 :                         ErrorsFound = true;
    4770              :                     }
    4771              : 
    4772            0 :                     if (!lNumericBlanks(2)) {
    4773            0 :                         Subcooler(SubcoolerNum).LiqSuctDesignTliqIn = Numbers(2);
    4774              :                     } else {
    4775            0 :                         ShowSevereError(state,
    4776            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    4777              :                                                RoutineName,
    4778              :                                                CurrentModuleObject,
    4779            0 :                                                Subcooler(SubcoolerNum).Name,
    4780              :                                                cNumericFieldNames(2)));
    4781            0 :                         ErrorsFound = true;
    4782              :                     }
    4783              : 
    4784            0 :                     if (!lNumericBlanks(3)) {
    4785            0 :                         Subcooler(SubcoolerNum).LiqSuctDesignTvapIn = Numbers(3);
    4786              :                     } else {
    4787            0 :                         ShowSevereError(state,
    4788            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    4789              :                                                RoutineName,
    4790              :                                                CurrentModuleObject,
    4791            0 :                                                Subcooler(SubcoolerNum).Name,
    4792              :                                                cNumericFieldNames(3)));
    4793            0 :                         ErrorsFound = true;
    4794              :                     }
    4795            0 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignTvapIn > Subcooler(SubcoolerNum).LiqSuctDesignTliqIn) {
    4796            0 :                         ShowSevereError(state,
    4797            0 :                                         format("{}{}=\"{}\" {} cannot be greater than {}.",
    4798              :                                                RoutineName,
    4799              :                                                CurrentModuleObject,
    4800            0 :                                                Subcooler(SubcoolerNum).Name,
    4801              :                                                cNumericFieldNames(3),
    4802              :                                                cNumericFieldNames(2)));
    4803            0 :                         ErrorsFound = true;
    4804              :                     } // error check
    4805            0 :                 } break;
    4806            0 :                 case SubcoolerType::Mechanical: {
    4807            0 :                     Subcooler(SubcoolerNum).MechSourceSys = Alphas(3);
    4808              :                     // Error check on system name comes later after systems have been read
    4809              : 
    4810            0 :                     if (!lNumericBlanks(4)) {
    4811            0 :                         Subcooler(SubcoolerNum).MechControlTliqOut = Numbers(4);
    4812              :                     } else {
    4813            0 :                         ShowSevereError(state,
    4814            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    4815              :                                                RoutineName,
    4816              :                                                CurrentModuleObject,
    4817            0 :                                                Subcooler(SubcoolerNum).Name,
    4818              :                                                cNumericFieldNames(4)));
    4819            0 :                         ErrorsFound = true;
    4820              :                     } // error check
    4821            0 :                 } break;
    4822            0 :                 default:
    4823            0 :                     break;
    4824              :                 }
    4825              :             } // Subcooler Input
    4826              :         }     // If there are subcoolers
    4827              : 
    4828              :         // ********END SUBCOOLER INPUTS ************
    4829              : 
    4830              :         //**** Read TransferLoad Lists **********************************************************
    4831            0 :         if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    4832            0 :             CurrentModuleObject = "Refrigeration:TransferLoadList";
    4833            0 :             for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationTransferLoadLists; ++ListNum) {
    4834            0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4835              :                                                                          CurrentModuleObject,
    4836              :                                                                          ListNum,
    4837              :                                                                          Alphas,
    4838              :                                                                          NumAlphas,
    4839              :                                                                          Numbers,
    4840              :                                                                          NumNumbers,
    4841              :                                                                          IOStatus,
    4842              :                                                                          lNumericBlanks,
    4843              :                                                                          lAlphaBlanks,
    4844              :                                                                          cAlphaFieldNames,
    4845              :                                                                          cNumericFieldNames);
    4846            0 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4847              : 
    4848            0 :                 TransferLoadList(ListNum).Name = Alphas(1);
    4849              : 
    4850              :                 // Transfer load list alphas include TransferLoadList name and one name for each Secondary or Cascade Condenser in list
    4851              :                 // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    4852            0 :                 int NumTotalLoadsOnList = NumAlphas - 1;
    4853            0 :                 if (!allocated(TransferLoadList(ListNum).CascadeLoadItemNum))
    4854            0 :                     TransferLoadList(ListNum).CascadeLoadItemNum.allocate(NumTotalLoadsOnList);
    4855            0 :                 if (!allocated(TransferLoadList(ListNum).SecondaryItemNum)) TransferLoadList(ListNum).SecondaryItemNum.allocate(NumTotalLoadsOnList);
    4856              : 
    4857            0 :                 int NumSecondarysOnList = 0;
    4858            0 :                 int NumCascadeLoadsOnList = 0;
    4859            0 :                 for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    4860            0 :                     int AlphaListNum = 1 + NumLoad;
    4861            0 :                     int LoadCascadeNum = 0;
    4862            0 :                     int LoadSecondaryNum = 0;
    4863            0 :                     if (state.dataRefrigCase->NumRefrigCondensers > 0) LoadCascadeNum = Util::FindItemInList(Alphas(AlphaListNum), Condenser);
    4864            0 :                     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0)
    4865            0 :                         LoadSecondaryNum = Util::FindItemInList(Alphas(AlphaListNum), Secondary);
    4866            0 :                     if ((LoadCascadeNum == 0) && (LoadSecondaryNum == 0)) {
    4867            0 :                         ShowSevereError(state,
    4868            0 :                                         format("{}{}=\"{}\" : has an invalid value of {}",
    4869              :                                                RoutineName,
    4870              :                                                CurrentModuleObject,
    4871              :                                                cAlphaFieldNames(AlphaListNum),
    4872              :                                                Alphas(AlphaListNum)));
    4873            0 :                         ErrorsFound = true;
    4874            0 :                     } else if ((LoadCascadeNum != 0) && (LoadSecondaryNum != 0)) {
    4875            0 :                         ShowSevereError(state,
    4876            0 :                                         format("{}{}=\"{}\" : has a non-unique name : {}",
    4877              :                                                RoutineName,
    4878              :                                                CurrentModuleObject,
    4879              :                                                cAlphaFieldNames(AlphaListNum),
    4880              :                                                Alphas(AlphaListNum)));
    4881            0 :                         ErrorsFound = true;
    4882            0 :                     } else if (LoadCascadeNum != 0) {
    4883            0 :                         if (Condenser(LoadCascadeNum).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    4884            0 :                             ShowSevereError(state,
    4885            0 :                                             format("{}{}=\"{}\" : has a condenser listed as a transfer load that is not a cascade condenser: {}",
    4886              :                                                    RoutineName,
    4887              :                                                    CurrentModuleObject,
    4888            0 :                                                    System(RefrigSysNum).Name,
    4889              :                                                    Alphas(AlphaListNum)));
    4890            0 :                             ErrorsFound = true;
    4891              :                         } else {
    4892            0 :                             ++NumCascadeLoadsOnList;
    4893            0 :                             TransferLoadList(ListNum).CascadeLoadItemNum(NumCascadeLoadsOnList) = LoadCascadeNum;
    4894              :                         } // /= condenser cascade type
    4895            0 :                     } else if (LoadSecondaryNum != 0) {
    4896            0 :                         ++NumSecondarysOnList;
    4897            0 :                         TransferLoadList(ListNum).SecondaryItemNum(NumSecondarysOnList) = LoadSecondaryNum;
    4898              :                     }
    4899            0 :                     TransferLoadList(ListNum).NumSecondarys = NumSecondarysOnList;
    4900            0 :                     TransferLoadList(ListNum).NumCascadeLoads = NumCascadeLoadsOnList;
    4901              :                 } // Num Total Loads on List
    4902              :             }     // ListNum=1,NumSimulationTransferLoadLists
    4903              :         }         //(NumSimulationTransferLoadLists > 0)
    4904              : 
    4905              :         //**** End read transfer load Lists **********************************************************
    4906              : 
    4907              :         //**** Read Compressor Lists **********************************************************
    4908            0 :         CurrentModuleObject = "Refrigeration:CompressorList";
    4909            0 :         for (int ListNum = 1; ListNum <= NumCompressorLists; ++ListNum) {
    4910            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4911              :                                                                      CurrentModuleObject,
    4912              :                                                                      ListNum,
    4913              :                                                                      Alphas,
    4914              :                                                                      NumAlphas,
    4915              :                                                                      Numbers,
    4916              :                                                                      NumNumbers,
    4917              :                                                                      IOStatus,
    4918              :                                                                      lNumericBlanks,
    4919              :                                                                      lAlphaBlanks,
    4920              :                                                                      cAlphaFieldNames,
    4921              :                                                                      cNumericFieldNames);
    4922            0 :             CompressorLists(ListNum).NumCompressors = NumAlphas - 1;
    4923            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4924              : 
    4925            0 :             CompressorLists(ListNum).Name = Alphas(1);
    4926            0 :             if (!allocated(CompressorLists(ListNum).CompItemNum))
    4927            0 :                 CompressorLists(ListNum).CompItemNum.allocate(CompressorLists(ListNum).NumCompressors);
    4928              : 
    4929            0 :             for (int CompIndex = 1; CompIndex <= CompressorLists(ListNum).NumCompressors; ++CompIndex) {
    4930            0 :                 int AlphaListNum = CompIndex + 1; // same as do loop from 2 to end of list
    4931            0 :                 if (!lAlphaBlanks(AlphaListNum)) {
    4932            0 :                     CompressorLists(ListNum).CompItemNum(CompIndex) = Util::FindItemInList(Alphas(AlphaListNum), Compressor);
    4933            0 :                     if (CompressorLists(ListNum).CompItemNum(CompIndex) == 0) {
    4934            0 :                         ShowSevereError(state,
    4935            0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    4936              :                                                RoutineName,
    4937              :                                                CurrentModuleObject,
    4938            0 :                                                CompressorLists(ListNum).Name,
    4939              :                                                cAlphaFieldNames(AlphaListNum),
    4940              :                                                Alphas(AlphaListNum)));
    4941            0 :                         ErrorsFound = true;
    4942              :                     }
    4943              :                 }
    4944              :             } // NumCompressors in CompressorList
    4945              : 
    4946              :         } // NumCompressorLists
    4947              : 
    4948              :         // ********READ REFRIGERATION SYSTEMS  ***********
    4949              : 
    4950            0 :         CurrentModuleObject = "Refrigeration:System";
    4951            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    4952              : 
    4953            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4954              :                                                                      CurrentModuleObject,
    4955              :                                                                      RefrigSysNum,
    4956              :                                                                      Alphas,
    4957              :                                                                      NumAlphas,
    4958              :                                                                      Numbers,
    4959              :                                                                      NumNumbers,
    4960              :                                                                      IOStatus,
    4961              :                                                                      lNumericBlanks,
    4962              :                                                                      lAlphaBlanks,
    4963              :                                                                      cAlphaFieldNames,
    4964              :                                                                      cNumericFieldNames);
    4965              : 
    4966            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4967            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4968              : 
    4969            0 :             System(RefrigSysNum).Name = Alphas(1);
    4970              : 
    4971              :             // Read all loads on this System: cases, walk-ins, cascade loads, and secondary loops
    4972            0 :             if (lAlphaBlanks(2) && lAlphaBlanks(3)) {
    4973              :                 // No cases, walkins, cascade loads, or secondary loops specified, ie, System has no load
    4974            0 :                 ShowSevereError(state,
    4975            0 :                                 format("{}{}=\"{}\", has no loads, must have at least one of: {} or {} objects attached.",
    4976              :                                        RoutineName,
    4977              :                                        CurrentModuleObject,
    4978            0 :                                        System(RefrigSysNum).Name,
    4979              :                                        cAlphaFieldNames(2),
    4980              :                                        cAlphaFieldNames(3)));
    4981            0 :                 ErrorsFound = true;
    4982              :             }
    4983            0 :             NumCases = 0;
    4984            0 :             System(RefrigSysNum).NumCases = 0;
    4985            0 :             int NumCoils = 0;
    4986            0 :             System(RefrigSysNum).NumCoils = 0;
    4987            0 :             NumWalkIns = 0;
    4988            0 :             System(RefrigSysNum).NumWalkIns = 0;
    4989            0 :             int NumSecondary = 0;
    4990            0 :             System(RefrigSysNum).NumSecondarys = 0;
    4991            0 :             System(RefrigSysNum).NumCascadeLoads = 0;
    4992            0 :             System(RefrigSysNum).NumNonCascadeLoads = 0;
    4993            0 :             Real64 NominalTotalCaseCap = 0.0;
    4994            0 :             Real64 NominalTotalCoilCap = 0.0;
    4995            0 :             Real64 NominalTotalWalkInCap = 0.0;
    4996            0 :             Real64 NominalTotalSecondaryCap = 0.0;
    4997              :             Real64 NominalTotalCoolingCap;
    4998            0 :             Real64 NominalTotalCascadeLoad = 0.0;
    4999            0 :             System(RefrigSysNum).RefInventory = 0.0;
    5000              : 
    5001              :             //   Check for case or walkin or CaseAndWalkInList names
    5002            0 :             AlphaNum = 2;
    5003            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5004              : 
    5005              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    5006            0 :                 int CaseAndWalkInListNum = 0;
    5007            0 :                 int CaseNum = 0;
    5008            0 :                 int WalkInNum = 0;
    5009            0 :                 int CoilNum = 0;
    5010            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    5011            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    5012            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    5013            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    5014            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    5015            0 :                 int NumNameMatches = 0;
    5016            0 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    5017            0 :                 if (CaseNum != 0) ++NumNameMatches;
    5018            0 :                 if (WalkInNum != 0) ++NumNameMatches;
    5019            0 :                 if (CoilNum != 0) ++NumNameMatches;
    5020              : 
    5021            0 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    5022            0 :                     ErrorsFound = true;
    5023            0 :                     if (NumNameMatches == 0) {
    5024            0 :                         ShowSevereError(state,
    5025            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5026              :                                                RoutineName,
    5027              :                                                CurrentModuleObject,
    5028            0 :                                                System(RefrigSysNum).Name,
    5029              :                                                cAlphaFieldNames(AlphaNum),
    5030              :                                                Alphas(AlphaNum)));
    5031            0 :                     } else if (NumNameMatches > 1) {
    5032            0 :                         ShowSevereError(state,
    5033            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    5034              :                                                RoutineName,
    5035              :                                                CurrentModuleObject,
    5036            0 :                                                System(RefrigSysNum).Name,
    5037              :                                                cAlphaFieldNames(AlphaNum),
    5038              :                                                Alphas(AlphaNum)));
    5039              :                     }                                   // num matches = 0 or > 1
    5040            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    5041            0 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    5042            0 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    5043            0 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    5044            0 :                     System(RefrigSysNum).NumCases = NumCases;
    5045            0 :                     System(RefrigSysNum).NumWalkIns = NumWalkIns;
    5046            0 :                     System(RefrigSysNum).NumCoils = NumCoils;
    5047            0 :                     if (NumCases > 0) {
    5048            0 :                         if (!allocated(System(RefrigSysNum).CaseNum)) System(RefrigSysNum).CaseNum.allocate(NumCases);
    5049            0 :                         System(RefrigSysNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    5050              :                     }
    5051            0 :                     if (NumCoils > 0) {
    5052            0 :                         if (!allocated(System(RefrigSysNum).CoilNum)) System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5053            0 :                         System(RefrigSysNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    5054              :                     }
    5055            0 :                     if (NumWalkIns > 0) {
    5056            0 :                         if (!allocated(System(RefrigSysNum).WalkInNum)) System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5057            0 :                         System(RefrigSysNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    5058              :                     }
    5059            0 :                 } else if (CaseNum != 0) { // Name points to a case
    5060            0 :                     NumCases = 1;
    5061            0 :                     System(RefrigSysNum).NumCases = 1;
    5062            0 :                     if (!allocated(System(RefrigSysNum).CaseNum)) System(RefrigSysNum).CaseNum.allocate(NumCases);
    5063            0 :                     System(RefrigSysNum).CaseNum(NumCases) = CaseNum;
    5064            0 :                 } else if (CoilNum != 0) { // Name points to a coil
    5065            0 :                     NumCoils = 1;
    5066            0 :                     System(RefrigSysNum).NumCoils = 1;
    5067            0 :                     if (!allocated(System(RefrigSysNum).CoilNum)) System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5068            0 :                     System(RefrigSysNum).CoilNum(NumCoils) = CoilNum;
    5069            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    5070            0 :                     NumWalkIns = 1;
    5071            0 :                     System(RefrigSysNum).NumWalkIns = 1;
    5072            0 :                     if (!allocated(System(RefrigSysNum).WalkInNum)) System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5073            0 :                     System(RefrigSysNum).WalkInNum(NumWalkIns) = WalkInNum;
    5074              :                 } // NumNameMatches /= 1
    5075              :             }     // blank input for cases, walkins, or caseandwalkinlist
    5076              : 
    5077            0 :             if (NumCases > 0) {
    5078              :                 // Find lowest design evap T
    5079              :                 // Sum rated capacity of all cases on system
    5080            0 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    5081              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    5082            0 :                     int CaseNum = System(RefrigSysNum).CaseNum(caseIndex);
    5083            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    5084            0 :                     NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap;
    5085            0 :                     System(RefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    5086            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    5087            0 :                         System(RefrigSysNum).TEvapDesign = RefrigCase(CaseNum).EvapTempDesign;
    5088              :                     } else {
    5089            0 :                         System(RefrigSysNum).TEvapDesign = min(RefrigCase(CaseNum).EvapTempDesign, System(RefrigSysNum).TEvapDesign);
    5090              :                     }
    5091              :                 } // CaseIndex=1,NumCases
    5092            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCases;
    5093              :             } // Numcases > 0
    5094              : 
    5095            0 :             if (NumCoils > 0) {
    5096              :                 // Find lowest design evap T
    5097              :                 // Sum rated capacity of all Coils on system
    5098            0 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    5099              :                     // mark all Coils on system as used by this system - checking for unused or non-unique Coils
    5100            0 :                     int CoilNum = System(RefrigSysNum).CoilNum(CoilIndex);
    5101            0 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    5102            0 :                     NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    5103            0 :                     System(RefrigSysNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    5104            0 :                     if ((CoilIndex == 1) && (System(RefrigSysNum).NumCases == 0)) { // look for lowest Coil design evap T for system
    5105            0 :                         System(RefrigSysNum).TEvapDesign = WarehouseCoil(CoilNum).TEvapDesign;
    5106              :                     } else {
    5107            0 :                         System(RefrigSysNum).TEvapDesign = min(WarehouseCoil(CoilNum).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5108              :                     }
    5109              :                 } // CoilIndex=1,NumCoils
    5110            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCoils;
    5111              :             } // NumCoils > 0
    5112              : 
    5113            0 :             if (NumWalkIns > 0) {
    5114            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    5115            0 :                     int WalkInID = System(RefrigSysNum).WalkInNum(WalkInIndex);
    5116              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    5117            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    5118            0 :                     NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    5119            0 :                     System(RefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    5120              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    5121              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    5122              :                     //  to either the rack or system.
    5123              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    5124            0 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    5125              :                         // - 99 used as a flag for blank input error message for detailed systems
    5126            0 :                         ShowSevereError(state,
    5127            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    5128              :                                                "electric and hotfluid defrost types",
    5129              :                                                RoutineName,
    5130            0 :                                                WalkIn(WalkInID).Name));
    5131            0 :                         ErrorsFound = true;
    5132              :                     }
    5133              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    5134            0 :                     if ((WalkInIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0)) {
    5135              :                         // note use walk in index, not walkinid here to get
    5136              :                         // first walkin on this suction group/system
    5137            0 :                         System(RefrigSysNum).TEvapDesign = WalkIn(WalkInID).TEvapDesign;
    5138              :                     } else {
    5139            0 :                         System(RefrigSysNum).TEvapDesign = min(WalkIn(WalkInID).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5140              :                     }
    5141              :                 } // WalkInIndex=1,NumWalkIns
    5142            0 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumWalkIns;
    5143              :             } // numwalkins > 0
    5144              : 
    5145            0 :             AlphaNum = 3;
    5146              :             // Read Transfer Loads (Secondary and Cascade) assignments for this System ,
    5147              :             //     already allow more than one mech subcooler to load onto a system so they don't need to go in list
    5148            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5149              : 
    5150              :                 // Entry for Alphas(AlphaNum) can be either a Secondary, CascadeLoad name or a TransferLoadList name
    5151            0 :                 int TransferLoadListNum = 0;
    5152            0 :                 int SecondaryNum = 0;
    5153            0 :                 int CascadeLoadNum = 0;
    5154            0 :                 if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0)
    5155            0 :                     TransferLoadListNum = Util::FindItemInList(Alphas(AlphaNum), TransferLoadList);
    5156            0 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) SecondaryNum = Util::FindItemInList(Alphas(AlphaNum), Secondary);
    5157            0 :                 if (state.dataRefrigCase->NumRefrigCondensers > 0) CascadeLoadNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5158            0 :                 int NumNameMatches = 0;
    5159            0 :                 if (TransferLoadListNum != 0) ++NumNameMatches;
    5160            0 :                 if (SecondaryNum != 0) ++NumNameMatches;
    5161            0 :                 if (CascadeLoadNum != 0) ++NumNameMatches;
    5162            0 :                 int NumCascadeLoad = 0;
    5163              : 
    5164            0 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single transfer load
    5165            0 :                     ErrorsFound = true;
    5166            0 :                     if (NumNameMatches == 0) {
    5167            0 :                         ShowSevereError(state,
    5168            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5169              :                                                RoutineName,
    5170              :                                                CurrentModuleObject,
    5171            0 :                                                System(RefrigSysNum).Name,
    5172              :                                                cAlphaFieldNames(AlphaNum),
    5173              :                                                Alphas(AlphaNum)));
    5174            0 :                     } else if (NumNameMatches > 1) {
    5175            0 :                         ShowSevereError(state,
    5176            0 :                                         format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    5177              :                                                RoutineName,
    5178              :                                                CurrentModuleObject,
    5179            0 :                                                System(RefrigSysNum).Name,
    5180              :                                                cAlphaFieldNames(AlphaNum),
    5181              :                                                Alphas(AlphaNum)));
    5182              :                     }                                  // num matches = 0 or > 1
    5183            0 :                 } else if (TransferLoadListNum != 0) { // Name points to a transferLoad list
    5184            0 :                     NumSecondary = TransferLoadList(TransferLoadListNum).NumSecondarys;
    5185            0 :                     NumCascadeLoad = TransferLoadList(TransferLoadListNum).NumCascadeLoads;
    5186            0 :                     System(RefrigSysNum).NumSecondarys = NumSecondary;
    5187            0 :                     System(RefrigSysNum).NumCascadeLoads = NumCascadeLoad;
    5188            0 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5189            0 :                     System(RefrigSysNum).SecondaryNum({1, NumSecondary}) = TransferLoadList(TransferLoadListNum).SecondaryItemNum({1, NumSecondary});
    5190            0 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5191            0 :                     System(RefrigSysNum).CascadeLoadNum({1, NumCascadeLoad}) =
    5192            0 :                         TransferLoadList(TransferLoadListNum).CascadeLoadItemNum({1, NumCascadeLoad});
    5193            0 :                 } else if (SecondaryNum != 0) { // Name points to a secondary loop load
    5194            0 :                     NumSecondary = 1;
    5195            0 :                     System(RefrigSysNum).NumSecondarys = 1;
    5196            0 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5197            0 :                     System(RefrigSysNum).SecondaryNum(NumSecondary) = SecondaryNum;
    5198            0 :                 } else if (CascadeLoadNum != 0) { // Name points to a cascade condenser load
    5199            0 :                     NumCascadeLoad = 1;
    5200            0 :                     System(RefrigSysNum).NumCascadeLoads = 1;
    5201            0 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5202            0 :                     System(RefrigSysNum).CascadeLoadNum(NumCascadeLoad) = CascadeLoadNum;
    5203              :                 } // NumNameMatches /= 1
    5204              : 
    5205            0 :                 System(RefrigSysNum).CoilFlag = false;
    5206              :                 // Now need to loop through all transfer loads to see if they change the minimum required system evaporating temperature
    5207            0 :                 if (NumSecondary > 0) {
    5208            0 :                     for (int SecondaryIndex = 1; SecondaryIndex <= NumSecondary; ++SecondaryIndex) {
    5209            0 :                         int SecondaryID = System(RefrigSysNum).SecondaryNum(SecondaryIndex);
    5210            0 :                         if (SecondaryIndex == 1) { // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5211            0 :                             if (Secondary(SecondaryID).CoilFlag) System(RefrigSysNum).CoilFlag = true;
    5212            0 :                         } else if (Secondary(SecondaryID).CoilFlag != System(RefrigSysNum).CoilFlag) {
    5213            0 :                             ShowSevereError(
    5214              :                                 state,
    5215            0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5216              :                                        "step than case or walkin loads. Compare loads on system served by secondary loop \"{}",
    5217              :                                        RoutineName,
    5218              :                                        CurrentModuleObject,
    5219            0 :                                        System(RefrigSysNum).Name,
    5220            0 :                                        Secondary(SecondaryID).Name));
    5221            0 :                             ErrorsFound = true;
    5222              :                         } // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5223              :                         // mark all Secondarys on system as used by this system (checking for unused or non-unique Secondarys)
    5224            0 :                         ++Secondary(SecondaryID).NumSysAttach;
    5225            0 :                         NominalTotalSecondaryCap += Secondary(SecondaryID).CoolingLoadRated;
    5226            0 :                         System(RefrigSysNum).RefInventory += Secondary(SecondaryID).ChillerRefInventory;
    5227              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5228            0 :                         if ((SecondaryIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0) &&
    5229            0 :                             (System(RefrigSysNum).NumWalkIns == 0)) {
    5230              :                             // note use secondary index above, not secondaryid here to get
    5231              :                             // first secondary on this suction group/system
    5232              :                             // note - TMinNeeded on secondary defined by cases and walkins served by secondary, not by
    5233              :                             //       the secondary's rated evaporating temperature (which is used to calc secondary heat
    5234              :                             //       exchanger effectiveness with other rated values)
    5235            0 :                             System(RefrigSysNum).TEvapDesign = Secondary(SecondaryID).TMinNeeded;
    5236              :                         } else {
    5237            0 :                             System(RefrigSysNum).TEvapDesign = min(Secondary(SecondaryID).TMinNeeded, System(RefrigSysNum).TEvapDesign);
    5238              :                         }
    5239              :                     } // SecondaryIndex=1,NumSecondary
    5240            0 :                     System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumSecondarys;
    5241              :                 } // numsecondary > 0
    5242              : 
    5243            0 :                 if (NumCascadeLoad > 0) {
    5244            0 :                     for (int cascadeLoadIndex = 1; cascadeLoadIndex <= NumCascadeLoad; ++cascadeLoadIndex) {
    5245            0 :                         int CondID = System(RefrigSysNum).CascadeLoadNum(cascadeLoadIndex);
    5246            0 :                         if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    5247            0 :                             ShowSevereError(state,
    5248            0 :                                             format("{}{}=\"{}\", has a  {}: {} cascade load that is not a cascade condenser.",
    5249              :                                                    RoutineName,
    5250              :                                                    CurrentModuleObject,
    5251            0 :                                                    System(RefrigSysNum).Name,
    5252              :                                                    cAlphaFieldNames(AlphaNum),
    5253              :                                                    Alphas(AlphaNum)));
    5254            0 :                             ErrorsFound = true;
    5255              :                         }
    5256              :                         // For a cascade condenser, need to identify the system absorbing the heat
    5257            0 :                         Condenser(CondID).CascadeSinkSystemID = RefrigSysNum;
    5258            0 :                         NominalTotalCascadeLoad += Condenser(CondID).RatedCapacity;
    5259              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5260            0 :                         if (System(RefrigSysNum).NumNonCascadeLoads == 0) {
    5261            0 :                             if (cascadeLoadIndex == 1) {
    5262              :                                 // note use cascadeload index above, not condid here to get
    5263              :                                 // first cascade condenser served by this suction group/system
    5264            0 :                                 System(RefrigSysNum).TEvapDesign = Condenser(CondID).CascadeRatedEvapTemp;
    5265              :                             } else {
    5266            0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp, System(RefrigSysNum).TEvapDesign);
    5267              :                             }    // CascadeLoadIndex == 1
    5268              :                         } else { // (NumNonCascadeLoads > 0 so initial TEvapDesign set above with those other loads)
    5269            0 :                             if (Condenser(CondID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet)
    5270            0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp,
    5271            0 :                                                                        System(RefrigSysNum).TEvapDesign); // other wise TEvapDesign set by other loads
    5272              :                         }
    5273              :                     } // CascadeLoadIndex=1,NumCascadeLoad
    5274              :                 }     // CascadeLoadNum > 0
    5275              :             }         // yes/no blank input for transfer loads
    5276              : 
    5277              :             // check for consistency of loads (coils calc on sys time step, all others on zone time step, so can't mix on one system)
    5278            0 :             if (System(RefrigSysNum).CoilFlag) { // could already be true if serving secondary that serves coils
    5279            0 :                 if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5280            0 :                     ShowSevereError(state,
    5281            0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5282              :                                            "step than case or walkin loads.",
    5283              :                                            RoutineName,
    5284              :                                            CurrentModuleObject,
    5285            0 :                                            System(RefrigSysNum).Name));
    5286            0 :                     ErrorsFound = true;
    5287              :                 }
    5288              :             } else {                                     // no coils on secondary or no secondary
    5289            0 :                 if (System(RefrigSysNum).NumCoils > 0) { //(note, coilflag set to .FALSE. for all systems as default above
    5290            0 :                     System(RefrigSysNum).CoilFlag = true;
    5291            0 :                     if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5292            0 :                         ShowSevereError(state,
    5293            0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    5294              :                                                "time step than case or walkin loads.",
    5295              :                                                RoutineName,
    5296              :                                                CurrentModuleObject,
    5297            0 :                                                System(RefrigSysNum).Name));
    5298            0 :                         ErrorsFound = true;
    5299              :                     }
    5300              :                 } // NumCoils > 0
    5301              :             }     // Coil flag already true due to secondary coil loads
    5302              : 
    5303            0 :             NominalTotalCoolingCap = NominalTotalCaseCap + NominalTotalWalkInCap + NominalTotalSecondaryCap + NominalTotalCascadeLoad;
    5304              : 
    5305              :             // read condenser
    5306              :             // currently assumes one condenser per refrigeration system and but multiple systems allowed per condenser
    5307            0 :             AlphaNum = 4;
    5308            0 :             int NumCondensers = 1;
    5309            0 :             if (!allocated(System(RefrigSysNum).CondenserNum)) System(RefrigSysNum).CondenserNum.allocate(NumCondensers);
    5310            0 :             System(RefrigSysNum).NumCondensers = 1;
    5311              :             // Find condenser number, note condensers were read in one of four objects, but all read into same list
    5312            0 :             int CondNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5313            0 :             if (CondNum == 0) {
    5314            0 :                 ShowSevereError(state,
    5315            0 :                                 format("{}{}=\"{}\", has an invalid {} defined as {}",
    5316              :                                        RoutineName,
    5317              :                                        CurrentModuleObject,
    5318            0 :                                        System(RefrigSysNum).Name,
    5319              :                                        cAlphaFieldNames(AlphaNum),
    5320              :                                        Alphas(AlphaNum)));
    5321            0 :                 ErrorsFound = true;
    5322              :             } else {
    5323            0 :                 System(RefrigSysNum).CondenserNum(NumCondensers) = CondNum;
    5324              :                 // Now take care of case where multiple systems share a condenser
    5325            0 :                 ++Condenser(CondNum).NumSysAttach;
    5326            0 :                 Condenser(CondNum).SysNum(Condenser(CondNum).NumSysAttach) = RefrigSysNum;
    5327              :             }
    5328              : 
    5329            0 :             System(RefrigSysNum).RefInventory +=
    5330            0 :                 Condenser(CondNum).RefReceiverInventory + Condenser(CondNum).RefPipingInventory + Condenser(CondNum).RefOpCharge;
    5331            0 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) Condenser(CondNum).CascadeSysID = RefrigSysNum;
    5332            0 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) && (Condenser(CondNum).CondenserRejectHeatToZone))
    5333            0 :                 System(RefrigSysNum).SystemRejectHeatToZone = true;
    5334              : 
    5335              :             // Now do evaporative condenser auto-sizing because it is a function of the system's cooling load
    5336            0 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5337            0 :                 if (Condenser(CondNum).RatedAirFlowRate == Constant::AutoCalculate) {
    5338            0 :                     Condenser(CondNum).RatedAirFlowRate = AirVolRateEvapCond * Condenser(CondNum).RatedCapacity;
    5339              :                 }
    5340            0 :                 if (Condenser(CondNum).RatedAirFlowRate <= 0.0) {
    5341            0 :                     ShowSevereError(state,
    5342            0 :                                     format("{}{}=\"{}\", Evaporative Condenser Air Volume Flow Rate cannot be less than or equal to zero.",
    5343              :                                            RoutineName,
    5344              :                                            CurrentModuleObject,
    5345            0 :                                            Condenser(CondNum).Name));
    5346            0 :                     ErrorsFound = true;
    5347              :                 }
    5348            0 :                 if (Condenser(CondNum).EvapPumpPower == Constant::AutoCalculate) {
    5349            0 :                     Condenser(CondNum).EvapPumpPower = CondPumpRatePower * Condenser(CondNum).RatedCapacity;
    5350              :                 }
    5351            0 :                 if (Condenser(CondNum).EvapPumpPower < 0.0) {
    5352            0 :                     ShowSevereError(state,
    5353            0 :                                     format("{}{}=\"{}\", Design Evaporative Condenser Water Pump Power cannot be less than zero.",
    5354              :                                            RoutineName,
    5355              :                                            CurrentModuleObject,
    5356            0 :                                            Condenser(CondNum).Name));
    5357            0 :                     ErrorsFound = true;
    5358              :                 }
    5359              :             }
    5360              : 
    5361              :             // Read the compressor data.
    5362              :             // If the system consists of two stages of compression, these compressors will be the low-stage compressors.
    5363            0 :             AlphaNum = 5;
    5364            0 :             int NumCompressorsSys = 0;
    5365            0 :             if (lAlphaBlanks(AlphaNum)) {
    5366              :                 // blank input where must have compressor or compressor list input.
    5367            0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    5368            0 :                 ErrorsFound = true;
    5369              :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    5370              :                 int ListNum;
    5371            0 :                 if (NumCompressorLists > 0) {
    5372            0 :                     ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5373              :                 } else {
    5374            0 :                     ListNum = 0;
    5375              :                 }
    5376              :                 int CompNum;
    5377            0 :                 if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    5378            0 :                     CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5379              :                 } else {
    5380            0 :                     CompNum = 0;
    5381              :                 }
    5382            0 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    5383            0 :                     ShowSevereError(state,
    5384            0 :                                     format("{}{} {}, has an invalid or undefined value=\"{}\".",
    5385              :                                            RoutineName,
    5386              :                                            CurrentModuleObject,
    5387              :                                            cAlphaFieldNames(AlphaNum),
    5388              :                                            Alphas(AlphaNum)));
    5389            0 :                     ErrorsFound = true;
    5390            0 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    5391            0 :                     ShowSevereError(state,
    5392            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    5393              :                                            RoutineName,
    5394              :                                            CurrentModuleObject,
    5395              :                                            cAlphaFieldNames(AlphaNum),
    5396              :                                            Alphas(AlphaNum)));
    5397            0 :                     ErrorsFound = true;
    5398            0 :                 } else if (ListNum != 0) {
    5399            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    5400            0 :                     System(RefrigSysNum).NumCompressors = NumCompressorsSys;
    5401            0 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5402            0 :                     System(RefrigSysNum).CompressorNum({1, NumCompressorsSys}) = CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    5403            0 :                 } else if (CompNum != 0) {
    5404            0 :                     NumCompressorsSys = 1;
    5405            0 :                     System(RefrigSysNum).NumCompressors = 1;
    5406            0 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5407            0 :                     System(RefrigSysNum).CompressorNum(NumCompressorsSys) = CompNum;
    5408              :                 }
    5409              :             }
    5410              : 
    5411            0 :             if (!lNumericBlanks(1)) {
    5412            0 :                 System(RefrigSysNum).TCondenseMin = Numbers(1);
    5413            0 :                 System(RefrigSysNum).TCondenseMinInput = System(RefrigSysNum).TCondenseMin;
    5414            0 :                 if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5415            0 :                     SetupEMSActuator(state,
    5416              :                                      "Refrigeration:System",
    5417            0 :                                      System(RefrigSysNum).Name,
    5418              :                                      "Minimum Condensing Temperature",
    5419              :                                      "[C]",
    5420            0 :                                      System(RefrigSysNum).EMSOverrideOnTCondenseMin,
    5421            0 :                                      System(RefrigSysNum).EMSOverrideValueTCondenseMin);
    5422              :                 }
    5423              :             } else {
    5424            0 :                 ShowSevereError(
    5425              :                     state,
    5426            0 :                     format("{}{}=\"{}\", {} must be defined.", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name, cNumericFieldNames(1)));
    5427            0 :                 ErrorsFound = true;
    5428              :             }
    5429            0 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) &&
    5430            0 :                 (System(RefrigSysNum).TCondenseMin > Condenser(CondNum).RatedTCondense))
    5431            0 :                 ShowWarningError(state,
    5432            0 :                                  format("{}=\"{}\", The system specified minimum condensing temperature is greater than the rated condensing "
    5433              :                                         "temperature for the cascade condenser. ",
    5434              :                                         CurrentModuleObject,
    5435            0 :                                         System(RefrigSysNum).Name));
    5436              : 
    5437            0 :             AlphaNum = 6;
    5438            0 :             System(RefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    5439            0 :             if (System(RefrigSysNum).RefrigerantName.empty()) {
    5440            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    5441            0 :                 ErrorsFound = true;
    5442            0 :             } else if ((System(RefrigSysNum).refrig = Fluid::GetRefrig(state, System(RefrigSysNum).RefrigerantName)) == nullptr) {
    5443            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5444            0 :                 ErrorsFound = true;
    5445              :             }
    5446              :             // error messages for refrigerants already found in fluidproperties
    5447              : 
    5448            0 :             AlphaNum = 7;
    5449            0 :             if (lAlphaBlanks(AlphaNum)) {
    5450            0 :                 System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::ConstantSuctionTemperature; // Default for blank
    5451            0 :             } else if ((System(RefrigSysNum).CompSuctControl = static_cast<CompressorSuctionPressureCtrl>(
    5452            0 :                             getEnumValue(compressorSuctionPressureCtrlNamesUC, Alphas(AlphaNum)))) == CompressorSuctionPressureCtrl::Invalid) {
    5453            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5454            0 :                 ErrorsFound = true;
    5455            0 :             } else if (System(RefrigSysNum).CompSuctControl == CompressorSuctionPressureCtrl::FloatSuctionTemperature &&
    5456            0 :                        System(RefrigSysNum).CoilFlag) {
    5457            0 :                 ShowWarningError(state,
    5458            0 :                                  format("{}=\"{}\", The system specified a FloatSuctionTemperature, but that is not available with air "
    5459              :                                         "chiller loads so ConstantSuctionTemperature will be used. ",
    5460              :                                         CurrentModuleObject,
    5461            0 :                                         System(RefrigSysNum).Name));
    5462              :             }
    5463              : 
    5464              :             // Count subcoolers on system and allocate
    5465            0 :             AlphaNum = 8;
    5466            0 :             System(RefrigSysNum).NumSubcoolers = 0;
    5467            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5468            0 :                 ++System(RefrigSysNum).NumSubcoolers;
    5469              :             }
    5470            0 :             if (!lAlphaBlanks(AlphaNum + 1)) {
    5471            0 :                 ++System(RefrigSysNum).NumSubcoolers;
    5472              :             }
    5473              : 
    5474            0 :             if (System(RefrigSysNum).NumSubcoolers > 0) {
    5475            0 :                 if (!allocated(System(RefrigSysNum).SubcoolerNum)) System(RefrigSysNum).SubcoolerNum.allocate(System(RefrigSysNum).NumSubcoolers);
    5476            0 :                 int NumSubcooler = 1;
    5477            0 :                 if (!lAlphaBlanks(AlphaNum)) {
    5478            0 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5479            0 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum));
    5480            0 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    5481            0 :                         ShowSevereError(state,
    5482            0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    5483              :                                                RoutineName,
    5484              :                                                CurrentModuleObject,
    5485            0 :                                                System(RefrigSysNum).Name,
    5486              :                                                cAlphaFieldNames(AlphaNum),
    5487              :                                                Alphas(AlphaNum)));
    5488            0 :                         ErrorsFound = true;
    5489              :                     } else {
    5490            0 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    5491              :                     }
    5492            0 :                     ++NumSubcooler;
    5493              :                 }
    5494            0 :                 if (!lAlphaBlanks(AlphaNum + 1)) {
    5495            0 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5496            0 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum + 1));
    5497            0 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    5498            0 :                         ShowSevereError(state,
    5499            0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    5500              :                                                RoutineName,
    5501              :                                                CurrentModuleObject,
    5502            0 :                                                System(RefrigSysNum).Name,
    5503              :                                                cAlphaFieldNames(AlphaNum + 1),
    5504              :                                                Alphas(AlphaNum + 1)));
    5505            0 :                         ErrorsFound = true;
    5506              :                     } else {
    5507            0 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    5508              :                     }
    5509              :                 }
    5510              :             }
    5511              : 
    5512              :             // Suction piping heat gain - optional
    5513              :             //  Input UA and identify the Zone containing the bulk of the suction piping
    5514              :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    5515              :             //  The pipe heat gains are also counted as cooling credit for the zone.
    5516              :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    5517              :             //  Get the Zone and zone node numbers from the zone name entered by the user
    5518            0 :             AlphaNum = 10;
    5519            0 :             System(RefrigSysNum).SumUASuctionPiping = 0.0;
    5520            0 :             if (!lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    5521            0 :                 System(RefrigSysNum).SumUASuctionPiping = Numbers(2);
    5522            0 :                 System(RefrigSysNum).SuctionPipeActualZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    5523            0 :                 System(RefrigSysNum).SuctionPipeZoneNodeNum =
    5524            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, System(RefrigSysNum).SuctionPipeActualZoneNum);
    5525            0 :                 if (System(RefrigSysNum).SuctionPipeZoneNodeNum == 0) {
    5526            0 :                     ShowSevereError(
    5527              :                         state,
    5528            0 :                         format("{}{}=\"{}\", System Node Number not found for {} = {} even though {} is greater than zero. Suction piping heat gain "
    5529              :                                "cannot be calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    5530              :                                RoutineName,
    5531              :                                CurrentModuleObject,
    5532            0 :                                System(RefrigSysNum).Name,
    5533              :                                cAlphaFieldNames(AlphaNum),
    5534              :                                Alphas(AlphaNum),
    5535              :                                cNumericFieldNames(2)));
    5536            0 :                     ErrorsFound = true;
    5537              :                 } else {
    5538            0 :                     state.dataRefrigCase->RefrigPresentInZone(System(RefrigSysNum).SuctionPipeActualZoneNum) = true;
    5539              :                 }
    5540            0 :             } else if (!lNumericBlanks(2) && lAlphaBlanks(AlphaNum)) {
    5541            0 :                 ShowWarningError(state,
    5542            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero. Suction piping heat gain will not be "
    5543              :                                         "calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    5544              :                                         RoutineName,
    5545              :                                         CurrentModuleObject,
    5546            0 :                                         System(RefrigSysNum).Name,
    5547              :                                         cAlphaFieldNames(AlphaNum),
    5548              :                                         cNumericFieldNames(2)));
    5549            0 :             } else if (lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    5550            0 :                 ShowWarningError(state,
    5551            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    5552              :                                         RoutineName,
    5553              :                                         CurrentModuleObject,
    5554            0 :                                         System(RefrigSysNum).Name,
    5555              :                                         cAlphaFieldNames(AlphaNum),
    5556              :                                         cNumericFieldNames(2)));
    5557              :             } // suction piping heat gains
    5558              : 
    5559            0 :             AlphaNum = 11;
    5560            0 :             if (!lAlphaBlanks(AlphaNum)) System(RefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    5561              : 
    5562              :             // Single-stage or two-stage compression system
    5563            0 :             if (!lNumericBlanks(3)) {
    5564            0 :                 System(RefrigSysNum).NumStages = Numbers(3);
    5565            0 :                 if (System(RefrigSysNum).NumStages < 1 || System(RefrigSysNum).NumStages > 2) {
    5566            0 :                     ShowSevereError(state,
    5567            0 :                                     format("{}{}=\"{}\", {}{}",
    5568              :                                            RoutineName,
    5569              :                                            CurrentModuleObject,
    5570            0 :                                            System(RefrigSysNum).Name,
    5571              :                                            cNumericFieldNames(3),
    5572              :                                            R"( has an invalid value.  Only \"1\" or \"2\" compressor stages are allowed.)"));
    5573            0 :                     ErrorsFound = true;
    5574              :                 }
    5575              :             } else {
    5576            0 :                 System(RefrigSysNum).NumStages = 1; // Default for blank
    5577              :             }
    5578              : 
    5579              :             // Intercooler type
    5580              :             // None (0) for single-stage compression systems
    5581              :             // Flash intercooler (1) or coil-and-shell intercooler (2) for two-stage compression systems
    5582            0 :             AlphaNum = 12;
    5583            0 :             if (lAlphaBlanks(AlphaNum)) {
    5584            0 :                 System(RefrigSysNum).intercoolerType = IntercoolerType::None; // Default for blank
    5585            0 :             } else if ((System(RefrigSysNum).intercoolerType =
    5586            0 :                             static_cast<IntercoolerType>(getEnumValue(intercoolerTypeNamesUC, Alphas(AlphaNum)))) == IntercoolerType::Invalid) {
    5587            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5588            0 :                 ErrorsFound = true;
    5589              :             }
    5590              : 
    5591            0 :             if (System(RefrigSysNum).NumStages == 1 && (System(RefrigSysNum).intercoolerType == IntercoolerType::Flash ||
    5592            0 :                                                         System(RefrigSysNum).intercoolerType == IntercoolerType::ShellAndCoil)) {
    5593            0 :                 ShowSevereError(
    5594            0 :                     state, format("{}{}=\"{}\", A single-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5595            0 :                 ShowContinueError(state, "has been specified with an intercooler.  Verify that the number of compressor stages");
    5596            0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    5597            0 :                 ErrorsFound = true;
    5598            0 :             } else if (System(RefrigSysNum).NumStages == 2 && System(RefrigSysNum).intercoolerType == IntercoolerType::None) {
    5599            0 :                 ShowSevereError(state,
    5600            0 :                                 format("{}{}=\"{}\", A two-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5601            0 :                 ShowContinueError(state, "has been specified without an intercooler.  Verify that the number of compressor stages");
    5602            0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    5603            0 :                 ErrorsFound = true;
    5604              :             }
    5605              : 
    5606              :             // Shell-and-coil intercooler effectiveness
    5607            0 :             if (!lNumericBlanks(4)) {
    5608            0 :                 System(RefrigSysNum).IntercoolerEffectiveness = Numbers(4);
    5609            0 :                 if (System(RefrigSysNum).IntercoolerEffectiveness < 0.0 || System(RefrigSysNum).IntercoolerEffectiveness > 1.0) {
    5610            0 :                     ShowWarningError(state,
    5611            0 :                                      format("{}{}=\"{}\", The specified value for the", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5612            0 :                     ShowContinueError(
    5613              :                         state,
    5614            0 :                         format("{} = {:.2R} is invalid.  This value must be", cNumericFieldNames(4), System(RefrigSysNum).IntercoolerEffectiveness));
    5615            0 :                     ShowContinueError(state, "between 0.0 and 1.0.  The default value of 0.8 will be used.");
    5616            0 :                     System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    5617              :                 }
    5618              :             } else {
    5619            0 :                 System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    5620              :             }
    5621              : 
    5622              :             // Read the high-stage compressor info, if two-stage compression has been specified.
    5623            0 :             AlphaNum = 13;
    5624            0 :             int NumHiStageCompressorsSys = 0;
    5625            0 :             if (System(RefrigSysNum).NumStages == 2) {
    5626            0 :                 if (lAlphaBlanks(AlphaNum)) {
    5627              :                     // blank input where must have high-stage compressor or compressor list input.
    5628            0 :                     ShowSevereError(state,
    5629            0 :                                     format("{}{}=\"{}\", {} must be input for two-stage compression systems.",
    5630              :                                            RoutineName,
    5631              :                                            CurrentModuleObject,
    5632            0 :                                            System(RefrigSysNum).Name,
    5633              :                                            cAlphaFieldNames(AlphaNum)));
    5634            0 :                     ErrorsFound = true;
    5635              :                 } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    5636            0 :                     int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5637            0 :                     int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5638            0 :                     if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    5639            0 :                         ShowSevereError(state,
    5640            0 :                                         format(R"({}{}="{}", {} has an invalid or undefined value="{}".)",
    5641              :                                                RoutineName,
    5642              :                                                CurrentModuleObject,
    5643            0 :                                                System(RefrigSysNum).Name,
    5644              :                                                cAlphaFieldNames(AlphaNum),
    5645              :                                                Alphas(AlphaNum)));
    5646            0 :                         ErrorsFound = true;
    5647            0 :                     } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    5648            0 :                         ShowSevereError(state,
    5649            0 :                                         format(R"({}{}="{}", {} has a non-unique name used for both Compressor and CompressorList name: "{}".)",
    5650              :                                                RoutineName,
    5651              :                                                CurrentModuleObject,
    5652            0 :                                                System(RefrigSysNum).Name,
    5653              :                                                cAlphaFieldNames(AlphaNum),
    5654              :                                                Alphas(AlphaNum)));
    5655            0 :                         ErrorsFound = true;
    5656            0 :                     } else if (ListNum != 0) {
    5657            0 :                         NumHiStageCompressorsSys = CompressorLists(ListNum).NumCompressors;
    5658            0 :                         System(RefrigSysNum).NumHiStageCompressors = NumHiStageCompressorsSys;
    5659            0 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum))
    5660            0 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    5661            0 :                         System(RefrigSysNum).HiStageCompressorNum({1, NumHiStageCompressorsSys}) =
    5662            0 :                             CompressorLists(ListNum).CompItemNum({1, NumHiStageCompressorsSys});
    5663            0 :                     } else if (CompNum != 0) {
    5664            0 :                         NumHiStageCompressorsSys = 1;
    5665            0 :                         System(RefrigSysNum).NumHiStageCompressors = 1;
    5666            0 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum))
    5667            0 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    5668            0 :                         System(RefrigSysNum).HiStageCompressorNum(NumHiStageCompressorsSys) = CompNum;
    5669              :                     }
    5670              :                 }
    5671              :             }
    5672              : 
    5673              :             // Determine intercooler pressure and temperature at design conditions
    5674            0 :             if (System(RefrigSysNum).NumStages == 2) {
    5675              :                 Real64 PCond =
    5676            0 :                     System(RefrigSysNum).refrig->getSatPressure(state, Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense, RoutineName);
    5677            0 :                 Real64 PEvap = System(RefrigSysNum).refrig->getSatPressure(state, System(RefrigSysNum).TEvapDesign, RoutineName);
    5678            0 :                 System(RefrigSysNum).PIntercooler = std::sqrt(PCond * PEvap);
    5679            0 :                 System(RefrigSysNum).TIntercooler =
    5680            0 :                     System(RefrigSysNum).refrig->getSatTemperature(state, System(RefrigSysNum).PIntercooler, RoutineName);
    5681              :             } // NumStages
    5682              : 
    5683              :             // Sum capacity of single-stage compressors or low-stage compressors if two-stage system
    5684            0 :             Real64 NominalTotalCompCap = 0.0;
    5685            0 :             for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    5686            0 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    5687            0 :                 if (!Compressor(CompNum).TransFlag) {          //  Subcritical Compressor
    5688            0 :                     if (System(RefrigSysNum).NumStages == 1) { //  Single-stage compression
    5689            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    5690            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    5691            0 :                                                                        System(RefrigSysNum).TEvapDesign,
    5692            0 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    5693            0 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    5694            0 :                         ++Compressor(CompNum).NumSysAttach;
    5695              :                     } else { //  Two-stage compression, low-stage compressors
    5696            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    5697            0 :                             state, Compressor(CompNum).CapacityCurvePtr, System(RefrigSysNum).TEvapDesign, System(RefrigSysNum).TIntercooler);
    5698            0 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    5699            0 :                         ++Compressor(CompNum).NumSysAttach;
    5700              :                     }    // NumStages
    5701              :                 } else { //  Transcritical compressor attached to subcritical refrigeration cycle
    5702            0 :                     ShowSevereError(state,
    5703            0 :                                     format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    5704              :                                            RoutineName,
    5705              :                                            CurrentModuleObject));
    5706            0 :                     ShowContinueError(state,
    5707              :                                       "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    5708              :                                       "transcritical compressors are connected only to transcritical systems.");
    5709            0 :                     ErrorsFound = true;
    5710              :                 } // .NOT. Compressor(CompNum)%TransFlag
    5711              :             }
    5712              : 
    5713            0 :             Real64 NominalTotalHiStageCompCap(0.0); // Total of nominal high-stage compressor capacities, used for rough input check (W)
    5714              : 
    5715              :             // Sum capacity of high-stage compressors if two stage system
    5716            0 :             if (System(RefrigSysNum).NumStages == 2) {
    5717            0 :                 for (int CompIndex = 1; CompIndex <= NumHiStageCompressorsSys; ++CompIndex) {
    5718            0 :                     int CompNum = System(RefrigSysNum).HiStageCompressorNum(CompIndex);
    5719            0 :                     if (!Compressor(CompNum).TransFlag) { //  Subcritical Compressor
    5720            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    5721            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    5722            0 :                                                                        System(RefrigSysNum).TIntercooler,
    5723            0 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    5724            0 :                         NominalTotalHiStageCompCap += Compressor(CompNum).NomCap;
    5725            0 :                         ++Compressor(CompNum).NumSysAttach;
    5726              :                     } else { //  Transcritical compressor attached to subcritical refrigeration cycle
    5727            0 :                         ShowSevereError(state,
    5728            0 :                                         format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    5729              :                                                RoutineName,
    5730              :                                                CurrentModuleObject));
    5731            0 :                         ShowContinueError(state,
    5732              :                                           "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    5733              :                                           "transcritical compressors are connected only to transcritical systems.");
    5734            0 :                         ErrorsFound = true;
    5735              :                     }
    5736              :                 }
    5737              :             } // NumStages
    5738              : 
    5739              :             // Compare the rated capacity of compressor, condenser, and cases.
    5740              :             // Note, rated capacities can be far off from operating capacities, but rough check.
    5741            0 :             Real64 NominalCondCap = Condenser(System(RefrigSysNum).CondenserNum(1)).RatedCapacity;
    5742            0 :             if (System(RefrigSysNum).SystemRejectHeatToZone) NominalCondCap *= 2.0;
    5743            0 :             if (System(RefrigSysNum).NumStages == 1) { // Single-stage system
    5744            0 :                 if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    5745            0 :                     ShowWarningError(state,
    5746            0 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    5747              :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    5748              :                                             CurrentModuleObject,
    5749            0 :                                             System(RefrigSysNum).Name,
    5750              :                                             NominalTotalCoolingCap,
    5751              :                                             NominalCondCap,
    5752              :                                             NominalTotalCompCap));
    5753              :                 }
    5754            0 :             } else if (System(RefrigSysNum).NumStages == 2) { // Two-stage system
    5755            0 :                 if ((NominalTotalHiStageCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    5756            0 :                     ShowWarningError(state,
    5757            0 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    5758              :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    5759              :                                             CurrentModuleObject,
    5760            0 :                                             System(RefrigSysNum).Name,
    5761              :                                             NominalTotalCoolingCap,
    5762              :                                             NominalCondCap,
    5763              :                                             NominalTotalCompCap));
    5764              :                 }
    5765              :             } // NumStages
    5766              : 
    5767              :         } // Refrigeration systems
    5768              : 
    5769              :         // Assign coilflags to compressors, condensers, and subcoolers (coils calc on sys time step, all other refrig loads on zone time step, so
    5770              :         // can't mix on one system) need to do here once again after all cascade condensers and cascade sink systems have been identified
    5771            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    5772              :             // assign flags to all condensers to match system below condenser (system rejecting heat to cascade condenser)
    5773            0 :             int CondNum = System(RefrigSysNum).CondenserNum(1); // right now only have one condenser per system
    5774            0 :             Condenser(CondNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    5775            0 :             for (int CompIndex = 1; CompIndex <= System(RefrigSysNum).NumCompressors; ++CompIndex) {
    5776            0 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    5777            0 :                 Compressor(CompNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    5778              :             }
    5779              : 
    5780              :         } // assign coil flags to all condensers
    5781              : 
    5782              :         // Finished setting cascade condenser coilflags to match system rejecting heat to the cascade condenser
    5783              :         // Now have to see if there's a mismatch in the coilflag with the system absorbing heat from the cascade condenser
    5784              :         // 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
    5785              :         // 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)
    5786            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems;
    5787              :              ++RefrigSysNum) { // check flags for systems reflect all cascade loads
    5788            0 :             if (System(RefrigSysNum).NumCascadeLoads == 0) continue;
    5789            0 :             if (System(RefrigSysNum).CoilFlag) { // system already identified as serving coils
    5790            0 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
    5791            0 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) continue;
    5792            0 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) continue; // this condenser is not a cascade load on this system
    5793            0 :                     if (!Condenser(CondID).CoilFlag) {
    5794              :                         // would mean system already serving coil loads and this condenser cooling system with case-type loads
    5795            0 :                         ShowSevereError(state,
    5796            0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    5797              :                                                "time step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    5798              :                                                RoutineName,
    5799              :                                                CurrentModuleObject,
    5800            0 :                                                System(RefrigSysNum).Name,
    5801            0 :                                                Condenser(CondID).Name));
    5802            0 :                         ErrorsFound = true;
    5803              :                     }
    5804              :                 }    // CondID
    5805              :             } else { // %coilflag == false, so no coil loads prev identified directly or through secondary loop
    5806              :                 // Flag to help verify load type with loads served by systems cooled by cascade condensers
    5807            0 :                 bool CaseLoads = false;
    5808            0 :                 int NumCascadeLoadsChecked = 0;
    5809            0 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) { // look at All cascade condenser loads on system
    5810            0 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) continue;
    5811            0 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) continue; // this condenser is not a cascade load on this system
    5812            0 :                     ++NumCascadeLoadsChecked;
    5813            0 :                     if ((CaseLoads) && (!Condenser(CondID).CoilFlag) && (!System(RefrigSysNum).CoilFlag)) continue;
    5814              :                     // all loads to date are case-type and properly flagged with consistent coilflags
    5815              :                     //(note caseloads could be true if prev cascade load checked is serving a case-type system)
    5816            0 :                     if (NumCascadeLoadsChecked == 1) {
    5817            0 :                         if (Condenser(CondID).CoilFlag) {
    5818            0 :                             System(RefrigSysNum).CoilFlag = true;
    5819              :                             // setting system coilflag if 1st cascade condenser served has coils (system has no case-type loads up to this point)
    5820              :                         } else { // condenser is not serving coils, but case-type loads
    5821            0 :                             CaseLoads = true;
    5822              :                             // system coilflag already set to false
    5823              :                         }    // Condenser%CoilFlag
    5824              :                     } else { // numcascadeloadschecked > 1
    5825            0 :                         if (System(RefrigSysNum).CoilFlag != Condenser(CondID).CoilFlag) {
    5826            0 :                             ShowSevereError(
    5827              :                                 state,
    5828            0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5829              :                                        "step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    5830              :                                        RoutineName,
    5831              :                                        CurrentModuleObject,
    5832            0 :                                        System(RefrigSysNum).Name,
    5833            0 :                                        Condenser(CondID).Name));
    5834            0 :                             ErrorsFound = true;
    5835              :                         }
    5836              :                     } // numcascadeloadschecked > 1
    5837              :                 }     // CondID
    5838              :             }         //(System%coilflag)
    5839              :         }             // Refrigeration systems checking coilflag consistency with cascade condenser loads
    5840              : 
    5841              :     } //(NumRefrigSystems > 0)
    5842              : 
    5843              :     // after the systems have been read, can finish the mechanical subcooler/system interactions
    5844              :     // System%NumMechSCServed=0
    5845          150 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    5846            0 :         for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    5847            0 :             if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) continue;
    5848            0 :             Subcooler(SubcoolerNum).MechSourceSysID =
    5849            0 :                 state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:System", Subcooler(SubcoolerNum).MechSourceSys);
    5850            0 :             if (Subcooler(SubcoolerNum).MechSourceSysID == 0) {
    5851            0 :                 ShowSevereError(state,
    5852            0 :                                 format(R"({}{}="{}", Mechanical Subcooler has an invalid Source Refrigeration:System="{}".)",
    5853              :                                        RoutineName,
    5854              :                                        CurrentModuleObject,
    5855            0 :                                        Subcooler(SubcoolerNum).Name,
    5856            0 :                                        Subcooler(SubcoolerNum).MechSourceSys));
    5857            0 :                 ErrorsFound = true;
    5858              :             } else {
    5859            0 :                 if (System(Subcooler(SubcoolerNum).MechSourceSysID).CoilFlag != Subcooler(SubcoolerNum).CoilFlag) {
    5860            0 :                     ShowSevereError(state,
    5861            0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5862              :                                            "step than case or walkin loads. Compare loads on system served by mechanical subcooler \"{}",
    5863              :                                            RoutineName,
    5864              :                                            CurrentModuleObject,
    5865            0 :                                            System(RefrigSysNum).Name,
    5866            0 :                                            Subcooler(SubcoolerNum).Name));
    5867            0 :                     ErrorsFound = true;
    5868              :                 }
    5869              :             } // error check
    5870              :         }     // numsubcoolers
    5871              : 
    5872            0 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    5873            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    5874            0 :                 if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) continue;
    5875            0 :                 if (Subcooler(SubcoolerNum).MechSourceSysID == RefrigSysNum) {
    5876            0 :                     ++System(RefrigSysNum).NumMechSCServed;
    5877              :                 }
    5878              :             }
    5879            0 :             if (System(RefrigSysNum).NumMechSCServed > 0) {
    5880            0 :                 if (!allocated(System(RefrigSysNum).MechSCLoad))
    5881            0 :                     System(RefrigSysNum).MechSCLoad.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
    5882              :             }
    5883              :         }
    5884              :     } // NumSimulationSubcoolers > 0
    5885              : 
    5886              :     // **********  READ TRANSCRITICAL REFRIGERATION SYSTEMS  **********
    5887              : 
    5888          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    5889            0 :         CurrentModuleObject = "Refrigeration:TranscriticalSystem";
    5890            0 :         for (int TransRefrigSysNum = 1; TransRefrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransRefrigSysNum) {
    5891            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5892              :                                                                      CurrentModuleObject,
    5893              :                                                                      TransRefrigSysNum,
    5894              :                                                                      Alphas,
    5895              :                                                                      NumAlphas,
    5896              :                                                                      Numbers,
    5897              :                                                                      NumNumbers,
    5898              :                                                                      IOStatus,
    5899              :                                                                      lNumericBlanks,
    5900              :                                                                      lAlphaBlanks,
    5901              :                                                                      cAlphaFieldNames,
    5902              :                                                                      cNumericFieldNames);
    5903              : 
    5904            0 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    5905              : 
    5906            0 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5907              : 
    5908            0 :             TransSystem(TransRefrigSysNum).Name = Alphas(1);
    5909              : 
    5910              :             // Read refrigerant for this system
    5911            0 :             AlphaNum = 8;
    5912            0 :             TransSystem(TransRefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    5913            0 :             if (TransSystem(TransRefrigSysNum).RefrigerantName.empty()) {
    5914            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    5915            0 :                 ErrorsFound = true;
    5916            0 :             } else if ((TransSystem(TransRefrigSysNum).refrig = Fluid::GetRefrig(state, TransSystem(TransRefrigSysNum).RefrigerantName)) == nullptr) {
    5917            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5918            0 :                 ErrorsFound = true;
    5919              :             }
    5920              :             // error messages for refrigerants already found in fluidproperties
    5921              : 
    5922              :             // Read Transcritical System Type:  SingleStage or TwoStage
    5923            0 :             if (lAlphaBlanks(2)) {
    5924            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2));
    5925            0 :                 ErrorsFound = true;
    5926            0 :             } else if ((TransSystem(TransRefrigSysNum).transSysType = static_cast<TransSysType>(getEnumValue(transSysTypeNamesUC, Alphas(2)))) ==
    5927              :                        TransSysType::Invalid) {
    5928            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(1), Alphas(2));
    5929            0 :                 ErrorsFound = true;
    5930            0 :             } else if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::SingleStage && lAlphaBlanks(3)) {
    5931              :                 // No medium temperature loads specified for a SingleStage system - display error
    5932            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3), cAlphaFieldNames(2), Alphas(2));
    5933            0 :                 ErrorsFound = true;
    5934            0 :             } else if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage && lAlphaBlanks(4)) {
    5935            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3), cAlphaFieldNames(2), Alphas(2));
    5936            0 :                 ErrorsFound = true;
    5937              :             }
    5938              : 
    5939            0 :             int NumCasesMT = 0;
    5940            0 :             TransSystem(TransRefrigSysNum).NumCasesMT = 0;
    5941            0 :             int NumCasesLT = 0;
    5942            0 :             TransSystem(TransRefrigSysNum).NumCasesLT = 0;
    5943            0 :             int NumWalkInsMT = 0;
    5944            0 :             TransSystem(TransRefrigSysNum).NumWalkInsMT = 0;
    5945            0 :             int NumWalkInsLT = 0;
    5946            0 :             TransSystem(TransRefrigSysNum).NumWalkInsLT = 0;
    5947            0 :             Real64 NominalTotalCaseCapMT = 0.0;
    5948            0 :             Real64 NominalTotalCaseCapLT = 0.0;
    5949            0 :             Real64 NominalTotalWalkInCapMT = 0.0;
    5950            0 :             Real64 NominalTotalWalkInCapLT = 0.0;
    5951              :             Real64 NominalTotalCoolingCap;
    5952            0 :             TransSystem(TransRefrigSysNum).RefInventory = 0.0;
    5953              : 
    5954              :             //   Check for Medium Temperature Case or Walk-In or CaseAndWalkInList names
    5955            0 :             AlphaNum = 3;
    5956              : 
    5957            0 :             if (!lAlphaBlanks(AlphaNum)) {
    5958              : 
    5959              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    5960            0 :                 int CaseAndWalkInListNum = 0;
    5961            0 :                 int CaseNum = 0;
    5962            0 :                 int WalkInNum = 0;
    5963            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    5964            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    5965            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    5966            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    5967            0 :                 int NumNameMatches = 0;
    5968            0 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    5969            0 :                 if (CaseNum != 0) ++NumNameMatches;
    5970            0 :                 if (WalkInNum != 0) ++NumNameMatches;
    5971              : 
    5972            0 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    5973            0 :                     ErrorsFound = true;
    5974            0 :                     if (NumNameMatches == 0) {
    5975            0 :                         ShowSevereError(state,
    5976            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5977              :                                                RoutineName,
    5978              :                                                CurrentModuleObject,
    5979            0 :                                                TransSystem(TransRefrigSysNum).Name,
    5980              :                                                cAlphaFieldNames(AlphaNum),
    5981              :                                                Alphas(AlphaNum)));
    5982            0 :                     } else if (NumNameMatches > 1) {
    5983            0 :                         ShowSevereError(state,
    5984            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    5985              :                                                RoutineName,
    5986              :                                                CurrentModuleObject,
    5987            0 :                                                TransSystem(TransRefrigSysNum).Name,
    5988              :                                                cAlphaFieldNames(AlphaNum),
    5989              :                                                Alphas(AlphaNum)));
    5990              :                     }                                   // num matches = 0 or > 1
    5991            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    5992            0 :                     NumCasesMT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    5993            0 :                     NumWalkInsMT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    5994            0 :                     TransSystem(TransRefrigSysNum).NumCasesMT = NumCasesMT;
    5995            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = NumWalkInsMT;
    5996            0 :                     if (NumCasesMT > 0) {
    5997            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    5998            0 :                         TransSystem(TransRefrigSysNum).CaseNumMT({1, NumCasesMT}) =
    5999            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesMT});
    6000              :                     }
    6001            0 :                     if (NumWalkInsMT > 0) {
    6002            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6003            0 :                         TransSystem(TransRefrigSysNum).WalkInNumMT({1, NumWalkInsMT}) =
    6004            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsMT});
    6005              :                     }
    6006            0 :                 } else if (CaseNum != 0) { // Name points to a case
    6007            0 :                     NumCasesMT = 1;
    6008            0 :                     TransSystem(TransRefrigSysNum).NumCasesMT = 1;
    6009            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6010            0 :                     TransSystem(TransRefrigSysNum).CaseNumMT(NumCases) = CaseNum;
    6011            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6012            0 :                     NumWalkInsMT = 1;
    6013            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = 1;
    6014            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6015            0 :                     TransSystem(TransRefrigSysNum).WalkInNumMT(NumWalkIns) = WalkInNum;
    6016              :                 } // NumNameMatches /= 1
    6017              :             }     // blank input for cases, walkins, or caseandwalkinlist
    6018              : 
    6019            0 :             if (NumCasesMT > 0) {
    6020              :                 // Find lowest design evap T
    6021              :                 // Sum rated capacity of all MT cases on system
    6022            0 :                 for (int caseIndex = 1; caseIndex <= NumCasesMT; ++caseIndex) {
    6023              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6024            0 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumMT(caseIndex);
    6025            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6026            0 :                     NominalTotalCaseCapMT += RefrigCase(CaseNum).DesignRatedCap;
    6027            0 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6028            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6029            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = RefrigCase(CaseNum).EvapTempDesign;
    6030              :                     } else {
    6031            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6032            0 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6033              :                     }
    6034              :                 } // CaseIndex=1,NumCases
    6035              :             }     // NumcasesMT > 0
    6036              : 
    6037            0 :             if (NumWalkInsMT > 0) {
    6038            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsMT; ++WalkInIndex) {
    6039            0 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumMT(WalkInIndex);
    6040              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6041            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    6042            0 :                     NominalTotalWalkInCapMT += WalkIn(WalkInID).DesignRatedCap;
    6043            0 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6044              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6045              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6046              :                     //  to either the rack or system.
    6047              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6048            0 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6049              :                         // - 99 used as a flag for blank input error message for detailed systems
    6050            0 :                         ShowSevereError(state,
    6051            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6052              :                                                "electric and hotfluid defrost types",
    6053              :                                                RoutineName,
    6054            0 :                                                WalkIn(WalkInID).Name));
    6055            0 :                         ErrorsFound = true;
    6056              :                     }
    6057              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6058            0 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesMT == 0)) {
    6059              :                         // note use walk in index, not walkinid here to get
    6060              :                         // first walkin on this suction group/system
    6061            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = WalkIn(WalkInID).TEvapDesign;
    6062              :                     } else {
    6063            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6064            0 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6065              :                     }
    6066              :                 } // WalkInIndex=1,NumWalkIns
    6067              :             }     // NumWalkInsMT > 0
    6068              : 
    6069              :             //   Check for Low Temperature Case or Walk-In or CaseAndWalkInList names
    6070            0 :             AlphaNum = 4;
    6071            0 :             if (!lAlphaBlanks(AlphaNum)) {
    6072              : 
    6073              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6074            0 :                 int CaseAndWalkInListNum = 0;
    6075            0 :                 int CaseNum = 0;
    6076            0 :                 int WalkInNum = 0;
    6077            0 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    6078            0 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6079            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6080            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6081            0 :                 int NumNameMatches = 0;
    6082            0 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    6083            0 :                 if (CaseNum != 0) ++NumNameMatches;
    6084            0 :                 if (WalkInNum != 0) ++NumNameMatches;
    6085              : 
    6086            0 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    6087            0 :                     ErrorsFound = true;
    6088            0 :                     if (NumNameMatches == 0) {
    6089            0 :                         ShowSevereError(state,
    6090            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    6091              :                                                RoutineName,
    6092              :                                                CurrentModuleObject,
    6093            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6094              :                                                cAlphaFieldNames(AlphaNum),
    6095              :                                                Alphas(AlphaNum)));
    6096            0 :                     } else if (NumNameMatches > 1) {
    6097            0 :                         ShowSevereError(state,
    6098            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    6099              :                                                RoutineName,
    6100              :                                                CurrentModuleObject,
    6101            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6102              :                                                cAlphaFieldNames(AlphaNum),
    6103              :                                                Alphas(AlphaNum)));
    6104              :                     }                                   // num matches = 0 or > 1
    6105            0 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6106            0 :                     NumCasesLT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6107            0 :                     NumWalkInsLT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6108            0 :                     TransSystem(TransRefrigSysNum).NumCasesLT = NumCasesLT;
    6109            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = NumWalkInsLT;
    6110            0 :                     if (NumCasesLT > 0) {
    6111            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6112            0 :                         TransSystem(TransRefrigSysNum).CaseNumLT({1, NumCasesLT}) =
    6113            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesLT});
    6114              :                     }
    6115            0 :                     if (NumWalkInsLT > 0) {
    6116            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6117            0 :                         TransSystem(TransRefrigSysNum).WalkInNumLT({1, NumWalkInsLT}) =
    6118            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsLT});
    6119              :                     }
    6120            0 :                 } else if (CaseNum != 0) { // Name points to a case
    6121            0 :                     NumCasesLT = 1;
    6122            0 :                     TransSystem(TransRefrigSysNum).NumCasesLT = 1;
    6123            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6124            0 :                     TransSystem(TransRefrigSysNum).CaseNumLT(NumCases) = CaseNum;
    6125            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6126            0 :                     NumWalkInsLT = 1;
    6127            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = 1;
    6128            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6129            0 :                     TransSystem(TransRefrigSysNum).WalkInNumLT(NumWalkIns) = WalkInNum;
    6130              :                 } // NumNameMatches /= 1
    6131              :             }     // blank input for cases, walkins, or caseandwalkinlist
    6132              : 
    6133            0 :             if (NumCasesLT > 0) {
    6134              :                 // Find lowest design evap T
    6135              :                 // Sum rated capacity of all LT cases on system
    6136            0 :                 for (int caseIndex = 1; caseIndex <= NumCasesLT; ++caseIndex) {
    6137              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6138            0 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumLT(caseIndex);
    6139            0 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6140            0 :                     NominalTotalCaseCapLT += RefrigCase(CaseNum).DesignRatedCap;
    6141            0 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6142            0 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6143            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = RefrigCase(CaseNum).EvapTempDesign;
    6144              :                     } else {
    6145            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6146            0 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6147              :                     }
    6148              :                 } // CaseIndex=1,NumCases
    6149              :             }     // NumcasesLT > 0
    6150              : 
    6151            0 :             if (NumWalkInsLT > 0) {
    6152            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsLT; ++WalkInIndex) {
    6153            0 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumLT(WalkInIndex);
    6154              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6155            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    6156            0 :                     NominalTotalWalkInCapLT += WalkIn(WalkInID).DesignRatedCap;
    6157            0 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6158              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6159              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6160              :                     //  to either the rack or system.
    6161              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6162            0 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6163              :                         // - 99 used as a flag for blank input error message for detailed systems
    6164            0 :                         ShowSevereError(state,
    6165            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6166              :                                                "electric and hotfluid defrost types",
    6167              :                                                RoutineName,
    6168            0 :                                                WalkIn(WalkInID).Name));
    6169            0 :                         ErrorsFound = true;
    6170              :                     }
    6171              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6172            0 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesLT == 0)) {
    6173              :                         // note use walk in index, not walkinid here to get
    6174              :                         // first walkin on this suction group/system
    6175            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = WalkIn(WalkInID).TEvapDesign;
    6176              :                     } else {
    6177            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6178            0 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6179              :                     }
    6180              :                 } // WalkInIndex=1,NumWalkIns
    6181              :             }     // NumWalkInsMT > 0
    6182              : 
    6183            0 :             NominalTotalCoolingCap = NominalTotalCaseCapMT + NominalTotalCaseCapLT + NominalTotalWalkInCapMT + NominalTotalWalkInCapLT;
    6184              : 
    6185              :             // Read Gas Cooler
    6186              :             // currently assumes one gas cooler per refrigeration system and but multiple systems allowed per gas cooler
    6187            0 :             AlphaNum = 5;
    6188            0 :             int NumGasCoolers = 1;
    6189            0 :             if (!allocated(TransSystem(TransRefrigSysNum).GasCoolerNum)) TransSystem(TransRefrigSysNum).GasCoolerNum.allocate(NumGasCoolers);
    6190            0 :             TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6191              :             // Find gascooler number
    6192            0 :             int GCNum = Util::FindItemInList(Alphas(AlphaNum), GasCooler);
    6193              : 
    6194            0 :             if (GCNum == 0) { //  Invalid Gas Cooler attached to Transcritical Refrigeration System
    6195            0 :                 ShowSevereError(state,
    6196            0 :                                 format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    6197              :                                        RoutineName,
    6198              :                                        CurrentModuleObject,
    6199            0 :                                        TransSystem(TransRefrigSysNum).Name,
    6200              :                                        cAlphaFieldNames(AlphaNum),
    6201              :                                        Alphas(AlphaNum)));
    6202            0 :                 ErrorsFound = true;
    6203            0 :             } else if (GCNum != 0) { //  Gas Cooler attached to Transcritical Refrigeration System
    6204            0 :                 TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers) = GCNum;
    6205            0 :                 TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6206              :                 // Now take care of case where multiple systems share a gas cooler
    6207            0 :                 ++GasCooler(GCNum).NumSysAttach;
    6208            0 :                 GasCooler(GCNum).SysNum(GasCooler(GCNum).NumSysAttach) = TransRefrigSysNum;
    6209            0 :                 TransSystem(TransRefrigSysNum).RefInventory +=
    6210            0 :                     GasCooler(GCNum).RefReceiverInventory + GasCooler(GCNum).RefPipingInventory + GasCooler(GCNum).RefOpCharge;
    6211            0 :                 if (GasCooler(GCNum).GasCoolerRejectHeatToZone) TransSystem(TransRefrigSysNum).SystemRejectHeatToZone = true;
    6212              :             }
    6213              : 
    6214              :             // Read High Pressure Compressor
    6215            0 :             AlphaNum = 6;
    6216            0 :             int NumCompressorsSys = 0;
    6217            0 :             if (lAlphaBlanks(AlphaNum)) {
    6218              :                 // blank input where must have compressor or compressor list input.
    6219            0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    6220            0 :                 ErrorsFound = true;
    6221              :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    6222            0 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6223            0 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6224            0 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6225            0 :                     ShowSevereError(state,
    6226            0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6227              :                                            RoutineName,
    6228              :                                            CurrentModuleObject,
    6229              :                                            cAlphaFieldNames(AlphaNum),
    6230              :                                            Alphas(AlphaNum)));
    6231            0 :                     ErrorsFound = true;
    6232            0 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6233            0 :                     ShowSevereError(state,
    6234            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6235              :                                            RoutineName,
    6236              :                                            CurrentModuleObject,
    6237              :                                            cAlphaFieldNames(AlphaNum),
    6238              :                                            Alphas(AlphaNum)));
    6239            0 :                     ErrorsFound = true;
    6240            0 :                 } else if (ListNum != 0) {
    6241            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6242            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = NumCompressorsSys;
    6243            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP))
    6244            0 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6245            0 :                     TransSystem(TransRefrigSysNum).CompressorNumHP({1, NumCompressorsSys}) =
    6246            0 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6247            0 :                 } else if (CompNum != 0) {
    6248            0 :                     NumCompressorsSys = 1;
    6249            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = 1;
    6250            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP))
    6251            0 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6252            0 :                     TransSystem(TransRefrigSysNum).CompressorNumHP(NumCompressorsSys) = CompNum;
    6253              :                 }
    6254              :                 // Sum rated capacity of all HP compressors on system
    6255            0 :                 NominalTotalCompCapHP = 0.0;
    6256            0 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6257            0 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumHP(CompIndex);
    6258              : 
    6259            0 :                     if (Compressor(CompNum).TransFlag) { //  Calculate nominal capacity of transcritical Compressor
    6260            0 :                         Real64 GCOutletH = TransSystem(TransRefrigSysNum)
    6261            0 :                                                .refrig->getSupHeatEnthalpy(state,
    6262            0 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletT,
    6263            0 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletP,
    6264              :                                                                            routineName);
    6265            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6266            0 :                             state, Compressor(CompNum).TransCapacityCurvePtr, TransSystem(TransRefrigSysNum).TEvapDesignMT, GCOutletH);
    6267            0 :                         NominalTotalCompCapHP += Compressor(CompNum).NomCap;
    6268            0 :                         ++Compressor(CompNum).NumSysAttach;
    6269              :                     } else { //  Subcritical compressor attached to transcritical system - show error
    6270            0 :                         ShowSevereError(
    6271              :                             state,
    6272            0 :                             format("{}{}, No transcritical CO2 compressors are attached to the transcritical refrigeration system, \"{}\".",
    6273              :                                    RoutineName,
    6274              :                                    CurrentModuleObject,
    6275            0 :                                    TransSystem(TransRefrigSysNum).Name));
    6276            0 :                         ErrorsFound = true;
    6277              :                     }
    6278              :                 }
    6279              :             }
    6280              : 
    6281              :             // Read Low Pressure Compressor
    6282            0 :             AlphaNum = 7;
    6283            0 :             NumCompressorsSys = 0;
    6284              : 
    6285            0 :             if ((lAlphaBlanks(AlphaNum)) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage)) {
    6286              :                 // TwoStage system type is specified but low pressure compressor input is blank
    6287            0 :                 ShowSevereError(state,
    6288            0 :                                 format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"TwoStage\", "
    6289              :                                        "however, the \"{}\" is not given.",
    6290              :                                        RoutineName,
    6291              :                                        CurrentModuleObject,
    6292            0 :                                        TransSystem(TransRefrigSysNum).Name,
    6293              :                                        cAlphaFieldNames(AlphaNum)));
    6294            0 :                 ErrorsFound = true;
    6295            0 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::SingleStage)) {
    6296              :                 // SingleStage system type with low pressure compressors specified. Ignore low pressure compressors
    6297            0 :                 ShowWarningError(state,
    6298            0 :                                  format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"SingleStage\", "
    6299              :                                         "however, a \"{}\" was found.  The low pressure compressors will be ignored and will not simulated.",
    6300              :                                         RoutineName,
    6301              :                                         CurrentModuleObject,
    6302            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6303              :                                         cAlphaFieldNames(AlphaNum)));
    6304            0 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage)) {
    6305              :                 // TwoStage system with low pressure compressors specified
    6306            0 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6307            0 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6308            0 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6309            0 :                     ShowSevereError(state,
    6310            0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6311              :                                            RoutineName,
    6312              :                                            CurrentModuleObject,
    6313              :                                            cAlphaFieldNames(AlphaNum),
    6314              :                                            Alphas(AlphaNum)));
    6315            0 :                     ErrorsFound = true;
    6316            0 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6317            0 :                     ShowSevereError(state,
    6318            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6319              :                                            RoutineName,
    6320              :                                            CurrentModuleObject,
    6321              :                                            cAlphaFieldNames(AlphaNum),
    6322              :                                            Alphas(AlphaNum)));
    6323            0 :                     ErrorsFound = true;
    6324            0 :                 } else if (ListNum != 0) {
    6325            0 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6326            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = NumCompressorsSys;
    6327            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP))
    6328            0 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6329            0 :                     TransSystem(TransRefrigSysNum).CompressorNumLP({1, NumCompressorsSys}) =
    6330            0 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6331            0 :                 } else if (CompNum != 0) {
    6332            0 :                     NumCompressorsSys = 1;
    6333            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = 1;
    6334            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP))
    6335            0 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6336            0 :                     TransSystem(TransRefrigSysNum).CompressorNumLP(NumCompressorsSys) = CompNum;
    6337              :                 }
    6338              :                 // Sum rated capacity of all LP compressors on system
    6339            0 :                 NominalTotalCompCapLP = 0.0;
    6340            0 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6341            0 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumLP(CompIndex);
    6342            0 :                     if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage) { //  Calculate capacity of LP compressors
    6343            0 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6344            0 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6345            0 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignLT,
    6346            0 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6347            0 :                         NominalTotalCompCapLP += Compressor(CompNum).NomCap;
    6348            0 :                         ++Compressor(CompNum).NumSysAttach;
    6349              :                     }
    6350              :                 }
    6351              :             }
    6352              : 
    6353              :             // Read Receiver Pressure
    6354            0 :             if (!lNumericBlanks(1)) {
    6355            0 :                 TransSystem(TransRefrigSysNum).PReceiver = Numbers(1);
    6356              :             } else { // Default value receiver pressure = 4000000 Pa
    6357            0 :                 TransSystem(TransRefrigSysNum).PReceiver = 4.0e6;
    6358              :             }
    6359              : 
    6360              :             // Check receiver temperature against minimum condensing temperature (from gas cooler input) and design evaporator temperatures
    6361            0 :             TransSystem(TransRefrigSysNum).TReceiver =
    6362            0 :                 TransSystem(TransRefrigSysNum).refrig->getSatTemperature(state, TransSystem(TransRefrigSysNum).PReceiver, routineName);
    6363            0 :             if (TransSystem(TransRefrigSysNum).TReceiver > GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp) {
    6364            0 :                 ShowWarningError(state,
    6365            0 :                                  format("{}{}=\"{}: The receiver temperature ({:.2R}C) is greater than the minimum condensing temperature "
    6366              :                                         "specified for subcritical operation ({:.2R}C).",
    6367              :                                         RoutineName,
    6368              :                                         CurrentModuleObject,
    6369            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6370            0 :                                         TransSystem(TransRefrigSysNum).TReceiver,
    6371            0 :                                         GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp));
    6372            0 :                 ShowContinueError(state, "  The minimum condensing temperature will be set at 5C greater than the receiver temperature.");
    6373            0 :                 GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp = TransSystem(TransRefrigSysNum).TReceiver + 5.0;
    6374              :             }
    6375            0 :             if (NominalTotalCompCapLP > 0.0) {
    6376            0 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignLT) {
    6377            0 :                     ShowSevereError(state,
    6378            0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6379              :                                            "low temperature loads ({:.2R}C).",
    6380              :                                            RoutineName,
    6381              :                                            CurrentModuleObject,
    6382            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6383            0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6384            0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignLT));
    6385            0 :                     ShowContinueError(state,
    6386              :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6387              :                                       "the low temperature loads.");
    6388            0 :                     ShowContinueError(state,
    6389              :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6390            0 :                     ErrorsFound = true;
    6391              :                 }
    6392              :             }
    6393            0 :             if (NominalTotalCompCapHP > 0.0) {
    6394            0 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignMT) {
    6395            0 :                     ShowSevereError(state,
    6396            0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6397              :                                            "medium temperature loads ({:.2R}C).",
    6398              :                                            RoutineName,
    6399              :                                            CurrentModuleObject,
    6400            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6401            0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6402            0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignMT));
    6403            0 :                     ShowContinueError(state,
    6404              :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6405              :                                       "the medium temperature loads.");
    6406            0 :                     ShowContinueError(state,
    6407              :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6408            0 :                     ErrorsFound = true;
    6409              :                 }
    6410              :             }
    6411              : 
    6412              :             // Read subcooler effectiveness
    6413            0 :             if (!lNumericBlanks(2)) {
    6414            0 :                 TransSystem(TransRefrigSysNum).SCEffectiveness = Numbers(2);
    6415              :             } else { // Default value effectiveness = 0.4
    6416            0 :                 TransSystem(TransRefrigSysNum).PReceiver = 0.4;
    6417              :             }
    6418              :             // Check subcooler effectiveness value, must be value between 0 and 1
    6419            0 :             if ((TransSystem(TransRefrigSysNum).SCEffectiveness < 0) || (TransSystem(TransRefrigSysNum).SCEffectiveness > 1)) {
    6420            0 :                 ShowSevereError(state,
    6421            0 :                                 format("{}{}=\"{}: The value for subcooler effectiveness is invalid.  The subcooler effectiveness must be a value "
    6422              :                                        "greater than or equal to zero and less than or equal to one.",
    6423              :                                        RoutineName,
    6424              :                                        CurrentModuleObject,
    6425            0 :                                        TransSystem(TransRefrigSysNum).Name));
    6426            0 :                 ErrorsFound = true;
    6427              :             }
    6428              : 
    6429              :             // Suction piping heat gain - optional
    6430              :             //  Input UA and identify the Zone containing the bulk of the suction piping
    6431              :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    6432              :             //  The pipe heat gains are also counted as cooling credit for the zone.
    6433              :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    6434              :             //  Get the Zone and zone node numbers from the zone name entered by the user
    6435            0 :             AlphaNum = 9; // Medium temperature suction piping
    6436            0 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = 0.0;
    6437            0 :             if (!lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    6438            0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = Numbers(3);
    6439            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    6440            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT =
    6441            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT);
    6442            0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT == 0) {
    6443            0 :                     ShowSevereError(state,
    6444            0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    6445              :                                            RoutineName,
    6446              :                                            CurrentModuleObject,
    6447            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6448              :                                            cAlphaFieldNames(AlphaNum),
    6449              :                                            Alphas(AlphaNum),
    6450              :                                            cNumericFieldNames(3)));
    6451            0 :                     ShowContinueError(state,
    6452              :                                       "  The medium temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    6453              :                                       "determine the environmental temperature surrounding the piping.");
    6454            0 :                     ErrorsFound = true;
    6455              :                 } else {
    6456            0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT) = true;
    6457              :                 }
    6458            0 :             } else if (!lNumericBlanks(3) && lAlphaBlanks(AlphaNum)) {
    6459            0 :                 ShowWarningError(state,
    6460            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    6461              :                                         RoutineName,
    6462              :                                         CurrentModuleObject,
    6463            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6464              :                                         cAlphaFieldNames(AlphaNum),
    6465              :                                         cNumericFieldNames(3)));
    6466            0 :                 ShowContinueError(state,
    6467              :                                   "  The medium temperature suction piping heat gain will not be calculated unless a Zone is defined to "
    6468              :                                   "determine the environmental temperature surrounding the piping.");
    6469            0 :             } else if (lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    6470            0 :                 ShowWarningError(state,
    6471            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    6472              :                                         RoutineName,
    6473              :                                         CurrentModuleObject,
    6474            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6475              :                                         cAlphaFieldNames(AlphaNum),
    6476              :                                         cNumericFieldNames(3)));
    6477              :             } // Medium temperature suction piping heat gains
    6478              : 
    6479            0 :             AlphaNum = 10; // Low temperature suction piping
    6480            0 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = 0.0;
    6481            0 :             if (!lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    6482            0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = Numbers(4);
    6483            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    6484            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT =
    6485            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT);
    6486            0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT == 0) {
    6487            0 :                     ShowSevereError(state,
    6488            0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    6489              :                                            RoutineName,
    6490              :                                            CurrentModuleObject,
    6491            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6492              :                                            cAlphaFieldNames(AlphaNum),
    6493              :                                            Alphas(AlphaNum),
    6494              :                                            cNumericFieldNames(4)));
    6495            0 :                     ShowContinueError(state,
    6496              :                                       "  The low temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    6497              :                                       "determine the environmental temperature surrounding the piping.");
    6498            0 :                     ErrorsFound = true;
    6499              :                 } else {
    6500            0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT) = true;
    6501              :                 }
    6502            0 :             } else if (!lNumericBlanks(4) && lAlphaBlanks(AlphaNum)) {
    6503            0 :                 ShowWarningError(state,
    6504            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    6505              :                                         RoutineName,
    6506              :                                         CurrentModuleObject,
    6507            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6508              :                                         cAlphaFieldNames(AlphaNum),
    6509              :                                         cNumericFieldNames(4)));
    6510            0 :                 ShowContinueError(state,
    6511              :                                   "  The low temperature suction piping heat gain will not be calculated unless a Zone is defined to determine "
    6512              :                                   "the environmental temperature surrounding the piping.");
    6513            0 :             } else if (lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    6514            0 :                 ShowWarningError(state,
    6515            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    6516              :                                         RoutineName,
    6517              :                                         CurrentModuleObject,
    6518            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6519              :                                         cAlphaFieldNames(AlphaNum),
    6520              :                                         cNumericFieldNames(4)));
    6521              :             } // Low temperature suction piping heat gains
    6522              : 
    6523            0 :             AlphaNum = 11;
    6524            0 :             if (!lAlphaBlanks(AlphaNum)) TransSystem(TransRefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    6525              : 
    6526              :             // Compare the rated capacity of compressor, condenser, and cases.
    6527              :             // Note, rated capacities can be far off from operating capacities, but rough check.
    6528            0 :             Real64 NominalCondCap = GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedCapacity;
    6529            0 :             Real64 NominalTotalCompCap = NominalTotalCompCapHP + NominalTotalCompCapLP;
    6530            0 :             if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6531            0 :                 ShowWarningError(
    6532            0 :                     state, format("{}=\"{}\", You may wish to check the system sizing.", CurrentModuleObject, TransSystem(TransRefrigSysNum).Name));
    6533            0 :                 ShowContinueError(
    6534              :                     state,
    6535            0 :                     format("Total nominal cooling capacity is {:.0R}W. Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6536              :                            NominalTotalCoolingCap,
    6537              :                            NominalCondCap,
    6538              :                            NominalTotalCompCap));
    6539              :             }
    6540              : 
    6541              :         } // Transcritical refrigeration systems
    6542              : 
    6543              :     } //(NumTransRefrigSystems > 0)
    6544              : 
    6545          150 :     DayValues.deallocate();
    6546          150 :     Alphas.deallocate();
    6547          150 :     Numbers.deallocate();
    6548          150 :     cAlphaFieldNames.deallocate();
    6549          150 :     cNumericFieldNames.deallocate();
    6550          150 :     lAlphaBlanks.deallocate();
    6551          150 :     lNumericBlanks.deallocate();
    6552              : 
    6553          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    6554              :         // Find unused and non-unique display case objects to report in eio and err file and sum
    6555              :         //    all HVAC RA fractions and write error message if greater than 1 for any zone
    6556            6 :         for (int ZoneIndex = 1; ZoneIndex <= state.dataGlobal->NumOfZones; ++ZoneIndex) { // numofzones from dataglobals
    6557            3 :             Real64 TempRAFraction = CaseRAFraction(ZoneIndex).TotalCaseRAFraction;
    6558            6 :             for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    6559              :                 // TempRaFraction already includes contributions from ALL cases in zone
    6560              :                 // Want to delete portion from unused cases (numsysattach = 0)that will never be simulated
    6561            3 :                 if (RefrigCase(CaseNum).ActualZoneNum != ZoneIndex || RefrigCase(CaseNum).NumSysAttach > 0) continue;
    6562            0 :                 TempRAFraction -= RefrigCase(CaseNum).RAFrac;
    6563              :             } // NumSimulationCases
    6564            3 :             if (TempRAFraction > 1.0) {
    6565            0 :                 ShowSevereError(
    6566              :                     state,
    6567            0 :                     format("{}: Refrigeration:Case, Refrigerated case return air fraction for all cases in zone=\"{}\" is greater than 1.0.",
    6568              :                            RoutineName,
    6569            0 :                            CaseRAFraction(ZoneIndex).ZoneName));
    6570              :                 // check in comment, can't use "currentModuleObject" because not in get input subroutine where that is known
    6571            0 :                 ErrorsFound = true;
    6572              :             }
    6573              :         } // ZoneIndex=1,DataGlobals::NumOfZones
    6574              : 
    6575            3 :         CaseRAFraction.deallocate(); // only used for input check just completed
    6576              :         // check for cases not connected to systems and cases connected
    6577              :         // more than once (twice in a system or to more than one system)
    6578              : 
    6579            3 :         state.dataRefrigCase->NumUnusedRefrigCases = 0;
    6580            6 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    6581            3 :             if (RefrigCase(CaseNum).NumSysAttach == 1) continue;
    6582            0 :             if (RefrigCase(CaseNum).NumSysAttach < 1) {
    6583            0 :                 ++state.dataRefrigCase->NumUnusedRefrigCases;
    6584            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6585              :                     //  individual case names listed if DataGlobals::DisplayExtraWarnings option selected
    6586            0 :                     ShowWarningError(state, format("{}: Refrigeration:Case=\"{}\" unused. ", RoutineName, RefrigCase(CaseNum).Name));
    6587              :                 } // display extra warnings - give a list of unused cases
    6588              :             }     // unused case
    6589            0 :             if (RefrigCase(CaseNum).NumSysAttach > 1) {
    6590            0 :                 ErrorsFound = true;
    6591            0 :                 ShowSevereError(
    6592            0 :                     state, format("{}: Refrigeration:Case=\"{}\", Same refrigerated case name referenced ", RoutineName, RefrigCase(CaseNum).Name));
    6593            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    6594              :             } // if looking for same case attached to multiple systems/racks
    6595              :         }     // NumSimulationCases
    6596              : 
    6597            3 :         if ((state.dataRefrigCase->NumUnusedRefrigCases > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6598              :             //  write to error file,
    6599              :             //  summary number of unused cases given if DataGlobals::DisplayExtraWarnings option not selected
    6600            0 :             ShowWarningError(state,
    6601            0 :                              format("Refrigeration:Case -> {} unused refrigerated case(s) found during input processing.",
    6602            0 :                                     state.dataRefrigCase->NumUnusedRefrigCases));
    6603            0 :             ShowContinueError(state, "  These refrigerated cases are in the input file but are not connected to a ");
    6604            0 :             ShowContinueError(state, "  Refrigeration:CompressorRack, Refrigeration:System, or Refrigeration:SecondarySystem object.");
    6605            0 :             ShowContinueError(state, "  These unused refrigeration cases will not be simulated.");
    6606            0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6607              :         } // NumUnusedRefrigCases
    6608              :     }     // numsimulation cases > 0
    6609              : 
    6610          150 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    6611              :         // check for compressors not connected to systems and compressors connected more than once
    6612              :         // (twice in a system or to more than one system)
    6613            0 :         state.dataRefrigCase->NumUnusedCompressors = 0;
    6614            0 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    6615            0 :             if (Compressor(CompNum).NumSysAttach == 1) continue;
    6616            0 :             if (Compressor(CompNum).NumSysAttach < 1) {
    6617            0 :                 ++state.dataRefrigCase->NumUnusedCompressors;
    6618            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6619              :                     //  individual compressor names listed if DataGlobals::DisplayExtraWarnings option selected
    6620            0 :                     ShowWarningError(state, format("{}: Refrigeration:Compressor=\"{}\" unused. ", RoutineName, Compressor(CompNum).Name));
    6621              :                 } // display extra warnings - give a list of unused compressors
    6622              :             }     // unused compressor
    6623            0 :             if (Compressor(CompNum).NumSysAttach > 1) {
    6624            0 :                 ErrorsFound = true;
    6625            0 :                 ShowSevereError(state,
    6626            0 :                                 format("{}: Refrigeration:Compressor=\"{}\", Same refrigeration compressor name referenced",
    6627              :                                        RoutineName,
    6628            0 :                                        Compressor(CompNum).Name));
    6629            0 :                 ShowContinueError(state, " by more than one refrigeration system.");
    6630              :             } // looking for same compressor attached to multiple systems/racks
    6631              :         }     // NumSimulationCompressors
    6632              : 
    6633            0 :         if ((state.dataRefrigCase->NumUnusedCompressors > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6634              :             //  write to error file,
    6635              :             //  summary number of unused compressors given if DataGlobals::DisplayExtraWarnings option not selected
    6636            0 :             ShowWarningError(state,
    6637            0 :                              format("Refrigeration:Compressor -> {} unused refrigeration compressor(s) found during input processing.",
    6638            0 :                                     state.dataRefrigCase->NumUnusedCompressors));
    6639            0 :             ShowContinueError(state,
    6640              :                               "  Those refrigeration compressors are in the input file but are not connected to a Refrigeration:System object.");
    6641            0 :             ShowContinueError(state, "   These unused refrigeration compressors will not be simulated.");
    6642            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6643              :         } // NumUnusedCompressors
    6644              :     }     // NumSimulationCompressors > 0
    6645              : 
    6646          150 :     int NumUnusedWalkIns = 0;
    6647          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    6648              :         // check for refrigeration WalkIns not connected to any systems and
    6649              :         //  refrigeration WalkIns connected more than once
    6650            6 :         for (int WalkInNum = 1; WalkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInNum) {
    6651            3 :             if (WalkIn(WalkInNum).NumSysAttach == 1) continue;
    6652            0 :             if (WalkIn(WalkInNum).NumSysAttach < 1) {
    6653            0 :                 ++NumUnusedWalkIns;
    6654            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6655              :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    6656            0 :                     ShowWarningError(state, format("{}: Refrigeration:WalkIn=\"{}\" unused. ", RoutineName, WalkIn(WalkInNum).Name));
    6657              :                 } // display extra warnings - give a list of unused WalkIns
    6658              :             }     // unused walkin
    6659            0 :             if (WalkIn(WalkInNum).NumSysAttach > 1) {
    6660            0 :                 ErrorsFound = true;
    6661            0 :                 ShowSevereError(
    6662            0 :                     state, format("{}: Refrigeration:WalkIn=\"{}\", Same Refrigeration WalkIn name referenced", RoutineName, WalkIn(WalkInNum).Name));
    6663            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    6664              :             } // if looking for same walk in attached to multiple systems/racks
    6665              :         }     // NumSimulationWalkIns
    6666              : 
    6667            3 :         if ((NumUnusedWalkIns > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6668              :             //  write to error file,
    6669              :             //  summary number of unused walkins given if DataGlobals::DisplayExtraWarnings option not selected
    6670            0 :             ShowWarningError(
    6671              :                 state,
    6672            0 :                 format("{}Refrigeration:WalkIn -> {} unused refrigeration WalkIns found during input processing.", RoutineName, NumUnusedWalkIns));
    6673            0 :             ShowContinueError(state, "   Those refrigeration WalkIns are in the input file but are not connected to a ");
    6674            0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    6675            0 :             ShowContinueError(state, "   These unused refrigeration WalkIns will not be simulated.");
    6676            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6677              :         } // NumUnusedWalkIns
    6678              :     }     // NumSimulationWalkIns > 0
    6679              : 
    6680          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    6681              :         // check for air chillers not connected to any systems and
    6682              :         //  air chillers connected more than once
    6683            0 :         state.dataRefrigCase->NumUnusedCoils = 0;
    6684            0 :         for (int CoilNum = 1; CoilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilNum) {
    6685            0 :             if (WarehouseCoil(CoilNum).NumSysAttach == 1) continue;
    6686            0 :             if (WarehouseCoil(CoilNum).NumSysAttach < 1) {
    6687            0 :                 ++NumUnusedWalkIns;
    6688            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6689              :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    6690            0 :                     ShowWarningError(state, format("{}: Refrigeration:AirChiller=\"{}\" unused. ", RoutineName, WarehouseCoil(CoilNum).Name));
    6691              :                 } // display extra warnings - give a list of unused chillers
    6692              :             }     // unused chiller
    6693            0 :             if (WarehouseCoil(CoilNum).NumSysAttach > 1) {
    6694            0 :                 ErrorsFound = true;
    6695            0 :                 ShowSevereError(state,
    6696            0 :                                 format("{}: Refrigeration:AirChiller=\"{}\", Same Refrigeration Air Chiller name referenced",
    6697              :                                        RoutineName,
    6698            0 :                                        WarehouseCoil(CoilNum).Name));
    6699            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    6700              :             } // if looking for same walk in attached to multiple systems/racks
    6701              :         }     // NumSimulationRefrigAirchillers
    6702              : 
    6703            0 :         if ((state.dataRefrigCase->NumUnusedCoils > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6704              :             //  write to error file,
    6705              :             //  summary number of unused air chillers given if DataGlobals::DisplayExtraWarnings option not selected
    6706            0 :             ShowWarningError(state,
    6707            0 :                              format("{}Refrigeration:AirChiller -> {} unused refrigeration air chillers found during input processing.",
    6708              :                                     RoutineName,
    6709            0 :                                     state.dataRefrigCase->NumUnusedCoils));
    6710            0 :             ShowContinueError(state, "   Those refrigeration air chillers are in the input file but are not connected to a ");
    6711            0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    6712            0 :             ShowContinueError(state, "   These unused refrigeration air chillers will not be simulated.");
    6713            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6714              :         } // NumUnusedAirChllerss
    6715              :     }     // NumSimulationAirChillers > 0
    6716              : 
    6717          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    6718              :         // check for refrigeration Secondarys not connected to detailed systems and
    6719              :         //  refrigeration Secondarys connected more than once
    6720            0 :         state.dataRefrigCase->NumUnusedSecondarys = 0;
    6721            0 :         for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    6722            0 :             if (Secondary(SecondaryNum).NumSysAttach == 1) continue;
    6723            0 :             if (Secondary(SecondaryNum).NumSysAttach < 1) {
    6724            0 :                 ++state.dataRefrigCase->NumUnusedSecondarys;
    6725            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6726              :                     //  individual secondary names listed if DataGlobals::DisplayExtraWarnings option selected
    6727            0 :                     ShowWarningError(state, format("{}: Refrigeration:Secondary=\"{}\" unused. ", RoutineName, Secondary(SecondaryNum).Name));
    6728              :                 } // display extra warnings - give a list of unused Secondaries
    6729              :             }     // unused secondary
    6730            0 :             if (Secondary(SecondaryNum).NumSysAttach > 1) {
    6731            0 :                 ErrorsFound = true;
    6732            0 :                 ShowSevereError(state,
    6733            0 :                                 format("{}: Refrigeration:Secondary=\"{}\", Same Refrigeration Secondary name referenced",
    6734              :                                        RoutineName,
    6735            0 :                                        Secondary(SecondaryNum).Name));
    6736            0 :                 ShowContinueError(state, "   by more than one refrigeration system");
    6737              :             } // looking for same secondary loop attached to multiple systems/racks
    6738              :         }     // NumSimulationSecondarys
    6739              : 
    6740            0 :         if ((state.dataRefrigCase->NumUnusedSecondarys > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6741              :             //  write to error file,
    6742              :             //  summary number of unused secondaries given if DataGlobals::DisplayExtraWarnings option not selected
    6743            0 :             ShowWarningError(state,
    6744            0 :                              format("{}Refrigeration:Secondary -> {} unused refrigeration Secondary Loops found during input processing.",
    6745              :                                     RoutineName,
    6746            0 :                                     state.dataRefrigCase->NumUnusedSecondarys));
    6747            0 :             ShowContinueError(state, "  Those refrigeration Secondary Loops are in the input file but are not connected to a refrigeration system.");
    6748            0 :             ShowContinueError(state, "   These unused refrigeration secondaries will not be simulated.");
    6749            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6750              :         } // NumUnusedSecondarys
    6751              :     }     // NumSimulationSecondarySystems > 0
    6752              : 
    6753          150 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    6754              :         // Check for presence of shared condensers and for unused condensers
    6755              :         //     - determines number of loops through refrigeration simulation
    6756              :         //       because of dependence of performance on total condenser load
    6757            0 :         state.dataRefrigCase->NumSimulationSharedCondensers = 0;
    6758            0 :         state.dataRefrigCase->NumUnusedCondensers = 0;
    6759            0 :         for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumRefrigCondensers; ++CondNum) {
    6760            0 :             if (Condenser(CondNum).NumSysAttach == 1) continue;
    6761            0 :             if (Condenser(CondNum).NumSysAttach < 1) {
    6762            0 :                 ++state.dataRefrigCase->NumUnusedCondensers;
    6763            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6764              :                     //  individual condenser names listed if DataGlobals::DisplayExtraWarnings option selected
    6765            0 :                     ShowWarningError(state, format("{}: Refrigeration:Condenser=\"{}\" unused. ", RoutineName, Condenser(CondNum).Name));
    6766              :                 } // display extra warnings - give a list of unused condensers
    6767              :             }     // unused condenser
    6768            0 :             if (Condenser(CondNum).NumSysAttach > 1) {
    6769            0 :                 ++state.dataRefrigCase->NumSimulationSharedCondensers;
    6770              :             } // looking for shared condensers
    6771              :         }     // CondNum
    6772              : 
    6773            0 :         if ((state.dataRefrigCase->NumUnusedCondensers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6774              :             //  write to error file,
    6775              :             //  summary number of unused condensers given if DataGlobals::DisplayExtraWarnings option not selected
    6776            0 :             ShowWarningError(state,
    6777            0 :                              format("{}Refrigeration condenser -> {} unused refrigeration condensers found during input processing.",
    6778              :                                     RoutineName,
    6779            0 :                                     state.dataRefrigCase->NumUnusedCondensers));
    6780            0 :             ShowContinueError(state, "  Those refrigeration condensers are in the input file but are not connected to a refrigeration system.");
    6781            0 :             ShowContinueError(state, "   These unused refrigeration condensers will not be simulated.");
    6782            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6783              :         } // NumUnusedCondensers and displayextra warnings
    6784              :     }     // DataHeatBalance::NumRefrigCondensers > 0
    6785              : 
    6786          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    6787              :         // Check for presence of shared gas coolers and for unused gas coolers
    6788            0 :         state.dataRefrigCase->NumSimulationSharedGasCoolers = 0;
    6789            0 :         state.dataRefrigCase->NumUnusedGasCoolers = 0;
    6790            0 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    6791            0 :             if (GasCooler(GCNum).NumSysAttach == 1) continue;
    6792            0 :             if (GasCooler(GCNum).NumSysAttach < 1) {
    6793            0 :                 ++state.dataRefrigCase->NumUnusedGasCoolers;
    6794            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    6795              :                     //  individual gas cooler names listed if DataGlobals::DisplayExtraWarnings option selected
    6796            0 :                     ShowWarningError(state, format("{}: Refrigeration:GasCooler=\"{}\" unused. ", RoutineName, GasCooler(GCNum).Name));
    6797              :                 } // display extra warnings - give a list of unused gas coolers
    6798              :             }     // unused gas cooler
    6799            0 :             if (GasCooler(GCNum).NumSysAttach > 1) {
    6800            0 :                 ++state.dataRefrigCase->NumSimulationSharedGasCoolers;
    6801              :             } // looking for shared gas coolers
    6802              :         }     // GCNum
    6803              : 
    6804            0 :         if ((state.dataRefrigCase->NumUnusedGasCoolers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    6805              :             //  write to error file,
    6806              :             //  summary number of unused gas coolers given if DataGlobals::DisplayExtraWarnings option not selected
    6807            0 :             ShowWarningError(state,
    6808            0 :                              format("{}Refrigeration gas cooler -> {} unused refrigeration gas cooler(s) found during input processing.",
    6809              :                                     RoutineName,
    6810            0 :                                     state.dataRefrigCase->NumUnusedGasCoolers));
    6811            0 :             ShowContinueError(state, "  These refrigeration gas coolers are in the input file but are not connected to a refrigeration system.");
    6812            0 :             ShowContinueError(state, "  These unused refrigeration gas coolers will not be simulated.");
    6813            0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    6814              :         } // NumUnusedGasCoolers and displayextra warnings
    6815              :     }     // NumSimulationGasCooler > 0
    6816              : 
    6817              :     // echo input to eio file.
    6818          150 :     ReportRefrigerationComponents(state);
    6819              : 
    6820          150 :     if (ErrorsFound) {
    6821            0 :         ShowFatalError(state, format("{} Previous errors cause program termination", RoutineName));
    6822              :     }
    6823          150 : }
    6824              : 
    6825          150 : void SetupReportInput(EnergyPlusData &state)
    6826              : {
    6827              :     // SUBROUTINE INFORMATION:
    6828              :     //       AUTHOR         Richard Raustad, FSEC
    6829              :     //       DATE WRITTEN   Oct/Nov 2004
    6830              :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008 and 09
    6831              :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
    6832              :     //       RE-ENGINEERED  na
    6833              : 
    6834              :     // PURPOSE OF THIS SUBROUTINE:
    6835              :     // Set up the report variables.
    6836              : 
    6837          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
    6838          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
    6839          150 :     auto &System = state.dataRefrigCase->System;
    6840          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
    6841          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
    6842          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
    6843          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
    6844          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
    6845          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
    6846          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
    6847          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
    6848          150 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
    6849          150 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
    6850              : 
    6851          150 :     std::string Walkin_and_zone_name; // concat name for walk-in/zone credit reporting
    6852              : 
    6853          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    6854              :         // Setup Report Variables for simulated Refrigerated Case (do not report unused cases)
    6855              :         // CurrentModuleObject='Refrigeration:Case'
    6856            6 :         for (int caseNum = 1; caseNum <= state.dataRefrigCase->NumSimulationCases; ++caseNum) {
    6857            3 :             auto &thisCase = RefrigCase(caseNum);
    6858            3 :             if (thisCase.NumSysAttach == 1) {
    6859            6 :                 SetupOutputVariable(state,
    6860              :                                     "Refrigeration Case Evaporator Total Cooling Rate",
    6861              :                                     Constant::Units::W,
    6862            3 :                                     thisCase.TotalCoolingLoad,
    6863              :                                     OutputProcessor::TimeStepType::Zone,
    6864              :                                     OutputProcessor::StoreType::Average,
    6865            3 :                                     thisCase.Name);
    6866            6 :                 SetupOutputVariable(state,
    6867              :                                     "Refrigeration Case Evaporator Total Cooling Energy",
    6868              :                                     Constant::Units::J,
    6869            3 :                                     thisCase.TotalCoolingEnergy,
    6870              :                                     OutputProcessor::TimeStepType::Zone,
    6871              :                                     OutputProcessor::StoreType::Sum,
    6872            3 :                                     thisCase.Name,
    6873              :                                     Constant::eResource::EnergyTransfer,
    6874              :                                     OutputProcessor::Group::Building,
    6875              :                                     OutputProcessor::EndUseCat::Refrigeration,
    6876              :                                     "", // End-use sub category
    6877            3 :                                     thisCase.ZoneName);
    6878            6 :                 SetupOutputVariable(state,
    6879              :                                     "Refrigeration Case Evaporator Sensible Cooling Rate",
    6880              :                                     Constant::Units::W,
    6881            3 :                                     thisCase.SensCoolingEnergyRate,
    6882              :                                     OutputProcessor::TimeStepType::Zone,
    6883              :                                     OutputProcessor::StoreType::Average,
    6884            3 :                                     thisCase.Name);
    6885            6 :                 SetupOutputVariable(state,
    6886              :                                     "Refrigeration Case Evaporator Sensible Cooling Energy",
    6887              :                                     Constant::Units::J,
    6888            3 :                                     thisCase.SensCoolingEnergy,
    6889              :                                     OutputProcessor::TimeStepType::Zone,
    6890              :                                     OutputProcessor::StoreType::Sum,
    6891            3 :                                     thisCase.Name);
    6892            6 :                 SetupOutputVariable(state,
    6893              :                                     "Refrigeration Case Evaporator Latent Cooling Rate",
    6894              :                                     Constant::Units::W,
    6895            3 :                                     thisCase.LatCoolingEnergyRate,
    6896              :                                     OutputProcessor::TimeStepType::Zone,
    6897              :                                     OutputProcessor::StoreType::Average,
    6898            3 :                                     thisCase.Name);
    6899            6 :                 SetupOutputVariable(state,
    6900              :                                     "Refrigeration Case Evaporator Latent Cooling Energy",
    6901              :                                     Constant::Units::J,
    6902            3 :                                     thisCase.LatCoolingEnergy,
    6903              :                                     OutputProcessor::TimeStepType::Zone,
    6904              :                                     OutputProcessor::StoreType::Sum,
    6905            3 :                                     thisCase.Name);
    6906              : 
    6907            6 :                 SetupOutputVariable(state,
    6908              :                                     "Refrigeration Case Zone Sensible Cooling Rate",
    6909              :                                     Constant::Units::W,
    6910            3 :                                     thisCase.SensZoneCreditCoolRate,
    6911              :                                     OutputProcessor::TimeStepType::Zone,
    6912              :                                     OutputProcessor::StoreType::Average,
    6913            3 :                                     thisCase.Name);
    6914            6 :                 SetupOutputVariable(state,
    6915              :                                     "Refrigeration Case Zone Sensible Cooling Energy",
    6916              :                                     Constant::Units::J,
    6917            3 :                                     thisCase.SensZoneCreditCool,
    6918              :                                     OutputProcessor::TimeStepType::Zone,
    6919              :                                     OutputProcessor::StoreType::Sum,
    6920            3 :                                     thisCase.Name);
    6921            6 :                 SetupOutputVariable(state,
    6922              :                                     "Refrigeration Case Zone Sensible Heating Rate",
    6923              :                                     Constant::Units::W,
    6924            3 :                                     thisCase.SensZoneCreditHeatRate,
    6925              :                                     OutputProcessor::TimeStepType::Zone,
    6926              :                                     OutputProcessor::StoreType::Average,
    6927            3 :                                     thisCase.Name);
    6928            6 :                 SetupOutputVariable(state,
    6929              :                                     "Refrigeration Case Zone Sensible Heating Energy",
    6930              :                                     Constant::Units::J,
    6931            3 :                                     thisCase.SensZoneCreditHeat,
    6932              :                                     OutputProcessor::TimeStepType::Zone,
    6933              :                                     OutputProcessor::StoreType::Sum,
    6934            3 :                                     thisCase.Name);
    6935              : 
    6936            6 :                 SetupOutputVariable(state,
    6937              :                                     "Refrigeration Case Zone Latent Rate",
    6938              :                                     Constant::Units::W,
    6939            3 :                                     thisCase.LatZoneCreditRate,
    6940              :                                     OutputProcessor::TimeStepType::Zone,
    6941              :                                     OutputProcessor::StoreType::Average,
    6942            3 :                                     thisCase.Name);
    6943            6 :                 SetupOutputVariable(state,
    6944              :                                     "Refrigeration Case Zone Latent Energy",
    6945              :                                     Constant::Units::J,
    6946            3 :                                     thisCase.LatZoneCredit,
    6947              :                                     OutputProcessor::TimeStepType::Zone,
    6948              :                                     OutputProcessor::StoreType::Sum,
    6949            3 :                                     thisCase.Name);
    6950              : 
    6951            6 :                 SetupOutputVariable(state,
    6952              :                                     "Refrigeration Case Return Air Sensible Cooling Rate",
    6953              :                                     Constant::Units::W,
    6954            3 :                                     thisCase.SensHVACCreditCoolRate,
    6955              :                                     OutputProcessor::TimeStepType::Zone,
    6956              :                                     OutputProcessor::StoreType::Average,
    6957            3 :                                     thisCase.Name);
    6958            6 :                 SetupOutputVariable(state,
    6959              :                                     "Refrigeration Case Return Air Sensible Cooling Energy",
    6960              :                                     Constant::Units::J,
    6961            3 :                                     thisCase.SensHVACCreditCool,
    6962              :                                     OutputProcessor::TimeStepType::Zone,
    6963              :                                     OutputProcessor::StoreType::Sum,
    6964            3 :                                     thisCase.Name);
    6965            6 :                 SetupOutputVariable(state,
    6966              :                                     "Refrigeration Case Return Air Sensible Heating Rate",
    6967              :                                     Constant::Units::W,
    6968            3 :                                     thisCase.SensHVACCreditHeatRate,
    6969              :                                     OutputProcessor::TimeStepType::Zone,
    6970              :                                     OutputProcessor::StoreType::Average,
    6971            3 :                                     thisCase.Name);
    6972            6 :                 SetupOutputVariable(state,
    6973              :                                     "Refrigeration Case Return Air Sensible Heating Energy",
    6974              :                                     Constant::Units::J,
    6975            3 :                                     thisCase.SensHVACCreditHeat,
    6976              :                                     OutputProcessor::TimeStepType::Zone,
    6977              :                                     OutputProcessor::StoreType::Sum,
    6978            3 :                                     thisCase.Name);
    6979              : 
    6980            6 :                 SetupOutputVariable(state,
    6981              :                                     "Refrigeration Case Return Air Latent Rate",
    6982              :                                     Constant::Units::W,
    6983            3 :                                     thisCase.LatHVACCreditRate,
    6984              :                                     OutputProcessor::TimeStepType::Zone,
    6985              :                                     OutputProcessor::StoreType::Average,
    6986            3 :                                     thisCase.Name);
    6987            6 :                 SetupOutputVariable(state,
    6988              :                                     "Refrigeration Case Return Air Latent Energy",
    6989              :                                     Constant::Units::J,
    6990            3 :                                     thisCase.LatHVACCredit,
    6991              :                                     OutputProcessor::TimeStepType::Zone,
    6992              :                                     OutputProcessor::StoreType::Sum,
    6993            3 :                                     thisCase.Name);
    6994              : 
    6995            6 :                 SetupOutputVariable(state,
    6996              :                                     "Refrigeration Case Evaporator Fan Electricity Rate",
    6997              :                                     Constant::Units::W,
    6998            3 :                                     thisCase.ElecFanPower,
    6999              :                                     OutputProcessor::TimeStepType::Zone,
    7000              :                                     OutputProcessor::StoreType::Average,
    7001            3 :                                     thisCase.Name);
    7002            6 :                 SetupOutputVariable(state,
    7003              :                                     "Refrigeration Case Evaporator Fan Electricity Energy",
    7004              :                                     Constant::Units::J,
    7005            3 :                                     thisCase.ElecFanConsumption,
    7006              :                                     OutputProcessor::TimeStepType::Zone,
    7007              :                                     OutputProcessor::StoreType::Sum,
    7008            3 :                                     thisCase.Name,
    7009              :                                     Constant::eResource::Electricity,
    7010              :                                     OutputProcessor::Group::Building,
    7011              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7012              :                                     "General",
    7013            3 :                                     thisCase.ZoneName);
    7014            6 :                 SetupOutputVariable(state,
    7015              :                                     "Refrigeration Case Lighting Electricity Rate",
    7016              :                                     Constant::Units::W,
    7017            3 :                                     thisCase.ElecLightingPower,
    7018              :                                     OutputProcessor::TimeStepType::Zone,
    7019              :                                     OutputProcessor::StoreType::Average,
    7020            3 :                                     thisCase.Name);
    7021            6 :                 SetupOutputVariable(state,
    7022              :                                     "Refrigeration Case Lighting Electricity Energy",
    7023              :                                     Constant::Units::J,
    7024            3 :                                     thisCase.ElecLightingConsumption,
    7025              :                                     OutputProcessor::TimeStepType::Zone,
    7026              :                                     OutputProcessor::StoreType::Sum,
    7027            3 :                                     thisCase.Name,
    7028              :                                     Constant::eResource::Electricity,
    7029              :                                     OutputProcessor::Group::Building,
    7030              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7031              :                                     "General",
    7032            3 :                                     thisCase.ZoneName);
    7033              : 
    7034              :                 // Report defrost energy curve value only for cases having electric or hot-gas defrost with temperature termination
    7035            3 :                 if (thisCase.defrostType == RefCaseDefrostType::ElectricTerm || thisCase.defrostType == RefCaseDefrostType::HotFluidTerm) {
    7036            0 :                     SetupOutputVariable(state,
    7037              :                                         "Refrigeration Case Defrost Energy Correction Curve Value",
    7038              :                                         Constant::Units::None,
    7039            0 :                                         thisCase.DefEnergyCurveValue,
    7040              :                                         OutputProcessor::TimeStepType::Zone,
    7041              :                                         OutputProcessor::StoreType::Average,
    7042            0 :                                         thisCase.Name);
    7043              :                 }
    7044              : 
    7045            6 :                 SetupOutputVariable(state,
    7046              :                                     "Refrigeration Case Latent Credit Curve Value",
    7047              :                                     Constant::Units::None,
    7048            3 :                                     thisCase.LatEnergyCurveValue,
    7049              :                                     OutputProcessor::TimeStepType::Zone,
    7050              :                                     OutputProcessor::StoreType::Average,
    7051            3 :                                     thisCase.Name);
    7052              : 
    7053              :                 // Report only for cases having anti-sweat heaters
    7054            3 :                 if (thisCase.AntiSweatControlType > ASHtrCtrlType::None) {
    7055            0 :                     SetupOutputVariable(state,
    7056              :                                         "Refrigeration Case Anti Sweat Electricity Rate",
    7057              :                                         Constant::Units::W,
    7058            0 :                                         thisCase.ElecAntiSweatPower,
    7059              :                                         OutputProcessor::TimeStepType::Zone,
    7060              :                                         OutputProcessor::StoreType::Average,
    7061            0 :                                         thisCase.Name);
    7062            0 :                     SetupOutputVariable(state,
    7063              :                                         "Refrigeration Case Anti Sweat Electricity Energy",
    7064              :                                         Constant::Units::J,
    7065            0 :                                         thisCase.ElecAntiSweatConsumption,
    7066              :                                         OutputProcessor::TimeStepType::Zone,
    7067              :                                         OutputProcessor::StoreType::Sum,
    7068            0 :                                         thisCase.Name,
    7069              :                                         Constant::eResource::Electricity,
    7070              :                                         OutputProcessor::Group::Building,
    7071              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7072              :                                         "General",
    7073            0 :                                         thisCase.ZoneName);
    7074              :                 }
    7075              : 
    7076              :                 // Report only for cases using electric defrost
    7077              : 
    7078            3 :                 if (thisCase.defrostType == RefCaseDefrostType::Electric || thisCase.defrostType == RefCaseDefrostType::ElectricOnDemand ||
    7079            3 :                     thisCase.defrostType == RefCaseDefrostType::ElectricTerm) {
    7080            0 :                     SetupOutputVariable(state,
    7081              :                                         "Refrigeration Case Defrost Electricity Rate",
    7082              :                                         Constant::Units::W,
    7083            0 :                                         thisCase.ElecDefrostPower,
    7084              :                                         OutputProcessor::TimeStepType::Zone,
    7085              :                                         OutputProcessor::StoreType::Average,
    7086            0 :                                         thisCase.Name);
    7087            0 :                     SetupOutputVariable(state,
    7088              :                                         "Refrigeration Case Defrost Electricity Energy",
    7089              :                                         Constant::Units::J,
    7090            0 :                                         thisCase.ElecDefrostConsumption,
    7091              :                                         OutputProcessor::TimeStepType::Zone,
    7092              :                                         OutputProcessor::StoreType::Sum,
    7093            0 :                                         thisCase.Name,
    7094              :                                         Constant::eResource::Electricity,
    7095              :                                         OutputProcessor::Group::Building,
    7096              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7097              :                                         "General",
    7098            0 :                                         thisCase.ZoneName);
    7099              :                 }
    7100              : 
    7101              :                 // register refrigeration case credits as internal gains
    7102            3 :                 if (thisCase.ActualZoneNum > 0) {
    7103            3 :                     SetupZoneInternalGain(state,
    7104              :                                           thisCase.ActualZoneNum,
    7105              :                                           thisCase.Name,
    7106              :                                           DataHeatBalance::IntGainType::RefrigerationCase,
    7107              :                                           &thisCase.SensZoneCreditRate,
    7108              :                                           &thisCase.SensHVACCreditRate,
    7109              :                                           nullptr,
    7110              :                                           &thisCase.LatZoneCreditRate,
    7111              :                                           &thisCase.LatHVACCreditRate,
    7112              :                                           nullptr,
    7113              :                                           nullptr,
    7114              :                                           thisCase.ZoneRANode);
    7115              :                 }
    7116              :             } // END IF (.NOT. RefrigCase(CaseNum)%unusedCase)
    7117              :         }
    7118              :     } // NumSimulationCases > 0
    7119              : 
    7120          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7121              :         // Setup Report Variables for simulated  Walk In (do not report unused WalkIns)
    7122              :         // CurrentModuleObject='Refrigeration:WalkIn'
    7123            6 :         for (int walkInNum = 1; walkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInNum) {
    7124            3 :             auto &walkin = WalkIn(walkInNum);
    7125            3 :             if (walkin.NumSysAttach == 1) { // ensure no unuseds reported
    7126            6 :                 SetupOutputVariable(state,
    7127              :                                     "Refrigeration Walk In Evaporator Total Cooling Rate",
    7128              :                                     Constant::Units::W,
    7129            3 :                                     walkin.TotalCoolingLoad,
    7130              :                                     OutputProcessor::TimeStepType::Zone,
    7131              :                                     OutputProcessor::StoreType::Average,
    7132            3 :                                     walkin.Name);
    7133            6 :                 SetupOutputVariable(state,
    7134              :                                     "Refrigeration Walk In Evaporator Total Cooling Energy",
    7135              :                                     Constant::Units::J,
    7136            3 :                                     walkin.TotalCoolingEnergy,
    7137              :                                     OutputProcessor::TimeStepType::Zone,
    7138              :                                     OutputProcessor::StoreType::Sum,
    7139            3 :                                     walkin.Name);
    7140            6 :                 SetupOutputVariable(state,
    7141              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Rate",
    7142              :                                     Constant::Units::W,
    7143            3 :                                     walkin.TotSensCoolingEnergyRate,
    7144              :                                     OutputProcessor::TimeStepType::Zone,
    7145              :                                     OutputProcessor::StoreType::Average,
    7146            3 :                                     walkin.Name);
    7147            6 :                 SetupOutputVariable(state,
    7148              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Energy",
    7149              :                                     Constant::Units::J,
    7150            3 :                                     walkin.TotSensCoolingEnergy,
    7151              :                                     OutputProcessor::TimeStepType::Zone,
    7152              :                                     OutputProcessor::StoreType::Sum,
    7153            3 :                                     walkin.Name);
    7154            6 :                 SetupOutputVariable(state,
    7155              :                                     "Refrigeration Walk In Evaporator Latent Cooling Rate",
    7156              :                                     Constant::Units::W,
    7157            3 :                                     walkin.TotLatCoolingEnergyRate,
    7158              :                                     OutputProcessor::TimeStepType::Zone,
    7159              :                                     OutputProcessor::StoreType::Average,
    7160            3 :                                     walkin.Name);
    7161            6 :                 SetupOutputVariable(state,
    7162              :                                     "Refrigeration Walk In Evaporator Latent Cooling Energy",
    7163              :                                     Constant::Units::J,
    7164            3 :                                     walkin.TotLatCoolingEnergy,
    7165              :                                     OutputProcessor::TimeStepType::Zone,
    7166              :                                     OutputProcessor::StoreType::Sum,
    7167            3 :                                     walkin.Name);
    7168            6 :                 SetupOutputVariable(state,
    7169              :                                     "Refrigeration Walk In Ancillary Electricity Rate",
    7170              :                                     Constant::Units::W,
    7171            3 :                                     walkin.TotalElecPower,
    7172              :                                     OutputProcessor::TimeStepType::Zone,
    7173              :                                     OutputProcessor::StoreType::Average,
    7174            3 :                                     walkin.Name);
    7175            6 :                 SetupOutputVariable(state,
    7176              :                                     "Refrigeration Walk In Ancillary Electricity Energy",
    7177              :                                     Constant::Units::J,
    7178            3 :                                     walkin.TotalElecConsumption,
    7179              :                                     OutputProcessor::TimeStepType::Zone,
    7180              :                                     OutputProcessor::StoreType::Sum,
    7181            3 :                                     walkin.Name);
    7182            6 :                 SetupOutputVariable(state,
    7183              :                                     "Refrigeration Walk In Fan Electricity Rate",
    7184              :                                     Constant::Units::W,
    7185            3 :                                     walkin.ElecFanPower,
    7186              :                                     OutputProcessor::TimeStepType::Zone,
    7187              :                                     OutputProcessor::StoreType::Average,
    7188            3 :                                     walkin.Name);
    7189            6 :                 SetupOutputVariable(state,
    7190              :                                     "Refrigeration Walk In Fan Electricity Energy",
    7191              :                                     Constant::Units::J,
    7192            3 :                                     walkin.ElecFanConsumption,
    7193              :                                     OutputProcessor::TimeStepType::Zone,
    7194              :                                     OutputProcessor::StoreType::Sum,
    7195            3 :                                     walkin.Name,
    7196              :                                     Constant::eResource::Electricity,
    7197              :                                     OutputProcessor::Group::Building,
    7198              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7199              :                                     "General");
    7200            6 :                 SetupOutputVariable(state,
    7201              :                                     "Refrigeration Walk In Lighting Electricity Rate",
    7202              :                                     Constant::Units::W,
    7203            3 :                                     walkin.ElecLightingPower,
    7204              :                                     OutputProcessor::TimeStepType::Zone,
    7205              :                                     OutputProcessor::StoreType::Average,
    7206            3 :                                     walkin.Name);
    7207            6 :                 SetupOutputVariable(state,
    7208              :                                     "Refrigeration Walk In Lighting Electricity Energy",
    7209              :                                     Constant::Units::J,
    7210            3 :                                     walkin.ElecLightingConsumption,
    7211              :                                     OutputProcessor::TimeStepType::Zone,
    7212              :                                     OutputProcessor::StoreType::Sum,
    7213            3 :                                     walkin.Name,
    7214              :                                     Constant::eResource::Electricity,
    7215              :                                     OutputProcessor::Group::Building,
    7216              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7217              :                                     "General");
    7218            6 :                 SetupOutputVariable(state,
    7219              :                                     "Refrigeration Walk In Heater Electricity Rate",
    7220              :                                     Constant::Units::W,
    7221            3 :                                     walkin.ElecHeaterPower,
    7222              :                                     OutputProcessor::TimeStepType::Zone,
    7223              :                                     OutputProcessor::StoreType::Average,
    7224            3 :                                     walkin.Name);
    7225            6 :                 SetupOutputVariable(state,
    7226              :                                     "Refrigeration Walk In Heater Electricity Energy",
    7227              :                                     Constant::Units::J,
    7228            3 :                                     walkin.ElecHeaterConsumption,
    7229              :                                     OutputProcessor::TimeStepType::Zone,
    7230              :                                     OutputProcessor::StoreType::Sum,
    7231            3 :                                     walkin.Name,
    7232              :                                     Constant::eResource::Electricity,
    7233              :                                     OutputProcessor::Group::Building,
    7234              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7235              :                                     "General");
    7236              : 
    7237              :                 // Report only for WalkIns using electric defrost
    7238            3 :                 if (walkin.defrostType == DefrostType::Elec) {
    7239            6 :                     SetupOutputVariable(state,
    7240              :                                         "Refrigeration Walk In Defrost Electricity Rate",
    7241              :                                         Constant::Units::W,
    7242            3 :                                         walkin.ElecDefrostPower,
    7243              :                                         OutputProcessor::TimeStepType::Zone,
    7244              :                                         OutputProcessor::StoreType::Average,
    7245            3 :                                         walkin.Name);
    7246            6 :                     SetupOutputVariable(state,
    7247              :                                         "Refrigeration Walk In Defrost Electricity Energy",
    7248              :                                         Constant::Units::J,
    7249            3 :                                         walkin.ElecDefrostConsumption,
    7250              :                                         OutputProcessor::TimeStepType::Zone,
    7251              :                                         OutputProcessor::StoreType::Sum,
    7252            3 :                                         walkin.Name,
    7253              :                                         Constant::eResource::Electricity,
    7254              :                                         OutputProcessor::Group::Building,
    7255              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7256              :                                         "General");
    7257              :                 }
    7258              : 
    7259              :                 // Report walkin variables that are specified for each zone exposed to the walkin
    7260              :                 // For "IDOut" variable in SetupOutputVariable, need to create a single name that includes
    7261              :                 //    both the walk-in name and the zone name - see "Walkin_and_zone_name" concatenation
    7262              :                 //    This new variable name is important if using an rvi file!
    7263            6 :                 for (int zoneId = 1; zoneId <= walkin.NumZones; ++zoneId) {
    7264              : 
    7265            3 :                     Walkin_and_zone_name = walkin.Name + "InZone" + walkin.ZoneName(zoneId);
    7266              : 
    7267            6 :                     SetupOutputVariable(state,
    7268              :                                         "Refrigeration Walk In Zone Sensible Cooling Rate",
    7269              :                                         Constant::Units::W,
    7270            3 :                                         walkin.SensZoneCreditCoolRate(zoneId),
    7271              :                                         OutputProcessor::TimeStepType::Zone,
    7272              :                                         OutputProcessor::StoreType::Average,
    7273              :                                         Walkin_and_zone_name);
    7274            6 :                     SetupOutputVariable(state,
    7275              :                                         "Refrigeration Walk In Zone Sensible Cooling Energy",
    7276              :                                         Constant::Units::J,
    7277            3 :                                         walkin.SensZoneCreditCool(zoneId),
    7278              :                                         OutputProcessor::TimeStepType::Zone,
    7279              :                                         OutputProcessor::StoreType::Sum,
    7280              :                                         Walkin_and_zone_name);
    7281            6 :                     SetupOutputVariable(state,
    7282              :                                         "Refrigeration Walk In Zone Sensible Heating Rate",
    7283              :                                         Constant::Units::W,
    7284            3 :                                         walkin.SensZoneCreditHeatRate(zoneId),
    7285              :                                         OutputProcessor::TimeStepType::Zone,
    7286              :                                         OutputProcessor::StoreType::Average,
    7287              :                                         Walkin_and_zone_name);
    7288            6 :                     SetupOutputVariable(state,
    7289              :                                         "Refrigeration Walk In Zone Sensible Heating Energy",
    7290              :                                         Constant::Units::J,
    7291            3 :                                         walkin.SensZoneCreditHeat(zoneId),
    7292              :                                         OutputProcessor::TimeStepType::Zone,
    7293              :                                         OutputProcessor::StoreType::Sum,
    7294              :                                         Walkin_and_zone_name);
    7295            6 :                     SetupOutputVariable(state,
    7296              :                                         "Refrigeration Walk In Zone Latent Rate",
    7297              :                                         Constant::Units::W,
    7298            3 :                                         walkin.LatZoneCreditRate(zoneId),
    7299              :                                         OutputProcessor::TimeStepType::Zone,
    7300              :                                         OutputProcessor::StoreType::Average,
    7301              :                                         Walkin_and_zone_name);
    7302            6 :                     SetupOutputVariable(state,
    7303              :                                         "Refrigeration Walk In Zone Latent Energy",
    7304              :                                         Constant::Units::J,
    7305            3 :                                         walkin.LatZoneCredit(zoneId),
    7306              :                                         OutputProcessor::TimeStepType::Zone,
    7307              :                                         OutputProcessor::StoreType::Sum,
    7308              :                                         Walkin_and_zone_name);
    7309              : 
    7310            3 :                     if (walkin.ZoneNum(zoneId) > 0)
    7311            6 :                         SetupZoneInternalGain(state,
    7312            3 :                                               walkin.ZoneNum(zoneId),
    7313              :                                               Walkin_and_zone_name,
    7314              :                                               DataHeatBalance::IntGainType::RefrigerationWalkIn,
    7315            3 :                                               &walkin.SensZoneCreditRate(zoneId),
    7316              :                                               nullptr,
    7317              :                                               nullptr,
    7318            3 :                                               &walkin.LatZoneCreditRate(zoneId));
    7319              : 
    7320              :                 } // ZoneID
    7321              :             }     //(.NOT.  WalkIn( WalkInNum)%unusedWalkIn)
    7322              :         }         // NumSimulationWalkIns
    7323              :     }             // NumSimulationWalkIns > 0
    7324              : 
    7325          150 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7326              :         // Setup Report Variables for simulated Warehouse coils (do not report unused warehouse coils)
    7327              :         // CurrentModuleObject='Refrigeration:AirChiller'
    7328            0 :         for (int coilNum = 1; coilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilNum) {
    7329            0 :             auto &coil = WarehouseCoil(coilNum);
    7330            0 :             if (coil.NumSysAttach == 1) { // ensure no unuseds reported
    7331            0 :                 SetupOutputVariable(state,
    7332              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    7333              :                                     Constant::Units::W,
    7334            0 :                                     coil.TotalCoolingLoad,
    7335              :                                     OutputProcessor::TimeStepType::System,
    7336              :                                     OutputProcessor::StoreType::Average,
    7337            0 :                                     coil.Name);
    7338            0 :                 SetupOutputVariable(state,
    7339              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    7340              :                                     Constant::Units::J,
    7341            0 :                                     coil.TotalCoolingEnergy,
    7342              :                                     OutputProcessor::TimeStepType::System,
    7343              :                                     OutputProcessor::StoreType::Sum,
    7344            0 :                                     coil.Name);
    7345            0 :                 SetupOutputVariable(state,
    7346              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    7347              :                                     Constant::Units::W,
    7348            0 :                                     coil.SensCoolingEnergyRate,
    7349              :                                     OutputProcessor::TimeStepType::System,
    7350              :                                     OutputProcessor::StoreType::Average,
    7351            0 :                                     coil.Name);
    7352            0 :                 SetupOutputVariable(state,
    7353              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    7354              :                                     Constant::Units::J,
    7355            0 :                                     coil.SensCoolingEnergy,
    7356              :                                     OutputProcessor::TimeStepType::System,
    7357              :                                     OutputProcessor::StoreType::Sum,
    7358            0 :                                     coil.Name);
    7359            0 :                 SetupOutputVariable(state,
    7360              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    7361              :                                     Constant::Units::W,
    7362            0 :                                     coil.LatCreditRate,
    7363              :                                     OutputProcessor::TimeStepType::System,
    7364              :                                     OutputProcessor::StoreType::Average,
    7365            0 :                                     coil.Name);
    7366            0 :                 SetupOutputVariable(state,
    7367              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    7368              :                                     Constant::Units::J,
    7369            0 :                                     coil.LatCreditEnergy,
    7370              :                                     OutputProcessor::TimeStepType::System,
    7371              :                                     OutputProcessor::StoreType::Sum,
    7372            0 :                                     coil.Name);
    7373            0 :                 SetupOutputVariable(state,
    7374              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    7375              :                                     Constant::Units::kg_s,
    7376            0 :                                     coil.LatKgPerS_ToZone,
    7377              :                                     OutputProcessor::TimeStepType::System,
    7378              :                                     OutputProcessor::StoreType::Average,
    7379            0 :                                     coil.Name);
    7380            0 :                 SetupOutputVariable(state,
    7381              :                                     "Refrigeration Zone Air Chiller Total Electricity Rate",
    7382              :                                     Constant::Units::W,
    7383            0 :                                     coil.TotalElecPower,
    7384              :                                     OutputProcessor::TimeStepType::System,
    7385              :                                     OutputProcessor::StoreType::Average,
    7386            0 :                                     coil.Name);
    7387            0 :                 SetupOutputVariable(state,
    7388              :                                     "Refrigeration Zone Air Chiller Total Electricity Energy",
    7389              :                                     Constant::Units::J,
    7390            0 :                                     coil.TotalElecConsumption,
    7391              :                                     OutputProcessor::TimeStepType::System,
    7392              :                                     OutputProcessor::StoreType::Sum,
    7393            0 :                                     coil.Name); // components are metered separately
    7394            0 :                 SetupOutputVariable(state,
    7395              :                                     "Refrigeration Zone Air Chiller Fan Electricity Rate",
    7396              :                                     Constant::Units::W,
    7397            0 :                                     coil.ElecFanPower,
    7398              :                                     OutputProcessor::TimeStepType::System,
    7399              :                                     OutputProcessor::StoreType::Average,
    7400            0 :                                     coil.Name);
    7401            0 :                 SetupOutputVariable(state,
    7402              :                                     "Refrigeration Zone Air Chiller Fan Electric Energy",
    7403              :                                     Constant::Units::J,
    7404            0 :                                     coil.ElecFanConsumption,
    7405              :                                     OutputProcessor::TimeStepType::System,
    7406              :                                     OutputProcessor::StoreType::Sum,
    7407            0 :                                     coil.Name,
    7408              :                                     Constant::eResource::Electricity,
    7409              :                                     OutputProcessor::Group::Building,
    7410              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7411              :                                     "General");
    7412            0 :                 SetupOutputVariable(state,
    7413              :                                     "Refrigeration Zone Air Chiller Heater Electricity Rate",
    7414              :                                     Constant::Units::W,
    7415            0 :                                     coil.ElecHeaterPower,
    7416              :                                     OutputProcessor::TimeStepType::System,
    7417              :                                     OutputProcessor::StoreType::Average,
    7418            0 :                                     coil.Name);
    7419            0 :                 SetupOutputVariable(state,
    7420              :                                     "Refrigeration Zone Air Chiller Heater Electricity Energy",
    7421              :                                     Constant::Units::J,
    7422            0 :                                     coil.ElecHeaterConsumption,
    7423              :                                     OutputProcessor::TimeStepType::System,
    7424              :                                     OutputProcessor::StoreType::Sum,
    7425            0 :                                     coil.Name,
    7426              :                                     Constant::eResource::Electricity,
    7427              :                                     OutputProcessor::Group::Building,
    7428              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7429              :                                     "General");
    7430            0 :                 SetupOutputVariable(state,
    7431              :                                     "Refrigeration Zone Air Chiller Sensible Heat Ratio",
    7432              :                                     Constant::Units::None,
    7433            0 :                                     coil.SensHeatRatio,
    7434              :                                     OutputProcessor::TimeStepType::System,
    7435              :                                     OutputProcessor::StoreType::Average,
    7436            0 :                                     coil.Name);
    7437            0 :                 SetupOutputVariable(state,
    7438              :                                     "Refrigeration Zone Air Chiller Frost Accumulation Mass",
    7439              :                                     Constant::Units::kg,
    7440            0 :                                     coil.KgFrost,
    7441              :                                     OutputProcessor::TimeStepType::System,
    7442              :                                     OutputProcessor::StoreType::Average,
    7443            0 :                                     coil.Name);
    7444            0 :                 SetupOutputVariable(state,
    7445              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Rate",
    7446              :                                     Constant::Units::W,
    7447            0 :                                     coil.ReportTotalCoolCreditRate,
    7448              :                                     OutputProcessor::TimeStepType::System,
    7449              :                                     OutputProcessor::StoreType::Average,
    7450            0 :                                     coil.Name);
    7451            0 :                 SetupOutputVariable(state,
    7452              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Energy",
    7453              :                                     Constant::Units::J,
    7454            0 :                                     coil.ReportTotalCoolCreditEnergy,
    7455              :                                     OutputProcessor::TimeStepType::System,
    7456              :                                     OutputProcessor::StoreType::Sum,
    7457            0 :                                     coil.Name);
    7458            0 :                 SetupOutputVariable(state,
    7459              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Rate",
    7460              :                                     Constant::Units::W,
    7461            0 :                                     coil.ReportSensCoolCreditRate,
    7462              :                                     OutputProcessor::TimeStepType::System,
    7463              :                                     OutputProcessor::StoreType::Average,
    7464            0 :                                     coil.Name);
    7465            0 :                 SetupOutputVariable(state,
    7466              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Energy",
    7467              :                                     Constant::Units::J,
    7468            0 :                                     coil.ReportSensCoolCreditEnergy,
    7469              :                                     OutputProcessor::TimeStepType::System,
    7470              :                                     OutputProcessor::StoreType::Sum,
    7471            0 :                                     coil.Name);
    7472            0 :                 SetupOutputVariable(state,
    7473              :                                     "Refrigeration Zone Air Chiller Zone Heating Rate",
    7474              :                                     Constant::Units::W,
    7475            0 :                                     coil.ReportHeatingCreditRate,
    7476              :                                     OutputProcessor::TimeStepType::System,
    7477              :                                     OutputProcessor::StoreType::Average,
    7478            0 :                                     coil.Name);
    7479            0 :                 SetupOutputVariable(state,
    7480              :                                     "Refrigeration Zone Air Chiller Zone Heating Energy",
    7481              :                                     Constant::Units::J,
    7482            0 :                                     coil.ReportHeatingCreditEnergy,
    7483              :                                     OutputProcessor::TimeStepType::System,
    7484              :                                     OutputProcessor::StoreType::Sum,
    7485            0 :                                     coil.Name);
    7486              : 
    7487              :                 // Report only for Warehouse coils using electric defrost
    7488            0 :                 if (coil.defrostType == DefrostType::Elec) {
    7489            0 :                     SetupOutputVariable(state,
    7490              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Rate",
    7491              :                                         Constant::Units::W,
    7492            0 :                                         coil.ElecDefrostPower,
    7493              :                                         OutputProcessor::TimeStepType::System,
    7494              :                                         OutputProcessor::StoreType::Average,
    7495            0 :                                         coil.Name);
    7496            0 :                     SetupOutputVariable(state,
    7497              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Energy",
    7498              :                                         Constant::Units::J,
    7499            0 :                                         coil.ElecDefrostConsumption,
    7500              :                                         OutputProcessor::TimeStepType::System,
    7501              :                                         OutputProcessor::StoreType::Sum,
    7502            0 :                                         coil.Name,
    7503              :                                         Constant::eResource::Electricity,
    7504              :                                         OutputProcessor::Group::Building,
    7505              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7506              :                                         "General");
    7507              :                 } // electric defrost coil
    7508              :             }     //(.NOT.  coil%unusedWarehouseCoil)
    7509              :         }         // NumSimulationWarehouseCoils
    7510              :     }             // NumSimulationRefrigAirChillers > 0
    7511              : 
    7512              :     // There are no report variables for Chiller sets because they are
    7513              :     // used to pass the demand to the coils, but are NOT used to provide the
    7514              :     // cooling energy to the zone (because more than one set may cool a zone)
    7515              : 
    7516              :     // Report sum of all refrigeration interactions with each zone
    7517              : 
    7518          302 :     for (int zoneID = 1; zoneID <= state.dataGlobal->NumOfZones; ++zoneID) {
    7519          152 :         if (state.dataRefrigCase->RefrigPresentInZone(zoneID)) {
    7520            5 :             if (state.dataRefrigCase->HaveCasesOrWalkins) {
    7521           10 :                 SetupOutputVariable(state,
    7522              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Rate",
    7523              :                                     Constant::Units::W,
    7524            5 :                                     state.dataHeatBal->RefrigCaseCredit(zoneID).SenCaseCreditToZone,
    7525              :                                     OutputProcessor::TimeStepType::Zone,
    7526              :                                     OutputProcessor::StoreType::Average,
    7527            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7528           10 :                 SetupOutputVariable(state,
    7529              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Energy",
    7530              :                                     Constant::Units::J,
    7531            5 :                                     CaseWIZoneReport(zoneID).SenCaseCreditToZoneEnergy,
    7532              :                                     OutputProcessor::TimeStepType::Zone,
    7533              :                                     OutputProcessor::StoreType::Sum,
    7534            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7535           10 :                 SetupOutputVariable(state,
    7536              :                                     "Refrigeration Zone Case and Walk In Heating Rate",
    7537              :                                     Constant::Units::W,
    7538            5 :                                     CaseWIZoneReport(zoneID).HeatingToZoneRate,
    7539              :                                     OutputProcessor::TimeStepType::Zone,
    7540              :                                     OutputProcessor::StoreType::Average,
    7541            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7542           10 :                 SetupOutputVariable(state,
    7543              :                                     "Refrigeration Zone Case and Walk In Heating Energy",
    7544              :                                     Constant::Units::J,
    7545            5 :                                     CaseWIZoneReport(zoneID).HeatingToZoneEnergy,
    7546              :                                     OutputProcessor::TimeStepType::Zone,
    7547              :                                     OutputProcessor::StoreType::Sum,
    7548            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7549           10 :                 SetupOutputVariable(state,
    7550              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Rate",
    7551              :                                     Constant::Units::W,
    7552            5 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneRate,
    7553              :                                     OutputProcessor::TimeStepType::Zone,
    7554              :                                     OutputProcessor::StoreType::Average,
    7555            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7556           10 :                 SetupOutputVariable(state,
    7557              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Energy",
    7558              :                                     Constant::Units::J,
    7559            5 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneEnergy,
    7560              :                                     OutputProcessor::TimeStepType::Zone,
    7561              :                                     OutputProcessor::StoreType::Sum,
    7562            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7563           10 :                 SetupOutputVariable(state,
    7564              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Rate",
    7565              :                                     Constant::Units::W,
    7566            5 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneRate,
    7567              :                                     OutputProcessor::TimeStepType::Zone,
    7568              :                                     OutputProcessor::StoreType::Average,
    7569            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7570           10 :                 SetupOutputVariable(state,
    7571              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Energy",
    7572              :                                     Constant::Units::J,
    7573            5 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneEnergy,
    7574              :                                     OutputProcessor::TimeStepType::Zone,
    7575              :                                     OutputProcessor::StoreType::Sum,
    7576            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7577           10 :                 SetupOutputVariable(state,
    7578              :                                     "Refrigeration Zone Case and Walk In Total Cooling Rate",
    7579              :                                     Constant::Units::W,
    7580            5 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneRate,
    7581              :                                     OutputProcessor::TimeStepType::Zone,
    7582              :                                     OutputProcessor::StoreType::Average,
    7583            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7584           10 :                 SetupOutputVariable(state,
    7585              :                                     "Refrigeration Zone Case and Walk In Total Cooling Energy",
    7586              :                                     Constant::Units::J,
    7587            5 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneEnergy,
    7588              :                                     OutputProcessor::TimeStepType::Zone,
    7589              :                                     OutputProcessor::StoreType::Sum,
    7590            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7591           10 :                 SetupOutputVariable(state,
    7592              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Rate",
    7593              :                                     Constant::Units::W,
    7594            5 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneRate,
    7595              :                                     OutputProcessor::TimeStepType::Zone,
    7596              :                                     OutputProcessor::StoreType::Average,
    7597            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7598           10 :                 SetupOutputVariable(state,
    7599              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Energy",
    7600              :                                     Constant::Units::J,
    7601            5 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneEnergy,
    7602              :                                     OutputProcessor::TimeStepType::Zone,
    7603              :                                     OutputProcessor::StoreType::Sum,
    7604            5 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7605              :             } // HaveCasesOrWalkIns
    7606              : 
    7607            5 :             if (state.dataRefrigCase->HaveChillers) {
    7608            0 :                 SetupOutputVariable(state,
    7609              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Rate",
    7610              :                                     Constant::Units::W,
    7611            0 :                                     CoilSysCredit(zoneID).SenCreditToZoneRate,
    7612              :                                     OutputProcessor::TimeStepType::System,
    7613              :                                     OutputProcessor::StoreType::Average,
    7614            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7615            0 :                 SetupOutputVariable(state,
    7616              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Energy",
    7617              :                                     Constant::Units::J,
    7618            0 :                                     CoilSysCredit(zoneID).SenCreditToZoneEnergy,
    7619              :                                     OutputProcessor::TimeStepType::System,
    7620              :                                     OutputProcessor::StoreType::Sum,
    7621            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7622            0 :                 SetupOutputVariable(state,
    7623              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    7624              :                                     Constant::Units::W,
    7625            0 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneRate,
    7626              :                                     OutputProcessor::TimeStepType::System,
    7627              :                                     OutputProcessor::StoreType::Average,
    7628            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7629            0 :                 SetupOutputVariable(state,
    7630              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    7631              :                                     Constant::Units::J,
    7632            0 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneEnergy,
    7633              :                                     OutputProcessor::TimeStepType::System,
    7634              :                                     OutputProcessor::StoreType::Sum,
    7635            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7636            0 :                 SetupOutputVariable(state,
    7637              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    7638              :                                     Constant::Units::W,
    7639            0 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneRate,
    7640              :                                     OutputProcessor::TimeStepType::System,
    7641              :                                     OutputProcessor::StoreType::Average,
    7642            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7643            0 :                 SetupOutputVariable(state,
    7644              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    7645              :                                     Constant::Units::J,
    7646            0 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneEnergy,
    7647              :                                     OutputProcessor::TimeStepType::System,
    7648              :                                     OutputProcessor::StoreType::Sum,
    7649            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7650            0 :                 SetupOutputVariable(state,
    7651              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    7652              :                                     Constant::Units::kg_s,
    7653            0 :                                     CoilSysCredit(zoneID).ReportH2ORemovedKgPerS_FromZoneRate,
    7654              :                                     OutputProcessor::TimeStepType::System,
    7655              :                                     OutputProcessor::StoreType::Average,
    7656            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7657            0 :                 SetupOutputVariable(state,
    7658              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    7659              :                                     Constant::Units::W,
    7660            0 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneRate,
    7661              :                                     OutputProcessor::TimeStepType::System,
    7662              :                                     OutputProcessor::StoreType::Average,
    7663            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7664            0 :                 SetupOutputVariable(state,
    7665              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    7666              :                                     Constant::Units::J,
    7667            0 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneEnergy,
    7668              :                                     OutputProcessor::TimeStepType::System,
    7669              :                                     OutputProcessor::StoreType::Sum,
    7670            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7671            0 :                 SetupOutputVariable(state,
    7672              :                                     "Refrigeration Zone Air Chiller Heating Rate",
    7673              :                                     Constant::Units::W,
    7674            0 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneRate,
    7675              :                                     OutputProcessor::TimeStepType::System,
    7676              :                                     OutputProcessor::StoreType::Average,
    7677            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7678            0 :                 SetupOutputVariable(state,
    7679              :                                     "Refrigeration Zone Air Chiller Heating Energy",
    7680              :                                     Constant::Units::J,
    7681            0 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneEnergy,
    7682              :                                     OutputProcessor::TimeStepType::System,
    7683              :                                     OutputProcessor::StoreType::Sum,
    7684            0 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7685              :             } // HaveChillers
    7686              :         }     // RefrigPresentInZone(ZoneID)
    7687              :     }         // ZoneID
    7688              : 
    7689          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    7690              :         // CurrentModuleObject='Refrigeration:SecondarySystem'
    7691            0 :         for (int secondNum = 1; secondNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondNum) {
    7692            0 :             auto &secondary = Secondary(secondNum);
    7693            0 :             if (secondary.NumSysAttach == 1) {
    7694            0 :                 if (secondary.CoilFlag) { // secondary system serves chillers and is solved on HVAC time step
    7695            0 :                     SetupOutputVariable(state,
    7696              :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Rate",
    7697              :                                         Constant::Units::W,
    7698            0 :                                         secondary.PumpPowerTotal,
    7699              :                                         OutputProcessor::TimeStepType::System,
    7700              :                                         OutputProcessor::StoreType::Average,
    7701            0 :                                         secondary.Name);
    7702            0 :                     SetupOutputVariable(state,
    7703              :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Energy",
    7704              :                                         Constant::Units::J,
    7705            0 :                                         secondary.PumpElecEnergyTotal,
    7706              :                                         OutputProcessor::TimeStepType::System,
    7707              :                                         OutputProcessor::StoreType::Sum,
    7708            0 :                                         secondary.Name,
    7709              :                                         Constant::eResource::Electricity,
    7710              :                                         OutputProcessor::Group::Plant,
    7711              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7712              :                                         secondary.EndUseSubcategory);
    7713            0 :                     SetupOutputVariable(state,
    7714              :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Rate",
    7715              :                                         Constant::Units::W,
    7716            0 :                                         secondary.TotalRefrigLoad,
    7717              :                                         OutputProcessor::TimeStepType::System,
    7718              :                                         OutputProcessor::StoreType::Average,
    7719            0 :                                         secondary.Name);
    7720            0 :                     SetupOutputVariable(state,
    7721              :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Energy",
    7722              :                                         Constant::Units::J,
    7723            0 :                                         secondary.TotalRefrigEnergy,
    7724              :                                         OutputProcessor::TimeStepType::System,
    7725              :                                         OutputProcessor::StoreType::Sum,
    7726            0 :                                         secondary.Name);
    7727            0 :                     SetupOutputVariable(state,
    7728              :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Rate",
    7729              :                                         Constant::Units::W,
    7730            0 :                                         secondary.TotalCoolingLoad,
    7731              :                                         OutputProcessor::TimeStepType::System,
    7732              :                                         OutputProcessor::StoreType::Average,
    7733            0 :                                         secondary.Name);
    7734            0 :                     SetupOutputVariable(state,
    7735              :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Energy",
    7736              :                                         Constant::Units::J,
    7737            0 :                                         secondary.TotalCoolingEnergy,
    7738              :                                         OutputProcessor::TimeStepType::System,
    7739              :                                         OutputProcessor::StoreType::Sum,
    7740            0 :                                         secondary.Name);
    7741            0 :                     SetupOutputVariable(state,
    7742              :                                         "Refrigeration Air Chiller Secondary Loop Estimated Refrigerant Inventory Mass",
    7743              :                                         Constant::Units::kg,
    7744            0 :                                         secondary.RefInventory,
    7745              :                                         OutputProcessor::TimeStepType::System,
    7746              :                                         OutputProcessor::StoreType::Average,
    7747            0 :                                         secondary.Name);
    7748            0 :                     SetupOutputVariable(state,
    7749              :                                         "Refrigeration Air Chiller Secondary Loop Volume Flow Rate",
    7750              :                                         Constant::Units::m3_s,
    7751            0 :                                         secondary.FlowVolActual,
    7752              :                                         OutputProcessor::TimeStepType::System,
    7753              :                                         OutputProcessor::StoreType::Average,
    7754            0 :                                         secondary.Name);
    7755            0 :                     SetupOutputVariable(state,
    7756              :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Rate",
    7757              :                                         Constant::Units::W,
    7758            0 :                                         secondary.DistPipeHeatGain,
    7759              :                                         OutputProcessor::TimeStepType::System,
    7760              :                                         OutputProcessor::StoreType::Average,
    7761            0 :                                         secondary.Name);
    7762            0 :                     SetupOutputVariable(state,
    7763              :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Energy",
    7764              :                                         Constant::Units::J,
    7765            0 :                                         secondary.DistPipeHeatGainEnergy,
    7766              :                                         OutputProcessor::TimeStepType::System,
    7767              :                                         OutputProcessor::StoreType::Sum,
    7768            0 :                                         secondary.Name);
    7769            0 :                     SetupOutputVariable(state,
    7770              :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Rate",
    7771              :                                         Constant::Units::W,
    7772            0 :                                         secondary.ReceiverHeatGain,
    7773              :                                         OutputProcessor::TimeStepType::System,
    7774              :                                         OutputProcessor::StoreType::Average,
    7775            0 :                                         secondary.Name);
    7776            0 :                     SetupOutputVariable(state,
    7777              :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Energy",
    7778              :                                         Constant::Units::J,
    7779            0 :                                         secondary.ReceiverHeatGainEnergy,
    7780              :                                         OutputProcessor::TimeStepType::System,
    7781              :                                         OutputProcessor::StoreType::Sum,
    7782            0 :                                         secondary.Name);
    7783              :                 } else { // Secondary loop serves cases and walk-ins on zone(load) time step
    7784            0 :                     SetupOutputVariable(state,
    7785              :                                         "Refrigeration Secondary Loop Pump Electricity Rate",
    7786              :                                         Constant::Units::W,
    7787            0 :                                         secondary.PumpPowerTotal,
    7788              :                                         OutputProcessor::TimeStepType::Zone,
    7789              :                                         OutputProcessor::StoreType::Average,
    7790            0 :                                         secondary.Name);
    7791            0 :                     SetupOutputVariable(state,
    7792              :                                         "Refrigeration Secondary Loop Pump Electricity Energy",
    7793              :                                         Constant::Units::J,
    7794            0 :                                         secondary.PumpElecEnergyTotal,
    7795              :                                         OutputProcessor::TimeStepType::Zone,
    7796              :                                         OutputProcessor::StoreType::Sum,
    7797            0 :                                         secondary.Name,
    7798              :                                         Constant::eResource::Electricity,
    7799              :                                         OutputProcessor::Group::Plant,
    7800              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7801              :                                         secondary.EndUseSubcategory);
    7802            0 :                     SetupOutputVariable(state,
    7803              :                                         "Refrigeration Secondary Loop Load Heat Transfer Rate",
    7804              :                                         Constant::Units::W,
    7805            0 :                                         secondary.TotalRefrigLoad,
    7806              :                                         OutputProcessor::TimeStepType::Zone,
    7807              :                                         OutputProcessor::StoreType::Average,
    7808            0 :                                         secondary.Name);
    7809            0 :                     SetupOutputVariable(state,
    7810              :                                         "Refrigeration Secondary Loop Load Heat Transfer Energy",
    7811              :                                         Constant::Units::J,
    7812            0 :                                         secondary.TotalRefrigEnergy,
    7813              :                                         OutputProcessor::TimeStepType::Zone,
    7814              :                                         OutputProcessor::StoreType::Sum,
    7815            0 :                                         secondary.Name);
    7816            0 :                     SetupOutputVariable(state,
    7817              :                                         "Refrigeration Secondary Loop Total Heat Transfer Rate",
    7818              :                                         Constant::Units::W,
    7819            0 :                                         secondary.TotalCoolingLoad,
    7820              :                                         OutputProcessor::TimeStepType::Zone,
    7821              :                                         OutputProcessor::StoreType::Average,
    7822            0 :                                         secondary.Name);
    7823            0 :                     SetupOutputVariable(state,
    7824              :                                         "Refrigeration Secondary Loop Total Heat Transfer Energy",
    7825              :                                         Constant::Units::J,
    7826            0 :                                         secondary.TotalCoolingEnergy,
    7827              :                                         OutputProcessor::TimeStepType::Zone,
    7828              :                                         OutputProcessor::StoreType::Sum,
    7829            0 :                                         secondary.Name);
    7830            0 :                     SetupOutputVariable(state,
    7831              :                                         "Refrigeration Secondary Loop Estimated Refrigerant Inventory Mass",
    7832              :                                         Constant::Units::kg,
    7833            0 :                                         secondary.RefInventory,
    7834              :                                         OutputProcessor::TimeStepType::Zone,
    7835              :                                         OutputProcessor::StoreType::Average,
    7836            0 :                                         secondary.Name);
    7837            0 :                     SetupOutputVariable(state,
    7838              :                                         "Refrigeration Secondary Loop Volume Flow Rate",
    7839              :                                         Constant::Units::m3_s,
    7840            0 :                                         secondary.FlowVolActual,
    7841              :                                         OutputProcessor::TimeStepType::Zone,
    7842              :                                         OutputProcessor::StoreType::Average,
    7843            0 :                                         secondary.Name);
    7844            0 :                     SetupOutputVariable(state,
    7845              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Rate",
    7846              :                                         Constant::Units::W,
    7847            0 :                                         secondary.DistPipeHeatGain,
    7848              :                                         OutputProcessor::TimeStepType::Zone,
    7849              :                                         OutputProcessor::StoreType::Average,
    7850            0 :                                         secondary.Name);
    7851            0 :                     SetupOutputVariable(state,
    7852              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Energy",
    7853              :                                         Constant::Units::J,
    7854            0 :                                         secondary.DistPipeHeatGainEnergy,
    7855              :                                         OutputProcessor::TimeStepType::Zone,
    7856              :                                         OutputProcessor::StoreType::Sum,
    7857            0 :                                         secondary.Name);
    7858            0 :                     SetupOutputVariable(state,
    7859              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Rate",
    7860              :                                         Constant::Units::W,
    7861            0 :                                         secondary.ReceiverHeatGain,
    7862              :                                         OutputProcessor::TimeStepType::Zone,
    7863              :                                         OutputProcessor::StoreType::Average,
    7864            0 :                                         secondary.Name);
    7865            0 :                     SetupOutputVariable(state,
    7866              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Energy",
    7867              :                                         Constant::Units::J,
    7868            0 :                                         secondary.ReceiverHeatGainEnergy,
    7869              :                                         OutputProcessor::TimeStepType::Zone,
    7870              :                                         OutputProcessor::StoreType::Sum,
    7871            0 :                                         secondary.Name);
    7872              :                 } // NOT coilflag so on Zone timestep
    7873            0 :                 if (secondary.ReceiverZoneNum > 0) {
    7874            0 :                     SetupZoneInternalGain(state,
    7875              :                                           secondary.ReceiverZoneNum,
    7876              :                                           secondary.Name,
    7877              :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryReceiver,
    7878              :                                           &secondary.ReceiverZoneHeatGain);
    7879              :                 }
    7880            0 :                 if (secondary.DistPipeZoneNum > 0) {
    7881            0 :                     SetupZoneInternalGain(state,
    7882              :                                           secondary.DistPipeZoneNum,
    7883              :                                           secondary.Name,
    7884              :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryPipe,
    7885              :                                           &secondary.DistPipeZoneHeatGain);
    7886              :                 }
    7887              :             } // not an unused
    7888              :         }     // NumSimulationSecondarySystems
    7889              :     }         // NumSimulationSecondarySystems > 0
    7890              : 
    7891              :     // Setup Report Variables for Refrigeration Compressor Rack
    7892          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    7893              :         // CurrentModuleObject='Refrigeration:CompressorRack'
    7894           10 :         for (int rackNum = 1; rackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++rackNum) {
    7895            5 :             auto &rack = RefrigRack(rackNum);
    7896            5 :             if (rack.CoilFlag) { // rack serves chillers and is solved on HVAC time step
    7897            0 :                 SetupOutputVariable(state,
    7898              :                                     "Refrigeration Air Chiller Compressor Rack Electricity Rate",
    7899              :                                     Constant::Units::W,
    7900            0 :                                     rack.RackCompressorPower,
    7901              :                                     OutputProcessor::TimeStepType::System,
    7902              :                                     OutputProcessor::StoreType::Average,
    7903            0 :                                     rack.Name);
    7904            0 :                 SetupOutputVariable(state,
    7905              :                                     "Refrigeration Air Chiller Compressor Rack Electricity Energy",
    7906              :                                     Constant::Units::J,
    7907            0 :                                     rack.RackElecConsumption,
    7908              :                                     OutputProcessor::TimeStepType::System,
    7909              :                                     OutputProcessor::StoreType::Sum,
    7910            0 :                                     rack.Name,
    7911              :                                     Constant::eResource::Electricity,
    7912              :                                     OutputProcessor::Group::Plant,
    7913              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7914              :                                     rack.EndUseSubcategory);
    7915            0 :                 SetupOutputVariable(state,
    7916              :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Rate",
    7917              :                                     Constant::Units::W,
    7918            0 :                                     rack.ActualCondenserFanPower,
    7919              :                                     OutputProcessor::TimeStepType::System,
    7920              :                                     OutputProcessor::StoreType::Average,
    7921            0 :                                     rack.Name);
    7922            0 :                 SetupOutputVariable(state,
    7923              :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Energy",
    7924              :                                     Constant::Units::J,
    7925            0 :                                     rack.CondenserFanConsumption,
    7926              :                                     OutputProcessor::TimeStepType::System,
    7927              :                                     OutputProcessor::StoreType::Sum,
    7928            0 :                                     rack.Name,
    7929              :                                     Constant::eResource::Electricity,
    7930              :                                     OutputProcessor::Group::Plant,
    7931              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7932              :                                     rack.EndUseSubcategory);
    7933            0 :                 SetupOutputVariable(state,
    7934              :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Rate",
    7935              :                                     Constant::Units::W,
    7936            0 :                                     rack.RackCapacity,
    7937              :                                     OutputProcessor::TimeStepType::System,
    7938              :                                     OutputProcessor::StoreType::Average,
    7939            0 :                                     rack.Name);
    7940            0 :                 SetupOutputVariable(state,
    7941              :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Energy",
    7942              :                                     Constant::Units::J,
    7943            0 :                                     rack.RackCoolingEnergy,
    7944              :                                     OutputProcessor::TimeStepType::System,
    7945              :                                     OutputProcessor::StoreType::Sum,
    7946            0 :                                     rack.Name,
    7947              :                                     Constant::eResource::EnergyTransfer,
    7948              :                                     OutputProcessor::Group::Plant,
    7949              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7950              :                                     rack.EndUseSubcategory);
    7951            0 :                 SetupOutputVariable(state,
    7952              :                                     "Refrigeration Air Chiller Compressor Rack COP",
    7953              :                                     Constant::Units::W_W,
    7954            0 :                                     rack.RackCompressorCOP,
    7955              :                                     OutputProcessor::TimeStepType::System,
    7956              :                                     OutputProcessor::StoreType::Average,
    7957            0 :                                     rack.Name);
    7958              : 
    7959            0 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    7960            0 :                     SetupOutputVariable(state,
    7961              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Rate",
    7962              :                                         Constant::Units::W,
    7963            0 :                                         rack.ActualEvapPumpPower,
    7964              :                                         OutputProcessor::TimeStepType::System,
    7965              :                                         OutputProcessor::StoreType::Average,
    7966            0 :                                         rack.Name);
    7967            0 :                     SetupOutputVariable(state,
    7968              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Energy",
    7969              :                                         Constant::Units::J,
    7970            0 :                                         rack.EvapPumpConsumption,
    7971              :                                         OutputProcessor::TimeStepType::System,
    7972              :                                         OutputProcessor::StoreType::Sum,
    7973            0 :                                         rack.Name,
    7974              :                                         Constant::eResource::Electricity,
    7975              :                                         OutputProcessor::Group::Plant,
    7976              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7977              :                                         rack.EndUseSubcategory);
    7978            0 :                     SetupOutputVariable(state,
    7979              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    7980              :                                         Constant::Units::W,
    7981            0 :                                         rack.BasinHeaterPower,
    7982              :                                         OutputProcessor::TimeStepType::System,
    7983              :                                         OutputProcessor::StoreType::Average,
    7984            0 :                                         rack.Name);
    7985            0 :                     SetupOutputVariable(state,
    7986              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    7987              :                                         Constant::Units::J,
    7988            0 :                                         rack.BasinHeaterConsumption,
    7989              :                                         OutputProcessor::TimeStepType::System,
    7990              :                                         OutputProcessor::StoreType::Sum,
    7991            0 :                                         rack.Name,
    7992              :                                         Constant::eResource::Electricity,
    7993              :                                         OutputProcessor::Group::Plant,
    7994              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7995              :                                         rack.EndUseSubcategory);
    7996            0 :                     SetupOutputVariable(state,
    7997              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    7998              :                                         Constant::Units::m3_s,
    7999            0 :                                         rack.EvapWaterConsumpRate,
    8000              :                                         OutputProcessor::TimeStepType::System,
    8001              :                                         OutputProcessor::StoreType::Average,
    8002            0 :                                         rack.Name);
    8003            0 :                     SetupOutputVariable(state,
    8004              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume",
    8005              :                                         Constant::Units::m3,
    8006            0 :                                         rack.EvapWaterConsumption,
    8007              :                                         OutputProcessor::TimeStepType::System,
    8008              :                                         OutputProcessor::StoreType::Sum,
    8009            0 :                                         rack.Name,
    8010              :                                         Constant::eResource::Water,
    8011              :                                         OutputProcessor::Group::Plant,
    8012              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8013              :                                         rack.EndUseSubcategory);
    8014              :                 } // Evap condenser
    8015              : 
    8016            0 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8017            0 :                     SetupOutputVariable(state,
    8018              :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Rate",
    8019              :                                         Constant::Units::W,
    8020            0 :                                         rack.SensZoneCreditHeatRate,
    8021              :                                         OutputProcessor::TimeStepType::System,
    8022              :                                         OutputProcessor::StoreType::Average,
    8023            0 :                                         rack.Name);
    8024            0 :                     SetupOutputVariable(state,
    8025              :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Energy",
    8026              :                                         Constant::Units::J,
    8027            0 :                                         rack.SensZoneCreditHeat,
    8028              :                                         OutputProcessor::TimeStepType::System,
    8029              :                                         OutputProcessor::StoreType::Sum,
    8030            0 :                                         rack.Name);
    8031              : 
    8032            0 :                     SetupOutputVariable(state,
    8033              :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Rate",
    8034              :                                         Constant::Units::W,
    8035            0 :                                         rack.SensHVACCreditHeatRate,
    8036              :                                         OutputProcessor::TimeStepType::System,
    8037              :                                         OutputProcessor::StoreType::Average,
    8038            0 :                                         rack.Name);
    8039            0 :                     SetupOutputVariable(state,
    8040              :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Energy",
    8041              :                                         Constant::Units::J,
    8042            0 :                                         rack.SensHVACCreditHeat,
    8043              :                                         OutputProcessor::TimeStepType::System,
    8044              :                                         OutputProcessor::StoreType::Sum,
    8045            0 :                                         rack.Name);
    8046              : 
    8047              :                     // If CoilFlag is true and Location is Zone, GetRefrigerationInput ensures you must have a Heat Rejection Zone provided already
    8048            0 :                     SetupZoneInternalGain(state,
    8049              :                                           rack.HeatRejectionZoneNum,
    8050              :                                           rack.Name,
    8051              :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8052              :                                           &rack.SensZoneCreditHeatRate,
    8053              :                                           &rack.SensHVACCreditHeatRate);
    8054              : 
    8055              :                 } // LocationZone
    8056              : 
    8057              :             } else { // Rack serves cases and walkins on zone (load) time step
    8058              : 
    8059           10 :                 SetupOutputVariable(state,
    8060              :                                     "Refrigeration Compressor Rack Electricity Rate",
    8061              :                                     Constant::Units::W,
    8062            5 :                                     rack.RackCompressorPower,
    8063              :                                     OutputProcessor::TimeStepType::Zone,
    8064              :                                     OutputProcessor::StoreType::Average,
    8065            5 :                                     rack.Name);
    8066           10 :                 SetupOutputVariable(state,
    8067              :                                     "Refrigeration Compressor Rack Electricity Energy",
    8068              :                                     Constant::Units::J,
    8069            5 :                                     rack.RackElecConsumption,
    8070              :                                     OutputProcessor::TimeStepType::Zone,
    8071              :                                     OutputProcessor::StoreType::Sum,
    8072            5 :                                     rack.Name,
    8073              :                                     Constant::eResource::Electricity,
    8074              :                                     OutputProcessor::Group::Plant,
    8075              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8076              :                                     rack.EndUseSubcategory);
    8077           10 :                 SetupOutputVariable(state,
    8078              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Rate",
    8079              :                                     Constant::Units::W,
    8080            5 :                                     rack.ActualCondenserFanPower,
    8081              :                                     OutputProcessor::TimeStepType::Zone,
    8082              :                                     OutputProcessor::StoreType::Average,
    8083            5 :                                     rack.Name);
    8084           10 :                 SetupOutputVariable(state,
    8085              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Energy",
    8086              :                                     Constant::Units::J,
    8087            5 :                                     rack.CondenserFanConsumption,
    8088              :                                     OutputProcessor::TimeStepType::Zone,
    8089              :                                     OutputProcessor::StoreType::Sum,
    8090            5 :                                     rack.Name,
    8091              :                                     Constant::eResource::Electricity,
    8092              :                                     OutputProcessor::Group::Plant,
    8093              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8094              :                                     rack.EndUseSubcategory);
    8095           10 :                 SetupOutputVariable(state,
    8096              :                                     "Refrigeration Compressor Rack Total Heat Transfer Rate",
    8097              :                                     Constant::Units::W,
    8098            5 :                                     rack.RackCapacity,
    8099              :                                     OutputProcessor::TimeStepType::Zone,
    8100              :                                     OutputProcessor::StoreType::Average,
    8101            5 :                                     rack.Name);
    8102           10 :                 SetupOutputVariable(state,
    8103              :                                     "Refrigeration Compressor Rack Total Heat Transfer Energy",
    8104              :                                     Constant::Units::J,
    8105            5 :                                     rack.RackCoolingEnergy,
    8106              :                                     OutputProcessor::TimeStepType::Zone,
    8107              :                                     OutputProcessor::StoreType::Sum,
    8108            5 :                                     rack.Name,
    8109              :                                     Constant::eResource::EnergyTransfer,
    8110              :                                     OutputProcessor::Group::Plant,
    8111              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8112              :                                     rack.EndUseSubcategory);
    8113           10 :                 SetupOutputVariable(state,
    8114              :                                     "Refrigeration Compressor Rack COP",
    8115              :                                     Constant::Units::W_W,
    8116            5 :                                     rack.RackCompressorCOP,
    8117              :                                     OutputProcessor::TimeStepType::Zone,
    8118              :                                     OutputProcessor::StoreType::Average,
    8119            5 :                                     rack.Name);
    8120              : 
    8121            5 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8122            0 :                     SetupOutputVariable(state,
    8123              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8124              :                                         Constant::Units::W,
    8125            0 :                                         rack.ActualEvapPumpPower,
    8126              :                                         OutputProcessor::TimeStepType::Zone,
    8127              :                                         OutputProcessor::StoreType::Average,
    8128            0 :                                         rack.Name);
    8129            0 :                     SetupOutputVariable(state,
    8130              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8131              :                                         Constant::Units::J,
    8132            0 :                                         rack.EvapPumpConsumption,
    8133              :                                         OutputProcessor::TimeStepType::Zone,
    8134              :                                         OutputProcessor::StoreType::Sum,
    8135            0 :                                         rack.Name,
    8136              :                                         Constant::eResource::Electricity,
    8137              :                                         OutputProcessor::Group::Plant,
    8138              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8139              :                                         rack.EndUseSubcategory);
    8140            0 :                     SetupOutputVariable(state,
    8141              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8142              :                                         Constant::Units::W,
    8143            0 :                                         rack.BasinHeaterPower,
    8144              :                                         OutputProcessor::TimeStepType::Zone,
    8145              :                                         OutputProcessor::StoreType::Average,
    8146            0 :                                         rack.Name);
    8147            0 :                     SetupOutputVariable(state,
    8148              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8149              :                                         Constant::Units::J,
    8150            0 :                                         rack.BasinHeaterConsumption,
    8151              :                                         OutputProcessor::TimeStepType::Zone,
    8152              :                                         OutputProcessor::StoreType::Sum,
    8153            0 :                                         rack.Name,
    8154              :                                         Constant::eResource::Electricity,
    8155              :                                         OutputProcessor::Group::Plant,
    8156              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8157              :                                         rack.EndUseSubcategory);
    8158            0 :                     SetupOutputVariable(state,
    8159              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8160              :                                         Constant::Units::m3_s,
    8161            0 :                                         rack.EvapWaterConsumpRate,
    8162              :                                         OutputProcessor::TimeStepType::Zone,
    8163              :                                         OutputProcessor::StoreType::Average,
    8164            0 :                                         rack.Name);
    8165            0 :                     SetupOutputVariable(state,
    8166              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume",
    8167              :                                         Constant::Units::m3,
    8168            0 :                                         rack.EvapWaterConsumption,
    8169              :                                         OutputProcessor::TimeStepType::Zone,
    8170              :                                         OutputProcessor::StoreType::Sum,
    8171            0 :                                         rack.Name,
    8172              :                                         Constant::eResource::Water,
    8173              :                                         OutputProcessor::Group::Plant,
    8174              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8175              :                                         rack.EndUseSubcategory);
    8176              :                 } // condenser evap
    8177              : 
    8178            5 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8179            8 :                     SetupOutputVariable(state,
    8180              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Rate",
    8181              :                                         Constant::Units::W,
    8182            4 :                                         rack.SensZoneCreditHeatRate,
    8183              :                                         OutputProcessor::TimeStepType::Zone,
    8184              :                                         OutputProcessor::StoreType::Average,
    8185            4 :                                         rack.Name);
    8186            8 :                     SetupOutputVariable(state,
    8187              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Energy",
    8188              :                                         Constant::Units::J,
    8189            4 :                                         rack.SensZoneCreditHeat,
    8190              :                                         OutputProcessor::TimeStepType::Zone,
    8191              :                                         OutputProcessor::StoreType::Sum,
    8192            4 :                                         rack.Name);
    8193              : 
    8194            8 :                     SetupOutputVariable(state,
    8195              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Rate",
    8196              :                                         Constant::Units::W,
    8197            4 :                                         rack.SensHVACCreditHeatRate,
    8198              :                                         OutputProcessor::TimeStepType::Zone,
    8199              :                                         OutputProcessor::StoreType::Average,
    8200            4 :                                         rack.Name);
    8201            8 :                     SetupOutputVariable(state,
    8202              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Energy",
    8203              :                                         Constant::Units::J,
    8204            4 :                                         rack.SensHVACCreditHeat,
    8205              :                                         OutputProcessor::TimeStepType::Zone,
    8206              :                                         OutputProcessor::StoreType::Sum,
    8207            4 :                                         rack.Name);
    8208              : 
    8209              :                     // if Location is Zone, GetRefrigerationInputEither checks that you have at least one load and that either:
    8210              :                     // * You have only cases, and they must be all in the same zone
    8211              :                     // * Or you must have a Heat Rejection Zone provided
    8212            4 :                     int rackZoneNum = -1;
    8213            4 :                     if (rack.HeatRejectionZoneNum > 0) {
    8214            3 :                         rackZoneNum = rack.HeatRejectionZoneNum;
    8215              :                     } else {
    8216            1 :                         rackZoneNum = RefrigCase(rack.CaseNum(1)).ActualZoneNum;
    8217              :                     }
    8218            4 :                     SetupZoneInternalGain(state,
    8219              :                                           rackZoneNum,
    8220              :                                           rack.Name,
    8221              :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8222              :                                           &rack.SensZoneCreditHeatRate,
    8223              :                                           &rack.SensHVACCreditHeatRate);
    8224              : 
    8225              :                 } // location zone
    8226              :             }     // Serves coils or case/walkin loads
    8227              : 
    8228            5 :             if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) { // on HVAC time step no matter what
    8229            0 :                 SetupOutputVariable(state,
    8230              :                                     "Refrigeration Compressor Rack Condenser Mass Flow Rate",
    8231              :                                     Constant::Units::kg_s,
    8232            0 :                                     rack.MassFlowRate,
    8233              :                                     OutputProcessor::TimeStepType::System,
    8234              :                                     OutputProcessor::StoreType::Average,
    8235            0 :                                     rack.Name);
    8236              : 
    8237            0 :                 SetupOutputVariable(state,
    8238              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Rate",
    8239              :                                     Constant::Units::W,
    8240            0 :                                     rack.CondLoad,
    8241              :                                     OutputProcessor::TimeStepType::System,
    8242              :                                     OutputProcessor::StoreType::Average,
    8243            0 :                                     rack.Name);
    8244              : 
    8245            0 :                 SetupOutputVariable(state,
    8246              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Energy",
    8247              :                                     Constant::Units::J,
    8248            0 :                                     rack.CondEnergy,
    8249              :                                     OutputProcessor::TimeStepType::System,
    8250              :                                     OutputProcessor::StoreType::Sum,
    8251            0 :                                     rack.Name,
    8252              :                                     Constant::eResource::EnergyTransfer,
    8253              :                                     OutputProcessor::Group::Plant,
    8254              :                                     OutputProcessor::EndUseCat::Heating);
    8255              : 
    8256              :             } // Condenser cooling water
    8257              :         }     // Refrigerated Racks
    8258              :     }         // NumRefrigeratedRacks > 0
    8259              : 
    8260          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
    8261              :         // CurrentModuleObject='Refrigeration:System'
    8262            0 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++refrigSysNum) {
    8263            0 :             auto &sys = System(refrigSysNum);
    8264            0 :             if (sys.CoilFlag) { // system serves chillers and is solved on HVAC time step
    8265            0 :                 if (sys.NumStages == 1) {
    8266            0 :                     SetupOutputVariable(state,
    8267              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Rate",
    8268              :                                         Constant::Units::W,
    8269            0 :                                         sys.TotCompPower,
    8270              :                                         OutputProcessor::TimeStepType::System,
    8271              :                                         OutputProcessor::StoreType::Average,
    8272            0 :                                         sys.Name);
    8273            0 :                     SetupOutputVariable(state,
    8274              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Energy",
    8275              :                                         Constant::Units::J,
    8276            0 :                                         sys.TotCompElecConsump,
    8277              :                                         OutputProcessor::TimeStepType::System,
    8278              :                                         OutputProcessor::StoreType::Sum,
    8279            0 :                                         sys.Name);
    8280            0 :                 } else if (sys.NumStages == 2) {
    8281            0 :                     SetupOutputVariable(state,
    8282              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Rate",
    8283              :                                         Constant::Units::W,
    8284            0 :                                         sys.TotCompPower,
    8285              :                                         OutputProcessor::TimeStepType::System,
    8286              :                                         OutputProcessor::StoreType::Average,
    8287            0 :                                         sys.Name);
    8288            0 :                     SetupOutputVariable(state,
    8289              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Energy",
    8290              :                                         Constant::Units::J,
    8291            0 :                                         sys.TotCompElecConsump,
    8292              :                                         OutputProcessor::TimeStepType::System,
    8293              :                                         OutputProcessor::StoreType::Sum,
    8294            0 :                                         sys.Name);
    8295            0 :                     SetupOutputVariable(state,
    8296              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Rate",
    8297              :                                         Constant::Units::W,
    8298            0 :                                         sys.TotHiStageCompPower,
    8299              :                                         OutputProcessor::TimeStepType::System,
    8300              :                                         OutputProcessor::StoreType::Average,
    8301            0 :                                         sys.Name);
    8302            0 :                     SetupOutputVariable(state,
    8303              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Energy",
    8304              :                                         Constant::Units::J,
    8305            0 :                                         sys.TotHiStageCompElecConsump,
    8306              :                                         OutputProcessor::TimeStepType::System,
    8307              :                                         OutputProcessor::StoreType::Sum,
    8308            0 :                                         sys.Name);
    8309            0 :                     SetupOutputVariable(state,
    8310              :                                         "Refrigeration Air Chiller System Total Low and High Stage Compressor Electricity Energy",
    8311              :                                         Constant::Units::J,
    8312            0 :                                         sys.TotCompElecConsumpTwoStage,
    8313              :                                         OutputProcessor::TimeStepType::System,
    8314              :                                         OutputProcessor::StoreType::Sum,
    8315            0 :                                         sys.Name);
    8316              :                 } // NumStages
    8317            0 :                 SetupOutputVariable(state,
    8318              :                                     "Refrigeration Air Chiller System Average Compressor COP",
    8319              :                                     Constant::Units::W_W,
    8320            0 :                                     sys.AverageCompressorCOP,
    8321              :                                     OutputProcessor::TimeStepType::System,
    8322              :                                     OutputProcessor::StoreType::Average,
    8323            0 :                                     sys.Name);
    8324            0 :                 SetupOutputVariable(state,
    8325              :                                     "Refrigeration Air Chiller System Total Air Chiller Heat Transfer Rate",
    8326              :                                     Constant::Units::W,
    8327            0 :                                     sys.TotalCoolingLoad,
    8328              :                                     OutputProcessor::TimeStepType::System,
    8329              :                                     OutputProcessor::StoreType::Average,
    8330            0 :                                     sys.Name);
    8331            0 :                 SetupOutputVariable(state,
    8332              :                                     "Refrigeration Air Chiller System Total Case and Walk In Heat Transfer Energy",
    8333              :                                     Constant::Units::J,
    8334            0 :                                     sys.TotalCoolingEnergy,
    8335              :                                     OutputProcessor::TimeStepType::System,
    8336              :                                     OutputProcessor::StoreType::Sum,
    8337            0 :                                     sys.Name);
    8338            0 :                 SetupOutputVariable(state,
    8339              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Rate",
    8340              :                                     Constant::Units::W,
    8341            0 :                                     sys.TotTransferLoad,
    8342              :                                     OutputProcessor::TimeStepType::System,
    8343              :                                     OutputProcessor::StoreType::Average,
    8344            0 :                                     sys.Name);
    8345            0 :                 SetupOutputVariable(state,
    8346              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Energy",
    8347              :                                     Constant::Units::J,
    8348            0 :                                     sys.TotTransferEnergy,
    8349              :                                     OutputProcessor::TimeStepType::System,
    8350              :                                     OutputProcessor::StoreType::Sum,
    8351            0 :                                     sys.Name);
    8352            0 :                 SetupOutputVariable(state,
    8353              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Rate",
    8354              :                                     Constant::Units::W,
    8355            0 :                                     sys.PipeHeatLoad,
    8356              :                                     OutputProcessor::TimeStepType::System,
    8357              :                                     OutputProcessor::StoreType::Average,
    8358            0 :                                     sys.Name);
    8359            0 :                 SetupOutputVariable(state,
    8360              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Energy",
    8361              :                                     Constant::Units::J,
    8362            0 :                                     sys.PipeHeatEnergy,
    8363              :                                     OutputProcessor::TimeStepType::System,
    8364              :                                     OutputProcessor::StoreType::Sum,
    8365            0 :                                     sys.Name);
    8366            0 :                 if (sys.NumStages == 1) {
    8367            0 :                     SetupOutputVariable(state,
    8368              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Rate",
    8369              :                                         Constant::Units::W,
    8370            0 :                                         sys.TotCompCapacity,
    8371              :                                         OutputProcessor::TimeStepType::System,
    8372              :                                         OutputProcessor::StoreType::Average,
    8373            0 :                                         sys.Name);
    8374            0 :                     SetupOutputVariable(state,
    8375              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Energy",
    8376              :                                         Constant::Units::J,
    8377            0 :                                         sys.TotCompCoolingEnergy,
    8378              :                                         OutputProcessor::TimeStepType::System,
    8379              :                                         OutputProcessor::StoreType::Sum,
    8380            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8381            0 :                 } else if (sys.NumStages == 2) {
    8382            0 :                     SetupOutputVariable(state,
    8383              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Rate",
    8384              :                                         Constant::Units::W,
    8385            0 :                                         sys.TotCompCapacity,
    8386              :                                         OutputProcessor::TimeStepType::System,
    8387              :                                         OutputProcessor::StoreType::Average,
    8388            0 :                                         sys.Name);
    8389            0 :                     SetupOutputVariable(state,
    8390              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Energy",
    8391              :                                         Constant::Units::J,
    8392            0 :                                         sys.TotCompCoolingEnergy,
    8393              :                                         OutputProcessor::TimeStepType::System,
    8394              :                                         OutputProcessor::StoreType::Sum,
    8395            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8396            0 :                     SetupOutputVariable(state,
    8397              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Rate",
    8398              :                                         Constant::Units::W,
    8399            0 :                                         sys.TotHiStageCompCapacity,
    8400              :                                         OutputProcessor::TimeStepType::System,
    8401              :                                         OutputProcessor::StoreType::Average,
    8402            0 :                                         sys.Name);
    8403            0 :                     SetupOutputVariable(state,
    8404              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Energy",
    8405              :                                         Constant::Units::J,
    8406            0 :                                         sys.TotHiStageCompCoolingEnergy,
    8407              :                                         OutputProcessor::TimeStepType::System,
    8408              :                                         OutputProcessor::StoreType::Sum,
    8409            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8410              :                 }                                  // NumStages
    8411            0 :                 SetupOutputVariable(state,
    8412              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Rate",
    8413              :                                     Constant::Units::W,
    8414            0 :                                     sys.NetHeatRejectLoad,
    8415              :                                     OutputProcessor::TimeStepType::System,
    8416              :                                     OutputProcessor::StoreType::Average,
    8417            0 :                                     sys.Name);
    8418            0 :                 SetupOutputVariable(state,
    8419              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Energy",
    8420              :                                     Constant::Units::J,
    8421            0 :                                     sys.NetHeatRejectEnergy,
    8422              :                                     OutputProcessor::TimeStepType::System,
    8423              :                                     OutputProcessor::StoreType::Sum,
    8424            0 :                                     sys.Name);
    8425            0 :                 SetupOutputVariable(state,
    8426              :                                     "Refrigeration Air Chiller System Estimated Refrigerant Inventory Mass",
    8427              :                                     Constant::Units::kg,
    8428            0 :                                     sys.RefInventory,
    8429              :                                     OutputProcessor::TimeStepType::System,
    8430              :                                     OutputProcessor::StoreType::Average,
    8431            0 :                                     sys.Name);
    8432            0 :                 if (sys.NumStages == 1) {
    8433            0 :                     SetupOutputVariable(state,
    8434              :                                         "Refrigeration Air Chiller System Estimated Refrigerant Mass Flow Rate",
    8435              :                                         Constant::Units::kg_s,
    8436            0 :                                         sys.RefMassFlowComps,
    8437              :                                         OutputProcessor::TimeStepType::System,
    8438              :                                         OutputProcessor::StoreType::Average,
    8439            0 :                                         sys.Name);
    8440            0 :                 } else if (sys.NumStages == 2) {
    8441            0 :                     SetupOutputVariable(state,
    8442              :                                         "Refrigeration Air Chiller System Estimated Low Stage Refrigerant Mass Flow Rate",
    8443              :                                         Constant::Units::kg_s,
    8444            0 :                                         sys.RefMassFlowComps,
    8445              :                                         OutputProcessor::TimeStepType::System,
    8446              :                                         OutputProcessor::StoreType::Average,
    8447            0 :                                         sys.Name);
    8448            0 :                     SetupOutputVariable(state,
    8449              :                                         "Refrigeration Air Chiller System Estimated High Stage Refrigerant Mass Flow Rate",
    8450              :                                         Constant::Units::kg_s,
    8451            0 :                                         sys.RefMassFlowHiStageComps,
    8452              :                                         OutputProcessor::TimeStepType::System,
    8453              :                                         OutputProcessor::StoreType::Average,
    8454            0 :                                         sys.Name);
    8455              :                 } // NumStages
    8456            0 :                 if (sys.NumStages == 2) {
    8457            0 :                     SetupOutputVariable(state,
    8458              :                                         "Refrigeration Air Chiller System Intercooler Temperature",
    8459              :                                         Constant::Units::C,
    8460            0 :                                         sys.TIntercooler,
    8461              :                                         OutputProcessor::TimeStepType::System,
    8462              :                                         OutputProcessor::StoreType::Average,
    8463            0 :                                         sys.Name);
    8464            0 :                     SetupOutputVariable(state,
    8465              :                                         "Refrigeration Air Chiller System Intercooler Pressure",
    8466              :                                         Constant::Units::Pa,
    8467            0 :                                         sys.PIntercooler,
    8468              :                                         OutputProcessor::TimeStepType::System,
    8469              :                                         OutputProcessor::StoreType::Average,
    8470            0 :                                         sys.Name);
    8471              :                 }
    8472            0 :                 SetupOutputVariable(state,
    8473              :                                     "Refrigeration Air Chiller System Condensing Temperature",
    8474              :                                     Constant::Units::C,
    8475            0 :                                     sys.TCondense,
    8476              :                                     OutputProcessor::TimeStepType::System,
    8477              :                                     OutputProcessor::StoreType::Average,
    8478            0 :                                     sys.Name);
    8479            0 :                 SetupOutputVariable(state,
    8480              :                                     "Refrigeration Air Chiller System Evaporating Temperature",
    8481              :                                     Constant::Units::C,
    8482            0 :                                     sys.TEvapNeeded,
    8483              :                                     OutputProcessor::TimeStepType::System,
    8484              :                                     OutputProcessor::StoreType::Average,
    8485            0 :                                     sys.Name);
    8486            0 :                 SetupOutputVariable(state,
    8487              :                                     "Refrigeration Air Chiller System Suction Temperature",
    8488              :                                     Constant::Units::C,
    8489            0 :                                     sys.TCompIn,
    8490              :                                     OutputProcessor::TimeStepType::System,
    8491              :                                     OutputProcessor::StoreType::Average,
    8492            0 :                                     sys.Name);
    8493            0 :                 SetupOutputVariable(state,
    8494              :                                     "Refrigeration Air Chiller System TXV Liquid Temperature",
    8495              :                                     Constant::Units::C,
    8496            0 :                                     sys.TLiqInActual,
    8497              :                                     OutputProcessor::TimeStepType::System,
    8498              :                                     OutputProcessor::StoreType::Average,
    8499            0 :                                     sys.Name);
    8500            0 :                 SetupOutputVariable(state,
    8501              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Rate",
    8502              :                                     Constant::Units::W,
    8503            0 :                                     sys.LSHXTrans,
    8504              :                                     OutputProcessor::TimeStepType::System,
    8505              :                                     OutputProcessor::StoreType::Average,
    8506            0 :                                     sys.Name);
    8507            0 :                 SetupOutputVariable(state,
    8508              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Energy",
    8509              :                                     Constant::Units::J,
    8510            0 :                                     sys.LSHXTransEnergy,
    8511              :                                     OutputProcessor::TimeStepType::System,
    8512              :                                     OutputProcessor::StoreType::Sum,
    8513            0 :                                     sys.Name);
    8514              :             } else { // NOT System(SysNum)%CoilFlag, so serving loads on zone timestep
    8515            0 :                 if (sys.NumStages == 1) {
    8516            0 :                     SetupOutputVariable(state,
    8517              :                                         "Refrigeration System Total Compressor Electricity Rate",
    8518              :                                         Constant::Units::W,
    8519            0 :                                         sys.TotCompPower,
    8520              :                                         OutputProcessor::TimeStepType::Zone,
    8521              :                                         OutputProcessor::StoreType::Average,
    8522            0 :                                         sys.Name);
    8523            0 :                     SetupOutputVariable(state,
    8524              :                                         "Refrigeration System Total Compressor Electricity Energy",
    8525              :                                         Constant::Units::J,
    8526            0 :                                         sys.TotCompElecConsump,
    8527              :                                         OutputProcessor::TimeStepType::Zone,
    8528              :                                         OutputProcessor::StoreType::Sum,
    8529            0 :                                         sys.Name);
    8530            0 :                 } else if (sys.NumStages == 2) {
    8531            0 :                     SetupOutputVariable(state,
    8532              :                                         "Refrigeration System Total Low Stage Compressor Electricity Rate",
    8533              :                                         Constant::Units::W,
    8534            0 :                                         sys.TotCompPower,
    8535              :                                         OutputProcessor::TimeStepType::Zone,
    8536              :                                         OutputProcessor::StoreType::Average,
    8537            0 :                                         sys.Name);
    8538            0 :                     SetupOutputVariable(state,
    8539              :                                         "Refrigeration System Total Low Stage Compressor Electricity Energy",
    8540              :                                         Constant::Units::J,
    8541            0 :                                         sys.TotCompElecConsump,
    8542              :                                         OutputProcessor::TimeStepType::Zone,
    8543              :                                         OutputProcessor::StoreType::Sum,
    8544            0 :                                         sys.Name);
    8545            0 :                     SetupOutputVariable(state,
    8546              :                                         "Refrigeration System Total High Stage Compressor Electricity Rate",
    8547              :                                         Constant::Units::W,
    8548            0 :                                         sys.TotHiStageCompPower,
    8549              :                                         OutputProcessor::TimeStepType::Zone,
    8550              :                                         OutputProcessor::StoreType::Average,
    8551            0 :                                         sys.Name);
    8552            0 :                     SetupOutputVariable(state,
    8553              :                                         "Refrigeration System Total High Stage Compressor Electricity Energy",
    8554              :                                         Constant::Units::J,
    8555            0 :                                         sys.TotHiStageCompElecConsump,
    8556              :                                         OutputProcessor::TimeStepType::Zone,
    8557              :                                         OutputProcessor::StoreType::Sum,
    8558            0 :                                         sys.Name);
    8559            0 :                     SetupOutputVariable(state,
    8560              :                                         "Refrigeration System Total Low and High Stage Compressor Electricity Energy",
    8561              :                                         Constant::Units::J,
    8562            0 :                                         sys.TotCompElecConsumpTwoStage,
    8563              :                                         OutputProcessor::TimeStepType::Zone,
    8564              :                                         OutputProcessor::StoreType::Sum,
    8565            0 :                                         sys.Name);
    8566              :                 } // NumStages
    8567            0 :                 SetupOutputVariable(state,
    8568              :                                     "Refrigeration System Average Compressor COP",
    8569              :                                     Constant::Units::W_W,
    8570            0 :                                     sys.AverageCompressorCOP,
    8571              :                                     OutputProcessor::TimeStepType::Zone,
    8572              :                                     OutputProcessor::StoreType::Average,
    8573            0 :                                     sys.Name);
    8574            0 :                 SetupOutputVariable(state,
    8575              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Rate",
    8576              :                                     Constant::Units::W,
    8577            0 :                                     sys.TotalCoolingLoad,
    8578              :                                     OutputProcessor::TimeStepType::Zone,
    8579              :                                     OutputProcessor::StoreType::Average,
    8580            0 :                                     sys.Name);
    8581            0 :                 SetupOutputVariable(state,
    8582              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Energy",
    8583              :                                     Constant::Units::J,
    8584            0 :                                     sys.TotalCoolingEnergy,
    8585              :                                     OutputProcessor::TimeStepType::Zone,
    8586              :                                     OutputProcessor::StoreType::Sum,
    8587            0 :                                     sys.Name);
    8588            0 :                 SetupOutputVariable(state,
    8589              :                                     "Refrigeration System Total Transferred Load Heat Transfer Rate",
    8590              :                                     Constant::Units::W,
    8591            0 :                                     sys.TotTransferLoad,
    8592              :                                     OutputProcessor::TimeStepType::Zone,
    8593              :                                     OutputProcessor::StoreType::Average,
    8594            0 :                                     sys.Name);
    8595            0 :                 SetupOutputVariable(state,
    8596              :                                     "Refrigeration System Total Transferred Load Heat Transfer Energy",
    8597              :                                     Constant::Units::J,
    8598            0 :                                     sys.TotTransferEnergy,
    8599              :                                     OutputProcessor::TimeStepType::Zone,
    8600              :                                     OutputProcessor::StoreType::Sum,
    8601            0 :                                     sys.Name);
    8602            0 :                 SetupOutputVariable(state,
    8603              :                                     "Refrigeration System Total Suction Pipe Heat Gain Rate",
    8604              :                                     Constant::Units::W,
    8605            0 :                                     sys.PipeHeatLoad,
    8606              :                                     OutputProcessor::TimeStepType::Zone,
    8607              :                                     OutputProcessor::StoreType::Average,
    8608            0 :                                     sys.Name);
    8609            0 :                 SetupOutputVariable(state,
    8610              :                                     "Refrigeration System Total Suction Pipe Heat Gain Energy",
    8611              :                                     Constant::Units::J,
    8612            0 :                                     sys.PipeHeatEnergy,
    8613              :                                     OutputProcessor::TimeStepType::Zone,
    8614              :                                     OutputProcessor::StoreType::Sum,
    8615            0 :                                     sys.Name);
    8616            0 :                 if (sys.NumStages == 1) {
    8617            0 :                     SetupOutputVariable(state,
    8618              :                                         "Refrigeration System Total Compressor Heat Transfer Rate",
    8619              :                                         Constant::Units::W,
    8620            0 :                                         sys.TotCompCapacity,
    8621              :                                         OutputProcessor::TimeStepType::Zone,
    8622              :                                         OutputProcessor::StoreType::Average,
    8623            0 :                                         sys.Name);
    8624            0 :                     SetupOutputVariable(state,
    8625              :                                         "Refrigeration System Total Compressor Heat Transfer Energy",
    8626              :                                         Constant::Units::J,
    8627            0 :                                         sys.TotCompCoolingEnergy,
    8628              :                                         OutputProcessor::TimeStepType::Zone,
    8629              :                                         OutputProcessor::StoreType::Sum,
    8630            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8631            0 :                 } else if (sys.NumStages == 2) {
    8632            0 :                     SetupOutputVariable(state,
    8633              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Rate",
    8634              :                                         Constant::Units::W,
    8635            0 :                                         sys.TotCompCapacity,
    8636              :                                         OutputProcessor::TimeStepType::Zone,
    8637              :                                         OutputProcessor::StoreType::Average,
    8638            0 :                                         sys.Name);
    8639            0 :                     SetupOutputVariable(state,
    8640              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Energy",
    8641              :                                         Constant::Units::J,
    8642            0 :                                         sys.TotCompCoolingEnergy,
    8643              :                                         OutputProcessor::TimeStepType::Zone,
    8644              :                                         OutputProcessor::StoreType::Sum,
    8645            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8646            0 :                     SetupOutputVariable(state,
    8647              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Rate",
    8648              :                                         Constant::Units::W,
    8649            0 :                                         sys.TotHiStageCompCapacity,
    8650              :                                         OutputProcessor::TimeStepType::Zone,
    8651              :                                         OutputProcessor::StoreType::Average,
    8652            0 :                                         sys.Name);
    8653            0 :                     SetupOutputVariable(state,
    8654              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Energy",
    8655              :                                         Constant::Units::J,
    8656            0 :                                         sys.TotHiStageCompCoolingEnergy,
    8657              :                                         OutputProcessor::TimeStepType::Zone,
    8658              :                                         OutputProcessor::StoreType::Sum,
    8659            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8660              :                 }                                  // NumStages
    8661            0 :                 SetupOutputVariable(state,
    8662              :                                     "Refrigeration System Net Rejected Heat Transfer Rate",
    8663              :                                     Constant::Units::W,
    8664            0 :                                     sys.NetHeatRejectLoad,
    8665              :                                     OutputProcessor::TimeStepType::Zone,
    8666              :                                     OutputProcessor::StoreType::Average,
    8667            0 :                                     sys.Name);
    8668            0 :                 SetupOutputVariable(state,
    8669              :                                     "Refrigeration System Net Rejected Heat Transfer Energy",
    8670              :                                     Constant::Units::J,
    8671            0 :                                     sys.NetHeatRejectEnergy,
    8672              :                                     OutputProcessor::TimeStepType::Zone,
    8673              :                                     OutputProcessor::StoreType::Sum,
    8674            0 :                                     sys.Name);
    8675            0 :                 SetupOutputVariable(state,
    8676              :                                     "Refrigeration System Estimated Refrigerant Inventory Mass",
    8677              :                                     Constant::Units::kg,
    8678            0 :                                     sys.RefInventory,
    8679              :                                     OutputProcessor::TimeStepType::Zone,
    8680              :                                     OutputProcessor::StoreType::Average,
    8681            0 :                                     sys.Name);
    8682            0 :                 if (sys.NumStages == 1) {
    8683            0 :                     SetupOutputVariable(state,
    8684              :                                         "Refrigeration System Estimated Refrigerant Mass Flow Rate",
    8685              :                                         Constant::Units::kg_s,
    8686            0 :                                         sys.RefMassFlowComps,
    8687              :                                         OutputProcessor::TimeStepType::Zone,
    8688              :                                         OutputProcessor::StoreType::Average,
    8689            0 :                                         sys.Name);
    8690            0 :                 } else if (sys.NumStages == 2) {
    8691            0 :                     SetupOutputVariable(state,
    8692              :                                         "Refrigeration System Estimated Low Stage Refrigerant Mass Flow Rate",
    8693              :                                         Constant::Units::kg_s,
    8694            0 :                                         sys.RefMassFlowComps,
    8695              :                                         OutputProcessor::TimeStepType::Zone,
    8696              :                                         OutputProcessor::StoreType::Average,
    8697            0 :                                         sys.Name);
    8698            0 :                     SetupOutputVariable(state,
    8699              :                                         "Refrigeration System Estimated High Stage Refrigerant Mass Flow Rate",
    8700              :                                         Constant::Units::kg_s,
    8701            0 :                                         sys.RefMassFlowHiStageComps,
    8702              :                                         OutputProcessor::TimeStepType::Zone,
    8703              :                                         OutputProcessor::StoreType::Average,
    8704            0 :                                         sys.Name);
    8705              :                 } // NumStages
    8706            0 :                 if (sys.NumStages == 2) {
    8707            0 :                     SetupOutputVariable(state,
    8708              :                                         "Refrigeration System Intercooler Temperature",
    8709              :                                         Constant::Units::C,
    8710            0 :                                         sys.TIntercooler,
    8711              :                                         OutputProcessor::TimeStepType::Zone,
    8712              :                                         OutputProcessor::StoreType::Average,
    8713            0 :                                         sys.Name);
    8714            0 :                     SetupOutputVariable(state,
    8715              :                                         "Refrigeration System Intercooler Pressure",
    8716              :                                         Constant::Units::Pa,
    8717            0 :                                         sys.PIntercooler,
    8718              :                                         OutputProcessor::TimeStepType::Zone,
    8719              :                                         OutputProcessor::StoreType::Average,
    8720            0 :                                         sys.Name);
    8721              :                 }
    8722            0 :                 SetupOutputVariable(state,
    8723              :                                     "Refrigeration System Condensing Temperature",
    8724              :                                     Constant::Units::C,
    8725            0 :                                     sys.TCondense,
    8726              :                                     OutputProcessor::TimeStepType::Zone,
    8727              :                                     OutputProcessor::StoreType::Average,
    8728            0 :                                     sys.Name);
    8729            0 :                 SetupOutputVariable(state,
    8730              :                                     "Refrigeration System Evaporating Temperature",
    8731              :                                     Constant::Units::C,
    8732            0 :                                     sys.TEvapNeeded,
    8733              :                                     OutputProcessor::TimeStepType::Zone,
    8734              :                                     OutputProcessor::StoreType::Average,
    8735            0 :                                     sys.Name);
    8736            0 :                 SetupOutputVariable(state,
    8737              :                                     "Refrigeration System Suction Pipe Suction Temperature",
    8738              :                                     Constant::Units::C,
    8739            0 :                                     sys.TCompIn,
    8740              :                                     OutputProcessor::TimeStepType::Zone,
    8741              :                                     OutputProcessor::StoreType::Average,
    8742            0 :                                     sys.Name);
    8743            0 :                 SetupOutputVariable(state,
    8744              :                                     "Refrigeration System Thermostatic Expansion Valve Liquid Temperature",
    8745              :                                     Constant::Units::C,
    8746            0 :                                     sys.TLiqInActual,
    8747              :                                     OutputProcessor::TimeStepType::Zone,
    8748              :                                     OutputProcessor::StoreType::Average,
    8749            0 :                                     sys.Name);
    8750            0 :                 SetupOutputVariable(state,
    8751              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Rate",
    8752              :                                     Constant::Units::W,
    8753            0 :                                     sys.LSHXTrans,
    8754              :                                     OutputProcessor::TimeStepType::Zone,
    8755              :                                     OutputProcessor::StoreType::Average,
    8756            0 :                                     sys.Name);
    8757            0 :                 SetupOutputVariable(state,
    8758              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Energy",
    8759              :                                     Constant::Units::J,
    8760            0 :                                     sys.LSHXTransEnergy,
    8761              :                                     OutputProcessor::TimeStepType::Zone,
    8762              :                                     OutputProcessor::StoreType::Sum,
    8763            0 :                                     sys.Name);
    8764              :             } // System(coilflag)
    8765              : 
    8766            0 :             if (sys.SystemRejectHeatToZone) {
    8767            0 :                 if (Condenser(sys.CondenserNum(1)).InletAirZoneNum > 0)
    8768            0 :                     SetupZoneInternalGain(state,
    8769            0 :                                           Condenser(sys.CondenserNum(1)).InletAirZoneNum,
    8770              :                                           sys.Name,
    8771              :                                           DataHeatBalance::IntGainType::RefrigerationSystemAirCooledCondenser,
    8772              :                                           &sys.NetHeatRejectLoad);
    8773              : 
    8774            0 :                 if (sys.SuctionPipeActualZoneNum > 0)
    8775            0 :                     SetupZoneInternalGain(state,
    8776              :                                           sys.SuctionPipeActualZoneNum,
    8777              :                                           sys.Name,
    8778              :                                           DataHeatBalance::IntGainType::RefrigerationSystemSuctionPipe,
    8779              :                                           &sys.PipeHeatLoad);
    8780              :             }
    8781              :         } // numrefrigsystems
    8782              : 
    8783              :         // Report Compressor ENERGY here, not on system level for meters.
    8784            0 :         for (int compNum = 1; compNum <= state.dataRefrigCase->NumSimulationCompressors; ++compNum) {
    8785            0 :             auto &comp = Compressor(compNum);
    8786              :             // CurrentModuleObject='Refrigeration:Compressor'
    8787            0 :             if (comp.NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    8788            0 :                 if (comp.CoilFlag) {      // Compressor serving system with chillers on HVAC time step
    8789            0 :                     SetupOutputVariable(state,
    8790              :                                         "Refrigeration Air Chiller System Compressor Electricity Rate",
    8791              :                                         Constant::Units::W,
    8792            0 :                                         comp.Power,
    8793              :                                         OutputProcessor::TimeStepType::System,
    8794              :                                         OutputProcessor::StoreType::Average,
    8795            0 :                                         comp.Name);
    8796            0 :                     SetupOutputVariable(state,
    8797              :                                         "Refrigeration Air Chiller System Compressor Electricity Energy",
    8798              :                                         Constant::Units::J,
    8799            0 :                                         comp.ElecConsumption,
    8800              :                                         OutputProcessor::TimeStepType::System,
    8801              :                                         OutputProcessor::StoreType::Sum,
    8802            0 :                                         comp.Name,
    8803              :                                         Constant::eResource::Electricity,
    8804              :                                         OutputProcessor::Group::Plant,
    8805              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8806              :                                         comp.EndUseSubcategory);
    8807            0 :                     SetupOutputVariable(state,
    8808              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Rate",
    8809              :                                         Constant::Units::W,
    8810            0 :                                         comp.Capacity,
    8811              :                                         OutputProcessor::TimeStepType::System,
    8812              :                                         OutputProcessor::StoreType::Average,
    8813            0 :                                         comp.Name);
    8814            0 :                     SetupOutputVariable(state,
    8815              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Energy",
    8816              :                                         Constant::Units::J,
    8817            0 :                                         comp.CoolingEnergy,
    8818              :                                         OutputProcessor::TimeStepType::System,
    8819              :                                         OutputProcessor::StoreType::Sum,
    8820            0 :                                         comp.Name);
    8821            0 :                     SetupOutputVariable(state,
    8822              :                                         "Refrigeration Air Chiller System Compressor Runtime Fraction",
    8823              :                                         Constant::Units::None,
    8824            0 :                                         comp.LoadFactor,
    8825              :                                         OutputProcessor::TimeStepType::System,
    8826              :                                         OutputProcessor::StoreType::Average,
    8827            0 :                                         comp.Name);
    8828              :                 } else { // serve cases/walkins on zone time step
    8829            0 :                     SetupOutputVariable(state,
    8830              :                                         "Refrigeration Compressor Electricity Rate",
    8831              :                                         Constant::Units::W,
    8832            0 :                                         comp.Power,
    8833              :                                         OutputProcessor::TimeStepType::Zone,
    8834              :                                         OutputProcessor::StoreType::Average,
    8835            0 :                                         comp.Name);
    8836            0 :                     SetupOutputVariable(state,
    8837              :                                         "Refrigeration Compressor Electricity Energy",
    8838              :                                         Constant::Units::J,
    8839            0 :                                         comp.ElecConsumption,
    8840              :                                         OutputProcessor::TimeStepType::Zone,
    8841              :                                         OutputProcessor::StoreType::Sum,
    8842            0 :                                         comp.Name,
    8843              :                                         Constant::eResource::Electricity,
    8844              :                                         OutputProcessor::Group::Plant,
    8845              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8846              :                                         comp.EndUseSubcategory);
    8847            0 :                     SetupOutputVariable(state,
    8848              :                                         "Refrigeration Compressor Heat Transfer Rate",
    8849              :                                         Constant::Units::W,
    8850            0 :                                         comp.Capacity,
    8851              :                                         OutputProcessor::TimeStepType::Zone,
    8852              :                                         OutputProcessor::StoreType::Average,
    8853            0 :                                         comp.Name);
    8854            0 :                     SetupOutputVariable(state,
    8855              :                                         "Refrigeration Compressor Heat Transfer Energy",
    8856              :                                         Constant::Units::J,
    8857            0 :                                         comp.CoolingEnergy,
    8858              :                                         OutputProcessor::TimeStepType::Zone,
    8859              :                                         OutputProcessor::StoreType::Sum,
    8860            0 :                                         comp.Name);
    8861            0 :                     SetupOutputVariable(state,
    8862              :                                         "Refrigeration Compressor Runtime Fraction",
    8863              :                                         Constant::Units::None,
    8864            0 :                                         comp.LoadFactor,
    8865              :                                         OutputProcessor::TimeStepType::Zone,
    8866              :                                         OutputProcessor::StoreType::Average,
    8867            0 :                                         comp.Name);
    8868              :                 } // Serve coils on HVAC time step or cases/walkins on Zone time step
    8869              :             }     // NumSysAttach
    8870              :         }         // CompNum on NumSimulationCompressors
    8871              : 
    8872              :         // Report Variables for Refrigeration Condensers
    8873            0 :         for (int condNum = 1; condNum <= state.dataRefrigCase->NumRefrigCondensers; ++condNum) {
    8874            0 :             auto &cond = Condenser(condNum);
    8875              :             // CurrentModuleObject='Refrigeration:Condenser:*'
    8876            0 :             if (cond.CoilFlag) { // Condenser serving system with chillers on HVAC time step
    8877            0 :                 SetupOutputVariable(state,
    8878              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Rate",
    8879              :                                     Constant::Units::W,
    8880            0 :                                     cond.CondLoad,
    8881              :                                     OutputProcessor::TimeStepType::System,
    8882              :                                     OutputProcessor::StoreType::Average,
    8883            0 :                                     cond.Name);
    8884            0 :                 SetupOutputVariable(state,
    8885              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Energy",
    8886              :                                     Constant::Units::J,
    8887            0 :                                     cond.CondEnergy,
    8888              :                                     OutputProcessor::TimeStepType::System,
    8889              :                                     OutputProcessor::StoreType::Sum,
    8890            0 :                                     cond.Name);
    8891              : 
    8892            0 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    8893            0 :                     SetupOutputVariable(state,
    8894              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Rate",
    8895              :                                         Constant::Units::W,
    8896            0 :                                         cond.TotalHeatRecoveredLoad,
    8897              :                                         OutputProcessor::TimeStepType::System,
    8898              :                                         OutputProcessor::StoreType::Average,
    8899            0 :                                         cond.Name);
    8900            0 :                     SetupOutputVariable(state,
    8901              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Energy",
    8902              :                                         Constant::Units::J,
    8903            0 :                                         cond.TotalHeatRecoveredEnergy,
    8904              :                                         OutputProcessor::TimeStepType::System,
    8905              :                                         OutputProcessor::StoreType::Sum,
    8906            0 :                                         cond.Name);
    8907            0 :                     SetupOutputVariable(state,
    8908              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    8909              :                                         Constant::Units::W,
    8910            0 :                                         cond.ExternalHeatRecoveredLoad,
    8911              :                                         OutputProcessor::TimeStepType::System,
    8912              :                                         OutputProcessor::StoreType::Average,
    8913            0 :                                         cond.Name);
    8914            0 :                     SetupOutputVariable(state,
    8915              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    8916              :                                         Constant::Units::J,
    8917            0 :                                         cond.ExternalEnergyRecovered,
    8918              :                                         OutputProcessor::TimeStepType::System,
    8919              :                                         OutputProcessor::StoreType::Sum,
    8920            0 :                                         cond.Name);
    8921            0 :                     SetupOutputVariable(state,
    8922              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Rate",
    8923              :                                         Constant::Units::W,
    8924            0 :                                         cond.InternalHeatRecoveredLoad,
    8925              :                                         OutputProcessor::TimeStepType::System,
    8926              :                                         OutputProcessor::StoreType::Average,
    8927            0 :                                         cond.Name);
    8928            0 :                     SetupOutputVariable(state,
    8929              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Energy",
    8930              :                                         Constant::Units::J,
    8931            0 :                                         cond.InternalEnergyRecovered,
    8932              :                                         OutputProcessor::TimeStepType::System,
    8933              :                                         OutputProcessor::StoreType::Sum,
    8934            0 :                                         cond.Name);
    8935              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    8936              : 
    8937            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    8938            0 :                     SetupOutputVariable(state,
    8939              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    8940              :                                         Constant::Units::W,
    8941            0 :                                         cond.ActualFanPower,
    8942              :                                         OutputProcessor::TimeStepType::System,
    8943              :                                         OutputProcessor::StoreType::Average,
    8944            0 :                                         cond.Name);
    8945            0 :                     SetupOutputVariable(state,
    8946              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    8947              :                                         Constant::Units::J,
    8948            0 :                                         cond.FanElecEnergy,
    8949              :                                         OutputProcessor::TimeStepType::System,
    8950              :                                         OutputProcessor::StoreType::Sum,
    8951            0 :                                         cond.Name,
    8952              :                                         Constant::eResource::Electricity,
    8953              :                                         OutputProcessor::Group::Plant,
    8954              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8955              :                                         cond.EndUseSubcategory);
    8956              :                 } // Air cooled
    8957              : 
    8958            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8959            0 :                     SetupOutputVariable(state,
    8960              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    8961              :                                         Constant::Units::W,
    8962            0 :                                         cond.ActualFanPower,
    8963              :                                         OutputProcessor::TimeStepType::System,
    8964              :                                         OutputProcessor::StoreType::Average,
    8965            0 :                                         cond.Name);
    8966            0 :                     SetupOutputVariable(state,
    8967              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    8968              :                                         Constant::Units::J,
    8969            0 :                                         cond.FanElecEnergy,
    8970              :                                         OutputProcessor::TimeStepType::System,
    8971              :                                         OutputProcessor::StoreType::Sum,
    8972            0 :                                         cond.Name,
    8973              :                                         Constant::eResource::Electricity,
    8974              :                                         OutputProcessor::Group::Plant,
    8975              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8976              :                                         cond.EndUseSubcategory);
    8977            0 :                     SetupOutputVariable(state,
    8978              :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Rate",
    8979              :                                         Constant::Units::W,
    8980            0 :                                         cond.ActualEvapPumpPower,
    8981              :                                         OutputProcessor::TimeStepType::System,
    8982              :                                         OutputProcessor::StoreType::Average,
    8983            0 :                                         cond.Name);
    8984            0 :                     SetupOutputVariable(state,
    8985              :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Energy",
    8986              :                                         Constant::Units::J,
    8987            0 :                                         cond.EvapPumpConsumption,
    8988              :                                         OutputProcessor::TimeStepType::System,
    8989              :                                         OutputProcessor::StoreType::Sum,
    8990            0 :                                         cond.Name,
    8991              :                                         Constant::eResource::Electricity,
    8992              :                                         OutputProcessor::Group::Plant,
    8993              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8994              :                                         cond.EndUseSubcategory);
    8995            0 :                     SetupOutputVariable(state,
    8996              :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Rate",
    8997              :                                         Constant::Units::W,
    8998            0 :                                         cond.BasinHeaterPower,
    8999              :                                         OutputProcessor::TimeStepType::System,
    9000              :                                         OutputProcessor::StoreType::Average,
    9001            0 :                                         cond.Name);
    9002            0 :                     SetupOutputVariable(state,
    9003              :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Energy",
    9004              :                                         Constant::Units::J,
    9005            0 :                                         cond.BasinHeaterConsumption,
    9006              :                                         OutputProcessor::TimeStepType::System,
    9007              :                                         OutputProcessor::StoreType::Sum,
    9008            0 :                                         cond.Name,
    9009              :                                         Constant::eResource::Electricity,
    9010              :                                         OutputProcessor::Group::Plant,
    9011              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9012              :                                         cond.EndUseSubcategory);
    9013            0 :                     SetupOutputVariable(state,
    9014              :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume Flow Rate",
    9015              :                                         Constant::Units::m3_s,
    9016            0 :                                         cond.EvapWaterConsumpRate,
    9017              :                                         OutputProcessor::TimeStepType::System,
    9018              :                                         OutputProcessor::StoreType::Average,
    9019            0 :                                         cond.Name);
    9020            0 :                     SetupOutputVariable(state,
    9021              :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume",
    9022              :                                         Constant::Units::m3,
    9023            0 :                                         cond.EvapWaterConsumption,
    9024              :                                         OutputProcessor::TimeStepType::System,
    9025              :                                         OutputProcessor::StoreType::Sum,
    9026            0 :                                         cond.Name,
    9027              :                                         Constant::eResource::Water,
    9028              :                                         OutputProcessor::Group::Plant,
    9029              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9030              :                                         cond.EndUseSubcategory);
    9031              :                 } // Evaporative Condenser Variables
    9032              : 
    9033            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9034            0 :                     SetupOutputVariable(state,
    9035              :                                         "Refrigeration Air Chiller System Condenser Fluid Mass Flow Rate",
    9036              :                                         Constant::Units::kg_s,
    9037            0 :                                         cond.MassFlowRate,
    9038              :                                         OutputProcessor::TimeStepType::System,
    9039              :                                         OutputProcessor::StoreType::Average,
    9040            0 :                                         cond.Name);
    9041              : 
    9042              :                 } // Water-cooled Condenser variables
    9043              : 
    9044              :             } else { // Serving loads/systems with cases and walkins on zone time step
    9045              : 
    9046            0 :                 SetupOutputVariable(state,
    9047              :                                     "Refrigeration System Condenser Heat Transfer Rate",
    9048              :                                     Constant::Units::W,
    9049            0 :                                     cond.CondLoad,
    9050              :                                     OutputProcessor::TimeStepType::Zone,
    9051              :                                     OutputProcessor::StoreType::Average,
    9052            0 :                                     cond.Name);
    9053            0 :                 SetupOutputVariable(state,
    9054              :                                     "Refrigeration System Condenser Heat Transfer Energy",
    9055              :                                     Constant::Units::J,
    9056            0 :                                     cond.CondEnergy,
    9057              :                                     OutputProcessor::TimeStepType::Zone,
    9058              :                                     OutputProcessor::StoreType::Sum,
    9059            0 :                                     cond.Name);
    9060              : 
    9061            0 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9062            0 :                     SetupOutputVariable(state,
    9063              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Rate",
    9064              :                                         Constant::Units::W,
    9065            0 :                                         cond.TotalHeatRecoveredLoad,
    9066              :                                         OutputProcessor::TimeStepType::Zone,
    9067              :                                         OutputProcessor::StoreType::Average,
    9068            0 :                                         cond.Name);
    9069            0 :                     SetupOutputVariable(state,
    9070              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Energy",
    9071              :                                         Constant::Units::J,
    9072            0 :                                         cond.TotalHeatRecoveredEnergy,
    9073              :                                         OutputProcessor::TimeStepType::Zone,
    9074              :                                         OutputProcessor::StoreType::Sum,
    9075            0 :                                         cond.Name);
    9076            0 :                     SetupOutputVariable(state,
    9077              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9078              :                                         Constant::Units::W,
    9079            0 :                                         cond.ExternalHeatRecoveredLoad,
    9080              :                                         OutputProcessor::TimeStepType::Zone,
    9081              :                                         OutputProcessor::StoreType::Average,
    9082            0 :                                         cond.Name);
    9083            0 :                     SetupOutputVariable(state,
    9084              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9085              :                                         Constant::Units::J,
    9086            0 :                                         cond.ExternalEnergyRecovered,
    9087              :                                         OutputProcessor::TimeStepType::Zone,
    9088              :                                         OutputProcessor::StoreType::Sum,
    9089            0 :                                         cond.Name);
    9090            0 :                     SetupOutputVariable(state,
    9091              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Rate",
    9092              :                                         Constant::Units::W,
    9093            0 :                                         cond.InternalHeatRecoveredLoad,
    9094              :                                         OutputProcessor::TimeStepType::Zone,
    9095              :                                         OutputProcessor::StoreType::Average,
    9096            0 :                                         cond.Name);
    9097            0 :                     SetupOutputVariable(state,
    9098              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Energy",
    9099              :                                         Constant::Units::J,
    9100            0 :                                         cond.InternalEnergyRecovered,
    9101              :                                         OutputProcessor::TimeStepType::Zone,
    9102              :                                         OutputProcessor::StoreType::Sum,
    9103            0 :                                         cond.Name);
    9104              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9105              : 
    9106            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9107            0 :                     SetupOutputVariable(state,
    9108              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9109              :                                         Constant::Units::W,
    9110            0 :                                         cond.ActualFanPower,
    9111              :                                         OutputProcessor::TimeStepType::Zone,
    9112              :                                         OutputProcessor::StoreType::Average,
    9113            0 :                                         cond.Name);
    9114            0 :                     SetupOutputVariable(state,
    9115              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9116              :                                         Constant::Units::J,
    9117            0 :                                         cond.FanElecEnergy,
    9118              :                                         OutputProcessor::TimeStepType::Zone,
    9119              :                                         OutputProcessor::StoreType::Sum,
    9120            0 :                                         cond.Name,
    9121              :                                         Constant::eResource::Electricity,
    9122              :                                         OutputProcessor::Group::Plant,
    9123              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9124              :                                         cond.EndUseSubcategory);
    9125              :                 } // Air cooled
    9126              : 
    9127            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9128            0 :                     SetupOutputVariable(state,
    9129              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9130              :                                         Constant::Units::W,
    9131            0 :                                         cond.ActualFanPower,
    9132              :                                         OutputProcessor::TimeStepType::Zone,
    9133              :                                         OutputProcessor::StoreType::Average,
    9134            0 :                                         cond.Name);
    9135            0 :                     SetupOutputVariable(state,
    9136              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9137              :                                         Constant::Units::J,
    9138            0 :                                         cond.FanElecEnergy,
    9139              :                                         OutputProcessor::TimeStepType::Zone,
    9140              :                                         OutputProcessor::StoreType::Sum,
    9141            0 :                                         cond.Name,
    9142              :                                         Constant::eResource::Electricity,
    9143              :                                         OutputProcessor::Group::Plant,
    9144              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9145              :                                         cond.EndUseSubcategory);
    9146            0 :                     SetupOutputVariable(state,
    9147              :                                         "Refrigeration System Condenser Pump Electricity Rate",
    9148              :                                         Constant::Units::W,
    9149            0 :                                         cond.ActualEvapPumpPower,
    9150              :                                         OutputProcessor::TimeStepType::Zone,
    9151              :                                         OutputProcessor::StoreType::Average,
    9152            0 :                                         cond.Name);
    9153            0 :                     SetupOutputVariable(state,
    9154              :                                         "Refrigeration System Condenser Pump Electricity Energy",
    9155              :                                         Constant::Units::J,
    9156            0 :                                         cond.EvapPumpConsumption,
    9157              :                                         OutputProcessor::TimeStepType::Zone,
    9158              :                                         OutputProcessor::StoreType::Sum,
    9159            0 :                                         cond.Name,
    9160              :                                         Constant::eResource::Electricity,
    9161              :                                         OutputProcessor::Group::Plant,
    9162              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9163              :                                         cond.EndUseSubcategory);
    9164            0 :                     SetupOutputVariable(state,
    9165              :                                         "Refrigeration System Condenser Basin Heater Electricity Rate",
    9166              :                                         Constant::Units::W,
    9167            0 :                                         cond.BasinHeaterPower,
    9168              :                                         OutputProcessor::TimeStepType::Zone,
    9169              :                                         OutputProcessor::StoreType::Average,
    9170            0 :                                         cond.Name);
    9171            0 :                     SetupOutputVariable(state,
    9172              :                                         "Refrigeration System Condenser Basin Heater Electricity Energy",
    9173              :                                         Constant::Units::J,
    9174            0 :                                         cond.BasinHeaterConsumption,
    9175              :                                         OutputProcessor::TimeStepType::Zone,
    9176              :                                         OutputProcessor::StoreType::Sum,
    9177            0 :                                         cond.Name,
    9178              :                                         Constant::eResource::Electricity,
    9179              :                                         OutputProcessor::Group::Plant,
    9180              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9181              :                                         cond.EndUseSubcategory);
    9182            0 :                     SetupOutputVariable(state,
    9183              :                                         "Refrigeration System Condenser Evaporated Water Volume Flow Rate",
    9184              :                                         Constant::Units::m3_s,
    9185            0 :                                         cond.EvapWaterConsumpRate,
    9186              :                                         OutputProcessor::TimeStepType::Zone,
    9187              :                                         OutputProcessor::StoreType::Average,
    9188            0 :                                         cond.Name);
    9189            0 :                     SetupOutputVariable(state,
    9190              :                                         "Refrigeration System Condenser Evaporated Water Volume",
    9191              :                                         Constant::Units::m3,
    9192            0 :                                         cond.EvapWaterConsumption,
    9193              :                                         OutputProcessor::TimeStepType::Zone,
    9194              :                                         OutputProcessor::StoreType::Sum,
    9195            0 :                                         cond.Name,
    9196              :                                         Constant::eResource::Water,
    9197              :                                         OutputProcessor::Group::Plant,
    9198              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9199              :                                         cond.EndUseSubcategory);
    9200              :                 } // Evaporative Condenser Variables
    9201              : 
    9202            0 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9203            0 :                     SetupOutputVariable(state,
    9204              :                                         "Refrigeration System Condenser Water Mass Flow Rate",
    9205              :                                         Constant::Units::kg_s,
    9206            0 :                                         cond.MassFlowRate,
    9207              :                                         OutputProcessor::TimeStepType::System,
    9208              :                                         OutputProcessor::StoreType::Average,
    9209            0 :                                         cond.Name);
    9210              : 
    9211              :                 } // Water-cooled Condenser variables
    9212              :             }     // Condenser%CoilFlag to distinguish HVAC vs Zone time steps
    9213              :         }         // CondNum on DataHeatBalance::NumRefrigCondensers
    9214              : 
    9215            0 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    9216            0 :             for (int subcoolNum = 1; subcoolNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++subcoolNum) {
    9217            0 :                 auto &cooler = Subcooler(subcoolNum);
    9218              :                 // CurrentModuleObject='Refrigeration:Subcooler'
    9219            0 :                 if (cooler.CoilFlag) { // Subcooler serving system with chillers on HVAC time step
    9220            0 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9221            0 :                         SetupOutputVariable(state,
    9222              :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Rate",
    9223              :                                             Constant::Units::W,
    9224            0 :                                             cooler.MechSCTransLoad,
    9225              :                                             OutputProcessor::TimeStepType::Zone,
    9226              :                                             OutputProcessor::StoreType::Average,
    9227            0 :                                             cooler.Name);
    9228            0 :                         SetupOutputVariable(state,
    9229              :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Energy",
    9230              :                                             Constant::Units::J,
    9231            0 :                                             cooler.MechSCTransEnergy,
    9232              :                                             OutputProcessor::TimeStepType::Zone,
    9233              :                                             OutputProcessor::StoreType::Sum,
    9234            0 :                                             cooler.Name);
    9235              :                     }
    9236              :                 } else { // Subcooler on system serving cases and/or walkins
    9237            0 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9238            0 :                         SetupOutputVariable(state,
    9239              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Rate",
    9240              :                                             Constant::Units::W,
    9241            0 :                                             cooler.MechSCTransLoad,
    9242              :                                             OutputProcessor::TimeStepType::System,
    9243              :                                             OutputProcessor::StoreType::Average,
    9244            0 :                                             cooler.Name);
    9245            0 :                         SetupOutputVariable(state,
    9246              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Energy",
    9247              :                                             Constant::Units::J,
    9248            0 :                                             cooler.MechSCTransEnergy,
    9249              :                                             OutputProcessor::TimeStepType::System,
    9250              :                                             OutputProcessor::StoreType::Sum,
    9251            0 :                                             cooler.Name);
    9252              :                     }
    9253              :                 } // Subcoolers on system serving chillers
    9254              :             }     // Subcoolnum on NumSimulationSubcoolers
    9255              :         }         // NumSimulationSubcoolers > 0
    9256              : 
    9257              :     } // NumRefrigSystems > 0
    9258              : 
    9259          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9260              :         // CurrentModuleObject='Refrigeration:TranscriticalSystem'
    9261            0 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++refrigSysNum) {
    9262            0 :             auto &sys = TransSystem(refrigSysNum);
    9263              :             // for both SingleStage and TwoStage systems (medium temperature loads present)
    9264            0 :             SetupOutputVariable(state,
    9265              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Rate",
    9266              :                                 Constant::Units::W,
    9267            0 :                                 sys.TotCompPowerHP,
    9268              :                                 OutputProcessor::TimeStepType::Zone,
    9269              :                                 OutputProcessor::StoreType::Average,
    9270            0 :                                 sys.Name);
    9271            0 :             SetupOutputVariable(state,
    9272              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Energy",
    9273              :                                 Constant::Units::J,
    9274            0 :                                 sys.TotCompElecConsumpHP,
    9275              :                                 OutputProcessor::TimeStepType::Zone,
    9276              :                                 OutputProcessor::StoreType::Sum,
    9277            0 :                                 sys.Name);
    9278            0 :             SetupOutputVariable(state,
    9279              :                                 "Refrigeration Transcritical System Total Compressor Electricity Energy",
    9280              :                                 Constant::Units::J,
    9281            0 :                                 sys.TotCompElecConsump,
    9282              :                                 OutputProcessor::TimeStepType::Zone,
    9283              :                                 OutputProcessor::StoreType::Sum,
    9284            0 :                                 sys.Name);
    9285            0 :             SetupOutputVariable(state,
    9286              :                                 "Refrigeration Transcritical System Average COP",
    9287              :                                 Constant::Units::W_W,
    9288            0 :                                 sys.AverageCompressorCOP,
    9289              :                                 OutputProcessor::TimeStepType::Zone,
    9290              :                                 OutputProcessor::StoreType::Average,
    9291            0 :                                 sys.Name);
    9292            0 :             SetupOutputVariable(state,
    9293              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Rate",
    9294              :                                 Constant::Units::W,
    9295            0 :                                 sys.TotalCoolingLoadMT,
    9296              :                                 OutputProcessor::TimeStepType::Zone,
    9297              :                                 OutputProcessor::StoreType::Average,
    9298            0 :                                 sys.Name);
    9299            0 :             SetupOutputVariable(state,
    9300              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Energy",
    9301              :                                 Constant::Units::J,
    9302            0 :                                 sys.TotalCoolingEnergyMT,
    9303              :                                 OutputProcessor::TimeStepType::Zone,
    9304              :                                 OutputProcessor::StoreType::Sum,
    9305            0 :                                 sys.Name);
    9306            0 :             SetupOutputVariable(state,
    9307              :                                 "Refrigeration Transcritical System Total Cases and Walk Ins Heat Transfer Energy",
    9308              :                                 Constant::Units::J,
    9309            0 :                                 sys.TotalCoolingEnergy,
    9310              :                                 OutputProcessor::TimeStepType::Zone,
    9311              :                                 OutputProcessor::StoreType::Sum,
    9312            0 :                                 sys.Name);
    9313            0 :             SetupOutputVariable(state,
    9314              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Rate",
    9315              :                                 Constant::Units::W,
    9316            0 :                                 sys.PipeHeatLoadMT,
    9317              :                                 OutputProcessor::TimeStepType::Zone,
    9318              :                                 OutputProcessor::StoreType::Average,
    9319            0 :                                 sys.Name);
    9320            0 :             SetupOutputVariable(state,
    9321              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Energy",
    9322              :                                 Constant::Units::J,
    9323            0 :                                 sys.PipeHeatEnergyMT,
    9324              :                                 OutputProcessor::TimeStepType::Zone,
    9325              :                                 OutputProcessor::StoreType::Sum,
    9326            0 :                                 sys.Name);
    9327            0 :             SetupOutputVariable(state,
    9328              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Rate",
    9329              :                                 Constant::Units::W,
    9330            0 :                                 sys.TotCompCapacityHP,
    9331              :                                 OutputProcessor::TimeStepType::Zone,
    9332              :                                 OutputProcessor::StoreType::Average,
    9333            0 :                                 sys.Name);
    9334            0 :             SetupOutputVariable(state,
    9335              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Energy",
    9336              :                                 Constant::Units::J,
    9337            0 :                                 sys.TotCompCoolingEnergyHP,
    9338              :                                 OutputProcessor::TimeStepType::Zone,
    9339              :                                 OutputProcessor::StoreType::Sum,
    9340            0 :                                 sys.Name); // indiv compressors go to meter, not system sum
    9341            0 :             SetupOutputVariable(state,
    9342              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Rate",
    9343              :                                 Constant::Units::W,
    9344            0 :                                 sys.NetHeatRejectLoad,
    9345              :                                 OutputProcessor::TimeStepType::Zone,
    9346              :                                 OutputProcessor::StoreType::Average,
    9347            0 :                                 sys.Name);
    9348            0 :             SetupOutputVariable(state,
    9349              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Energy",
    9350              :                                 Constant::Units::J,
    9351            0 :                                 sys.NetHeatRejectEnergy,
    9352              :                                 OutputProcessor::TimeStepType::Zone,
    9353              :                                 OutputProcessor::StoreType::Sum,
    9354            0 :                                 sys.Name);
    9355            0 :             SetupOutputVariable(state,
    9356              :                                 "Refrigeration Transcritical System Estimated Refrigerant Inventory Mass",
    9357              :                                 Constant::Units::kg,
    9358            0 :                                 sys.RefInventory,
    9359              :                                 OutputProcessor::TimeStepType::Zone,
    9360              :                                 OutputProcessor::StoreType::Average,
    9361            0 :                                 sys.Name);
    9362            0 :             SetupOutputVariable(state,
    9363              :                                 "Refrigeration Transcritical System Refrigerant Mass Flow Rate",
    9364              :                                 Constant::Units::kg_s,
    9365            0 :                                 sys.RefMassFlowComps,
    9366              :                                 OutputProcessor::TimeStepType::Zone,
    9367              :                                 OutputProcessor::StoreType::Average,
    9368            0 :                                 sys.Name);
    9369            0 :             SetupOutputVariable(state,
    9370              :                                 "Refrigeration Transcritical System Medium Temperature Evaporating Temperature",
    9371              :                                 Constant::Units::C,
    9372            0 :                                 sys.TEvapNeededMT,
    9373              :                                 OutputProcessor::TimeStepType::Zone,
    9374              :                                 OutputProcessor::StoreType::Average,
    9375            0 :                                 sys.Name);
    9376            0 :             SetupOutputVariable(state,
    9377              :                                 "Refrigeration Transcritical System Medium Temperature Suction Temperature",
    9378              :                                 Constant::Units::C,
    9379            0 :                                 sys.TCompInHP,
    9380              :                                 OutputProcessor::TimeStepType::Zone,
    9381              :                                 OutputProcessor::StoreType::Average,
    9382            0 :                                 sys.Name);
    9383            0 :             if (sys.transSysType == TransSysType::TwoStage) { // for TwoStage system only (low temperature loads present)
    9384            0 :                 SetupOutputVariable(state,
    9385              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Rate",
    9386              :                                     Constant::Units::W,
    9387            0 :                                     sys.TotCompPowerLP,
    9388              :                                     OutputProcessor::TimeStepType::Zone,
    9389              :                                     OutputProcessor::StoreType::Average,
    9390            0 :                                     sys.Name);
    9391            0 :                 SetupOutputVariable(state,
    9392              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Energy",
    9393              :                                     Constant::Units::J,
    9394            0 :                                     sys.TotCompElecConsumpLP,
    9395              :                                     OutputProcessor::TimeStepType::Zone,
    9396              :                                     OutputProcessor::StoreType::Sum,
    9397            0 :                                     sys.Name);
    9398            0 :                 SetupOutputVariable(state,
    9399              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Rate",
    9400              :                                     Constant::Units::W,
    9401            0 :                                     sys.TotalCoolingLoadLT,
    9402              :                                     OutputProcessor::TimeStepType::Zone,
    9403              :                                     OutputProcessor::StoreType::Average,
    9404            0 :                                     sys.Name);
    9405            0 :                 SetupOutputVariable(state,
    9406              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Energy",
    9407              :                                     Constant::Units::J,
    9408            0 :                                     sys.TotalCoolingEnergyLT,
    9409              :                                     OutputProcessor::TimeStepType::Zone,
    9410              :                                     OutputProcessor::StoreType::Sum,
    9411            0 :                                     sys.Name);
    9412            0 :                 SetupOutputVariable(state,
    9413              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Rate",
    9414              :                                     Constant::Units::W,
    9415            0 :                                     sys.PipeHeatLoadLT,
    9416              :                                     OutputProcessor::TimeStepType::Zone,
    9417              :                                     OutputProcessor::StoreType::Average,
    9418            0 :                                     sys.Name);
    9419            0 :                 SetupOutputVariable(state,
    9420              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Energy",
    9421              :                                     Constant::Units::J,
    9422            0 :                                     sys.PipeHeatEnergyLT,
    9423              :                                     OutputProcessor::TimeStepType::Zone,
    9424              :                                     OutputProcessor::StoreType::Sum,
    9425            0 :                                     sys.Name);
    9426            0 :                 SetupOutputVariable(state,
    9427              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Rate",
    9428              :                                     Constant::Units::W,
    9429            0 :                                     sys.TotCompCapacityLP,
    9430              :                                     OutputProcessor::TimeStepType::Zone,
    9431              :                                     OutputProcessor::StoreType::Average,
    9432            0 :                                     sys.Name);
    9433            0 :                 SetupOutputVariable(state,
    9434              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Energy",
    9435              :                                     Constant::Units::J,
    9436            0 :                                     sys.TotCompCoolingEnergyLP,
    9437              :                                     OutputProcessor::TimeStepType::Zone,
    9438              :                                     OutputProcessor::StoreType::Sum,
    9439            0 :                                     sys.Name); // indiv compressors go to meter, not system sum
    9440            0 :                 SetupOutputVariable(state,
    9441              :                                     "Refrigeration Transcritical System Low Temperature Evaporating Temperature",
    9442              :                                     Constant::Units::C,
    9443            0 :                                     sys.TEvapNeededLT,
    9444              :                                     OutputProcessor::TimeStepType::Zone,
    9445              :                                     OutputProcessor::StoreType::Average,
    9446            0 :                                     sys.Name);
    9447            0 :                 SetupOutputVariable(state,
    9448              :                                     "Refrigeration Transcritical System Low Temperature Suction Temperature",
    9449              :                                     Constant::Units::C,
    9450            0 :                                     sys.TCompInLP,
    9451              :                                     OutputProcessor::TimeStepType::Zone,
    9452              :                                     OutputProcessor::StoreType::Average,
    9453            0 :                                     sys.Name);
    9454              :             } // (sys%TransSysType == 2)
    9455              : 
    9456            0 :             if (sys.SystemRejectHeatToZone) {
    9457            0 :                 if (GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum > 0)
    9458            0 :                     SetupZoneInternalGain(state,
    9459            0 :                                           GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum,
    9460              :                                           sys.Name,
    9461              :                                           DataHeatBalance::IntGainType::RefrigerationTransSysAirCooledGasCooler,
    9462              :                                           &sys.NetHeatRejectLoad);
    9463              :             } // (sys%SystemRejectHeatToZone)
    9464            0 :             if (sys.SuctionPipeActualZoneNumMT > 0) {
    9465            0 :                 SetupZoneInternalGain(state,
    9466              :                                       sys.SuctionPipeActualZoneNumMT,
    9467              :                                       sys.Name,
    9468              :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeMT,
    9469              :                                       &sys.PipeHeatLoadMT);
    9470              :             } // sys%SuctionPipeActualZoneNumMT > 0
    9471            0 :             if (sys.SuctionPipeActualZoneNumLT > 0) {
    9472            0 :                 SetupZoneInternalGain(state,
    9473              :                                       sys.SuctionPipeActualZoneNumLT,
    9474              :                                       sys.Name,
    9475              :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeLT,
    9476              :                                       &sys.PipeHeatLoadLT);
    9477              :             } // sys%SuctionPipeActualZoneNumLT > 0
    9478              : 
    9479              :             // Report Compressor ENERGY here, not on system level for meters.
    9480              :             // LP compressors
    9481            0 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsLP; ++compIndex) {
    9482            0 :                 int compNum = sys.CompressorNumLP(compIndex);
    9483              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9484            0 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9485            0 :                     SetupOutputVariable(state,
    9486              :                                         "Refrigeration Compressor Electricity Rate",
    9487              :                                         Constant::Units::W,
    9488            0 :                                         Compressor(compNum).Power,
    9489              :                                         OutputProcessor::TimeStepType::Zone,
    9490              :                                         OutputProcessor::StoreType::Average,
    9491            0 :                                         Compressor(compNum).Name);
    9492            0 :                     SetupOutputVariable(state,
    9493              :                                         "Refrigeration Compressor Electricity Energy",
    9494              :                                         Constant::Units::J,
    9495            0 :                                         Compressor(compNum).ElecConsumption,
    9496              :                                         OutputProcessor::TimeStepType::Zone,
    9497              :                                         OutputProcessor::StoreType::Sum,
    9498            0 :                                         Compressor(compNum).Name,
    9499              :                                         Constant::eResource::Electricity,
    9500              :                                         OutputProcessor::Group::Plant,
    9501              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9502            0 :                                         Compressor(compNum).EndUseSubcategory);
    9503            0 :                     SetupOutputVariable(state,
    9504              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9505              :                                         Constant::Units::W,
    9506            0 :                                         Compressor(compNum).Capacity,
    9507              :                                         OutputProcessor::TimeStepType::Zone,
    9508              :                                         OutputProcessor::StoreType::Average,
    9509            0 :                                         Compressor(compNum).Name);
    9510            0 :                     SetupOutputVariable(state,
    9511              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9512              :                                         Constant::Units::J,
    9513            0 :                                         Compressor(compNum).CoolingEnergy,
    9514              :                                         OutputProcessor::TimeStepType::Zone,
    9515              :                                         OutputProcessor::StoreType::Sum,
    9516            0 :                                         Compressor(compNum).Name);
    9517            0 :                     SetupOutputVariable(state,
    9518              :                                         "Refrigeration Compressor Runtime Fraction",
    9519              :                                         Constant::Units::None,
    9520            0 :                                         Compressor(compNum).LoadFactor,
    9521              :                                         OutputProcessor::TimeStepType::Zone,
    9522              :                                         OutputProcessor::StoreType::Average,
    9523            0 :                                         Compressor(compNum).Name);
    9524              :                 } // NumSysAttach
    9525              :             }     // sys%NumCompressorsLP
    9526              : 
    9527              :             // HP compressors
    9528            0 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsHP; ++compIndex) {
    9529            0 :                 int compNum = sys.CompressorNumHP(compIndex);
    9530              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9531            0 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9532            0 :                     SetupOutputVariable(state,
    9533              :                                         "Refrigeration Compressor Electricity Rate",
    9534              :                                         Constant::Units::W,
    9535            0 :                                         Compressor(compNum).Power,
    9536              :                                         OutputProcessor::TimeStepType::Zone,
    9537              :                                         OutputProcessor::StoreType::Average,
    9538            0 :                                         Compressor(compNum).Name);
    9539            0 :                     SetupOutputVariable(state,
    9540              :                                         "Refrigeration Compressor Electricity Energy",
    9541              :                                         Constant::Units::J,
    9542            0 :                                         Compressor(compNum).ElecConsumption,
    9543              :                                         OutputProcessor::TimeStepType::Zone,
    9544              :                                         OutputProcessor::StoreType::Sum,
    9545            0 :                                         Compressor(compNum).Name,
    9546              :                                         Constant::eResource::Electricity,
    9547              :                                         OutputProcessor::Group::Plant,
    9548              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9549            0 :                                         Compressor(compNum).EndUseSubcategory);
    9550            0 :                     SetupOutputVariable(state,
    9551              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9552              :                                         Constant::Units::W,
    9553            0 :                                         Compressor(compNum).Capacity,
    9554              :                                         OutputProcessor::TimeStepType::Zone,
    9555              :                                         OutputProcessor::StoreType::Average,
    9556            0 :                                         Compressor(compNum).Name);
    9557            0 :                     SetupOutputVariable(state,
    9558              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9559              :                                         Constant::Units::J,
    9560            0 :                                         Compressor(compNum).CoolingEnergy,
    9561              :                                         OutputProcessor::TimeStepType::Zone,
    9562              :                                         OutputProcessor::StoreType::Sum,
    9563            0 :                                         Compressor(compNum).Name);
    9564            0 :                     SetupOutputVariable(state,
    9565              :                                         "Refrigeration Compressor Runtime Fraction",
    9566              :                                         Constant::Units::None,
    9567            0 :                                         Compressor(compNum).LoadFactor,
    9568              :                                         OutputProcessor::TimeStepType::Zone,
    9569              :                                         OutputProcessor::StoreType::Average,
    9570            0 :                                         Compressor(compNum).Name);
    9571              :                 } // NumSysAttach
    9572              :             }     // sys%NumCompressorsHP
    9573              : 
    9574              :         } // NumTransRefrigSystems
    9575              :     }     // (NumTransRefrigSystems > 0)
    9576              : 
    9577          150 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    9578            0 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    9579            0 :             auto &cooler = GasCooler(GCNum);
    9580              :             // CurrentModuleObject='Refrigeration:GasCooler:AirCooled'
    9581            0 :             SetupOutputVariable(state,
    9582              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Rate",
    9583              :                                 Constant::Units::W,
    9584            0 :                                 cooler.GasCoolerLoad,
    9585              :                                 OutputProcessor::TimeStepType::Zone,
    9586              :                                 OutputProcessor::StoreType::Average,
    9587            0 :                                 cooler.Name);
    9588            0 :             SetupOutputVariable(state,
    9589              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Energy",
    9590              :                                 Constant::Units::J,
    9591            0 :                                 cooler.GasCoolerEnergy,
    9592              :                                 OutputProcessor::TimeStepType::Zone,
    9593              :                                 OutputProcessor::StoreType::Sum,
    9594            0 :                                 cooler.Name);
    9595            0 :             SetupOutputVariable(state,
    9596              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Rate",
    9597              :                                 Constant::Units::W,
    9598            0 :                                 cooler.ActualFanPower,
    9599              :                                 OutputProcessor::TimeStepType::Zone,
    9600              :                                 OutputProcessor::StoreType::Average,
    9601            0 :                                 cooler.Name);
    9602            0 :             SetupOutputVariable(state,
    9603              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Energy",
    9604              :                                 Constant::Units::J,
    9605            0 :                                 cooler.FanElecEnergy,
    9606              :                                 OutputProcessor::TimeStepType::Zone,
    9607              :                                 OutputProcessor::StoreType::Sum,
    9608            0 :                                 cooler.Name,
    9609              :                                 Constant::eResource::Electricity,
    9610              :                                 OutputProcessor::Group::Plant,
    9611              :                                 OutputProcessor::EndUseCat::Refrigeration,
    9612              :                                 cooler.EndUseSubcategory);
    9613            0 :             SetupOutputVariable(state,
    9614              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Temperature",
    9615              :                                 Constant::Units::C,
    9616            0 :                                 cooler.TGasCoolerOut,
    9617              :                                 OutputProcessor::TimeStepType::Zone,
    9618              :                                 OutputProcessor::StoreType::Average,
    9619            0 :                                 cooler.Name);
    9620            0 :             SetupOutputVariable(state,
    9621              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Pressure",
    9622              :                                 Constant::Units::Pa,
    9623            0 :                                 cooler.PGasCoolerOut,
    9624              :                                 OutputProcessor::TimeStepType::Zone,
    9625              :                                 OutputProcessor::StoreType::Average,
    9626            0 :                                 cooler.Name);
    9627            0 :             SetupOutputVariable(state,
    9628              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Rate",
    9629              :                                 Constant::Units::W,
    9630            0 :                                 cooler.InternalHeatRecoveredLoad,
    9631              :                                 OutputProcessor::TimeStepType::Zone,
    9632              :                                 OutputProcessor::StoreType::Average,
    9633            0 :                                 cooler.Name);
    9634            0 :             SetupOutputVariable(state,
    9635              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Energy",
    9636              :                                 Constant::Units::J,
    9637            0 :                                 cooler.InternalEnergyRecovered,
    9638              :                                 OutputProcessor::TimeStepType::Zone,
    9639              :                                 OutputProcessor::StoreType::Sum,
    9640            0 :                                 cooler.Name);
    9641              :         } // GCNum on NumSimulationGasCooler
    9642              :     }     // (NumSimulationGasCooler >0)
    9643          150 : }
    9644              : 
    9645            5 : void InitRefrigeration(EnergyPlusData &state)
    9646              : {
    9647              :     // SUBROUTINE INFORMATION:
    9648              :     //       AUTHOR         Richard Raustad, FSEC
    9649              :     //       DATE WRITTEN   Oct/Nov 2004
    9650              :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008
    9651              :     //       RE-ENGINEERED  na
    9652              : 
    9653              :     // PURPOSE OF THIS SUBROUTINE:
    9654              :     // Initialize (zero) global variables before simulating compressor racks and refrigerated cases
    9655              :     // Several variables in this module are accumulative.  For example, unmet compressor loads are carried over
    9656              :     // to the next time step. Ice loads are accumulated until melted by a defrost.  Because this module can be
    9657              :     // called multiple times during any single time step, these summations need to be saved ONLY on the last time
    9658              :     // through any given time step.
    9659              : 
    9660              :     // It is necessary to decrease the condenser load by the amount of heat used elsewhere
    9661              :     //   via desuperheating water heaters and heating coils.
    9662              :     //   Because the refrigeration system is solved before the HVAC time step loops, the
    9663              :     //   refrigeration system must use the values lagged from the previous time step. In
    9664              :     //   terms of energy, this should balance out and is preferable to not making the correction,
    9665              :     //   in which case the condenser cooling water/air/fan energy are charged with energy
    9666              :     //   loads that have been accounted elsewhere.  For consistency, the lagged value must be used,
    9667              :     //   even if the Zone time step is repeated.  Therefore, the lagged variables are saved
    9668              :     //   here for use during successive iterations of same zone/load time step.
    9669              : 
    9670              :     // METHODOLOGY EMPLOYED:
    9671              :     // Global variables for Case Credit are located in DataHeatBalance. To Zone variables are used in the Air Heat
    9672              :     // Balance in ZoneTempPredictorCorrector to calculate the zone load. To HVAC variables are used in
    9673              :     // ZoneEquipmentManager to add the portion of case credits attributed to the HVAC system to the zone return air node.
    9674              : 
    9675              :     // Because we can't know apriori whether or not the time step will be repeated, we save the most recent
    9676              :     // addition/subtraction to/from each accumulating variable.  If the time step is repeated,
    9677              :     // this most recent addition/subtraction is reversed before the rest of the refrigeration simulation begins.
    9678              : 
    9679              :     // Used to adjust accumulative variables when time step is repeated
    9680              : 
    9681            5 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
    9682            5 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
    9683            5 :     auto &System = state.dataRefrigCase->System;
    9684            5 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
    9685            5 :     auto &Condenser = state.dataRefrigCase->Condenser;
    9686            5 :     auto &Compressor = state.dataRefrigCase->Compressor;
    9687            5 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
    9688            5 :     auto &Secondary = state.dataRefrigCase->Secondary;
    9689            5 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
    9690            5 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
    9691            5 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
    9692            5 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
    9693              : 
    9694              :     // Zero display case, air-coil, and walk-in cooler credits (summed by zone)
    9695              :     // to 0 each zone or sys time step
    9696              :     // These 'casecredit' variables are also used to transfer energy from zone-located
    9697              :     // compressor-rack condenser heat rejection, heat absorption by distribution piping,
    9698              :     // suction piping, and receiver shells to zone
    9699            5 :     if (state.dataGlobal->NumOfZones > 0) {
    9700            5 :         if (state.dataRefrigCase->UseSysTimeStep) {
    9701            0 :             for (int i = CoilSysCredit.l(), e = CoilSysCredit.u(); i <= e; ++i) {
    9702            0 :                 CoilSysCredit(i).reset();
    9703              :             }
    9704              :         } // UseSysTimeStep = true
    9705              : 
    9706              :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is false
    9707           10 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
    9708            5 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
    9709              : 
    9710           10 :             for (auto &credit : state.dataHeatBal->RefrigCaseCredit) {
    9711            5 :                 credit.reset();
    9712              :             }
    9713           10 :             for (auto &zoneReport : CaseWIZoneReport) {
    9714            5 :                 zoneReport.reset();
    9715              :             }
    9716              :         }
    9717              :     }
    9718              : 
    9719            5 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    9720              :         // RefrigCase ALLOCATED to NumSimulationCases
    9721            6 :         for (auto &refrig : RefrigCase) {
    9722            3 :             refrig.reset_init();
    9723              :         }
    9724              :     } // NumSimulationCases
    9725              : 
    9726            5 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    9727              :         // WalkIn ALLOCATED to NumSimulationWalkIns
    9728            6 :         for (int i = WalkIn.l(), e = WalkIn.u(); i <= e; ++i) {
    9729            3 :             WalkIn(i).reset_init();
    9730              :         }
    9731              :     }
    9732              : 
    9733            5 :     if (state.dataRefrigCase->HaveChillers) {
    9734              :         // HaveChillers is TRUE when NumSimulationRefrigAirChillers > 0
    9735              :         // WarehouseCoil ALLOCATED to NumSimulationRefrigAirChillers
    9736            0 :         for (int i = WarehouseCoil.l(), e = WarehouseCoil.u(); i <= e; ++i) {
    9737            0 :             WarehouseCoil(i).reset_init();
    9738              :         }
    9739              :     }
    9740              : 
    9741            5 :     if (state.dataRefrigCase->HaveRefrigRacks) {
    9742              :         // HaveRefrigRacks TRUE when NumRefrigeratedRacks > 0
    9743              :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
    9744           10 :         for (int i = RefrigRack.l(), e = RefrigRack.u(); i <= e; ++i) {
    9745            5 :             RefrigRack(i).reset_init();
    9746              :         }
    9747           10 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack)
    9748            5 :             e.AvailCapacity = 0.0;
    9749              :         // Note don't reset basin heat to zero when no load because heater would remain on
    9750              :         // RefrigRack.BasinHeaterPower = 0.0;
    9751              :         // RefrigRack.BasinHeaterConsumption = 0.0;
    9752              :     }
    9753              : 
    9754            5 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    9755              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
    9756            0 :         for (int i = Condenser.l(), e = Condenser.u(); i <= e; ++i) {
    9757            0 :             Condenser(i).reset_init();
    9758              :         }
    9759              :         // N don't reset basin heat to zero when no load because heater would remain on
    9760            0 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
    9761            0 :             e.AvailCapacity = 0.0;
    9762            0 :             e.AvailTemperature = 0.0;
    9763              :         }
    9764              :     }
    9765              : 
    9766            5 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    9767              :         // GasCooler ALLOCATED to NumSimulationGasCooler
    9768            0 :         for (int i = GasCooler.l(), e = GasCooler.u(); i <= e; ++i) {
    9769            0 :             GasCooler(i).reset_init();
    9770              :         }
    9771              :     }
    9772              : 
    9773            5 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    9774              :         // Compressor ALLOCATED to NumSimulationCompressors
    9775            0 :         for (int i = Compressor.l(), e = Compressor.u(); i <= e; ++i) {
    9776            0 :             Compressor(i).reset_init();
    9777              :         }
    9778              :     }
    9779              : 
    9780            5 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
    9781              :         // HaveDetailedRefrig is TRUE when NumRefrigSystems > 0
    9782              :         // System is ALLOCATED to NumRefrigSystems
    9783            0 :         for (int i = System.l(), e = System.u(); i <= e; ++i) {
    9784            0 :             System(i).reset_init();
    9785              :         }
    9786              :     }
    9787              : 
    9788            5 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
    9789              :         // HaveDetailedTransRefrig is TRUE when NumTransRefrigSystems > 0
    9790              :         // TransSystem is ALLOCATED to NumTransRefrigSystems
    9791            0 :         for (int i = TransSystem.l(), e = TransSystem.u(); i <= e; ++i) {
    9792            0 :             TransSystem(i).reset_init();
    9793              :         }
    9794              :     }
    9795              : 
    9796            5 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    9797              :         // Secondary is ALLOCATED to NumSimulationSecondarySystems
    9798            0 :         for (int i = Secondary.l(), e = Secondary.u(); i <= e; ++i) {
    9799            0 :             Secondary(i).reset_init();
    9800              :         }
    9801              :     }
    9802              : 
    9803              :     // Accumulative and carry-over variables are not zeroed at start of each time step, only at beginning of environment
    9804            5 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag) {
    9805            0 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
    9806            0 :             for (int i = RefrigCase.l(), e = RefrigCase.u(); i <= e; ++i) {
    9807            0 :                 RefrigCase(i).reset_init_accum();
    9808              :             }
    9809              :         }
    9810            0 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
    9811            0 :             for (auto &e : System)
    9812            0 :                 e.UnmetEnergy = 0.0;
    9813              :         }
    9814            0 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    9815            0 :             for (auto &e : WalkIn) {
    9816            0 :                 e.KgFrost = 0.0;
    9817            0 :                 e.StoredEnergy = 0.0;
    9818              :             }
    9819            0 :             for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
    9820            0 :                 WalkIn(walkInID).IceTemp = WalkIn(walkInID).TEvapDesign;
    9821              :             }
    9822              :         }
    9823            0 :         if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    9824            0 :             for (auto &e : WarehouseCoil) {
    9825            0 :                 e.KgFrost = 0.0;
    9826            0 :                 e.KgFrostSaved = 0.0;
    9827              :             }
    9828            0 :             for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
    9829            0 :                 WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).TEvapDesign;
    9830            0 :                 WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).TEvapDesign;
    9831              :             }
    9832              :         }
    9833            0 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    9834            0 :             for (auto &e : Secondary)
    9835            0 :                 e.UnmetEnergy = 0.0;
    9836              :         }
    9837            0 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    9838            0 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
    9839            0 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
    9840            0 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
    9841              :             }
    9842            0 :             for (auto &e : RefrigRack) {
    9843            0 :                 e.LaggedUsedWaterHeater = 0.0;
    9844            0 :                 e.LaggedUsedHVACCoil = 0.0;
    9845              :             }
    9846              :         }
    9847            0 :         if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    9848            0 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
    9849            0 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
    9850            0 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
    9851              :             }
    9852            0 :             for (auto &e : Condenser) {
    9853            0 :                 e.LaggedUsedWaterHeater = 0.0;
    9854            0 :                 e.LaggedUsedHVACCoil = 0.0;
    9855              :             }
    9856              :         }
    9857            0 :         for (int systemId = 1; systemId <= state.dataRefrigCase->NumRefrigSystems; ++systemId) {
    9858            0 :             if (allocated(System(systemId).MechSCLoad)) System(systemId).MechSCLoad = 0.0;
    9859            0 :             System(systemId).LSHXTrans = 0.0;
    9860            0 :             System(systemId).LSHXTransEnergy = 0.0;
    9861              :         }
    9862              : 
    9863            0 :         if (state.dataGlobal->TimeStepsInHour > 0.0) state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->TimeStepsInHour);
    9864            0 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = false;
    9865              : 
    9866              :     } // ( DataGlobals::BeginEnvrnFlag && MyBeginEnvrnFlag )
    9867              : 
    9868            5 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = true;
    9869              : 
    9870              :     // Avoid multiplying accumulation if go through zone/load time step more than once.
    9871            5 :     if (!state.dataGlobal->WarmupFlag) { // because no accumulation is done during warm up
    9872              :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
    9873           10 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
    9874            5 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
    9875              :             // Used to determine whether the zone time step is a repetition
    9876            5 :             Real64 MyCurrentTime = (state.dataGlobal->HourOfDay - 1) + state.dataGlobal->TimeStep * state.dataRefrigCase->TimeStepFraction;
    9877            5 :             if (std::abs(MyCurrentTime - state.dataRefrigCase->MyCurrentTimeSaved) < MySmallNumber) {
    9878              :                 // If the time step is repeated, need to return to correct values at start of time step
    9879            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    9880            0 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
    9881            0 :                         RefrigCase(caseID).DefrostEnergy = RefrigCase(caseID).DefrostEnergySaved;
    9882            0 :                         RefrigCase(caseID).StockingEnergy = RefrigCase(caseID).StockingEnergySaved;
    9883            0 :                         RefrigCase(caseID).WarmEnvEnergy = RefrigCase(caseID).WarmEnvEnergySaved;
    9884            0 :                         RefrigCase(caseID).KgFrost = RefrigCase(caseID).KgFrostSaved;
    9885            0 :                         RefrigCase(caseID).StoredEnergy = RefrigCase(caseID).StoredEnergySaved;
    9886              :                     } // CaseID
    9887              :                 }     // NumSimulationCases
    9888            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    9889            0 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
    9890            0 :                         WalkIn(walkInID).KgFrost = WalkIn(walkInID).KgFrostSaved;
    9891            0 :                         WalkIn(walkInID).StoredEnergy = WalkIn(walkInID).StoredEnergySaved;
    9892            0 :                         WalkIn(walkInID).IceTemp = WalkIn(walkInID).IceTempSaved;
    9893              :                     }
    9894              :                 }
    9895            0 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
    9896            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
    9897            0 :                         if (System(systemID).CoilFlag) continue;
    9898            0 :                         System(systemID).UnmetEnergy = System(systemID).UnmetEnergySaved;
    9899              :                     }
    9900              :                 }
    9901            0 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9902            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
    9903            0 :                         TransSystem(systemID).UnmetEnergyMT = TransSystem(systemID).UnmetEnergySavedMT;
    9904            0 :                         TransSystem(systemID).UnmetEnergyLT = TransSystem(systemID).UnmetEnergySavedLT;
    9905              :                     }
    9906              :                 }
    9907            0 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    9908            0 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
    9909            0 :                         if (Secondary(secondID).CoilFlag) continue;
    9910            0 :                         Secondary(secondID).UnmetEnergy = Secondary(secondID).UnmetEnergySaved;
    9911              :                     }
    9912              :                 }
    9913              : 
    9914              :             } else {
    9915              :                 // First time through this Zone time step, so set saved values to those in place at start of this time step
    9916            5 :                 state.dataRefrigCase->MyCurrentTimeSaved = MyCurrentTime;
    9917            5 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    9918            6 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
    9919            3 :                         RefrigCase(caseID).DefrostEnergySaved = RefrigCase(caseID).DefrostEnergy;
    9920            3 :                         RefrigCase(caseID).StockingEnergySaved = RefrigCase(caseID).StockingEnergy;
    9921            3 :                         RefrigCase(caseID).WarmEnvEnergySaved = RefrigCase(caseID).WarmEnvEnergy;
    9922            3 :                         RefrigCase(caseID).KgFrostSaved = RefrigCase(caseID).KgFrost;
    9923            3 :                         RefrigCase(caseID).StoredEnergySaved = RefrigCase(caseID).StoredEnergy;
    9924              :                     } // caseid
    9925              :                 }     // numsimulationcases
    9926            5 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    9927            6 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
    9928            3 :                         WalkIn(walkInID).KgFrostSaved = WalkIn(walkInID).KgFrost;
    9929            3 :                         WalkIn(walkInID).StoredEnergySaved = WalkIn(walkInID).StoredEnergy;
    9930            3 :                         WalkIn(walkInID).IceTempSaved = WalkIn(walkInID).IceTemp;
    9931              :                     }
    9932              :                 }
    9933            5 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
    9934            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
    9935            0 :                         if (System(systemID).CoilFlag) continue;
    9936            0 :                         System(systemID).UnmetEnergySaved = System(systemID).UnmetEnergy;
    9937              :                     }
    9938              :                 }
    9939            5 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9940            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
    9941            0 :                         TransSystem(systemID).UnmetEnergySavedMT = TransSystem(systemID).UnmetEnergyMT;
    9942            0 :                         TransSystem(systemID).UnmetEnergySavedLT = TransSystem(systemID).UnmetEnergyLT;
    9943              :                     }
    9944              :                 }
    9945            5 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    9946            0 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
    9947            0 :                         if (Secondary(secondID).CoilFlag) continue;
    9948            0 :                         Secondary(secondID).UnmetEnergySaved = Secondary(secondID).UnmetEnergy;
    9949              :                     }
    9950              :                 }
    9951              :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
    9952            5 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
    9953           10 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
    9954           10 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
    9955            5 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
    9956            5 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
    9957            5 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
    9958              :                     }
    9959              :                 }
    9960            5 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
    9961            0 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
    9962            0 :                         Condenser(ICond).LaggedUsedHVACCoil =
    9963            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
    9964            0 :                         Condenser(ICond).LaggedUsedWaterHeater =
    9965            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
    9966              :                     }
    9967              :                 }
    9968              :             } // repeating same time step
    9969              : 
    9970              :         } else { // using UseSysTimeStep as a flag for a chiller system
    9971              : 
    9972              :             // Used to determine whether the system time step is a repetition
    9973            0 :             Real64 MyStepStartTime = state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed;
    9974            0 :             if (std::abs(MyStepStartTime - state.dataRefrigCase->MyStepStartTimeSaved) < MySmallNumber) {
    9975              :                 // If the time step is repeated, need to return to correct values at start of time step
    9976            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    9977            0 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
    9978            0 :                         WarehouseCoil(coilID).KgFrost = WarehouseCoil(coilID).KgFrostSaved;
    9979            0 :                         WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).IceTempSaved;
    9980              :                     }
    9981              :                 }
    9982              :             } else { // First time through this system time step or hvac loop,
    9983              :                 // so set saved values to those in place at start of this time step
    9984            0 :                 state.dataRefrigCase->MyStepStartTimeSaved = MyStepStartTime;
    9985            0 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    9986            0 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
    9987            0 :                         WarehouseCoil(coilID).KgFrostSaved = WarehouseCoil(coilID).KgFrost;
    9988            0 :                         WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).IceTemp;
    9989              :                     }
    9990              :                 }
    9991              :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
    9992            0 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
    9993            0 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
    9994            0 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
    9995            0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
    9996            0 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
    9997            0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
    9998              :                     }
    9999              :                 }
   10000            0 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10001            0 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10002            0 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10003            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10004            0 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10005            0 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10006              :                     }
   10007              :                 }
   10008              :             } // if first time
   10009              :         }     //(.NOT. UseSysTimeStep)
   10010              : 
   10011              :     } // warm up flag
   10012              : 
   10013            5 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
   10014            0 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10015            0 :             for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10016            0 :                 if (System(systemID).EMSOverrideOnTCondenseMin) {
   10017            0 :                     System(systemID).TCondenseMin = System(systemID).EMSOverrideValueTCondenseMin;
   10018              :                 } else {
   10019            0 :                     System(systemID).TCondenseMin = System(systemID).TCondenseMinInput;
   10020              :                 }
   10021              :             }
   10022              :         }
   10023              :     }
   10024            5 : }
   10025              : 
   10026            0 : void InitRefrigerationPlantConnections(EnergyPlusData &state)
   10027              : {
   10028              : 
   10029              :     // SUBROUTINE INFORMATION:
   10030              :     //       AUTHOR         B. Griffith
   10031              :     //       DATE WRITTEN   Dec 2010
   10032              :     //       MODIFIED       na
   10033              :     //       RE-ENGINEERED  na
   10034              : 
   10035              :     // PURPOSE OF THIS SUBROUTINE:
   10036              :     // do inits that should only occur when component model routines
   10037              :     // are entered from plant, for water cooled Condensers and Refrigeration Racks
   10038              : 
   10039              :     static constexpr std::string_view RoutineName = "InitRefrigerationPlantConnections";
   10040              : 
   10041            0 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10042            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10043              : 
   10044              :     // initialize plant topology information, if applicable
   10045            0 :     if (state.dataRefrigCase->MyReferPlantScanFlag && allocated(state.dataPlnt->PlantLoop)) {
   10046            0 :         for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10047            0 :             if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10048              : 
   10049            0 :             bool errFlag = false;
   10050            0 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10051            0 :                                                     Condenser(RefCondLoop).Name,
   10052              :                                                     DataPlant::PlantEquipmentType::RefrigSystemWaterCondenser,
   10053            0 :                                                     Condenser(RefCondLoop).plantLoc,
   10054              :                                                     errFlag,
   10055              :                                                     _,
   10056              :                                                     _,
   10057              :                                                     _,
   10058              :                                                     _,
   10059              :                                                     _);
   10060            0 :             if (errFlag) {
   10061            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10062              :             }
   10063              : 
   10064            0 :             Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10065              : 
   10066            0 :             if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10067            0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10068            0 :             } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10069            0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10070              :             }
   10071              :         }
   10072              : 
   10073            0 :         for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10074            0 :             if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10075              : 
   10076            0 :             bool errFlag = false;
   10077            0 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10078            0 :                                                     RefrigRack(RefCompRackLoop).Name,
   10079              :                                                     DataPlant::PlantEquipmentType::RefrigerationWaterCoolRack,
   10080            0 :                                                     RefrigRack(RefCompRackLoop).plantLoc,
   10081              :                                                     errFlag,
   10082              :                                                     _,
   10083              :                                                     _,
   10084              :                                                     _,
   10085              :                                                     _,
   10086              :                                                     _);
   10087            0 :             if (errFlag) {
   10088            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10089              :             }
   10090              : 
   10091            0 :             Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10092              : 
   10093            0 :             if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10094            0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10095            0 :             } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10096            0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10097              :             }
   10098              :         }
   10099              : 
   10100            0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10101            0 :     } else if (state.dataRefrigCase->MyReferPlantScanFlag && !state.dataGlobal->AnyPlantInModel) {
   10102            0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10103              :     }
   10104              : 
   10105            0 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag) {
   10106              : 
   10107              :         // do plant inits, if applicable
   10108            0 :         if (!state.dataRefrigCase->MyReferPlantScanFlag) {
   10109            0 :             for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10110            0 :                 if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10111              : 
   10112            0 :                 Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10113              : 
   10114            0 :                 if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10115            0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10116            0 :                 } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10117            0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10118              :                 }
   10119              : 
   10120            0 :                 PlantUtilities::InitComponentNodes(
   10121            0 :                     state, 0.0, Condenser(RefCondLoop).MassFlowRateMax, Condenser(RefCondLoop).InletNode, Condenser(RefCondLoop).OutletNode);
   10122              :             }
   10123            0 :             for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10124            0 :                 if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10125              : 
   10126            0 :                 Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10127              : 
   10128            0 :                 if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10129            0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10130            0 :                 } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10131            0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10132              :                 }
   10133              : 
   10134            0 :                 PlantUtilities::InitComponentNodes(state,
   10135              :                                                    0.0,
   10136            0 :                                                    RefrigRack(RefCompRackLoop).MassFlowRateMax,
   10137            0 :                                                    RefrigRack(RefCompRackLoop).InletNode,
   10138            0 :                                                    RefrigRack(RefCompRackLoop).OutletNode);
   10139              :             }
   10140              :         }
   10141            0 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = false;
   10142              : 
   10143              :     } //(DataGlobals::BeginEnvrnFlag .AND. MyBeginEnvrnFlag)
   10144              : 
   10145            0 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = true;
   10146            0 : }
   10147              : 
   10148            5 : void RefrigRackData::CalcRackSystem(EnergyPlusData &state)
   10149              : {
   10150              : 
   10151              :     // SUBROUTINE INFORMATION:
   10152              :     //       AUTHOR         Richard Raustad, FSEC
   10153              :     //       DATE WRITTEN   Oct/Nov 2004
   10154              :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
   10155              :     //       RE-ENGINEERED  na
   10156              : 
   10157              :     // PURPOSE OF THIS SUBROUTINE:
   10158              :     // Calculate compressor rack load, power, energy consumption, and condenser fan/pump power and consumption
   10159              : 
   10160              :     // METHODOLOGY EMPLOYED:
   10161              :     // Loop through cases attached to each rack and determine total load on compressor rack
   10162              : 
   10163              :     // REFERENCES:
   10164              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   10165              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   10166              : 
   10167              :     Real64 COPFTempOutput;          // Curve value for COPFTemp curve object
   10168              :     Real64 CondenserFrac;           // Fraction of condenser power as a function of outdoor temperature
   10169              :     Real64 TotalHeatRejectedToZone; // Total compressor and condenser fan heat rejected to zone (based on CaseRAFactor)
   10170              :     int HeatRejectZoneNum;          // Index to zone where heat is rejected
   10171              :     int HeatRejectZoneNodeNum;      // Index to zone where heat is rejected
   10172              :     Real64 OutWbTemp;               // Outdoor wet bulb temp at condenser air inlet node [C]
   10173              :     Real64 OutDbTemp;               // Outdoor dry bulb temp at condenser air inlet node [C]
   10174              :     Real64 EffectTemp;              // Effective outdoor temp when using evap condenser cooling [C]
   10175              :     Real64 HumRatIn;                // Humidity ratio of inlet air to condenser [kg/kg]
   10176              :     Real64 HumRatOut;               // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   10177              :     Real64 BPress;                  // Barometric pressure at condenser air inlet node [Pa]
   10178              :     bool EvapAvail;                 // Control for evap condenser availability
   10179              : 
   10180            5 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10181            5 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10182            5 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10183            5 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   10184              : 
   10185            5 :     state.dataRefrigCase->TotalRackDeliveredCapacity = 0.0;
   10186            5 :     state.dataRefrigCase->CompressorCOPactual = 0.0;
   10187            5 :     state.dataRefrigCase->TotalCompressorPower = 0.0;
   10188            5 :     state.dataRefrigCase->TotalCondenserFanPower = 0.0;
   10189            5 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   10190            5 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   10191            5 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   10192            5 :     TotalHeatRejectedToZone = 0.0;
   10193            5 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   10194            5 :     state.dataRefrigCase->RackSenCreditToZone = 0.0;
   10195            5 :     state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10196            5 :     CondenserFrac = 0.0;
   10197            5 :     EvapAvail = true;
   10198            5 :     HeatRejectZoneNum = 0;
   10199            5 :     HeatRejectZoneNodeNum = 0;
   10200              : 
   10201              :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   10202              :     // (all chiller coils within a set are located in the same zone)
   10203              :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   10204              :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   10205              :     // In that subroutine, dispatch coils within each set in order specified for each zone
   10206              :     //  Below will assign loads to refrigeration system or secondary loop
   10207              :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   10208              :     // with interactions will not be known for the initial calls with first HVAC time step. They will,
   10209              :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   10210              :     // that's why important where init goes, don't want to zero out data should keep
   10211            5 :     if (state.dataRefrigCase->UseSysTimeStep) {
   10212            0 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   10213            0 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   10214              :         }
   10215              :     }
   10216              : 
   10217            5 :     if (this->NumCoils > 0) {
   10218            0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   10219            0 :             int CoilID = this->CoilNum(CoilIndex);
   10220              :             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   10221              :             // increment TotalCoolingLoad for Compressors/condenser on each system
   10222            0 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WarehouseCoil(CoilID).TotalCoolingLoad;
   10223              :             //      System(SysNum)%TotalCondDefrostCredit=System(SysNum)%TotalCondDefrostCredit + WarehouseCoil(CoilID)%HotDefrostCondCredit
   10224              :         } // NumCoils systems
   10225              :     }     // System(SysNum)%NumCoils > 0
   10226              : 
   10227            5 :     if (this->NumCases > 0) {
   10228            6 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   10229            3 :             int CaseID = this->CaseNum(caseNum);
   10230            3 :             RefrigCase(CaseID).CalculateCase(state);
   10231              : 
   10232              :             //   add evaporator load for all cases connected to rack
   10233            3 :             state.dataRefrigCase->TotalRackDeliveredCapacity += RefrigCase(CaseID).TotalCoolingLoad;
   10234              : 
   10235              :             //   sensible and latent case credits already calculated in "CalculateCase"
   10236              :             //   Now need to calculate amount of condenser heat rejection that should be applied to zone
   10237              :             //                                     (used when HeatRejectionLocation = LocationZone)
   10238              :             //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10239              :             //   rejection goes to that zone - that is, no heat rejection goes to the HVAC return air
   10240            3 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10241            2 :                 if (this->NumWalkIns == 0) {
   10242            1 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad * (1.0 - state.dataRefrigCase->CaseRAFactor);
   10243              :                     //  CaseRAFactor is a module variable calculated in CalculateCase
   10244              :                     //   find zone number of first case on rack (all cases are in the same zone
   10245              :                     //  if HeatRejectionLocation = LocationZone and no walk-ins)
   10246            1 :                     HeatRejectZoneNum = RefrigCase(this->CaseNum(1)).ActualZoneNum;
   10247            1 :                     HeatRejectZoneNodeNum = RefrigCase(this->CaseNum(1)).ZoneNodeNum;
   10248              :                 } else { // have walk ins so no reduction in condenser heat rejection for caseRA factor
   10249            1 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad;
   10250              :                 } // no walk ins
   10251              :             }
   10252              :         } // NumCases
   10253              :     }     // Numcases on rack > 0
   10254              : 
   10255            5 :     if (this->NumWalkIns > 0) {
   10256            6 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   10257            3 :             int WalkInID = this->WalkInNum(WalkInIndex);
   10258            3 :             WalkIn(WalkInID).CalculateWalkIn(state);
   10259            3 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WalkIn(WalkInID).TotalCoolingLoad;
   10260            3 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10261            3 :                 TotalHeatRejectedToZone += WalkIn(WalkInID).TotalCoolingLoad;
   10262            3 :                 HeatRejectZoneNum = this->HeatRejectionZoneNum;
   10263            3 :                 HeatRejectZoneNodeNum = this->HeatRejectionZoneNodeNum;
   10264              :             } // reject heat to zone
   10265              :         }     // WalkInIndex
   10266              :     }         // NumWalkIns>0
   10267              : 
   10268            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10269            4 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp);
   10270            4 :         EvapAvail = false;
   10271              :     } else {
   10272            1 :         if (this->OutsideAirNodeNum != 0) {
   10273            0 :             OutDbTemp = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Temp;
   10274            0 :             BPress = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Press;
   10275              :         } else {
   10276            1 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   10277            1 :             BPress = state.dataEnvrn->OutBaroPress;
   10278              :         }
   10279            1 :         EffectTemp = OutDbTemp;
   10280              : 
   10281              :         // IF schedule exists, evap condenser can be scheduled OFF
   10282              :         // Check schedule to determine evap condenser availability
   10283            1 :         if (this->evapAvailSched != nullptr && this->evapAvailSched->getCurrentVal() == 0) EvapAvail = false;
   10284              : 
   10285              :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   10286              :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   10287              :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   10288              :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   10289              :         //  climates.  To accommodate such applications, the variable EvapCutOutTdb is used as an extra
   10290              :         //  check.
   10291            1 :         if (OutDbTemp < EvapCutOutTdb) EvapAvail = false;
   10292              : 
   10293            1 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10294              :             // determine temps for evap cooling
   10295            0 :             if (this->OutsideAirNodeNum != 0) {
   10296            0 :                 HumRatIn = state.dataLoopNodes->Node(this->OutsideAirNodeNum).HumRat;
   10297              :             } else {
   10298            0 :                 HumRatIn = state.dataEnvrn->OutHumRat;
   10299              :             } // outsideairnode
   10300            0 :             OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   10301            0 :             EffectTemp = OutWbTemp + (1.0 - this->EvapEffect) * (OutDbTemp - OutWbTemp);
   10302              :         } // evapAvail
   10303              : 
   10304              :         // Obtain water-cooled condenser inlet/outlet temps
   10305            1 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   10306            0 :             this->InletTemp = state.dataLoopNodes->Node(this->InletNode).Temp;
   10307            0 :             EffectTemp = state.dataLoopNodes->Node(this->InletNode).Temp + 5.0; // includes approach temp
   10308            0 :             if (this->InletTemp < this->InletTempMin) {
   10309            0 :                 if (this->LowTempWarnIndex == 0) {
   10310            0 :                     ShowWarningMessage(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10311            0 :                     ShowContinueError(state,
   10312              :                                       "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature "
   10313              :                                       "and/or minimum temperature setpoints.");
   10314              :                 } // LowTempWarnIndex
   10315            0 :                 ShowRecurringWarningErrorAtEnd(state,
   10316            0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10317              :                                                    " - Condenser inlet temp lower than minimum allowed ... continues",
   10318            0 :                                                this->LowTempWarnIndex);
   10319              :                 // END IF  !LowTempWarn
   10320              :             } // InletTempMin
   10321              :         }     // DataHeatBalance::RefrigCondenserType::Water
   10322              : 
   10323            1 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, EffectTemp);
   10324              :     } // Location Zone
   10325              : 
   10326            5 :     state.dataRefrigCase->CompressorCOPactual = this->RatedCOP * COPFTempOutput;
   10327              : 
   10328            5 :     if (state.dataRefrigCase->CompressorCOPactual > 0.0) {
   10329            5 :         state.dataRefrigCase->TotalCompressorPower = state.dataRefrigCase->TotalRackDeliveredCapacity / state.dataRefrigCase->CompressorCOPactual;
   10330            5 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalCompressorPower + state.dataRefrigCase->TotalRackDeliveredCapacity;
   10331              :     } else {
   10332            0 :         if (this->ShowCOPWarning) {
   10333            0 :             ShowWarningError(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10334            0 :             ShowContinueError(state, " The calculated COP has a value of zero or is negative. Refer to Engineering Documentation for");
   10335            0 :             ShowContinueError(state, " further explanation of Compressor Rack COP as a Function of Temperature Curve.");
   10336            0 :             this->ShowCOPWarning = false;
   10337              :         }
   10338              :     }
   10339              : 
   10340              :     // calculate condenser fan usage here if not water-cooled; if water-cooled, fan is in separate tower object
   10341              :     // fan loads > 0 only if the connected cases are operating
   10342            5 :     if (state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0 && this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10343            1 :         if (this->TotCondFTempPtr != 0) {
   10344            0 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10345              :                 CondenserFrac =
   10346            0 :                     max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp)));
   10347            0 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10348            0 :                 state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += this->CondenserFanPower * CondenserFrac;
   10349              :             } else {
   10350            0 :                 CondenserFrac = max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, EffectTemp)));
   10351            0 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10352              :             } // location zone
   10353              :         } else {
   10354            1 :             CondenserFrac = 1.0;
   10355            1 :             state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10356              :         } // TotCondFTempPtr
   10357              :     }     // Cooling Water type
   10358              : 
   10359              :     // calculate evap water use and water pump power, if applicable
   10360              :     // assumes pump runs whenever evap cooling is available to minimize scaling
   10361            5 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10362            0 :         state.dataRefrigCase->TotalCondenserPumpPower = this->EvapPumpPower;
   10363            0 :         HumRatOut = Psychrometrics::PsyWFnTdbTwbPb(state, EffectTemp, OutWbTemp, BPress);
   10364            0 :         state.dataRefrigCase->TotalEvapWaterUseRate = this->CondenserAirFlowRate * CondenserFrac *
   10365            0 :                                                       Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn) * (HumRatOut - HumRatIn) /
   10366            0 :                                                       Psychrometrics::RhoH2O(EffectTemp);
   10367              :     } // evapAvail
   10368              :     // calculate basin water heater load
   10369            5 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   10370            0 :         if ((state.dataRefrigCase->TotalRackDeliveredCapacity == 0.0) && (EvapAvail) && (OutDbTemp < this->BasinHeaterSetPointTemp)) {
   10371            0 :             state.dataRefrigCase->TotalBasinHeatPower = max(0.0, this->BasinHeaterPowerFTempDiff * (this->BasinHeaterSetPointTemp - OutDbTemp));
   10372              :             // provide warning if no heater power exists
   10373            0 :             if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   10374            0 :                 if (this->EvapFreezeWarnIndex == 0) {
   10375            0 :                     ShowWarningMessage(
   10376              :                         state,
   10377            0 :                         format("Refrigeration Compressor Rack {} - Evap cooling of condenser underway with no basin heater power", this->Name));
   10378            0 :                     ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   10379            0 :                     ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   10380              :                 } // EvapFreezeWarnIndex == 0
   10381            0 :                 ShowRecurringWarningErrorAtEnd(state,
   10382            0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10383              :                                                    " - Evap cooling of condenser underway with no basin heater power ... continues",
   10384            0 :                                                this->EvapFreezeWarnIndex);
   10385              :                 // END IF
   10386              :             } // TotalBasinHeatPower == 0 when at outdoor freezing conditions
   10387              :         }     // cap
   10388              :     }         // evap condenser type
   10389              : 
   10390              :     // add in compressor and condenser fan power to rack heat rejection variables if the heat rejection location is to the zone
   10391              :     //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10392              :     //   rejection goes to that zone - that is, no condenser heat rejection goes to the HVAC return air
   10393            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10394            4 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalRackDeliveredCapacity + state.dataRefrigCase->TotalCompressorPower +
   10395            4 :                                                    state.dataRefrigCase->TotalCondenserFanPower;
   10396            4 :         if (HeatRejectZoneNum > 0 && state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0) {
   10397            0 :             if (this->NumWalkIns == 0) {
   10398              :                 //       rack report variables for condenser heat to Zone and/or HVAC
   10399              :                 //       The difference between TotalHeatRejectedToZone and TotalRackDeliveredCapacity is the heat sent to return air
   10400            0 :                 state.dataRefrigCase->RackSenCreditToZone =
   10401            0 :                     state.dataRefrigCase->TotalCondenserHeat * (TotalHeatRejectedToZone / state.dataRefrigCase->TotalRackDeliveredCapacity);
   10402            0 :                 state.dataRefrigCase->RackSenCreditToHVAC = state.dataRefrigCase->TotalCondenserHeat - state.dataRefrigCase->RackSenCreditToZone;
   10403              :             } else { // walkins present and no rack heat rejection goes to return air
   10404            0 :                 state.dataRefrigCase->RackSenCreditToZone = state.dataRefrigCase->TotalCondenserHeat;
   10405            0 :                 state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10406              :             } // walkins present
   10407              :             //     Update globals for use in Air Heat Balance and Zone Equipment Manager
   10408            0 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += state.dataRefrigCase->RackSenCreditToZone;
   10409              : 
   10410            0 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToHVAC += state.dataRefrigCase->RackSenCreditToHVAC;
   10411              :         } // zone # > 0 and tot del cap > 0
   10412              :     }     // rack heat rejection to zone
   10413            5 : }
   10414              : 
   10415            5 : void RefrigRackData::ReportRackSystem(EnergyPlusData &state, int const RackNum)
   10416              : {
   10417              : 
   10418              :     // SUBROUTINE INFORMATION:
   10419              :     //       AUTHOR         Richard Raustad, FSEC
   10420              :     //       DATE WRITTEN   Oct/Nov 2004
   10421              :     //       MODIFIED       Hudson, ORNL Feb 2007, July 2007
   10422              :     //       RE-ENGINEERED  na
   10423              : 
   10424              :     // PURPOSE OF THIS SUBROUTINE:
   10425              :     // To report compressor rack variables
   10426              : 
   10427            5 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   10428            5 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   10429              : 
   10430            5 :     this->RackCompressorPower = state.dataRefrigCase->TotalCompressorPower;
   10431            5 :     this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * localTimeStepSec;
   10432            5 :     this->ActualCondenserFanPower = state.dataRefrigCase->TotalCondenserFanPower;
   10433            5 :     this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * localTimeStepSec;
   10434            5 :     this->RackCapacity = state.dataRefrigCase->TotalRackDeliveredCapacity;
   10435            5 :     this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * localTimeStepSec;
   10436            5 :     this->RackCompressorCOP = state.dataRefrigCase->CompressorCOPactual;
   10437            5 :     this->SensHVACCreditHeatRate = state.dataRefrigCase->RackSenCreditToHVAC;
   10438            5 :     this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * localTimeStepSec;
   10439            5 :     this->SensZoneCreditHeatRate = state.dataRefrigCase->RackSenCreditToZone;
   10440            5 :     this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * localTimeStepSec;
   10441            5 :     this->EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   10442            5 :     this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   10443            5 :     this->ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   10444            5 :     this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   10445            5 :     this->BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   10446            5 :     this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   10447            5 :     this->CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   10448            5 :     this->CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec;
   10449              :     // Set total rack heat rejection used for heat reclaim. Do not allow heat reclaim on stand alone (indoor) display cases.
   10450            5 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10451            4 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity = 0.0;
   10452              :     } else {
   10453            1 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity =
   10454            1 :             state.dataRefrigCase->TotalRackDeliveredCapacity * (1.0 + 1.0 / state.dataRefrigCase->CompressorCOPactual);
   10455              :     }
   10456              : 
   10457              :     // set water system demand request (if needed)
   10458            5 :     if (this->EvapWaterSupplyMode == WaterSupply::FromTank) {
   10459            0 :         int DemandARRID = this->EvapWaterTankDemandARRID;
   10460            0 :         int RackTankID = this->EvapWaterSupTankID;
   10461            0 :         state.dataWaterData->WaterStorage(RackTankID).VdotRequestDemand(DemandARRID) = this->EvapWaterConsumpRate;
   10462              :     }
   10463              : 
   10464            5 :     SumZoneImpacts(state);
   10465            5 : }
   10466              : 
   10467            3 : void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to refrigerated case
   10468              : {
   10469              : 
   10470              :     // SUBROUTINE INFORMATION:
   10471              :     //       AUTHOR         Richard Raustad and Don Shirey, FSEC
   10472              :     //       DATE WRITTEN   Oct/Nov 2004
   10473              :     //       MODIFIED       Therese Stovall, ORNL, May 2008
   10474              :     //       RE-ENGINEERED  na
   10475              : 
   10476              :     // PURPOSE OF THIS SUBROUTINE:
   10477              :     // To model refrigerated cases.
   10478              : 
   10479              :     // METHODOLOGY EMPLOYED:
   10480              :     // Case performance is based on a latent component calculated using a user input curve object. The sensible
   10481              :     // component is made up of all equipment loads (fan, light, anti-sweat) and the sensible case credit
   10482              :     // calculated during initialization. A master schedule is used for the refrigerated case operation and
   10483              :     // additional schedules control the lights and defrost operation.
   10484              :     // The fan is assumed to be off for Hot-Gas and Electric defrost.
   10485              : 
   10486              :     // Unmet loads are accumulated to be met the following time step.  This usually occurs only during the
   10487              :     // defrost period, so the case calls for full capacity at the end of defrost to make up for the sensible
   10488              :     // case gains during the defrost period. This feature is also used if needed for restocking loads.
   10489              : 
   10490              :     // REFERENCES:
   10491              : 
   10492              :     // "Calculation of Humidity Effects on Energy Requirements of Refrigerated Display Cases",
   10493              :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3687 (CH-93-16-4) (RP-596)
   10494              : 
   10495              :     // "Effects of Store Relative Humidity on Refrigerated Display Case Performance",
   10496              :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3686 (CH-93-16-1) (RP-596)
   10497              : 
   10498              :     // "Analysis of Supermarket Dehumidification Alternatives",
   10499              :     //  Electric Power Research Institute, EPRI TR-100352, Project 2891-03 Final Report, Nov. 1992.
   10500              : 
   10501              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   10502              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   10503              : 
   10504            3 :     Real64 CaseCreditFraction(0.0);      // Reduction in case credits due to e.g., reduced door openings at night
   10505            3 :     Real64 DefrostSchedule(0.0);         // Display case defrost schedule
   10506            3 :     Real64 DefrostDripDownSchedule(0.0); // Display case drip-down schedule (allows coil to drain after defrost)
   10507            3 :     Real64 DefrostRatio(0.0);            // ratio of defrost energy at current zone temp/humrat to defrost
   10508              :     //    capacity at design condition
   10509            3 :     Real64 LatentRatio(0.0); // ratio of latent capacity at current zone temp/humrat to
   10510              :     //    latent capacity at design condition
   10511            3 :     Real64 LatentCap_Actual(0.0);   // Refrigerated case latent capacity at specific operating conditions
   10512            3 :     Real64 LatentCaseCredit(0.0);   // Latent case credit delivered to zone (W)
   10513            3 :     Real64 SensibleCap_Actual(0.0); // Refrigerated case sensible capacity at specific operating conditions
   10514            3 :     Real64 SensibleLoadPrime(0.0);  // Sensible load due to cond, conv, rad, infil (W)
   10515            3 :     Real64 TotalCap_Actual(0.0);    // Refrigerated case total capacity at specific operating conditions
   10516            3 :     Real64 TotalLightingLoad(0.0);  // Total lighting energy rate (W)
   10517            3 :     Real64 TotalFan(0.0);           // Total fan energy rate (W)
   10518            3 :     Real64 TotalAntiSweat(0.0);     // Total anti-sweat heater energy rate (W)
   10519              : 
   10520              :     // Refrigerated display case defrost type (parameters)
   10521              :     // DefNone             = 0
   10522              :     // DefOffCycle         = 1
   10523              :     // DefHotFluid           = 2
   10524              :     // DefHotFluidOnDemand   = 3 (not available)
   10525              :     // DefHotFluidTerm       = 4
   10526              :     // DefElectric         = 5
   10527              :     // DefElectricOnDemand = 6 (not available)
   10528              :     // DefElectricTerm     = 7
   10529              : 
   10530            3 :     state.dataRefrigCase->CaseRAFactor = 0.0;
   10531              : 
   10532              :     // Zone relative humidity (%)
   10533            3 :     Real64 ZoneRHPercent = Psychrometrics::PsyRhFnTdbWPb(state,
   10534            3 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).Temp,
   10535            3 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat,
   10536            3 :                                                          state.dataEnvrn->OutBaroPress) *
   10537            3 :                            100.0;
   10538              : 
   10539              :     // Zone dew point (C)
   10540            3 :     Real64 ZoneDewPoint = Psychrometrics::PsyTdpFnWPb(state, state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat, state.dataEnvrn->OutBaroPress);
   10541              : 
   10542              :     // Display case operating temperature
   10543            3 :     Real64 TCase = this->Temperature;
   10544              : 
   10545              :     // GET ALL SCHEDULES (note all schedules can be fractions if on/off a portion of time step)
   10546              :     // case schedule should be coincident with the zone time step otherwise the simulation proceeds
   10547              : 
   10548              :     // Current value of case operating (availability) schedule
   10549            3 :     Real64 CaseSchedule = this->availSched->getCurrentVal();
   10550            3 :     if (CaseSchedule <= 0) return;
   10551              :     // get defrost schedule
   10552            3 :     if (this->defrostType > RefCaseDefrostType::None) {
   10553            0 :         DefrostSchedule = this->defrostSched->getCurrentVal();
   10554            0 :         DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   10555              :         // next statement In case user doesn't understand concept of drip down schedule
   10556            0 :         DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   10557              :     } else {
   10558            3 :         DefrostSchedule = 0.0;
   10559            3 :         DefrostDripDownSchedule = 0.0;
   10560              :     }
   10561              : 
   10562              :     // get product stocking schedule and load due to product stocking, if no schedule exists load is 0
   10563            3 :     Real64 StockingSchedule = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   10564              : 
   10565              :     // get lighting schedule and total load due to lighting
   10566            3 :     Real64 LightingSchedule = this->lightingSched->getCurrentVal();
   10567              : 
   10568              :     // if case credit reduction fraction schedule exists, modify both sensible and latent case credits
   10569              :     // according to schedule - used to account for variable case envelope, such as night covers.
   10570            3 :     CaseCreditFraction = (this->caseCreditFracSched != nullptr) ? this->caseCreditFracSched->getCurrentVal() : 1.0;
   10571              : 
   10572              :     // CALCULATE AUX LOADS DUE TO LIGHTS, FAN AND STOCKING
   10573            3 :     TotalLightingLoad = this->DesignLighting * LightingSchedule;
   10574              : 
   10575              :     // Lighting energy to case
   10576            3 :     Real64 TotalLightToCase = TotalLightingLoad * this->LightingFractionToCase;
   10577              : 
   10578              :     // Lighting energy to zone
   10579            3 :     Real64 TotalLightToZone = TotalLightingLoad - TotalLightToCase;
   10580              :     // cycle fan according to defrost schedule
   10581              :     // turn fan on for none or off-cycle defrost types
   10582            3 :     if (this->defrostType == RefCaseDefrostType::None || this->defrostType == RefCaseDefrostType::OffCycle) {
   10583            3 :         TotalFan = this->DesignFanPower;
   10584              :     } else {
   10585            0 :         TotalFan = this->DesignFanPower * (1.0 - DefrostDripDownSchedule);
   10586              :     }
   10587              :     // get  load due to product stocking
   10588              :     // accumulate stocking loads for reporting to help evaluate any cumulative unmet loads problems
   10589              :     // only accumulate energy during actual simulation (so same if DD's are switched)
   10590              : 
   10591              :     // Total load due to stocking case product (W)
   10592            3 :     Real64 StockingLoad = StockingSchedule * this->Length;
   10593            3 :     if (!state.dataGlobal->WarmupFlag) {
   10594            3 :         Real64 DeltaStockingEnergy = (StockingLoad * state.dataGlobal->TimeStepZoneSec);
   10595            3 :         this->StockingEnergy += DeltaStockingEnergy;
   10596              :     } // warm up
   10597              :     // CALCULTE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   10598              :     // Anti-sweat heater capacity
   10599            3 :     switch (this->AntiSweatControlType) {
   10600            3 :     case ASHtrCtrlType::None: {
   10601            3 :         TotalAntiSweat = 0.0;
   10602            3 :     } break;
   10603            0 :     case ASHtrCtrlType::Constant: {
   10604            0 :         TotalAntiSweat = this->AntiSweatPower;
   10605            0 :     } break;
   10606            0 :     case ASHtrCtrlType::Linear: {
   10607            0 :         TotalAntiSweat =
   10608            0 :             this->AntiSweatPower * min(1.0, max(0.0, 1.0 - (this->RatedAmbientRH - ZoneRHPercent) / (this->RatedAmbientRH - this->HumAtZeroAS)));
   10609            0 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   10610            0 :     } break;
   10611            0 :     case ASHtrCtrlType::DewPoint: {
   10612            0 :         TotalAntiSweat = this->AntiSweatPower * min(1.0, max(0.0, (ZoneDewPoint - TCase) / (this->RatedAmbientDewPoint - TCase)));
   10613            0 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   10614            0 :     } break;
   10615            0 :     case ASHtrCtrlType::HeatBalance: {
   10616            0 :         if (this->Rcase > 0.0) {
   10617            0 :             TotalAntiSweat = (((ZoneDewPoint - state.dataLoopNodes->Node(this->ZoneNodeNum).Temp) * this->Height / Rair) +
   10618            0 :                               ((ZoneDewPoint - TCase) * this->Height / this->Rcase));
   10619            0 :             TotalAntiSweat = min(this->AntiSweatPower, max(this->MinimumASPower, TotalAntiSweat));
   10620              :         } else {
   10621            0 :             TotalAntiSweat = 0.0;
   10622              :         }
   10623            0 :     } break;
   10624            0 :     default: {
   10625              :         // should never execute this CASE statement
   10626            0 :         TotalAntiSweat = 0.0;
   10627            0 :     } break;
   10628              :     }
   10629            3 :     TotalAntiSweat *= this->Length;
   10630              : 
   10631              :     // Anti-sweat heater energy to case
   10632            3 :     Real64 TotalASHeaterToCase = this->ASHeaterFractionToCase * TotalAntiSweat;
   10633              : 
   10634              :     // Anti-sweat heater energy to zone
   10635            3 :     Real64 TotalASHeaterToZone = TotalAntiSweat - TotalASHeaterToCase;
   10636              : 
   10637              :     // latent capacity correction term at off-design conditions
   10638            3 :     switch (this->LatentEnergyCurveType) {
   10639            3 :     case EnergyEqnForm::CaseTemperatureMethod: {
   10640            3 :         Real64 LatCapModFrac = Curve::CurveValue(state, this->LatCapCurvePtr, TCase);
   10641            3 :         LatentRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * LatCapModFrac));
   10642            3 :     } break;
   10643            0 :     case EnergyEqnForm::RHCubic: {
   10644            0 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneRHPercent));
   10645            0 :     } break;
   10646            0 :     case EnergyEqnForm::DPCubic: {
   10647            0 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneDewPoint));
   10648            0 :     } break;
   10649            0 :     default:
   10650            0 :         break;
   10651              :     }
   10652              : 
   10653              :     // calculate latent case load (assumes no moisture load due to stocking)
   10654              :     // assume sensible case credits continue to accumulate in case during defrost/dripdown,
   10655              :     //    but latent credits/load and capacity only applied outside dripdownschedule
   10656              : 
   10657              :     // Latent load placed on case at actual zone conditions (W)
   10658            3 :     Real64 LatentLoad = this->DesignLatentCap * LatentRatio * CaseCreditFraction * (1.0 - DefrostDripDownSchedule);
   10659            3 :     LatentCaseCredit = -LatentLoad;
   10660              :     // adjust sensible loads and case credit for actual zone temperature
   10661              :     // If zone temp rises above rated ambient temperature, total load can exceed case design capacity,
   10662              :     // so unmet cooling loads are accumulated to meet in the next time step. (Case credit fraction allows
   10663              :     //  extra insulation, e.g. night covers, or imitating a better insulated walk-in cooler)
   10664              : 
   10665              :     // used to look at extra sensible load due to excursions in zone T
   10666            3 :     Real64 ZoneTempFactor = (state.dataLoopNodes->Node(ZoneNodeNum).Temp - TCase) / (this->RatedAmbientTemp - TCase);
   10667            3 :     SensibleLoadPrime = this->DesignSensCaseCredit * ZoneTempFactor * CaseCreditFraction;
   10668              : 
   10669              :     // Sensible load due to heaters, lighting (W)
   10670            3 :     Real64 SensibleLoadAux = TotalLightToCase + TotalASHeaterToCase + TotalFan + StockingLoad;
   10671              : 
   10672              :     // Total sensible load on case, may not = capacity applied (W)
   10673            3 :     Real64 SensibleLoadTotal = SensibleLoadPrime + SensibleLoadAux;
   10674              :     // include lighting and anti-sweat power not attributed to case load to sensible case credit
   10675              : 
   10676              :     // Sensible case credit delivered to zone (W)
   10677            3 :     Real64 SensibleCaseCredit = TotalLightToZone + TotalASHeaterToZone - SensibleLoadPrime;
   10678              : 
   10679              :     // FROST:  keep track of frost build up on evaporator coil
   10680              :     // avoid accumulation during warm-up to avoid reverse dd test problem
   10681            3 :     if (!state.dataGlobal->WarmupFlag) {
   10682            3 :         Real64 DeltaFreezeKgFrost = LatentLoad * state.dataGlobal->TimeStepZoneSec / IcetoVaporEnthalpy;
   10683            3 :         this->KgFrost += DeltaFreezeKgFrost;
   10684              :     }
   10685              : 
   10686            3 :     if (TCase > TempTooHotToFrost) this->KgFrost = 0.0;
   10687              : 
   10688            3 :     Real64 DefrostLoad_Actual(0.0); // heat load on case due to defrost (W)
   10689            3 :     Real64 DefrostCap_Actual(0.0);  // power used to defrost (W)
   10690              : 
   10691              :     // DEFROST CALCULATIONS
   10692            3 :     if (DefrostSchedule > 0.0) {
   10693            0 :         if (this->defrostType != RefCaseDefrostType::None && this->defrostType != RefCaseDefrostType::OffCycle) {
   10694            0 :             DefrostCap_Actual = this->DesignDefrostCap * DefrostSchedule;
   10695            0 :             if (this->defrostType == RefCaseDefrostType::ElectricTerm || this->defrostType == RefCaseDefrostType::HotFluidTerm) {
   10696              :                 // calculate correction term for temperature termination defrost control
   10697            0 :                 switch (this->DefrostEnergyCurveType) {
   10698            0 :                 case EnergyEqnForm::CaseTemperatureMethod: {
   10699            0 :                     Real64 DefCapModFrac = Curve::CurveValue(state, this->DefCapCurvePtr, TCase);
   10700            0 :                     DefrostRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * DefCapModFrac));
   10701            0 :                 } break;
   10702            0 :                 case EnergyEqnForm::RHCubic: {
   10703            0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneRHPercent));
   10704            0 :                 } break;
   10705            0 :                 case EnergyEqnForm::DPCubic: {
   10706            0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneDewPoint));
   10707            0 :                 } break;
   10708            0 :                 case EnergyEqnForm::None: {
   10709            0 :                     DefrostRatio = 1.0;
   10710            0 :                 } break;
   10711            0 :                 default:
   10712            0 :                     break;
   10713              :                 }
   10714            0 :                 DefrostCap_Actual *= DefrostRatio;
   10715              :             }
   10716              : 
   10717              :             // frost load at start of time step (kg of ice)
   10718            0 :             Real64 StartFrostKg = this->KgFrost;
   10719              : 
   10720              :             // Energy form of defrost capacity (J)
   10721            0 :             Real64 defrostEnergy = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   10722              : 
   10723              :             // Frost melted by defrost during a time step (kg)
   10724            0 :             Real64 FrostMeltedKg = min(defrostEnergy / IceMeltEnthalpy, StartFrostKg);
   10725            0 :             this->KgFrost -= FrostMeltedKg;
   10726              : 
   10727              :             // Reduce defrost heat load on case by amount of ice melted during time step
   10728              :             // However, don't reduce the defrost capacity applied
   10729              : 
   10730            0 :             DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   10731              : 
   10732            0 :             if (!state.dataGlobal->WarmupFlag) { // avoid reverse dd test problems
   10733              :                 // keep running total of defrost energy above that needed to melt frost for use in evaluating
   10734              :                 //      problems of excessive unmet loads
   10735            0 :                 this->DeltaDefrostEnergy = max(0.0, (defrostEnergy - (FrostMeltedKg * IceMeltEnthalpy)));
   10736            0 :                 this->DefrostEnergy += this->DeltaDefrostEnergy;
   10737              :             }
   10738              :             // If hot brine or hot gas is used for defrost, need to reduce condenser load
   10739              :             // Note this condenser credit is not applied in compressor-rack systems.
   10740            0 :             if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   10741            0 :                 this->defrostType != RefCaseDefrostType::ElectricTerm)
   10742            0 :                 this->HotDefrostCondCredit = DefrostCap_Actual * DefrostSchedule;
   10743            0 :         } else { // no defrost or off-cycle defrost
   10744            0 :             DefrostCap_Actual = 0.0;
   10745            0 :             DefrostLoad_Actual = 0.0;
   10746            0 :             this->KgFrost = 0.0;
   10747              :             // Off-Cycle defrost is assumed to melt all the ice
   10748              :         } // defrost type
   10749              : 
   10750              :     } else { // DefrostSchedule = 0, so no defrost load or capacity
   10751            3 :         DefrostLoad_Actual = 0.0;
   10752            3 :         DefrostCap_Actual = 0.0;
   10753              :     } // Defrost calculations
   10754              : 
   10755              :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   10756              :     // total load on case at zone conditions (W)
   10757            3 :     Real64 TotalLoad_Actual = SensibleLoadTotal + LatentLoad + DefrostLoad_Actual;
   10758              : 
   10759              :     // Rate needed to serve all stored energy during single time step (W)
   10760            3 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   10761            3 :     Real64 LoadRequested = TotalLoad_Actual + StoredEnergyRate;
   10762              : 
   10763              :     // prorate available cooling capacity for portion of time off due to drip down.
   10764            3 :     Real64 CapAvail = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule);
   10765            3 :     if (CapAvail >= LoadRequested) {
   10766              :         // Have more at least as much capacity available as needed, even counting stored energy
   10767            3 :         TotalCap_Actual = LoadRequested;
   10768            3 :         SensibleCap_Actual = SensibleLoadTotal + StoredEnergyRate;
   10769            3 :         LatentCap_Actual = LatentLoad;
   10770            3 :         this->StoredEnergy = 0.0;
   10771              :     } else {
   10772              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   10773            0 :         TotalCap_Actual = CapAvail;
   10774            0 :         LatentCap_Actual = min(LatentLoad, CapAvail); // Latent load should never be > capavail, but just in case...
   10775            0 :         SensibleCap_Actual = TotalCap_Actual - LatentCap_Actual;
   10776            0 :         if (!state.dataGlobal->WarmupFlag) this->StoredEnergy += (TotalLoad_Actual - CapAvail) * state.dataGlobal->TimeStepZoneSec;
   10777              :     } // CapAvail vs Load requested
   10778              : 
   10779              :     // Reset DefrostLoad_Actual to zero for non-electric defrost types, for reporting purposes
   10780            3 :     if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   10781            3 :         this->defrostType != RefCaseDefrostType::ElectricTerm)
   10782            3 :         DefrostCap_Actual = 0.0;
   10783              : 
   10784            3 :     Real64 caseRAFraction = min(0.8, this->RAFrac);
   10785            3 :     state.dataRefrigCase->CaseRAFactor = (1.0 - ((0.8 - caseRAFraction) / 0.8)) * 0.5;
   10786              : 
   10787              :     // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   10788              :     //   Zone Equipment Manager. Sum case credits to zone and case credits to HVAC
   10789              : 
   10790              :     //** this needs a moisture variable NonAirSystemMoistureResponse (equivalent of NonAirSystemResponse) to properly
   10791              :     //** allocate moisture to the zone when the HVAC system is off.
   10792              : 
   10793              :     // Amount of sensible case credit applied to zone load (W)
   10794            3 :     Real64 CaseSenCreditToZone = SensibleCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   10795              : 
   10796              :     // Amount of latent case credit applied to zone load (W)
   10797            3 :     Real64 CaseLatCreditToZone = LatentCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   10798              : 
   10799              :     // Amount of sensible case credit applied to HVAC RA duct (W)
   10800            3 :     Real64 CaseSenCreditToHVAC = SensibleCaseCredit * state.dataRefrigCase->CaseRAFactor;
   10801              : 
   10802              :     // Amount of latent case credit applied to HVAC RA duct (W)
   10803            3 :     Real64 CaseLatCreditToHVAC = LatentCaseCredit * state.dataRefrigCase->CaseRAFactor;
   10804              : 
   10805            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToZone += CaseSenCreditToZone;
   10806            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToZone += CaseLatCreditToZone;
   10807            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToHVAC += CaseSenCreditToHVAC;
   10808            3 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToHVAC += CaseLatCreditToHVAC;
   10809              : 
   10810              :     // ReportRefrigeratedCase(CaseID)
   10811            3 :     this->TotalCoolingLoad = TotalCap_Actual;
   10812            3 :     this->TotalCoolingEnergy = TotalCap_Actual * state.dataGlobal->TimeStepZoneSec;
   10813            3 :     this->SensCoolingEnergyRate = SensibleCap_Actual;
   10814            3 :     this->SensCoolingEnergy = SensibleCap_Actual * state.dataGlobal->TimeStepZoneSec;
   10815            3 :     this->LatCoolingEnergyRate = LatentCap_Actual;
   10816            3 :     this->LatCoolingEnergy = LatentCap_Actual * state.dataGlobal->TimeStepZoneSec;
   10817              : 
   10818            3 :     this->SensZoneCreditRate = CaseSenCreditToZone; // both positive or negative
   10819              :     // This rate can be positive or negative, split into separate output variables and always report positive value
   10820            3 :     if (CaseSenCreditToZone <= 0.0) {
   10821            1 :         this->SensZoneCreditCoolRate = -CaseSenCreditToZone;
   10822            1 :         this->SensZoneCreditCool = -CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   10823            1 :         this->SensZoneCreditHeatRate = 0.0;
   10824            1 :         this->SensZoneCreditHeat = 0.0;
   10825              :     } else {
   10826            2 :         this->SensZoneCreditHeatRate = CaseSenCreditToZone;
   10827            2 :         this->SensZoneCreditHeat = CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   10828            2 :         this->SensZoneCreditCoolRate = 0.0;
   10829            2 :         this->SensZoneCreditCool = 0.0;
   10830              :     }
   10831              : 
   10832              :     // This rate should always be negative
   10833            3 :     this->LatZoneCreditRate = CaseLatCreditToZone;
   10834            3 :     this->LatZoneCredit = CaseLatCreditToZone * state.dataGlobal->TimeStepZoneSec;
   10835              : 
   10836            3 :     this->SensHVACCreditRate = CaseSenCreditToHVAC;
   10837              :     // This rate can be positive or negative, split into separate output variables and always report positive value
   10838            3 :     if (CaseSenCreditToHVAC <= 0.0) {
   10839            3 :         this->SensHVACCreditCoolRate = -CaseSenCreditToHVAC;
   10840            3 :         this->SensHVACCreditCool = -CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   10841            3 :         this->SensHVACCreditHeatRate = 0.0;
   10842            3 :         this->SensHVACCreditHeat = 0.0;
   10843              :     } else {
   10844            0 :         this->SensHVACCreditHeatRate = CaseSenCreditToHVAC;
   10845            0 :         this->SensHVACCreditHeat = CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   10846            0 :         this->SensHVACCreditCoolRate = 0.0;
   10847            0 :         this->SensHVACCreditCool = 0.0;
   10848              :     }
   10849              : 
   10850              :     // This rate should always be negative
   10851            3 :     this->LatHVACCreditRate = CaseLatCreditToHVAC;
   10852            3 :     this->LatHVACCredit = CaseLatCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   10853              : 
   10854            3 :     this->ElecFanPower = TotalFan;
   10855            3 :     this->ElecFanConsumption = TotalFan * state.dataGlobal->TimeStepZoneSec;
   10856            3 :     this->ElecAntiSweatPower = TotalAntiSweat;
   10857            3 :     this->ElecAntiSweatConsumption = TotalAntiSweat * state.dataGlobal->TimeStepZoneSec;
   10858            3 :     this->ElecLightingPower = TotalLightingLoad;
   10859            3 :     this->ElecLightingConsumption = TotalLightingLoad * state.dataGlobal->TimeStepZoneSec;
   10860            3 :     this->ElecDefrostPower = DefrostCap_Actual;
   10861            3 :     this->ElecDefrostConsumption = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   10862              : 
   10863            3 :     this->DefEnergyCurveValue = DefrostRatio;
   10864            3 :     this->LatEnergyCurveValue = LatentRatio;
   10865              : 
   10866              :     //**************************************************************************************************
   10867              :     // Cap Energy and Kg Frost to avoid floating overflow errors
   10868              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   10869              : 
   10870              :     // Collect extra sensible load above design for possible warning if that is determining factor in
   10871              :     // excessively large stored energy
   10872            3 :     if ((ZoneTempFactor * CaseCreditFraction) > 1.0) {
   10873            1 :         if (!state.dataGlobal->WarmupFlag) {
   10874            1 :             Real64 DeltaWarmEnvEnergy = (SensibleLoadPrime - this->DesignSensCaseCredit) * state.dataGlobal->TimeStepZoneSec;
   10875            1 :             this->WarmEnvEnergy += DeltaWarmEnvEnergy;
   10876              :         }
   10877              :     }
   10878              : 
   10879            3 :     if (this->DefrostEnergy > MyLargeNumber) this->DefrostEnergy = MyLargeNumber;
   10880            3 :     if (this->WarmEnvEnergy > MyLargeNumber) this->WarmEnvEnergy = MyLargeNumber;
   10881            3 :     if (this->StockingEnergy > MyLargeNumber) this->StockingEnergy = MyLargeNumber;
   10882            3 :     if (this->StoredEnergy > MyLargeNumber) {
   10883            0 :         this->StoredEnergy = MyLargeNumber;
   10884            0 :         if (this->ShowStoreEnergyWarning) {
   10885            0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   10886            0 :             if (this->StockingEnergy >= this->DefrostEnergy) {
   10887            0 :                 if (this->StockingEnergy >= this->WarmEnvEnergy) {
   10888            0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with stocking.");
   10889            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   10890            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   10891              :                 } else {
   10892            0 :                     ShowContinueError(state,
   10893              :                                       " This case has insufficient capacity to meet excess energy associated with a zone environment temperature "
   10894              :                                       "greater than the design ambient for the case.");
   10895            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   10896            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   10897              :                 } // Stocking energy > warm environment energy
   10898              :             } else {
   10899            0 :                 if (this->DefrostEnergy >= this->WarmEnvEnergy) {
   10900            0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with defrost.");
   10901            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of defrost control requirements and");
   10902            0 :                     ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Defrost Capacity.");
   10903              :                 } else {
   10904            0 :                     ShowContinueError(state,
   10905              :                                       " This case has insufficient capacity to meet excess energy associated with a zone environment temperature "
   10906              :                                       "greater than the design ambient for the case.");
   10907            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   10908            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   10909              :                 }                                 // defrost energy > warm environment energy
   10910              :             }                                     // stock > defrost ELSE
   10911            0 :             this->ShowStoreEnergyWarning = false; // only give this warning once for any one case
   10912              :         }                                         // showstoreenergy warning true
   10913              :     }                                             // stored energy > large number
   10914              : 
   10915            3 :     if (this->KgFrost > MyLargeNumber) {
   10916            0 :         this->KgFrost = MyLargeNumber;
   10917            0 :         if (this->ShowFrostWarning) {
   10918            0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   10919            0 :             ShowContinueError(state, " This case has insufficient defrost capacity to remove the excess frost accumulation.");
   10920            0 :             ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   10921            0 :             ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Latent Heat Ratio.");
   10922            0 :             this->ShowFrostWarning = false;
   10923              :         }
   10924              :     }
   10925              : }
   10926              : 
   10927            0 : PlantComponent *RefrigCondenserData::factory(EnergyPlusData &state, std::string const &objectName)
   10928              : {
   10929              :     // Process the input data for boilers if it hasn't been done already
   10930            0 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   10931            0 :         CheckRefrigerationInput(state);
   10932            0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   10933              :     }
   10934              :     // Now look for this particular object in list
   10935            0 :     for (auto &obj : state.dataRefrigCase->Condenser) {
   10936            0 :         if (obj.Name == objectName) {
   10937            0 :             return &obj;
   10938              :         }
   10939              :     }
   10940              :     // If we didn't find it, fatal
   10941              :     ShowFatalError(state, format("LocalRefrigCondenserFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   10942              :     // Shut up the compiler
   10943              :     return nullptr; // LCOV_EXCL_LINE
   10944              : }
   10945              : 
   10946            0 : void RefrigCondenserData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   10947              : {
   10948            0 :     InitRefrigeration(state);
   10949            0 :     InitRefrigerationPlantConnections(state);
   10950            0 : }
   10951              : 
   10952            0 : void RefrigCondenserData::simulate(EnergyPlusData &state,
   10953              :                                    [[maybe_unused]] const PlantLocation &calledFromLocation,
   10954              :                                    bool const FirstHVACIteration,
   10955              :                                    [[maybe_unused]] Real64 &CurLoad,
   10956              :                                    [[maybe_unused]] bool const RunFlag)
   10957              : {
   10958              : 
   10959              :     // SUBROUTINE INFORMATION:
   10960              :     //       AUTHOR         Randy Hudson, ORNL
   10961              :     //       DATE WRITTEN   July 2007
   10962              :     //       MODIFIED       Therese Stovall, ORNL May 2008
   10963              :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   10964              :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   10965              :     //       RE-ENGINEERED  na
   10966              : 
   10967              :     // PURPOSE OF THIS SUBROUTINE:
   10968              :     // Simulates the water-cooled refrigeration condenser object.
   10969              :     // Modified to add condensers for detailed refrigeration systems and to
   10970              :     // avoid double-counting heat rejection that has been used in desuperheater
   10971              :     // hvac coils or water heaters.
   10972              : 
   10973              :     // METHODOLOGY EMPLOYED:
   10974              :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   10975              :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   10976              : 
   10977              :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   10978            0 :     int PlantInletNode(0);
   10979            0 :     int PlantOutletNode(0);
   10980            0 :     PlantLocation PlantLoc{};
   10981              : 
   10982            0 :     InitRefrigerationPlantConnections(state);
   10983              : 
   10984            0 :     std::string TypeName;
   10985            0 :     std::string ErrIntro;
   10986              : 
   10987              :     // set variables depending upon system type
   10988            0 :     PlantInletNode = this->InletNode;
   10989            0 :     PlantOutletNode = this->OutletNode;
   10990            0 :     PlantLoc = this->plantLoc;
   10991              : 
   10992            0 :     state.dataRefrigCase->TotalCondenserHeat = this->CondLoad;
   10993            0 :     TypeName = "Refrigeration:Condenser:WaterCooled";
   10994            0 :     ErrIntro = "Condenser for refrigeration system ";
   10995              : 
   10996              :     // Current condenser is water cooled
   10997              :     // Make demand request on first HVAC iteration
   10998              : 
   10999              :     // get cooling fluid properties
   11000            0 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11001            0 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11002              : 
   11003            0 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11004              : 
   11005            0 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11006              : 
   11007            0 :         if (this->OutletTemp == this->InletTemp) {
   11008              : 
   11009            0 :             if (this->HighInletWarnIndex == 0) {
   11010            0 :                 ShowSevereError(
   11011              :                     state,
   11012            0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11013            0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11014              :             }
   11015            0 :             ShowRecurringWarningErrorAtEnd(state,
   11016            0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11017            0 :                                            this->HighInletWarnIndex);
   11018            0 :             this->VolFlowRate = 9999.0;
   11019            0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11020              :         } else {
   11021            0 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11022            0 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11023              :             // Check for maximum flow in the component
   11024            0 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11025            0 :                 if (this->HighFlowWarnIndex == 0) {
   11026            0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11027            0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11028            0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11029              :                 } // HighFlowWarnIndex
   11030            0 :                 ShowRecurringWarningErrorAtEnd(
   11031            0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11032              :                 // END IF
   11033            0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11034              :             }
   11035              :         } // compare outlet T to inlet T
   11036              : 
   11037            0 :     } else if (this->FlowType == CndsrFlowType::Constant && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11038              :         // this part for constant flow condition
   11039            0 :         this->VolFlowRate = this->DesVolFlowRate;
   11040            0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11041              : 
   11042            0 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11043            0 :         this->MassFlowRate = 0.0;
   11044              : 
   11045              :     } // on flow type
   11046              :     // check against plant, might get changed.
   11047            0 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11048              : 
   11049            0 :     this->VolFlowRate = this->MassFlowRate / rho;
   11050              : 
   11051            0 :     if (this->MassFlowRate > 0) {
   11052            0 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11053              :     } else {
   11054            0 :         this->OutletTemp = this->InletTemp;
   11055            0 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11056              : 
   11057            0 :             ShowRecurringWarningErrorAtEnd(
   11058              :                 state,
   11059            0 :                 TypeName + this->Name +
   11060              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11061            0 :                 this->NoFlowWarnIndex);
   11062              :         }
   11063              :     }
   11064              :     // Check outlet water temp for max value
   11065            0 :     if (this->OutletTemp > this->OutletTempMax) {
   11066            0 :         if (this->HighTempWarnIndex == 0) {
   11067            0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11068            0 :             ShowContinueError(state,
   11069              :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11070              :         }
   11071            0 :         ShowRecurringWarningErrorAtEnd(
   11072            0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", this->HighTempWarnIndex);
   11073              :     }
   11074              : 
   11075            0 :     this->UpdateCondenserOutletNode(state);
   11076            0 : }
   11077              : 
   11078            0 : PlantComponent *RefrigRackData::factory(EnergyPlusData &state, std::string const &objectName)
   11079              : {
   11080              :     // Process the input data for boilers if it hasn't been done already
   11081            0 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   11082            0 :         CheckRefrigerationInput(state);
   11083            0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   11084              :     }
   11085              :     // Now look for this particular object in list
   11086            0 :     for (auto &obj : state.dataRefrigCase->RefrigRack) {
   11087            0 :         if (obj.Name == objectName) {
   11088            0 :             return &obj;
   11089              :         }
   11090              :     }
   11091              :     // If we didn't find it, fatal
   11092              :     ShowFatalError(state, format("LocalRefrigRackFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   11093              :     // Shut up the compiler
   11094              :     return nullptr; // LCOV_EXCL_LINE
   11095              : }
   11096              : 
   11097            0 : void RefrigRackData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11098              : {
   11099            0 :     InitRefrigeration(state);
   11100            0 :     InitRefrigerationPlantConnections(state);
   11101            0 : }
   11102              : 
   11103            0 : void RefrigRackData::simulate(EnergyPlusData &state,
   11104              :                               [[maybe_unused]] const PlantLocation &calledFromLocation,
   11105              :                               bool const FirstHVACIteration,
   11106              :                               [[maybe_unused]] Real64 &CurLoad,
   11107              :                               [[maybe_unused]] bool const RunFlag)
   11108              : {
   11109              : 
   11110              :     // SUBROUTINE INFORMATION:
   11111              :     //       AUTHOR         Randy Hudson, ORNL
   11112              :     //       DATE WRITTEN   July 2007
   11113              :     //       MODIFIED       Therese Stovall, ORNL May 2008
   11114              :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   11115              :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   11116              :     //       RE-ENGINEERED  na
   11117              : 
   11118              :     // PURPOSE OF THIS SUBROUTINE:
   11119              :     // Simulates the water-cooled refrigeration condenser object.
   11120              :     // Modified to add condensers for detailed refrigeration systems and to
   11121              :     // avoid double-counting heat rejection that has been used in desuperheater
   11122              :     // hvac coils or water heaters.
   11123              : 
   11124              :     // METHODOLOGY EMPLOYED:
   11125              :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   11126              :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   11127              : 
   11128              :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   11129            0 :     int PlantInletNode(0);
   11130            0 :     int PlantOutletNode(0);
   11131            0 :     PlantLocation PlantLoc{};
   11132              : 
   11133            0 :     InitRefrigerationPlantConnections(state);
   11134              : 
   11135            0 :     std::string TypeName;
   11136            0 :     std::string ErrIntro;
   11137              : 
   11138              :     // set variables depending upon system type
   11139            0 :     PlantInletNode = this->InletNode;
   11140            0 :     PlantOutletNode = this->OutletNode;
   11141            0 :     PlantLoc = this->plantLoc;
   11142              : 
   11143            0 :     state.dataRefrigCase->TotalCondenserHeat =
   11144            0 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(this->MyIdx).AvailCapacity - this->LaggedUsedWaterHeater - this->LaggedUsedHVACCoil;
   11145            0 :     TypeName = "Refrigeration:CompressorRack:";
   11146            0 :     ErrIntro = "Condenser for refrigeration rack ";
   11147              : 
   11148              :     // Current condenser is water cooled
   11149              :     // Make demand request on first HVAC iteration
   11150              : 
   11151              :     // get cooling fluid properties
   11152            0 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11153            0 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11154              : 
   11155            0 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11156            0 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11157              : 
   11158            0 :         if (this->OutletTemp == this->InletTemp) {
   11159              : 
   11160            0 :             if (this->HighInletWarnIndex == 0) {
   11161            0 :                 ShowSevereError(
   11162              :                     state,
   11163            0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11164            0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11165              :             }
   11166            0 :             ShowRecurringWarningErrorAtEnd(state,
   11167            0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11168            0 :                                            this->HighInletWarnIndex);
   11169            0 :             this->VolFlowRate = 9999.0;
   11170            0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11171              :         } else {
   11172            0 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11173            0 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11174              :             // Check for maximum flow in the component
   11175            0 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11176            0 :                 if (this->HighFlowWarnIndex == 0) {
   11177            0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11178            0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11179            0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11180              :                 } // HighFlowWarnIndex
   11181            0 :                 ShowRecurringWarningErrorAtEnd(
   11182            0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11183              :                 // END IF
   11184            0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11185              :             }
   11186              :         } // compare outlet T to inlet T
   11187              : 
   11188            0 :     } else if (this->FlowType == CndsrFlowType::Constant && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11189              :         // this part for constant flow condition
   11190            0 :         this->VolFlowRate = this->DesVolFlowRate;
   11191            0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11192              : 
   11193            0 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11194            0 :         this->MassFlowRate = 0.0;
   11195              : 
   11196              :     } // on flow type
   11197              :     // check against plant, might get changed.
   11198            0 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11199              : 
   11200            0 :     this->VolFlowRate = this->MassFlowRate / rho;
   11201              : 
   11202            0 :     if (this->MassFlowRate > 0) {
   11203            0 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11204              :     } else {
   11205            0 :         this->OutletTemp = this->InletTemp;
   11206            0 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11207              : 
   11208            0 :             ShowRecurringWarningErrorAtEnd(
   11209              :                 state,
   11210            0 :                 TypeName + this->Name +
   11211              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11212            0 :                 this->NoFlowWarnIndex);
   11213              :         }
   11214              :     }
   11215              :     // Check outlet water temp for max value
   11216            0 :     if (this->OutletTemp > this->OutletTempMax) {
   11217            0 :         if (this->HighTempWarnIndex == 0) {
   11218            0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11219            0 :             ShowContinueError(state,
   11220              :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11221              :         }
   11222            0 :         ShowRecurringWarningErrorAtEnd(
   11223            0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", HighTempWarnIndex);
   11224              :     }
   11225              : 
   11226            0 :     this->UpdateCondenserOutletNode(state);
   11227            0 : }
   11228              : 
   11229            0 : void RefrigCondenserData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11230              : {
   11231              : 
   11232              :     // SUBROUTINE INFORMATION:
   11233              :     //       AUTHOR         Randy Hudson, ORNL
   11234              :     //       DATE WRITTEN   July 2007
   11235              :     //       MODIFIED       na
   11236              :     //       RE-ENGINEERED  na
   11237              : 
   11238              :     // PURPOSE OF THIS SUBROUTINE:
   11239              :     // Updates the node variables with local variables.
   11240              : 
   11241              :     // Pass all variables from inlet to outlet node
   11242            0 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11243              : 
   11244              :     // Set outlet node variables that are possibly changed
   11245            0 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11246            0 : }
   11247            0 : void RefrigCondenserData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11248              : {
   11249            0 : }
   11250            0 : void RefrigCondenserData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11251              : {
   11252            0 : }
   11253              : 
   11254            0 : void RefrigRackData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11255              : {
   11256              : 
   11257              :     // SUBROUTINE INFORMATION:
   11258              :     //       AUTHOR         Randy Hudson, ORNL
   11259              :     //       DATE WRITTEN   July 2007
   11260              :     //       MODIFIED       na
   11261              :     //       RE-ENGINEERED  na
   11262              : 
   11263              :     // PURPOSE OF THIS SUBROUTINE:
   11264              :     // Updates the node variables with local variables.
   11265              : 
   11266              :     // Pass all variables from inlet to outlet node
   11267            0 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11268              : 
   11269              :     // Set outlet node variables that are possibly changed
   11270            0 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11271            0 : }
   11272            0 : void RefrigRackData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11273              : {
   11274            0 : }
   11275              : 
   11276            0 : void RefrigRackData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11277              : {
   11278            0 : }
   11279              : 
   11280            0 : void SimulateDetailedRefrigerationSystems(EnergyPlusData &state)
   11281              : {
   11282              : 
   11283              :     // SUBROUTINE INFORMATION:
   11284              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   11285              :     //       DATE WRITTEN   Spring 2008
   11286              :     //       Based upon ManageRefrigeratedCaseRacks by Richard Raustad, FSEC
   11287              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004
   11288              :     //       RE-ENGINEERED  na
   11289              : 
   11290              :     // PURPOSE OF THIS SUBROUTINE:
   11291              :     // This subroutine is called to simulate detailed refrigeration systems
   11292              : 
   11293              :     // METHODOLOGY EMPLOYED:
   11294              :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases.  The sum
   11295              :     // of the total heat transfer for all attached cases determines the load on the compressor rack.
   11296              :     // Iterations are used here to account for load transfer between independent refrigeration systems
   11297              :     // via mechanical subcoolers.
   11298              :     // The logical variable, UseSysTimeStep, determines whether we are evaluating only systems driven by
   11299              :     // ZoneEquipmentManager on the system time step, or only system driven by HVACManager on the zone time step.
   11300              : 
   11301              :     static constexpr std::string_view RoutineName = "SimulateDetailedRefrigerationSystems";
   11302            0 :     Real64 constexpr MaxDelTFloatFrac = 0.5; // max fraction allowed for difference between case and evaporator temperature
   11303              : 
   11304            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   11305            0 :     auto &System = state.dataRefrigCase->System;
   11306            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   11307            0 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   11308            0 :     auto &Secondary = state.dataRefrigCase->Secondary;
   11309            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   11310            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   11311            0 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   11312            0 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   11313              : 
   11314            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   11315            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   11316              : 
   11317              :     // Cascade condenser assumes a constant approach delta T (Tcond - Tevap), not f(load)
   11318              : 
   11319              :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   11320              :     // (all chiller coils within a set are located in the same zone)
   11321              :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   11322              :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   11323              :     // In that subroutine, dispatch coils within each set in order specified for each zone
   11324              :     //  Below will assign loads to refrigeration system or secondary loop
   11325              :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   11326              :     // with interactions will not be known for the initial calls with first HVAC time step. They will,
   11327              :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   11328              :     // that's why important where init goes, don't want to zero out data should keep
   11329            0 :     if (state.dataRefrigCase->UseSysTimeStep) {
   11330            0 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   11331            0 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   11332              :         }
   11333              :     }
   11334              : 
   11335              :     // Do refrigeration system loop outside of iterative solution to initialize time step and
   11336              :     //  calculate case, walk-in, and secondary loop loads (that won't change during balance
   11337              :     //  of refrigeration system iterations) and prepare initial estimates for the iterative system solution
   11338            0 :     for (auto &thisSys : System) {
   11339              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11340            0 :         if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11341            0 :             if (thisSys.NumCases > 0) {
   11342            0 :                 for (int CaseIndex = 1; CaseIndex <= thisSys.NumCases; ++CaseIndex) {
   11343            0 :                     auto &thisCase = RefrigCase(thisSys.CaseNum(CaseIndex));
   11344            0 :                     thisCase.CalculateCase(state);
   11345              :                     //  TevapDesign calc in Get Input to meet lowest evap temp of any load on the system.
   11346              :                     //  Tevap needed is either fixed at this design value,
   11347              :                     //  or allowed to float to meet lowest T needed among all loads served by the system
   11348              :                     //  (Floating Tevap = Design Tevap unless load <= Design cap)
   11349            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11350            0 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11351              :                     } else { // calculate floating T evap
   11352            0 :                         Real64 LoadFrac = min(1.0, (thisCase.TotalCoolingLoad / thisCase.DesignRatedCap));
   11353            0 :                         Real64 MaxTEvap = thisCase.Temperature - (thisCase.Temperature - thisCase.EvapTempDesign) * max(LoadFrac, MaxDelTFloatFrac);
   11354              :                         // Compare Tevap for this case to max allowed for all previous cases on this suction group and set at the MINIMUM of the
   11355              :                         // two
   11356            0 :                         if (CaseIndex == 1) { // note use case index, not caseid here to get first case on this suction group/system
   11357            0 :                             thisSys.TEvapNeeded = MaxTEvap;
   11358              :                         } else {
   11359            0 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11360              :                         }
   11361              :                     } // floating or constant evap temperature
   11362              :                     // increment TotalCoolingLoad for Compressors/condenser on each system and defrost condenser credits for heat recovery
   11363            0 :                     thisSys.TotalCoolingLoad += thisCase.TotalCoolingLoad;
   11364            0 :                     thisSys.TotalCondDefrostCredit += thisCase.HotDefrostCondCredit;
   11365              :                 } // NumCases
   11366              :             }     // Num of cases > 0
   11367              : 
   11368            0 :             if (thisSys.NumWalkIns > 0) {
   11369            0 :                 for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkIns; ++WalkInIndex) {
   11370            0 :                     auto &thisWalkIn = WalkIn(thisSys.WalkInNum(WalkInIndex));
   11371            0 :                     thisWalkIn.CalculateWalkIn(state);
   11372            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11373            0 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11374              :                     } else { // calculate floating T evap
   11375            0 :                         Real64 LoadFrac = min(1.0, (thisWalkIn.TotalCoolingLoad / thisWalkIn.DesignRatedCap));
   11376              :                         Real64 MaxTEvap =
   11377            0 :                             thisWalkIn.Temperature - (thisWalkIn.Temperature - thisWalkIn.TEvapDesign) * max(LoadFrac, MaxDelTFloatFrac);
   11378              :                         //  Compare maxTevap for this walk in to max allowed for cases and for all
   11379              :                         //  previous walk ins on this suction group and set at the MINIMUM of the two
   11380            0 :                         if (WalkInIndex == 1 && thisSys.NumCases == 0) {
   11381            0 :                             thisSys.TEvapNeeded = MaxTEvap;
   11382              :                         } else {
   11383            0 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11384              :                         }
   11385              :                     } // floating or constant evap temperature
   11386              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11387            0 :                     thisSys.TotalCoolingLoad += thisWalkIn.TotalCoolingLoad;
   11388            0 :                     thisSys.TotalCondDefrostCredit += thisWalkIn.HotDefrostCondCredit;
   11389              :                 } // NumWalkIns systems
   11390              :             }     // thisSys%NumWalkIns > 0
   11391              : 
   11392            0 :             if (thisSys.NumCoils > 0) {
   11393            0 :                 for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   11394            0 :                     int CoilID = thisSys.CoilNum(CoilIndex);
   11395              :                     // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   11396            0 :                     thisSys.TEvapNeeded = thisSys.TEvapDesign; // floating or constant evap temperature
   11397              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11398            0 :                     thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   11399            0 :                     thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   11400              :                 } // NumCoils systems
   11401              :             }     // thisSys%NumCoils > 0
   11402              : 
   11403            0 :             if (thisSys.NumSecondarys > 0) {
   11404            0 :                 for (int SecondIndex = 1; SecondIndex <= thisSys.NumSecondarys; ++SecondIndex) {
   11405            0 :                     int SecondID = thisSys.SecondaryNum(SecondIndex);
   11406            0 :                     Secondary(SecondID).CalculateSecondary(state, SecondID);
   11407            0 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11408            0 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11409              :                     } else { // check for lowest T evap design among the secondary systems and
   11410              :                         //  Compare Tevap for this second to max allowed for cases, walk ins, and
   11411              :                         //  for all previous secondary loops on this suction group and set
   11412              :                         //  at the MINIMUM (note secondary loops control capacity with
   11413              :                         //  brine flow rate, so don't float above their design evap temperature)
   11414            0 :                         if (SecondIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   11415            0 :                             thisSys.TEvapNeeded = Secondary(SecondID).TEvapDesign;
   11416              :                         } else {
   11417            0 :                             thisSys.TEvapNeeded = min(Secondary(SecondID).TEvapDesign, thisSys.TEvapNeeded);
   11418              :                         }
   11419              :                     } // floating or constant evap temperature
   11420              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11421            0 :                     thisSys.SumSecondaryLoopLoad += Secondary(SecondID).TotalCoolingLoad;
   11422            0 :                     thisSys.TotalCondDefrostCredit += Secondary(SecondID).HotDefrostCondCredit;
   11423              :                 } // NumSecondarys systems
   11424              :             }     // thisSys%NumSecondarys > 0
   11425              : 
   11426              :             // add suction pipe heat gains (W) if input by user
   11427              :             // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   11428              :             //  condenser and compressor loads. However, secondary dist piping and receiver gains are included
   11429              :             //  in the total secondary system loads.
   11430            0 :             thisSys.PipeHeatLoad = 0.0;
   11431            0 :             if (thisSys.SumUASuctionPiping > MySmallNumber) {
   11432            0 :                 Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNum)
   11433            0 :                                                  .Temp; // Temperature for zone identified as environment for suction pipe heat gains, C
   11434            0 :                 thisSys.PipeHeatLoad = thisSys.SumUASuctionPiping * (SuctionPipeZoneTemp - thisSys.TEvapNeeded);
   11435              :                 // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   11436              :                 //     from refrigcasecredit (- for cooling zone, + for heating zone)
   11437            0 :                 int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNum;
   11438            0 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   11439            0 :                     CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate -= thisSys.PipeHeatLoad;
   11440            0 :                     CoilSysCredit(SuctionPipeActualZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate;
   11441              :                 }
   11442              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11443            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11444            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11445            0 :                     state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoad;
   11446              :                 } // UseSysTimeStep
   11447              :             }
   11448              :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag)))
   11449              :     }     // SysNum
   11450              : 
   11451              :     // Need to know if mechanical subcoolers or cascade condensers or shared condensers
   11452              :     //    are present. If so, energy transfer between
   11453              :     //    detailed refrigeration systems requires additional iteration at this level.
   11454              : 
   11455            0 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system,
   11456            0 :     if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) || (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) ||
   11457            0 :         (state.dataRefrigCase->NumSimulationSharedCondensers > 0) || (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0))
   11458            0 :         StartMechSubcoolLoop = 1;
   11459              : 
   11460            0 :     bool FirstSCLoop = true; // Flag first time through multi-system loop used when mech subcoolers present
   11461              : 
   11462            0 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3;
   11463              :          ++LoopNum) { // Note, for cascade cond loads compared requiring 5 iterations to 3, no difference.
   11464              : 
   11465            0 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   11466            0 :             auto &thisSys = System(SysNum);
   11467              :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11468            0 :             if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11469            0 :                 thisSys.SumMechSCLoad = 0.0;
   11470            0 :                 thisSys.SumCascadeLoad = 0.0;
   11471            0 :                 thisSys.SumCascadeCondCredit = 0.0;
   11472            0 :                 thisSys.SumMechSCBenefit = 0.0;
   11473              : 
   11474            0 :                 if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) && (!FirstSCLoop)) {
   11475              :                     // This loop places load on system providing mechanical subcooling
   11476            0 :                     for (int SubcoolID = 1; SubcoolID <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolID) {
   11477            0 :                         if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) continue;
   11478            0 :                         if (Subcooler(SubcoolID).MechSourceSysID != SysNum) continue;
   11479              :                         // don't have summechscload until second subcooler pass, set to zero on first pass
   11480            0 :                         thisSys.SumMechSCLoad += thisSys.MechSCLoad(SubcoolID);
   11481              :                         // subcooler should not drive Tevap for supplying system,
   11482              :                         //    but check to see if T controlled can be met or if Tevap is at a higher temperature
   11483            0 :                         if (Subcooler(SubcoolID).MechControlTliqOut < thisSys.TEvapNeeded) {
   11484            0 :                             ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   11485            0 :                             ShowContinueError(state, " Evaporating temperature greater than the controlled ");
   11486            0 :                             ShowContinueError(state, format(" liquid outlet temperature for SUBCOOLER:{}", Subcooler(SubcoolID).Name));
   11487              :                         }
   11488              :                     } // SubcoolId
   11489              : 
   11490            0 :                     if (thisSys.NumSubcoolers > 0) {
   11491            0 :                         for (int SubcoolerIndex = 1; SubcoolerIndex <= thisSys.NumSubcoolers; ++SubcoolerIndex) {
   11492            0 :                             int SubcoolID = thisSys.SubcoolerNum(SubcoolerIndex);
   11493            0 :                             if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) continue;
   11494            0 :                             thisSys.SumMechSCBenefit = Subcooler(SubcoolID).MechSCTransLoad;
   11495              :                         } // subcoolerindex
   11496              :                     }     // System(sysid)%numsubcoolers > 0
   11497              :                 }         // NumSimulationMechSubcoolers > 0 and not first loop
   11498              : 
   11499              :                 // This loop places load on system absorbing heat from cascade condenser and &
   11500              :                 //     condenser heat reclaim credits from hot gas/brine defrosts
   11501            0 :                 if ((thisSys.NumCascadeLoads > 0) && (!FirstSCLoop)) {
   11502            0 :                     for (int CascadeLoadIndex = 1; CascadeLoadIndex <= thisSys.NumCascadeLoads; ++CascadeLoadIndex) {
   11503            0 :                         int CascadeLoadID = thisSys.CascadeLoadNum(CascadeLoadIndex);
   11504            0 :                         if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11505            0 :                             thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11506              :                         } else { // check for lowest T evap design among the CascadeLoad systems and
   11507              :                             //  Compare Tevap for this Cascade to max allowed for cases, walk ins, and
   11508              :                             //  for all previous CascadeLoad loops on this suction group and set
   11509              :                             //  at the MINIMUM
   11510            0 :                             if (Condenser(CascadeLoadID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet) {
   11511              :                                 // if float then set tevap based upon other loads
   11512            0 :                                 if (CascadeLoadIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   11513            0 :                                     thisSys.TEvapNeeded = Condenser(CascadeLoadID).CascadeRatedEvapTemp;
   11514              :                                 } else {
   11515            0 :                                     thisSys.TEvapNeeded = min(Condenser(CascadeLoadID).CascadeRatedEvapTemp, thisSys.TEvapNeeded);
   11516              :                                 }
   11517              :                             }
   11518              :                         } // floating or constant system evap temperature
   11519              :                         // increment Cascade condenser Loads for Compressors/condenser on each system
   11520              :                         // place any defrost credits on the same system absorbing the cascade condenser load
   11521              :                         // (CascadeSysID identifies the condenser producing the defrost credits, that is, the lower temp system)
   11522            0 :                         thisSys.SumCascadeLoad += Condenser(CascadeLoadID).CondLoad;
   11523            0 :                         thisSys.SumCascadeCondCredit += System(Condenser(CascadeLoadID).CascadeSysID).TotalCondDefrostCredit;
   11524              : 
   11525              :                     } // NumCascadeLoads
   11526              :                 }     // thisSys%NumCascadeLoads > 0
   11527              : 
   11528              :                 // only calc detailed system if have load (could be zero first time through if only load is cascade condenser)
   11529            0 :                 thisSys.TotalSystemLoad = thisSys.TotalCoolingLoad + thisSys.SumSecondaryLoopLoad + thisSys.SumMechSCLoad + thisSys.SumCascadeLoad;
   11530            0 :                 if (thisSys.TotalSystemLoad > 0.0) {
   11531            0 :                     thisSys.CpSatVapEvap = thisSys.refrig->getSatSpecificHeat(state, thisSys.TEvapNeeded, 1.0, RoutineName);
   11532            0 :                     thisSys.HCaseOut =
   11533            0 :                         thisSys.refrig->getSatEnthalpy(state, thisSys.TEvapNeeded, 1.0, RoutineName) + thisSys.CpSatVapEvap * CaseSuperheat;
   11534              :                     // Establish estimates to start solution loop
   11535            0 :                     switch (Condenser(thisSys.CondenserNum(1)).CondenserType) {
   11536            0 :                     case DataHeatBalance::RefrigCondenserType::Air: {
   11537            0 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 16.7;
   11538              :                         // 16.7C is delta T at rating point for air-cooled condensers, just estimate, so ok for zone-located condensers
   11539            0 :                     } break;
   11540            0 :                     case DataHeatBalance::RefrigCondenserType::Evap: {
   11541            0 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 15.0;
   11542              :                         // 15C is delta T at rating point for evap-cooled condensers
   11543            0 :                     } break;
   11544            0 :                     case DataHeatBalance::RefrigCondenserType::Water: {
   11545              :                         // define starting estimate at temperature of water exiting condenser
   11546            0 :                         thisSys.TCondense = state.dataLoopNodes->Node(Condenser(thisSys.CondenserNum(1)).OutletNode).Temp;
   11547            0 :                     } break;
   11548            0 :                     case DataHeatBalance::RefrigCondenserType::Cascade: {
   11549              :                         //?Don't need estimate for cascade condenser because it doesn't iterate?
   11550            0 :                     } break;
   11551            0 :                     default:
   11552            0 :                         break;
   11553              :                     }
   11554              : 
   11555              :                     // Produce first time step estimates, assume no subcoolers
   11556            0 :                     thisSys.HSatLiqCond = thisSys.refrig->getSatEnthalpy(state, thisSys.TCondense, 0.0, RoutineName);
   11557            0 :                     thisSys.CpSatLiqCond = thisSys.refrig->getSatSpecificHeat(state, thisSys.TCondense, 0.0, RoutineName);
   11558            0 :                     thisSys.HCaseIn = thisSys.HSatLiqCond - thisSys.CpSatLiqCond * Condenser(thisSys.CondenserNum(1)).RatedSubcool;
   11559            0 :                     thisSys.RefMassFlowtoLoads = thisSys.TotalSystemLoad / (thisSys.HCaseOut - thisSys.HCaseIn);
   11560            0 :                     thisSys.RefMassFlowComps = thisSys.RefMassFlowtoLoads;
   11561              : 
   11562            0 :                     if (thisSys.NumStages == 2) { // Two-stage compression system
   11563              :                         // Initial guess for high-stage mass flow rate in two-stage compression systems
   11564            0 :                         thisSys.RefMassFlowHiStageComps = thisSys.RefMassFlowComps / 0.65;
   11565              :                     }
   11566              : 
   11567            0 :                     thisSys.CalcDetailedSystem(state, SysNum);
   11568              : 
   11569              :                     bool DeRate; // If true, need to derate aircoils because load can't be met by system
   11570              : 
   11571              :                     // With air chiller coils, don't use unmet energy, instead reduce capacity on coils to match avail compressor/cond capacity
   11572              :                     // current loads on compressor, exclusive of unmet loads from prev time steps
   11573            0 :                     Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   11574            0 :                     if ((thisSys.CoilFlag) && (CurrentLoads > (thisSys.TotCompCapacity * 1.001))) {
   11575            0 :                         DeRate = true;
   11576            0 :                         FinalRateCoils(state, DeRate, SourceType::DetailedSystem, SysNum, CurrentLoads, thisSys.TotCompCapacity);
   11577            0 :                         thisSys.TotalCoolingLoad = 0.0;
   11578            0 :                         thisSys.TotalCondDefrostCredit = 0.0;
   11579            0 :                         for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   11580            0 :                             int CoilID = thisSys.CoilNum(CoilIndex);
   11581              :                             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   11582            0 :                             if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11583            0 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11584              :                             } else { // calculate floating T evap
   11585            0 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11586            0 :                                 ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   11587            0 :                                 ShowContinueError(state, " Floating evaporator temperature model not yet available for warehouse coil systems. ");
   11588              :                             } // floating or constant evap temperature
   11589              :                             // increment TotalCoolingLoad for Compressors/condenser on each system
   11590            0 :                             thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   11591            0 :                             thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   11592              :                         } // NumCoils systems
   11593            0 :                         if (thisSys.NumStages == 2 &&
   11594            0 :                             thisSys.TotHiStageCompCapacity < (thisSys.TotalCoolingLoad + thisSys.LSHXTrans + thisSys.TotCompPower)) {
   11595            0 :                             ShowRecurringWarningErrorAtEnd(state,
   11596            0 :                                                            "Refrigeration:System: " + thisSys.Name +
   11597              :                                                                ":The specified high-stage compressors for this system are unable to meet the sum "
   11598              :                                                                "of the refrigeration loads, ",
   11599            0 :                                                            thisSys.HiStageWarnIndex1);
   11600            0 :                             ShowRecurringContinueErrorAtEnd(
   11601            0 :                                 state, " subcooler loads (if any), and low-stage compressor loads for this system.", thisSys.HiStageWarnIndex2);
   11602              :                         } // Hi-stage capacity<(load+LSHX load + lo-stage compressor load)
   11603              :                     }     // CoilFlag (Numcoils > 0) and load > capacity
   11604              : 
   11605              :                 } // thisSys%TotalSystemLoad > 0
   11606              :             }     //(((.NOT. UseSysTimeStep).AND.(.NOT. thisSys%CoilFlag)).OR.((UseSysTimeStep).AND.(thisSys%CoilFlag)))
   11607              :         }         // SysNum over NumRefrigSystems
   11608            0 :         FirstSCLoop = false;
   11609              :     } // LoopNum, three times for buildings with multiple detailed systems connected with mechanical subcoolers
   11610              :     // or cascade condensers or shared condensers or warehouse coils that might need to be de-rated
   11611              : 
   11612              :     // Dealing with unmet load has to be done outside iterative loop
   11613            0 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   11614            0 :         auto &thisSys = System(SysNum);
   11615              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11616            0 :         if ((((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) &&
   11617            0 :             (!state.dataGlobal->WarmupFlag)) {
   11618            0 :             Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   11619            0 :             Real64 CurrentHiStageLoads(0.0); // Current loads on high-stage compressor, exclusive of unmet loads from
   11620            0 :             if (thisSys.NumStages == 2) {
   11621            0 :                 CurrentHiStageLoads = CurrentLoads + thisSys.TotCompPower;
   11622              :             } // NumStages==2
   11623            0 :             if (thisSys.CoilFlag) {
   11624              :                 // don't use 'unmet energy' with air chillers, see 'derate'
   11625            0 :                 thisSys.UnmetEnergy = 0.0;
   11626            0 :                 thisSys.UnmetHiStageEnergy = 0.0;
   11627              :             } else {
   11628              :                 // Meeting current and possibly some portion of the previously unmet energy
   11629              :                 // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   11630              :                 // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   11631              :                 // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   11632            0 :                 thisSys.UnmetEnergy += (CurrentLoads - thisSys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   11633            0 :                 if (thisSys.NumStages == 2) {
   11634            0 :                     thisSys.UnmetHiStageEnergy += (CurrentHiStageLoads - thisSys.TotHiStageCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   11635              :                 }
   11636            0 :                 if (thisSys.UnmetEnergy > MyLargeNumber) {
   11637            0 :                     thisSys.UnmetEnergy = MyLargeNumber;
   11638            0 :                     if (state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum)) {
   11639            0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   11640            0 :                         ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   11641            0 :                         ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this system.");
   11642            0 :                         state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum) = false;
   11643              :                     } // show warning
   11644              :                 }     // > mylarge number
   11645            0 :                 if (thisSys.UnmetHiStageEnergy > MyLargeNumber) {
   11646            0 :                     thisSys.UnmetHiStageEnergy = MyLargeNumber;
   11647            0 :                     if (state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum)) {
   11648            0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   11649            0 :                         ShowContinueError(state, " The specified high-stage compressors for this system are unable to meet ");
   11650            0 :                         ShowContinueError(state, " the sum of the refrigerated case loads, subcooler loads (if any) and ");
   11651            0 :                         ShowContinueError(state, " low-stage compressor loads for this system.");
   11652            0 :                         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum) = false;
   11653              :                     } // show warning
   11654              :                 }     // > mylarge number
   11655              :             }         // numcoils > 0
   11656              : 
   11657              :             // Zone-located air-cooled condenser reject heat also has to be outside iterative loop
   11658            0 :             if (thisSys.SystemRejectHeatToZone) {
   11659            0 :                 int CondInletAirZoneNum = Condenser(thisSys.CondenserNum(1)).InletAirZoneNum;
   11660            0 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   11661            0 :                     CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate += thisSys.NetHeatRejectLoad; // Adding heat is positive
   11662            0 :                     CoilSysCredit(CondInletAirZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate;
   11663              :                 }
   11664              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11665            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11666            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11667            0 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone +=
   11668            0 :                         thisSys.NetHeatRejectLoad; // Adding heat is positive
   11669              :                 }                                  // UseSystimestep
   11670              :             }                                      // Reject heat to zone
   11671              : 
   11672              :             // Report variables
   11673            0 :             thisSys.TotTransferLoad = thisSys.SumMechSCLoad - thisSys.SumMechSCBenefit + thisSys.SumSecondaryLoopLoad + thisSys.SumCascadeLoad;
   11674            0 :             thisSys.TotTransferEnergy = thisSys.TotTransferLoad * localTimeStepSec;
   11675            0 :             thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * localTimeStepSec;
   11676            0 :             thisSys.TotalCoolingEnergy = thisSys.TotalCoolingLoad * localTimeStepSec;
   11677              :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag))).and.not
   11678              :           // WarmupFlag
   11679              :     }     // SysNum = 1,NumRefrigSystems
   11680              : 
   11681              :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   11682              :     //   LatOutputProvided = CoilSysCredit(ZoneNum)%LatKgPerS_ToZoneRate
   11683              :     //   SysOutputProvided = CoilSysCredit(ZoneNum)%SenCreditToZoneRate
   11684              :     // Note that case credit is negative for cooling, thus subtract positive value calculated for coil
   11685              :     //   Note this is done whether or not the coils are derated.
   11686            0 :     if (state.dataRefrigCase->UseSysTimeStep) {
   11687            0 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   11688            0 :             auto &zoneCredit = CoilSysCredit(ZoneNum);
   11689            0 :             for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
   11690            0 :                 auto &coil = WarehouseCoil(CoilID);
   11691            0 :                 if (coil.ZoneNum != ZoneNum) continue;
   11692            0 :                 zoneCredit.SenCreditToZoneRate -= coil.SensCreditRate;
   11693            0 :                 zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * localTimeStepSec;
   11694            0 :                 zoneCredit.LatKgPerS_ToZoneRate -= coil.LatKgPerS_ToZone;
   11695            0 :                 zoneCredit.LatCreditToZoneRate -= coil.LatCreditRate;
   11696            0 :                 zoneCredit.LatCreditToZoneEnergy -= coil.LatCreditEnergy;
   11697              :             }
   11698              :         }
   11699              :     }
   11700              : 
   11701            0 :     SumZoneImpacts(state);
   11702            0 : }
   11703              : 
   11704            0 : void SimulateDetailedTransRefrigSystems(EnergyPlusData &state)
   11705              : {
   11706              : 
   11707              :     // SUBROUTINE INFORMATION:
   11708              :     //       AUTHOR         Brian A. Fricke, ORNL
   11709              :     //       DATE WRITTEN   Fall 2011
   11710              :     //       RE-ENGINEERED  na
   11711              : 
   11712              :     // PURPOSE OF THIS SUBROUTINE:
   11713              :     // This subroutine is called to simulate detailed transcritical CO2 refrigeration systems
   11714              : 
   11715              :     // METHODOLOGY EMPLOYED:
   11716              :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases and
   11717              :     // walk-ins. The sum of the total heat transfer for all attached cases and walk-ins determines
   11718              :     // the load on the compressors. Iterations are used here to account for sharing of gas coolers
   11719              :     // between independent refrigeration systems.
   11720              : 
   11721              :     static constexpr std::string_view RoutineName = "SimulateDetailedTransRefrigSystems";
   11722              : 
   11723            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   11724            0 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   11725            0 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   11726            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   11727              : 
   11728            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   11729            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   11730              : 
   11731              :     //  Do transcritical CO2 refrigeration system loop outside of iterative solution to initialize time step and
   11732              :     //  calculate case and and walk-ins (that won't change during balance of refrigeration system iterations)
   11733              :     //  and prepare initial estimates for the iterative system solution
   11734              : 
   11735              :     //  TransCritSysFlag = .TRUE.
   11736            0 :     for (auto &thisSys : TransSystem) {
   11737              :         // Only do those systems appropriate for this analysis, supermarket type on load time step
   11738            0 :         if (thisSys.NumCasesMT > 0) {
   11739            0 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesMT; ++CaseIndex) {
   11740            0 :                 int CaseID = thisSys.CaseNumMT(CaseIndex);
   11741            0 :                 RefrigCase(CaseID).CalculateCase(state);
   11742              :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   11743              :                 //  TEvapNeededMT is fixed at this design value.
   11744            0 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   11745              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   11746            0 :                 thisSys.TotalCoolingLoadMT += RefrigCase(CaseID).TotalCoolingLoad;
   11747            0 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   11748              :             } // NumCasesMT
   11749              :         }     // Num of MT cases > 0
   11750              : 
   11751            0 :         if (thisSys.NumCasesLT > 0) {
   11752            0 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesLT; ++CaseIndex) {
   11753            0 :                 int CaseID = thisSys.CaseNumLT(CaseIndex);
   11754            0 :                 RefrigCase(CaseID).CalculateCase(state);
   11755              :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   11756              :                 //  TEvapNeededLT is fixed at this design value.
   11757            0 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   11758              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   11759            0 :                 thisSys.TotalCoolingLoadLT += RefrigCase(CaseID).TotalCoolingLoad;
   11760            0 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   11761              :             } // NumCasesLT
   11762              :         }     // Num of LT cases > 0
   11763              : 
   11764            0 :         if (thisSys.NumWalkInsMT > 0) {
   11765            0 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsMT; ++WalkInIndex) {
   11766            0 :                 int WalkInID = thisSys.WalkInNumMT(WalkInIndex);
   11767            0 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   11768              :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   11769              :                 //  TEvapNeededMT is fixed at this design value.
   11770            0 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   11771              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   11772            0 :                 thisSys.TotalCoolingLoadMT += WalkIn(WalkInID).TotalCoolingLoad;
   11773            0 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   11774              :             } // NumWalkInsMT systems
   11775              :         }     // thisSys%NumWalkInsMT > 0
   11776              : 
   11777            0 :         if (thisSys.NumWalkInsLT > 0) {
   11778            0 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsLT; ++WalkInIndex) {
   11779            0 :                 int WalkInID = thisSys.WalkInNumLT(WalkInIndex);
   11780            0 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   11781              :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   11782              :                 //  TEvapNeeded is fixed at this design value.
   11783            0 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   11784              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   11785            0 :                 thisSys.TotalCoolingLoadLT += WalkIn(WalkInID).TotalCoolingLoad;
   11786            0 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   11787              :             } // NumWalkInsLT systems
   11788              :         }     // thisSys%NumWalkInsLT > 0
   11789              : 
   11790              :         // add suction pipe heat gains (W) if input by user
   11791              :         // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   11792              :         //  gas cooler and compressor loads.
   11793            0 :         thisSys.PipeHeatLoadMT = 0.0;
   11794            0 :         if (thisSys.SumUASuctionPipingMT > MySmallNumber) {
   11795            0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumMT).Temp;
   11796            0 :             thisSys.PipeHeatLoadMT = thisSys.SumUASuctionPipingMT * (SuctionPipeZoneTemp - thisSys.TEvapNeededMT);
   11797              :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   11798              :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   11799            0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumMT;
   11800              :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11801            0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11802            0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11803            0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadMT;
   11804              :             } // UseSysTimeStep
   11805              :         }
   11806              : 
   11807            0 :         thisSys.PipeHeatLoadLT = 0.0;
   11808            0 :         if (thisSys.SumUASuctionPipingLT > MySmallNumber) {
   11809            0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumLT).Temp;
   11810            0 :             thisSys.PipeHeatLoadLT = thisSys.SumUASuctionPipingLT * (SuctionPipeZoneTemp - thisSys.TEvapNeededLT);
   11811              :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   11812              :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   11813            0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumLT;
   11814              :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11815            0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11816            0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11817            0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadLT;
   11818              :             } // UseSysTimeStep
   11819              :         }
   11820              : 
   11821              :     } // SysNum
   11822              : 
   11823              :     // Need to know if shared gas coolers are present. If so, energy
   11824              :     // transfer between detailed transcritical refrigeration systems
   11825              :     // requires additional iteration at this level.
   11826              : 
   11827            0 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system, don't loop
   11828            0 :     if (state.dataRefrigCase->NumSimulationSharedGasCoolers > 0) StartMechSubcoolLoop = 1;
   11829              : 
   11830            0 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3; ++LoopNum) {
   11831            0 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   11832            0 :             auto &sys = TransSystem(SysNum);
   11833              :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11834              :             // only calc detailed system if have load
   11835            0 :             sys.TotalSystemLoadMT = sys.TotalCoolingLoadMT;
   11836            0 :             if (sys.transSysType == TransSysType::TwoStage) {
   11837            0 :                 sys.TotalSystemLoadLT = sys.TotalCoolingLoadLT;
   11838              :             }
   11839            0 :             sys.TotalSystemLoad = sys.TotalSystemLoadLT + sys.TotalSystemLoadMT;
   11840            0 :             if (sys.TotalSystemLoad > 0.0) {
   11841            0 :                 if (sys.transSysType == TransSysType::TwoStage) {
   11842            0 :                     sys.CpSatVapEvapLT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededLT, 1.0, RoutineName);
   11843            0 :                     sys.HCaseOutLT = sys.refrig->getSatEnthalpy(state, sys.TEvapNeededLT, 1.0, RoutineName) + sys.CpSatVapEvapLT * TransCaseSuperheat;
   11844              :                 }
   11845            0 :                 sys.CpSatVapEvapMT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededMT, 1.0, RoutineName);
   11846            0 :                 sys.HCaseOutMT = sys.refrig->getSatEnthalpy(state, sys.TEvapNeededMT, 1.0, RoutineName) + sys.CpSatVapEvapMT * TransCaseSuperheat;
   11847              : 
   11848              :                 // Produce first time step estimates.
   11849              :                 // Assume no subcoolers and neglect flow through bypass.
   11850            0 :                 sys.TReceiver = sys.refrig->getSatTemperature(state, sys.PReceiver, RoutineName);
   11851            0 :                 sys.HSatLiqReceiver = sys.refrig->getSatEnthalpy(state, sys.TReceiver, 0.0, RoutineName);
   11852            0 :                 sys.CpSatLiqReceiver = sys.refrig->getSatSpecificHeat(state, sys.TReceiver, 0.0, RoutineName);
   11853            0 :                 sys.HCaseInMT = sys.HSatLiqReceiver;
   11854            0 :                 sys.HCaseInLT = sys.HSatLiqReceiver;
   11855            0 :                 sys.RefMassFlowtoLTLoads = 0.0;
   11856            0 :                 sys.RefMassFlowCompsLP = 0.0;
   11857            0 :                 sys.DelHSubcoolerDis = 0.0;
   11858            0 :                 sys.DelHSubcoolerSuc = 0.0;
   11859            0 :                 if (sys.transSysType == TransSysType::TwoStage) {
   11860            0 :                     sys.RefMassFlowtoLTLoads = sys.TotalSystemLoadLT / (sys.HCaseOutLT - sys.HCaseInLT);
   11861            0 :                     sys.RefMassFlowCompsLP = sys.RefMassFlowtoLTLoads;
   11862              :                 } // (thisSys%TransSysType == 2)
   11863            0 :                 sys.RefMassFlowtoMTLoads = sys.TotalSystemLoadMT / (sys.HCaseOutMT - sys.HCaseInMT);
   11864            0 :                 sys.RefMassFlowCompsHP = sys.RefMassFlowtoLTLoads + sys.RefMassFlowtoMTLoads;
   11865              : 
   11866            0 :                 sys.CalcDetailedTransSystem(state, SysNum);
   11867              :                 //       TransCritSysFlag = .FALSE.
   11868              : 
   11869              :             } // TransSystem(SysNum)%TotalSystemLoad > 0
   11870              :         }     // SysNum over NumRefrigSystems
   11871              :     }         // LoopNum, three times for buildings with multiple detailed systems connected with shared gas coolers
   11872              : 
   11873              :     // Unmet load is done outside iterative loop
   11874            0 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   11875            0 :         auto &sys = TransSystem(SysNum);
   11876              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11877            0 :         if ((!state.dataRefrigCase->UseSysTimeStep) && (!state.dataGlobal->WarmupFlag)) {
   11878            0 :             Real64 CurrentLoads = sys.TotalSystemLoad;
   11879              :             // Meeting current and possibly some portion of the previously unmet energy
   11880              :             // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   11881              :             // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   11882              :             // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   11883            0 :             sys.UnmetEnergy += (CurrentLoads - sys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   11884              : 
   11885            0 :             if (sys.UnmetEnergy > MyLargeNumber) {
   11886            0 :                 sys.UnmetEnergy = MyLargeNumber;
   11887            0 :                 if (state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum)) {
   11888            0 :                     ShowWarningError(state, format("Refrigeration:TranscriticalSystem: {}", sys.Name));
   11889            0 :                     ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   11890            0 :                     ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this system.");
   11891            0 :                     state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum) = false;
   11892              :                 } // show warning
   11893              :             }     // > mylarge number
   11894              : 
   11895              :             // Zone-located air-cooled gas cooler reject heat also has to be outside iterative loop
   11896            0 :             if (sys.SystemRejectHeatToZone) {
   11897            0 :                 int CondInletAirZoneNum = GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum;
   11898              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11899            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11900            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11901            0 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone += sys.NetHeatRejectLoad; // Adding heat is positive
   11902              :                 }                                                                                                          // UseSystimestep
   11903              :             }                                                                                                              // Reject heat to zone
   11904              : 
   11905              :             // Report variables
   11906            0 :             sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * localTimeStepSec;
   11907            0 :             sys.TotalCoolingEnergy = (sys.TotalCoolingLoadMT + sys.TotalCoolingLoadMT) * localTimeStepSec;
   11908              :         } //(.NOT. UseSysTimeStep).AND. (.not. WarmupFlag)
   11909              :     }     // SysNum = 1,NumTransRefrigSystems
   11910              : 
   11911              :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   11912              : 
   11913            0 :     SumZoneImpacts(state);
   11914            0 : }
   11915              : 
   11916            0 : void RefrigSystemData::CalcDetailedSystem(EnergyPlusData &state, int const SysNum)
   11917              : {
   11918              : 
   11919              :     // SUBROUTINE INFORMATION:
   11920              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   11921              :     //       DATE WRITTEN   Spring 2008
   11922              :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   11923              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   11924              :     //       RE-ENGINEERED  na
   11925              : 
   11926              :     // PURPOSE OF THIS SUBROUTINE:
   11927              :     // Find the power and energy needed to meet the refrigeration loads for a particular detailed
   11928              :     // refrigeration system comprised of multiple cases, one condenser, and multiple compressors.
   11929              : 
   11930              :     // METHODOLOGY EMPLOYED:
   11931              :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   11932              :     // Using the initial estimate for condensing temperature, dispatch the compressors to
   11933              :     // determine the needed power, energy consumption, and refrigerant mass flow.
   11934              :     // Calculate the condenser fan/pump power and consumption.
   11935              :     // Calculate the condensing temperature as a function of environment and load.
   11936              :     // Resolve the impact of subcooler heat transfer between and among systems
   11937              :     // Iterate until the calculated refrigerant mass flow through the compressors converges, which
   11938              :     // typically requires less than 5 iterations. This was found to be more sensitive than converging
   11939              :     // upon the calculated condensing temperature.
   11940              : 
   11941              :     // REFERENCES:
   11942              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   11943              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   11944              : 
   11945              :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   11946              :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   11947              :     //  Master of Science, University of Wisconsin-Madison, 1999
   11948              : 
   11949            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   11950              : 
   11951            0 :     bool NotBalanced = true;
   11952            0 :     int NumIter = 0;
   11953            0 :     Real64 ErrorMassFlowComps(0.0);        // Error in calculated low stage compressor mass flow (single- or two-stage systems)
   11954            0 :     Real64 ErrorMassFlowHiStageComps(0.0); // Error in calculated high-stage compressor mass flow (two-stage systems only)
   11955              : 
   11956              :     // Balance This Refrigeration System using calculated refrigerant flow
   11957            0 :     Real64 MassFlowHiStageCompsStart(0.0); // Mass flow through high-stage compressors (two-stage systems only)
   11958              : 
   11959            0 :     while (NotBalanced) {
   11960              :         // Set values for iteration convergence tolerance check
   11961            0 :         ++NumIter;
   11962              :         // Mass flow through (low-stage) compressors (single- or two-stage systems)
   11963            0 :         Real64 MassFlowCompsStart = this->RefMassFlowComps;
   11964              : 
   11965            0 :         if (this->NumStages == 2) { // Two-stage systems
   11966            0 :             MassFlowHiStageCompsStart = this->RefMassFlowHiStageComps;
   11967              :         }
   11968              : 
   11969            0 :         if (this->NumSubcoolers > 0) this->CalculateSubcoolers(state);
   11970            0 :         this->CalculateCompressors(state);
   11971            0 :         this->CalculateCondensers(state, SysNum);
   11972            0 :         this->RefMassFlowtoLoads = this->TotalSystemLoad / (this->HCaseOut - this->HCaseIn);
   11973            0 :         if (NumIter < 2) continue;
   11974              :         // Previously did error check on calculated Tcondense, but not sensitive enough
   11975            0 :         if ((this->RefMassFlowtoLoads == 0.0) || (MassFlowCompsStart == 0.0)) { //.OR. (MassFlowCasesStart == 0.0)
   11976            0 :             ShowWarningError(state, format("Refrigeration:System: {} showing zero refrigeration flow.", this->Name));
   11977              :         } else {
   11978            0 :             ErrorMassFlowComps = std::abs(MassFlowCompsStart - this->RefMassFlowComps) / MassFlowCompsStart;
   11979            0 :             if (this->NumStages == 2) { // Two-stage systems
   11980            0 :                 ErrorMassFlowHiStageComps = std::abs(MassFlowHiStageCompsStart - this->RefMassFlowHiStageComps) / MassFlowCompsStart;
   11981              :             }
   11982              :         } // denominator zero check
   11983            0 :         if (NumIter > 20) break;
   11984            0 :         if (ErrorMassFlowComps < ErrorTol) {
   11985            0 :             if (this->NumStages == 1 || (this->NumStages == 2 && ErrorMassFlowHiStageComps < ErrorTol)) {
   11986            0 :                 NotBalanced = false;
   11987              :             }
   11988              :         }
   11989              :     } // error check
   11990            0 : }
   11991              : 
   11992            0 : void TransRefrigSystemData::CalcDetailedTransSystem(EnergyPlusData &state, int const SysNum)
   11993              : {
   11994              : 
   11995              :     // SUBROUTINE INFORMATION:
   11996              :     //       AUTHOR         Brian A. Fricke, ORNL
   11997              :     //       DATE WRITTEN   Fall 2011
   11998              :     //       MODIFIED       na
   11999              :     //       RE-ENGINEERED  na
   12000              : 
   12001              :     // PURPOSE OF THIS SUBROUTINE:
   12002              :     // Find the power and energy needed to meet the refrigeration loads for a detailed transcritical
   12003              :     // CO2 refrigeration system comprised of multiple cases and walk-ins, one gas cooler, and
   12004              :     // multiple compressors.
   12005              : 
   12006              :     // METHODOLOGY EMPLOYED:
   12007              :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   12008              :     // Dispatch the compressors to determine the needed power, energy consumption, and refrigerant
   12009              :     // mass flow. Calculate the gas cooler fan power and consumption. Calculate the gas cooler
   12010              :     // outlet temperature and pressure as a function of ambient temperature. Iterate until the
   12011              :     // calculated refrigerant mass flow through the receiver bypass converges, which typically
   12012              :     // requires less than 5 iterations.
   12013              : 
   12014            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12015              : 
   12016            0 :     int NumIter(0);            // Iteration counter
   12017            0 :     bool NotBalanced(true);    // Flag to indicate convergence, based on system balance
   12018            0 :     Real64 MassFlowStart(0.5); // Initial refrigerant mass flow through receiver bypass
   12019              :     Real64 ErrorMassFlow;      // Error in calculated refrigerant mass flow through receiver bypass
   12020              : 
   12021            0 :     while (NotBalanced) {
   12022            0 :         ++NumIter;
   12023              : 
   12024            0 :         if (this->NumGasCoolers >= 1) this->CalcGasCooler(state, SysNum);
   12025            0 :         this->CalculateTransCompressors(state);
   12026            0 :         if (NumIter < 2) continue;
   12027            0 :         if ((this->RefMassFlowReceiverBypass == 0.0) || (MassFlowStart == 0.0)) {
   12028            0 :             ShowSevereError(state,
   12029            0 :                             format("Refrigeration:TranscriticalSystem: {} showing zero refrigerant flow through receiver bypass.", this->Name));
   12030            0 :             ShowContinueError(state, format("Receiver Bypass Flow = {:.6R}", this->RefMassFlowReceiverBypass));
   12031            0 :             ShowContinueError(state, "Check input file to ensure that refrigeration loads on this system are not zero.");
   12032              :         } else {
   12033            0 :             ErrorMassFlow = std::abs(MassFlowStart - this->RefMassFlowReceiverBypass) / MassFlowStart;
   12034            0 :             MassFlowStart = this->RefMassFlowReceiverBypass;
   12035              :         } // denominator zero check
   12036            0 :         if (NumIter > 20) break;
   12037            0 :         if (ErrorMassFlow < ErrorTol) NotBalanced = false;
   12038              :     } // error check
   12039            0 : }
   12040              : 
   12041            0 : void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysNum)
   12042              : {
   12043              : 
   12044              :     // SUBROUTINE INFORMATION:
   12045              :     //       AUTHOR         Therese Stovall and C. R. Hudson, ORNL, Assisted by Hugh Henderson
   12046              :     //       DATE WRITTEN   Spring 2008
   12047              :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   12048              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   12049              :     //       RE-ENGINEERED  na
   12050              : 
   12051              :     // PURPOSE OF THIS SUBROUTINE:
   12052              :     // Find the condenser heat rejection for a particular detailed
   12053              :     // refrigeration system and condensing temperature (part of iterative soln for cond temp).
   12054              : 
   12055              :     // METHODOLOGY EMPLOYED:
   12056              :     // Calculate the condenser fan/pump power and consumption
   12057              :     // using manufacturer's rating data and fan power correlations
   12058              :     // from ASHRAE and evaporative effectiveness based on enthalpy
   12059              :     // similar to work done by Manske.
   12060              : 
   12061              :     // From Heejin Cho, Re variable frequency drive fans,
   12062              :     // "From HVAC forums, I learned that it is common practice to set a
   12063              :     // minimum frequency at 15 or 20 Hz to protect motors from overheating. The
   12064              :     // full speed is at 60 Hz. The ratio of minimum and maximum frequencies
   12065              :     // will correspond to the ratio of minimum and maximum flow rates."
   12066              : 
   12067              :     // REFERENCES:
   12068              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12069              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12070              : 
   12071              :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   12072              :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   12073              :     //  Master of Science, University of Wisconsin-Madison, 1999
   12074              : 
   12075              :     // Lawrence Berkeley Laboratory and Resource Dynamics, Improving Fan System Performance,
   12076              :     //   A Sourcebook for Industry, DOE/GO-102003-1294, April 2003
   12077              : 
   12078            0 :     Real64 constexpr BleedRateConstant = 5.0E-10; // water purge rate for evaporative
   12079              :     //  condensers (m3/W-s) equal to 3 GPM per 100 tons (BAC Engineering Reference)
   12080              : 
   12081            0 :     auto &System = state.dataRefrigCase->System;
   12082            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   12083              : 
   12084              :     int CondID;               // Condenser Number
   12085              :     int CondCreditWarnIndex1; // Used to sum up warning count
   12086              :     int CondCreditWarnIndex2; // Used to sum up warning count
   12087              :     int CondCreditWarnIndex3; // Used to sum up warning count
   12088              :     int CondCreditWarnIndex4; // Used to sum up warning count
   12089              :     int CondCreditWarnIndex5; // Used to sum up warning count
   12090              :     int CondCreditWarnIndex6; // Used to sum up warning count
   12091              :     int CondCreditWarnIndex7; // Used to sum up warning count
   12092              :     int Sysloop;              // counter over number of systems attached to this condenser
   12093              :     int SystemID;             // System number rejecting heat to this condenser
   12094              :     bool EvapAvail;           // Control for evap condenser availability
   12095              : 
   12096              :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   12097              :     Real64 AirDensity;                  // Density of air at condenser inlet [kg/m3]
   12098              :     Real64 AirDensityDry;               // Density of dry air at condenser inlet temperature [kg/m3]
   12099              :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded condenser [W]
   12100              :     Real64 BPress;                      // Barometric pressure at condenser air inlet node [Pa]
   12101              :     Real64 CapFac;                      // Capacity Factor
   12102              :     Real64 Effectiveness;               // for evap condenser, =capacity/max cap, where max cap is cap if Tairout equal Tcondense
   12103              :     Real64 EnthalpyAtTcond;             // enthalpy of saturated air at Tcondense
   12104              :     Real64 EnthalpyAirIn;               // Enthalpy of air entering condenser [J/kg]
   12105              :     Real64 EnthalpyAirOut;              // Enthalpy of air leaving condenser [J/kg]
   12106              :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   12107              :     Real64 FanPowerRatio;               // Calculated fan power ratio
   12108            0 :     Real64 HRCF(0.0);                   // Heat Rejection Capacity Factor (convention for evap condensers)
   12109              :     Real64 HRCFFullFlow;                // Heat Rejection Capacity Factor at full air flow
   12110              :     Real64 HumRatIn;                    // Humidity ratio of inlet air to condenser [kg/kg]
   12111              :     Real64 HumRatOut;                   // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   12112            0 :     Real64 OutWbTemp(0.0);              // Outdoor wet bulb temp at condenser air inlet node [C]
   12113              :     Real64 OutDbTemp;                   // Outdoor dry bulb temp at condenser air inlet node [C]
   12114              :     Real64 PurgeRate;                   // Rate of water blow-down/bleed/purge in evap condenser (m3/s)
   12115              :     Real64 RatedFanPower;               // local variable equal to input condenser value
   12116              :     Real64 RatedAirFlowRate;            // local variable equal to input condenser value
   12117              :     Real64 SinkTemp;                    // Heat sink temperature used to derate fan power at reduced loads [C]
   12118              :     Real64 TCondCalc;                   // Calculated Condensing temperature
   12119              :     Real64 TotalCondDefrostCreditLocal; // total cond credit from hot gas/brine defr for cases etc. served
   12120              :     //     directly by all systems served by this condenser [W]
   12121              :     Real64 TotalCondDefCredfromSysID;    // cond credit for single system [W]
   12122            0 :     Real64 TotalLoadFromThisSystem(0.0); // total heat rejection load from the detailed system id'd in subroutine call [W]
   12123              :     Real64 TotalLoadFromSystems;         // total heat rejection load from all systems served by this condenser [W]
   12124              : 
   12125            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12126            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12127              : 
   12128              :     // Initialize this condenser for this time step
   12129            0 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   12130            0 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   12131            0 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12132            0 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   12133            0 :     ActualFanPower = 0.0;
   12134            0 :     TotalCondDefrostCreditLocal = 0.0;
   12135            0 :     TotalLoadFromSystems = 0.0;
   12136            0 :     EvapAvail = true;
   12137            0 :     CondID = this->CondenserNum(1);
   12138            0 :     auto &condenser = Condenser(CondID);
   12139            0 :     RatedFanPower = condenser.RatedFanPower;
   12140            0 :     RatedAirFlowRate = condenser.RatedAirFlowRate;
   12141            0 :     FanMinAirFlowRatio = condenser.FanMinAirFlowRatio;
   12142            0 :     CondCreditWarnIndex1 = condenser.CondCreditWarnIndex1;
   12143            0 :     CondCreditWarnIndex2 = condenser.CondCreditWarnIndex2;
   12144            0 :     CondCreditWarnIndex3 = condenser.CondCreditWarnIndex3;
   12145            0 :     CondCreditWarnIndex4 = condenser.CondCreditWarnIndex4;
   12146            0 :     CondCreditWarnIndex5 = condenser.CondCreditWarnIndex5;
   12147            0 :     CondCreditWarnIndex6 = condenser.CondCreditWarnIndex6;
   12148            0 :     CondCreditWarnIndex7 = condenser.CondCreditWarnIndex7;
   12149              : 
   12150              :     // Sum total condenser load and defrost credits for all systems connected to this condenser
   12151              :     //  The system values will match the last time that system was solved, so some of the values may be
   12152              :     //  from the previous overall solution iteration.  However, solution goes through 3 iterations if
   12153              :     //  there are any shared condensers, so that's ok.
   12154            0 :     for (Sysloop = 1; Sysloop <= condenser.NumSysAttach; ++Sysloop) {
   12155            0 :         SystemID = condenser.SysNum(Sysloop);
   12156            0 :         TotalCondDefCredfromSysID = System(SystemID).TotalCondDefrostCredit + System(SystemID).SumCascadeCondCredit;
   12157            0 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   12158              :         // total heat rejection load from a single detailed system [W]
   12159              :         Real64 TotalLoadFromSysID =
   12160            0 :             System(SystemID).TotalSystemLoad + System(SystemID).TotCompPower + System(SystemID).TotHiStageCompPower + System(SystemID).PipeHeatLoad;
   12161            0 :         TotalLoadFromSystems += TotalLoadFromSysID;
   12162            0 :         if (SystemID == SysNum) TotalLoadFromThisSystem = TotalLoadFromSysID;
   12163              :     } // Sysloop over every system connected to this condenser
   12164              : 
   12165              :     // for cascade condensers, condenser defrost credit gets passed on to the primary system condenser
   12166            0 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) TotalCondDefrostCreditLocal = 0.0;
   12167              : 
   12168              :     // Calculate Total Heat rejection needed.  Assume hermetic compressors - conservative assumption
   12169              :     // Note that heat rejection load carried by desuperheater hvac coils or water heaters is the
   12170              :     // lagged variable from the previous time step because these are calculated after the refrigeration
   12171              :     // system is solved.
   12172            0 :     condenser.ExternalHeatRecoveredLoad = condenser.LaggedUsedWaterHeater + condenser.LaggedUsedHVACCoil;
   12173            0 :     condenser.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12174            0 :     condenser.TotalHeatRecoveredLoad = condenser.ExternalHeatRecoveredLoad + TotalCondDefrostCreditLocal;
   12175              : 
   12176            0 :     state.dataRefrigCase->TotalCondenserHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal - condenser.ExternalHeatRecoveredLoad;
   12177            0 :     if (state.dataRefrigCase->TotalCondenserHeat < 0.0) {
   12178              : 
   12179            0 :         state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12180            0 :         if (!state.dataGlobal->WarmupFlag) {
   12181            0 :             ShowRecurringWarningErrorAtEnd(state,
   12182            0 :                                            "Refrigeration:System: " + this->Name +
   12183              :                                                ":heat reclaimed(defrost,other purposes) >current condenser load. ",
   12184              :                                            CondCreditWarnIndex1);
   12185            0 :             ShowRecurringContinueErrorAtEnd(
   12186              :                 state, "For heat recovered for defrost: ASHRAE rule of thumb: <= 25% of the load on a rack ", CondCreditWarnIndex2);
   12187            0 :             ShowRecurringContinueErrorAtEnd(
   12188              :                 state, "should be in defrost at the same time. Consider diversifying defrost schedules.", CondCreditWarnIndex3);
   12189            0 :             ShowRecurringContinueErrorAtEnd(
   12190              :                 state,
   12191              :                 "For heat recovered for other purposes: this warning may be an artifact of refrigeration calculation at the load",
   12192              :                 CondCreditWarnIndex4);
   12193            0 :             ShowRecurringContinueErrorAtEnd(
   12194              :                 state,
   12195              :                 "time step and heat recovery at the system time step. In that case, and ONLY if it occurs a large number of times",
   12196              :                 CondCreditWarnIndex5);
   12197            0 :             ShowRecurringContinueErrorAtEnd(
   12198              :                 state, "(relative to the number of time steps in the simulation), there may be a mis-match between the", CondCreditWarnIndex6);
   12199            0 :             ShowRecurringContinueErrorAtEnd(
   12200              :                 state, "operating schedules of the refrigeration system and the heat recovery load.", CondCreditWarnIndex7);
   12201              :         } // not warmup
   12202              :     }     // total condenser heat < 0
   12203              : 
   12204              :     // Water side of water-cooled condensers simulated in SimRefrigCondenser,
   12205              :     //   Here, we just need load and condensing temperatures.
   12206              :     //   Condensing temperature a fixed delta (the rated approach temperature) from inlet water temp so long as above minimum.
   12207              :     //   Note, if condensing temperature falls below minimum, get warning and reset but no change in water-side calculations.
   12208            0 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   12209              :         // Obtain water-cooled condenser inlet/outlet temps
   12210            0 :         condenser.InletTemp = state.dataLoopNodes->Node(condenser.InletNode).Temp;
   12211            0 :         TCondCalc = state.dataLoopNodes->Node(condenser.InletNode).Temp + condenser.RatedApproachT;
   12212            0 :         if ((condenser.InletTemp < condenser.InletTempMin) || (TCondCalc < this->TCondenseMin)) {
   12213            0 :             this->TCondense = this->TCondenseMin;
   12214              :             // condenser.LowTempWarn += 1;
   12215            0 :             if (condenser.LowTempWarnIndex == 0) {
   12216            0 :                 ShowWarningMessage(state, format("Refrigeration:Condenser:WaterCooled {}", condenser.Name));
   12217            0 :                 ShowContinueError(state,
   12218              :                                   "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature and/or "
   12219              :                                   "minimum temperature setpoints relative to minimum allowed condensing temperature.");
   12220              :             }
   12221            0 :             ShowRecurringWarningErrorAtEnd(state,
   12222            0 :                                            "Refrigeration:Condenser:WaterCooled " + condenser.Name +
   12223              :                                                " - Condenser inlet temp lower than minimum allowed ... continues",
   12224            0 :                                            condenser.LowTempWarnIndex);
   12225              :             // END IF
   12226              :         } else {
   12227            0 :             this->TCondense = TCondCalc;
   12228              :         }
   12229              : 
   12230            0 :     } else if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) ||
   12231            0 :                (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap)) {
   12232              :         // Condensing Temp, fan and other aux loads for air-cooled or evap-cooled
   12233              : 
   12234              :         // The rated capacity of air-cooled condenser was adjusted for elevation in get input step
   12235            0 :         CapFac = state.dataRefrigCase->TotalCondenserHeat / condenser.RatedCapacity;
   12236              :         // See whether condenser is at ground level or if other air conditions(ie node) have been specified.
   12237              :         //    Note that air-cooled condensers can draw air from, and reject heat to, a conditioned zone
   12238              :         //    But evaporative condensers cannot.
   12239              :         // Provides effective condensing temperature for air-cooled condenser (or evap if evap is scheduled off)
   12240            0 :         if (condenser.InletAirNodeNum != 0) {
   12241            0 :             OutDbTemp = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Temp;
   12242            0 :             BPress = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Press;
   12243            0 :             HumRatIn = state.dataLoopNodes->Node(condenser.InletAirNodeNum).HumRat;
   12244              :         } else {
   12245            0 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   12246            0 :             BPress = state.dataEnvrn->OutBaroPress;
   12247            0 :             HumRatIn = state.dataEnvrn->OutHumRat;
   12248              :         }
   12249            0 :         AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn);
   12250            0 :         AirDensityDry = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, 0.0);
   12251              :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   12252              :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   12253              :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   12254              :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   12255              :         //  climates.  To accommodate such applications, the variable EvapCutOutTdb is used as an extra
   12256              :         //  check.
   12257              : 
   12258            0 :         if (OutDbTemp < EvapCutOutTdb) EvapAvail = false;
   12259              : 
   12260              :         // Check schedule to determine evap condenser availability
   12261              :         // IF schedule exists, evap condenser can be scheduled OFF
   12262            0 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (condenser.evapAvailSched != nullptr) &&
   12263            0 :             (condenser.evapAvailSched->getCurrentVal() == 0))
   12264            0 :             EvapAvail = false;
   12265              : 
   12266              :         // Calculate condensing temperatures for air-cooled and evap-cooled
   12267            0 :         if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   12268              :             // Manufacturer's HRCF regressed to produce a function of the form:
   12269              :             // (Tcondense-Twb)=A1 + A2*hrcf + A3/hrcf + A4*Twb
   12270              :             // HRCF defined as rated capacity divided by load
   12271              :             // Apply ARI490 elevation correction factor here for evap condenser, then apply hrcf limits
   12272            0 :             if (CapFac > 0.0) {
   12273            0 :                 HRCF = condenser.EvapElevFact / CapFac;
   12274              :                 // Condenser(CondNum)%EvapElevFact=1.0d0-3.074D-5*Elevation
   12275              :             } else {
   12276            0 :                 HRCF = MyLargeNumber;
   12277              :             }
   12278            0 :             HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12279            0 :             HRCF = max(HRCF, condenser.MinCapFacEvap);
   12280            0 :             if (EvapAvail) {
   12281            0 :                 OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   12282            0 :                 SinkTemp = OutWbTemp;
   12283              :             } else {         // evaporative condenser with water spray scheduled off so use Tdb
   12284            0 :                 HRCF /= 3.0; // reference Menske, cap of evap cond operating dry about 1/3 of rated cap
   12285            0 :                 HRCF = max(HRCF, condenser.MinCapFacEvap);
   12286            0 :                 SinkTemp = OutDbTemp;
   12287              :             } // evap avail, still in evap condenser
   12288            0 :             TCondCalc = condenser.EvapCoeff1 + condenser.EvapCoeff2 * HRCF + condenser.EvapCoeff3 / HRCF + (1.0 + condenser.EvapCoeff4) * SinkTemp;
   12289              :         } else { // air-cooled condenser
   12290              :             // MinCondLoad and TempSlope came from condenser capacity curve, using curve backwards
   12291            0 :             TCondCalc = OutDbTemp + (state.dataRefrigCase->TotalCondenserHeat - condenser.MinCondLoad) * condenser.TempSlope;
   12292            0 :             SinkTemp = OutDbTemp;
   12293              :         } // if evap-cooled condenser
   12294              : 
   12295              :         // Fan energy calculations apply to both air- and evap-cooled condensers
   12296              :         // Compare calculated condensing temps to minimum allowed to determine fan power/operating mode
   12297            0 :         if (TCondCalc >= this->TCondenseMin) {
   12298            0 :             this->TCondense = TCondCalc;
   12299            0 :             ActualFanPower = RatedFanPower;
   12300            0 :             AirVolRatio = 1.0;
   12301              : 
   12302              :         } else { // need to reduce fan speed to reduce air flow and keep Tcond at or above Tcond min
   12303            0 :             this->TCondense = this->TCondenseMin;
   12304            0 :             TCondCalc = this->TCondenseMin;
   12305              :             // recalculate CapFac at current delta T
   12306            0 :             if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
   12307              :                 // current maximum condenser capacity at delta T present for minimum condensing temperature [W]
   12308            0 :                 Real64 CurMaxCapacity = Curve::CurveValue(state, condenser.CapCurvePtr, (this->TCondenseMin - OutDbTemp));
   12309            0 :                 CapFac = state.dataRefrigCase->TotalCondenserHeat / CurMaxCapacity;
   12310            0 :                 AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   12311            0 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12312              :             } else { // condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap
   12313            0 :                 HRCFFullFlow = HRCF;
   12314              :                 // if evap condenser need to back calculate the operating capacity using HRCF relationship, given known Tcond
   12315            0 :                 Real64 QuadBterm = condenser.EvapCoeff1 - (this->TCondense - SinkTemp) + condenser.EvapCoeff4 * SinkTemp;
   12316            0 :                 Real64 Sqrtterm = pow_2(QuadBterm) - 4.0 * condenser.EvapCoeff2 * condenser.EvapCoeff3;
   12317            0 :                 if (Sqrtterm < 0.0) { // only happens for very high wet bulb temps
   12318            0 :                     HRCF = condenser.EvapElevFact * condenser.MaxCapFacEvap;
   12319            0 :                     if (!EvapAvail) HRCF /= 3.0;
   12320            0 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12321              :                 } else {
   12322            0 :                     HRCF = condenser.EvapElevFact * (-QuadBterm - std::sqrt(Sqrtterm)) / (2.0 * condenser.EvapCoeff2);
   12323            0 :                     if (!EvapAvail) HRCF /= 3.0;
   12324            0 :                     HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12325            0 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12326              :                 }                             // sqrtterm
   12327            0 :                 CapFac = HRCF / HRCFFullFlow; // note, HRCFFullFlow previously limited between min and max,so can't be zero
   12328            0 :                 if (EvapAvail) {
   12329            0 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentEvap)); // Fans limited by minimum air flow ratio
   12330              :                 } else {                                                                             // evap not available
   12331            0 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry));  // Fans limited by minimum air flow ratio
   12332              :                 }                                                                                    // evap available
   12333            0 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12334              :             } // condenser type = DataHeatBalance::RefrigCondenserType::Air with else for evap
   12335              : 
   12336            0 :             switch (condenser.FanSpeedControlType) {
   12337            0 :             case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   12338            0 :                 FanPowerRatio = std::pow(AirVolRatio, 2.5);
   12339            0 :                 ActualFanPower = FanPowerRatio * RatedFanPower;
   12340            0 :             } break;
   12341            0 :             case FanSpeedCtrlType::ConstantSpeed: {
   12342            0 :                 ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12343            0 :             } break;
   12344            0 :             case FanSpeedCtrlType::ConstantSpeedLinear: {
   12345            0 :                 ActualFanPower = AirVolRatio * RatedFanPower;
   12346            0 :             } break;
   12347            0 :             case FanSpeedCtrlType::TwoSpeed: {
   12348              :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   12349              :                 // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   12350              :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   12351            0 :                 Real64 const air_vol_fan_power_fac(std::exp(1.0 - AirVolRatio) * RatedFanPower);
   12352            0 :                 ActualFanPower = AirVolRatio * air_vol_fan_power_fac;
   12353            0 :                 if (CapFac < CapFac60Percent) ActualFanPower = ((AirVolRatio + 0.4) * FanHalfSpeedRatio) * air_vol_fan_power_fac;
   12354            0 :             } break;
   12355            0 :             default:
   12356            0 :                 break;
   12357              :             } // fan speed control type
   12358              :         }     // Tcondense >= Tcondense minimum
   12359              : 
   12360            0 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (EvapAvail)) {
   12361              :             // calculate evap water use,  need to include bleed down/purge water as well as water
   12362              :             // actually evaporated.  Use BAC Engineering Reference value of 3 gpm/100 tons because it's more
   12363              :             // conservative than the ASHRAE value.
   12364              :             //  Also, based on experience, running the evap water when outdoor T near freezing
   12365              :             //  leads to 'spectacular' ice, so schedule evap off when Tdb <=4 C.
   12366              :             // Calculate bleed/purge rate of water loss as a function of capacity, 3 gpm/100 tons refrigeration
   12367            0 :             PurgeRate = state.dataRefrigCase->TotalCondenserHeat * BleedRateConstant;
   12368            0 :             EnthalpyAirIn = Psychrometrics::PsyHFnTdbW(OutDbTemp, HumRatIn);
   12369              :             // calculate effectiveness at rated conditions, so use Tcondcalc)
   12370            0 :             EnthalpyAtTcond = Psychrometrics::PsyHFnTdbRhPb(state, TCondCalc, 1.0, BPress);
   12371            0 :             Effectiveness = state.dataRefrigCase->TotalCondenserHeat / (RatedAirFlowRate * AirDensity * (EnthalpyAtTcond - EnthalpyAirIn));
   12372              :             // need to limit max effectiveness for errors due to working beyond limits of HRCF in manuf data
   12373            0 :             Effectiveness = min(Effectiveness, 0.9);
   12374            0 :             EnthalpyAirOut = EnthalpyAirIn + Effectiveness * (EnthalpyAtTcond - EnthalpyAirIn);
   12375              :             // Air leaving the evaporative condenser is saturated
   12376            0 :             Real64 TAirOut = Psychrometrics::PsyTsatFnHPb(state, EnthalpyAirOut, BPress);
   12377            0 :             HumRatOut = Psychrometrics::PsyWFnTdpPb(state, TAirOut, BPress);
   12378            0 :             state.dataRefrigCase->TotalEvapWaterUseRate =
   12379            0 :                 PurgeRate + RatedAirFlowRate * AirVolRatio * AirDensityDry * (HumRatOut - HumRatIn) / Psychrometrics::RhoH2O(OutWbTemp);
   12380              :             // assumes evap water pump runs whenever evap cooling is available to minimize scaling
   12381            0 :             state.dataRefrigCase->TotalCondenserPumpPower = condenser.EvapPumpPower;
   12382              :             // calculate basin water heater load
   12383            0 :             if (state.dataRefrigCase->TotalCondenserHeat == 0.0 && OutDbTemp < condenser.BasinHeaterSetPointTemp) {
   12384            0 :                 state.dataRefrigCase->TotalBasinHeatPower =
   12385            0 :                     max(0.0, condenser.BasinHeaterPowerFTempDiff * (condenser.BasinHeaterSetPointTemp - OutDbTemp));
   12386              :                 // provide warning if no heater power exists
   12387            0 :                 if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   12388              :                     // condenser.EvapFreezeWarn = condenser.EvapFreezeWarn + 1;
   12389            0 :                     if (condenser.EvapFreezeWarnIndex == 0) {
   12390            0 :                         ShowWarningMessage(
   12391              :                             state,
   12392            0 :                             format("Refrigeration Condenser {} - Evap cooling of condenser underway with no basin heater power", condenser.Name));
   12393            0 :                         ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   12394            0 :                         ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   12395              :                     }
   12396            0 :                     ShowRecurringWarningErrorAtEnd(state,
   12397            0 :                                                    "Refrigeration Condenser " + condenser.Name +
   12398              :                                                        " - Evap cooling of condenser underway with no basin heater power ... continues",
   12399            0 :                                                    condenser.EvapFreezeWarnIndex);
   12400              :                     // END IF  !freeze warnings <= 5
   12401              :                 } // basin power == 0
   12402              :             }     // no load and cold outside
   12403              :         }         // EvapAvail
   12404              : 
   12405            0 :     } else if (condenser.CondenserType ==
   12406              :                DataHeatBalance::RefrigCondenserType::Cascade) { // continuing Condenser type = water, (evap or air), or cascade
   12407              :         // Cascade condenser does not iterate.  Condensing temperature specified as a load on higher temp system
   12408              :         //    or floats to meet other loads on that system
   12409              :         // therese ** future - here and for new phase change heat exchanger - need to handle unmet loads!
   12410              : 
   12411            0 :         this->TCondense = condenser.RatedTCondense;
   12412              : 
   12413            0 :         if ((this->NumNonCascadeLoads > 0) && (condenser.CascadeTempControl == CascadeCndsrTempCtrlType::TempFloat)) {
   12414            0 :             this->TCondense = System(condenser.CascadeSinkSystemID).TEvapNeeded + condenser.RatedApproachT;
   12415            0 :             if (this->TCondense < this->TCondenseMin) {
   12416            0 :                 this->TCondense = this->TCondenseMin;
   12417            0 :                 ShowRecurringWarningErrorAtEnd(state,
   12418            0 :                                                "Refrigeration Condenser " + condenser.Name +
   12419              :                                                    " - Cascade condenser floating condensing temperature less than specified minimum condensing "
   12420              :                                                    "temperature. Minimum specified temperature used for system below cascade condenser. No "
   12421              :                                                    "correction made for system absorbing heat rejected by the cascade condenser.",
   12422            0 :                                                condenser.EvapFreezeWarnIndex);
   12423              :             } // floating condensing temperature less than specified min for system
   12424              :         }     // floating temperature
   12425              :     }         // Condenser type = water, (evap or air), or cascade
   12426              : 
   12427            0 :     condenser.ActualFanPower = ActualFanPower;
   12428            0 :     condenser.FanElecEnergy = ActualFanPower * localTimeStepSec;
   12429            0 :     condenser.EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   12430            0 :     condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   12431            0 :     condenser.ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   12432            0 :     condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   12433            0 :     condenser.BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   12434            0 :     condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   12435            0 :     condenser.CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   12436            0 :     condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec;
   12437            0 :     condenser.CondCreditWarnIndex1 = CondCreditWarnIndex1;
   12438            0 :     condenser.CondCreditWarnIndex2 = CondCreditWarnIndex2;
   12439            0 :     condenser.CondCreditWarnIndex3 = CondCreditWarnIndex3;
   12440            0 :     condenser.CondCreditWarnIndex4 = CondCreditWarnIndex4;
   12441            0 :     condenser.CondCreditWarnIndex5 = CondCreditWarnIndex5;
   12442            0 :     condenser.CondCreditWarnIndex6 = CondCreditWarnIndex6;
   12443            0 :     condenser.CondCreditWarnIndex7 = CondCreditWarnIndex7;
   12444            0 :     condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * localTimeStepSec;
   12445            0 :     condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * localTimeStepSec;
   12446            0 :     condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * localTimeStepSec;
   12447            0 :     this->NetHeatRejectLoad = state.dataRefrigCase->TotalCondenserHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   12448            0 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   12449              : 
   12450              :     // set water system demand request (if needed)
   12451            0 :     if (condenser.EvapWaterSupplyMode == WaterSupply::FromTank) {
   12452            0 :         state.dataWaterData->WaterStorage(condenser.EvapWaterSupTankID).VdotRequestDemand(condenser.EvapWaterTankDemandARRID) =
   12453            0 :             condenser.EvapWaterConsumpRate;
   12454              :     }
   12455            0 : }
   12456              : 
   12457            0 : void TransRefrigSystemData::CalcGasCooler(EnergyPlusData &state, int const SysNum)
   12458              : {
   12459              : 
   12460              :     // SUBROUTINE INFORMATION:
   12461              :     //       AUTHOR         Brian A. Fricke, ORNL
   12462              :     //       DATE WRITTEN   Fall 2011
   12463              :     //       MODIFIED       na
   12464              :     //       RE-ENGINEERED  na
   12465              : 
   12466              :     // PURPOSE OF THIS SUBROUTINE:
   12467              :     // Find the gas cooler outlet temperature, the optimum gas cooler pressure, heat rejection,
   12468              :     // fan power, and fan energy for a detailed transcritical CO2 refrigeration system.
   12469              : 
   12470              :     // METHODOLOGY EMPLOYED:
   12471              :     // For a specified gas cooler outlet temperature in transcritical operation, there is an optimal gas cooler
   12472              :     // pressure which produces the highest COP. A curve-fit equation similar to that presented by Ge and Tassou
   12473              :     // (2011) and Sawalha (2008) is used to determine the optimum gas cooler pressure for a given gas cooler
   12474              :     // outlet temperature. In subcritical operation, the condensing temperature and pressure are allowed to
   12475              :     // float with ambient conditions, above the minimum condensing temperature.
   12476              : 
   12477              :     // REFERENCES:
   12478              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   12479              :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   12480              :     //     Journal of Refrigeration 34: 527-539.
   12481              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   12482              :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   12483              :     //     Refrigeration 34: 540-549.
   12484              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   12485              :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   12486              :     //     Refrigeration 31: 516-524.
   12487              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   12488              :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   12489              :     //     Refrigeration 31: 525-534.
   12490              : 
   12491              :     static constexpr std::string_view RoutineName = "RefrigeratedCase:CalcGasCooler";
   12492              : 
   12493            0 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   12494            0 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   12495              : 
   12496              :     int GasCoolerCreditWarnIndex;       // Warning counter
   12497              :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded gas cooler [W]
   12498              :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   12499              :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   12500              :     Real64 FanPowerRatio;               // Calculated fan power ratio
   12501              :     Real64 OutDbTemp;                   // Outdoor dry bulb temperature at gas cooler air inlet node [C]
   12502              :     Real64 RatedFanPower;               // Rated fan power for this gas cooler [W]
   12503              :     Real64 TotalCondDefCredfromSysID;   // Gas cooler defrost credit for single system [W]
   12504              :     Real64 TotalCondDefrostCreditLocal; // Total gas cooler credit from hot gas/brine defrost for cases etc. served
   12505              :     //     directly by all systems served by this gas cooler [W]
   12506              :     Real64 TotalGasCoolerHeat;           // Total gas cooler heat from system [W]
   12507              :     Real64 TotalLoadFromSysID;           // Total heat rejection load from a single detailed system [W]
   12508              :     Real64 TotalLoadFromSystems;         // Total heat rejection load from all systems served by this condenser [W]
   12509            0 :     Real64 TotalLoadFromThisSystem(0.0); // Total heat rejection load from the detailed system identified in subroutine call [W]
   12510              : 
   12511            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12512            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12513              : 
   12514              :     // Initialize this gas cooler for this time step
   12515            0 :     ActualFanPower = 0.0;
   12516            0 :     TotalCondDefrostCreditLocal = 0.0;
   12517            0 :     TotalLoadFromSystems = 0.0;
   12518            0 :     int GasCoolerID = this->GasCoolerNum(1);
   12519            0 :     auto &cooler = GasCooler(GasCoolerID);
   12520            0 :     RatedFanPower = cooler.RatedFanPower;
   12521            0 :     FanMinAirFlowRatio = cooler.FanMinAirFlowRatio;
   12522            0 :     GasCoolerCreditWarnIndex = cooler.GasCoolerCreditWarnIndex;
   12523              : 
   12524            0 :     for (int Sysloop = 1; Sysloop <= cooler.NumSysAttach; ++Sysloop) {
   12525            0 :         int SystemID = cooler.SysNum(Sysloop);
   12526            0 :         TotalCondDefCredfromSysID = TransSystem(SystemID).TotalCondDefrostCredit;
   12527            0 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   12528            0 :         TotalLoadFromSysID = TransSystem(SystemID).TotalSystemLoadLT + TransSystem(SystemID).TotalSystemLoadMT +
   12529            0 :                              TransSystem(SystemID).TotCompPowerLP + TransSystem(SystemID).TotCompPowerHP + TransSystem(SystemID).PipeHeatLoadLT +
   12530            0 :                              TransSystem(SystemID).PipeHeatLoadMT;
   12531            0 :         TotalLoadFromSystems += TotalLoadFromSysID;
   12532            0 :         if (SystemID == SysNum) TotalLoadFromThisSystem = TotalLoadFromSysID;
   12533              :     } // Sysloop over every system connected to this gas cooler
   12534              : 
   12535              :     // Calculate Total Heat rejection needed.
   12536            0 :     cooler.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12537            0 :     cooler.TotalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12538            0 :     TotalGasCoolerHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal;
   12539              : 
   12540            0 :     if (TotalGasCoolerHeat < 0.0) {
   12541            0 :         TotalGasCoolerHeat = 0.0;
   12542            0 :         if (!state.dataGlobal->WarmupFlag)
   12543            0 :             ShowRecurringWarningErrorAtEnd(state,
   12544            0 :                                            "Refrigeration:TranscriticalSystem: " + this->Name +
   12545              :                                                ":heat reclaimed (defrost,other purposes) is greater than current gas cooler load. ASHRAE rule of "
   12546              :                                                "thumb: <= 25% of the load on a system should be in defrost at the same time. Consider "
   12547              :                                                "diversifying defrost schedules.",
   12548              :                                            GasCoolerCreditWarnIndex);
   12549              :     } // total gas cooler heat < 0
   12550              : 
   12551              :     // The rated capacity of air-cooled gas cooler was adjusted for elevation in get input step
   12552            0 :     Real64 CapFac = TotalGasCoolerHeat / cooler.RatedCapacity;
   12553              :     // See whether gas cooler is at ground level or if other air conditions (ie node) have been specified.
   12554              :     // Note that air-cooled gas coolers can draw air from, and reject heat to, a conditioned zone.
   12555            0 :     if (cooler.InletAirNodeNum != 0) {
   12556            0 :         OutDbTemp = state.dataLoopNodes->Node(cooler.InletAirNodeNum).Temp;
   12557              :     } else {
   12558            0 :         OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   12559              :     }
   12560              :     // Determine gas cooler outlet temperature and pressure
   12561              :     // Transcritical:  Gas cooler outlet temperature based on ambient temperature and approach temperature.
   12562              :     //                 Determine optimum gas cooler pressure to maximize COP.
   12563              :     // Subcritical:  Allow condensing temperature and pressure to float between minimum condensing temperature and
   12564              :     //               transition temperature.
   12565            0 :     if (OutDbTemp > cooler.TransitionTemperature) { // Gas cooler in transcritical operation
   12566            0 :         cooler.TGasCoolerOut = OutDbTemp + cooler.GasCoolerApproachT;
   12567            0 :         cooler.PGasCoolerOut = 1.0e5 * (2.3083 * state.dataEnvrn->OutDryBulbTemp + 11.9);
   12568            0 :         if (cooler.PGasCoolerOut < 7.5e6) { // Ensure gas cooler pressure is at least 7.5 MPa for transcritical operation
   12569            0 :             cooler.PGasCoolerOut = 7.5e6;
   12570              :         }
   12571            0 :         cooler.HGasCoolerOut = this->refrig->getSupHeatEnthalpy(state, cooler.TGasCoolerOut, cooler.PGasCoolerOut, RoutineName);
   12572            0 :         cooler.TransOpFlag = true;
   12573              :     } else { // Gas cooler in subcritical operation
   12574            0 :         cooler.TGasCoolerOut = OutDbTemp + cooler.SubcriticalTempDiff;
   12575            0 :         if (cooler.TGasCoolerOut > 30.978) { //  Gas temperature should be less than critical temperature
   12576            0 :             cooler.PGasCoolerOut = 7.2e6;    //  Fix the pressure to be subcritical
   12577            0 :             cooler.TGasCoolerOut = this->refrig->getSatTemperature(state, cooler.PGasCoolerOut, RoutineName);
   12578            0 :         } else if (cooler.TGasCoolerOut > cooler.MinCondTemp) { //  Allow condensing temperature to float above the minimum
   12579            0 :             cooler.PGasCoolerOut = this->refrig->getSatPressure(state, cooler.TGasCoolerOut, RoutineName);
   12580              :         } else { //  Don't allow condensing temperature to drop below minimum
   12581            0 :             cooler.TGasCoolerOut = cooler.MinCondTemp;
   12582            0 :             cooler.PGasCoolerOut = this->refrig->getSatPressure(state, cooler.TGasCoolerOut, RoutineName);
   12583              :         }
   12584            0 :         cooler.HGasCoolerOut = this->refrig->getSatEnthalpy(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   12585            0 :         cooler.TransOpFlag = false;
   12586              :     } // (OutDbTemp > TransitionTemperature)
   12587              : 
   12588            0 :     if (cooler.TGasCoolerOut < 30.978) {
   12589            0 :         cooler.CpGasCoolerOut = this->refrig->getSatSpecificHeat(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   12590              :     } else {
   12591            0 :         cooler.CpGasCoolerOut = 0.0;
   12592              :     }
   12593              : 
   12594              :     // Gas cooler fan energy calculations
   12595            0 :     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   12596              : 
   12597            0 :     switch (cooler.FanSpeedControlType) {
   12598            0 :     case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   12599            0 :         FanPowerRatio = std::pow(AirVolRatio, 2.5);
   12600            0 :         ActualFanPower = FanPowerRatio * RatedFanPower;
   12601            0 :     } break;
   12602            0 :     case FanSpeedCtrlType::ConstantSpeed: {
   12603            0 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12604            0 :     } break;
   12605            0 :     case FanSpeedCtrlType::ConstantSpeedLinear: {
   12606            0 :         ActualFanPower = AirVolRatio * RatedFanPower;
   12607            0 :     } break;
   12608            0 :     case FanSpeedCtrlType::TwoSpeed: {
   12609              :         // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   12610              :         // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   12611              :         // dampers are used to control flow within those two ranges as in FanConstantSpeed
   12612            0 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12613            0 :         if (CapFac < CapFac60Percent) ActualFanPower = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12614            0 :     } break;
   12615            0 :     default:
   12616            0 :         break;
   12617              :     } // fan speed control type
   12618              : 
   12619            0 :     cooler.ActualFanPower = ActualFanPower;
   12620            0 :     cooler.FanElecEnergy = ActualFanPower * localTimeStepSec;
   12621            0 :     cooler.GasCoolerLoad = TotalGasCoolerHeat;
   12622            0 :     cooler.GasCoolerEnergy = TotalGasCoolerHeat * localTimeStepSec;
   12623            0 :     cooler.GasCoolerCreditWarnIndex = GasCoolerCreditWarnIndex;
   12624            0 :     cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * localTimeStepSec;
   12625            0 :     cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * localTimeStepSec;
   12626            0 :     this->NetHeatRejectLoad = TotalGasCoolerHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   12627            0 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   12628            0 : }
   12629              : 
   12630            0 : void RefrigSystemData::CalculateCompressors(EnergyPlusData &state)
   12631              : {
   12632              : 
   12633              :     // SUBROUTINE INFORMATION:
   12634              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   12635              :     //       DATE WRITTEN   Spring 2008
   12636              :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   12637              :     //       RE-ENGINEERED  na
   12638              : 
   12639              :     // PURPOSE OF THIS SUBROUTINE:
   12640              :     // Find the Compressor power, energy, capacity, and efficiency for a particular detailed
   12641              :     // refrigeration system.  Routine is capable of modeling single-stage and two-stage
   12642              :     // compression refrigeration systems.
   12643              : 
   12644              :     // METHODOLOGY EMPLOYED:
   12645              :     // USe ARI compressor performance curves, the evaporating temperature and condensing temperature
   12646              : 
   12647              :     // REFERENCES:
   12648              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12649              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12650              : 
   12651              :     // ARI Standard 540, 2004, Standard for Performance Rating of Positive Displacement Refrigerant
   12652              :     //  Compressors and Compressor Units, Air-Conditioning & Refrigeration Institute,Arlington VA
   12653              : 
   12654              :     // SUBROUTINE PARAMETER DEFINITIONS:
   12655              :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c, future allow input?
   12656              :     //   May want to allow input to reflect larger pipes selected to reduce delta P and increase compressor efficiency.
   12657              :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   12658            0 :     Real64 constexpr DelTSuctPipes(1.0);  // Tsat drop corresponding to P drop in suction pipes, ASHRAE 2006 p 2.4 (C)
   12659            0 :     Real64 constexpr DelTDischPipes(0.5); // Tsat drop corresponding to P drop in discharge pipes, ASHRAE 2006 p 2.5 (C)
   12660              : 
   12661              :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateCompressors");
   12662              :     Real64 CaseEnthalpyChangeRated;   // Enthalpy change in cases at compressor rated cond, J/kg
   12663              :     Real64 CapacityCorrection;        // Capacity at existing subcool/superheat over cap at rated conditions
   12664              :     Real64 CpSatVapCondense;          // Specific heat of vapor at cond temp J/kg-C
   12665              :     Real64 DensityRated;              // Density of inlet gas at rated superheat, m3/kg
   12666              :     Real64 DensityActual;             // Density of superheated gas at compressor inlet, m3/kg
   12667            0 :     Real64 HCompInRated(0.0);         // Enthalpy entering compressor at rated superheat, J/kg //Autodesk:Init
   12668            0 :     Real64 HCaseInRated(0.0);         // Enthalpy entering cases at rated subcooling, J/kg //Autodesk:Init
   12669              :     Real64 HSatVapCondense;           // Enthalpy of saturated vapor at T condense, J/kg
   12670              :     Real64 HsatVaporforTevapneeded;   // Enthalpy saturated vapor at temperature needed at evaporator
   12671              :     Real64 LFLastComp;                // Load factor for last compressor dispatched
   12672              :     Real64 MassCorrection;            // Mass flow at existing subcool/superheat over cap at rated conditions
   12673              :     Real64 NeededCapacity;            // Sum of case loads and mech subcooler loads on suction group
   12674              :     Real64 PSuction;                  // Suction Pressure
   12675              :     Real64 PCond;                     // Condensing pressure
   12676              :     Real64 PEvap;                     // Evaporating pressure
   12677              :     Real64 TCompOutEstimate;          // Estimated temperature out of the compressor, used to flag whether heat reclaim is reasonable, C
   12678            0 :     Real64 TempInRated(0.0);          // Temperature entering compressor at rated superheat, C //Autodesk:Init
   12679              :     Real64 TotalEnthalpyChangeActual; // Actual enthalpy change in cases and cold side of LSHX, J/kg
   12680              :     Real64 TsatforPsuct;              // Tsat for PSuction, C
   12681            0 :     Real64 TsatforPdisch(0.0);        // Tsat for Pdischarge, c
   12682              :     int NumComps;                     // Number of low-stage or high-stage compressors in system
   12683              :     Real64 HHiStageCompIn;            // Enthalpy at inlet of high-stage compressor (J/kg)
   12684            0 :     Real64 HCaseInRated_base(0.0), HCompInRated_base(0.0); // Autodesk:Tuned Intermediate values for performance tuning
   12685              : 
   12686            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   12687            0 :     auto &Compressor = state.dataRefrigCase->Compressor;
   12688              : 
   12689            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12690            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12691              : 
   12692            0 :     int CondID = this->CondenserNum(1);
   12693            0 :     auto const &Condenser1 = Condenser(CondID);
   12694            0 :     Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / localTimeStepSec)); // Load due to previously unmet compressor loads
   12695            0 :     Real64 const NeededCapacity_base(this->TotalSystemLoad + AccumLoad + this->PipeHeatLoad + this->LSHXTrans);
   12696              : 
   12697              :     // Before dispatching compressors, zero sum of compressor outputs and zero each compressor
   12698            0 :     this->TotCompCapacity = 0.0;
   12699            0 :     this->RefMassFlowComps = 0.0;
   12700            0 :     this->TotCompPower = 0.0;
   12701            0 :     if (this->NumStages == 2) {
   12702            0 :         this->TotHiStageCompCapacity = 0.0;
   12703            0 :         this->RefMassFlowHiStageComps = 0.0;
   12704            0 :         this->TotHiStageCompPower = 0.0;
   12705              :     }
   12706              : 
   12707            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressors; ++CompIndex) {
   12708            0 :         int CompID = this->CompressorNum(CompIndex);
   12709            0 :         auto &compressor = Compressor(CompID);
   12710            0 :         compressor.Power = 0.0;
   12711            0 :         compressor.MassFlow = 0.0;
   12712            0 :         compressor.Capacity = 0.0;
   12713            0 :         compressor.ElecConsumption = 0.0;
   12714            0 :         compressor.CoolingEnergy = 0.0;
   12715            0 :         compressor.LoadFactor = 0.0;
   12716              :     }
   12717            0 :     if (this->NumStages == 2) {
   12718            0 :         for (int CompIndex = 1; CompIndex <= this->NumHiStageCompressors; ++CompIndex) {
   12719            0 :             int CompID = this->HiStageCompressorNum(CompIndex);
   12720            0 :             auto &compressor = Compressor(CompID);
   12721            0 :             compressor.Power = 0.0;
   12722            0 :             compressor.MassFlow = 0.0;
   12723            0 :             compressor.Capacity = 0.0;
   12724            0 :             compressor.ElecConsumption = 0.0;
   12725            0 :             compressor.CoolingEnergy = 0.0;
   12726            0 :             compressor.LoadFactor = 0.0;
   12727              :         }
   12728              :     }
   12729              : 
   12730              :     // Determine properties at case inlet and compressor inlet
   12731            0 :     for (int StageIndex = 1; StageIndex <= min(2, this->NumStages); ++StageIndex) {
   12732            0 :         if (StageIndex == 1) {                                    // Do single-stage or low-stage calculations
   12733            0 :             if (this->NumStages == 1) {                           // Single-stage system
   12734            0 :                 NeededCapacity = NeededCapacity_base;             // because compressor capacity rated from txv to comp inlet
   12735            0 :                 TsatforPdisch = this->TCondense + DelTDischPipes; // need (Psat of (Tcond + delT corresponding to delP disch Pipes))
   12736            0 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes; // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   12737            0 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   12738            0 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   12739            0 :                 this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   12740              :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   12741              :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   12742              :                 // Calculate both here unless set previously by subcooler subroutine
   12743              :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   12744              :                 // future - visit how parameter 'casesuperheat' applies when using walk-ins or transfer loads
   12745            0 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   12746            0 :                     this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   12747            0 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   12748            0 :                     this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool;
   12749            0 :                     this->HCompIn = this->HCaseOut;
   12750              :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   12751            0 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   12752              :                 } // whether or not subcooler routine used
   12753            0 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   12754            0 :                 NumComps = this->NumCompressors;
   12755              :             } else { // Low-stage side of two-stage system
   12756            0 :                 PCond = this->refrig->getSatPressure(state, this->TCondense, RoutineName);
   12757            0 :                 PEvap = this->refrig->getSatPressure(state, this->TEvapNeeded, RoutineName);
   12758            0 :                 this->PIntercooler = std::sqrt(PCond * PEvap);
   12759            0 :                 this->TIntercooler = this->refrig->getSatTemperature(state, this->PIntercooler, RoutineName);
   12760            0 :                 NeededCapacity = NeededCapacity_base;                // because compressor capacity rated from txv to comp inlet
   12761            0 :                 TsatforPdisch = this->TIntercooler + DelTDischPipes; // need (Psat of (Tinter + delT corresponding to delP disch Pipes))
   12762            0 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes;    // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   12763            0 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   12764            0 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   12765            0 :                 this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   12766              :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   12767              :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   12768              :                 // Calculate both here unless set previously by subcooler subroutine
   12769              :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   12770            0 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   12771            0 :                     if (this->intercoolerType == IntercoolerType::Flash) {
   12772            0 :                         this->HCaseIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   12773            0 :                         this->TLiqInActual = this->TIntercooler;
   12774            0 :                     } else if (this->intercoolerType == IntercoolerType::ShellAndCoil) {
   12775            0 :                         this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool -
   12776            0 :                                              this->IntercoolerEffectiveness * (this->TCondense - Condenser1.RatedSubcool - this->TIntercooler);
   12777            0 :                         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - this->TLiqInActual);
   12778              :                     }                                                  // IntercoolerType
   12779            0 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   12780            0 :                     this->HCompIn = this->HCaseOut;
   12781              :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   12782            0 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   12783              :                 } // whether or not subcooler routine used
   12784            0 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   12785            0 :                 NumComps = this->NumCompressors;
   12786              :             }    // NumStages
   12787              :         } else { // Two-stage system, high-stage side
   12788            0 :             NeededCapacity = NeededCapacity_base + this->TotCompPower;
   12789            0 :             TsatforPdisch = this->TCondense + DelTDischPipes;
   12790            0 :             TsatforPsuct = this->TIntercooler;
   12791            0 :             HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   12792              :             //                HSatLiqCond = Fluid::GetSatEnthalpyRefrig(state, RefrigerantName, TCondense, 0.0, RefIndex,
   12793              :             // RoutineName
   12794              :             //);
   12795              :             ////Autodesk:Tuned These don't change for 2nd stage
   12796              :             //                CpSatLiqCond = Fluid::GetSatSpecificHeatRefrig(RefrigerantName, TCondense, 0.0, RefIndex,
   12797              :             // RoutineName );
   12798              :             ////Autodesk:Tuned These don't change for 2nd stage
   12799            0 :             this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   12800            0 :             this->TCompIn = this->TIntercooler;
   12801              :             //      System(SysNum)%TLiqInActual = System(SysNum)%TCondense-Condenser(System(SysNum)%CondenserNum(1))%RatedSubcool
   12802            0 :             this->HCompIn = HsatVaporforTevapneeded;
   12803            0 :             PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   12804            0 :             NumComps = this->NumHiStageCompressors;
   12805              :         } // StageIndex
   12806              : 
   12807              :         // dispatch compressors to meet load, note they were listed in compressor list in dispatch order
   12808            0 :         DensityActual = this->refrig->getSupHeatDensity(state, this->TCompIn, PSuction, RoutineName); // Autodesk:Tuned Hoisted out of CompIndex loop
   12809            0 :         TotalEnthalpyChangeActual = this->HCompIn - this->HCaseIn;                                    // Autodesk:Tuned Hoisted out of CompIndex loop
   12810            0 :         if (this->NumStages == 2) {                                                                   // Autodesk:Tuned Hoisted out of CompIndex loop
   12811            0 :             if (StageIndex == 1) {
   12812            0 :                 HCaseInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   12813            0 :             } else if (StageIndex == 2) {
   12814            0 :                 HCompInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   12815              :             }
   12816              :         }
   12817            0 :         for (int CompIndex = 1; CompIndex <= NumComps; ++CompIndex) {
   12818              :             int CompID;
   12819            0 :             if (StageIndex == 1) {
   12820            0 :                 CompID = this->CompressorNum(CompIndex);
   12821              :             } else {
   12822            0 :                 CompID = this->HiStageCompressorNum(CompIndex);
   12823              :             } // StageIndex
   12824            0 :             auto &compressor = Compressor(CompID);
   12825              : 
   12826              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   12827            0 :             switch (compressor.SubcoolRatingType) {
   12828            0 :             case CompRatingType::Subcooling: {
   12829            0 :                 if (this->NumStages == 1) { // Single-stage system
   12830            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   12831            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   12832            0 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * compressor.RatedSubcool;
   12833            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   12834            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   12835              :                 } // NumStages
   12836            0 :             } break;
   12837            0 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   12838            0 :                 if (this->NumStages == 1) {           // Single-stage system
   12839            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   12840            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   12841            0 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * (this->TIntercooler - compressor.RatedSubcool);
   12842            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   12843            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   12844              :                 } // NumStages
   12845            0 :             } break;
   12846            0 :             default:
   12847            0 :                 break;
   12848              :             } // Compressor SubcoolRatingType
   12849            0 :             switch (compressor.SuperheatRatingType) {
   12850            0 :             case CompRatingType::Superheat: {
   12851            0 :                 if (this->NumStages == 1) { // Single-stage system
   12852            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   12853            0 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   12854            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   12855            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   12856            0 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   12857            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   12858            0 :                     HCompInRated = HCompInRated_base + this->CpSatVapEvap * compressor.RatedSuperheat;
   12859            0 :                     TempInRated = this->TIntercooler + compressor.RatedSuperheat;
   12860              :                 } // NumStages
   12861            0 :             } break;
   12862            0 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   12863            0 :                 if (this->NumStages == 1) {              // Single-stage system
   12864            0 :                     TempInRated = compressor.RatedSuperheat;
   12865            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   12866            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   12867            0 :                     TempInRated = compressor.RatedSuperheat;
   12868            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   12869            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   12870            0 :                     TempInRated = compressor.RatedSuperheat;
   12871            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TIntercooler);
   12872              :                 } // NumStages
   12873            0 :             } break;
   12874            0 :             default:
   12875            0 :                 break;
   12876              :             } // Compressor SuperheatRatingType
   12877              : 
   12878            0 :             CaseEnthalpyChangeRated = HCompInRated - HCaseInRated;
   12879            0 :             DensityRated = this->refrig->getSupHeatDensity(state, TempInRated, PSuction, RoutineName);
   12880              :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   12881              :             //  the increase in capacity due to extra subcooling
   12882            0 :             MassCorrection = DensityActual / DensityRated;
   12883            0 :             CapacityCorrection = MassCorrection * TotalEnthalpyChangeActual / CaseEnthalpyChangeRated;
   12884            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsuct, TsatforPdisch);
   12885            0 :             compressor.Capacity = CapacityCorrection * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsuct, TsatforPdisch);
   12886            0 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActual;
   12887              : 
   12888              :             // calculate load factor for last compressor added
   12889              :             // assumes either cycling or part load eff = full load eff for last compressor
   12890            0 :             if (StageIndex == 1) { // Single-stage or low-stage compressors
   12891            0 :                 if ((this->TotCompCapacity + compressor.Capacity) >= NeededCapacity) {
   12892            0 :                     LFLastComp = (NeededCapacity - this->TotCompCapacity) / compressor.Capacity;
   12893            0 :                     compressor.Power *= LFLastComp;
   12894            0 :                     compressor.MassFlow *= LFLastComp;
   12895            0 :                     compressor.Capacity *= LFLastComp;
   12896            0 :                     this->TotCompCapacity += compressor.Capacity;
   12897            0 :                     this->RefMassFlowComps += compressor.MassFlow;
   12898            0 :                     this->TotCompPower += compressor.Power;
   12899            0 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   12900            0 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   12901            0 :                     compressor.LoadFactor = LFLastComp;
   12902            0 :                     break; // numcomps do
   12903              :                 } else {   //>= needed capacity
   12904            0 :                     this->TotCompCapacity += compressor.Capacity;
   12905            0 :                     this->RefMassFlowComps += compressor.MassFlow;
   12906            0 :                     this->TotCompPower += compressor.Power;
   12907              :                 }    //>= needed capacity
   12908              :             } else { // high-stage compressors (for two-stage systems only)
   12909            0 :                 if ((this->TotHiStageCompCapacity + compressor.Capacity) >= NeededCapacity) {
   12910            0 :                     LFLastComp = (NeededCapacity - this->TotHiStageCompCapacity) / compressor.Capacity;
   12911            0 :                     compressor.Power *= LFLastComp;
   12912            0 :                     compressor.MassFlow *= LFLastComp;
   12913            0 :                     compressor.Capacity *= LFLastComp;
   12914            0 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   12915            0 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   12916            0 :                     this->TotHiStageCompPower += compressor.Power;
   12917            0 :                     this->FlowRatioIntercooler = this->RefMassFlowComps / this->RefMassFlowHiStageComps;
   12918            0 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   12919            0 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   12920            0 :                     compressor.LoadFactor = LFLastComp;
   12921            0 :                     break; // numcomps do
   12922              :                 } else {   //>= needed capacity
   12923            0 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   12924            0 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   12925            0 :                     this->TotHiStageCompPower += compressor.Power;
   12926              :                 } //>= needed capacity
   12927              :             }     // StageIndex
   12928            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   12929            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   12930            0 :             compressor.LoadFactor = 1.0;
   12931              :         } // NumComps
   12932              :     }
   12933              : 
   12934              :     // Calculate enthalpy at compressor discharge
   12935            0 :     if (this->NumStages == 1) { // Single-stage or low-stage compressors
   12936            0 :         this->HCompOut = this->HCompIn + this->TotCompPower / this->RefMassFlowComps;
   12937              :         // error found 9/19/2011, was System(SysNum)%TotCompPower*LocalTimeStep*DataGlobals::SecInHour/System(SysNum)%RefMassFlowComps
   12938              :     } else { // High-stage compressors (only for two-stage systems)
   12939            0 :         HHiStageCompIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   12940            0 :         this->HCompOut = HHiStageCompIn + this->TotHiStageCompPower / this->RefMassFlowHiStageComps;
   12941              :     }
   12942              : 
   12943              :     // Calculate superheat energy available for desuperheaters
   12944            0 :     HSatVapCondense = this->refrig->getSatEnthalpy(state, this->TCondense, 1.0, RoutineName);
   12945            0 :     CpSatVapCondense = this->refrig->getSatSpecificHeat(state, this->TCondense, 1.0, RoutineName);
   12946            0 :     if (this->NumStages == 1) { // Single-stage systems
   12947            0 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowComps * (this->HCompOut - HSatVapCondense);
   12948              :     } else { // Two-stage systems
   12949            0 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowHiStageComps * (this->HCompOut - HSatVapCondense);
   12950              :     } // NumStages
   12951              : 
   12952              :     // No function available to get Tout as f(Pout, Hout), so use estimate based on constant cp in superheat range...
   12953              :     //  Use average of Tcondense and Tout of condenser as check for whether heat reclaim is reasonable.
   12954            0 :     TCompOutEstimate = this->TCondense + (this->HCompOut - HSatVapCondense) / CpSatVapCondense;
   12955              : 
   12956            0 :     state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailTemperature = (TsatforPdisch + TCompOutEstimate) / 2.0;
   12957            0 :     this->AverageCompressorCOP = this->TotCompCapacity / (this->TotCompPower + this->TotHiStageCompPower);
   12958            0 :     this->TotCompElecConsump = this->TotCompPower * localTimeStepSec;
   12959            0 :     if (this->NumStages == 2) {
   12960            0 :         this->TotHiStageCompElecConsump = this->TotHiStageCompPower * localTimeStepSec;
   12961            0 :         this->TotCompElecConsumpTwoStage = this->TotCompElecConsump + this->TotHiStageCompElecConsump;
   12962              :     }
   12963            0 :     this->TotCompCoolingEnergy = this->TotCompCapacity * localTimeStepSec;
   12964            0 :     this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * localTimeStepSec;
   12965            0 : }
   12966              : 
   12967            0 : void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state)
   12968              : {
   12969              : 
   12970              :     // SUBROUTINE INFORMATION:
   12971              :     //       AUTHOR         Brian A. Fricke, ORNL
   12972              :     //       DATE WRITTEN   Fall 2011
   12973              :     //       RE-ENGINEERED  na
   12974              : 
   12975              :     // PURPOSE OF THIS SUBROUTINE:
   12976              :     // Find the compressor power, energy, capacity, and efficiency for a detailed transcritical CO2
   12977              :     // refrigeration system.
   12978              : 
   12979              :     // METHODOLOGY EMPLOYED:
   12980              :     // Use AHRI compressor performance curves for subcritical compressor operation, AHRI-style compressor
   12981              :     // performance curves for transcritical compressor operation, the evaporating temperature of the
   12982              :     // medium- and low-temperature loads, and the gas cooler outlet conditions (temperature, pressure
   12983              :     // and enthalpy).
   12984              : 
   12985              :     // REFERENCES:
   12986              :     // ANSI/AHRI. 2004. Standard 540, Standard for Performance Rating of Positive Displacement Refrigerant
   12987              :     //     Compressors and Compressor Units. Arlington, VA: Air-Conditioning, Heating, and Refrigeration
   12988              :     //     Institute.
   12989              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   12990              :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   12991              :     //     Journal of Refrigeration 34: 527-539.
   12992              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   12993              :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   12994              :     //     Refrigeration 34: 540-549.
   12995              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   12996              :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   12997              :     //     Refrigeration 31: 516-524.
   12998              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   12999              :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   13000              :     //     Refrigeration 31: 525-534.
   13001              : 
   13002              :     // SUBROUTINE PARAMETER DEFINITIONS:
   13003              :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c.
   13004              :     // For the same pressure drop, CO2 has a corresponding temperature penalty 5 to 10 times smaller than
   13005              :     // ammonia and R-134a (ASHRAE Handbook of Refrigeration, 2010, p. 3.7).  Ignore pressure drop for CO2 calculations.
   13006              :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   13007              : 
   13008            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   13009              : 
   13010              :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateTransCompressors");
   13011              :     int Iter;                           // Iteration counter
   13012              :     Real64 CapacityCorrectionMT;        // Capacity at existing subcool/superheat over cap at rated conditions for MT loads
   13013              :     Real64 CaseEnthalpyChangeRatedMT;   // Enthalpy change in medium temperature cases at compressor rated cond, J/kg
   13014              :     Real64 CaseEnthalpyChangeRatedLT;   // Enthalpy change in low temperature cases at compressor rated cond, J/kg
   13015              :     Real64 DensityActualLT;             // Density of superheated gas at LP compressor inlet, m3/kg
   13016              :     Real64 DensityActualMT;             // Density of superheated gas at HP compressor inlet, m3/kg
   13017              :     Real64 DensityRatedHP;              // Density of high pressure compressor inlet gas at rated superheat, m3/kg
   13018              :     Real64 DensityRatedLP;              // Density of low pressure compressor inlet gas at rated superheat, m3/kg
   13019              :     Real64 HCaseInRatedLT;              // Enthalpy entering low temperature cases at rated subcooling, J/kg
   13020              :     Real64 HCaseInRatedMT;              // Enthalpy entering medium temperature cases at rated subcooling, J/kg
   13021            0 :     Real64 HCompInRatedHP(0.0);         // Enthalpy entering high pressure compressor at rated superheat, J/kg
   13022              :     Real64 HCompInRatedLP;              // Enthalpy entering low pressure compressor at rated superheat, J/kg
   13023              :     Real64 HGCOutlet;                   // Enthalpy at gas cooler outlet, J/kg
   13024              :     Real64 HIdeal;                      // Ideal enthalpy at subcooler (for 100% effectiveness)
   13025              :     Real64 HsatLiqforTevapNeededMT;     // Enthalpy of saturated liquid at MT evaporator, J/kg
   13026              :     Real64 HsatVaporforTevapneededMT;   // Enthalpy of saturated vapor at MT evaporator (transcritical cycle), J/kg
   13027              :     Real64 HsatVaporforTevapneededLT;   // Enthalpy of saturated vapor at LT evaporator (transcritical cycle), J/kg
   13028              :     Real64 LFLastComp;                  // Load factor for last compressor dispatched
   13029              :     Real64 MassCorrectionLT;            // Mass flow at existing subcool/superheat over cap at rated conditions for LT loads
   13030              :     Real64 MassCorrectionMT;            // Mass flow at existing subcool/superheat over cap at rated conditions for MT loads
   13031              :     Real64 NeededCapacityLT;            // Sum of LT case loads and mech subcooler loads (transcritical cycle), W
   13032              :     Real64 NeededCapacityMT;            // Sum of MT case loads and mech subcooler loads (transcritical cycle), W
   13033              :     Real64 PSuctionLT;                  // Suction pressure in low temperature cases, Pa
   13034              :     Real64 PSuctionMT;                  // Suction pressure in medium temperature cases, Pa
   13035              :     Real64 PGCOutlet;                   // Gas cooler outlet pressure, Pa
   13036            0 :     Real64 QualityReceiver(0.0);        // Refrigerant quality in the receiver
   13037              :     Real64 SubcoolEffect;               // Heat exchanger effectiveness of the subcooler
   13038              :     Real64 TempInRatedHP;               // Temperature entering high pressure compressor at rated superheat, C
   13039              :     Real64 TempInRatedLP;               // Temperature entering low pressure compressor at rated superheat, C
   13040              :     Real64 TsatforPdisLT;               // Low temperature saturated discharge temperature (transcritical cycle), C
   13041              :     Real64 TsatforPdisMT;               // Medium temperature saturated discharge temperature (transcritical cycle), C
   13042              :     Real64 TsatforPsucLT;               // Low temperature saturated suction temperature (transcritical cycle), C
   13043              :     Real64 TsatforPsucMT;               // Medium temperature saturated suction temperature (transcritical cycle), C
   13044              :     Real64 TSubcoolerColdIn;            // Suction gas temperature at the inlet of the subcooler, C
   13045              :     Real64 TotalEnthalpyChangeActualLT; // Actual enthalpy change in LT cases, J/kg
   13046              :     Real64 TotalEnthalpyChangeActualMT; // Actual enthalpy change in MT cases, J/kg
   13047              :     Real64 TotalRefMassFlow;            // Total mass flow through high pressure side of system, kg/s
   13048              :     Real64 Xu;                          // Initial upper guess for iterative search
   13049              :     Real64 Xl;                          // Initial lower guess for iterative search
   13050            0 :     Real64 Xnew(0.0);                   // New guess for iterative search
   13051              : 
   13052            0 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13053            0 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13054              : 
   13055            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13056            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13057              : 
   13058              :     // Determine refrigerating capacity needed
   13059              :     // Load due to previously unmet low temperature compressor loads (transcritical system)
   13060              :     Real64 AccumLoadLT;
   13061            0 :     NeededCapacityLT = 0.0;
   13062            0 :     if (this->transSysType == TransSysType::TwoStage) {
   13063            0 :         AccumLoadLT = max(0.0, (this->UnmetEnergyLT / localTimeStep / Constant::rSecsInHour)); // localTimeStep / rSecsInHour?
   13064            0 :         NeededCapacityLT = this->TotalSystemLoadLT + AccumLoadLT + this->PipeHeatLoadLT;
   13065              :     } // (TransSystem(SysNum)%TransSysType == 2)
   13066              : 
   13067              :     // Load due to previously unmet medium temperature compressor loads (transcritical system)
   13068            0 :     Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / localTimeStep / Constant::rSecsInHour));
   13069            0 :     NeededCapacityMT = this->TotalSystemLoadMT + AccumLoadMT + this->PipeHeatLoadMT;
   13070              : 
   13071              :     // Determine refrigerant properties at receiver
   13072            0 :     this->CpSatLiqReceiver = this->refrig->getSatSpecificHeat(state, this->TReceiver, 0.0, RoutineName);
   13073              : 
   13074              :     // Enthalpy at the receiver bypass, J/kg
   13075            0 :     Real64 HReceiverBypass = this->refrig->getSatEnthalpy(state, this->TReceiver, 1.0, RoutineName);
   13076              : 
   13077              :     // Determine refrigerant properties at low temperature (LT) loads (if present)
   13078              :     // Dispatch low pressure (LP) compressors as necessary
   13079            0 :     if (this->transSysType == TransSysType::TwoStage) { // LT side of TwoStage transcritical system
   13080            0 :         this->HCaseInLT = this->HSatLiqReceiver;
   13081              :         // TCompInLP and HCompInLP include case superheat plus effect of suction line heat gain
   13082            0 :         this->TCompInLP = this->TEvapNeededLT + TransCaseSuperheat + this->PipeHeatLoadLT / (this->CpSatVapEvapLT * this->RefMassFlowtoLTLoads);
   13083            0 :         this->HCompInLP = this->HCaseOutLT + this->PipeHeatLoadLT / this->RefMassFlowtoLTLoads;
   13084            0 :         TsatforPsucLT = this->TEvapNeededLT;
   13085            0 :         TsatforPdisLT = this->TEvapNeededMT;
   13086            0 :         HsatVaporforTevapneededLT = this->refrig->getSatEnthalpy(state, this->TEvapNeededLT, 1.0, RoutineName);
   13087            0 :         HsatLiqforTevapNeededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 0.0, RoutineName);
   13088            0 :         PSuctionLT = this->refrig->getSatPressure(state, TsatforPsucLT, RoutineName);
   13089            0 :         DensityActualLT = this->refrig->getSupHeatDensity(state, this->TCompInLP, PSuctionLT, RoutineName);
   13090            0 :         TotalEnthalpyChangeActualLT = this->HCompInLP - this->HCaseInLT;
   13091              : 
   13092              :         // Dispatch low pressure (LP) compressors
   13093              :         // Before dispatching LP compressors, zero sum of compressor outputs and zero each compressor
   13094            0 :         this->TotCompCapacityLP = 0.0;
   13095            0 :         this->RefMassFlowCompsLP = 0.0;
   13096            0 :         this->TotCompPowerLP = 0.0;
   13097              : 
   13098            0 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13099            0 :             int CompID = this->CompressorNumLP(CompIndex);
   13100            0 :             Compressor(CompID).Power = 0.0;
   13101            0 :             Compressor(CompID).MassFlow = 0.0;
   13102            0 :             Compressor(CompID).Capacity = 0.0;
   13103            0 :             Compressor(CompID).ElecConsumption = 0.0;
   13104            0 :             Compressor(CompID).CoolingEnergy = 0.0;
   13105            0 :             Compressor(CompID).LoadFactor = 0.0;
   13106              :         }
   13107              : 
   13108            0 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13109            0 :             int CompID = this->CompressorNumLP(CompIndex);
   13110            0 :             auto &compressor = Compressor(CompID);
   13111              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13112            0 :             switch (compressor.SubcoolRatingType) {
   13113            0 :             case CompRatingType::Subcooling: {
   13114            0 :                 HCaseInRatedLT = HsatLiqforTevapNeededMT - this->CpSatLiqReceiver * compressor.RatedSubcool;
   13115            0 :             } break;
   13116            0 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13117            0 :                 HCaseInRatedLT = this->refrig->getSatEnthalpy(state, compressor.RatedSubcool, 0.0, RoutineName);
   13118            0 :             } break;
   13119            0 :             default:
   13120            0 :                 break;
   13121              :             }
   13122            0 :             switch (compressor.SuperheatRatingType) {
   13123            0 :             case CompRatingType::Superheat: {
   13124            0 :                 HCompInRatedLP = HsatVaporforTevapneededLT + this->CpSatVapEvapLT * compressor.RatedSuperheat;
   13125            0 :                 TempInRatedLP = this->TEvapNeededLT + compressor.RatedSuperheat;
   13126            0 :             } break;
   13127            0 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in
   13128              :                                                          // "CompRatingType::Superheat"
   13129            0 :                 TempInRatedLP = compressor.RatedSuperheat;
   13130            0 :                 HCompInRatedLP = this->refrig->getSupHeatEnthalpy(state, compressor.RatedSuperheat, PSuctionLT, RoutineName);
   13131            0 :             } break;
   13132            0 :             default:
   13133            0 :                 break;
   13134              :             }
   13135              : 
   13136            0 :             CaseEnthalpyChangeRatedLT = HCompInRatedLP - HCaseInRatedLT;
   13137            0 :             DensityRatedLP = this->refrig->getSupHeatDensity(state, TempInRatedLP, PSuctionLT, RoutineName);
   13138              : 
   13139              :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13140              :             //  the increase in capacity due to extra subcooling
   13141            0 :             MassCorrectionLT = DensityActualLT / DensityRatedLP;
   13142              :             // Capacity at existing subcool/superheat over cap at rated conditions for LT loads
   13143            0 :             Real64 CapacityCorrectionLT = MassCorrectionLT * TotalEnthalpyChangeActualLT / CaseEnthalpyChangeRatedLT;
   13144            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13145            0 :             compressor.Capacity = CapacityCorrectionLT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13146            0 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActualLT;
   13147            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13148            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13149            0 :             compressor.LoadFactor = 1.0;
   13150            0 :             if ((this->TotCompCapacityLP + compressor.Capacity) >= NeededCapacityLT) {
   13151            0 :                 LFLastComp = (NeededCapacityLT - this->TotCompCapacityLP) / compressor.Capacity;
   13152            0 :                 compressor.Power *= LFLastComp;
   13153            0 :                 compressor.MassFlow *= LFLastComp;
   13154            0 :                 compressor.Capacity *= LFLastComp;
   13155            0 :                 this->TotCompCapacityLP += compressor.Capacity;
   13156            0 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13157            0 :                 this->TotCompPowerLP += compressor.Power;
   13158            0 :                 compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13159            0 :                 compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13160            0 :                 compressor.LoadFactor = LFLastComp;
   13161            0 :                 break;
   13162              :             } else {
   13163            0 :                 this->TotCompCapacityLP += compressor.Capacity;
   13164            0 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13165            0 :                 this->TotCompPowerLP += compressor.Power;
   13166              :             }
   13167              :         } // NumCompressorsLP
   13168            0 :         this->HCompOutLP = this->HCompInLP + this->TotCompPowerLP / this->RefMassFlowCompsLP;
   13169              :     } // (TransSystem(SysNum)%TransSysType == 2)
   13170              : 
   13171              :     // Determine refrigerant properties at medium temperature (MT) loads
   13172              :     // Dispatch high pressure (HP) compressors as necessary
   13173            0 :     TsatforPsucMT = this->TEvapNeededMT;
   13174            0 :     if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Transcritical system is operating in transcritical region
   13175            0 :         HGCOutlet = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13176              :     } else { // Transcritical system is operating in subcritical region
   13177            0 :         TsatforPdisMT = GasCooler(this->GasCoolerNum(1)).TGasCoolerOut;
   13178              :     }
   13179            0 :     PSuctionMT = this->refrig->getSatPressure(state, TsatforPsucMT, RoutineName);
   13180            0 :     PGCOutlet = GasCooler(this->GasCoolerNum(1)).PGasCoolerOut;
   13181            0 :     HsatVaporforTevapneededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 1.0, RoutineName);
   13182            0 :     this->HCaseInMT = this->HSatLiqReceiver;
   13183              :     // Enthalpy of refrigerant after leaving medium temperature loads and low pressure compressors
   13184              : 
   13185              :     // Combined enthalpy from the outlets of the LP compressor and MT loads, J/kg
   13186            0 :     Real64 HCaseOutLTMT = (this->RefMassFlowtoLTLoads * this->HCompOutLP + this->RefMassFlowtoMTLoads * this->HCaseOutMT + this->PipeHeatLoadMT) /
   13187            0 :                           (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13188              : 
   13189              :     // Total refrigerant flow rate is total flow from LT and MT loads divided by (1-x) where x is the quality of the
   13190              :     // refrigerant entering the receiver.  The receiver bypass flow rate is (x)*(Total Flow).
   13191              :     // Iterate to find the quality of the refrigerant entering the receiver.
   13192            0 :     Xu = 1.0; // upper bound on quality
   13193            0 :     Xl = 0.0; // lower bound on quality
   13194            0 :     if ((GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis) > this->HSatLiqReceiver) {
   13195            0 :         for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations to find receiver quality
   13196            0 :             QualityReceiver = (Xu + Xl) / 2.0;
   13197            0 :             Real64 Hnew = this->refrig->getSatEnthalpy(state, this->TReceiver, QualityReceiver, RoutineName);
   13198              : 
   13199              :             // estimated QualityReceiver is too high
   13200            0 :             if (Hnew > (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) {
   13201            0 :                 Xu = QualityReceiver;
   13202              :             } else { // estimated QualityReceiver is too low
   13203            0 :                 Xl = QualityReceiver;
   13204              :             }
   13205            0 :             if (std::abs((Hnew - (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) / Hnew) < ErrorTol) break;
   13206              :         }
   13207            0 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) / (1.0 - QualityReceiver);
   13208            0 :         this->RefMassFlowReceiverBypass = QualityReceiver * TotalRefMassFlow;
   13209              :     } else {
   13210            0 :         this->RefMassFlowReceiverBypass = 0.0;
   13211            0 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13212              :     } // %HGasCoolerOut > TransSystem(SysNum)%HSatLiqReceiver)
   13213              : 
   13214            0 :     this->HCompInHP = (HCaseOutLTMT * (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) + HReceiverBypass * this->RefMassFlowReceiverBypass) /
   13215            0 :                       (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads + this->RefMassFlowReceiverBypass);
   13216              : 
   13217              :     // Iterate to find the suction temperature entering subcooler
   13218            0 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13219            0 :     Xu = Xl + 50.0;
   13220            0 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13221            0 :         Xnew = (Xu + Xl) / 2.0;
   13222            0 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13223            0 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13224            0 :             Xu = Xnew;
   13225              :         } else { // xnew is too low
   13226            0 :             Xl = Xnew;
   13227              :         }
   13228            0 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) break;
   13229              :     }
   13230            0 :     TSubcoolerColdIn = Xnew;
   13231              : 
   13232              :     // Modify receiver inlet enthalpy and HP compressor inlet enthalpy to account for subcooler
   13233            0 :     HIdeal = this->refrig->getSupHeatEnthalpy(state, GasCooler(this->GasCoolerNum(1)).TGasCoolerOut, PSuctionMT, RoutineName);
   13234              :     // Only use subcooler if suction gas inlet temperature less than gas cooler outlet temperature
   13235            0 :     if (TSubcoolerColdIn < GasCooler(this->GasCoolerNum(1)).TGasCoolerOut) {
   13236            0 :         SubcoolEffect = this->SCEffectiveness;
   13237              :     } else {
   13238            0 :         SubcoolEffect = 0.0;
   13239              :     } // (TSubcoolerColdIn < GasCooler(SysNum)%TGasCoolerOut)
   13240            0 :     this->DelHSubcoolerSuc = SubcoolEffect * (HIdeal - this->HCompInHP);
   13241            0 :     this->HCompInHP += this->DelHSubcoolerSuc;
   13242            0 :     this->DelHSubcoolerDis = -this->DelHSubcoolerSuc;
   13243              : 
   13244              :     // Iterate to find the temperature at the inlet of the high pressure (HP) compressors
   13245            0 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13246            0 :     Xu = Xl + 50.0;
   13247            0 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13248            0 :         Xnew = (Xu + Xl) / 2.0;
   13249            0 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13250            0 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13251            0 :             Xu = Xnew;
   13252              :         } else { // xnew is too low
   13253            0 :             Xl = Xnew;
   13254              :         }
   13255            0 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) break;
   13256              :     }
   13257            0 :     this->TCompInHP = Xnew;
   13258              : 
   13259              :     //  For capacity correction of HP compressors, consider subcooler, receiver, MT loads, LT loads and LP compressors
   13260              :     //  to constitute the "load".  The actual and rated conditions at the exit of the gas cooler and the inlet of the
   13261              :     //  HP compressors are used for capacity correction calculations.
   13262            0 :     DensityActualMT = this->refrig->getSupHeatDensity(state, this->TCompInHP, PSuctionMT, RoutineName);
   13263            0 :     TotalEnthalpyChangeActualMT = this->HCompInHP - GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13264              : 
   13265              :     // Dispatch HP compressors
   13266              :     // Before dispatching HP compressors, zero sum of compressor outputs and zero each compressor
   13267            0 :     this->TotCompCapacityHP = 0.0;
   13268            0 :     this->RefMassFlowCompsHP = 0.0;
   13269            0 :     this->TotCompPowerHP = 0.0;
   13270              : 
   13271            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13272            0 :         int CompID = this->CompressorNumHP(CompIndex);
   13273            0 :         auto &compressor = Compressor(CompID);
   13274            0 :         compressor.Power = 0.0;
   13275            0 :         compressor.MassFlow = 0.0;
   13276            0 :         compressor.Capacity = 0.0;
   13277            0 :         compressor.ElecConsumption = 0.0;
   13278            0 :         compressor.CoolingEnergy = 0.0;
   13279            0 :         compressor.LoadFactor = 0.0;
   13280              :     }
   13281              : 
   13282              :     // Dispatch High Pressure compressors to meet load, note they were listed in compressor list in dispatch order
   13283            0 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13284            0 :         int CompID = this->CompressorNumHP(CompIndex);
   13285            0 :         auto &compressor = Compressor(CompID);
   13286              :         // Need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13287              :         // Transcritical operation requires rated superheat
   13288              :         // Subcritical operation requires rated subcool and rated superheat
   13289            0 :         switch (compressor.SubcoolRatingType) {
   13290            0 :         case CompRatingType::Subcooling: {
   13291            0 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13292            0 :                 HCaseInRatedMT =
   13293            0 :                     GasCooler(this->GasCoolerNum(1)).HGasCoolerOut - GasCooler(this->GasCoolerNum(1)).CpGasCoolerOut * compressor.RatedSubcool;
   13294              :             } else { // Transcritical operation
   13295            0 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13296              :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13297            0 :         } break;
   13298            0 :         case CompRatingType::LiquidTemperature: {                // have rated liquid temperature stored in "RatedSubcool"
   13299            0 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13300            0 :                 HCaseInRatedMT = this->refrig->getSatEnthalpy(state, compressor.RatedSubcool, 0.0, RoutineName);
   13301              :             } else { // Transcritical operation
   13302            0 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13303              :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13304            0 :         } break;
   13305            0 :         default:
   13306            0 :             break;
   13307              :         }
   13308            0 :         switch (compressor.SuperheatRatingType) {
   13309            0 :         case CompRatingType::Superheat: {
   13310            0 :             HCompInRatedHP = HsatVaporforTevapneededMT + this->CpSatVapEvapMT * compressor.RatedSuperheat;
   13311            0 :             TempInRatedHP = this->TEvapNeededMT + compressor.RatedSuperheat;
   13312            0 :         } break;
   13313            0 :         case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13314            0 :             TempInRatedHP = compressor.RatedSuperheat;
   13315            0 :             HCompInRatedHP = this->refrig->getSupHeatEnthalpy(state, compressor.RatedSuperheat, PSuctionMT, RoutineName);
   13316            0 :         } break;
   13317            0 :         default:
   13318            0 :             break;
   13319              :         }
   13320              : 
   13321            0 :         CaseEnthalpyChangeRatedMT = HCompInRatedHP - HCaseInRatedMT;
   13322            0 :         DensityRatedHP = this->refrig->getSupHeatDensity(state, TempInRatedHP, PSuctionMT, RoutineName);
   13323              :         //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13324              :         //  the increase in capacity due to extra subcooling
   13325            0 :         MassCorrectionMT = DensityActualMT / DensityRatedHP;
   13326            0 :         CapacityCorrectionMT = MassCorrectionMT * TotalEnthalpyChangeActualMT / CaseEnthalpyChangeRatedMT;
   13327              : 
   13328            0 :         if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // System is operating in transcritical region
   13329            0 :             compressor.Power = Curve::CurveValue(state, compressor.TransElecPowerCurvePtr, TsatforPsucMT, PGCOutlet);
   13330            0 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.TransCapacityCurvePtr, TsatforPsucMT, HGCOutlet);
   13331              :         } else { // System is operating in subcritical region
   13332            0 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucMT, TsatforPdisMT);
   13333            0 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucMT, TsatforPdisMT);
   13334              :         } // (GasCooler(SysNum)%TransOpFlag)
   13335              :         //  Mass flow through HP compressors is HP compressor refrigerating capacity divided by MT load, LT load and LP compressor power
   13336            0 :         compressor.MassFlow = TotalRefMassFlow * compressor.Capacity / (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP);
   13337            0 :         compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13338            0 :         compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13339            0 :         compressor.LoadFactor = 1.0;
   13340              :         // calculate load factor for last compressor added
   13341              :         // assumes either cycling or part load eff = full load eff for last compressor
   13342            0 :         if ((this->TotCompCapacityHP + compressor.Capacity) >= (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP)) {
   13343            0 :             LFLastComp = ((NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP) - this->TotCompCapacityHP) / compressor.Capacity;
   13344            0 :             compressor.Power *= LFLastComp;
   13345            0 :             compressor.MassFlow *= LFLastComp;
   13346            0 :             compressor.Capacity *= LFLastComp;
   13347            0 :             this->TotCompCapacityHP += compressor.Capacity;
   13348            0 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13349            0 :             this->TotCompPowerHP += compressor.Power;
   13350            0 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13351            0 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13352            0 :             compressor.LoadFactor = LFLastComp;
   13353            0 :             break;
   13354              :         } else {
   13355            0 :             this->TotCompCapacityHP += compressor.Capacity;
   13356            0 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13357            0 :             this->TotCompPowerHP += compressor.Power;
   13358              :         }
   13359              : 
   13360              :     } // NumCompressorsHP
   13361              : 
   13362            0 :     this->HCompOutHP = this->HCompInHP + this->TotCompPowerHP / this->RefMassFlowCompsHP;
   13363            0 :     this->RefMassFlowComps = this->RefMassFlowCompsLP + this->RefMassFlowCompsHP;
   13364            0 :     this->TotCompCapacity = this->TotCompCapacityHP + this->TotCompCapacityLP;
   13365            0 :     this->AverageCompressorCOP = (this->TotCompCapacityHP - this->TotCompPowerLP) / (this->TotCompPowerLP + this->TotCompPowerHP);
   13366            0 :     this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * localTimeStepSec;
   13367            0 :     this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * localTimeStepSec;
   13368            0 : }
   13369              : 
   13370            0 : void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state)
   13371              : {
   13372              : 
   13373              :     // SUBROUTINE INFORMATION:
   13374              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   13375              :     //       DATE WRITTEN   Spring 2008
   13376              :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   13377              :     //       RE-ENGINEERED  na
   13378              : 
   13379              :     // PURPOSE OF THIS SUBROUTINE:
   13380              :     // Find the subcooler energy exchange and refrigerant states for a particular detailed
   13381              :     // refrigeration system. Use the refrigerant property subroutines in FluidProperties.cc
   13382              : 
   13383              :     // METHODOLOGY EMPLOYED:
   13384              :     // Use refrigerant properties and heat exchanger correlations.  NOTE:  Assumes any Mech subcooler
   13385              :     // immediately follows condenser outlet (after pipe loss) and comes before any LSHX
   13386              : 
   13387              :     // REFERENCES:
   13388              :     // ASHRAE 1006 Section 2: Refrigeration Accessories
   13389              : 
   13390              :     static constexpr std::string_view RoutineName = "CalculateSubcoolers";
   13391            0 :     Real64 TLiqInActualLocal = 0.0; // Liquid T in, after condenser, before any mechanical subcooler
   13392              : 
   13393            0 :     auto &System = state.dataRefrigCase->System;
   13394            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13395            0 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   13396              : 
   13397            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13398            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13399              : 
   13400              :     // HCaseIn has to be recalculated as the starting point for the subcoolers here because
   13401              :     //  of the multiple number of iterations through this subroutine and because Tcondense is evolving.
   13402            0 :     if (this->NumStages == 1) { // Single-stage compression system
   13403            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13404            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13405            0 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser(this->CondenserNum(1)).RatedSubcool;
   13406              : 
   13407              :         // Two-stage compression with flash intercooler
   13408            0 :     } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::Flash) {
   13409            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13410            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13411            0 :         this->HCaseIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13412              : 
   13413              :         // Two-stage compression with shell-and-coil intercooler
   13414            0 :     } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13415            0 :         TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   13416            0 :                             this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   13417            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13418            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13419            0 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - TLiqInActualLocal);
   13420              :     } // NumStages and IntercoolerType
   13421              : 
   13422            0 :     for (int SubcoolerIndex = 1; SubcoolerIndex <= this->NumSubcoolers; ++SubcoolerIndex) {
   13423            0 :         int SubcoolerID = this->SubcoolerNum(SubcoolerIndex);
   13424            0 :         auto &cooler = Subcooler(SubcoolerID);
   13425              :         // set up local variables for convenience
   13426            0 :         Real64 DelTLiqDes = cooler.LiqSuctDesignDelT;
   13427            0 :         Real64 TVapInDes = cooler.LiqSuctDesignTvapIn;
   13428            0 :         Real64 TLiqInDes = cooler.LiqSuctDesignTliqIn;
   13429            0 :         Real64 ControlTLiqOut = cooler.MechControlTliqOut;
   13430            0 :         Real64 CpLiquid = this->CpSatLiqCond;
   13431            0 :         Real64 CpVapor = this->CpSatVapEvap;
   13432            0 :         if (this->NumStages == 1) { // Single-stage compression system
   13433            0 :             TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool;
   13434              : 
   13435              :             // Two-stage compression with flash intercooler
   13436            0 :         } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::Flash) {
   13437            0 :             TLiqInActualLocal = this->TIntercooler;
   13438              : 
   13439              :             // Two-stage compression with shell-and-coil intercooler
   13440            0 :         } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13441            0 :             TLiqInActualLocal =
   13442            0 :                 this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   13443            0 :                 this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   13444              :         } // NumStages and IntercoolerType
   13445              : 
   13446            0 :         switch (cooler.subcoolerType) {
   13447              :             // Mechanical subcoolers required to come first in order to take advantage of delT
   13448              :             //  from lshx. taken care of because subcooler ID assigned in that order in input.
   13449            0 :         case SubcoolerType::Mechanical: {
   13450            0 :             Real64 mechSCLoad = this->RefMassFlowtoLoads * CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13451            0 :             this->HCaseIn -= CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13452              :             // refrigeration benefit to System(sysnum)
   13453              :             // refrigeration load must be assigned properly according to input
   13454            0 :             int SysProvideID = cooler.MechSourceSysID;
   13455            0 :             System(SysProvideID).MechSCLoad(SubcoolerID) = mechSCLoad;
   13456            0 :             cooler.MechSCTransLoad = mechSCLoad;
   13457            0 :             cooler.MechSCTransEnergy = mechSCLoad * localTimeStepSec;
   13458              :             // Reset inlet temperature for any LSHX that follows this mech subcooler
   13459            0 :             TLiqInActualLocal = ControlTLiqOut;
   13460            0 :             this->TCompIn = this->TEvapNeeded + CaseSuperheat;
   13461            0 :         } break;
   13462            0 :         case SubcoolerType::LiquidSuction: {
   13463            0 :             Real64 LSHXeffectiveness = DelTLiqDes / (TLiqInDes - TVapInDes);
   13464            0 :             Real64 TVapInActual = this->TEvapNeeded + CaseSuperheat;
   13465            0 :             Real64 DelTempActual = LSHXeffectiveness * (TLiqInActualLocal - TVapInActual);
   13466            0 :             TLiqInActualLocal -= DelTempActual;
   13467            0 :             Real64 SubcoolLoad = this->RefMassFlowtoLoads * CpLiquid * DelTempActual;
   13468            0 :             Real64 SubcoolerSupHeat = SubcoolLoad / CpVapor / this->RefMassFlowComps;
   13469            0 :             this->TCompIn = TVapInActual + SubcoolerSupHeat;
   13470            0 :             this->HCaseIn -= SubcoolLoad / this->RefMassFlowtoLoads;
   13471            0 :             this->LSHXTrans = SubcoolLoad;
   13472            0 :             this->LSHXTransEnergy = SubcoolLoad * localTimeStepSec;
   13473            0 :         } break;
   13474            0 :         default:
   13475            0 :             break;
   13476              :         }
   13477              : 
   13478            0 :         this->TLiqInActual = TLiqInActualLocal;
   13479              :     }
   13480            0 : }
   13481              : 
   13482            1 : void GetRefrigeratedRackIndex(EnergyPlusData &state,
   13483              :                               std::string const &Name,
   13484              :                               int &IndexPtr,
   13485              :                               DataHeatBalance::RefrigSystemType const SysType,
   13486              :                               bool &ErrorsFound,
   13487              :                               std::string_view const ThisObjectType,
   13488              :                               bool const SuppressWarning)
   13489              : {
   13490              : 
   13491              :     // SUBROUTINE INFORMATION:
   13492              :     //       AUTHOR         Richard Raustad
   13493              :     //       DATE WRITTEN   June 2007
   13494              :     //       MODIFIED       Therese Stovall May 2008
   13495              :     //       RE-ENGINEERED  na
   13496              :     // PURPOSE OF THIS SUBROUTINE:
   13497              :     // This subroutine sets an index for a given refrigerated rack or refrigeration condenser
   13498              :     //  -- issues error message if the rack or condenser is not found.
   13499              : 
   13500            1 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   13501            1 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13502              : 
   13503            1 :     CheckRefrigerationInput(state);
   13504              : 
   13505            1 :     switch (SysType) {
   13506            1 :     case DataHeatBalance::RefrigSystemType::Rack: {
   13507            1 :         IndexPtr = Util::FindItemInList(Name, RefrigRack);
   13508            1 :         if (IndexPtr == 0) {
   13509            0 :             if (SuppressWarning) {
   13510              :                 //     No warning printed if only searching for the existence of a refrigerated rack
   13511              :             } else {
   13512            0 :                 if (!ThisObjectType.empty()) {
   13513            0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   13514              :                 } else {
   13515            0 :                     if (!ThisObjectType.empty()) {
   13516            0 :                         ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   13517              :                     } else {
   13518            0 :                         ShowSevereError(state, format("GetRefrigeratedRackIndex: Rack not found={}", Name));
   13519              :                     }
   13520              :                 }
   13521              :             }
   13522            0 :             ErrorsFound = true;
   13523              :         }
   13524            1 :     } break;
   13525            0 :     case DataHeatBalance::RefrigSystemType::Detailed: {
   13526            0 :         IndexPtr = Util::FindItemInList(Name, Condenser);
   13527            0 :         if (IndexPtr == 0) {
   13528            0 :             if (SuppressWarning) {
   13529              :                 //     No warning printed if only searching for the existence of a refrigeration Condenser
   13530              :             } else {
   13531            0 :                 if (!ThisObjectType.empty()) {
   13532            0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Condenser not found={}", ThisObjectType, Name));
   13533              :                 } else {
   13534            0 :                     ShowSevereError(state, format("GetRefrigeratedRackIndex: Condenser not found={}", Name));
   13535              :                 }
   13536              :             }
   13537              :         }
   13538            0 :         ErrorsFound = true;
   13539            0 :     } break;
   13540            0 :     default:
   13541            0 :         break;
   13542              :     }
   13543            1 : }
   13544              : 
   13545          150 : void ReportRefrigerationComponents(EnergyPlusData &state)
   13546              : {
   13547              : 
   13548              :     // SUBROUTINE INFORMATION:
   13549              :     //       AUTHOR         Richard Raustad, FSEC
   13550              :     //       DATE WRITTEN   October 2004
   13551              :     //       MODIFIED       Shirey, FSEC Dec 2004; Lawrie, Mar 2008 - Node names, not numbers.
   13552              :     //       MODIFIED       Stovall - 2008 to 2010, new refrig variables and move orphan reporting to input.
   13553              :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
   13554              :     //       RE-ENGINEERED  na
   13555              : 
   13556              :     // PURPOSE OF THIS SUBROUTINE:
   13557              :     // To report information from the input deck for refrigerated cases and racks to the eio and err file.
   13558              : 
   13559          150 :     std::string ChrOut;
   13560          150 :     std::string ChrOut2;
   13561              : 
   13562          150 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   13563          150 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   13564          150 :     auto &System = state.dataRefrigCase->System;
   13565          150 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   13566          150 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13567          150 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13568          150 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13569          150 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   13570          150 :     auto &Secondary = state.dataRefrigCase->Secondary;
   13571          150 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   13572          150 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   13573          150 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   13574              : 
   13575              :     static constexpr std::string_view Format_104(
   13576              :         "! <Refrigeration Compressor Rack>,Compressor Rack Name, # Refrigerated Cases Connected,# WalkIn Coolers "
   13577              :         "Connected, Heat Rejection Location, Condenser Type, COP");
   13578              :     static constexpr std::string_view Format_105(
   13579              :         "!  <Refrigeration Case>,Refrigeration Case Number, Refrigeration Case Name,Zone Name,Zone Node #,Zone "
   13580              :         "Node Name,Capacity (W/m),LHR,Temperature (C),Length (m),Fan (W/m),Installed Lighting (W/m),Anti-Sweat "
   13581              :         "(W/m),Defrost (W/m)");
   13582              :     static constexpr std::string_view Format_108("!  <Refrigeration Compressor>,Compressor Number,Compressor Name,Nominal Capacity (W)");
   13583              :     static constexpr std::string_view Format_109("! <#Refrigeration Compressor Racks>,Number of Refrigeration Compressor Racks");
   13584              :     static constexpr std::string_view Format_117("! <#Detailed Refrigeration Systems>,Number of Detailed Refrigeration Systems");
   13585              :     static constexpr std::string_view Format_118(
   13586              :         "! <Detailed Refrigeration System>,Refrigeration System Name,Refrigerant Used, # Refrigerated Cases "
   13587              :         "Connected, # WalkInCoolers Connected, #Air Chillers Connected, # Secondary Loops Served, # Cascade Condensers "
   13588              :         "Served, # Mechanical Subcoolers Served, # Compressors Connected, # Compression Stages, Intercooler Type, "
   13589              :         "Intercooler Effectiveness, # Subcoolers Connected, Minimum Condensing Temperature (C)");
   13590              :     static constexpr std::string_view Format_119(
   13591              :         "!  <Refrigeration Walk In Cooler>, Walk In Number, Walk In Name,Capacity (W),Temperature (C),Coil Fan "
   13592              :         "(W), Circulating Fan (W), Lighting (W),Heaters (W),Defrost (W), # Zones");
   13593              :     static constexpr std::string_view Format_120(
   13594              :         "! <#Detailed Transcritical Refrigeration Systems>,Number of Detailed Transcritical Refrigeration Systems");
   13595              :     static constexpr std::string_view Format_121(
   13596              :         "! <Detailed Transcritical Refrigeration System>,Transcritical Refrigeration System Name,Refrigerant Used, # "
   13597              :         "Medium Temperature Refrigerated Cases Connected, # Low Temperature Refrigerated Cases Connected, # Medium "
   13598              :         "Temperature WalkInCoolers Connected, # Low Temperature WalkInCoolers Connected, # High Pressure Compressors "
   13599              :         "Connected, # Low Pressure Compressors Connected, Minimum Condensing Temperature (C)");
   13600              :     static constexpr std::string_view Format_123("!  <Secondary Load>, Secondary System Served Name, Secondary Number");
   13601              :     static constexpr std::string_view Format_126(
   13602              :         "!  <Refrigeration Mechanical Subcooler>, Subcooler Number, Subcooler Name, Name of System Providing "
   13603              :         "Cooling, Design Outlet Temperature (C)");
   13604              :     static constexpr std::string_view Format_127("!  <Refrigeration Liquid Suction Subcooler>, Subcooler Number, Subcooler Name, Design Subcooling "
   13605              :                                                  "(DeltaC),Design liquid inlet temperature (C), Design vapor inlet temperature (C)");
   13606              :     static constexpr std::string_view Format_128("!  <Cascade Load>, System Name Connected, Condenser Number, Condenser Name");
   13607              :     static constexpr std::string_view Format_129(
   13608              :         "!  <Refrigeration Condenser:Air-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   13609              :         "(C),Rated Capacity (W), Rated Fan Power (W)");
   13610              :     static constexpr std::string_view Format_130(
   13611              :         "!  <Refrigeration Condenser:Water-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   13612              :         "(C),Rated Capacity (W), Rated Water Inlet Temperature (C), Rated Water Flow Rate (m3/s)");
   13613              :     static constexpr std::string_view Format_131(
   13614              :         "!  <Refrigeration Condenser:Evaporative-Cooled>,Condenser Number,Condenser Name,Rated Capacity (W), Rated Fan Power (W)");
   13615              :     static constexpr std::string_view Format_132(
   13616              :         "!  <Refrigeration Condenser:Cascade>, Condenser Number, Condenser Name, Condensing Temperature Control "
   13617              :         "Type, Rated Condensing Temperature (C), Capacity (W), Approach Temperature Difference (DeltaC)");
   13618              :     static constexpr std::string_view Format_133(
   13619              :         "! <Secondary Refrigeration System: Fluid Always Liquid>, Secondary Number, Secondary Name, # Refrigerated "
   13620              :         "Cases Connected, # WalkIn Coolers Connected, Fluid Name, Capacity (W),Evap Temperature in Secondary "
   13621              :         "Evaporator (C), Approach Temperature Difference (DeltaC), Temperature Range (DeltaC), TotalPumpPower (W)");
   13622              :     static constexpr std::string_view Format_134(
   13623              :         "!      <Walk-In Surfaces Facing Zone>, ZoneName, Wall/Ceiling Area (m2), UValue (W/m2-C), AreaStockDoors "
   13624              :         "(m2), HeightStockDoors, UValueStockDoors (W/m2-C), AreaGlassDoors (m2), HeightGlassDoors (m),  "
   13625              :         "UValueGlassDoors (W/m2-C)");
   13626              :     static constexpr std::string_view Format_141("!  <Mechanical Subcooler Load>, Subcooler Number, Subcooler Name");
   13627              :     static constexpr std::string_view Format_142("! <#Secondary Refrigeration Systems>,Number of Secondary Refrigeration Systems");
   13628              :     static constexpr std::string_view Format_146(
   13629              :         "! <Secondary Refrigeration System: Liquid Overfeed>, Secondary Number, Secondary Name, # Refrigerated Cases "
   13630              :         "Connected, # WalkIn Coolers Connected, #Air Coils Connected Fluid Name, Capacity (W),Evap Temperature in "
   13631              :         "Secondary Evaporator (C), Approach Temperature Difference (DeltaC), Circulating Rate, TotalPumpPower (W)");
   13632              :     static constexpr std::string_view Format_148("! <#ZoneHVAC/Refrigeration Air Chiller Sets>,Number of ZoneHVAC/Refrigeration Air Chiller Sets");
   13633              :     static constexpr std::string_view Format_149(
   13634              :         "! <ZoneHVAC/Refrigeration Air Chiller Set>,Chiller Set Name, # Air Chillers Connected, Zone Location");
   13635              :     static constexpr std::string_view Format_151(
   13636              :         "!  <Refrigeration Air Chiller>,Refrigeration Chiller Number, Refrigeration Chiller Name,Zone Name,Zone "
   13637              :         "Node #,Zone Node Name,Sensible Capacity (W/C),Sensible Capacity (W),Evaporating Temperature (C),DT1 (C),Fan "
   13638              :         "Power (W),Heater (W),Defrost (W), Air Flow Rate (m3/s)");
   13639              :     static constexpr std::string_view Format_152("!  <Air Chiller Load>, Air Chiller Name, Air Chiller Number, Zone Name,");
   13640              :     static constexpr std::string_view Format_160(
   13641              :         "!  <Refrigeration GasCooler:Air-Cooled>,Gas Cooler Number, Gas Cooler Name, Rated Outlet Pressure "
   13642              :         "(Pa),Rated Outlet Temperature (C), Rated Approach Temperature (C), Rated Capacity (W), Rated Fan Power (W)");
   13643              : 
   13644              :     // write all headers applicable to this simulation
   13645          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   13646            5 :         print(state.files.eio, "{}\n", Format_109); // Intro to refrigeration case racks
   13647            5 :         print(state.files.eio, "{}\n", Format_104); // Refrigeration Rack header
   13648              :     }                                               //(NumRefrigeratedRacks > 0)
   13649          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   13650            0 :         print(state.files.eio, "{}\n", Format_117); // Intro to detailed systems
   13651            0 :         print(state.files.eio, "{}\n", Format_118); // Detailed system header
   13652            0 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   13653              :     }                                               //(NumRefrigSystems > 0)
   13654          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   13655            0 :         print(state.files.eio, "{}\n", Format_142); // Intro to Secondary systems
   13656            0 :         int CountSecPhase = 0;
   13657            0 :         int CountSecBrine = 0;
   13658            0 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   13659            0 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::AlwaysLiquid) && (CountSecBrine == 0)) {
   13660            0 :                 print(state.files.eio, "{}\n", Format_133); // Secondary system header for brine type systems
   13661            0 :                 ++CountSecBrine;
   13662              :             }
   13663            0 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::PhaseChange) && (CountSecPhase == 0)) {
   13664            0 :                 print(state.files.eio, "{}\n", Format_146); // Secondary system header for liquid overfeed/phase change systems
   13665            0 :                 ++CountSecPhase;
   13666              :             }
   13667              :         }
   13668            0 :         print(state.files.eio, "{}\n", Format_123); //  Secondary system load header
   13669              :     }                                               //(NumSimulationSecondarySystems > 0)
   13670          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   13671            0 :         print(state.files.eio, "{}\n", Format_148); // Intro to Chiller set
   13672            0 :         print(state.files.eio, "{}\n", Format_149); // Chiller set header
   13673            0 :         print(state.files.eio, "{}\n", Format_151); // Intro to Air Chiller
   13674            0 :         print(state.files.eio, "{}\n", Format_152); // Air chiller header
   13675              :     }                                               //(NumRefrigSystems > 0)
   13676          150 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   13677            3 :         print(state.files.eio, "{}\n", Format_105); //  Case header
   13678              :     }                                               //(NumSimulationCases > 0)
   13679          150 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   13680            3 :         print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   13681            3 :         print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   13682              :     }                                               //(NumSimulationWalkIns > 0)
   13683          150 :     if (state.dataRefrigCase->NumSimulationCondAir > 0) {
   13684            0 :         print(state.files.eio, "{}\n", Format_129); //  Condenser, Air-Cooled header
   13685              :     }                                               //(NumSimulationCondAir > 0)
   13686          150 :     if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
   13687            0 :         print(state.files.eio, "{}\n", Format_131); //  Condenser, Evaporative-Cooled header
   13688              :     }                                               //(NumSimulationCondEvap > 0)
   13689          150 :     if (state.dataRefrigCase->NumSimulationCondWater > 0) {
   13690            0 :         print(state.files.eio, "{}\n", Format_130); //  Condenser, Water-Cooled header
   13691              :     }                                               //(NumSimulationCondWater > 0)
   13692          150 :     if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
   13693            0 :         print(state.files.eio, "{}\n", Format_132); //  Condenser, Cascade header
   13694            0 :         print(state.files.eio, "{}\n", Format_128); //  Cascade Load header
   13695              :     }                                               //(NumSimulationCascadeCondensers > 0)
   13696          150 :     if (state.dataRefrigCase->NumSimulationMechSubcoolers > 0) {
   13697            0 :         print(state.files.eio, "{}\n", Format_141); //  Mech subcooler loads served header
   13698            0 :         print(state.files.eio, "{}\n", Format_126); //  Mechanical Subcooler header
   13699              :     }                                               //(NumSimulationMechSubcoolers > 0)
   13700          150 :     if ((state.dataRefrigCase->NumSimulationSubcoolers - state.dataRefrigCase->NumSimulationMechSubcoolers) > 0) {
   13701            0 :         print(state.files.eio, "{}\n", Format_127); //  LSHX Subcooler header
   13702              :     }                                               //((NumSimulationSubcoolers - NumSimulationMechSubcoolers) > 0)
   13703              : 
   13704          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   13705            0 :         print(state.files.eio, "{}\n", Format_120); // Intro to detailed transcritical refrigeration system
   13706            0 :         print(state.files.eio, "{}\n", Format_121); // Detailed system header
   13707            0 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   13708            0 :             print(state.files.eio, "{}\n", Format_105); //  Case header
   13709              :         }                                               //(NumSimulationCases > 0)
   13710            0 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   13711            0 :             print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   13712            0 :             print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   13713              :         }                                               //(NumSimulationWalkIns > 0)
   13714            0 :         print(state.files.eio, "{}\n", Format_108);     // Compressor header (Always have compressor if have detailed system)
   13715            0 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   13716            0 :             print(state.files.eio, "{}\n", Format_160); //  Gas Cooler, Air-Cooled header
   13717              :         }                                               //(NumSimulationGasCooler > 0)
   13718              :     }                                                   //(NumTransRefrigSystems > 0)
   13719              : 
   13720          150 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   13721            5 :         print(state.files.eio, "#Refrigeration Compressor Racks, {}\n", state.dataRefrigCase->NumRefrigeratedRacks);
   13722           10 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   13723            5 :             if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Outdoors) {
   13724            1 :                 ChrOut = "Outdoors";
   13725              :             } else {
   13726            4 :                 ChrOut = "Zone";
   13727              :             }
   13728            5 :             switch (RefrigRack(RackNum).CondenserType) {
   13729            5 :             case DataHeatBalance::RefrigCondenserType::Air: {
   13730            5 :                 ChrOut2 = "Air-Cooled";
   13731            5 :             } break;
   13732            0 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   13733            0 :                 ChrOut2 = "Evap-Cooled";
   13734            0 :             } break;
   13735            0 :             case DataHeatBalance::RefrigCondenserType::Water: {
   13736            0 :                 ChrOut2 = "Water-Cooled";
   13737            0 :             } break;
   13738            0 :             default:
   13739            0 :                 break;
   13740              :             }
   13741            5 :             print(state.files.eio,
   13742              :                   " Refrigeration Compressor Rack,{},{},{},{},{},{:.3R}\n",
   13743            5 :                   RefrigRack(RackNum).Name,
   13744            5 :                   RefrigRack(RackNum).NumCases,
   13745            5 :                   RefrigRack(RackNum).NumWalkIns,
   13746              :                   ChrOut,
   13747              :                   ChrOut2,
   13748            5 :                   RefrigRack(RackNum).RatedCOP);
   13749            8 :             for (int CaseNum = 1; CaseNum <= RefrigRack(RackNum).NumCases; ++CaseNum) {
   13750            3 :                 int CaseID = RefrigRack(RackNum).CaseNum(CaseNum);
   13751            3 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   13752            3 :                     print(state.files.eio,
   13753              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   13754              :                           CaseID,
   13755            3 :                           RefrigCase(CaseID).Name,
   13756            3 :                           RefrigCase(CaseID).ZoneName,
   13757            3 :                           RefrigCase(CaseID).ZoneNodeNum,
   13758            3 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   13759            3 :                           RefrigCase(CaseID).RateTotCapPerLength,
   13760            3 :                           RefrigCase(CaseID).RatedLHR,
   13761            3 :                           RefrigCase(CaseID).Temperature,
   13762            3 :                           RefrigCase(CaseID).Length,
   13763            3 :                           RefrigCase(CaseID).OperatingFanPower,
   13764            3 :                           RefrigCase(CaseID).LightingPower,
   13765            3 :                           RefrigCase(CaseID).AntiSweatPower,
   13766            3 :                           RefrigCase(CaseID).DefrostPower); // Installed lighting power, may not be rated power
   13767              :                 }
   13768              :             } // numcases
   13769              : 
   13770            8 :             for (int WalkInNum = 1; WalkInNum <= RefrigRack(RackNum).NumWalkIns; ++WalkInNum) {
   13771            3 :                 int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInNum);
   13772            3 :                 print(state.files.eio,
   13773              :                       "   Refrigeration Walk In Cooler,  {},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   13774              :                       WalkInID,
   13775            3 :                       WalkIn(WalkInID).Name,
   13776            3 :                       WalkIn(WalkInID).DesignRatedCap,
   13777            3 :                       WalkIn(WalkInID).Temperature,
   13778            3 :                       WalkIn(WalkInID).CoilFanPower,
   13779            3 :                       WalkIn(WalkInID).CircFanPower,
   13780            3 :                       WalkIn(WalkInID).ElecFanPower,
   13781            3 :                       WalkIn(WalkInID).DesignLighting,
   13782            3 :                       WalkIn(WalkInID).HeaterPower,
   13783            3 :                       WalkIn(WalkInID).DefrostCapacity,
   13784            3 :                       WalkIn(WalkInID).NumZones);
   13785            6 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   13786            3 :                     print(state.files.eio,
   13787              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   13788            3 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   13789            3 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   13790            3 :                           WalkIn(WalkInID).UValue(ZoneID),
   13791            3 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   13792            3 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   13793            3 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   13794            3 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   13795            3 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   13796            3 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   13797              :                 } // zones for walk ins on rack
   13798              :             }     // walk ins on rack
   13799              : 
   13800            5 :             for (int CoilNum = 1; CoilNum <= RefrigRack(RackNum).NumCoils; ++CoilNum) {
   13801            0 :                 int CoilID = RefrigRack(RackNum).CoilNum(CoilNum);
   13802            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   13803              :             } // numairchillers
   13804              :         }     // numracks
   13805              :     }         //(NumRefrigeratedRacks > 0)
   13806              : 
   13807          150 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   13808            0 :         print(state.files.eio, "#Detailed Refrigeration Systems,{}\n", state.dataRefrigCase->NumRefrigSystems);
   13809            0 :         for (int SystemNum = 1; SystemNum <= state.dataRefrigCase->NumRefrigSystems; ++SystemNum) {
   13810            0 :             print(state.files.eio,
   13811              :                   " Detailed Refrigeration System,{},{},{},{},{},{},{},{},{},{},{},{:.2R},{},{:.1R}\n",
   13812            0 :                   System(SystemNum).Name,
   13813            0 :                   System(SystemNum).RefrigerantName,
   13814            0 :                   System(SystemNum).NumCases,
   13815            0 :                   System(SystemNum).NumWalkIns,
   13816            0 :                   System(SystemNum).NumCoils,
   13817            0 :                   System(SystemNum).NumSecondarys,
   13818            0 :                   System(SystemNum).NumCascadeLoads,
   13819            0 :                   System(SystemNum).NumMechSCServed,
   13820            0 :                   System(SystemNum).NumCompressors + System(SystemNum).NumHiStageCompressors,
   13821            0 :                   System(SystemNum).NumStages,
   13822            0 :                   System(SystemNum).intercoolerType,
   13823            0 :                   System(SystemNum).IntercoolerEffectiveness,
   13824            0 :                   System(SystemNum).NumSubcoolers,
   13825            0 :                   System(SystemNum).TCondenseMin);
   13826              : 
   13827            0 :             for (int CaseNum = 1; CaseNum <= System(SystemNum).NumCases; ++CaseNum) {
   13828            0 :                 int CaseID = System(SystemNum).CaseNum(CaseNum);
   13829            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   13830            0 :                     print(state.files.eio,
   13831              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   13832              :                           CaseID,
   13833            0 :                           RefrigCase(CaseID).Name,
   13834            0 :                           RefrigCase(CaseID).ZoneName,
   13835            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   13836            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   13837            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   13838            0 :                           RefrigCase(CaseID).RatedLHR,
   13839            0 :                           RefrigCase(CaseID).Temperature,
   13840            0 :                           RefrigCase(CaseID).Length,
   13841            0 :                           RefrigCase(CaseID).OperatingFanPower,
   13842            0 :                           RefrigCase(CaseID).LightingPower,
   13843            0 :                           RefrigCase(CaseID).AntiSweatPower,
   13844            0 :                           RefrigCase(CaseID).DefrostPower);
   13845              :                 }
   13846              :             } // NumCases on system
   13847            0 :             for (int WalkInNum = 1; WalkInNum <= System(SystemNum).NumWalkIns; ++WalkInNum) {
   13848            0 :                 int WalkInID = System(SystemNum).WalkInNum(WalkInNum);
   13849            0 :                 print(state.files.eio,
   13850              :                       "   Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   13851              :                       WalkInID,
   13852            0 :                       WalkIn(WalkInID).Name,
   13853            0 :                       WalkIn(WalkInID).DesignRatedCap,
   13854            0 :                       WalkIn(WalkInID).Temperature,
   13855            0 :                       WalkIn(WalkInID).CoilFanPower,
   13856            0 :                       WalkIn(WalkInID).CircFanPower,
   13857            0 :                       WalkIn(WalkInID).DesignLighting,
   13858            0 :                       WalkIn(WalkInID).HeaterPower,
   13859            0 :                       WalkIn(WalkInID).DefrostCapacity,
   13860            0 :                       WalkIn(WalkInID).NumZones);
   13861            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   13862            0 :                     print(state.files.eio,
   13863              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   13864            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   13865            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   13866            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   13867            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   13868            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   13869            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   13870            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   13871            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   13872            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   13873              :                 } // Num zones for each walk in on system
   13874              :             }     // NumWalkIns on system
   13875              : 
   13876            0 :             for (int CoilNum = 1; CoilNum <= System(SystemNum).NumCoils; ++CoilNum) {
   13877            0 :                 int CoilID = System(SystemNum).CoilNum(CoilNum);
   13878            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   13879              :             } // numairchillers
   13880              : 
   13881            0 :             for (int CascadeLoadNum = 1; CascadeLoadNum <= System(SystemNum).NumCascadeLoads; ++CascadeLoadNum) {
   13882            0 :                 int CascadeLoadID = System(SystemNum).CascadeLoadNum(CascadeLoadNum);
   13883            0 :                 print(state.files.eio,
   13884              :                       "   Cascade Load,{},{},{}\n",
   13885            0 :                       System(Condenser(CascadeLoadID).CascadeSysID).Name,
   13886              :                       CascadeLoadID,
   13887            0 :                       Condenser(CascadeLoadID).Name);
   13888              :             } // cascade load on detailed system
   13889              : 
   13890            0 :             for (int SecondaryNum = 1; SecondaryNum <= System(SystemNum).NumSecondarys; ++SecondaryNum) {
   13891            0 :                 int SecondaryID = System(SystemNum).SecondaryNum(SecondaryNum);
   13892            0 :                 print(state.files.eio, "   Secondary Load,{},{}\n", Secondary(SecondaryID).Name, SecondaryID);
   13893              :             } // secondary load on detailed system
   13894              : 
   13895            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
   13896            0 :                 if (Subcooler(SubcoolerNum).MechSourceSysID != SystemNum) continue;
   13897            0 :                 print(state.files.eio, "   Mechanical Subcooler Load, {},{}\n", SubcoolerNum, Subcooler(SubcoolerNum).Name);
   13898              :             } // Num sim subcoolers, looking only for NumSMech Subcoolers served by this system
   13899              : 
   13900            0 :             if (System(SystemNum).NumStages == 1) { // Single-stage compression system
   13901            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   13902            0 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   13903            0 :                     print(state.files.eio, "   Refrigeration Compressor,{},{},{:.0R}\n", CompID, Compressor(CompID).Name, Compressor(CompID).NomCap);
   13904              :                 }                                          // NumCompressors
   13905            0 :             } else if (System(SystemNum).NumStages == 2) { // Two-stage compression system
   13906              :                 // Low-stage compressors
   13907            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   13908            0 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   13909            0 :                     print(state.files.eio,
   13910              :                           "   Refrigeration Low-Stage Compressor,{},{},{:.0R}\n",
   13911              :                           CompID,
   13912            0 :                           Compressor(CompID).Name,
   13913            0 :                           Compressor(CompID).NomCap);
   13914              :                 } // NumCompressors
   13915              :                 // High-stage compressors
   13916            0 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumHiStageCompressors; ++CompressorNum) {
   13917            0 :                     int CompID = System(SystemNum).HiStageCompressorNum(CompressorNum);
   13918            0 :                     print(state.files.eio,
   13919              :                           "   Refrigeration High-Stage Compressor,{},{},{:.0R}\n",
   13920              :                           CompID,
   13921            0 :                           Compressor(CompID).Name,
   13922            0 :                           Compressor(CompID).NomCap);
   13923              :                 } // NumHiStageCompressors
   13924              :             }     // NumStages
   13925              : 
   13926            0 :             int CondID = System(SystemNum).CondenserNum(1);
   13927            0 :             switch (Condenser(CondID).CondenserType) {
   13928            0 :             case DataHeatBalance::RefrigCondenserType::Air: {
   13929            0 :                 print(state.files.eio,
   13930              :                       "   Refrigeration Condenser:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R}\n",
   13931              :                       CondID,
   13932            0 :                       Condenser(CondID).Name,
   13933            0 :                       Condenser(CondID).RatedTCondense,
   13934            0 :                       Condenser(CondID).RatedCapacity,
   13935            0 :                       Condenser(CondID).RatedFanPower);
   13936            0 :             } break;
   13937            0 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   13938            0 :                 print(state.files.eio,
   13939              :                       "   Refrigeration Condenser:Evaporative-Cooled,{},{},{:.1R},{:.1R}\n",
   13940              :                       CondID,
   13941            0 :                       Condenser(CondID).Name,
   13942            0 :                       Condenser(CondID).RatedCapacity,
   13943            0 :                       Condenser(CondID).RatedFanPower);
   13944            0 :             } break;
   13945            0 :             case DataHeatBalance::RefrigCondenserType::Water: {
   13946            0 :                 print(state.files.eio,
   13947              :                       "   Refrigeration Condenser:Water-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   13948              :                       CondID,
   13949            0 :                       Condenser(CondID).Name,
   13950            0 :                       Condenser(CondID).RatedTCondense,
   13951            0 :                       Condenser(CondID).RatedCapacity,
   13952            0 :                       Condenser(CondID).InletTemp,
   13953            0 :                       Condenser(CondID).DesVolFlowRate);
   13954            0 :             } break;
   13955            0 :             case DataHeatBalance::RefrigCondenserType::Cascade: {
   13956              : 
   13957            0 :                 switch (Condenser(CondID).CascadeTempControl) {
   13958            0 :                 case CascadeCndsrTempCtrlType::TempSet: {
   13959            0 :                     ChrOut = "Fixed";
   13960            0 :                 } break;
   13961            0 :                 case CascadeCndsrTempCtrlType::TempFloat: {
   13962            0 :                     ChrOut = "Floating";
   13963            0 :                 } break;
   13964            0 :                 default:
   13965            0 :                     break;
   13966              :                 } // cascade temperature control
   13967            0 :                 print(state.files.eio,
   13968              :                       "   Refrigeration Condenser:Cascade,{},{},{},{:.1R},{:.1R},{:.1R}\n",
   13969              :                       CondID,
   13970            0 :                       Condenser(CondID).Name,
   13971              :                       ChrOut,
   13972            0 :                       Condenser(CondID).RatedTCondense,
   13973            0 :                       Condenser(CondID).RatedCapacity,
   13974            0 :                       Condenser(CondID).RatedApproachT);
   13975            0 :             } break;
   13976            0 :             default:
   13977            0 :                 break;
   13978              :             } // condenser type
   13979              : 
   13980            0 :             for (int SubcoolerNum = 1; SubcoolerNum <= System(SystemNum).NumSubcoolers; ++SubcoolerNum) {
   13981            0 :                 int SubcoolerID = System(SystemNum).SubcoolerNum(SubcoolerNum);
   13982            0 :                 switch (Subcooler(SubcoolerID).subcoolerType) {
   13983            0 :                 case SubcoolerType::LiquidSuction: {
   13984            0 :                     print(state.files.eio,
   13985              :                           "   Refrigeration Liquid Suction Subcooler,{},{},{:.1R},{:.1R},{:.1R}\n",
   13986              :                           SubcoolerID,
   13987            0 :                           Subcooler(SubcoolerID).Name,
   13988            0 :                           Subcooler(SubcoolerID).LiqSuctDesignDelT,
   13989            0 :                           Subcooler(SubcoolerID).LiqSuctDesignTliqIn,
   13990            0 :                           Subcooler(SubcoolerID).LiqSuctDesignTvapIn);
   13991            0 :                 } break;
   13992            0 :                 case SubcoolerType::Mechanical: {
   13993            0 :                     print(state.files.eio,
   13994              :                           "   Refrigeration Mechanical Subcooler,{},{},{},{:.1R}\n",
   13995              :                           SubcoolerID,
   13996            0 :                           Subcooler(SubcoolerID).Name,
   13997            0 :                           Subcooler(SubcoolerID).MechSourceSys,
   13998            0 :                           Subcooler(SubcoolerID).MechControlTliqOut);
   13999            0 :                 } break;
   14000            0 :                 default:
   14001            0 :                     break;
   14002              :                 }
   14003              :             } // NumSubcoolers
   14004              : 
   14005              :         } // NumRefrigSystems
   14006              :     }     //(NumRefrigSystems > 0)
   14007              : 
   14008          150 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14009            0 :         print(state.files.eio, "#Detailed Transcritical Refrigeration Systems,{}\n", state.dataRefrigCase->NumTransRefrigSystems);
   14010            0 :         for (int TransSystemNum = 1; TransSystemNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransSystemNum) {
   14011            0 :             print(state.files.eio,
   14012              :                   " Detailed Transcritical Refrigeration System,{},{},{},{},{},{},{},{},{:.1R}\n",
   14013            0 :                   TransSystem(TransSystemNum).Name,
   14014            0 :                   TransSystem(TransSystemNum).RefrigerantName,
   14015            0 :                   TransSystem(TransSystemNum).NumCasesMT,
   14016            0 :                   TransSystem(TransSystemNum).NumCasesLT,
   14017            0 :                   TransSystem(TransSystemNum).NumWalkInsMT,
   14018            0 :                   TransSystem(TransSystemNum).NumWalkInsLT,
   14019            0 :                   TransSystem(TransSystemNum).NumCompressorsHP,
   14020            0 :                   TransSystem(TransSystemNum).NumCompressorsLP,
   14021            0 :                   GasCooler(TransSystem(TransSystemNum).GasCoolerNum(1)).MinCondTemp);
   14022              : 
   14023            0 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesMT; ++CaseNum) {
   14024            0 :                 int CaseID = TransSystem(TransSystemNum).CaseNumMT(CaseNum);
   14025            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14026            0 :                     print(state.files.eio,
   14027              :                           "   Medium Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14028              :                           CaseID,
   14029            0 :                           RefrigCase(CaseID).Name,
   14030            0 :                           RefrigCase(CaseID).ZoneName,
   14031            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14032            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14033            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14034            0 :                           RefrigCase(CaseID).RatedLHR,
   14035            0 :                           RefrigCase(CaseID).Temperature,
   14036            0 :                           RefrigCase(CaseID).Length,
   14037            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14038            0 :                           RefrigCase(CaseID).LightingPower,
   14039            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14040            0 :                           RefrigCase(CaseID).DefrostPower);
   14041              :                 }
   14042              :             } // NumCasesMT on system
   14043            0 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesLT; ++CaseNum) {
   14044            0 :                 int CaseID = TransSystem(TransSystemNum).CaseNumLT(CaseNum);
   14045            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14046            0 :                     print(state.files.eio,
   14047              :                           "   Low Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14048              :                           CaseID,
   14049            0 :                           RefrigCase(CaseID).Name,
   14050            0 :                           RefrigCase(CaseID).ZoneName,
   14051            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14052            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14053            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14054            0 :                           RefrigCase(CaseID).RatedLHR,
   14055            0 :                           RefrigCase(CaseID).Temperature,
   14056            0 :                           RefrigCase(CaseID).Length,
   14057            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14058            0 :                           RefrigCase(CaseID).LightingPower,
   14059            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14060            0 :                           RefrigCase(CaseID).DefrostPower);
   14061              :                 }
   14062              :             } // NumCasesLT on system
   14063            0 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsMT; ++WalkInNum) {
   14064            0 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumMT(WalkInNum);
   14065            0 :                 print(state.files.eio,
   14066              :                       "   Medium Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14067              :                       WalkInID,
   14068            0 :                       WalkIn(WalkInID).Name,
   14069            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14070            0 :                       WalkIn(WalkInID).Temperature,
   14071            0 :                       WalkIn(WalkInID).CoilFanPower,
   14072            0 :                       WalkIn(WalkInID).CircFanPower,
   14073            0 :                       WalkIn(WalkInID).DesignLighting,
   14074            0 :                       WalkIn(WalkInID).HeaterPower,
   14075            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14076            0 :                       WalkIn(WalkInID).NumZones);
   14077            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14078            0 :                     print(state.files.eio,
   14079              :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14080            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14081            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14082            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14083            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14084            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14085            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14086            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14087            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14088            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14089              :                 } // Num zones for each walk in on system
   14090              :             }     // NumWalkInsMT on system
   14091            0 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsLT; ++WalkInNum) {
   14092            0 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumLT(WalkInNum);
   14093            0 :                 print(state.files.eio,
   14094              :                       "   Low Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14095              :                       WalkInID,
   14096            0 :                       WalkIn(WalkInID).Name,
   14097            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14098            0 :                       WalkIn(WalkInID).Temperature,
   14099            0 :                       WalkIn(WalkInID).CoilFanPower,
   14100            0 :                       WalkIn(WalkInID).CircFanPower,
   14101            0 :                       WalkIn(WalkInID).DesignLighting,
   14102            0 :                       WalkIn(WalkInID).HeaterPower,
   14103            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14104            0 :                       WalkIn(WalkInID).NumZones);
   14105            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14106            0 :                     print(state.files.eio,
   14107              :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14108            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14109            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14110            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14111            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14112            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14113            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14114            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14115            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14116            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14117              :                 } // Num zones for each walk in on system
   14118              :             }     // NumWalkInsLT on system
   14119              : 
   14120            0 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsHP; ++CompressorNum) {
   14121            0 :                 int CompID = TransSystem(TransSystemNum).CompressorNumHP(CompressorNum);
   14122            0 :                 print(state.files.eio,
   14123              :                       "   High Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14124              :                       CompID,
   14125            0 :                       Compressor(CompID).Name,
   14126            0 :                       Compressor(CompID).NomCap);
   14127              :             } // NumCompressorsHP
   14128            0 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsLP; ++CompressorNum) {
   14129            0 :                 int CompID = TransSystem(TransSystemNum).CompressorNumLP(CompressorNum);
   14130            0 :                 print(state.files.eio,
   14131              :                       "   Low Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14132              :                       CompID,
   14133            0 :                       Compressor(CompID).Name,
   14134            0 :                       Compressor(CompID).NomCap);
   14135              :             } // NumCompressorsLP
   14136              : 
   14137            0 :             if (TransSystem(TransSystemNum).NumGasCoolers >= 1) {
   14138            0 :                 int GasCoolerID = TransSystem(TransSystemNum).GasCoolerNum(1);
   14139            0 :                 print(state.files.eio,
   14140              :                       "   Refrigeration GasCooler:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14141              :                       GasCoolerID,
   14142            0 :                       GasCooler(GasCoolerID).Name,
   14143            0 :                       GasCooler(GasCoolerID).RatedOutletP,
   14144            0 :                       GasCooler(GasCoolerID).RatedOutletT,
   14145            0 :                       GasCooler(GasCoolerID).RatedApproachT,
   14146            0 :                       GasCooler(GasCoolerID).RatedCapacity,
   14147            0 :                       GasCooler(GasCoolerID).RatedFanPower);
   14148              :             } // System(SystemNum)%NumGasCoolers >= 1
   14149              : 
   14150              :         } // NumTransRefrigSystems
   14151              :     }     //(NumTransRefrigSystems > 0)
   14152              : 
   14153          150 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14154            0 :         print(state.files.eio, "#Secondary Refrigeration Systems,{}\n", state.dataRefrigCase->NumSimulationSecondarySystems);
   14155            0 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14156            0 :             switch (Secondary(SecondaryID).FluidType) {
   14157            0 :             case SecFluidType::AlwaysLiquid: {
   14158            0 :                 print(state.files.eio,
   14159              :                       "Secondary Refrigeration System: Fluid Always Liquid,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14160              :                       SecondaryID,
   14161            0 :                       Secondary(SecondaryID).Name,
   14162            0 :                       Secondary(SecondaryID).NumCases,
   14163            0 :                       Secondary(SecondaryID).NumWalkIns,
   14164            0 :                       Secondary(SecondaryID).FluidName,
   14165            0 :                       Secondary(SecondaryID).CoolingLoadRated,
   14166            0 :                       Secondary(SecondaryID).TEvapDesign,
   14167            0 :                       Secondary(SecondaryID).TApproachDifRated,
   14168            0 :                       Secondary(SecondaryID).TRangeDifRated,
   14169            0 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14170            0 :             } break;
   14171            0 :             case SecFluidType::PhaseChange: {
   14172            0 :                 print(state.files.eio,
   14173              :                       "Secondary Refrigeration System: Liquid Overfeed,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14174              :                       SecondaryID,
   14175            0 :                       Secondary(SecondaryID).Name,
   14176            0 :                       Secondary(SecondaryID).NumCases,
   14177            0 :                       Secondary(SecondaryID).NumWalkIns,
   14178            0 :                       Secondary(SecondaryID).FluidName,
   14179            0 :                       Secondary(SecondaryID).CoolingLoadRated,
   14180            0 :                       Secondary(SecondaryID).TEvapDesign,
   14181            0 :                       Secondary(SecondaryID).TApproachDifRated,
   14182            0 :                       Secondary(SecondaryID).CircRate,
   14183            0 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14184            0 :             } break;
   14185            0 :             default:
   14186            0 :                 break;
   14187              :             }
   14188            0 :             for (int CaseNum = 1; CaseNum <= Secondary(SecondaryID).NumCases; ++CaseNum) {
   14189            0 :                 int CaseID = Secondary(SecondaryID).CaseNum(CaseNum);
   14190            0 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14191            0 :                     print(state.files.eio,
   14192              :                           "  Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14193              :                           CaseID,
   14194            0 :                           RefrigCase(CaseID).Name,
   14195            0 :                           RefrigCase(CaseID).ZoneName,
   14196            0 :                           RefrigCase(CaseID).ZoneNodeNum,
   14197            0 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14198            0 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14199            0 :                           RefrigCase(CaseID).RatedLHR,
   14200            0 :                           RefrigCase(CaseID).Temperature,
   14201            0 :                           RefrigCase(CaseID).Length,
   14202            0 :                           RefrigCase(CaseID).OperatingFanPower,
   14203            0 :                           RefrigCase(CaseID).LightingPower,
   14204            0 :                           RefrigCase(CaseID).AntiSweatPower,
   14205            0 :                           RefrigCase(CaseID).DefrostPower);
   14206              :                 }
   14207              :             } // NumCases on secondary on secondary system
   14208              : 
   14209            0 :             for (int WalkInNum = 1; WalkInNum <= Secondary(SecondaryID).NumWalkIns; ++WalkInNum) {
   14210            0 :                 int WalkInID = Secondary(SecondaryID).WalkInNum(WalkInNum);
   14211            0 :                 print(state.files.eio,
   14212              :                       "  Walk In,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14213              :                       WalkInID,
   14214            0 :                       WalkIn(WalkInID).Name,
   14215            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14216            0 :                       WalkIn(WalkInID).Temperature,
   14217            0 :                       WalkIn(WalkInID).CoilFanPower,
   14218            0 :                       WalkIn(WalkInID).CircFanPower,
   14219            0 :                       WalkIn(WalkInID).DesignLighting,
   14220            0 :                       WalkIn(WalkInID).HeaterPower,
   14221            0 :                       WalkIn(WalkInID).DefrostCapacity);
   14222            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14223            0 :                     print(state.files.eio,
   14224              :                           "    Walk In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14225            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14226            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14227            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14228            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14229            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14230            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14231            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14232            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14233            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14234              :                 } // zones for walk ins on secondary
   14235              :             }     // walk ins on secondary
   14236              : 
   14237            0 :             for (int CoilNum = 1; CoilNum <= Secondary(SecondaryID).NumCoils; ++CoilNum) {
   14238            0 :                 int CoilID = Secondary(SecondaryID).CoilNum(CoilNum);
   14239            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14240              :             } // numairchillers
   14241              :         }     // secondary
   14242              :     }         // numsimulationsecondarys
   14243              : 
   14244          150 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14245            0 :         print(state.files.eio, "#ZoneHVAC/Refrigeration Air Chiller Sets,{}\n", state.dataRefrigCase->NumRefrigChillerSets);
   14246            0 :         for (int ChillerSetNum = 1; ChillerSetNum <= state.dataRefrigCase->NumRefrigChillerSets; ++ChillerSetNum) {
   14247            0 :             print(state.files.eio,
   14248              :                   "ZoneHVAC/Refrigeration Air Chiller Set,{},{},{},{}\n",
   14249            0 :                   AirChillerSet(ChillerSetNum).Name,
   14250              :                   ChillerSetNum,
   14251            0 :                   AirChillerSet(ChillerSetNum).NumCoils,
   14252            0 :                   AirChillerSet(ChillerSetNum).ZoneName);
   14253              : 
   14254            0 :             for (int CoilNum = 1; CoilNum <= AirChillerSet(ChillerSetNum).NumCoils; ++CoilNum) {
   14255            0 :                 int CoilID = AirChillerSet(ChillerSetNum).CoilNum(CoilNum);
   14256            0 :                 print(state.files.eio,
   14257              :                       "   Refrigeration Air Chiller,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14258              :                       CoilID,
   14259            0 :                       WarehouseCoil(CoilID).Name,
   14260            0 :                       WarehouseCoil(CoilID).ZoneName,
   14261            0 :                       WarehouseCoil(CoilID).ZoneNodeNum,
   14262            0 :                       state.dataLoopNodes->NodeID(WarehouseCoil(CoilID).ZoneNodeNum),
   14263            0 :                       WarehouseCoil(CoilID).UnitLoadFactorSens,
   14264            0 :                       WarehouseCoil(CoilID).RatedSensibleCap,
   14265            0 :                       WarehouseCoil(CoilID).TEvapDesign,
   14266            0 :                       WarehouseCoil(CoilID).RatedTemperatureDif,
   14267            0 :                       WarehouseCoil(CoilID).RatedFanPower,
   14268            0 :                       WarehouseCoil(CoilID).HeaterPower,
   14269            0 :                       WarehouseCoil(CoilID).DefrostCapacity,
   14270            0 :                       WarehouseCoil(CoilID).RatedAirVolumeFlow);
   14271              :             } // numairchillers
   14272              :         }     // DataHeatBalance::NumRefrigChillerSets
   14273              :     }         // DataHeatBalance::NumRefrigChillerSets
   14274          150 : }
   14275              : 
   14276            3 : void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to  Walk In
   14277              : {
   14278              : 
   14279              :     // SUBROUTINE INFORMATION:
   14280              :     //       AUTHOR         Therese Stovall, ORNL, May 2009
   14281              :     //       DATE WRITTEN   Oct/Nov 2004
   14282              :     //       MODIFIED       na
   14283              :     //       RE-ENGINEERED  na
   14284              : 
   14285              :     // PURPOSE OF THIS SUBROUTINE:
   14286              :     // To model Walk In Coolers.
   14287              : 
   14288              :     // METHODOLOGY EMPLOYED:
   14289              :     // Walk-in cooler performance is based on the ASHRAE load model, which includes
   14290              :     // infiltration through door openings and sensible loss through walls/ceilings identified
   14291              :     // by the user as sum of UA for each zone. A sub-floor heater is assumed to be sized so that
   14292              :     // the temperature of the slab beneath the floor insulation is the same as the ground
   14293              :     // temperature (to avoid ground freezing and heaving).
   14294              :     // All equipment loads (fan, light, heaters) are modeled as well.  Sensible and latent
   14295              :     // exchange with multiple adjoining zones is included. A master schedule is used for the Walk In operation and
   14296              :     // additional schedules control the lights, defrost, and heater operation.
   14297              : 
   14298              :     // The fan is assumed to be off for Hot-Gas, Hot-Brine, and Electric defrost. The user can choose
   14299              :     // to include the load due to bringing the coil mass up from the evaporating temperature to the melting temperature
   14300              :     //  if they choose.  Otherwise this factor is set to zero.
   14301              : 
   14302              :     // Unmet loads are accumulated to be met the following time step.  This usually occurs during defrost and
   14303              :     // restocking.
   14304              : 
   14305              :     // REFERENCES:
   14306              :     // ASHRAE 2006 Handbook, chapters 13 and 14.
   14307              :     // Gosney, W.B., Olama, G.A.-L., Heat and Enthalpy Gains through Cold Room Doorways,
   14308              :     //     Proceedings of the Institute of Refrigeration, vol. 72, pp 31-41, 1975
   14309              : 
   14310            3 :     Real64 constexpr DefaultWalkInDoorOpenFactor(0.05); // walk in door open factor (fraction time open)
   14311              : 
   14312              :     static constexpr std::string_view RoutineName("CalculateWalkIn");
   14313            3 :     Real64 CapApplied(0.0);          // Walk In total capacity at specific operating conditions
   14314            3 :     Real64 DefrostSchedule(0.0);     // WalkIn defrost schedule, between 0 and 1
   14315            3 :     Real64 DefrostEnergyNeeded(0.0); // Energy needed to melt all ice, used with temperature termination (J)
   14316            3 :     Real64 DensityFactorFm(0.0);     // called Fm in ASHRAE 2010 eq 13 page 24.5 for door infiltration
   14317            3 :     Real64 DensitySqRtFactor(0.0);   // from ASHRAE 2010 eq 12 page 24.4 for door infiltration
   14318              : 
   14319              :     // Current value of WalkIn operating (availability) schedule
   14320            3 :     Real64 WalkInSchedule = this->availSched->getCurrentVal();
   14321            3 :     if (WalkInSchedule <= 0) return;
   14322              :     // GET OTHER SCHEDULES
   14323            3 :     DefrostSchedule = this->defrostSched->getCurrentVal();
   14324            3 :     Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   14325              :     // next statement In case user doesn't understand concept of drip down schedule
   14326            3 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   14327              : 
   14328              :     // next four values optional, so set to default before checking for schedule
   14329            3 :     Real64 StockingLoad = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   14330            3 :     Real64 LightingSchedule = (this->lightingSched != nullptr) ? this->lightingSched->getCurrentVal() : 1.0;
   14331            3 :     Real64 HeaterSchedule = (this->heaterSched != nullptr) ? this->heaterSched->getCurrentVal() : 1.0;
   14332            3 :     Real64 CircFanSchedule = (this->circFanAvailSched != nullptr) ? this->circFanAvailSched->getCurrentVal() : 1.0;
   14333              : 
   14334              :     // Set local subroutine variables for convenience
   14335            3 :     Real64 TWalkIn = this->Temperature; // WalkIn operating temperature (C)
   14336              : 
   14337              :     // Enthalpy of air corresponding to walk in temperature and 90% assumed RH (J/kg)
   14338            3 :     Real64 EnthalpyAirWalkIn = Psychrometrics::PsyHFnTdbRhPb(state, TWalkIn, 0.9, state.dataEnvrn->OutBaroPress); // assume 90%RH in cooler
   14339              : 
   14340              :     // corresponds to walk in temp and 90% assumed RH(kg water/kg dry air)
   14341            3 :     Real64 HumRatioAirWalkIn = Psychrometrics::PsyWFnTdbH(state, TWalkIn, EnthalpyAirWalkIn);
   14342            3 :     Real64 DensityAirWalkIn = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TWalkIn, HumRatioAirWalkIn);
   14343            3 :     Real64 Conv = state.dataEnvrn->Latitude * 2.0 * Constant::Pi / 360.0; // Convert DataEnvironment::Latitude to radians
   14344            3 :     Real64 Gravity = 9.780373 * (1.0 + 0.0052891 * pow_2(std::sin(Conv)) - 0.0000059 * pow_2(std::sin(2.0 * Conv)));
   14345              : 
   14346              :     // CALCULATE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   14347              :     // set to zero before summing over zones
   14348            3 :     Real64 SensibleLoadTotal(0.0); // Total sensible load on WalkIn over all zones (W)
   14349            3 :     Real64 LatentLoadTotal(0.0);   // total latent load on WalkIn over all zones (W)
   14350            3 :     Real64 ZoneLatentLoad(0.0);    // Latent WalkIn credit delivered to zone (W)
   14351              : 
   14352            3 :     this->SensZoneCreditRate = 0.0;
   14353            3 :     this->SensZoneCreditCoolRate = 0.0;
   14354            3 :     this->SensZoneCreditCool = 0.0;
   14355            3 :     this->SensZoneCreditHeatRate = 0.0;
   14356            3 :     this->SensZoneCreditHeat = 0.0;
   14357            3 :     this->LatZoneCreditRate = 0.0;
   14358              : 
   14359              :     // Start zone loop:
   14360            6 :     for (int ZoneID = 1; ZoneID <= this->NumZones; ++ZoneID) {
   14361            3 :         int zoneNum = this->ZoneNum(ZoneID);
   14362            3 :         int zoneNodeNum = this->ZoneNodeNum(ZoneID);
   14363            3 :         Real64 ZoneDryBulb = state.dataLoopNodes->Node(zoneNodeNum).Temp; // Dry Bulb Temperature of adjacent zone
   14364            3 :         Real64 WalkInLatLoad = -ZoneLatentLoad;                           // Walk in cooler latent load facing particular zone (W)
   14365            3 :         Real64 DelTemp = ZoneDryBulb - TWalkIn;                           // Difference between zone and walk in temperatures (C)
   14366            3 :         Real64 StockDoorArea = this->AreaStockDr(ZoneID);
   14367            3 :         Real64 GlassDoorArea = this->AreaGlassDr(ZoneID);                          // facing a particular zone (m2)
   14368            3 :         Real64 UAOtherSurfaces = this->SurfaceArea(ZoneID) * this->UValue(ZoneID); // UA for non-door surfaces facing a certain zone (W/C)
   14369            3 :         Real64 ZInfilSensLoad(0.0);                                                // Sensible load due to infiltration in one zone
   14370            3 :         Real64 ZdoorSensLoad(0.0);                                                 // Sensible load due to UA delta T through closed door in one zone
   14371              : 
   14372              :         // Derate compared to fully developed flow through 100% open door
   14373            3 :         Real64 DoorFlowFactor = 0.8;               // see ASHRAE Refrigeration, p13.5, 2006
   14374            3 :         if (DelTemp <= 11.0) DoorFlowFactor = 1.1; // from ASHRAE Refrigeration Loads
   14375              : 
   14376              :         // Get infiltration loads if either type of door is present in this zone
   14377            3 :         if (StockDoorArea > 0.0 || GlassDoorArea > 0.0) {
   14378              :             // Zone relative humidity fraction (decimal)
   14379           12 :             Real64 ZoneRHFrac = Psychrometrics::PsyRhFnTdbWPb(state,
   14380            3 :                                                               state.dataLoopNodes->Node(zoneNodeNum).Temp,
   14381            3 :                                                               state.dataLoopNodes->Node(zoneNodeNum).HumRat,
   14382            3 :                                                               state.dataEnvrn->OutBaroPress,
   14383              :                                                               RoutineName);
   14384              :             // Enthalpy of the air in a particular zone (J/kg)
   14385            3 :             Real64 EnthalpyZoneAir = Psychrometrics::PsyHFnTdbRhPb(state, ZoneDryBulb, ZoneRHFrac, state.dataEnvrn->OutBaroPress, RoutineName);
   14386            3 :             Real64 HumRatioZoneAir = Psychrometrics::PsyWFnTdbH(state, ZoneDryBulb, EnthalpyZoneAir, RoutineName);
   14387              :             Real64 DensityZoneAir =
   14388            3 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneDryBulb, HumRatioZoneAir, RoutineName);
   14389            3 :             if (DensityZoneAir < DensityAirWalkIn) { // usual case when walk in is colder than zone
   14390            0 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityZoneAir / DensityAirWalkIn);
   14391            0 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityAirWalkIn / DensityZoneAir, 0.333)), 1.5);
   14392              :             } else { // temperature inversion with zone colder and/or drier than walk-in, infiltration in reverse direction
   14393              :                 // The enthalpy difference will show whether the energy transport is reversed
   14394              :                 //(same air mass exchange in either direction )
   14395              :                 // That is, these factors establish the magnitude of the exchange air flow, not direction
   14396            3 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityAirWalkIn / DensityZoneAir);
   14397            3 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityZoneAir / DensityAirWalkIn, 0.333)), 1.5);
   14398              :             } // check for density in zone and in walk-in to avoid taking sqrt of neg number
   14399              : 
   14400            3 :             Real64 StockDoorInfLoad = 0.0;  // infiltration through stock doors in a particular zone (W)
   14401            3 :             Real64 StockDoorSensHeat = 0.0; // sensible heat gain through stock doors (UA*delta T) (W)
   14402            3 :             Real64 DoorProtectEff(0.0);     // Door protection effectiveness
   14403            3 :             Real64 DrHeight(0.0);           // Door height (m)
   14404            3 :             Real64 DrArea(0.0);             // Door area (m2)
   14405            3 :             Real64 FullFlowInfLoad(0.0);    // Total load (lat + sens) due to 100% open doors w/ fully developed flow (W)
   14406              : 
   14407            3 :             if (StockDoorArea > 0.0) {
   14408            3 :                 std::array<Real64, (int)WIStockDoor::Num> doorProtectEffs = {0.0, 0.5, 0.9}; // Values from ASHRAE Ref p 13.6
   14409            3 :                 DoorProtectEff = doorProtectEffs[(int)this->StockDoorProtectType(ZoneID)];
   14410            3 :                 DrHeight = this->HeightStockDr(ZoneID);
   14411            3 :                 DrArea = StockDoorArea;
   14412              :                 // if exists, get Stock Door Zone schedule
   14413            3 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor;
   14414            3 :                 if (this->stockDoorOpenScheds(ZoneID) != nullptr) DoorOpenFactor = this->stockDoorOpenScheds(ZoneID)->getCurrentVal();
   14415              : 
   14416            3 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   14417            3 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   14418            3 :                 StockDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   14419            3 :                 StockDoorSensHeat = DrArea * this->UValueStockDr(ZoneID) * DelTemp;
   14420              :             } // have stock doors
   14421              : 
   14422            3 :             Real64 GlassDoorSensHeat(0.0); // sensible heat gain through glass reach-in doors (UA*delta T) (W)
   14423            3 :             Real64 GlassDoorInfLoad = 0.0; // infiltration through glass reach-in doors in a particular zone (W)
   14424              : 
   14425            3 :             if (GlassDoorArea > 0.0) {
   14426            0 :                 DoorProtectEff = 0.5; // Assume glass doors have air curtain
   14427            0 :                 DrHeight = this->HeightGlassDr(ZoneID);
   14428            0 :                 DrArea = GlassDoorArea;
   14429              :                 // get Glass Door Zone schedule
   14430            0 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor; // default value
   14431            0 :                 if (this->glassDoorOpenScheds(ZoneID) != nullptr) DoorOpenFactor = this->glassDoorOpenScheds(ZoneID)->getCurrentVal();
   14432              : 
   14433            0 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   14434            0 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   14435            0 :                 GlassDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   14436            0 :                 GlassDoorSensHeat = DrArea * this->UValueGlassDr(ZoneID) * DelTemp;
   14437              :             } // have Glass doors
   14438              : 
   14439              :             // assume mass dry air infiltrating into walk-in == mass out into zone,
   14440              :             //                       that is, equal air exchange (ASHRAE 2006 Refrigeration)
   14441            3 :             Real64 ZoneInfilLoad = -StockDoorInfLoad - GlassDoorInfLoad; // Walk in cooler infiltration load (sens + latent) in certain zone (W)
   14442            3 :             Real64 MassDryAirRate =
   14443            3 :                 -ZoneInfilLoad / (EnthalpyZoneAir - EnthalpyAirWalkIn); // Mass dry air infiltrating into/out-of walkin through doors (kg/s)
   14444            3 :             Real64 WaterRemovRate =
   14445            3 :                 MassDryAirRate * (HumRatioZoneAir - HumRatioAirWalkIn); // Walk in cooler removes water at this rate in this zone (kg/s)
   14446              :             // Just as with cases,  we assume no latent credit (water removal = 0) to zone or load on cooler during dripdown
   14447              :             // To be consistent with the treatment of refrigerated cases, latent load
   14448              :             //  and latent credit are both based on reducing the infiltrating vapor to ice.  (This is
   14449              :             //  slightly greater than if the latent credit were based upon condensing out the water as liquid.)
   14450              :             //  then it would be: ZoneLatentLoad = -WaterRemovRate * WaterToVaporEnthalpy * (1.0d0-DefrostDripDownSchedule)
   14451            3 :             ZoneLatentLoad = -WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   14452            3 :             ZInfilSensLoad = ZoneInfilLoad - (-WaterRemovRate * IcetoVaporEnthalpy); // done to avoid moving latent to sens during dripdown
   14453            3 :             ZdoorSensLoad = -GlassDoorSensHeat - StockDoorSensHeat;
   14454            3 :             WalkInLatLoad = -ZoneLatentLoad;
   14455            3 :             if (this->TEvapDesign <= 0.0) { // water turned to ice on coil
   14456            3 :                 WalkInLatLoad = WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   14457              :                 // FROST:  keep track of frost build up on evaporator coil
   14458              :                 //         avoid accumulation during warm-up to avoid reverse dd test problem
   14459            3 :                 if (!state.dataGlobal->WarmupFlag) {
   14460            3 :                     Real64 FrostChangekg = (WaterRemovRate * state.dataGlobal->TimeStepZoneSec) * (1.0 - DefrostDripDownSchedule);
   14461            3 :                     this->KgFrost += FrostChangekg;
   14462              :                 }
   14463              :             } // water to ice
   14464              :         }     // No doors
   14465              : 
   14466              :         // Sensible WalkIn credit delivered to a particular zone (W)
   14467            3 :         Real64 ZoneSensLoad = ZInfilSensLoad + ZdoorSensLoad - UAOtherSurfaces * DelTemp;
   14468            3 :         Real64 WalkInSensLoad = -ZoneSensLoad; // Walk in cooler sensible load facing particular zone (W)
   14469              : 
   14470              :         // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   14471              :         //   Zone Equipment Manager. Sum walk-in credits to zone using existing 'casecredit' variable
   14472              :         //   No return air fractions are applied to walk-ins, and no latent in stocking -
   14473              : 
   14474            3 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).SenCaseCreditToZone += ZoneSensLoad;
   14475            3 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).LatCaseCreditToZone += ZoneLatentLoad;
   14476              : 
   14477              :         // Set up report variables for each zone for this walk-in
   14478              :         // Sensible heat exchange can be positive or negative, split into separate output variables and always report positive value
   14479            3 :         this->SensZoneCreditRate(ZoneID) = ZoneSensLoad;
   14480            3 :         if (ZoneSensLoad <= 0.0) {
   14481            0 :             this->SensZoneCreditCoolRate(ZoneID) = -ZoneSensLoad;
   14482            0 :             this->SensZoneCreditCool(ZoneID) = -ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   14483            0 :             this->SensZoneCreditHeatRate(ZoneID) = 0.0;
   14484            0 :             this->SensZoneCreditHeat(ZoneID) = 0.0;
   14485              :         } else {
   14486            3 :             this->SensZoneCreditHeatRate(ZoneID) = ZoneSensLoad;
   14487            3 :             this->SensZoneCreditHeat(ZoneID) = ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   14488            3 :             this->SensZoneCreditCoolRate(ZoneID) = 0.0;
   14489            3 :             this->SensZoneCreditCool(ZoneID) = 0.0;
   14490              :         }
   14491              :         // This rate should always be negative
   14492            3 :         this->LatZoneCreditRate(ZoneID) = ZoneLatentLoad;
   14493            3 :         this->LatZoneCredit(ZoneID) = ZoneLatentLoad * state.dataGlobal->TimeStepZoneSec;
   14494              : 
   14495              :         // Running total over all zones, use later to dispatch capacity
   14496            3 :         SensibleLoadTotal += WalkInSensLoad;
   14497            3 :         LatentLoadTotal += WalkInLatLoad;
   14498              : 
   14499              :     } // Do loop over zones for zone-condition-related sensible and latent loads
   14500              : 
   14501              :     // cooling coil fan power default is 375W, = 1/2 HP (Tyler showed 1/3 to 3/4 hp)
   14502              : 
   14503              :     // CALCULATE AUX LOADS DUE TO LIGHTS, FANS AND HEATERS
   14504            3 :     Real64 LightLoad = this->DesignLighting * LightingSchedule; // Total lighting energy rate (W)
   14505              :     // turn coil fan off during defrost/drip - down period
   14506              : 
   14507              :     // Total fan energy rate (W)
   14508            3 :     Real64 FanLoad = this->CircFanPower * CircFanSchedule + this->CoilFanPower * (1.0 - DefrostDripDownSchedule);
   14509            3 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   14510              :     // Calculate floor load - using 'DataEnvironment::GroundTemp' assigned in weather manager (can be entered by user if desired)
   14511              :     //    Default value is 18C.
   14512              :     // Total floor energy rate (W)
   14513              :     Real64 FloorLoad =
   14514            3 :         this->FloorArea * this->FloorUValue * (state.dataEnvrn->GroundTemp[(int)DataEnvironment::GroundTempType::BuildingSurface] - TWalkIn);
   14515              : 
   14516              :     Real64 DefrostLoad;
   14517              : 
   14518              :     // DEFROST CALCULATIONS
   14519            3 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   14520            0 :         DefrostLoad = this->DefrostCapacity * DefrostSchedule;                  // W
   14521            0 :         Real64 StartFrostKg = this->KgFrost;                                    // frost load at start of time step (kg of ice)
   14522            0 :         Real64 DefrostEnergy = DefrostLoad * state.dataGlobal->TimeStepZoneSec; // Joules
   14523            0 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   14524              :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   14525              :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   14526              :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   14527              :             //  others and xfer heat to environment)
   14528              :             //  Assume full ice melting satisfies temperature control.
   14529              :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   14530            0 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // Joules avail to melt ice
   14531            0 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   14532            0 :             if (StartFrostKg > 0.0) {
   14533            0 :                 if (this->IceTemp < 0.0) {
   14534            0 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   14535            0 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   14536            0 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   14537            0 :                         this->IceTemp = 0.0;
   14538            0 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   14539              :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   14540            0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   14541            0 :                         AvailDefrostEnergy = 0.0;
   14542              :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   14543              :                 }     // IceTemp < 0,  need to raise temperature of ice
   14544              :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   14545            0 :                 Real64 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   14546            0 :                 if (FrostChangekg < StartFrostKg) {
   14547            0 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   14548            0 :                     if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   14549              :                     // DefrostSchedule not changed
   14550              :                 } else { // all frost melted during time step, so need to terminate defrost
   14551              :                     //  see Aug 8 page 3 notes
   14552            0 :                     this->KgFrost = 0.0;
   14553            0 :                     DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   14554            0 :                                           this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   14555            0 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (this->DefrostCapacity * state.dataGlobal->TimeStepZoneSec)));
   14556              :                     // reduce load on walkin by energy put into ice melting
   14557            0 :                     DefrostLoad = max(0.0,
   14558            0 :                                       (DefrostSchedule * this->DefrostCapacity -
   14559            0 :                                        (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / state.dataGlobal->TimeStepZoneSec));
   14560            0 :                     this->IceTemp = this->TEvapDesign;
   14561              : 
   14562              :                 }    // frost melted during time step less than amount of ice at start
   14563              :             } else { // no frost present so terminate defrost and reset ice temperature for start of next defrost
   14564            0 :                 DefrostLoad = 0.0;
   14565            0 :                 DefrostSchedule = 0.0;
   14566            0 :                 this->IceTemp = this->TEvapDesign;
   14567              :             } // have frost present
   14568              : 
   14569              :         } else { // Not temperature control type
   14570            0 :             Real64 FrostChangekg = min(DefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   14571              :             // Reduce defrost heat load on walkin by amount of ice melted during time step
   14572            0 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   14573            0 :             if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   14574              :             // DefrostSchedule not changed
   14575              :         } // Temperature termination control type
   14576              : 
   14577            0 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   14578            3 :         DefrostLoad = 0.0;
   14579              :     } // Defrost calculations
   14580              : 
   14581            3 :     if (this->defrostType == DefrostType::Elec) {
   14582            3 :         this->ElecDefrostConsumption = this->DefrostCapacity * DefrostSchedule * state.dataGlobal->TimeStepZoneSec;
   14583            3 :         this->ElecDefrostPower = this->DefrostCapacity * DefrostSchedule;
   14584              :     } else {
   14585            0 :         this->ElecDefrostConsumption = 0.0;
   14586            0 :         this->ElecDefrostPower = 0.0;
   14587              :     }
   14588              : 
   14589              :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   14590            3 :     if (this->defrostType == DefrostType::Fluid) this->HotDefrostCondCredit = this->DefrostCapacity * DefrostSchedule;
   14591              : 
   14592              :     // loads reflects that walk ins continue to accumulate loads, even during defrost
   14593              :     // but cap is used to report portion met by active system while operating
   14594              : 
   14595              :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   14596            3 :     SensibleLoadTotal += LightLoad + HeaterLoad + FanLoad + StockingLoad + DefrostLoad + FloorLoad;
   14597            3 :     Real64 LoadTotal = SensibleLoadTotal + LatentLoadTotal; // total load in time step (W)
   14598              : 
   14599              :     // Account for difference between load and capacity. Assume rack or system able to provide
   14600              :     // rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   14601              :     //  Here we are calculating the load the walk-in cooler places on the refrigeration compressor systems.
   14602              :     //  Meet current load to the extent possible.  If extra capacity available,
   14603              :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   14604              :     //  (e.g. as it is during defrost cycles) save the unmet/stored load to be met in
   14605              :     //  succeeding time steps. This is an artificial way of recognizing that the internal
   14606              :     //  temperature will increase by a small amount during defrost and the system will have to
   14607              :     //  run full out until the temperature is brought back down.
   14608              : 
   14609              :     // Rate needed to serve all stored energy during single time step (W)
   14610            3 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   14611            3 :     Real64 LoadRequested = LoadTotal + StoredEnergyRate; // Load necessary to meet current and all stored energy needs (W)
   14612              : 
   14613              :     Real64 LatentCapApplied;        // Walk In latent capacity at specific operating conditions
   14614            3 :     Real64 SensibleCapApplied(0.0); // Walk In sensible capacity at specific operating conditions
   14615              : 
   14616              :     // prorate available cooling capacity for portion of time off due to drip down.
   14617            3 :     Real64 MaxCap = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule); // Design chilling capacity reduced according to drip-down schedule (W)
   14618              : 
   14619            3 :     if (MaxCap >= LoadRequested) {
   14620              :         // Have more at least as much capacity available as needed, even counting stored energy
   14621            3 :         CapApplied = LoadRequested;
   14622            3 :         SensibleCapApplied = SensibleLoadTotal + StoredEnergyRate;
   14623            3 :         LatentCapApplied = LatentLoadTotal;
   14624            3 :         this->StoredEnergy = 0.0;
   14625              :     } else {
   14626              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   14627            0 :         CapApplied = MaxCap;
   14628            0 :         LatentCapApplied = min(LatentLoadTotal, MaxCap); // Latent load should never be > capavail, but just in case...
   14629            0 :         SensibleCapApplied = CapApplied - LatentCapApplied;
   14630            0 :         if (!state.dataGlobal->WarmupFlag) this->StoredEnergy += (LoadTotal - MaxCap) * state.dataGlobal->TimeStepZoneSec;
   14631              :     } // CapAvail vs Load requested
   14632              : 
   14633              :     // ReportWalkIn( WalkInID)
   14634            3 :     this->TotalCoolingLoad = CapApplied;
   14635            3 :     this->TotalCoolingEnergy = CapApplied * state.dataGlobal->TimeStepZoneSec;
   14636            3 :     this->TotSensCoolingEnergyRate = SensibleCapApplied;
   14637            3 :     this->TotSensCoolingEnergy = SensibleCapApplied * state.dataGlobal->TimeStepZoneSec;
   14638            3 :     this->TotLatCoolingEnergyRate = LatentCapApplied;
   14639            3 :     this->TotLatCoolingEnergy = LatentCapApplied * state.dataGlobal->TimeStepZoneSec;
   14640              : 
   14641            3 :     this->ElecFanPower = FanLoad;
   14642            3 :     this->ElecFanConsumption = FanLoad * state.dataGlobal->TimeStepZoneSec;
   14643            3 :     this->ElecHeaterPower = HeaterLoad;
   14644            3 :     this->ElecHeaterConsumption = HeaterLoad * state.dataGlobal->TimeStepZoneSec;
   14645            3 :     this->ElecLightingPower = LightLoad;
   14646            3 :     this->ElecLightingConsumption = LightLoad * state.dataGlobal->TimeStepZoneSec;
   14647            3 :     this->TotalElecPower = FanLoad + HeaterLoad + LightLoad + this->ElecDefrostPower;
   14648            3 :     this->TotalElecConsumption = this->TotalElecPower * state.dataGlobal->TimeStepZoneSec;
   14649              : 
   14650              :     //**************************************************************************************************
   14651              :     // Cap Energy and Kg Frost to avoid floating overflow errors
   14652              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   14653            3 :     if (this->StoredEnergy > MyLargeNumber) {
   14654            0 :         this->StoredEnergy = MyLargeNumber;
   14655            0 :         if (this->ShowUnmetWIEnergyWarning) {
   14656            0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   14657            0 :             ShowContinueError(state, " This walk-in cooler has insufficient capacity to meet the loads");
   14658            0 :             ShowContinueError(state,
   14659            0 :                               format("... Occurrence info = {}, {} {}",
   14660            0 :                                      state.dataEnvrn->EnvironmentName,
   14661            0 :                                      state.dataEnvrn->CurMnDy,
   14662            0 :                                      General::CreateSysTimeIntervalString(state)));
   14663            0 :             ShowContinueError(state, " Refer to documentation for further explanation of Total Cooling Capacity.");
   14664            0 :             this->ShowUnmetWIEnergyWarning = false;
   14665              :         } // ShowStoreEnergyWarning
   14666              :     }     // stored energy > large number
   14667            3 :     if (this->KgFrost > MyLargeNumber) {
   14668            0 :         this->KgFrost = MyLargeNumber;
   14669            0 :         if (this->ShowWIFrostWarning) {
   14670            0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   14671            0 :             ShowContinueError(state, " This walkin cooler has insufficient defrost capacity to remove the excess frost accumulation.");
   14672            0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   14673            0 :             ShowContinueError(state,
   14674            0 :                               format("... Occurrence info = {}, {} {}",
   14675            0 :                                      state.dataEnvrn->EnvironmentName,
   14676            0 :                                      state.dataEnvrn->CurMnDy,
   14677            0 :                                      General::CreateSysTimeIntervalString(state)));
   14678            0 :             this->ShowWIFrostWarning = false;
   14679              :         }
   14680              :     }
   14681              : }
   14682              : 
   14683            0 : void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const SecondaryNum)
   14684              : {
   14685              :     // SUBROUTINE INFORMATION:
   14686              :     //       AUTHOR         Therese Stovall, ORNL
   14687              :     //       DATE WRITTEN   Spring 2009
   14688              :     //       RE-ENGINEERED  na
   14689              : 
   14690              :     // PURPOSE OF THIS SUBROUTINE:
   14691              :     // Find the total cooling load, pump power, and needed primary refrigerant supply temperature
   14692              :     // for a secondary system.
   14693              : 
   14694              :     // METHODOLOGY EMPLOYED:
   14695              :     // Sum the loads for the cases and walk-ins supplied by a secondary loop.
   14696              :     // Calculate the pumping power.
   14697              :     // Assume that the fluid supply and return temperatures are fixed and the
   14698              :     // fluid flow rate is varied to meed the variable load.
   14699              :     // User has been told in IO and Eng ref: for secondary systems/pumps: pump energy is f(viscosity),
   14700              :     //        but since specifying Tcircfluid as steady
   14701              :     //        state in loop, specify power for fluid and system head/resistance at that temp
   14702              :     // ashrae 2006 p4.1 supports 78% eff for pump impellers
   14703              :     //  all power into heat because it would otherwise not be counted in zone
   14704              :     //  if use semihermetic motor, also need to add motor ineff as heat
   14705              : 
   14706              :     // REFERENCES:
   14707              :     // SCE report
   14708              :     //  others
   14709              : 
   14710            0 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   14711              : 
   14712              :     bool AtPartLoad;          // Whether or not need to iterate on pump power
   14713              :     bool DeRate;              // If true, need to derate aircoils because don't carry over unmet energy
   14714              :     int Iter;                 // loop counter
   14715              :     Real64 CpBrine;           // Specific heat (W/kg)
   14716              :     Real64 DensityBrine;      // Density (kg/m3)
   14717              :     Real64 DiffTemp;          // (C)
   14718              :     Real64 distPipeHeatGain;  // Optional (W)
   14719              :     Real64 Error;             // Used in iterative soln for pumps needed to meet load (that has to include pump energy)
   14720              :     Real64 FlowVolNeeded;     // Flow rate needed to meet load (m3/s)
   14721              :     Real64 PartLdFrac;        // Used to ratio pump power
   14722              :     Real64 PartPumpFrac;      // Used to see if part pumps dispatched meets part pump load
   14723              :     Real64 PrevTotalLoad;     // Used in pump energy convergence test
   14724              :     Real64 RefrigerationLoad; // Load for cases and walk-ins served by loop, does not include pump energy (W)
   14725              :     Real64 StoredEnergyRate;  // Used to meet loads unmet in previous time step (related to defrost cycles
   14726              :     //     on cases/walk-ins served)(W)
   14727              :     Real64 TBrineIn;                  // Brine temperature going to heat exchanger, C
   14728              :     Real64 TotalHotDefrostCondCredit; // Used to credit condenser when heat reclaim used for hot gas/brine defrost (W)
   14729              :     Real64 TotalPumpPower;            // Total Pumping power for loop, W
   14730              :     Real64 TotalLoad;                 // Total Cooling Load on secondary loop, W
   14731            0 :     Real64 TPipesReceiver(0.0);       // Temperature used for contents of pipes and/or receiver in calculating shell losses (C)
   14732              :     Real64 VarFrac;                   // Pump power fraction for variable speed pump, dimensionless
   14733              :     Real64 VolFlowRate;               // Used in dispatching pumps to meet load (m3/s)
   14734              : 
   14735            0 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   14736            0 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   14737            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   14738              : 
   14739            0 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   14740            0 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   14741              : 
   14742            0 :     switch (this->FluidType) {
   14743            0 :     case SecFluidType::AlwaysLiquid: {
   14744            0 :         CpBrine = this->CpBrineRated;
   14745            0 :         DensityBrine = this->DensityBrineRated;
   14746            0 :         TBrineIn = this->TBrineInRated;
   14747            0 :         TPipesReceiver = this->TBrineAverage;
   14748            0 :     } break;
   14749            0 :     case SecFluidType::PhaseChange: {
   14750            0 :         TPipesReceiver = this->TCondense;
   14751            0 :     } break;
   14752            0 :     default:
   14753            0 :         break;
   14754              :     } // Fluid type
   14755              : 
   14756              :     // Initialize this secondary for this time step
   14757            0 :     TotalPumpPower = 0.0;
   14758            0 :     RefrigerationLoad = 0.0;
   14759            0 :     TotalHotDefrostCondCredit = 0.0;
   14760            0 :     FlowVolNeeded = 0.0;
   14761            0 :     DeRate = false;
   14762              : 
   14763              :     // SCE page 28 gives a delta T for pipe heat gains
   14764              :     //         (.25F each for supply and discharge) for use with mdot*cp.
   14765              :     //          However, another author shows this as a major diff between dx and secondary
   14766              :     //          So - allow the user to include this in his total load, even though he has to do
   14767              :     //          most of the calculations before the input (to get to SumUADistPiping)).
   14768            0 :     distPipeHeatGain = 0.0;
   14769            0 :     if (this->SumUADistPiping > MySmallNumber) {
   14770            0 :         int ZoneNodeNum = this->DistPipeZoneNodeNum;
   14771            0 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   14772            0 :         distPipeHeatGain = DiffTemp * this->SumUADistPiping;
   14773              :         // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   14774              :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   14775            0 :         this->DistPipeZoneHeatGain = -distPipeHeatGain;
   14776            0 :         state.dataHeatBal->RefrigCaseCredit(this->DistPipeZoneNum).SenCaseCreditToZone -= distPipeHeatGain;
   14777              :     } // calc distribution piping heat gains
   14778              : 
   14779            0 :     Real64 receiverHeatGain = 0.0;
   14780            0 :     if (this->SumUAReceiver > MySmallNumber) {
   14781            0 :         int ZoneNodeNum = this->ReceiverZoneNodeNum;
   14782            0 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   14783            0 :         receiverHeatGain = DiffTemp * this->SumUAReceiver;
   14784              :         // receiver heat load is a positive number (ie. heat absorbed by receiver, so needs to be subtracted
   14785              :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   14786            0 :         this->ReceiverZoneHeatGain = -receiverHeatGain;
   14787            0 :         state.dataHeatBal->RefrigCaseCredit(this->ReceiverZoneNum).SenCaseCreditToZone -= receiverHeatGain;
   14788              :     } // calc receiver heat gains
   14789              : 
   14790              :     // Sum up all the case and walk-in loads served by the secondary loop
   14791            0 :     if (this->NumCases > 0) {
   14792            0 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   14793            0 :             int CaseID = this->CaseNum(caseNum);
   14794            0 :             RefrigCase(CaseID).CalculateCase(state);
   14795              :             // increment TotalCoolingLoad Hot gas/brine defrost credits for each secondary loop
   14796            0 :             RefrigerationLoad += RefrigCase(CaseID).TotalCoolingLoad;
   14797            0 :             TotalHotDefrostCondCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   14798              :         } // CaseNum
   14799              :     }     // NumCases > 0
   14800            0 :     if (this->NumWalkIns > 0) {
   14801            0 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   14802            0 :             int WalkInID = this->WalkInNum(WalkInIndex);
   14803            0 :             WalkIn(WalkInID).CalculateWalkIn(state);
   14804              :             // increment TotalCoolingLoad for  each system
   14805            0 :             RefrigerationLoad += WalkIn(WalkInID).TotalCoolingLoad;
   14806            0 :             TotalHotDefrostCondCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   14807              :         } // NumWalkIns systems
   14808              :     }     // Secondary(SecondaryNum)%NumWalkIns > 0
   14809              : 
   14810            0 :     if (this->NumCoils > 0) {
   14811            0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   14812            0 :             int CoilID = this->CoilNum(CoilIndex);
   14813              :             // already CALL CalculateCoil(CoilID) for each coil, dispatched in coilset order for each zone
   14814              :             // increment TotalCoolingLoad for each system
   14815              :             //  here will find out if secondary can serve total load, if not will derate coil output/case credits
   14816            0 :             RefrigerationLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   14817            0 :             TotalHotDefrostCondCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   14818              :         } // NumCoils on secondary system
   14819              :     }     // Secondary(SecondaryNum)%NumCoils > 0
   14820              : 
   14821            0 :     TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain;
   14822            0 :     AtPartLoad = true;
   14823              :     // Check to see if load is already >+ maxload without pump heat
   14824            0 :     if (this->FluidType == SecFluidType::AlwaysLiquid) { //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   14825            0 :         FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   14826              :         // For brine/glycol systems, find flow volume needed to meet load
   14827              :         // Per ashrae 2006, p4.1, eval mass flow rate to pump at brine return (to chiller) temp
   14828              :         //   because pumps located in return piping
   14829            0 :         if (FlowVolNeeded >= this->MaxVolFlow) {
   14830              :             // Don't need to iterate on pumps, just set to max.  Will have unmet load this time step (unless coils present)
   14831            0 :             VolFlowRate = this->MaxVolFlow;
   14832            0 :             TotalPumpPower = this->PumpTotRatedPower;
   14833            0 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   14834            0 :             AtPartLoad = false;
   14835            0 :             if (this->NumCoils > 0) DeRate = true;
   14836              :         }    // flowvolneeded >= maxvolflow
   14837              :     } else { // have SecFluidTypePhaseChange !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   14838            0 :         if (TotalLoad >= this->MaxLoad) {
   14839            0 :             TotalPumpPower = this->PumpTotRatedPower;
   14840            0 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   14841            0 :             VolFlowRate = this->MaxVolFlow;
   14842            0 :             AtPartLoad = false;
   14843            0 :             if (this->NumCoils > 0) DeRate = true;
   14844              :         }
   14845              :     } // fluid type check for max load or max flow       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   14846              : 
   14847              :     // If totalLoad < maxload, then need to calculate partial pump load
   14848              :     // Need an iterative soln for pump energy needed to meet total load
   14849              :     //  because that total load has to include pump energy
   14850            0 :     if (AtPartLoad) {
   14851            0 :         for (Iter = 1; Iter <= 10; ++Iter) {
   14852            0 :             if (TotalLoad <= 0.0) {
   14853              :                 // Load on secondary loop is zero (or negative).
   14854              :                 // Set volumetric flow rate and pump power to be zero.
   14855            0 :                 VolFlowRate = 0.0;
   14856            0 :                 TotalPumpPower = 0.0;
   14857            0 :                 break;
   14858              :             }
   14859            0 :             PrevTotalLoad = TotalLoad;
   14860            0 :             if (this->FluidType == SecFluidType::AlwaysLiquid) {
   14861            0 :                 FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   14862            0 :                 PartLdFrac = FlowVolNeeded / this->MaxVolFlow;
   14863              :             } else {
   14864            0 :                 PartLdFrac = TotalLoad / this->MaxLoad;
   14865              :             }
   14866            0 :             if (this->PumpControlType == SecPumpCtrl::Constant) {
   14867            0 :                 VolFlowRate = 0.0;
   14868            0 :                 TotalPumpPower = 0.0;
   14869            0 :                 for (int PumpID = 1; PumpID <= this->NumPumps; ++PumpID) { // dispatch pumps to meet needed flow rate
   14870            0 :                     if (this->FluidType == SecFluidType::AlwaysLiquid) {   //>>>>>>>>>>>>>>>>>>>>>
   14871            0 :                         VolFlowRate += this->PumpIncrementFlowVol;
   14872            0 :                         TotalPumpPower += this->PumpIncrementPower;
   14873            0 :                         if (VolFlowRate >= FlowVolNeeded) break;
   14874              :                     } else { // fluid type phase change >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   14875            0 :                         VolFlowRate += this->PumpIncrementFlowVol;
   14876            0 :                         TotalPumpPower += this->PumpIncrementPower;
   14877            0 :                         PartPumpFrac = TotalPumpPower / this->PumpTotRatedPower;
   14878            0 :                         if (PartPumpFrac >= PartLdFrac) break;
   14879              :                     } // fluid type              >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   14880              :                 }     // Dispatching pumps until fluid flow need is met
   14881              :             } else {  // pump type variable
   14882            0 :                 VarFrac = max(0.1, Curve::CurveValue(state, this->VarSpeedCurvePtr, PartLdFrac));
   14883            0 :                 TotalPumpPower = this->PumpTotRatedPower * VarFrac;
   14884            0 :                 VolFlowRate = this->MaxVolFlow * PartLdFrac;
   14885              :             } // pump type
   14886              : 
   14887            0 :             TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain + TotalPumpPower * this->PumpPowerToHeat;
   14888            0 :             Error = std::abs((TotalLoad - PrevTotalLoad) / PrevTotalLoad);
   14889            0 :             if (Error < ErrorTol) break;
   14890              :         } // end iteration on pump energy convergence
   14891              : 
   14892              :         //   IF (Iter >=10 .AND. .NOT. WarmupFlag)THEN
   14893              :         //     If( .not. WarmupFlag) Then
   14894              :         //      Write(OutputFileDebug,707)Month, DataGlobals::CurrentTime, Iter, TotalLoad, TotalPumpPower
   14895              :         //     End If
   14896              :         // 707 format(' in iter loop at 707: ',1x,I2,1x,F5.2,1x,I5,7(F10.5,1x))
   14897              :         //    END IF  !didn't converge
   14898              :     } //(AtPartLoad)
   14899              : 
   14900              :     // If only loads are cases and walk-ins, that is, no air coils:
   14901              :     //  Account for difference between load and capacity on secondary loop. Assume system able to provide
   14902              :     //  rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   14903              :     //  Meet current load to the extent possible.  If extra capacity available,
   14904              :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   14905              :     //  (e.g. as it may be following defrost cycles on cases or walk-ins served by secondary loop)
   14906              :     //  save the unmet/stored load to be met in succeeding time steps.
   14907            0 :     if (this->NumCoils == 0) {
   14908            0 :         StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour));
   14909              :         // Load necessary to meet current and all stored energy needs (W)
   14910            0 :         Real64 LoadRequested = TotalLoad + StoredEnergyRate;
   14911            0 :         if (this->MaxLoad > LoadRequested) {
   14912              :             // Have at least as much capacity avail as needed, even counting stored energy
   14913            0 :             this->TotalCoolingLoad = LoadRequested;
   14914            0 :             RefrigerationLoad += StoredEnergyRate;
   14915            0 :             this->UnmetEnergy = 0.0;
   14916              :         } else {
   14917              :             // Don't have as much capacity as needed (likely following defrost periods)
   14918            0 :             this->TotalCoolingLoad = this->MaxLoad;
   14919            0 :             RefrigerationLoad -= (TotalLoad - this->MaxLoad);
   14920            0 :             if (!state.dataGlobal->WarmupFlag) this->UnmetEnergy += ((TotalLoad - this->MaxLoad) * state.dataGlobal->TimeStepZoneSec);
   14921              :         } // load requested greater than MaxLoad
   14922            0 :         if (this->UnmetEnergy > MyLargeNumber) {
   14923            0 :             this->UnmetEnergy = MyLargeNumber;
   14924            0 :             if (state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum)) {
   14925            0 :                 ShowWarningError(state, format("Secondary Refrigeration Loop: {}", this->Name));
   14926            0 :                 ShowContinueError(state, " This secondary system has insufficient capacity to meet the refrigeration loads.");
   14927            0 :                 state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum) = false;
   14928              :             }
   14929              :         } //>my large number
   14930              : 
   14931              :     } else { // air coils on secondary loop, no "unmet" energy accounting, just reduce amount of cooling provided to zone by coils
   14932            0 :         DeRate = false;
   14933            0 :         if (TotalLoad > this->MaxLoad) DeRate = true;
   14934            0 :         FinalRateCoils(
   14935              :             state, DeRate, SourceType::SecondarySystem, SecondaryNum, TotalLoad, this->MaxLoad); // assign case credits for coils on this loop
   14936              :         // Bug TotalCoolingLoad not set but used below
   14937              :     } // no air coils on secondary loop
   14938            0 :     this->PumpPowerTotal = TotalPumpPower;
   14939            0 :     this->PumpElecEnergyTotal = TotalPumpPower * localTimeStepSec;
   14940            0 :     this->TotalRefrigLoad = RefrigerationLoad;
   14941            0 :     this->TotalRefrigEnergy = RefrigerationLoad * localTimeStepSec;
   14942            0 :     this->TotalCoolingEnergy = TotalCoolingLoad * localTimeStepSec;
   14943            0 :     this->FlowVolActual = VolFlowRate;
   14944            0 :     this->HotDefrostCondCredit = TotalHotDefrostCondCredit;
   14945            0 :     this->DistPipeHeatGain = distPipeHeatGain;
   14946            0 :     this->DistPipeHeatGainEnergy = distPipeHeatGain * localTimeStepSec;
   14947            0 :     this->ReceiverHeatGain = receiverHeatGain;
   14948            0 :     this->ReceiverHeatGainEnergy = receiverHeatGain * localTimeStepSec;
   14949            0 : }
   14950              : 
   14951            5 : void SumZoneImpacts(EnergyPlusData &state)
   14952              : {
   14953              : 
   14954              :     // SUBROUTINE INFORMATION:
   14955              :     //       AUTHOR         Therese Stovall, ORNL
   14956              :     //       DATE WRITTEN   Spring 2010
   14957              :     //       RE-ENGINEERED  na
   14958              : 
   14959              :     // PURPOSE OF THIS SUBROUTINE:
   14960              :     // Find the total impact of all refrigeration systems on each zone.
   14961              : 
   14962              :     // METHODOLOGY EMPLOYED:
   14963              :     // Calculate the energy from refrigerated case credits arising from interaction between the zone and:
   14964              :     //   refrigerated cases and walk-ins
   14965              :     //   heat rejection from zone-located compressor-racks and zone-located air-cooled condensers
   14966              :     //   heat absorbed by suction piping, secondary loop distribution piping, and
   14967              :     //   secondary receiver shells
   14968              : 
   14969            5 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   14970            5 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   14971              : 
   14972            5 :     if (state.dataRefrigCase->UseSysTimeStep) { // air chillers
   14973            0 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   14974            0 :             auto &credit = CoilSysCredit(ZoneNum);
   14975            0 :             credit.ReportH2ORemovedKgPerS_FromZoneRate = -credit.LatKgPerS_ToZoneRate;
   14976            0 :             credit.ReportLatCreditToZoneRate = -credit.LatCreditToZoneRate;
   14977            0 :             credit.ReportLatCreditToZoneEnergy = -credit.LatCreditToZoneEnergy;
   14978              :             // Sensible rate can be positive or negative, split into separate output variables and
   14979              :             //   always report positive value
   14980            0 :             if (credit.SenCreditToZoneRate <= 0.0) {
   14981            0 :                 credit.ReportSenCoolingToZoneRate = -credit.SenCreditToZoneRate;
   14982            0 :                 credit.ReportSenCoolingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   14983            0 :                 credit.ReportHeatingToZoneRate = 0.0;
   14984            0 :                 credit.ReportHeatingToZoneEnergy = 0.0;
   14985              :             } else {
   14986            0 :                 credit.ReportSenCoolingToZoneRate = 0.0;
   14987            0 :                 credit.ReportSenCoolingToZoneEnergy = 0.0;
   14988            0 :                 credit.ReportHeatingToZoneRate = credit.SenCreditToZoneRate;
   14989            0 :                 credit.ReportHeatingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   14990              :             }
   14991            0 :             credit.ReportTotCoolingToZoneRate = credit.ReportLatCreditToZoneRate + credit.ReportSenCoolingToZoneRate;
   14992            0 :             credit.ReportTotCoolingToZoneEnergy = credit.ReportLatCreditToZoneEnergy + credit.ReportSenCoolingToZoneEnergy;
   14993              :         }
   14994              :     } // UseSysTimeStep signals run for air chillers
   14995              : 
   14996              :     // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   14997           10 :     if ((!state.dataRefrigCase->UseSysTimeStep) &&
   14998            5 :         ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   14999           10 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15000            5 :             auto &report = CaseWIZoneReport(ZoneNum);
   15001            5 :             report.SenCaseCreditToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15002              :             // Latent always negative
   15003            5 :             report.LatCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15004            5 :             report.LatCoolingToZoneEnergy = report.LatCoolingToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15005              :             // Sensible rate can be positive or negative, split into separate output variables and
   15006              :             //   always report positive value
   15007            5 :             if (state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone <= 0.0) {
   15008            1 :                 report.SenCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15009            1 :                 report.SenCoolingToZoneEnergy = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15010            1 :                 report.HeatingToZoneRate = 0.0;
   15011            1 :                 report.HeatingToZoneEnergy = 0.0;
   15012              :             } else {
   15013            4 :                 report.SenCoolingToZoneRate = 0.0;
   15014            4 :                 report.SenCoolingToZoneEnergy = 0.0;
   15015            4 :                 report.HeatingToZoneRate = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15016            4 :                 report.HeatingToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15017              :             }
   15018            5 :             report.TotCoolingToZoneRate = report.SenCoolingToZoneRate + report.LatCoolingToZoneRate;
   15019            5 :             report.TotCoolingToZoneEnergy = report.SenCoolingToZoneEnergy + report.LatCoolingToZoneEnergy;
   15020            5 :             report.TotHtXferToZoneRate =
   15021            5 :                 state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone + state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15022            5 :             report.TotHtXferToZoneEnergy = report.TotHtXferToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15023              :         } // over zones for cases and walkins
   15024              :     }
   15025            5 : }
   15026              : 
   15027       250036 : void CheckRefrigerationInput(EnergyPlusData &state)
   15028              : {
   15029              : 
   15030              :     // SUBROUTINE INFORMATION:
   15031              :     //       AUTHOR         Linda Lawrie
   15032              :     //       DATE WRITTEN   Sep 2010 - mining function
   15033              :     //       MODIFIED       na
   15034              :     //       RE-ENGINEERED  na
   15035              : 
   15036              :     // PURPOSE OF THIS SUBROUTINE:
   15037              :     // Provides the structure to get Refrigeration input so that
   15038              :     // it can be called from internally or outside the module.
   15039              : 
   15040       250036 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   15041              : 
   15042          150 :         GetRefrigerationInput(state);
   15043          150 :         SetupReportInput(state);
   15044          150 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   15045              : 
   15046          150 :         if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->HaveChillers)) {
   15047          145 :             state.dataRefrigCase->ManageRefrigeration = false;
   15048          145 :             return;
   15049              :         }
   15050            5 :         if ((!state.dataRefrigCase->HaveDetailedRefrig) && (!state.dataRefrigCase->HaveRefrigRacks) &&
   15051            0 :             (!state.dataRefrigCase->HaveDetailedTransRefrig)) {
   15052            0 :             state.dataRefrigCase->ManageRefrigeration = false;
   15053            0 :             return;
   15054              :         }
   15055              :     } // GetRefrigerationInputFlag
   15056              : }
   15057              : 
   15058            0 : void SimAirChillerSet(EnergyPlusData &state,
   15059              :                       std::string const &AirChillerSetName,
   15060              :                       int const ZoneNum,
   15061              :                       bool const FirstHVACIteration,
   15062              :                       Real64 &SysOutputProvided,
   15063              :                       Real64 &LatOutputProvided,
   15064              :                       int &AirChillerSetPtr // from ZoneEquipList(CurZoneEqNum)%EquipIndex(EquipPtr)
   15065              : )
   15066              : {
   15067              : 
   15068              :     // SUBROUTINE INFORMATION:
   15069              :     //       AUTHOR         Therese Stovall, ORNL
   15070              :     //       DATE WRITTEN   January 2011
   15071              :     //       MODIFIED       na
   15072              :     //       RE-ENGINEERED  na
   15073              : 
   15074              :     // PURPOSE OF THIS SUBROUTINE:
   15075              :     // Transfers the load requested from the zone to the refrigeration module.
   15076              :     // The load is met, partially met, or not met in the call to the detailed system solution
   15077              :     // METHODOLOGY EMPLOYED:
   15078              :     // Called from Zone Equipment Manager.
   15079              : 
   15080            0 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   15081            0 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15082              : 
   15083              :     int ChillerSetID;
   15084              :     Real64 RemainingOutputToCoolingSP; // Remaining requested load in zone
   15085              : 
   15086            0 :     CheckRefrigerationInput(state);
   15087              : 
   15088              :     // Find the correct Chiller set
   15089            0 :     if (AirChillerSetPtr == 0) {
   15090            0 :         ChillerSetID = Util::FindItemInList(AirChillerSetName, AirChillerSet);
   15091            0 :         if (ChillerSetID == 0) {
   15092            0 :             ShowFatalError(state, format("SimAirChillerSet: Unit not found={}", AirChillerSetName));
   15093              :         } // chillersetid ==0 because not in list
   15094            0 :         AirChillerSetPtr = ChillerSetID;
   15095              :     } else { // airchllersetpointer passed in call to subroutine not ==0
   15096            0 :         ChillerSetID = AirChillerSetPtr;
   15097            0 :         if (ChillerSetID > state.dataRefrigCase->NumRefrigChillerSets || ChillerSetID < 1) {
   15098            0 :             ShowFatalError(state,
   15099            0 :                            format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Number of Units={}, Entered Unit name={}",
   15100              :                                   ChillerSetID,
   15101            0 :                                   state.dataRefrigCase->NumRefrigChillerSets,
   15102              :                                   AirChillerSetName));
   15103              :         } // ChillerSetID makes no sense
   15104            0 :         if (state.dataRefrigCase->CheckChillerSetName(ChillerSetID)) {
   15105            0 :             if (AirChillerSetName != AirChillerSet(ChillerSetID).Name) {
   15106            0 :                 ShowFatalError(state,
   15107            0 :                                format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Unit name={}, stored Unit Name for that index={}",
   15108              :                                       ChillerSetID,
   15109              :                                       AirChillerSetName,
   15110            0 :                                       AirChillerSet(ChillerSetID).Name));
   15111              :             } // name not equal correct name
   15112            0 :             state.dataRefrigCase->CheckChillerSetName(ChillerSetID) = false;
   15113              :         } // CheckChillerSetName logical test
   15114              :     }     //(AirChillerSetPtr == 0 or else not == 0
   15115              : 
   15116            0 :     if (FirstHVACIteration) {
   15117            0 :         for (ChillerSetID = 1; ChillerSetID <= state.dataRefrigCase->NumRefrigChillerSets;
   15118              :              ++ChillerSetID) { // bbb what point of do loop, only set one (airchillersetptr) to zero
   15119            0 :             AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15120              :         }
   15121              :     } // FirstHVACIteration
   15122              : 
   15123            0 :     RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
   15124              :     // RemainingOutputToCoolingSP in Watts, < 0 for cooling demand
   15125              : 
   15126            0 :     if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) {
   15127            0 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = RemainingOutputToCoolingSP;
   15128              :     } else {
   15129            0 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15130              :     }
   15131              : 
   15132            0 :     state.dataRefrigCase->UseSysTimeStep = true;
   15133              : 
   15134            0 :     ManageRefrigeratedCaseRacks(state);
   15135              : 
   15136            0 :     state.dataRefrigCase->UseSysTimeStep = false;
   15137              : 
   15138              :     // Return values to Zone Equipment Manager.
   15139            0 :     LatOutputProvided = CoilSysCredit(ZoneNum).LatKgPerS_ToZoneRate;
   15140            0 :     SysOutputProvided = CoilSysCredit(ZoneNum).SenCreditToZoneRate;
   15141            0 : }
   15142              : 
   15143            0 : void AirChillerSetData::CalculateAirChillerSets(EnergyPlusData &state)
   15144              : {
   15145              : 
   15146              :     // SUBROUTINE INFORMATION:
   15147              :     //       AUTHOR         Therese Stovall, ORNL
   15148              :     //       DATE WRITTEN   January 2011
   15149              :     //       MODIFIED       na
   15150              :     //       RE-ENGINEERED  na
   15151              : 
   15152              :     // PURPOSE OF THIS SUBROUTINE:
   15153              :     // Transfers the load requested from the zone to the refrigeration module.
   15154              :     // The load is met, partially met, or not met in the next time step when the refrigerated case
   15155              :     // module is called via case credits. Therefore, by definition, the sensible and latent
   15156              :     // output provided are zero.
   15157              :     // METHODOLOGY EMPLOYED:
   15158              :     // Called from Zone Equipment Manager.
   15159              :     //       have however done the variable definitions for in and out.
   15160              : 
   15161            0 :     Real64 AirChillerSetSchedule = 0.0; // Schedule value for air chiller SET
   15162            0 :     Real64 QZNReqSens = 0.0;            // Amount of sensible heat needed by the zone, NEGATIVE when cooling needed [W]
   15163            0 :     Real64 RemainQZNReqSens = 0.0;      // Remaining amount of sensible heat needed by the zone [W]
   15164              : 
   15165            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15166              : 
   15167              :     // Note, all coils in a coil set are in the same zone
   15168              :     // the coils may be served by different detailed systems
   15169              :     // The coils are dispatched to meet the load specified in the previous time step in order listed in coilset object
   15170            0 :     AirChillerSetSchedule = this->availSched->getCurrentVal();
   15171              : 
   15172            0 :     if (AirChillerSetSchedule <= 0.0) return;
   15173            0 :     QZNReqSens = this->QZnReqSens;
   15174            0 :     RemainQZNReqSens = QZNReqSens;
   15175              : 
   15176            0 :     for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15177            0 :         int CoilID = this->CoilNum(CoilIndex);
   15178              : 
   15179            0 :         WarehouseCoil(CoilID).CalculateCoil(state, RemainQZNReqSens);
   15180            0 :         RemainQZNReqSens += WarehouseCoil(CoilID).SensCreditRate;
   15181              :         // should be a negative minus a negative, so a smaller negative, that is, going toward zero, but senscoolingenergyrate expressed as
   15182              :         // 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
   15183              :         // particular time step  IF(RemainQZNReqSens >=0.0d0)EXIT  !shouldn't be > 0 because limited by request in calculatecoil
   15184            0 :         if (RemainQZNReqSens > 0.0) RemainQZNReqSens = 0.0;
   15185              :     } // CoilIndex
   15186              : }
   15187              : 
   15188            0 : void FinalRateCoils(EnergyPlusData &state,
   15189              :                     bool const DeRate,                 // True if compressor rack or secondary ht exchanger unable to provide capacity
   15190              :                     SourceType const SystemSourceType, // Secondarysystem or DetailedSystem
   15191              :                     int const SystemID,                // ID for Secondary loop or detailed system calling for derate
   15192              :                     Real64 const InitialTotalLoad,     // Load on system or secondary loop as initially calculated [W]
   15193              :                     Real64 const AvailableTotalLoad    // Load that system or secondary loop is able to serve [W]
   15194              : )
   15195              : {
   15196              : 
   15197              :     // SUBROUTINE INFORMATION:
   15198              :     //       AUTHOR         Therese Stovall, ORNL
   15199              :     //       DATE WRITTEN   January 2011
   15200              :     //       MODIFIED       na
   15201              :     //       RE-ENGINEERED  na
   15202              : 
   15203              :     // PURPOSE OF THIS SUBROUTINE:
   15204              :     // When compressor system, or secondary loop capacity is insufficient to meet coil loads
   15205              :     //   Come back here and derate the coil case credits to show unmet load impact
   15206              :     //   Note that the coil fan, heater, and defrost would be unaffected because they
   15207              :     //   would still be running at level calculated previously
   15208              : 
   15209            0 :     auto &System = state.dataRefrigCase->System;
   15210            0 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15211              : 
   15212            0 :     int NumCoils = 0;
   15213            0 :     Real64 DeRateFactor = 0.0;        // Ratio of energy available from system or secondary loop
   15214            0 :     Real64 InitLatCreditEnergy = 0.0; // Latent credit energy before derate [W]
   15215            0 :     Real64 FrostReduction = 0.0;      // Change in frost on coils based on derated latent load [kg]
   15216              : 
   15217              :     {
   15218            0 :         switch (SystemSourceType) {
   15219            0 :         case SourceType::DetailedSystem:
   15220            0 :             NumCoils = System(SystemID).NumCoils;
   15221            0 :             break;
   15222            0 :         case SourceType::SecondarySystem:
   15223            0 :             NumCoils = state.dataRefrigCase->Secondary(SystemID).NumCoils;
   15224            0 :             break;
   15225            0 :         default:
   15226            0 :             assert(false);
   15227              :         }
   15228              :     } // DeRateCoils
   15229              : 
   15230            0 :     if (DeRate) {
   15231            0 :         ShowRecurringWarningErrorAtEnd(
   15232              :             state,
   15233            0 :             "Refrigeration:System chilling WarehouseCoils " + System(SystemID).Name +
   15234              :                 " - Refrigeration system unable to meet load of warehouse coils chilled by system ... continues by derating coil load",
   15235            0 :             System(SystemID).InsuffCapWarn);
   15236              : 
   15237            0 :         DeRateFactor = AvailableTotalLoad / InitialTotalLoad;
   15238            0 :         Real64 const time_step_sec(state.dataHVACGlobal->TimeStepSysSec);
   15239            0 :         for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
   15240            0 :             int CoilID = System(SystemID).CoilNum(CoilIndex);
   15241            0 :             auto &warehouse_coil = WarehouseCoil(CoilID);
   15242              : 
   15243              :             // need to adjust ice on coil due to reduction in latent load met by coil
   15244            0 :             InitLatCreditEnergy = warehouse_coil.LatCreditEnergy;
   15245              : 
   15246            0 :             warehouse_coil.TotalCoolingLoad *= DeRateFactor;
   15247            0 :             warehouse_coil.TotalCoolingEnergy *= DeRateFactor;
   15248            0 :             warehouse_coil.SensCoolingEnergyRate *= DeRateFactor;
   15249            0 :             warehouse_coil.SensCoolingEnergy *= DeRateFactor;
   15250            0 :             warehouse_coil.LatCreditRate *= DeRateFactor;
   15251            0 :             warehouse_coil.LatCreditEnergy *= DeRateFactor;
   15252            0 :             warehouse_coil.LatKgPerS_ToZone *= DeRateFactor;
   15253            0 :             warehouse_coil.SensCreditRate = warehouse_coil.SensCoolingEnergyRate - warehouse_coil.ElecFanPower - warehouse_coil.ElecHeaterPower -
   15254            0 :                                             warehouse_coil.ThermalDefrostPower;
   15255            0 :             warehouse_coil.SensCreditEnergy = warehouse_coil.SensCreditRate * time_step_sec;
   15256              : 
   15257            0 :             FrostReduction = (InitLatCreditEnergy - warehouse_coil.LatCreditEnergy) / IcetoVaporEnthalpy;
   15258            0 :             warehouse_coil.KgFrost = max(0.0, warehouse_coil.KgFrost - FrostReduction);
   15259              : 
   15260            0 :             if (warehouse_coil.SensCreditRate >= 0.0) {
   15261            0 :                 warehouse_coil.ReportSensCoolCreditRate = warehouse_coil.SensCreditRate;
   15262            0 :                 warehouse_coil.ReportHeatingCreditRate = 0.0;
   15263              :             } else {
   15264            0 :                 warehouse_coil.ReportSensCoolCreditRate = 0.0;
   15265            0 :                 warehouse_coil.ReportHeatingCreditRate = -warehouse_coil.SensCreditRate;
   15266              :             }
   15267            0 :             warehouse_coil.ReportSensCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditRate * time_step_sec;
   15268            0 :             warehouse_coil.ReportHeatingCreditEnergy = warehouse_coil.ReportHeatingCreditRate * time_step_sec;
   15269            0 :             warehouse_coil.ReportTotalCoolCreditRate = warehouse_coil.ReportSensCoolCreditRate + warehouse_coil.LatCreditRate;
   15270            0 :             warehouse_coil.ReportTotalCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditEnergy + warehouse_coil.LatCreditEnergy;
   15271              :         }
   15272              :     } // DeRate == true
   15273            0 : }
   15274              : 
   15275            0 : void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq)
   15276              : {
   15277              : 
   15278              :     // SUBROUTINE INFORMATION:
   15279              :     //       AUTHOR         Therese Stovall, ORNL
   15280              :     //       DATE WRITTEN   January 2011
   15281              :     //       MODIFIED       na
   15282              :     //       RE-ENGINEERED  na
   15283              : 
   15284              :     // PURPOSE OF THIS SUBROUTINE:
   15285              :     // Simulates the refrigerated warehouse coil object.
   15286              :     // Note QZnReq < 0 corresponds to cooling needed
   15287              : 
   15288              :     // METHODOLOGY EMPLOYED:
   15289              :     // Called from Calculate Air Chiller Set.
   15290              :     // Air chillers are used to model the type of equipment typically used in
   15291              :     // refrigerated warehouses. For that reason, there is a major difference
   15292              :     // between the air chiller model and those for refrigerated cases or walk-ins.
   15293              :     // For cases and walk-ins, a portion of the model is directed toward
   15294              :     // calculating the amount of refrigeration needed to maintain the refrigerated
   15295              :     // volume at the desired temperature due to heat exchange with the surrounding
   15296              :     // zone, and that zone is conditioned to a nearly constant temperature.
   15297              :     // In a refrigerated warehouse, the refrigeration load is caused by heat exchange
   15298              :     // with a variable external environment.  For that reason, the loads for these
   15299              :     // zones are calculated by the usual EnergyPlus zone heat balance.
   15300              :     // The amount of refrigeration needed to maintain the specified temperature
   15301              :     // setpoints is then passed to the air chiller model, in a similar fashion
   15302              :     // to the load passed to a window air conditioner model. The air chillers
   15303              :     // are therefore solved using the system time step, not the zone time step
   15304              :     // used for cases and walk-ins.
   15305              :     // The air chiller performance is based on three types of manufacturers ratings,
   15306              :     // Unit Load Factor, Total Capacity Map, or a set of European standards.
   15307              :     // Correction factors for material and refrigerant are applied to all of these ratings.
   15308              : 
   15309              :     static constexpr std::string_view TrackMessage("from RefrigeratedCase:CalculateCoil");
   15310              : 
   15311            0 :     Real64 CoilSchedule = this->availSched->getCurrentVal(); // Current value of Coil operating (availability) schedule
   15312            0 :     if (CoilSchedule <= 0.0) return;
   15313              : 
   15314            0 :     Real64 DefrostSchedule = this->defrostSched->getCurrentVal();                 // Coil defrost schedule, between 0 and 1
   15315            0 :     Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal(); // Coil drip-down schedule (allows coil to drain after defrost)
   15316              :     // next statement In case user doesn't understand concept of drip down schedule
   15317            0 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   15318              :     // next value optional, so set to default before checking for schedule
   15319            0 :     Real64 HeaterSchedule = 1.0; // zero to one
   15320            0 :     if (this->heaterAvailSched != nullptr) HeaterSchedule = this->heaterAvailSched->getCurrentVal();
   15321              : 
   15322              :     // Set local subroutine variables for convenience
   15323            0 :     FanSpeedCtrlType FanSpeedControlType = this->FanType;
   15324            0 :     Real64 AirVolumeFlowRated = this->RatedAirVolumeFlow;   // Coil rated air flow (m3/s)
   15325            0 :     Real64 FanPowerRated = this->RatedFanPower;             // (W)
   15326            0 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   15327            0 :     Real64 DefrostCap = this->DefrostCapacity;              // Design defrost capacity of Coil (W)
   15328            0 :     Real64 TEvap = this->TEvapDesign;                       // Evaporating temperature in the coil (C)
   15329              : 
   15330            0 :     Real64 CoilCapTotEstimate(0.0); // Part of loop to solve for total coil capacity as a function of inlet air conditions (W)
   15331            0 :     Real64 AirVolumeFlowMax(0.0);   // Coil air flow limited by drip down schedule (m3/s)
   15332            0 :     Real64 CoilCapTotal(0.0);       // Sensible plus latent load (W)
   15333            0 :     Real64 CoilInletDensity(0.0);   // Coil air inlet density (kg/m3)
   15334            0 :     Real64 CoilInletDryAirCp(0.0);  // Dry air specific heat at coil inlet temperature (J/kg-C)
   15335            0 :     Real64 CoilInletHumRatio(0.0);  // Coil air inlet humidity ratio (kg water/kg air)
   15336            0 :     Real64 CoilInletTemp(0.0);      // Inlet temperature of air to coil, not mixed zone temperature unless "middle" location selected (C)
   15337            0 :     Real64 CoilInletEnthalpy(0.0);  // Coil inlet air enthalpy (J/kg)
   15338            0 :     Real64 CoilInletRHFrac(0.0);    // Coil inlet air relative humidity expressed as a fraction (0 to 1)
   15339            0 :     Real64 DefrostLoad(0.0);
   15340            0 :     Real64 DryAirMassFlowMax(0.0);      // Rated volume flow rate times dry air density adjusted for schedules (kg/s)
   15341            0 :     Real64 FanPowerActual(0.0);         // (W)
   15342            0 :     Real64 FrostChangekg(0.0);          // Amount of frost added or melted  (kg)
   15343            0 :     Real64 latLoadServed(0.0);          // Energy rate used to remove water from zone air (W)
   15344            0 :     Real64 SensLoadRequestedGross(0.0); // Gross sensible load removed by coil
   15345            0 :     Real64 SensLoadGross(0.0);          // Sensible load met by coil (W)
   15346            0 :     Real64 SHR(0.0);                    // Sensible heat ratio, sensible load/total load
   15347            0 :     Real64 SHRCorrection(0.0);          // Actual total/sensible load, NOT = Inverse SHR (unless coil efficiency = 1.0)
   15348            0 :     Real64 WaterRemovRate(0.0);         // Walk in cooler removes water at this rate in this zone (kg/s)
   15349              : 
   15350            0 :     if (DefrostDripDownSchedule == 1.0) {
   15351            0 :         AirVolumeFlowMax = 0.0;
   15352            0 :         DryAirMassFlowMax = 0.0;
   15353              :     } else { // DefrostDripDownSchedule < 1.0d0, cooling will occur at least part of the time step
   15354              :         // Sensible load requested by zone balance (W)
   15355            0 :         Real64 SensLoadRequested = -QZnReq; // here let cooling demand be positive within subroutine
   15356            0 :         if (SensLoadRequested <= 0.0) {     // No load so assume control keeps off, except that scheduled defrost still occurs
   15357            0 :             AirVolumeFlowMax = 0.0;
   15358            0 :             DryAirMassFlowMax = 0.0;
   15359              :         } else {
   15360            0 :             SensLoadRequestedGross = SensLoadRequested + HeaterLoad + FanPowerRated;
   15361            0 :             Real64 ZoneMixedAirDryBulb = state.dataLoopNodes->Node(this->ZoneNodeNum).Temp;    // (C)
   15362            0 :             Real64 ZoneMixedAirHumRatio = state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat; // kg water/kg air in the zone mixed air
   15363              :             Real64 ZoneMixedAirRHFrac =
   15364            0 :                 Psychrometrics::PsyRhFnTdbWPb(state, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, state.dataEnvrn->OutBaroPress, TrackMessage);
   15365              :             Real64 ZoneMixedAirEnthalpy =
   15366            0 :                 Psychrometrics::PsyHFnTdbRhPb(state, ZoneMixedAirDryBulb, ZoneMixedAirRHFrac, state.dataEnvrn->OutBaroPress, TrackMessage);
   15367              :             Real64 ZoneMixedAirDensity =
   15368            0 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, TrackMessage);
   15369              :             Real64 ZoneDryAirDensity =
   15370            0 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, 0.0, TrackMessage);
   15371            0 :             Real64 DryAirMassFlowRated = AirVolumeFlowRated * ZoneDryAirDensity;
   15372              :             // calc t inlet to coil assuming at middle/mixed point in room  bbb -
   15373              :             //    later need to do for hottest/coolest in room where Tin /= Tzonemixed
   15374              :             // calc RH inlet to coil assuming at middle/mixed point in room
   15375              :             // calc coilcap, sens and latent, available as f(inlet T,RH)
   15376            0 :             switch (this->VerticalLocation) {
   15377            0 :             case VerticalLoc::Floor:
   15378              :                 // purposely fall through
   15379              :             case VerticalLoc::Ceiling:
   15380              :                 // purposely fall through
   15381              :             case VerticalLoc::Middle:
   15382            0 :                 CoilInletTemp = ZoneMixedAirDryBulb;
   15383            0 :                 CoilInletEnthalpy = ZoneMixedAirEnthalpy;
   15384            0 :                 CoilInletRHFrac = ZoneMixedAirRHFrac;
   15385            0 :                 CoilInletDensity = ZoneMixedAirDensity;
   15386            0 :                 CoilInletHumRatio = ZoneMixedAirHumRatio;
   15387            0 :                 CoilInletDryAirCp = Psychrometrics::PsyCpAirFnW(0.0);
   15388            0 :                 break;
   15389            0 :             default:
   15390            0 :                 assert(false);
   15391              :             }
   15392            0 :             AirVolumeFlowMax = AirVolumeFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15393            0 :             DryAirMassFlowMax = DryAirMassFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15394              : 
   15395              :         } // Sens load requested is non-zero
   15396              :     }     // DefrostDripDownSchedule == 1.0d0
   15397              : 
   15398            0 :     if (AirVolumeFlowMax > 0.0) {
   15399              : 
   15400              :         Real64 TemperatureDif =
   15401            0 :             min(this->MaxTemperatureDif, (CoilInletTemp - TEvap)); // difference between inlet air and evaporating temperature (deltaC)
   15402              : 
   15403            0 :         if (this->ratingType == RatingType::RatedCapacityTotal) {
   15404              :             // RatingType = CapacityTotalSpecificConditions, will be doing a table lookup
   15405              :             //    based upon RHInlet, DT1, CoilInletTemperature - see excel files from B. Nelson, CoilCom
   15406              :             //    In the table, X1== inlet air dry bulb temperature
   15407              :             //                  X2== Difference between inlet T and evap T
   15408              :             //                  X3== RH expressed as decimal
   15409            0 :             CoilCapTotEstimate = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, CoilInletTemp, TemperatureDif, CoilInletRHFrac) *
   15410            0 :                                  this->RatedCapTotal * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15411              : 
   15412              :         } else { // work with unit load factor (sensible only), function of DT1 (Tair in drybulb-Tevap)
   15413            0 :             Real64 SensibleCapacityMax = this->UnitLoadFactorSens * TemperatureDif * (1.0 - DefrostDripDownSchedule) *
   15414              :                                          CoilSchedule; // Sensible capacity adjusted for any time in dripdown state (W)
   15415              : 
   15416            0 :             if (SensibleCapacityMax > 0.0) {
   15417            0 :                 Real64 ExitTemperatureEstimate =
   15418            0 :                     CoilInletTemp - (SensibleCapacityMax / (DryAirMassFlowMax * CoilInletDryAirCp)); // Estimated Air temperature leaving the coil (C)
   15419            0 :                 if (ExitTemperatureEstimate <= TEvap) {
   15420            0 :                     ShowWarningError(state, format("{}Refrigeration:AirCoil: {}", TrackMessage, this->Name));
   15421            0 :                     ShowContinueError(state, " The estimated air outlet temperature is less than the evaporating temperature.");
   15422              :                 }
   15423            0 :                 Real64 ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbRhPb(state,
   15424              :                                                                             ExitTemperatureEstimate,
   15425              :                                                                             1.0,
   15426            0 :                                                                             state.dataEnvrn->OutBaroPress,
   15427              :                                                                             TrackMessage); // Estimated Air enthalpy leaving the coil (J/kg)
   15428            0 :                 if (ExitEnthalpyEstimate <= CoilInletEnthalpy) {
   15429            0 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   15430              :                 } else {
   15431              :                     // Assume no water is extracted from flow
   15432            0 :                     ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbW(ExitTemperatureEstimate, CoilInletHumRatio);
   15433            0 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   15434              :                 }
   15435            0 :                 if (SensibleCapacityMax > CoilCapTotEstimate) SensibleCapacityMax = CoilCapTotEstimate;
   15436            0 :                 if (std::abs(CoilCapTotEstimate) > 0.0) {
   15437            0 :                     SHR = SensibleCapacityMax / (CoilCapTotEstimate);
   15438              :                 } else {
   15439              :                     // will occur whenever defrost or dripdown
   15440            0 :                     SHR = 0.0;
   15441              :                 }
   15442              : 
   15443            0 :                 switch (this->SHRCorrType) {
   15444            0 :                 case SHRCorrectionType::SHR60: {
   15445              :                     // line from y = SHRCorrection60 value to 1. as x(SHR) goes from .6 to 1, from B. Nelson, ASHRAE August 2010
   15446            0 :                     Real64 Slope = (this->SHRCorrection60 - 1.0) / (0.6 - 1.0); // Part of linear SHR60 correction factor, dimensionless
   15447            0 :                     Real64 Yint = this->SHRCorrection60 - (Slope * 0.6);        // Part of linear SHR60 correction factor, dimensionless
   15448            0 :                     SHRCorrection = Slope * SHR + Yint;
   15449            0 :                 } break;
   15450            0 :                 case SHRCorrectionType::QuadraticSHR: {
   15451            0 :                     SHRCorrection = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, SHR);
   15452            0 :                 } break;
   15453            0 :                 case SHRCorrectionType::European: {
   15454              :                     // With European ratings, either start with rated total sensible capacity or rated total capacity
   15455              :                     //    If rated total capacity is used, 'get input'
   15456              :                     //    translated it to rated total sensible capacity using
   15457              :                     //    PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   15458              :                     //    That sensible capacity rating was then turned to a rated UnitLoadFactor using
   15459              :                     //    the rated temperature difference. That sensible rating was also corrected
   15460              :                     //    for refrigerant and fin material in 'get input' and is given as UnitLoadFactor
   15461              :                     //  The total (sens + latent) capacity is equal to that * DT1 * WetCoilFactor(TcoilIn)
   15462              :                     //    Sensible capacity max already has DT1, just need WetCoilFactor(TcoilIn)
   15463              :                     // PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   15464              :                     // PARAMETER ::EuropeanAirInletTemp  = (/10.0D0,  0.0D0, -18.0D0, -25.0D0, -34.0D0/)
   15465              :                     // PARAMETER ::EuropeanEvapTemp      = (/ 0.0D0, -8.0D0, -25.0D0, -31.0D0, -40.0D0/)
   15466              :                     // PARAMETER ::EuropeanDT1           = (/10.0D0,  8.0D0,   7.0D0,   7.0D0,   6.0D0/)
   15467            0 :                     if (CoilInletTemp <= -25.0) {
   15468            0 :                         SHRCorrection = 1.0;
   15469            0 :                     } else if (CoilInletTemp > -25.0 && CoilInletTemp <= 0.0) {
   15470            0 :                         SHRCorrection = (EuropeanWetCoilFactor[1] - EuropeanWetCoilFactor[3]) / (EuropeanAirInletTemp[1] - EuropeanAirInletTemp[3]) *
   15471            0 :                                             (EuropeanAirInletTemp[1] - CoilInletTemp) +
   15472            0 :                                         EuropeanWetCoilFactor[3];
   15473            0 :                     } else if (CoilInletTemp > 0.0 && CoilInletTemp <= 5.0) {
   15474            0 :                         SHRCorrection = (EuropeanWetCoilFactor[0] - EuropeanWetCoilFactor[1]) / (EuropeanAirInletTemp[0] - EuropeanAirInletTemp[1]) *
   15475            0 :                                             (EuropeanAirInletTemp[0] - CoilInletTemp) +
   15476            0 :                                         EuropeanWetCoilFactor[1];
   15477            0 :                     } else if (CoilInletTemp > 5.0) {
   15478            0 :                         SHRCorrection = EuropeanWetCoilFactor[0];
   15479              :                     } // calc correction as a function of coil inlet temperature
   15480            0 :                 } break;
   15481            0 :                 default:
   15482            0 :                     break;
   15483              :                 }
   15484            0 :                 CoilCapTotEstimate = SHRCorrection * SensibleCapacityMax;
   15485              :             } else { // NOT (SensibleCapacityMax > 0.0d0)
   15486            0 :                 CoilCapTotEstimate = 0.0;
   15487              :             } //  (SensibleCapacityMax > 0.0d0)
   15488              :         }     // Rating type : CapacityTotalSpecificConditions or Sensible Unit Load Factor
   15489              : 
   15490            0 :         if (CoilCapTotEstimate > 0.0) {
   15491            0 :             Real64 ExitEnthalpy =
   15492            0 :                 CoilInletEnthalpy - (CoilCapTotEstimate / (AirVolumeFlowMax * CoilInletDensity)); // Air enthalpy leaving the coil (J/kg)
   15493            0 :             Real64 ExitTemperature = Psychrometrics::PsyTsatFnHPb(
   15494            0 :                 state, ExitEnthalpy, state.dataEnvrn->OutBaroPress, TrackMessage); // RH =1.0 at Tsat // Air temperature leaving the coil (C)
   15495            0 :             Real64 ExitHumRatio = Psychrometrics::PsyWFnTdbH(state, ExitTemperature, ExitEnthalpy, TrackMessage); // kg water/kg air
   15496            0 :             if (ExitHumRatio > CoilInletHumRatio) ExitHumRatio = CoilInletHumRatio;
   15497            0 :             WaterRemovRate = DryAirMassFlowMax * (CoilInletHumRatio - ExitHumRatio);
   15498            0 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   15499            0 :             SensLoadGross = CoilCapTotEstimate - latLoadServed;
   15500            0 :             FanPowerActual = FanPowerRated;
   15501            0 :             if (SensLoadGross < 0.0) {
   15502              :                 // Could rarely happen during initial cooldown of a warm environment
   15503            0 :                 SensLoadGross = 0.0;
   15504            0 :                 latLoadServed = CoilCapTotEstimate;
   15505            0 :                 WaterRemovRate = latLoadServed / IcetoVaporEnthalpy;
   15506              :             }    // SensLoadGross < 0
   15507              :         } else { // NOT (SensibleCapacityMax > 0.0d0)
   15508            0 :             WaterRemovRate = 0.0;
   15509            0 :             latLoadServed = 0.0;
   15510            0 :             SensLoadGross = 0.0;
   15511            0 :             FanPowerActual = 0.0;
   15512              :         } //(CoilCapTotEstimate > 0.0d0)
   15513              : 
   15514            0 :         Real64 FanPowerMax = FanPowerRated * (1.0 - DefrostDripDownSchedule); // Total fan energy rate, limited by dripdown period (W)
   15515            0 :         if (SensLoadGross > SensLoadRequestedGross) {                         // part load operation
   15516              :             // don't need full chiller power, reduce fan speed to reduce air flow
   15517              :             // move fan to part power if need to
   15518            0 :             Real64 CapFac = SensLoadRequestedGross / SensLoadGross; // used to reduce fan power when don't need full coil capacity
   15519            0 :             Real64 AirVolRatio = max(this->FanMinAirFlowRatio, std::pow(CapFac, EvaporatorAirVolExponent)); // used when operating at part load
   15520              :             // Fans limited by minimum air flow ratio
   15521              : 
   15522            0 :             switch (FanSpeedControlType) {
   15523            0 :             case FanSpeedCtrlType::VariableSpeed: {                // fan power law, adjusted for reality, applies
   15524            0 :                 Real64 FanPowerRatio = std::pow(AirVolRatio, 2.5); // Used for variable speed fans, dimensionless
   15525            0 :                 FanPowerActual = FanPowerRatio * FanPowerMax;
   15526            0 :             } break;
   15527            0 :             case FanSpeedCtrlType::ConstantSpeed: {
   15528            0 :                 FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   15529            0 :             } break;
   15530            0 :             case FanSpeedCtrlType::ConstantSpeedLinear: { // e.g., on-off control
   15531            0 :                 FanPowerActual = AirVolRatio * FanPowerMax;
   15532            0 :             } break;
   15533            0 :             case FanSpeedCtrlType::TwoSpeed: {
   15534              :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   15535              :                 // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   15536              :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   15537            0 :                 if (CapFac < CapFac60Percent) {
   15538            0 :                     FanPowerActual = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   15539              :                 } else {
   15540            0 :                     FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   15541              :                 } // capfac60percent
   15542            0 :             } break;
   15543            0 :             default:
   15544            0 :                 break;
   15545              :             } // fan speed control type
   15546              : 
   15547              :             // reduce latent capacity according to value called for for sensible  - recalc latent.
   15548              :             //   recalc coilcaptotal
   15549            0 :             WaterRemovRate *= AirVolRatio;
   15550            0 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   15551            0 :             SensLoadGross = SensLoadRequestedGross;
   15552              :         } else { // at full load
   15553            0 :             FanPowerActual = FanPowerMax;
   15554              :         } // part load and sensload served > 0.
   15555              : 
   15556            0 :         CoilCapTotal = SensLoadGross + latLoadServed;
   15557            0 :         if (CoilCapTotal > 0.0) {
   15558            0 :             SHR = SensLoadGross / CoilCapTotal;
   15559              :         } else {
   15560            0 :             SHR = 0.0;
   15561              :         } //(CoilCapTotal > 0.0d0)
   15562              : 
   15563              :         // now handle ice on coil and defrost because defrost energy not into melting ice goes into sensible load
   15564              :         // FROST:  keep track of frost build up on evaporator coil
   15565              :         //         avoid accumulation during warm-up to avoid reverse dd test problem
   15566            0 :         if (!state.dataGlobal->WarmupFlag) {
   15567            0 :             FrostChangekg = (WaterRemovRate * state.dataHVACGlobal->TimeStepSysSec);
   15568            0 :             this->KgFrost += FrostChangekg;
   15569              :         }
   15570              : 
   15571              :     } else { // NOT (AirVolumeFlowMax > 0.0d0)
   15572            0 :         WaterRemovRate = 0.0;
   15573            0 :         latLoadServed = 0.0;
   15574            0 :         SensLoadGross = 0.0;
   15575            0 :         FanPowerActual = 0.0;
   15576              :     } //(AirVolumeFlowMax > 0.0d0)
   15577              : 
   15578              :     // DEFROST CALCULATIONS   ***** need to reduce sensible heat to zone from
   15579              :     //                     defrost by amount used to melt ice. Last two elements
   15580              :     //                     in starting IF are there to mimic temperature override
   15581              :     //                     on the coils that stops defrost if the coils get above
   15582              :     //                     a certain temperature (such as when there's no load and no ice)
   15583            0 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   15584            0 :         DefrostLoad = DefrostCap * DefrostSchedule;                                // Part of the defrost that is a heat load on the zone (W)
   15585            0 :         Real64 DefrostEnergy = DefrostLoad * state.dataHVACGlobal->TimeStepSysSec; // Joules
   15586            0 :         Real64 StartFrostKg = this->KgFrost;                                       // frost load at start of time step (kg of ice)
   15587              : 
   15588            0 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   15589              :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   15590              :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   15591              :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   15592              :             //  others and xfer heat to environment)
   15593              :             //  Assume full ice melting satisfies temperature control.
   15594              :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   15595            0 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // available to melt ice with temp term control (J)
   15596            0 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   15597            0 :             if (StartFrostKg > 0.0) {
   15598            0 :                 if (this->IceTemp < 0.0) {
   15599            0 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   15600            0 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   15601            0 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   15602            0 :                         this->IceTemp = 0.0;
   15603            0 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   15604              :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   15605            0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   15606            0 :                         AvailDefrostEnergy = 0.0;
   15607              :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   15608              :                 }     // IceTemp < 0,  need to raise temperature of ice
   15609              :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   15610            0 :                 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15611            0 :                 if (FrostChangekg < StartFrostKg) {
   15612            0 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   15613            0 :                     if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   15614              :                     // DefrostSchedule not changed because ice not all melted, temp term not triggered
   15615              :                 } else { // all frost melted during time step, so need to terminate defrost
   15616              :                     //  see Aug 8 2010 page 3 notes
   15617            0 :                     this->KgFrost = 0.0;
   15618            0 :                     Real64 DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   15619            0 :                                                  this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   15620            0 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (DefrostCap * state.dataHVACGlobal->TimeStepSysSec)));
   15621              :                     // reduce heat load on warehouse by energy put into ice melting
   15622              :                     // Defrost load that actually goes to melting ice (W)
   15623            0 :                     Real64 DefrostRateNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / (state.dataHVACGlobal->TimeStepSysSec);
   15624            0 :                     DefrostLoad = max(0.0, (DefrostSchedule * DefrostCap - DefrostRateNeeded));
   15625            0 :                     this->IceTemp = this->TEvapDesign;
   15626              :                 } // frost melted during time step less than amount of ice at start
   15627              :             } else {
   15628              :                 // no frost present so terminate defrost and reset ice temperature for start of next defrost
   15629              :                 // However, dripdown schedule still prevents/limits cooling capacity during time step
   15630            0 :                 DefrostLoad = 0.0;
   15631            0 :                 DefrostSchedule = 0.0;
   15632            0 :                 this->IceTemp = this->TEvapDesign;
   15633              :             } // have frost present
   15634              : 
   15635              :         } else {
   15636              :             // Not temperature control type, controlled only by schedule
   15637              :             // Reduce defrost heat load on the zone by amount of ice melted during time step
   15638              :             // But DefrostSchedule not changed
   15639            0 :             FrostChangekg = max(0.0, min((DefrostEnergy / IceMeltEnthalpy), StartFrostKg));
   15640            0 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   15641            0 :             if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   15642              :         } // Temperature termination vs. time-clock control type
   15643              : 
   15644            0 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   15645            0 :         DefrostLoad = 0.0;
   15646              :     } // Defrost calculations
   15647              : 
   15648            0 :     Real64 SensLoadFromZone = SensLoadGross - HeaterLoad - DefrostLoad -
   15649              :                               FanPowerActual; // Net sensible load removed from zone after accounting for heaters, fans, defrost [W]
   15650              : 
   15651              :     // ReportWarehouseCoil(CoilID)
   15652            0 :     this->ThermalDefrostPower = DefrostLoad;
   15653            0 :     if (this->defrostType == DefrostType::Elec) {
   15654            0 :         this->ElecDefrostConsumption = DefrostCap * DefrostSchedule * state.dataHVACGlobal->TimeStepSysSec;
   15655            0 :         this->ElecDefrostPower = DefrostCap * DefrostSchedule;
   15656              :     } else {
   15657            0 :         this->ElecDefrostConsumption = 0.0;
   15658            0 :         this->ElecDefrostPower = 0.0;
   15659              :     }
   15660              : 
   15661              :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   15662            0 :     if (this->defrostType == DefrostType::Fluid) this->HotDefrostCondCredit = DefrostCap * DefrostSchedule;
   15663              :     // LatentLoadServed is positive for latent heat removed from zone
   15664              :     // SensLoadFromZone positive for heat REMOVED from zone, switch when do credit to zone
   15665            0 :     this->SensCreditRate = SensLoadFromZone;
   15666            0 :     this->SensCreditEnergy = SensLoadFromZone * state.dataHVACGlobal->TimeStepSysSec;
   15667            0 :     this->LatCreditRate = latLoadServed;
   15668            0 :     this->LatCreditEnergy = latLoadServed * state.dataHVACGlobal->TimeStepSysSec;
   15669            0 :     this->LatKgPerS_ToZone = WaterRemovRate;
   15670            0 :     this->TotalCoolingLoad = CoilCapTotal;
   15671            0 :     this->TotalCoolingEnergy = CoilCapTotal * state.dataHVACGlobal->TimeStepSysSec;
   15672            0 :     this->SensCoolingEnergyRate = SensLoadGross;
   15673            0 :     this->SensCoolingEnergy = SensLoadGross * state.dataHVACGlobal->TimeStepSysSec;
   15674            0 :     this->SensHeatRatio = SHR;
   15675            0 :     this->ElecFanPower = FanPowerActual;
   15676            0 :     this->ElecFanConsumption = FanPowerActual * state.dataHVACGlobal->TimeStepSysSec;
   15677            0 :     this->ElecHeaterPower = HeaterLoad;
   15678            0 :     this->ElecHeaterConsumption = HeaterLoad * state.dataHVACGlobal->TimeStepSysSec;
   15679              : 
   15680            0 :     this->TotalElecPower = FanPowerActual + HeaterLoad + this->ElecDefrostPower;
   15681            0 :     this->TotalElecConsumption = this->TotalElecPower * state.dataHVACGlobal->TimeStepSysSec;
   15682              : 
   15683            0 :     if (this->SensCreditRate >= 0.0) {
   15684            0 :         this->ReportSensCoolCreditRate = this->SensCreditRate;
   15685            0 :         this->ReportHeatingCreditRate = 0.0;
   15686              :     } else {
   15687            0 :         this->ReportSensCoolCreditRate = 0.0;
   15688            0 :         this->ReportHeatingCreditRate = -this->SensCreditRate;
   15689              :     }
   15690            0 :     this->ReportSensCoolCreditEnergy = this->ReportSensCoolCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   15691            0 :     this->ReportHeatingCreditEnergy = this->ReportHeatingCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   15692            0 :     this->ReportTotalCoolCreditRate = this->ReportSensCoolCreditRate + this->LatCreditRate;
   15693            0 :     this->ReportTotalCoolCreditEnergy = this->ReportSensCoolCreditEnergy + this->LatCreditEnergy;
   15694              : 
   15695              :     //**************************************************************************************************
   15696              :     // Cap Kg Frost to avoid floating overflow errors
   15697              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   15698              : 
   15699            0 :     if (this->KgFrost > MyLargeNumber) {
   15700            0 :         this->KgFrost = MyLargeNumber;
   15701            0 :         if (this->ShowCoilFrostWarning) {
   15702            0 :             ShowWarningError(state, format("Refrigeration:AirCoil: {}", this->Name));
   15703            0 :             ShowContinueError(state, " This refrigerated air coil has insufficient defrost capacity to remove the excess frost accumulation.");
   15704            0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   15705            0 :             ShowContinueErrorTimeStamp(state, "... Occurrence info");
   15706            0 :             this->ShowCoilFrostWarning = false;
   15707              :         }
   15708              :     }
   15709              : }
   15710              : 
   15711       249958 : void FigureRefrigerationZoneGains(EnergyPlusData &state)
   15712              : {
   15713              : 
   15714              :     // SUBROUTINE INFORMATION:
   15715              :     //       AUTHOR         B. Griffith
   15716              :     //       DATE WRITTEN   Dec 2011
   15717              :     //       MODIFIED       na
   15718              :     //       RE-ENGINEERED  na
   15719              : 
   15720              :     // PURPOSE OF THIS SUBROUTINE:
   15721              :     // initialize zone gain terms at begin environment
   15722              : 
   15723       249958 :     auto &System = state.dataRefrigCase->System;
   15724       249958 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   15725       249958 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   15726       249958 :     auto &Secondary = state.dataRefrigCase->Secondary;
   15727       249958 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   15728       249958 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   15729              : 
   15730       249958 :     CheckRefrigerationInput(state);
   15731              : 
   15732       249958 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag) {
   15733              : 
   15734          483 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   15735            0 :             for (auto &e : System) {
   15736            0 :                 e.PipeHeatLoad = 0.0;
   15737            0 :                 e.NetHeatRejectLoad = 0.0;
   15738              :             }
   15739              :         }
   15740              : 
   15741          483 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   15742            0 :             for (auto &e : TransSystem) {
   15743            0 :                 e.PipeHeatLoadMT = 0.0;
   15744            0 :                 e.PipeHeatLoadLT = 0.0;
   15745            0 :                 e.NetHeatRejectLoad = 0.0;
   15746              :             }
   15747              :         }
   15748              : 
   15749          483 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   15750            0 :             for (auto &e : RefrigRack) {
   15751            0 :                 e.SensZoneCreditHeatRate = 0.0;
   15752            0 :                 e.SensHVACCreditHeatRate = 0.0;
   15753              :             }
   15754              :         }
   15755              : 
   15756          483 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   15757            0 :             for (auto &e : Secondary) {
   15758            0 :                 e.DistPipeZoneHeatGain = 0.0;
   15759            0 :                 e.ReceiverZoneHeatGain = 0.0;
   15760              :             }
   15761              :         }
   15762              : 
   15763          483 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   15764            0 :             for (int loop = 1; loop <= state.dataRefrigCase->NumSimulationWalkIns; ++loop) {
   15765            0 :                 WalkIn(loop).SensZoneCreditRate = 0.0;
   15766            0 :                 WalkIn(loop).LatZoneCreditRate = 0.0;
   15767              :             }
   15768              :         }
   15769          483 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   15770            0 :             for (auto &e : RefrigCase) {
   15771            0 :                 e.SensZoneCreditRate = 0.0;
   15772            0 :                 e.SensHVACCreditRate = 0.0;
   15773            0 :                 e.LatZoneCreditRate = 0.0;
   15774            0 :                 e.LatHVACCreditRate = 0.0;
   15775              :             }
   15776              :         }
   15777          483 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = false;
   15778              :     }
   15779       249958 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = true;
   15780       249958 : }
   15781              : 
   15782            0 : void ZeroHVACValues(EnergyPlusData &state)
   15783              : {
   15784              : 
   15785              :     // SUBROUTINE INFORMATION:
   15786              :     //       AUTHOR         T. Stovall
   15787              :     //       DATE WRITTEN   Aug 2012
   15788              :     //       MODIFIED       na
   15789              :     //       RE-ENGINEERED  na
   15790              : 
   15791              :     // PURPOSE OF THIS SUBROUTINE:
   15792              :     // Reset all values that communicate outside module for HVAC steps
   15793              :     // to zero when called on zone timestep. Otherwise, values may be held over when
   15794              :     // no HVAC load calls module during that zone time step.
   15795              : 
   15796            0 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   15797            0 :     auto &Condenser = state.dataRefrigCase->Condenser;
   15798              : 
   15799            0 :     int DemandARRID = 0; // Index to water tank Demand used for evap condenser
   15800              : 
   15801            0 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   15802              :         // HaveRefrigRacks is TRUE when NumRefrigeratedRAcks > 0
   15803              :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   15804            0 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   15805            0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   15806            0 :                 Real64 MassFlowRate = 0.0;
   15807            0 :                 PlantUtilities::SetComponentFlowRate(
   15808            0 :                     state, MassFlowRate, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).OutletNode, RefrigRack(RackNum).plantLoc);
   15809              :             }
   15810            0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   15811            0 :                 if (RefrigRack(RackNum).EvapWaterSupplyMode == WaterSupply::FromTank) {
   15812            0 :                     DemandARRID = RefrigRack(RackNum).EvapWaterTankDemandARRID;
   15813            0 :                     int TankID = RefrigRack(RackNum).EvapWaterSupTankID;
   15814            0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   15815              :                 }
   15816              :             }
   15817              :         } // RackNum
   15818              :     }     // HaveRefrigRacks
   15819              : 
   15820            0 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   15821              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   15822            0 :         for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
   15823            0 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   15824            0 :                 Real64 MassFlowRate = 0.0;
   15825            0 :                 PlantUtilities::SetComponentFlowRate(
   15826            0 :                     state, MassFlowRate, Condenser(CondID).InletNode, Condenser(CondID).OutletNode, Condenser(CondID).plantLoc);
   15827              :             }
   15828            0 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   15829            0 :                 if (Condenser(CondID).EvapWaterSupplyMode == WaterSupply::FromTank) {
   15830            0 :                     DemandARRID = Condenser(CondID).EvapWaterTankDemandARRID;
   15831            0 :                     int TankID = Condenser(CondID).EvapWaterSupTankID;
   15832            0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   15833              :                 }
   15834              :             }
   15835              :         } // ICond
   15836              :     }     // DataHeatBalance::NumRefrigCondensers>0
   15837            0 : }
   15838              : 
   15839              : } // namespace EnergyPlus::RefrigeratedCase
        

Generated by: LCOV version 2.0-1