LCOV - code coverage report
Current view: top level - EnergyPlus - RefrigeratedCase.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 5886 8442 69.7 %
Date: 2024-08-24 18:31:18 Functions: 39 41 95.1 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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 (extendible) 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     3160938 : void ManageRefrigeratedCaseRacks(EnergyPlusData &state)
     226             : {
     227             : 
     228             :     // SUBROUTINE INFORMATION:
     229             :     //       AUTHOR         Richard Raustad, FSEC
     230             :     //       DATE WRITTEN   Oct/Nov 2004
     231             :     //       MODIFIED       Shirey, FSEC Dec 2004, Stovall, ORNL, May 2008
     232             :     //       RE-ENGINEERED  na
     233             : 
     234             :     // PURPOSE OF THIS SUBROUTINE:
     235             :     // This subroutine is called from HVACManager.cc, subroutine ManageHVAC to
     236             :     // manage refrigerated cases and associated compressor racks on zone time step
     237             :     // OR from SimAirChillerSet in this module on sys time step (Stovall 2011)
     238             : 
     239             :     // METHODOLOGY EMPLOYED:
     240             :     // Each compressor rack is modeled by first simulating the attached refrigeration loads. The
     241             :     // loads can include refrigerated cases, walk-in coolers, and secondary fluid chillers.  The sum
     242             :     // of the total heat transfer for all attached loads determines the load on the compressor rack.
     243             :     // For the refrigeration rack approach, a simple model for variation of COP with
     244             :     // condensing temperature is used to determine rack power and energy consumption.
     245             :     // For the detailed system approach, the compressors and condensers are modeled individually
     246             :     // using manufacturer's data and rated performance curves.
     247             :     // Inter-system heat transfer via subcoolers and cascade condensers can be accommodated.
     248             :     // Secondary refrigeration cycles are also available.
     249             : 
     250     3160938 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     251             : 
     252     3160938 :     if (!state.dataRefrigCase->ManageRefrigeration) return;
     253             : 
     254      464446 :     CheckRefrigerationInput(state);
     255             : 
     256      464446 :     InitRefrigeration(state);
     257             : 
     258             :     // ManageRefrigeratedCaseRacks is called on each zone time step.
     259             :     //  However, if have chillers, ManageRefrigeration will be .TRUE. and will
     260             :     //  need to bounce back. (InitRefrig has to be called anyway to zero values at zone time step.)
     261             :     //  Therefore...
     262      464446 :     if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->UseSysTimeStep)) {
     263             :         // Zero requests for cooling water from plant or tank
     264        2891 :         ZeroHVACValues(state);
     265        2891 :         return;
     266             :     }
     267             :     // Following case should never occur, but just for completeness:
     268      461555 :     if ((!state.dataRefrigCase->HaveChillers) && (state.dataRefrigCase->UseSysTimeStep)) return;
     269             : 
     270             :     // Refrigerated cases are not simulated the first time through, replicate this on beginning of next environment
     271      461555 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->MyEnvrnFlag) {
     272         308 :         state.dataRefrigCase->MyEnvrnFlag = false;
     273         308 :         return;
     274             :     }
     275      461247 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->MyEnvrnFlag = true;
     276             : 
     277      461247 :     if (state.dataRefrigCase->HaveRefrigRacks) {
     278      257168 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
     279      171218 :             RefrigRack(RackNum).CalcRackSystem(state);
     280      171218 :             RefrigRack(RackNum).ReportRackSystem(state, RackNum);
     281             :         }
     282             :     }
     283             : 
     284      461247 :     if (state.dataRefrigCase->HaveDetailedRefrig) SimulateDetailedRefrigerationSystems(state);
     285      461247 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) SimulateDetailedTransRefrigSystems(state);
     286             : }
     287             : 
     288         796 : void GetRefrigerationInput(EnergyPlusData &state)
     289             : {
     290             : 
     291             :     // SUBROUTINE INFORMATION:
     292             :     //       AUTHOR         Richard Raustad, FSEC
     293             :     //       DATE WRITTEN   Oct/Nov 2004
     294             :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
     295             :     //       MODIFIED       Stovall, ORNL April 2008, Assisted by Hugh Henderson
     296             :     //       RE-ENGINEERED  na
     297             : 
     298             :     // PURPOSE OF THIS SUBROUTINE:
     299             :     // GetObjectItem is called to read refrigerated case, rack, compressor, and condenser information
     300             :     // Lists of cases and compressors are then correlated to the appropriate system.
     301             :     // The nominal ratings of all components are then compared and a warning is printed if the system is not balanced
     302             : 
     303             :     // METHODOLOGY EMPLOYED:
     304             :     // GetObjectItem is called to read refrigerated case information
     305             : 
     306             :     static constexpr std::string_view TrackMessage("from refrigerated case");
     307             :     static constexpr std::string_view RoutineName("GetRefrigerationInput: ");
     308             :     static constexpr std::string_view TrackMessageAlt("GetInput in RefrigeratedCase");
     309             :     static constexpr std::string_view RoutineNameNoColon("GetRefrigerationInput");
     310             : 
     311         796 :     int constexpr AlwaysOn(-1); // -1 pointer sent to schedule manager returns a value of 1.0
     312             :     //     input in both watts and flow rate
     313         796 :     int constexpr NumWIAlphaFieldsBeforeZoneInput(9);   // Used to cycle through zones on input for walk in coolers
     314         796 :     int constexpr NumWIAlphaFieldsPerZone(4);           // Used to cycle through zones on input for walk in coolers
     315         796 :     int constexpr NumWINumberFieldsBeforeZoneInput(12); // Used to cycle through zones on input for walk in coolers
     316         796 :     int constexpr NumWINumberFieldsPerZone(8);          // Used to cycle through zones on input for walk in coolers
     317         796 :     Real64 constexpr CondARI460DelT(16.7);              // Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
     318         796 :     Real64 constexpr CondARI460Tcond(51.7);             // Rated sat cond temp for air-cooled cond, ARI 460
     319         796 :     Real64 constexpr CondARI490DelT(15.0);              // Rated sat cond temp - wet bulb air T for evap-cooled Cond w R22, ARI490
     320         796 :     Real64 constexpr CondARI490Tcond(40.6);             // Rated sat cond temp for evap-cooled cond with R22, ARI 490
     321         796 :     Real64 constexpr DelEvapTDefault(5.0);              // default difference between case T and evap T (C)
     322         796 :     Real64 constexpr HoursPerDay(24.0);
     323         796 :     Real64 constexpr SecondsPerHour(3600.0);
     324         796 :     Real64 constexpr DefaultCascadeCondApproach(3.0); // Cascade condenser approach temperature difference (deltaC)
     325         796 :     Real64 constexpr DefaultCircRate(2.5);            // Phase change liquid overfeed circulating rate (ASHRAE definition)
     326         796 :     Real64 constexpr DefaultWISurfaceUValue(0.3154);  // equiv R18 in Archaic American units (W/m2-delta T)
     327         796 :     Real64 constexpr DefaultWIUValueGlassDr(1.136);   // equiv R5 in Archaic American units (W/m2-delta T)
     328         796 :     Real64 constexpr DefaultWIUValueStockDr(0.3785);  // equiv R15 in Archaic American units (W/m2-delta T)
     329         796 :     Real64 constexpr DefaultWIHeightGlassDr(1.5);     // glass door height in walk-in cooler (m)
     330         796 :     Real64 constexpr DefaultWIHeightStockDr(3.0);     // stock door height in walk-in cooler (m)
     331         796 :     Real64 constexpr PumpImpellerEfficiency(0.78);    // same as used in pump auto-sizing, dimensionless
     332         796 :     Real64 constexpr PumpMotorEfficiency(0.85);       // suggested as average value in ITT/Gould pump references,
     333             : 
     334         796 :     Array1D_string Alphas;             // Alpha items for object
     335         796 :     Array1D_string cAlphaFieldNames;   // Alpha field names (from input processor)
     336         796 :     Array1D_string cNumericFieldNames; // Numeric field names (from input processor)
     337         796 :     std::string CurrentModuleObject;   // Object type for getting and error messages
     338             : 
     339         796 :     Array1D_bool lAlphaBlanks;   // Logic array, alpha input blank = .TRUE.
     340         796 :     Array1D_bool lNumericBlanks; // Logic array, numeric input blank = .TRUE.
     341         796 :     bool ErrorsFound(false);     // Set to true if errors in input, fatal at end of routine
     342             : 
     343         796 :     int AlphaNum(0);                       // Used to cycle through input
     344         796 :     int IOStatus(0);                       // Used in GetObjectItem
     345         796 :     int MaxNumAlphasRack(0);               // Maximum number of alphas for rack object
     346         796 :     int MaxNumAlphasAirChiller(0);         // Maximum number of alphas for air chiller
     347         796 :     int MaxNumAlphasAll(0);                // Maximum number of alphas for all objects
     348         796 :     int MaxNumAlphasSys(0);                // Maximum number of alphas for system object
     349         796 :     int MaxNumAlphasTransSys(0);           // Maximum number of alphas for transcritical system object
     350         796 :     int MaxNumAlphasChillerSet(0);         // Maximum number of alphas for chiller set
     351         796 :     int MaxNumAlphasConda(0);              // Maximum number of alphas for air-cooled condenser object
     352         796 :     int MaxNumAlphasConde(0);              // Maximum number of alphas for evap-cooled condenser object
     353         796 :     int MaxNumAlphasCondw(0);              // Maximum number of alphas for water-cooled condenser object
     354         796 :     int MaxNumAlphasGasCoolera(0);         // Maximum number of alphas for air-cooled gas cooler object
     355         796 :     int MaxNumAlphasComp(0);               // Maximum number of alphas for compressor object
     356         796 :     int MaxNumAlphasCompressorList(0);     // Maximum number of alphas for compressor list objects
     357         796 :     int MaxNumAlphasCase(0);               // Maximum number of alphas for case object
     358         796 :     int MaxNumAlphasCaseAndWalkInList(0);  // Maximum number of alphas in CaseAndWalkInList
     359         796 :     int MaxNumAlphasWalkIn(0);             // Maximum number of alphas for walkin object
     360         796 :     int MaxNumAlphasSecond(0);             // Maximum number of alphas for air chiller object
     361         796 :     int MaxNumNumbersAirChiller(0);        // Maximum number of numbers for air chiller object
     362         796 :     int MaxNumNumbersSecond(0);            // Maximum number of numbers for secondary system object
     363         796 :     int MaxNumNumbersWalkIn(0);            // Maximum number of numbers for walkin object
     364         796 :     int MaxNumNumbersCase(0);              // Maximum number of numbers for case object
     365         796 :     int MaxNumNumbersCaseAndWalkInList(0); // Maximum number of numbers in CaseAndWalkInList
     366         796 :     int MaxNumNumbersRack(0);              // Maximum number of numbers for rack object
     367         796 :     int MaxNumNumbersAll(0);               // Maximum number of numeric inputs for all objects
     368         796 :     int MaxNumNumbersSys(0);               // Maximum number of numbers for system object
     369         796 :     int MaxNumNumbersTransSys(0);          // Maximum number of numbers for transcritical system object
     370         796 :     int MaxNumNumbersChillerSet(0);        // Maximum number of numbers for chiller set object
     371         796 :     int MaxNumNumbersConda(0);             // Maximum number of numbers for air-cooled condenser object
     372         796 :     int MaxNumNumbersConde(0);             // Maximum number of numbers for evap-cooled condenser object
     373         796 :     int MaxNumNumbersCondw(0);             // Maximum number of numbers for water-cooled condenser object
     374         796 :     int MaxNumNumbersGasCoolera(0);        // Maximum number of numbers for air-cooled gas cooler object
     375         796 :     int MaxNumNumbersComp(0);              // Maximum number of numbers for compressor object
     376         796 :     int MaxNumNumbersCompressorList(0);    // Maximum number of numbers
     377         796 :     int MaxNumArgs(0);                     // Max number of alphas and numbers (arguments) for rack object
     378         796 :     int NumAlphas(0);                      // Number of Alphas for each GetObjectItem call
     379         796 :     int NumCases(0);                       // Number of refrigerated cases for single system
     380         796 :     int NumNum(0);                         // Used to cycle through input
     381         796 :     int NumNumbers(0);                     // Number of Numbers for each GetObjectItem call
     382         796 :     int NumDisplayCases(0);                // Counter for refrigerated cases in GetInput do loop
     383         796 :     int NumWalkIns(0);                     // Number of walk ins
     384         796 :     int RefrigSysNum(0);
     385         796 :     int RefrigIndex(0);                // Index used in fluid property routines
     386         796 :     Real64 DeltaHPhaseChange(0.0);     // Secondary loop enthalpy change in condenser w overfeed system (J/g)
     387         796 :     Real64 DelTempMin(0.0);            // min temperature for heat rej curve for air cooled condenser (C)
     388         796 :     Real64 DelTempMax(0.0);            // max temperature for heat rej curve for air cooled condenser (C)
     389         796 :     Real64 DensityBrineRated(0.0);     // density of circ fluid in secondary loop
     390         796 :     Real64 DensityPhaseChange(0.0);    // Secondary loop density at condensing temperature w overfeed system (g/m3)
     391         796 :     Real64 NominalTotalCompCapLP(0.0); // Total of nominal low pressure compressor capacities, used for rough input check (W) (Transcritical CO2)
     392         796 :     Real64 NominalTotalCompCapHP(0.0);
     393         796 :     Array1D<Real64> Numbers;   // Numeric items for object
     394         796 :     Array2D<Real64> DayValues; // Array of schedule values
     395             : 
     396         796 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
     397         796 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     398         796 :     auto &CaseRAFraction = state.dataRefrigCase->CaseRAFraction;
     399         796 :     auto &System = state.dataRefrigCase->System;
     400         796 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
     401         796 :     auto &Condenser = state.dataRefrigCase->Condenser;
     402         796 :     auto &Compressor = state.dataRefrigCase->Compressor;
     403         796 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
     404         796 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
     405         796 :     auto &CaseAndWalkInList = state.dataRefrigCase->CaseAndWalkInList;
     406         796 :     auto &CompressorLists = state.dataRefrigCase->CompressorLists;
     407         796 :     auto &Secondary = state.dataRefrigCase->Secondary;
     408         796 :     auto &TransferLoadList = state.dataRefrigCase->TransferLoadList;
     409         796 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
     410         796 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
     411         796 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
     412         796 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
     413         796 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
     414             : 
     415        1592 :     state.dataRefrigCase->NumSimulationCascadeCondensers =
     416         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:Cascade");
     417         796 :     state.dataRefrigCase->NumSimulationCases = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Case");
     418        1592 :     state.dataRefrigCase->NumSimulationCaseAndWalkInLists =
     419         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CaseAndWalkInList");
     420         796 :     state.dataRefrigCase->NumRefrigeratedRacks = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorRack");
     421        1592 :     state.dataRefrigCase->NumSimulationSecondarySystems =
     422         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:SecondarySystem");
     423        1592 :     state.dataRefrigCase->NumSimulationTransferLoadLists =
     424         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TransferLoadList");
     425         796 :     state.dataRefrigCase->NumSimulationWalkIns = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:WalkIn");
     426         796 :     state.dataRefrigCase->NumRefrigSystems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:System");
     427        1592 :     state.dataRefrigCase->NumTransRefrigSystems =
     428         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TranscriticalSystem");
     429        1592 :     state.dataRefrigCase->NumSimulationCondAir =
     430         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:AirCooled");
     431        1592 :     state.dataRefrigCase->NumSimulationCondEvap =
     432         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:EvaporativeCooled");
     433        1592 :     state.dataRefrigCase->NumSimulationCondWater =
     434         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:WaterCooled");
     435        1592 :     state.dataRefrigCase->NumSimulationGasCooler =
     436         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:GasCooler:AirCooled");
     437         796 :     state.dataRefrigCase->NumRefrigCondensers = state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
     438         796 :                                                 state.dataRefrigCase->NumSimulationCondWater + state.dataRefrigCase->NumSimulationCascadeCondensers;
     439         796 :     state.dataRefrigCase->NumSimulationCompressors = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Compressor");
     440         796 :     state.dataRefrigCase->NumSimulationSubcoolers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Subcooler");
     441         796 :     int NumCompressorLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorList");
     442        1592 :     state.dataRefrigCase->NumRefrigChillerSets =
     443         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneHVAC:RefrigerationChillerSet");
     444        1592 :     state.dataRefrigCase->NumSimulationRefrigAirChillers =
     445         796 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:AirChiller");
     446             : 
     447             :     // Set flags used later to avoid unnecessary steps.
     448         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks == 0) state.dataRefrigCase->HaveRefrigRacks = false;
     449         796 :     if (state.dataRefrigCase->NumRefrigSystems == 0) state.dataRefrigCase->HaveDetailedRefrig = false;
     450         796 :     if (state.dataRefrigCase->NumTransRefrigSystems == 0) state.dataRefrigCase->HaveDetailedTransRefrig = false;
     451         796 :     if (state.dataRefrigCase->NumSimulationCases == 0 && state.dataRefrigCase->NumSimulationWalkIns == 0)
     452         760 :         state.dataRefrigCase->HaveCasesOrWalkins = false;
     453         796 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers == 0) state.dataRefrigCase->HaveChillers = false;
     454             : 
     455         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
     456          31 :         RefrigRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     457          31 :         state.dataHeatBal->HeatReclaimRefrigeratedRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     458             :     }
     459         796 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
     460          14 :         System.allocate(state.dataRefrigCase->NumRefrigSystems);
     461          14 :         state.dataRefrigCase->ShowUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     462          14 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     463          14 :         state.dataRefrigCase->ShowUnmetEnergyWarning = true;
     464          14 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning = true;
     465             :     }
     466         796 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
     467           1 :         TransSystem.allocate(state.dataRefrigCase->NumTransRefrigSystems);
     468           1 :         state.dataRefrigCase->ShowUnmetEnergyWarningTrans.dimension(state.dataRefrigCase->NumTransRefrigSystems, true);
     469             :     }
     470         796 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) AirChillerSet.allocate(state.dataRefrigCase->NumRefrigChillerSets);
     471         796 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
     472          14 :         state.dataHeatBal->HeatReclaimRefrigCondenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     473          14 :         Condenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     474          14 :         state.dataRefrigCase->UniqueCondenserNames.reserve(static_cast<unsigned>(state.dataRefrigCase->NumRefrigCondensers));
     475             :     }
     476         796 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
     477           1 :         GasCooler.allocate(state.dataRefrigCase->NumSimulationGasCooler);
     478             :     }
     479         796 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     480          36 :         CaseRAFraction.allocate(state.dataGlobal->NumOfZones);
     481          36 :         RefrigCase.allocate(state.dataRefrigCase->NumSimulationCases);
     482             :     }
     483         796 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
     484          13 :         WalkIn.allocate(state.dataRefrigCase->NumSimulationWalkIns);
     485             :     }
     486         796 :     if ((state.dataRefrigCase->NumSimulationWalkIns > 0) || (state.dataRefrigCase->NumSimulationCases > 0)) {
     487          36 :         CaseWIZoneReport.allocate(state.dataGlobal->NumOfZones);
     488             :     } else {
     489         760 :         state.dataRefrigCase->UseSysTimeStep = true;
     490             :         // needed to avoid accessing unallocated caseWIZoneReport on early call to SumZones
     491             :     }
     492         796 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
     493           1 :         Secondary.allocate(state.dataRefrigCase->NumSimulationSecondarySystems);
     494           1 :         state.dataRefrigCase->ShowUnmetSecondEnergyWarning.dimension(state.dataRefrigCase->NumSimulationSecondarySystems, true);
     495             :     }
     496         796 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
     497           1 :         WarehouseCoil.allocate(state.dataRefrigCase->NumSimulationRefrigAirChillers);
     498           1 :         CoilSysCredit.allocate(state.dataGlobal->NumOfZones);
     499             :     }
     500         796 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) Compressor.allocate(state.dataRefrigCase->NumSimulationCompressors);
     501         796 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) Subcooler.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
     502         796 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) CaseAndWalkInList.allocate(state.dataRefrigCase->NumSimulationCaseAndWalkInLists);
     503         796 :     if (NumCompressorLists > 0) CompressorLists.allocate(NumCompressorLists);
     504         796 :     if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) TransferLoadList.allocate(state.dataRefrigCase->NumSimulationTransferLoadLists);
     505             : 
     506         796 :     DayValues.allocate(state.dataGlobal->NumOfTimeStepInHour, 24);
     507         796 :     state.dataRefrigCase->RefrigPresentInZone.dimension(state.dataGlobal->NumOfZones, false);
     508             : 
     509         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:Case", MaxNumArgs, MaxNumAlphasCase, MaxNumNumbersCase);
     510         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     511             :         state, "Refrigeration:CaseAndWalkInList", MaxNumArgs, MaxNumAlphasCaseAndWalkInList, MaxNumNumbersCaseAndWalkInList);
     512         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     513             :         state, "Refrigeration:CompressorRack", MaxNumArgs, MaxNumAlphasRack, MaxNumNumbersRack);
     514         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:System", MaxNumArgs, MaxNumAlphasSys, MaxNumNumbersSys);
     515         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     516             :         state, "Refrigeration:TranscriticalSystem", MaxNumArgs, MaxNumAlphasTransSys, MaxNumNumbersTransSys);
     517         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     518             :         state, "Refrigeration:Condenser:AirCooled", MaxNumArgs, MaxNumAlphasConda, MaxNumNumbersConda);
     519         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     520             :         state, "Refrigeration:Condenser:EvaporativeCooled", MaxNumArgs, MaxNumAlphasConde, MaxNumNumbersConde);
     521         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     522             :         state, "Refrigeration:Condenser:WaterCooled", MaxNumArgs, MaxNumAlphasCondw, MaxNumNumbersCondw);
     523         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     524             :         state, "Refrigeration:GasCooler:AirCooled", MaxNumArgs, MaxNumAlphasGasCoolera, MaxNumNumbersGasCoolera);
     525         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     526             :         state, "Refrigeration:Compressor", MaxNumArgs, MaxNumAlphasComp, MaxNumNumbersComp);
     527         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     528             :         state, "Refrigeration:CompressorList", MaxNumArgs, MaxNumAlphasCompressorList, MaxNumNumbersCompressorList);
     529         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     530             :         state, "Refrigeration:WalkIn", MaxNumArgs, MaxNumAlphasWalkIn, MaxNumNumbersWalkIn);
     531         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     532             :         state, "Refrigeration:SecondarySystem", MaxNumArgs, MaxNumAlphasSecond, MaxNumNumbersSecond);
     533         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     534             :         state, "ZoneHVAC:RefrigerationChillerSet", MaxNumArgs, MaxNumAlphasChillerSet, MaxNumNumbersChillerSet);
     535         796 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     536             :         state, "Refrigeration:AirChiller", MaxNumArgs, MaxNumAlphasAirChiller, MaxNumNumbersAirChiller);
     537             : 
     538         796 :     MaxNumAlphasAll = max(MaxNumAlphasCase,
     539             :                           MaxNumAlphasCaseAndWalkInList,
     540             :                           MaxNumAlphasRack,
     541             :                           MaxNumAlphasSys,
     542             :                           MaxNumAlphasTransSys,
     543             :                           MaxNumAlphasConda,
     544             :                           MaxNumAlphasConde,
     545             :                           MaxNumAlphasCondw,
     546             :                           MaxNumAlphasGasCoolera,
     547             :                           MaxNumAlphasComp,
     548             :                           MaxNumAlphasCompressorList,
     549             :                           MaxNumAlphasSecond,
     550             :                           MaxNumAlphasWalkIn,
     551             :                           MaxNumAlphasChillerSet,
     552             :                           MaxNumAlphasAirChiller);
     553         796 :     MaxNumNumbersAll = max(MaxNumNumbersCase,
     554             :                            MaxNumNumbersCaseAndWalkInList,
     555             :                            MaxNumNumbersRack,
     556             :                            MaxNumNumbersSys,
     557             :                            MaxNumNumbersTransSys,
     558             :                            MaxNumNumbersConda,
     559             :                            MaxNumNumbersConde,
     560             :                            MaxNumNumbersCondw,
     561             :                            MaxNumNumbersGasCoolera,
     562             :                            MaxNumNumbersComp,
     563             :                            MaxNumNumbersCompressorList,
     564             :                            MaxNumNumbersSecond,
     565             :                            MaxNumNumbersWalkIn,
     566             :                            MaxNumNumbersChillerSet,
     567             :                            MaxNumNumbersAirChiller);
     568             : 
     569         796 :     Alphas.allocate(MaxNumAlphasAll);
     570         796 :     Numbers.dimension(MaxNumNumbersAll, 0.0);
     571         796 :     cAlphaFieldNames.allocate(MaxNumAlphasAll);
     572         796 :     cNumericFieldNames.allocate(MaxNumNumbersAll);
     573         796 :     lAlphaBlanks.dimension(MaxNumAlphasAll, true);
     574         796 :     lNumericBlanks.dimension(MaxNumNumbersAll, true);
     575             :     // bbb stovall note for future - for all curve entries, see if need fail on type or if can allow table input
     576         796 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     577          36 :         CurrentModuleObject = "Refrigeration:Case";
     578         222 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
     579         186 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     580             :                                                                      CurrentModuleObject,
     581             :                                                                      CaseNum,
     582             :                                                                      Alphas,
     583             :                                                                      NumAlphas,
     584             :                                                                      Numbers,
     585             :                                                                      NumNumbers,
     586             :                                                                      IOStatus,
     587             :                                                                      lNumericBlanks,
     588             :                                                                      lAlphaBlanks,
     589             :                                                                      cAlphaFieldNames,
     590             :                                                                      cNumericFieldNames);
     591             : 
     592         186 :             ++NumDisplayCases;
     593             : 
     594         186 :             AlphaNum = 1;
     595         186 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
     596         186 :             RefrigCase(CaseNum).Name = Alphas(AlphaNum);
     597             : 
     598         186 :             AlphaNum = 2;
     599         186 :             if (!lAlphaBlanks(AlphaNum)) {
     600         186 :                 RefrigCase(CaseNum).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer
     601         186 :                 if (RefrigCase(CaseNum).SchedPtr == 0) {
     602           0 :                     ShowSevereError(state,
     603           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
     604             :                                            RoutineName,
     605             :                                            CurrentModuleObject,
     606           0 :                                            RefrigCase(CaseNum).Name,
     607             :                                            cAlphaFieldNames(AlphaNum),
     608             :                                            Alphas(AlphaNum)));
     609           0 :                     ErrorsFound = true;
     610             :                 }    // ptr == 0
     611             :             } else { // no schedule specified
     612           0 :                 RefrigCase(CaseNum).SchedPtr = AlwaysOn;
     613             :             } // not blank
     614             : 
     615             :             //   check availability schedule for values between 0 and 1
     616         186 :             if (RefrigCase(CaseNum).SchedPtr > 0) {
     617         186 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).SchedPtr, ">=", 0.0, "<=", 1.0)) {
     618           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name));
     619           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
     620           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
     621           0 :                     ErrorsFound = true;
     622             :                 }
     623             :             }
     624             : 
     625             :             // Get the Zone node number from the zone name entered by the user
     626         186 :             RefrigCase(CaseNum).ZoneName = Alphas(3);
     627         186 :             RefrigCase(CaseNum).ActualZoneNum = Util::FindItemInList(Alphas(3), state.dataHeatBal->Zone);
     628             : 
     629         186 :             if (RefrigCase(CaseNum).ActualZoneNum == 0) {
     630           0 :                 ShowSevereError(state,
     631           0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
     632             :                                        RoutineName,
     633             :                                        CurrentModuleObject,
     634           0 :                                        RefrigCase(CaseNum).Name,
     635             :                                        cAlphaFieldNames(3),
     636             :                                        Alphas(3)));
     637           0 :                 ErrorsFound = true;
     638             :             } else {
     639         186 :                 state.dataRefrigCase->RefrigPresentInZone(RefrigCase(CaseNum).ActualZoneNum) = true;
     640             :             }
     641             : 
     642         186 :             RefrigCase(CaseNum).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigCase(CaseNum).ActualZoneNum);
     643             : 
     644         186 :             RefrigCase(CaseNum).RatedAmbientTemp = Numbers(1);
     645         186 :             if (Numbers(1) <= 0.0) {
     646           0 :                 ShowSevereError(state,
     647           0 :                                 format("{}{}=\"{}\", {} must be greater than 0 C",
     648             :                                        RoutineName,
     649             :                                        CurrentModuleObject,
     650           0 :                                        RefrigCase(CaseNum).Name,
     651             :                                        cNumericFieldNames(1)));
     652           0 :                 ErrorsFound = true;
     653             :             }
     654             : 
     655         186 :             RefrigCase(CaseNum).RatedAmbientRH = Numbers(2);
     656         186 :             if (Numbers(2) <= 0.0 || Numbers(2) >= 100.0) {
     657           0 :                 ShowSevereError(state,
     658           0 :                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
     659             :                                        RoutineName,
     660             :                                        CurrentModuleObject,
     661           0 :                                        RefrigCase(CaseNum).Name,
     662             :                                        cNumericFieldNames(2)));
     663           0 :                 ErrorsFound = true;
     664             :             }
     665         372 :             RefrigCase(CaseNum).RatedAmbientDewPoint = Psychrometrics::PsyTdpFnWPb(
     666             :                 state,
     667         186 :                 Psychrometrics::PsyWFnTdbRhPb(
     668         186 :                     state, RefrigCase(CaseNum).RatedAmbientTemp, (RefrigCase(CaseNum).RatedAmbientRH / 100.0), state.dataEnvrn->StdBaroPress),
     669         186 :                 state.dataEnvrn->StdBaroPress);
     670             : 
     671         186 :             RefrigCase(CaseNum).RateTotCapPerLength = Numbers(3);
     672         186 :             if (Numbers(3) <= 0.0) {
     673           0 :                 ShowSevereError(state,
     674           0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m",
     675             :                                        RoutineName,
     676             :                                        CurrentModuleObject,
     677           0 :                                        RefrigCase(CaseNum).Name,
     678             :                                        cNumericFieldNames(3)));
     679           0 :                 ErrorsFound = true;
     680             :             }
     681             : 
     682         186 :             RefrigCase(CaseNum).RatedLHR = Numbers(4);
     683         186 :             if (Numbers(4) < 0.0 || Numbers(4) > 1.0) {
     684           0 :                 ShowSevereError(
     685             :                     state,
     686           0 :                     format(
     687           0 :                         "{}{}=\"{}\", {} must be >= 0 and <= 1", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name, cNumericFieldNames(4)));
     688           0 :                 ErrorsFound = true;
     689             :             }
     690             : 
     691         186 :             RefrigCase(CaseNum).RatedRTF = Numbers(5);
     692         186 :             if (Numbers(5) <= 0.0 || Numbers(5) > 1.0) {
     693           0 :                 ShowSevereError(state,
     694           0 :                                 format("{}{}=\"{}\", {} must be > 0 and <= to 1",
     695             :                                        RoutineName,
     696             :                                        CurrentModuleObject,
     697           0 :                                        RefrigCase(CaseNum).Name,
     698             :                                        cNumericFieldNames(5)));
     699           0 :                 ErrorsFound = true;
     700             :             }
     701             : 
     702         186 :             RefrigCase(CaseNum).Length = Numbers(6);
     703         186 :             if (Numbers(6) <= 0.0) {
     704           0 :                 ShowSevereError(state,
     705           0 :                                 format("{}{}=\"{}\", {} must be greater than 0 m",
     706             :                                        RoutineName,
     707             :                                        CurrentModuleObject,
     708           0 :                                        RefrigCase(CaseNum).Name,
     709             :                                        cNumericFieldNames(6)));
     710           0 :                 ErrorsFound = true;
     711             :             }
     712             : 
     713         186 :             RefrigCase(CaseNum).Temperature = Numbers(7);
     714         186 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientTemp) {
     715           0 :                 ShowSevereError(state,
     716           0 :                                 format("{}{}=\"{}\", {} must be below {}",
     717             :                                        RoutineName,
     718             :                                        CurrentModuleObject,
     719           0 :                                        RefrigCase(CaseNum).Name,
     720             :                                        cNumericFieldNames(7),
     721             :                                        cNumericFieldNames(1)));
     722           0 :                 ErrorsFound = true;
     723             :             }
     724             : 
     725         186 :             if (Util::SameString(Alphas(4), "CaseTemperatureMethod")) {
     726         160 :                 RefrigCase(CaseNum).LatentEnergyCurveType = EnergyEqnForm::CaseTemperatureMethod;
     727          26 :             } else if (Util::SameString(Alphas(4), "RelativeHumidityMethod")) {
     728          18 :                 RefrigCase(CaseNum).LatentEnergyCurveType = EnergyEqnForm::RHCubic;
     729           8 :             } else if (Util::SameString(Alphas(4), "DewpointMethod")) {
     730           8 :                 RefrigCase(CaseNum).LatentEnergyCurveType = EnergyEqnForm::DPCubic;
     731             :             } else {
     732           0 :                 ShowSevereError(state,
     733           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
     734             :                                        RoutineName,
     735             :                                        CurrentModuleObject,
     736           0 :                                        RefrigCase(CaseNum).Name,
     737             :                                        cAlphaFieldNames(4),
     738             :                                        Alphas(4)));
     739           0 :                 ErrorsFound = true;
     740             :             }
     741             : 
     742         186 :             RefrigCase(CaseNum).LatCapCurvePtr = Curve::GetCurveIndex(state, Alphas(5)); // convert curve name to number
     743         186 :             if (RefrigCase(CaseNum).LatCapCurvePtr == 0) {
     744           0 :                 ShowSevereError(state,
     745           0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
     746             :                                        RoutineName,
     747             :                                        CurrentModuleObject,
     748           0 :                                        RefrigCase(CaseNum).Name,
     749             :                                        cAlphaFieldNames(5),
     750             :                                        Alphas(5)));
     751           0 :                 ErrorsFound = true;
     752             :             }
     753             : 
     754         372 :             ErrorsFound |= Curve::CheckCurveDims(state,
     755         186 :                                                  RefrigCase(CaseNum).LatCapCurvePtr, // Curve index
     756             :                                                  {1},                                // Valid dimensions
     757             :                                                  RoutineName,                        // Routine name
     758             :                                                  CurrentModuleObject,                // Object Type
     759         186 :                                                  RefrigCase(CaseNum).Name,           // Object Name
     760         186 :                                                  cAlphaFieldNames(5));               // Field Name
     761             : 
     762         186 :             NumNum = 8;
     763         186 :             if (!lNumericBlanks(NumNum)) {
     764         186 :                 RefrigCase(CaseNum).STDFanPower = Numbers(NumNum);
     765         186 :                 if (Numbers(NumNum) < 0.0) {
     766           0 :                     ShowSevereError(state,
     767           0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     768             :                                            RoutineName,
     769             :                                            CurrentModuleObject,
     770           0 :                                            RefrigCase(CaseNum).Name,
     771             :                                            cNumericFieldNames(NumNum)));
     772           0 :                     ErrorsFound = true;
     773             :                 }
     774             :             } else { // blank use default of 75 W/m
     775           0 :                 RefrigCase(CaseNum).STDFanPower = 75.0;
     776             :             } // blank input
     777             : 
     778         186 :             NumNum = 9;
     779         186 :             if (!lNumericBlanks(NumNum)) {
     780         186 :                 RefrigCase(CaseNum).OperatingFanPower = Numbers(NumNum);
     781         186 :                 if (Numbers(NumNum) < 0.0) {
     782           0 :                     ShowSevereError(state,
     783           0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     784             :                                            RoutineName,
     785             :                                            CurrentModuleObject,
     786           0 :                                            RefrigCase(CaseNum).Name,
     787             :                                            cNumericFieldNames(NumNum)));
     788           0 :                     ErrorsFound = true;
     789             :                 }
     790             :             } else { // if blank set = to std fan power
     791           0 :                 RefrigCase(CaseNum).OperatingFanPower = RefrigCase(CaseNum).STDFanPower;
     792             :             } // if blank
     793             : 
     794         186 :             NumNum = 10;
     795         186 :             if (!lNumericBlanks(NumNum)) {
     796         186 :                 RefrigCase(CaseNum).RatedLightingPower = Numbers(NumNum);
     797         186 :                 if (Numbers(NumNum) < 0.0) {
     798           0 :                     ShowSevereError(state,
     799           0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     800             :                                            RoutineName,
     801             :                                            CurrentModuleObject,
     802           0 :                                            RefrigCase(CaseNum).Name,
     803             :                                            cNumericFieldNames(NumNum)));
     804           0 :                     ErrorsFound = true;
     805             :                 }
     806             :             } else { // blank input - use default of 90 W/m
     807           0 :                 RefrigCase(CaseNum).RatedLightingPower = 90.0;
     808             :             } // blank input
     809             : 
     810         186 :             NumNum = 11;
     811         186 :             if (!lNumericBlanks(NumNum)) {
     812           8 :                 RefrigCase(CaseNum).LightingPower = Numbers(NumNum);
     813           8 :                 if (Numbers(NumNum) < 0.0) {
     814           0 :                     ShowSevereError(state,
     815           0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     816             :                                            RoutineName,
     817             :                                            CurrentModuleObject,
     818           0 :                                            RefrigCase(CaseNum).Name,
     819             :                                            cNumericFieldNames(NumNum)));
     820           0 :                     ErrorsFound = true;
     821             :                 }
     822             :             } else { // blank input so set lighting power equal to rated/std lighting power
     823         178 :                 RefrigCase(CaseNum).LightingPower = RefrigCase(CaseNum).RatedLightingPower;
     824             :             } // blank input
     825             : 
     826         186 :             if (!lAlphaBlanks(6)) {
     827         186 :                 RefrigCase(CaseNum).LightingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(6)); // convert schedule name to pointer
     828         186 :                 if (RefrigCase(CaseNum).LightingSchedPtr == 0) {
     829           0 :                     ShowSevereError(state,
     830           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
     831             :                                            RoutineName,
     832             :                                            CurrentModuleObject,
     833           0 :                                            RefrigCase(CaseNum).Name,
     834             :                                            cAlphaFieldNames(6),
     835             :                                            Alphas(6)));
     836           0 :                     ErrorsFound = true;
     837             :                 }    // ptr == 0
     838             :             } else { // no schedule specified
     839           0 :                 RefrigCase(CaseNum).LightingSchedPtr = AlwaysOn;
     840             :             } // not blank
     841             : 
     842             :             //   check lighting schedule for values between 0 and 1
     843         186 :             if (RefrigCase(CaseNum).LightingSchedPtr > 0) {
     844         186 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).LightingSchedPtr, ">=", 0.0, "<=", 1.0)) {
     845           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name));
     846           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(6), Alphas(6)));
     847           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
     848           0 :                     ErrorsFound = true;
     849             :                 }
     850             :             }
     851             : 
     852         186 :             NumNum = 12;
     853         186 :             RefrigCase(CaseNum).LightingFractionToCase = 1.0; // default value
     854         186 :             if (!lNumericBlanks(NumNum)) {
     855         186 :                 RefrigCase(CaseNum).LightingFractionToCase = Numbers(NumNum);
     856             :             } // blank input lighting fraction to case
     857             :             //   check lighting fraction to case input
     858         186 :             if (RefrigCase(CaseNum).LightingFractionToCase < 0.0 || RefrigCase(CaseNum).LightingFractionToCase > 1.0) {
     859           0 :                 ShowSevereError(state,
     860           0 :                                 format("{}{}=\"{}\", {} has a value outside the valid range",
     861             :                                        RoutineName,
     862             :                                        CurrentModuleObject,
     863           0 :                                        RefrigCase(CaseNum).Name,
     864             :                                        cNumericFieldNames(NumNum)));
     865           0 :                 ShowContinueError(state, "  Minimum should be >= 0.0 and Maximum should be <= 1.0");
     866           0 :                 ErrorsFound = true;
     867             :             }
     868             : 
     869         186 :             NumNum = 13;
     870         186 :             RefrigCase(CaseNum).AntiSweatPower = Numbers(NumNum);
     871         186 :             if (Numbers(NumNum) < 0.0) {
     872           0 :                 ShowSevereError(state,
     873           0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     874             :                                        RoutineName,
     875             :                                        CurrentModuleObject,
     876           0 :                                        RefrigCase(CaseNum).Name,
     877             :                                        cNumericFieldNames(NumNum)));
     878           0 :                 ErrorsFound = true;
     879             :             }
     880             : 
     881         186 :             NumNum = 14;
     882         186 :             RefrigCase(CaseNum).MinimumASPower = Numbers(NumNum);
     883         186 :             if (Numbers(NumNum) < 0.0) {
     884           0 :                 ShowSevereError(state,
     885           0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     886             :                                        RoutineName,
     887             :                                        CurrentModuleObject,
     888           0 :                                        RefrigCase(CaseNum).Name,
     889             :                                        cNumericFieldNames(NumNum)));
     890           0 :                 ErrorsFound = true;
     891             :             }
     892             : 
     893         186 :             if (Util::SameString(Alphas(7), "None")) {
     894         107 :                 RefrigCase(CaseNum).AntiSweatControlType = ASHtrCtrlType::None;
     895         107 :                 RefrigCase(CaseNum).AntiSweatPower = 0.0;
     896          79 :             } else if (Util::SameString(Alphas(7), "Constant")) {
     897           0 :                 RefrigCase(CaseNum).AntiSweatControlType = ASHtrCtrlType::Constant;
     898          79 :             } else if (Util::SameString(Alphas(7), "Linear")) {
     899          38 :                 RefrigCase(CaseNum).AntiSweatControlType = ASHtrCtrlType::Linear;
     900          41 :             } else if (Util::SameString(Alphas(7), "DewpointMethod")) {
     901           0 :                 RefrigCase(CaseNum).AntiSweatControlType = ASHtrCtrlType::DewPoint;
     902          41 :             } else if (Util::SameString(Alphas(7), "HeatBalanceMethod")) {
     903          41 :                 RefrigCase(CaseNum).AntiSweatControlType = ASHtrCtrlType::HeatBalance;
     904             :             } else {
     905           0 :                 ShowSevereError(state,
     906           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
     907             :                                        RoutineName,
     908             :                                        CurrentModuleObject,
     909           0 :                                        RefrigCase(CaseNum).Name,
     910             :                                        cAlphaFieldNames(7),
     911             :                                        Alphas(7)));
     912           0 :                 ErrorsFound = true;
     913             :             }
     914             : 
     915             :             //   Assure that case temperature is below the rated dew point when anti-sweat heater control type is dew point method
     916         186 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientDewPoint &&
     917           0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::DewPoint) {
     918           0 :                 ShowSevereError(state,
     919           0 :                                 format("{}{}=\"{}\", {} must be below the Rated Ambient Dew Point when {} is Dew Point Method",
     920             :                                        RoutineName,
     921             :                                        CurrentModuleObject,
     922           0 :                                        RefrigCase(CaseNum).Name,
     923             :                                        cNumericFieldNames(7),
     924             :                                        cAlphaFieldNames(7)));
     925           0 :                 ErrorsFound = true;
     926             :             }
     927             : 
     928         186 :             NumNum = 15;
     929             :             //  negative values for minimum humidity are allowed
     930         186 :             RefrigCase(CaseNum).HumAtZeroAS = Numbers(NumNum);
     931             : 
     932             :             //   check minimum humidity when linear AS control type is used
     933         186 :             if (RefrigCase(CaseNum).HumAtZeroAS >= RefrigCase(CaseNum).RatedAmbientRH &&
     934           0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Linear) {
     935           0 :                 ShowSevereError(state,
     936           0 :                                 format("{}{}=\"{}\", {} must be less than {}",
     937             :                                        RoutineName,
     938             :                                        CurrentModuleObject,
     939           0 :                                        RefrigCase(CaseNum).Name,
     940             :                                        cNumericFieldNames(NumNum),
     941             :                                        cNumericFieldNames(2)));
     942           0 :                 ShowContinueError(state, format(" for Linear {}.", cAlphaFieldNames(7)));
     943           0 :                 ErrorsFound = true;
     944             :             }
     945             : 
     946         186 :             NumNum = 16;
     947         186 :             RefrigCase(CaseNum).Height = Numbers(NumNum);
     948         186 :             if (Numbers(NumNum) < 0.0) {
     949           0 :                 ShowSevereError(state,
     950           0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 m",
     951             :                                        RoutineName,
     952             :                                        CurrentModuleObject,
     953           0 :                                        RefrigCase(CaseNum).Name,
     954             :                                        cNumericFieldNames(NumNum)));
     955           0 :                 ErrorsFound = true;
     956             :             }
     957             : 
     958         186 :             if (RefrigCase(CaseNum).Height <= 0.0 && RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
     959           0 :                 ShowSevereError(state,
     960           0 :                                 format("{}{}=\"{}\", {} must be greater than 0 when {} is Heat Balance Method.",
     961             :                                        RoutineName,
     962             :                                        CurrentModuleObject,
     963           0 :                                        RefrigCase(CaseNum).Name,
     964             :                                        cNumericFieldNames(NumNum),
     965             :                                        cAlphaFieldNames(7)));
     966           0 :                 ShowContinueError(state, format("..given {} was: {:.3R}", cNumericFieldNames(NumNum), RefrigCase(CaseNum).Height));
     967           0 :                 ErrorsFound = true;
     968             :             }
     969             : 
     970             :             //   initialize case resistance for anti-sweat heater control type = Heat Balance Method
     971         186 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
     972          41 :                 Real64 Rcase(0.0);      // Case thermal resistance used with anti-sweat heater control
     973          41 :                 Real64 RcaseDenom(0.0); // Denominator of case thermal resistance calculation for anti-sweat
     974             : 
     975          41 :                 if (RefrigCase(CaseNum).Height == 0.0) {
     976           0 :                     Rcase = 0.0;
     977             :                 } else {
     978          41 :                     RcaseDenom = ((RefrigCase(CaseNum).AntiSweatPower / RefrigCase(CaseNum).Height) -
     979          41 :                                   (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).RatedAmbientTemp) / Rair);
     980          41 :                     Rcase = (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).Temperature) / RcaseDenom;
     981             :                 }
     982          41 :                 RefrigCase(CaseNum).Rcase = max(0.0, Rcase);
     983          41 :                 if (RefrigCase(CaseNum).Rcase == 0.0) {
     984           0 :                     ShowWarningError(state,
     985           0 :                                      format("{}=\"{}\" A case thermal resistance of 0 was calculated for anti-sweat heater performance using the",
     986             :                                             CurrentModuleObject,
     987           0 :                                             RefrigCase(CaseNum).Name));
     988           0 :                     ShowContinueError(state,
     989           0 :                                       format(" Heat Balance Method control type. Anti-sweat heater performance cannot be calculated and {} will be "
     990             :                                              "set to None and simulation continues.",
     991             :                                              cAlphaFieldNames(7)));
     992           0 :                     ShowContinueError(state, " See Engineering Documentation for anti-sweat heater control of refrigerated cases.");
     993             :                 }
     994             :             }
     995             : 
     996         186 :             NumNum = 17;
     997         186 :             RefrigCase(CaseNum).ASHeaterFractionToCase = Numbers(NumNum);
     998         186 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
     999           0 :                 ShowSevereError(state,
    1000           0 :                                 format("{}{}=\"{}\", {} must be >= 0 and <= 1",
    1001             :                                        RoutineName,
    1002             :                                        CurrentModuleObject,
    1003           0 :                                        RefrigCase(CaseNum).Name,
    1004             :                                        cNumericFieldNames(NumNum)));
    1005           0 :                 ErrorsFound = true;
    1006             :             }
    1007             : 
    1008         186 :             if (Util::SameString(Alphas(8), "None")) {
    1009          35 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::None;
    1010         151 :             } else if (Util::SameString(Alphas(8), "OffCycle")) {
    1011          47 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::OffCycle;
    1012         104 :             } else if ((Util::SameString(Alphas(8), "HotFluid")) || (Util::SameString(Alphas(8), "HotGas"))) {
    1013          18 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::HotFluid;
    1014         172 :             } else if ((Util::SameString(Alphas(8), "HotFluidWithTemperatureTermination")) ||
    1015         172 :                        (Util::SameString(Alphas(8), "HotGasWithTemperatureTermination"))) {
    1016          40 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::HotFluidTerm;
    1017             :                 //   ELSEIF (Util::SameString(Alphas(8),'Hot-Fluid On Demand')) THEN
    1018             :                 //     RefrigCase(CaseNum)%DefrostType = DefHotFluidOnDemand
    1019          46 :             } else if (Util::SameString(Alphas(8), "Electric")) {
    1020          28 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::Electric;
    1021          18 :             } else if (Util::SameString(Alphas(8), "ElectricWithTemperatureTermination")) {
    1022          18 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::ElectricTerm;
    1023             :                 //   ELSEIF (Util::SameString(Alphas(8),'Electric On Demand')) THEN
    1024             :                 //     RefrigCase(CaseNum)%DefrostType = DefElectricOnDemand
    1025             :             } else {
    1026           0 :                 ShowWarningError(
    1027           0 :                     state, format(R"({}="{}", invalid  {}="{}".)", CurrentModuleObject, RefrigCase(CaseNum).Name, cAlphaFieldNames(8), Alphas(8)));
    1028           0 :                 ShowContinueError(state, format("Simulation will default to {}=\"None\" and continue.", cAlphaFieldNames(8)));
    1029           0 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::None;
    1030             :             }
    1031             : 
    1032         186 :             RefCaseDefrostType DefType = RefrigCase(CaseNum).defrostType;
    1033         186 :             NumNum = 18;
    1034         186 :             if (!lNumericBlanks(NumNum)) {
    1035         186 :                 RefrigCase(CaseNum).DefrostPower = Numbers(NumNum);
    1036         186 :                 if (Numbers(NumNum) < 0.0) {
    1037           0 :                     ShowSevereError(state,
    1038           0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
    1039             :                                            RoutineName,
    1040             :                                            CurrentModuleObject,
    1041           0 :                                            RefrigCase(CaseNum).Name,
    1042             :                                            cNumericFieldNames(NumNum)));
    1043           0 :                     ErrorsFound = true;
    1044             :                 }
    1045             :                 //   disregard defrost power for Off-Cycle or None defrost types
    1046         186 :                 if ((DefType == RefCaseDefrostType::OffCycle || DefType == RefCaseDefrostType::None) && (RefrigCase(CaseNum).DefrostPower > 0.0)) {
    1047           0 :                     RefrigCase(CaseNum).DefrostPower = 0.0;
    1048           0 :                     ShowWarningError(state,
    1049           0 :                                      format("{}=\"{}\", {} for {} None or Off-Cycle will be set to 0 and simulation continues.",
    1050             :                                             CurrentModuleObject,
    1051           0 :                                             RefrigCase(CaseNum).Name,
    1052             :                                             cNumericFieldNames(NumNum),
    1053             :                                             cAlphaFieldNames(8)));
    1054             :                 }
    1055             :             } else {
    1056           0 :                 RefrigCase(CaseNum).DefrostPower = 0.0;
    1057             :             }
    1058             : 
    1059             :             // defrost power needed to calculate heat gain to case even if not needed for electric consumption
    1060         168 :             if ((DefType == RefCaseDefrostType::HotFluid || DefType == RefCaseDefrostType::HotFluidTerm || DefType == RefCaseDefrostType::Electric ||
    1061         372 :                  DefType == RefCaseDefrostType::ElectricTerm) &&
    1062         104 :                 RefrigCase(CaseNum).DefrostPower <= 0.0) {
    1063           0 :                 ShowSevereError(state,
    1064           0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m for {} {}",
    1065             :                                        RoutineName,
    1066             :                                        CurrentModuleObject,
    1067           0 :                                        RefrigCase(CaseNum).Name,
    1068             :                                        cNumericFieldNames(NumNum),
    1069             :                                        cAlphaFieldNames(8),
    1070             :                                        Alphas(8)));
    1071           0 :                 ErrorsFound = true;
    1072             :             }
    1073             : 
    1074         186 :             RefrigCase(CaseNum).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(9)); // convert schedule name to pointer
    1075         186 :             if (RefrigCase(CaseNum).DefrostSchedPtr == 0 && RefrigCase(CaseNum).defrostType != RefCaseDefrostType::None) {
    1076           0 :                 ShowSevereError(state,
    1077           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    1078             :                                        RoutineName,
    1079             :                                        CurrentModuleObject,
    1080           0 :                                        RefrigCase(CaseNum).Name,
    1081             :                                        cAlphaFieldNames(9),
    1082             :                                        Alphas(9)));
    1083           0 :                 ShowContinueError(state, format("required when {}=\"{}\".", cAlphaFieldNames(8), Alphas(8)));
    1084           0 :                 ErrorsFound = true;
    1085             :             }
    1086             : 
    1087             :             //   check defrost schedule for values between 0 and 1
    1088         186 :             if (RefrigCase(CaseNum).DefrostSchedPtr > 0) {
    1089         153 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1090           0 :                     ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name));
    1091           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(9), Alphas(9)));
    1092           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1093           0 :                     ErrorsFound = true;
    1094             :                 }
    1095             :             }
    1096             :             //   Note that next section counting number cycles and setting maxkgfrost not used now, but may be in the future.
    1097             :             //   count the number of defrost cycles
    1098             : 
    1099             :             // Flag for counting defrost cycles
    1100         186 :             bool StartCycle = false;
    1101         186 :             int NumDefCycles = 0;
    1102         186 :             DayValues = 0.0;
    1103         186 :             ScheduleManager::GetScheduleValuesForDay(state, RefrigCase(CaseNum).DefrostSchedPtr, DayValues, 1);
    1104        4650 :             for (int HRNum = 1; HRNum <= 24; ++HRNum) {
    1105       29424 :                 for (int TSNum = 1; TSNum <= state.dataGlobal->NumOfTimeStepInHour; ++TSNum) {
    1106       24960 :                     if (DayValues(TSNum, HRNum) > 0.0) {
    1107         578 :                         if (!StartCycle) {
    1108         290 :                             ++NumDefCycles;
    1109         290 :                             StartCycle = true;
    1110             :                         }
    1111             :                     } else {
    1112       24382 :                         StartCycle = false;
    1113             :                     }
    1114             :                 }
    1115             :             }
    1116             : 
    1117         186 :             if (NumDefCycles > 0) {
    1118             :                 //     calculate maximum frost formation based on defrost schedule, heat of vaporization+fusion for water = 2833.0 kJ/kg
    1119         290 :                 RefrigCase(CaseNum).MaxKgFrost = (RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).RatedLHR *
    1120         145 :                                                   RefrigCase(CaseNum).RatedRTF * SecondsPerHour * HoursPerDay / 1000.0 / 2833.0) /
    1121             :                                                  (NumDefCycles);
    1122             :             } else {
    1123          41 :                 RefrigCase(CaseNum).MaxKgFrost = 9999999.9;
    1124             :             }
    1125             : 
    1126             :             //   some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1127         186 :             if (!lAlphaBlanks(10)) {
    1128         306 :                 RefrigCase(CaseNum).DefrostDripDownSchedPtr =
    1129         153 :                     ScheduleManager::GetScheduleIndex(state, Alphas(10)); // convert schedule name to pointer
    1130         153 :                 if (RefrigCase(CaseNum).DefrostDripDownSchedPtr == 0) {
    1131           0 :                     ShowSevereError(state,
    1132           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1133             :                                            RoutineName,
    1134             :                                            CurrentModuleObject,
    1135           0 :                                            RefrigCase(CaseNum).Name,
    1136             :                                            cAlphaFieldNames(10),
    1137             :                                            Alphas(10)));
    1138           0 :                     ErrorsFound = true;
    1139             :                 }
    1140             :             } else {
    1141          33 :                 RefrigCase(CaseNum).DefrostDripDownSchedPtr = RefrigCase(CaseNum).DefrostSchedPtr;
    1142             :             }
    1143             : 
    1144             :             //   check defrost drip-down schedule for values between 0 and 1
    1145         186 :             if (RefrigCase(CaseNum).DefrostDripDownSchedPtr > 0 && (!lAlphaBlanks(10))) {
    1146         153 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1147           0 :                     ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name));
    1148           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(10), Alphas(10)));
    1149           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1150           0 :                     ErrorsFound = true;
    1151             :                 }
    1152             :             }
    1153             : 
    1154         186 :             if (Util::SameString(Alphas(11), "CaseTemperatureMethod")) {
    1155          58 :                 RefrigCase(CaseNum).DefrostEnergyCurveType = EnergyEqnForm::CaseTemperatureMethod;
    1156         128 :             } else if (Util::SameString(Alphas(11), "RelativeHumidityMethod")) {
    1157           0 :                 RefrigCase(CaseNum).DefrostEnergyCurveType = EnergyEqnForm::RHCubic;
    1158         128 :             } else if (Util::SameString(Alphas(11), "DewpointMethod")) {
    1159           0 :                 RefrigCase(CaseNum).DefrostEnergyCurveType = EnergyEqnForm::DPCubic;
    1160         128 :             } else if (Util::SameString(Alphas(11), "None")) {
    1161         128 :                 RefrigCase(CaseNum).DefrostEnergyCurveType = EnergyEqnForm::None;
    1162             :             } else {
    1163           0 :                 ShowSevereError(state,
    1164           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    1165             :                                        RoutineName,
    1166             :                                        CurrentModuleObject,
    1167           0 :                                        RefrigCase(CaseNum).Name,
    1168             :                                        cAlphaFieldNames(11),
    1169             :                                        Alphas(11)));
    1170           0 :                 ErrorsFound = true;
    1171             :             }
    1172             : 
    1173         186 :             RefrigCase(CaseNum).DefCapCurvePtr = Curve::GetCurveIndex(state, Alphas(12)); // convert curve name to number
    1174         186 :             if ((RefrigCase(CaseNum).defrostType == RefCaseDefrostType::ElectricTerm ||
    1175         244 :                  RefrigCase(CaseNum).defrostType == RefCaseDefrostType::HotFluidTerm) &&
    1176          58 :                 (RefrigCase(CaseNum).DefCapCurvePtr == 0)) {
    1177           0 :                 ShowSevereError(state,
    1178           0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
    1179             :                                        RoutineName,
    1180             :                                        CurrentModuleObject,
    1181           0 :                                        RefrigCase(CaseNum).Name,
    1182             :                                        cAlphaFieldNames(12),
    1183             :                                        Alphas(12)));
    1184           0 :                 ErrorsFound = true;
    1185             :             }
    1186             : 
    1187         186 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1188         116 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1189          58 :                                                      RefrigCase(CaseNum).DefCapCurvePtr, // Curve index
    1190             :                                                      {1},                                // Valid dimensions
    1191             :                                                      RoutineName,                        // Routine name
    1192             :                                                      CurrentModuleObject,                // Object Type
    1193          58 :                                                      RefrigCase(CaseNum).Name,           // Object Name
    1194          58 :                                                      cAlphaFieldNames(12));              // Field Name
    1195             :             }
    1196             : 
    1197             :             //  warn user if defrost energy curve is entered that it is only used for temperature termination types
    1198         186 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1199          98 :                 if (RefrigCase(CaseNum).defrostType != RefCaseDefrostType::ElectricTerm &&
    1200          40 :                     RefrigCase(CaseNum).defrostType != RefCaseDefrostType::HotFluidTerm) {
    1201           0 :                     ShowWarningError(state,
    1202           0 :                                      format("{}=\"{}\", invalid  {} is only applicable to Defrost Temperature Termination types.",
    1203             :                                             CurrentModuleObject,
    1204           0 :                                             RefrigCase(CaseNum).Name,
    1205             :                                             cAlphaFieldNames(12)));
    1206           0 :                     ShowContinueError(state, format("{} will be disregarded and simulation continues.", cAlphaFieldNames(12)));
    1207             :                 }
    1208             :             }
    1209             : 
    1210         186 :             NumNum = 19;
    1211         186 :             RefrigCase(CaseNum).RAFrac = Numbers(NumNum);
    1212         186 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
    1213           0 :                 ShowSevereError(state,
    1214           0 :                                 format("{}{}=\"{}\", {} must be >= 0 or <= 1 ",
    1215             :                                        RoutineName,
    1216             :                                        CurrentModuleObject,
    1217           0 :                                        RefrigCase(CaseNum).Name,
    1218             :                                        cNumericFieldNames(NumNum)));
    1219           0 :                 ErrorsFound = true;
    1220             :             }
    1221             : 
    1222             :             // Set return air node number
    1223         186 :             RefrigCase(CaseNum).ZoneRANode = 0;
    1224         186 :             std::string retNodeName;
    1225         186 :             if (!lAlphaBlanks(15)) {
    1226           0 :                 retNodeName = Alphas(15);
    1227             :             }
    1228         186 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1229         122 :                 std::string callDescription = CurrentModuleObject + "=" + RefrigCase(CaseNum).Name;
    1230         244 :                 RefrigCase(CaseNum).ZoneRANode =
    1231         122 :                     DataZoneEquipment::GetReturnAirNodeForZone(state, RefrigCase(CaseNum).ActualZoneNum, retNodeName, callDescription);
    1232         122 :             }
    1233             : 
    1234         186 :             if (RefrigCase(CaseNum).ActualZoneNum >= 0) {
    1235         186 :                 if (RefrigCase(CaseNum).ZoneNodeNum == 0) {
    1236           0 :                     ShowSevereError(state,
    1237           0 :                                     format("{}{}=\"{}\", System Node Number not found for {} = {}",
    1238             :                                            RoutineName,
    1239             :                                            CurrentModuleObject,
    1240           0 :                                            RefrigCase(CaseNum).Name,
    1241             :                                            cAlphaFieldNames(3),
    1242             :                                            Alphas(3)));
    1243           0 :                     ShowContinueError(state,
    1244             :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object).");
    1245           0 :                     ErrorsFound = true;
    1246             :                 }
    1247         186 :                 if ((RefrigCase(CaseNum).RAFrac > 0.0) && (RefrigCase(CaseNum).ZoneRANode == 0)) {
    1248           0 :                     ShowSevereError(state,
    1249           0 :                                     format("{}{}=\"{}\", Under Case HVAC Return Air Node number not found for {} = {}",
    1250             :                                            RoutineName,
    1251             :                                            CurrentModuleObject,
    1252           0 :                                            RefrigCase(CaseNum).Name,
    1253             :                                            cAlphaFieldNames(3),
    1254             :                                            Alphas(3)));
    1255           0 :                     ShowContinueError(state,
    1256             :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object) "
    1257             :                                       "with at least one return air node.");
    1258           0 :                     ErrorsFound = true;
    1259             :                 }
    1260             :             }
    1261             : 
    1262             :             // set flag in Zone Data if RAFrac > 0
    1263         186 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1264         122 :                 state.dataHeatBal->Zone(RefrigCase(CaseNum).ActualZoneNum).RefrigCaseRA = true;
    1265             :             }
    1266             : 
    1267             :             //   Make sure RA node exists for display cases with under case HVAC returns
    1268         186 :             if (RefrigCase(CaseNum).ZoneRANode == 0 && RefrigCase(CaseNum).RAFrac > 0.0) {
    1269           0 :                 ShowSevereError(state,
    1270           0 :                                 format("{}{}=\"{}\", {} not applicable to zones without return air systems.",
    1271             :                                        RoutineName,
    1272             :                                        CurrentModuleObject,
    1273           0 :                                        RefrigCase(CaseNum).Name,
    1274             :                                        cNumericFieldNames(19)));
    1275           0 :                 ErrorsFound = true;
    1276             :             }
    1277             : 
    1278         186 :             if (RefrigCase(CaseNum).ActualZoneNum != 0) {
    1279         186 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).TotalCaseRAFraction += RefrigCase(CaseNum).RAFrac;
    1280         186 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).ZoneName = RefrigCase(CaseNum).ZoneName;
    1281             :             }
    1282             : 
    1283         186 :             RefrigCase(CaseNum).StockingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(13)); // convert schedule name to pointer
    1284         186 :             if (!lAlphaBlanks(13)) {
    1285         186 :                 if (RefrigCase(CaseNum).StockingSchedPtr == 0) {
    1286           0 :                     ShowSevereError(state,
    1287           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1288             :                                            RoutineName,
    1289             :                                            CurrentModuleObject,
    1290           0 :                                            RefrigCase(CaseNum).Name,
    1291             :                                            cAlphaFieldNames(13),
    1292             :                                            Alphas(13)));
    1293           0 :                     ErrorsFound = true;
    1294             :                 }
    1295             :             } else {
    1296           0 :                 RefrigCase(CaseNum).StockingSchedPtr = 0;
    1297             :             }
    1298             : 
    1299             :             //   calculate sensible case load at design conditions
    1300             :             // Case sensible capacity used for error messages
    1301         186 :             Real64 DesignSensibleCap = RefrigCase(CaseNum).RateTotCapPerLength * (1.0 - RefrigCase(CaseNum).RatedLHR) * RefrigCase(CaseNum).RatedRTF *
    1302         186 :                                        RefrigCase(CaseNum).Length;
    1303             : 
    1304             :             //   calculate case heat gain = lights + fans + anti-sweat
    1305             :             Real64 CaseHeatGain =
    1306         186 :                 ((RefrigCase(CaseNum).RatedLightingPower * RefrigCase(CaseNum).LightingFractionToCase) +
    1307         186 :                  (RefrigCase(CaseNum).AntiSweatPower * RefrigCase(CaseNum).ASHeaterFractionToCase) + RefrigCase(CaseNum).STDFanPower) *
    1308         186 :                 RefrigCase(CaseNum).Length;
    1309             : 
    1310             :             //   sensible case credits are calculated as the difference between the design sensible capacity and the case heat gain
    1311         186 :             RefrigCase(CaseNum).DesignSensCaseCredit = DesignSensibleCap - CaseHeatGain;
    1312             : 
    1313             :             //   compare case loads to design capacity
    1314         186 :             if (DesignSensibleCap < CaseHeatGain) {
    1315           0 :                 ShowSevereError(
    1316             :                     state,
    1317           0 :                     format("{}{}=\"{}\", the sum of lighting, fan, and anti-sweat heater energy is greater than refrigerated case sensible capacity",
    1318             :                            RoutineName,
    1319             :                            CurrentModuleObject,
    1320           0 :                            RefrigCase(CaseNum).Name));
    1321           0 :                 ErrorsFound = true;
    1322             :             }
    1323             : 
    1324         186 :             RefrigCase(CaseNum).CaseCreditFracSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(14)); // convert schedule name to pointer
    1325         186 :             if (!lAlphaBlanks(14)) {
    1326         116 :                 if (RefrigCase(CaseNum).CaseCreditFracSchedPtr == 0) {
    1327           0 :                     ShowSevereError(state,
    1328           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1329             :                                            RoutineName,
    1330             :                                            CurrentModuleObject,
    1331           0 :                                            RefrigCase(CaseNum).Name,
    1332             :                                            cAlphaFieldNames(14),
    1333             :                                            Alphas(14)));
    1334           0 :                     ErrorsFound = true;
    1335             :                 }
    1336             :             } else {
    1337          70 :                 RefrigCase(CaseNum).CaseCreditFracSchedPtr = 0;
    1338             :             }
    1339             : 
    1340             :             //   check case credit fraction schedule for values between 0 and 1
    1341         186 :             if (RefrigCase(CaseNum).CaseCreditFracSchedPtr > 0) {
    1342         116 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigCase(CaseNum).CaseCreditFracSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1343           0 :                     ShowSevereError(state, format("{}{}=\"{}\".", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name));
    1344           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(14), Alphas(14)));
    1345           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1346           0 :                     ErrorsFound = true;
    1347             :                 }
    1348             :             }
    1349             : 
    1350         186 :             RefrigCase(CaseNum).DesignRatedCap = RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).Length;
    1351         186 :             RefrigCase(CaseNum).DesignLatentCap = RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF;
    1352         186 :             RefrigCase(CaseNum).DesignDefrostCap = RefrigCase(CaseNum).DefrostPower * RefrigCase(CaseNum).Length;
    1353         186 :             RefrigCase(CaseNum).DesignLighting = RefrigCase(CaseNum).LightingPower * RefrigCase(CaseNum).Length;
    1354         186 :             RefrigCase(CaseNum).DesignFanPower = RefrigCase(CaseNum).OperatingFanPower * RefrigCase(CaseNum).Length;
    1355             : 
    1356             :             // Design evaporating temperature:  for a DX system, saturated temperature for pressure leaving case
    1357             :             //                              :  for a liquid system, liquid temperature entering case
    1358         186 :             NumNum = 20;
    1359         186 :             if (!lNumericBlanks(NumNum)) {
    1360          85 :                 RefrigCase(CaseNum).EvapTempDesign = Numbers(NumNum);
    1361          85 :                 if (RefrigCase(CaseNum).EvapTempDesign >= RefrigCase(CaseNum).Temperature) {
    1362           0 :                     ShowSevereError(state,
    1363           0 :                                     format("{}{}=\"{}\" {} must be below {}",
    1364             :                                            RoutineName,
    1365             :                                            CurrentModuleObject,
    1366           0 :                                            RefrigCase(CaseNum).Name,
    1367             :                                            cNumericFieldNames(NumNum),
    1368             :                                            cNumericFieldNames(7)));
    1369           0 :                     ErrorsFound = true;
    1370             :                 }
    1371             :             } else {
    1372         101 :                 RefrigCase(CaseNum).EvapTempDesign = RefrigCase(CaseNum).Temperature - DelEvapTDefault;
    1373             :                 //    default 5C less than case operating temperature
    1374             :             }
    1375             : 
    1376         186 :             NumNum = 21;
    1377         186 :             if (!lNumericBlanks(NumNum)) {
    1378           8 :                 RefrigCase(CaseNum).RefrigInventory = Numbers(NumNum);
    1379           8 :                 RefrigCase(CaseNum).DesignRefrigInventory = RefrigCase(CaseNum).RefrigInventory * RefrigCase(CaseNum).Length;
    1380           8 :                 if (RefrigCase(CaseNum).RefrigInventory < 0.0) {
    1381           0 :                     ShowSevereError(state,
    1382           0 :                                     format("{}{}=\"{}\" {} must be a positive number.",
    1383             :                                            RoutineName,
    1384             :                                            CurrentModuleObject,
    1385           0 :                                            RefrigCase(CaseNum).Name,
    1386             :                                            cNumericFieldNames(NumNum)));
    1387           0 :                     ErrorsFound = true;
    1388             :                 }
    1389             :             } else {
    1390         178 :                 RefrigCase(CaseNum).RefrigInventory = 0.0;
    1391             :             }
    1392             : 
    1393         186 :         } // Individual refrigerated cases
    1394             :     }     //(NumSimulationCases > 0 )
    1395             : 
    1396             :     //************ START WALK IN COOLER INPUT **************
    1397             : 
    1398         796 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    1399          13 :         CurrentModuleObject = "Refrigeration:WalkIn";
    1400          28 :         for (int WalkInID = 1; WalkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInID) {
    1401          15 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1402             :                                                                      CurrentModuleObject,
    1403             :                                                                      WalkInID,
    1404             :                                                                      Alphas,
    1405             :                                                                      NumAlphas,
    1406             :                                                                      Numbers,
    1407             :                                                                      NumNumbers,
    1408             :                                                                      IOStatus,
    1409             :                                                                      lNumericBlanks,
    1410             :                                                                      lAlphaBlanks,
    1411             :                                                                      cAlphaFieldNames,
    1412             :                                                                      cNumericFieldNames);
    1413          15 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1414             : 
    1415          15 :             WalkIn(WalkInID).Name = Alphas(1);
    1416             : 
    1417          15 :             if (!lAlphaBlanks(2)) {
    1418          15 :                 WalkIn(WalkInID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    1419          15 :                 if (WalkIn(WalkInID).SchedPtr == 0) {
    1420           0 :                     ShowSevereError(state,
    1421           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1422             :                                            RoutineName,
    1423             :                                            CurrentModuleObject,
    1424           0 :                                            WalkIn(WalkInID).Name,
    1425             :                                            cAlphaFieldNames(2),
    1426             :                                            Alphas(2)));
    1427           0 :                     ErrorsFound = true;
    1428             :                 }    // ptr == 0
    1429             :             } else { // no schedule specified
    1430           0 :                 WalkIn(WalkInID).SchedPtr = AlwaysOn;
    1431             :             } // not blank
    1432             : 
    1433             :             //   check availability schedule for values between 0 and 1
    1434          15 :             if (WalkIn(WalkInID).SchedPtr > 0) {
    1435          15 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).SchedPtr, ">=", 0.0, "<=", 1.0)) {
    1436           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name));
    1437           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(2), Alphas(2)));
    1438           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1439           0 :                     ErrorsFound = true;
    1440             :                 }
    1441             :             }
    1442             : 
    1443          15 :             WalkIn(WalkInID).DesignRatedCap = Numbers(1);
    1444          15 :             if (Numbers(1) <= 0.0) {
    1445           0 :                 ShowSevereError(
    1446             :                     state,
    1447           0 :                     format(
    1448           0 :                         "{}{}=\"{}\", {} must be greater than 0 W", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(1)));
    1449           0 :                 ErrorsFound = true;
    1450             :             }
    1451             : 
    1452          15 :             if (!lNumericBlanks(2)) {
    1453          15 :                 WalkIn(WalkInID).Temperature = Numbers(2);
    1454             :             } else {
    1455           0 :                 ShowSevereError(
    1456           0 :                     state, format("{}{}=\"{}\", {} must be input ", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(2)));
    1457           0 :                 ErrorsFound = true;
    1458             :             }
    1459             : 
    1460          15 :             if (!lNumericBlanks(3)) {
    1461          15 :                 WalkIn(WalkInID).TEvapDesign = Numbers(3);
    1462             :             } else {
    1463           0 :                 ShowSevereError(
    1464           0 :                     state, format("{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(3)));
    1465           0 :                 ErrorsFound = true;
    1466             :             }
    1467             : 
    1468          15 :             if (!lNumericBlanks(4)) {
    1469          15 :                 WalkIn(WalkInID).HeaterPower = Numbers(4);
    1470             :             } else {
    1471           0 :                 ShowSevereError(
    1472           0 :                     state, format("{}{}=\"{}\", {} must be input ", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(4)));
    1473           0 :                 ErrorsFound = true;
    1474             :             }
    1475             : 
    1476          15 :             AlphaNum = 3;
    1477          15 :             if (!lAlphaBlanks(AlphaNum)) {
    1478          30 :                 WalkIn(WalkInID).HeaterSchedPtr =
    1479          15 :                     ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert heater schedule name to pointer
    1480          15 :                 if (WalkIn(WalkInID).HeaterSchedPtr == 0) {
    1481           0 :                     ShowSevereError(state,
    1482           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1483             :                                            RoutineName,
    1484             :                                            CurrentModuleObject,
    1485           0 :                                            WalkIn(WalkInID).Name,
    1486             :                                            cAlphaFieldNames(AlphaNum),
    1487             :                                            Alphas(AlphaNum)));
    1488           0 :                     ErrorsFound = true;
    1489             :                 }    // ptr == 0
    1490             :             } else { // no schedule specified
    1491           0 :                 WalkIn(WalkInID).HeaterSchedPtr = AlwaysOn;
    1492             :             } // not blank
    1493             : 
    1494             :             //   check heater schedule for values between 0 and 1
    1495          15 :             if (WalkIn(WalkInID).HeaterSchedPtr > 0) {
    1496          15 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).HeaterSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1497           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name));
    1498           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    1499           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1500           0 :                     ErrorsFound = true;
    1501             :                 }
    1502             :             }
    1503             : 
    1504          15 :             if (!lNumericBlanks(5) && Numbers(5) > 0.0) {
    1505          15 :                 WalkIn(WalkInID).CoilFanPower = Numbers(5);
    1506             :             } else {
    1507           0 :                 ShowWarningError(state,
    1508           0 :                                  format("{}{}=\"{}\", {} was not input or was less than 0 and default of 375.0 W will be used ",
    1509             :                                         RoutineName,
    1510             :                                         CurrentModuleObject,
    1511           0 :                                         WalkIn(WalkInID).Name,
    1512             :                                         cNumericFieldNames(5)));
    1513           0 :                 WalkIn(WalkInID).CoilFanPower = 375.0; // default value = 1/2 hp
    1514             :             }
    1515             : 
    1516          15 :             if (lNumericBlanks(6)) {
    1517           0 :                 WalkIn(WalkInID).CircFanPower = 0.0;
    1518             :             } else {
    1519          15 :                 WalkIn(WalkInID).CircFanPower = Numbers(6);
    1520          15 :                 if (Numbers(7) < 0.0) {
    1521           0 :                     ShowSevereError(state,
    1522           0 :                                     format("{}{}=\"{}\", {} must be greater than >= 0 W",
    1523             :                                            RoutineName,
    1524             :                                            CurrentModuleObject,
    1525           0 :                                            WalkIn(WalkInID).Name,
    1526             :                                            cNumericFieldNames(6)));
    1527           0 :                     ErrorsFound = true;
    1528             :                 }
    1529             :             }
    1530             : 
    1531          15 :             if (!lNumericBlanks(7)) {
    1532          15 :                 WalkIn(WalkInID).DesignLighting = Numbers(7);
    1533             :             } else {
    1534           0 :                 ShowSevereError(
    1535           0 :                     state, format("{}{}=\"{}\" {} must be input ", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(7)));
    1536           0 :                 ErrorsFound = true;
    1537             :             }
    1538             : 
    1539          15 :             AlphaNum = 4;
    1540          15 :             if (!lAlphaBlanks(AlphaNum)) {
    1541          30 :                 WalkIn(WalkInID).LightingSchedPtr =
    1542          15 :                     ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert lighting schedule name to pointer
    1543          15 :                 if (WalkIn(WalkInID).LightingSchedPtr == 0) {
    1544           0 :                     ShowSevereError(state,
    1545           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1546             :                                            RoutineName,
    1547             :                                            CurrentModuleObject,
    1548           0 :                                            WalkIn(WalkInID).Name,
    1549             :                                            cAlphaFieldNames(AlphaNum),
    1550             :                                            Alphas(AlphaNum)));
    1551           0 :                     ErrorsFound = true;
    1552             :                 }    // ptr == 0
    1553             :             } else { // no schedule specified
    1554           0 :                 WalkIn(WalkInID).LightingSchedPtr = AlwaysOn;
    1555             :             } // schedule name not blank
    1556             :             //   check Lighting schedule for values between 0 and 1
    1557          15 :             if (WalkIn(WalkInID).LightingSchedPtr > 0) {
    1558          15 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).LightingSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1559           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name));
    1560           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    1561           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1562           0 :                     ErrorsFound = true;
    1563             :                 }
    1564             :             }
    1565             : 
    1566             :             // Input walk-in cooler defrost information
    1567          15 :             AlphaNum = 5;
    1568          15 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "Electric")) {
    1569          13 :                 WalkIn(WalkInID).defrostType = WalkinClrDefrostType::Elec;
    1570           2 :             } else if (Util::SameString(Alphas(AlphaNum), "HotFluid")) {
    1571           2 :                 WalkIn(WalkInID).defrostType = WalkinClrDefrostType::Fluid;
    1572           0 :             } else if (Util::SameString(Alphas(AlphaNum), "None")) {
    1573           0 :                 WalkIn(WalkInID).defrostType = WalkinClrDefrostType::None;
    1574           0 :             } else if (Util::SameString(Alphas(AlphaNum), "OffCycle")) {
    1575           0 :                 WalkIn(WalkInID).defrostType = WalkinClrDefrostType::OffCycle;
    1576             :             } else {
    1577           0 :                 ShowSevereError(state,
    1578           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    1579             :                                        RoutineName,
    1580             :                                        CurrentModuleObject,
    1581           0 :                                        WalkIn(WalkInID).Name,
    1582             :                                        cAlphaFieldNames(AlphaNum),
    1583             :                                        Alphas(AlphaNum)));
    1584           0 :                 ErrorsFound = true;
    1585             :             }
    1586             : 
    1587          15 :             AlphaNum = 6;
    1588          15 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "TimeSchedule")) {
    1589          11 :                 WalkIn(WalkInID).DefrostControlType = DefrostCtrlType::Sched;
    1590           4 :             } else if (Util::SameString(Alphas(AlphaNum), "TemperatureTermination")) {
    1591           4 :                 WalkIn(WalkInID).DefrostControlType = DefrostCtrlType::TempTerm;
    1592             :             } else {
    1593           0 :                 ShowSevereError(state,
    1594           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    1595             :                                        RoutineName,
    1596             :                                        CurrentModuleObject,
    1597           0 :                                        WalkIn(WalkInID).Name,
    1598             :                                        cAlphaFieldNames(AlphaNum),
    1599             :                                        Alphas(AlphaNum)));
    1600           0 :                 ErrorsFound = true;
    1601             :             } // defrost control type
    1602             : 
    1603             :             // convert defrost schedule name to pointer
    1604          15 :             AlphaNum = 7;
    1605          15 :             WalkIn(WalkInID).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum));
    1606          15 :             if (WalkIn(WalkInID).DefrostSchedPtr == 0) {
    1607           0 :                 ShowSevereError(state,
    1608           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    1609             :                                        RoutineName,
    1610             :                                        CurrentModuleObject,
    1611           0 :                                        WalkIn(WalkInID).Name,
    1612             :                                        cAlphaFieldNames(AlphaNum),
    1613             :                                        Alphas(AlphaNum)));
    1614           0 :                 ErrorsFound = true;
    1615             :             }
    1616             :             //   check defrost schedule for values between 0 and 1
    1617          15 :             if (WalkIn(WalkInID).DefrostSchedPtr > 0) {
    1618          15 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1619           0 :                     ShowSevereError(state, format("{}{} = \"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name));
    1620           0 :                     ShowContinueError(state, format("Error found in {}={}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    1621           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1622           0 :                     ErrorsFound = true;
    1623             :                 }
    1624             :             }
    1625             : 
    1626             :             // convert defrost drip-down schedule name to pointer
    1627             :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1628          15 :             AlphaNum = 8;
    1629          15 :             if (!lAlphaBlanks(AlphaNum)) {
    1630          14 :                 WalkIn(WalkInID).DefrostDripDownSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum));
    1631          14 :                 if (WalkIn(WalkInID).DefrostDripDownSchedPtr == 0) {
    1632           0 :                     ShowSevereError(state,
    1633           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1634             :                                            RoutineName,
    1635             :                                            CurrentModuleObject,
    1636           0 :                                            WalkIn(WalkInID).Name,
    1637             :                                            cAlphaFieldNames(AlphaNum),
    1638             :                                            Alphas(AlphaNum)));
    1639           0 :                     ErrorsFound = true;
    1640             :                 }
    1641             :                 // check schedule for values between 0 and 1
    1642          14 :                 if (WalkIn(WalkInID).DefrostDripDownSchedPtr > 0) {
    1643          14 :                     if (!ScheduleManager::CheckScheduleValueMinMax(state, WalkIn(WalkInID).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) {
    1644           0 :                         ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name));
    1645           0 :                         ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    1646           0 :                         ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1647           0 :                         ErrorsFound = true;
    1648             :                     }
    1649             :                 }
    1650             :             } else { // blank input so use drip down schedule for defrost
    1651           1 :                 WalkIn(WalkInID).DefrostDripDownSchedPtr = WalkIn(WalkInID).DefrostSchedPtr;
    1652             :             }
    1653             : 
    1654          15 :             if (WalkIn(WalkInID).defrostType == WalkinClrDefrostType::OffCycle || WalkIn(WalkInID).defrostType == WalkinClrDefrostType::None) {
    1655           0 :                 WalkIn(WalkInID).DefrostCapacity = 0.0;
    1656             :                 // Don't even need to read N8 or N9 for those two defrost types.
    1657             :             } else { // have electric or hot gas/brine defrost
    1658          15 :                 if ((lNumericBlanks(8)) || (Numbers(8) <= 0.0)) {
    1659           0 :                     ShowSevereError(state,
    1660           0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    1661             :                                            RoutineName,
    1662             :                                            CurrentModuleObject,
    1663           0 :                                            WalkIn(WalkInID).Name,
    1664             :                                            cNumericFieldNames(8),
    1665             :                                            cAlphaFieldNames(5),
    1666             :                                            Alphas(5)));
    1667           0 :                     ErrorsFound = true;
    1668             :                 } else {
    1669          15 :                     WalkIn(WalkInID).DefrostCapacity = Numbers(8);
    1670             :                 } // Blank  or negative N8
    1671             : 
    1672             :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    1673             :                 // note this value is only used for temperature terminated defrost control type
    1674          15 :                 if (WalkIn(WalkInID).defrostType == WalkinClrDefrostType::Elec) WalkIn(WalkInID).DefEnergyFraction = 0.7;
    1675          15 :                 if (WalkIn(WalkInID).defrostType == WalkinClrDefrostType::Fluid) WalkIn(WalkInID).DefEnergyFraction = 0.3;
    1676          15 :                 if (!lNumericBlanks(9)) {
    1677           4 :                     if ((Numbers(9) > 1.0) || (Numbers(9) < 0.0)) {
    1678           0 :                         ShowWarningError(state,
    1679           0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    1680             :                                                 RoutineName,
    1681             :                                                 CurrentModuleObject,
    1682           0 :                                                 WalkIn(WalkInID).Name,
    1683             :                                                 cNumericFieldNames(9)));
    1684             :                     } else {
    1685           4 :                         WalkIn(WalkInID).DefEnergyFraction = Numbers(9);
    1686             :                     } // number out of range
    1687             :                 }     // lnumericblanks
    1688             :             }         // defrost type
    1689             : 
    1690             :             // convert restocking schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1691          15 :             AlphaNum = 9;
    1692          15 :             if (lAlphaBlanks(AlphaNum)) {
    1693           0 :                 WalkIn(WalkInID).StockingSchedPtr = 0;
    1694             :             } else {
    1695          15 :                 WalkIn(WalkInID).StockingSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum));
    1696          15 :                 if (WalkIn(WalkInID).StockingSchedPtr == 0) {
    1697           0 :                     ShowSevereError(state,
    1698           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1699             :                                            RoutineName,
    1700             :                                            CurrentModuleObject,
    1701           0 :                                            WalkIn(WalkInID).Name,
    1702             :                                            cAlphaFieldNames(AlphaNum),
    1703             :                                            Alphas(AlphaNum)));
    1704           0 :                     ErrorsFound = true;
    1705             :                 }
    1706             :             } // blank
    1707             : 
    1708          15 :             WalkIn(WalkInID).DesignRefrigInventory = 0.0;
    1709          15 :             if (!lNumericBlanks(10)) WalkIn(WalkInID).DesignRefrigInventory = Numbers(10);
    1710             : 
    1711          15 :             if (!lNumericBlanks(11)) {
    1712          15 :                 WalkIn(WalkInID).FloorArea = Numbers(11);
    1713             :             } else {
    1714           0 :                 ShowSevereError(
    1715           0 :                     state, format("{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(11)));
    1716           0 :                 ErrorsFound = true;
    1717             :             }
    1718             : 
    1719          15 :             if (lNumericBlanks(12)) {
    1720           0 :                 WalkIn(WalkInID).FloorUValue = DefaultWISurfaceUValue;
    1721             :             } else {
    1722          15 :                 WalkIn(WalkInID).FloorUValue = Numbers(12);
    1723          15 :                 if (Numbers(12) <= 0.0) {
    1724           0 :                     ShowSevereError(
    1725             :                         state,
    1726           0 :                         format("{}{}=\"{}\", {} must be > 0.", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(12)));
    1727           0 :                     ErrorsFound = true;
    1728             :                 }
    1729             :             }
    1730             : 
    1731             :             // Calculate the number of zones exposed to walk-in based on number of input fields, all integer math,
    1732             :             // This approach used because last zone could have less than NumWIFieldsPerZone due to optional values
    1733          15 :             int NumWIFieldsPerZone = NumWIAlphaFieldsPerZone + NumWINumberFieldsPerZone;
    1734          15 :             int NumWIFieldsTotal = NumNumbers + NumAlphas - NumWIAlphaFieldsBeforeZoneInput - NumWINumberFieldsBeforeZoneInput;
    1735          15 :             int NumZones = 1;
    1736          15 :             if (NumWIFieldsTotal > NumWIFieldsPerZone) NumZones = 2;
    1737          15 :             if (NumWIFieldsTotal > (2 * NumWIFieldsPerZone)) NumZones = 3;
    1738          15 :             if (NumWIFieldsTotal > (3 * NumWIFieldsPerZone)) NumZones = 4;
    1739          15 :             if (NumWIFieldsTotal > (4 * NumWIFieldsPerZone)) NumZones = 5;
    1740          15 :             if (NumWIFieldsTotal > (5 * NumWIFieldsPerZone)) NumZones = 6;
    1741          15 :             WalkIn(WalkInID).NumZones = NumZones;
    1742             : 
    1743             :             // All variables for walk-in/zone interactions need to be allocated after know number of zones
    1744             :             // Autodesk Missing initialization added below: At least SensZoneCreditRate was used uninitialized
    1745          15 :             if (!allocated(WalkIn(WalkInID).ZoneName)) WalkIn(WalkInID).ZoneName.allocate(NumZones);
    1746          15 :             if (!allocated(WalkIn(WalkInID).ZoneNum)) WalkIn(WalkInID).ZoneNum.allocate(NumZones) = 0;
    1747          15 :             if (!allocated(WalkIn(WalkInID).ZoneNodeNum)) WalkIn(WalkInID).ZoneNodeNum.allocate(NumZones) = 0;
    1748          15 :             if (!allocated(WalkIn(WalkInID).SurfaceArea)) WalkIn(WalkInID).SurfaceArea.allocate(NumZones) = 0.0;
    1749          15 :             if (!allocated(WalkIn(WalkInID).UValue)) WalkIn(WalkInID).UValue.allocate(NumZones) = 0.0;
    1750          15 :             if (!allocated(WalkIn(WalkInID).UValueGlassDr)) WalkIn(WalkInID).UValueGlassDr.allocate(NumZones) = 0.0;
    1751          15 :             if (!allocated(WalkIn(WalkInID).GlassDoorOpenSchedPtr)) WalkIn(WalkInID).GlassDoorOpenSchedPtr.allocate(NumZones) = 0;
    1752          15 :             if (!allocated(WalkIn(WalkInID).AreaGlassDr)) WalkIn(WalkInID).AreaGlassDr.allocate(NumZones) = 0.0;
    1753          15 :             if (!allocated(WalkIn(WalkInID).HeightGlassDr)) WalkIn(WalkInID).HeightGlassDr.allocate(NumZones) = 0.0;
    1754          15 :             if (!allocated(WalkIn(WalkInID).UValueStockDr)) WalkIn(WalkInID).UValueStockDr.allocate(NumZones) = 0.0;
    1755          15 :             if (!allocated(WalkIn(WalkInID).StockDoorOpenSchedPtr)) WalkIn(WalkInID).StockDoorOpenSchedPtr.allocate(NumZones) = 0;
    1756          15 :             if (!allocated(WalkIn(WalkInID).StockDoorProtectType)) WalkIn(WalkInID).StockDoorProtectType.allocate(NumZones) = WIStockDoor::Invalid;
    1757          15 :             if (!allocated(WalkIn(WalkInID).AreaStockDr)) WalkIn(WalkInID).AreaStockDr.allocate(NumZones) = 0.0;
    1758          15 :             if (!allocated(WalkIn(WalkInID).HeightStockDr)) WalkIn(WalkInID).HeightStockDr.allocate(NumZones) = 0.0;
    1759          15 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditRate)) WalkIn(WalkInID).SensZoneCreditRate.allocate(NumZones) = 0.0;
    1760          15 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCoolRate)) WalkIn(WalkInID).SensZoneCreditCoolRate.allocate(NumZones) = 0.0;
    1761          15 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCool)) WalkIn(WalkInID).SensZoneCreditCool.allocate(NumZones) = 0.0;
    1762          15 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeatRate)) WalkIn(WalkInID).SensZoneCreditHeatRate.allocate(NumZones) = 0.0;
    1763          15 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeat)) WalkIn(WalkInID).SensZoneCreditHeat.allocate(NumZones) = 0.0;
    1764          15 :             if (!allocated(WalkIn(WalkInID).LatZoneCreditRate)) WalkIn(WalkInID).LatZoneCreditRate.allocate(NumZones) = 0.0;
    1765          15 :             if (!allocated(WalkIn(WalkInID).LatZoneCredit)) WalkIn(WalkInID).LatZoneCredit.allocate(NumZones) = 0.0;
    1766             : 
    1767          15 :             int AStart = NumWIAlphaFieldsBeforeZoneInput + 1;
    1768          15 :             int NStart = NumWINumberFieldsBeforeZoneInput + 1;
    1769          30 :             for (int ZoneID = 1; ZoneID <= NumZones; ++ZoneID) {
    1770             :                 // Get the Zone node number from the zone name
    1771             :                 // The Zone Node is needed to get the zone's ambient conditions, DataGlobals::NumOfZones from dataglobals
    1772          15 :                 WalkIn(WalkInID).ZoneName(ZoneID) = Alphas(AStart);
    1773          15 :                 WalkIn(WalkInID).ZoneNum(ZoneID) = Util::FindItemInList(Alphas(AStart), state.dataHeatBal->Zone);
    1774             : 
    1775          15 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) == 0) {
    1776           0 :                     ShowSevereError(state,
    1777           0 :                                     format("{}{}=\"{}\", invalid  {} not valid: {}",
    1778             :                                            RoutineName,
    1779             :                                            CurrentModuleObject,
    1780           0 :                                            WalkIn(WalkInID).Name,
    1781             :                                            cAlphaFieldNames(AStart),
    1782             :                                            Alphas(AStart)));
    1783           0 :                     ErrorsFound = true;
    1784             :                 } else {
    1785          15 :                     state.dataRefrigCase->RefrigPresentInZone(WalkIn(WalkInID).ZoneNum(ZoneID)) = true;
    1786             :                 }
    1787          15 :                 WalkIn(WalkInID).ZoneNodeNum(ZoneID) = DataZoneEquipment::GetSystemNodeNumberForZone(state, WalkIn(WalkInID).ZoneNum(ZoneID));
    1788          15 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) >= 0) {
    1789          15 :                     if (WalkIn(WalkInID).ZoneNodeNum(ZoneID) == 0) {
    1790           0 :                         ShowSevereError(state,
    1791           0 :                                         format("{}{}=\"{}\" System Node Number not found for {} = {}",
    1792             :                                                RoutineName,
    1793             :                                                CurrentModuleObject,
    1794           0 :                                                WalkIn(WalkInID).Name,
    1795             :                                                cAlphaFieldNames(AStart),
    1796             :                                                Alphas(AStart)));
    1797           0 :                         ShowContinueError(state, ".. Walk Ins must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    1798           0 :                         ErrorsFound = true;
    1799             :                     }
    1800             :                 }
    1801             : 
    1802          15 :                 if (!lNumericBlanks(NStart)) {
    1803          15 :                     WalkIn(WalkInID).SurfaceArea(ZoneID) = Numbers(NStart);
    1804             :                 } else {
    1805           0 :                     ShowSevereError(state,
    1806           0 :                                     format("{}{}=\"{}\", {} must be input for Zone: {}",
    1807             :                                            RoutineName,
    1808             :                                            CurrentModuleObject,
    1809           0 :                                            WalkIn(WalkInID).Name,
    1810             :                                            cNumericFieldNames(NStart),
    1811           0 :                                            WalkIn(WalkInID).ZoneName(ZoneID)));
    1812           0 :                     ErrorsFound = true;
    1813             :                 }
    1814             : 
    1815          15 :                 if (lNumericBlanks(NStart + 1)) {
    1816           0 :                     WalkIn(WalkInID).UValue(ZoneID) = DefaultWISurfaceUValue;
    1817             :                 } else {
    1818          15 :                     WalkIn(WalkInID).UValue(ZoneID) = Numbers(NStart + 1);
    1819          15 :                     if (Numbers(NStart + 1) <= 0.0) {
    1820           0 :                         ShowSevereError(state,
    1821           0 :                                         format(R"({}{}="{}", Zone="{}", {} must be > 0.)",
    1822             :                                                RoutineName,
    1823             :                                                CurrentModuleObject,
    1824           0 :                                                WalkIn(WalkInID).Name,
    1825           0 :                                                WalkIn(WalkInID).ZoneName(ZoneID),
    1826             :                                                cNumericFieldNames(NStart + 1)));
    1827           0 :                         ErrorsFound = true;
    1828             :                     }
    1829             :                 }
    1830             : 
    1831             :                 // start IF set for glass doors in this zone
    1832          15 :                 WalkIn(WalkInID).AreaGlassDr(ZoneID) = 0.0;
    1833          15 :                 WalkIn(WalkInID).HeightGlassDr(ZoneID) = 0.0;
    1834          15 :                 WalkIn(WalkInID).UValueGlassDr(ZoneID) = 0.0;
    1835          15 :                 if (!lNumericBlanks(NStart + 2)) {
    1836           4 :                     WalkIn(WalkInID).AreaGlassDr(ZoneID) = Numbers(NStart + 2);
    1837             : 
    1838           4 :                     WalkIn(WalkInID).HeightGlassDr(ZoneID) = DefaultWIHeightGlassDr;
    1839           4 :                     if (!lNumericBlanks(NStart + 3)) WalkIn(WalkInID).HeightGlassDr(ZoneID) = Numbers(NStart + 3);
    1840             : 
    1841           4 :                     WalkIn(WalkInID).UValueGlassDr(ZoneID) = DefaultWIUValueGlassDr;
    1842           4 :                     if (!lNumericBlanks(NStart + 4)) WalkIn(WalkInID).UValueGlassDr(ZoneID) = Numbers(NStart + 4);
    1843             : 
    1844             :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1845           4 :                     if (lAlphaBlanks(AStart + 1)) {
    1846           0 :                         WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) = 0;
    1847             :                     } else {
    1848           4 :                         WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) = ScheduleManager::GetScheduleIndex(state, Alphas(AStart + 1));
    1849           4 :                         if (WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID) == 0) {
    1850           0 :                             ShowSevereError(state,
    1851           0 :                                             format(R"({}{}="{}", Zone="{}", invalid  {} not found: {})",
    1852             :                                                    RoutineName,
    1853             :                                                    CurrentModuleObject,
    1854           0 :                                                    WalkIn(WalkInID).Name,
    1855           0 :                                                    WalkIn(WalkInID).ZoneName(ZoneID),
    1856             :                                                    cAlphaFieldNames(AStart + 1),
    1857             :                                                    Alphas(AStart + 1)));
    1858           0 :                             ErrorsFound = true;
    1859             :                         } else {
    1860             :                             //       check schedule for values between 0 and 1
    1861           8 :                             if (!ScheduleManager::CheckScheduleValueMinMax(
    1862           4 :                                     state, WalkIn(WalkInID).GlassDoorOpenSchedPtr(ZoneID), ">=", 0.0, "<=", 1.0)) {
    1863           0 :                                 ShowSevereError(state,
    1864           0 :                                                 format(R"({}{}="{}", Zone="{}")",
    1865             :                                                        RoutineName,
    1866             :                                                        CurrentModuleObject,
    1867           0 :                                                        WalkIn(WalkInID).Name,
    1868           0 :                                                        WalkIn(WalkInID).ZoneName(ZoneID)));
    1869           0 :                                 ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AStart + 1), Alphas(AStart + 1)));
    1870           0 :                                 ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1871           0 :                                 ErrorsFound = true;
    1872             :                             } // schedule values outside range
    1873             :                         }     // have schedule pointer
    1874             :                     }         // blank on door opening schedule (AStart + 1)
    1875             :                 }             // have glassdoor area facing zone (blank on lNumericBlanks(NStart+2))
    1876             : 
    1877             :                 // start IF set for stock doors in this zone
    1878          15 :                 WalkIn(WalkInID).AreaStockDr(ZoneID) = 0.0;
    1879          15 :                 WalkIn(WalkInID).HeightStockDr(ZoneID) = 0.0;
    1880          15 :                 WalkIn(WalkInID).UValueStockDr(ZoneID) = 0.0;
    1881          15 :                 if (!lNumericBlanks(NStart + 5)) {
    1882          15 :                     WalkIn(WalkInID).AreaStockDr(ZoneID) = Numbers(NStart + 5);
    1883             : 
    1884          15 :                     WalkIn(WalkInID).HeightStockDr(ZoneID) = DefaultWIHeightStockDr;
    1885          15 :                     if (!lNumericBlanks(NStart + 6)) WalkIn(WalkInID).HeightStockDr(ZoneID) = Numbers(NStart + 6);
    1886             : 
    1887          15 :                     WalkIn(WalkInID).UValueStockDr(ZoneID) = DefaultWIUValueStockDr;
    1888          15 :                     if (!lNumericBlanks(NStart + 7)) WalkIn(WalkInID).UValueStockDr(ZoneID) = Numbers(NStart + 7);
    1889             : 
    1890             :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1891          15 :                     if (lAlphaBlanks(AStart + 2)) {
    1892           0 :                         WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) = 0;
    1893             :                     } else {
    1894          15 :                         WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) = ScheduleManager::GetScheduleIndex(state, Alphas(AStart + 2));
    1895          15 :                         if (WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID) == 0) {
    1896           0 :                             ShowSevereError(state,
    1897           0 :                                             format(R"({}{}="{}", Zone="{}", invalid  {} not found: {})",
    1898             :                                                    RoutineName,
    1899             :                                                    CurrentModuleObject,
    1900           0 :                                                    WalkIn(WalkInID).Name,
    1901           0 :                                                    WalkIn(WalkInID).ZoneName(ZoneID),
    1902             :                                                    cAlphaFieldNames(AStart + 2),
    1903             :                                                    Alphas(AStart + 2)));
    1904           0 :                             ErrorsFound = true;
    1905             :                         } else {
    1906             :                             //       check schedule for values between 0 and 1
    1907          30 :                             if (!ScheduleManager::CheckScheduleValueMinMax(
    1908          15 :                                     state, WalkIn(WalkInID).StockDoorOpenSchedPtr(ZoneID), ">=", 0.0, "<=", 1.0)) {
    1909           0 :                                 ShowSevereError(state,
    1910           0 :                                                 format(R"({}{}="{}", Zone="{}")",
    1911             :                                                        RoutineName,
    1912             :                                                        CurrentModuleObject,
    1913           0 :                                                        WalkIn(WalkInID).Name,
    1914           0 :                                                        WalkIn(WalkInID).ZoneName(ZoneID)));
    1915           0 :                                 ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AStart + 2), Alphas(AStart + 2)));
    1916           0 :                                 ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1917           0 :                                 ErrorsFound = true;
    1918             :                             } // schedule values outside range
    1919             :                         }     // have schedule pointer
    1920             :                     }         // blank on door opening schedule (AStart + 2)
    1921             : 
    1922          15 :                     if (lAlphaBlanks(AStart + 3) || Util::SameString(Alphas(AStart + 3), "AirCurtain")) {
    1923             :                         // default air curtain
    1924           0 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::AirCurtain;
    1925          15 :                     } else if (Util::SameString(Alphas(AStart + 3), "None")) {
    1926           4 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::None;
    1927          11 :                     } else if (Util::SameString(Alphas(AStart + 3), "StripCurtain")) {
    1928          11 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::StripCurtain;
    1929             :                     } else {
    1930           0 :                         ShowSevereError(state,
    1931           0 :                                         format(R"({}{}="{}", invalid  {}="{}".)",
    1932             :                                                RoutineName,
    1933             :                                                CurrentModuleObject,
    1934           0 :                                                WalkIn(WalkInID).Name,
    1935             :                                                cAlphaFieldNames(AStart + 3),
    1936             :                                                Alphas(AStart + 3)));
    1937           0 :                         ErrorsFound = true;
    1938             :                     } // stock door protection (AStart + 3) blank
    1939             :                 }     // have Stockdoor area facing zone
    1940             : 
    1941          15 :                 AStart += NumWIAlphaFieldsPerZone;
    1942          15 :                 NStart += NumWINumberFieldsPerZone;
    1943             :             } // Zones for Walk Ins
    1944             :         }     // Individual Walk Ins
    1945             :     }         //(NumSimulationWalkIns > 0 )
    1946             : 
    1947             :     //************* Start Indiv Refrig Air Chillers
    1948             : 
    1949         796 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    1950           1 :         CurrentModuleObject = "Refrigeration:AirChiller";
    1951          84 :         for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
    1952             :             // A1
    1953          83 :             AlphaNum = 1;
    1954          83 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1955             :                                                                      CurrentModuleObject,
    1956             :                                                                      CoilID,
    1957             :                                                                      Alphas,
    1958             :                                                                      NumAlphas,
    1959             :                                                                      Numbers,
    1960             :                                                                      NumNumbers,
    1961             :                                                                      IOStatus,
    1962             :                                                                      lNumericBlanks,
    1963             :                                                                      lAlphaBlanks,
    1964             :                                                                      cAlphaFieldNames,
    1965             :                                                                      cNumericFieldNames);
    1966          83 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1967             : 
    1968          83 :             WarehouseCoil(CoilID).Name = Alphas(AlphaNum);
    1969             : 
    1970             :             // A2
    1971          83 :             ++AlphaNum;
    1972          83 :             if (!lAlphaBlanks(AlphaNum)) {
    1973          83 :                 WarehouseCoil(CoilID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer
    1974          83 :                 if (WarehouseCoil(CoilID).SchedPtr == 0) {
    1975           0 :                     ShowSevereError(state,
    1976           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    1977             :                                            RoutineName,
    1978             :                                            CurrentModuleObject,
    1979           0 :                                            WarehouseCoil(CoilID).Name,
    1980             :                                            cAlphaFieldNames(AlphaNum),
    1981             :                                            Alphas(AlphaNum)));
    1982           0 :                     ErrorsFound = true;
    1983             :                 }    // ptr == 0
    1984             :             } else { // no schedule specified
    1985           0 :                 WarehouseCoil(CoilID).SchedPtr = AlwaysOn;
    1986             :             } // not blank
    1987             : 
    1988             :             //   check availability schedule for values between 0 and 1
    1989          83 :             if (WarehouseCoil(CoilID).SchedPtr > 0) {
    1990          83 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).SchedPtr, ">=", 0.0, "<=", 1.0)) {
    1991           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    1992           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    1993           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    1994           0 :                     ErrorsFound = true;
    1995             :                 }
    1996             :             }
    1997             : 
    1998             :             // Input capacity rating type
    1999             :             // bbbbb input values (DT1 or DTM type)translate DT1 to DTm here because node will give avg temp?
    2000             :             //      ask whether ceiling or floor mounted? - effects translation from DT1 to DTM
    2001             :             //      input coil condition, wet or dry OR input rating basis, European SC1, SC2 etc., have to combine with refrigerant factor)
    2002             :             //      rated capacity, BAC give W/C, European gives W
    2003             :             //      fin material factor, default 1
    2004             :             //      refrigerant factor (factor of both refrigerant and Tevap)
    2005             : 
    2006             :             // A3
    2007          83 :             ++AlphaNum;
    2008          83 :             if (lAlphaBlanks(AlphaNum)) {
    2009           0 :                 ShowSevereError(state,
    2010           0 :                                 format("{}{}=\"{}{} is required and not found.",
    2011             :                                        RoutineName,
    2012             :                                        CurrentModuleObject,
    2013           0 :                                        WarehouseCoil(CoilID).Name,
    2014             :                                        cAlphaFieldNames(AlphaNum)));
    2015           0 :                 ErrorsFound = true;
    2016          83 :             } else if (Util::SameString(Alphas(AlphaNum), "UnitLoadFactorSensibleOnly")) {
    2017          81 :                 WarehouseCoil(CoilID).ratingType = RatingType::UnitLoadFactorSens;
    2018           2 :             } else if (Util::SameString(Alphas(AlphaNum), "CapacityTotalSpecificConditions")) {
    2019           1 :                 WarehouseCoil(CoilID).ratingType = RatingType::RatedCapacityTotal;
    2020           1 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC1Standard")) {
    2021           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC1Std;
    2022           1 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC1NominalWet")) {
    2023           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC1Nom;
    2024           1 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC2Standard")) {
    2025           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC2Std;
    2026           1 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC2NominalWet")) {
    2027           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC2Nom;
    2028           1 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC3Standard")) {
    2029           1 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC3Std;
    2030           0 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC3NominalWet")) {
    2031           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC3Nom;
    2032           0 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC4Standard")) {
    2033           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC4Std;
    2034           0 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC4NominalWet")) {
    2035           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC4Nom;
    2036           0 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC5Standard")) {
    2037           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC5Std;
    2038           0 :             } else if (Util::SameString(Alphas(AlphaNum), "EuropeanSC5NominalWet")) {
    2039           0 :                 WarehouseCoil(CoilID).ratingType = RatingType::EuropeanSC5Nom;
    2040             :             } else {
    2041           0 :                 ShowSevereError(state,
    2042           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    2043             :                                        RoutineName,
    2044             :                                        CurrentModuleObject,
    2045           0 :                                        WarehouseCoil(CoilID).Name,
    2046             :                                        cAlphaFieldNames(AlphaNum),
    2047             :                                        Alphas(AlphaNum)));
    2048           0 :                 ErrorsFound = true;
    2049             :             }
    2050             : 
    2051             :             // Here have to do select case with one numeric field with units of W and the second with units of W/deltaC,
    2052             :             //  (RatedRH field only used for RatedCapacityTotal type)
    2053             :             {
    2054          83 :                 switch (WarehouseCoil(CoilID).ratingType) {
    2055          81 :                 case RatingType::UnitLoadFactorSens:
    2056             :                     // N1
    2057          81 :                     NumNum = 1;
    2058          81 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2059          81 :                         WarehouseCoil(CoilID).UnitLoadFactorSens = Numbers(NumNum);
    2060             :                     } else {
    2061           0 :                         ShowSevereError(state,
    2062           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W/C",
    2063             :                                                RoutineName,
    2064             :                                                CurrentModuleObject,
    2065           0 :                                                WarehouseCoil(CoilID).Name,
    2066             :                                                cNumericFieldNames(NumNum)));
    2067           0 :                         ErrorsFound = true;
    2068             :                     }
    2069          81 :                     break;
    2070           1 :                 case RatingType::RatedCapacityTotal:
    2071             :                     // N2
    2072           1 :                     NumNum = 2; // advance past rating in W/C to N2 with rating in W
    2073           1 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2074           1 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2075             :                         // N3
    2076           1 :                         NumNum = 3; // read rated RH only for this type of rating at N3
    2077           1 :                         if (lNumericBlanks(NumNum)) {
    2078           0 :                             WarehouseCoil(CoilID).RatedRH = 0.85;
    2079             :                         } else {
    2080           1 :                             if (Numbers(NumNum) <= 0.0 || Numbers(NumNum) >= 100.0) {
    2081           0 :                                 ShowSevereError(state,
    2082           0 :                                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
    2083             :                                                        RoutineName,
    2084             :                                                        CurrentModuleObject,
    2085           0 :                                                        WarehouseCoil(CoilID).Name,
    2086             :                                                        cNumericFieldNames(NumNum)));
    2087           0 :                                 ErrorsFound = true;
    2088             :                             }
    2089           1 :                             WarehouseCoil(CoilID).RatedRH = Numbers(NumNum) / 100.0;
    2090             :                         }
    2091             :                     } else {
    2092           0 :                         ShowSevereError(state,
    2093           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2094             :                                                RoutineName,
    2095             :                                                CurrentModuleObject,
    2096           0 :                                                WarehouseCoil(CoilID).Name,
    2097             :                                                cNumericFieldNames(NumNum)));
    2098           0 :                         ErrorsFound = true;
    2099             :                     }
    2100           1 :                     break;
    2101           0 :                 case RatingType::EuropeanSC1Std:
    2102             :                     // N2
    2103           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2104           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2105           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2106           0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    2107             :                     } else {
    2108           0 :                         ShowSevereError(state,
    2109           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2110             :                                                RoutineName,
    2111             :                                                CurrentModuleObject,
    2112           0 :                                                WarehouseCoil(CoilID).Name,
    2113             :                                                cNumericFieldNames(NumNum)));
    2114           0 :                         ErrorsFound = true;
    2115             :                     }
    2116           0 :                     break;
    2117           0 :                 case RatingType::EuropeanSC1Nom:
    2118             :                     // N2
    2119           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2120           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2121           0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2122           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[0];
    2123           0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    2124             :                     } else {
    2125           0 :                         ShowSevereError(state,
    2126           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2127             :                                                RoutineName,
    2128             :                                                CurrentModuleObject,
    2129           0 :                                                WarehouseCoil(CoilID).Name,
    2130             :                                                cNumericFieldNames(NumNum)));
    2131           0 :                         ErrorsFound = true;
    2132             :                     }
    2133           0 :                     break;
    2134           0 :                 case RatingType::EuropeanSC2Std:
    2135             :                     // N2
    2136           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2137           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2138           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2139           0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    2140             :                     } else {
    2141           0 :                         ShowSevereError(state,
    2142           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2143             :                                                RoutineName,
    2144             :                                                CurrentModuleObject,
    2145           0 :                                                WarehouseCoil(CoilID).Name,
    2146             :                                                cNumericFieldNames(NumNum)));
    2147           0 :                         ErrorsFound = true;
    2148             :                     }
    2149           0 :                     break;
    2150           0 :                 case RatingType::EuropeanSC2Nom:
    2151             :                     // N2
    2152           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2153           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2154           0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2155           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[1];
    2156           0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    2157             :                     } else {
    2158           0 :                         ShowSevereError(state,
    2159           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2160             :                                                RoutineName,
    2161             :                                                CurrentModuleObject,
    2162           0 :                                                WarehouseCoil(CoilID).Name,
    2163             :                                                cNumericFieldNames(NumNum)));
    2164           0 :                         ErrorsFound = true;
    2165             :                     }
    2166           0 :                     break;
    2167           1 :                 case RatingType::EuropeanSC3Std:
    2168             :                     // N2
    2169           1 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2170           1 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2171           1 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2172           1 :                         WarehouseCoil(CoilID).SCIndex = 3;
    2173             :                     } else {
    2174           0 :                         ShowSevereError(state,
    2175           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2176             :                                                RoutineName,
    2177             :                                                CurrentModuleObject,
    2178           0 :                                                WarehouseCoil(CoilID).Name,
    2179             :                                                cNumericFieldNames(NumNum)));
    2180           0 :                         ErrorsFound = true;
    2181             :                     }
    2182           1 :                     break;
    2183           0 :                 case RatingType::EuropeanSC3Nom:
    2184             :                     // N2
    2185           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2186           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2187           0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2188           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[2];
    2189           0 :                         WarehouseCoil(CoilID).SCIndex = 3;
    2190             :                     } else {
    2191           0 :                         ShowSevereError(state,
    2192           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2193             :                                                RoutineName,
    2194             :                                                CurrentModuleObject,
    2195           0 :                                                WarehouseCoil(CoilID).Name,
    2196             :                                                cNumericFieldNames(NumNum)));
    2197           0 :                         ErrorsFound = true;
    2198             :                     }
    2199           0 :                     break;
    2200           0 :                 case RatingType::EuropeanSC4Std:
    2201             :                     // N2
    2202           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2203           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2204           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2205           0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    2206             :                     } else {
    2207           0 :                         ShowSevereError(state,
    2208           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2209             :                                                RoutineName,
    2210             :                                                CurrentModuleObject,
    2211           0 :                                                WarehouseCoil(CoilID).Name,
    2212             :                                                cNumericFieldNames(NumNum)));
    2213           0 :                         ErrorsFound = true;
    2214             :                     }
    2215           0 :                     break;
    2216           0 :                 case RatingType::EuropeanSC4Nom:
    2217             :                     // N2
    2218           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2219           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2220           0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2221           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[3];
    2222           0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    2223             :                     } else {
    2224           0 :                         ShowSevereError(state,
    2225           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2226             :                                                RoutineName,
    2227             :                                                CurrentModuleObject,
    2228           0 :                                                WarehouseCoil(CoilID).Name,
    2229             :                                                cNumericFieldNames(NumNum)));
    2230           0 :                         ErrorsFound = true;
    2231             :                     }
    2232           0 :                     break;
    2233           0 :                 case RatingType::EuropeanSC5Std:
    2234             :                     // N2
    2235           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2236           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2237           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2238           0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    2239             :                     } else {
    2240           0 :                         ShowSevereError(state,
    2241           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2242             :                                                RoutineName,
    2243             :                                                CurrentModuleObject,
    2244           0 :                                                WarehouseCoil(CoilID).Name,
    2245             :                                                cNumericFieldNames(NumNum)));
    2246           0 :                         ErrorsFound = true;
    2247             :                     }
    2248           0 :                     break;
    2249           0 :                 case RatingType::EuropeanSC5Nom:
    2250             :                     // N2
    2251           0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2252           0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2253           0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2254           0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[4];
    2255           0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    2256             :                     } else {
    2257           0 :                         ShowSevereError(state,
    2258           0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2259             :                                                RoutineName,
    2260             :                                                CurrentModuleObject,
    2261           0 :                                                WarehouseCoil(CoilID).Name,
    2262             :                                                cNumericFieldNames(NumNum)));
    2263           0 :                         ErrorsFound = true;
    2264             :                     }
    2265             :                 default:
    2266           0 :                     break;
    2267             :                 }
    2268             :             } // WarehouseCoil(CoilID)%RatingType
    2269             : 
    2270             :             // N4
    2271          83 :             NumNum = 4;
    2272          83 :             if (!lNumericBlanks(NumNum)) {
    2273          83 :                 WarehouseCoil(CoilID).TEvapDesign = Numbers(NumNum); // also used to rep inlet brine T later when add that option
    2274             :             } else {
    2275           0 :                 ShowSevereError(
    2276             :                     state,
    2277           0 :                     format(
    2278           0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2279           0 :                 ErrorsFound = true;
    2280             :             }
    2281             : 
    2282          83 :             ++NumNum; // N5
    2283          83 :             if (!lNumericBlanks(NumNum)) {
    2284          83 :                 WarehouseCoil(CoilID).RatedTemperatureDif = Numbers(NumNum);
    2285             :                 // INLET temperature - evaporating temperature, NOT room temp - evap temp
    2286             :             } else {
    2287           0 :                 ShowSevereError(
    2288             :                     state,
    2289           0 :                     format(
    2290           0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2291           0 :                 ErrorsFound = true;
    2292             :             }
    2293             : 
    2294          83 :             ++NumNum; // N6
    2295          83 :             if (!lNumericBlanks(NumNum)) {
    2296          83 :                 WarehouseCoil(CoilID).MaxTemperatureDif = Numbers(NumNum);
    2297             :                 // Maximum difference between INLET temperature - evaporating temperature, NOT room temp - evap temp
    2298             :                 // Important when cooling down space at start of environment or if large stocking loads imposed.
    2299             :             } else {
    2300           0 :                 WarehouseCoil(CoilID).MaxTemperatureDif = 1.3 * WarehouseCoil(CoilID).RatedTemperatureDif;
    2301           0 :                 ShowWarningError(state,
    2302           0 :                                  format("{}{}=\"{}\", {} not entered, default 1.3 times rated temperature difference will be used.",
    2303             :                                         RoutineName,
    2304             :                                         CurrentModuleObject,
    2305           0 :                                         WarehouseCoil(CoilID).Name,
    2306             :                                         cNumericFieldNames(NumNum)));
    2307             :             }
    2308             : 
    2309             :             // Correction factor from manufacturer's rating for coil material, default 1.0
    2310          83 :             ++NumNum;                                 // N7
    2311          83 :             WarehouseCoil(CoilID).CorrMaterial = 1.0; // default value
    2312          83 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).CorrMaterial = Numbers(NumNum);
    2313             : 
    2314             :             // Correction factor from manufacturer's rating for refrigerant, default 1.0
    2315          83 :             ++NumNum;                                    // N8
    2316          83 :             WarehouseCoil(CoilID).CorrRefrigerant = 1.0; // default value
    2317          83 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).CorrRefrigerant = Numbers(NumNum);
    2318             :             // ONLY used if the Capacity Rating Type is CapacityTotalSpecificConditions
    2319             : 
    2320             :             // Convert all European sensible capacities to sensible load factors
    2321          85 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::UnitLoadFactorSens) &&
    2322           2 :                 (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal))
    2323           1 :                 WarehouseCoil(CoilID).UnitLoadFactorSens = WarehouseCoil(CoilID).RatedSensibleCap / WarehouseCoil(CoilID).RatedTemperatureDif;
    2324             :             // Now have UnitLoadFactorSens for all except RatingType == RatedCapacityTotal
    2325             : 
    2326             :             // Apply material and refrigerant correction factors to sensible load factors
    2327          83 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal))
    2328          82 :                 WarehouseCoil(CoilID).UnitLoadFactorSens *= WarehouseCoil(CoilID).CorrMaterial * WarehouseCoil(CoilID).CorrRefrigerant;
    2329             :             // First calc of ratedsensiblecap for type type unitloadfactorsens
    2330          83 :             WarehouseCoil(CoilID).RatedSensibleCap = WarehouseCoil(CoilID).UnitLoadFactorSens * WarehouseCoil(CoilID).RatedTemperatureDif;
    2331             :             // A4    Enter capacity correction curve type
    2332          83 :             AlphaNum = 4;
    2333          83 :             if ((lAlphaBlanks(AlphaNum)) && (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2334             :                 // For all except RatedCapacityTotal - default to linear capacity factor approximating Nelson August 2010 ASHRAE journal
    2335           0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::SHR60;
    2336          83 :             } else if (WarehouseCoil(CoilID).ratingType == RatingType::RatedCapacityTotal) {
    2337             :                 // For RatedCapacityTotal, the manufacturer's coil performance map is required
    2338             :                 // Specify the performance map with TabularRHxDT1xTRoom
    2339           1 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::TabularRH_DT1_TRoom;
    2340           1 :                 if (!(Util::SameString(Alphas(AlphaNum), "TabularRHxDT1xTRoom"))) {
    2341           0 :                     ShowWarningError(state,
    2342           0 :                                      format(R"({}{}="{}", invalid {}="{}".)",
    2343             :                                             RoutineName,
    2344             :                                             CurrentModuleObject,
    2345           0 :                                             WarehouseCoil(CoilID).Name,
    2346             :                                             cAlphaFieldNames(AlphaNum),
    2347             :                                             Alphas(AlphaNum)));
    2348           0 :                     ShowContinueError(state,
    2349             :                                       "The \"CapacityTotalSpecificConditions\" Capacity Rating Type has been specified for this air chiller.  "
    2350             :                                       "This rating type requires ");
    2351           0 :                     ShowContinueError(
    2352             :                         state,
    2353           0 :                         format(
    2354             :                             R"(the "TabularRHxDT1xTRoom" correction curve.  Verify that a valid "TabularRHxDT1xTRoom" curve is specified in "{}".)",
    2355             :                             cAlphaFieldNames(AlphaNum + 1)));
    2356             :                 }
    2357          82 :             } else if (Util::SameString(Alphas(AlphaNum), "LinearSHR60")) {
    2358          81 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::SHR60;
    2359           1 :             } else if (Util::SameString(Alphas(AlphaNum), "QuadraticSHR")) {
    2360           0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::QuadraticSHR;
    2361           1 :             } else if (Util::SameString(Alphas(AlphaNum), "European")) {
    2362           1 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::European;
    2363           0 :             } else if (Util::SameString(Alphas(AlphaNum), "TabularRHxDT1xTRoom")) {
    2364           0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::TabularRH_DT1_TRoom;
    2365             :             } else {
    2366           0 :                 ShowSevereError(state,
    2367           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    2368             :                                        RoutineName,
    2369             :                                        CurrentModuleObject,
    2370           0 :                                        WarehouseCoil(CoilID).Name,
    2371             :                                        cAlphaFieldNames(AlphaNum),
    2372             :                                        Alphas(AlphaNum)));
    2373           0 :                 ErrorsFound = true;
    2374             :             }
    2375             : 
    2376          83 :             ++AlphaNum; // A5
    2377          83 :             ++NumNum;   // N9
    2378          83 :             switch (WarehouseCoil(CoilID).SHRCorrType) {
    2379          81 :             case SHRCorrectionType::SHR60: {
    2380          81 :                 WarehouseCoil(CoilID).SHRCorrection60 = 1.48; // reference Nelson, ASHRAE journal August 2010 Fig 2
    2381          81 :                 if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).SHRCorrection60 = Numbers(NumNum);
    2382             :                 //(1.66667 would be a perfect effectiveness, 1.0 would be artificial coil that does only sensible)
    2383          81 :                 if (WarehouseCoil(CoilID).SHRCorrection60 > 1.67) {
    2384           0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.67;
    2385           0 :                     ShowWarningError(state,
    2386           0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.67 will be used.",
    2387             :                                             RoutineName,
    2388             :                                             CurrentModuleObject,
    2389           0 :                                             WarehouseCoil(CoilID).Name,
    2390             :                                             cNumericFieldNames(NumNum)));
    2391             :                 }
    2392          81 :                 if (WarehouseCoil(CoilID).SHRCorrection60 < 1.0) {
    2393           0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.0;
    2394           0 :                     ShowWarningError(state,
    2395           0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.00 will be used.",
    2396             :                                             RoutineName,
    2397             :                                             CurrentModuleObject,
    2398           0 :                                             WarehouseCoil(CoilID).Name,
    2399             :                                             cNumericFieldNames(NumNum)));
    2400             :                 }
    2401          81 :             } break;
    2402           1 :             case SHRCorrectionType::European: {
    2403             :                 // WarehouseCoil(CoilID)%SHRCorrectionCurvePtr = CurveManager::GetCurveIndex(state, 'ChillerEuropeanWetCoilFactor')
    2404             :                 // This is a place holder, currently use embedded constants for European ratings, future may want a curve
    2405           1 :             } break;
    2406           0 :             case SHRCorrectionType::QuadraticSHR: {
    2407           0 :                 WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    2408           0 :                 if (lAlphaBlanks(AlphaNum)) {
    2409           0 :                     ShowSevereError(state,
    2410           0 :                                     format("{}{}=\"{}\", invalid  {} is blank, required.",
    2411             :                                            RoutineName,
    2412             :                                            CurrentModuleObject,
    2413           0 :                                            WarehouseCoil(CoilID).Name,
    2414             :                                            cAlphaFieldNames(AlphaNum)));
    2415           0 :                     ErrorsFound = true;
    2416           0 :                 } else if (WarehouseCoil(CoilID).SHRCorrectionCurvePtr == 0) {
    2417           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid  ", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2418           0 :                     ShowContinueError(state, format("...invalid curve {}=\"{}\".", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2419           0 :                     ErrorsFound = true;
    2420             :                 }
    2421             :                 // error checks for curve type entered and curve name
    2422           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2423           0 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2424             :                                                      {1},                                         // Valid dimensions
    2425             :                                                      RoutineName,                                 // Routine name
    2426             :                                                      CurrentModuleObject,                         // Object Type
    2427           0 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2428           0 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2429           0 :             } break;
    2430           1 :             case SHRCorrectionType::TabularRH_DT1_TRoom: {
    2431           1 :                 WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    2432           1 :                 if (lAlphaBlanks(AlphaNum)) {
    2433           0 :                     ShowSevereError(state,
    2434           0 :                                     format("{}{}=\"{}\", invalid  {} is blank, required.",
    2435             :                                            RoutineName,
    2436             :                                            CurrentModuleObject,
    2437           0 :                                            WarehouseCoil(CoilID).Name,
    2438             :                                            cAlphaFieldNames(AlphaNum)));
    2439           0 :                     ErrorsFound = true;
    2440           1 :                 } else if (WarehouseCoil(CoilID).SHRCorrectionCurvePtr == 0) {
    2441           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid  ", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2442           0 :                     ShowContinueError(state, format("...invalid curve {}=\"{}\".", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2443           0 :                     ErrorsFound = true;
    2444             :                 }
    2445           2 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2446           1 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2447             :                                                      {3},                                         // Valid dimensions
    2448             :                                                      RoutineName,                                 // Routine name
    2449             :                                                      CurrentModuleObject,                         // Object Type
    2450           1 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2451           1 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2452             :                 //        IF(WarehouseCoil(CoilID)%SHRCorrectionCurvePtr == 0) THEN
    2453             :                 //          CALL ShowSevereError(state, RoutineName//TRIM(CurrentModuleObject)//'="'//TRIM(WarehouseCoil(CoilID)%Name)//&
    2454             :                 //                           '", not found  '//TRIM(cAlphaFieldNames(AlphaNum)))
    2455             :                 //          ErrorsFound = .TRUE.
    2456             :                 //        END IF !valid table name
    2457           1 :             } break;
    2458           0 :             default:
    2459           0 :                 break;
    2460             :             } // SHRCorrectionType
    2461             : 
    2462          83 :             ++NumNum; // N10
    2463          83 :             if (!lNumericBlanks(NumNum)) {
    2464          83 :                 WarehouseCoil(CoilID).HeaterPower = Numbers(NumNum);
    2465             :             } else {
    2466           0 :                 ShowSevereError(state,
    2467           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + WarehouseCoil(CoilID).Name + "\", " +
    2468           0 :                                     cNumericFieldNames(NumNum) + " must be input ");
    2469           0 :                 ErrorsFound = true;
    2470             :             }
    2471             : 
    2472          83 :             ++AlphaNum; // A6
    2473          83 :             if (!lAlphaBlanks(AlphaNum)) {
    2474         166 :                 WarehouseCoil(CoilID).HeaterSchedPtr =
    2475          83 :                     ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert heater schedule name to pointer
    2476          83 :                 if (WarehouseCoil(CoilID).HeaterSchedPtr == 0) {
    2477           0 :                     ShowSevereError(state,
    2478           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    2479             :                                            RoutineName,
    2480             :                                            CurrentModuleObject,
    2481           0 :                                            WarehouseCoil(CoilID).Name,
    2482             :                                            cAlphaFieldNames(AlphaNum),
    2483             :                                            Alphas(AlphaNum)));
    2484           0 :                     ErrorsFound = true;
    2485             :                 } else { //   check heater schedule for values between 0 and 1
    2486          83 :                     if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).HeaterSchedPtr, ">=", 0.0, "<=", 1.0)) {
    2487           0 :                         ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2488           0 :                         ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2489           0 :                         ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    2490           0 :                         ErrorsFound = true;
    2491             :                     } // heater schedule ptr == 0
    2492             :                 }     // htr sched == 0
    2493             :             } else {  // lalphaBlanks, no schedule specified
    2494           0 :                 WarehouseCoil(CoilID).HeaterSchedPtr = AlwaysOn;
    2495             :             } // not blank
    2496             : 
    2497             :             // Input fan control type
    2498          83 :             ++AlphaNum; // A7
    2499          83 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "Fixed")) {
    2500          83 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::ConstantSpeed;
    2501           0 :             } else if (Util::SameString(Alphas(AlphaNum), "FixedLinear")) {
    2502           0 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::ConstantSpeedLinear;
    2503           0 :             } else if (Util::SameString(Alphas(AlphaNum), "VariableSpeed")) {
    2504           0 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::VariableSpeed;
    2505           0 :             } else if (Util::SameString(Alphas(AlphaNum), "TwoSpeed")) {
    2506           0 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::TwoSpeed;
    2507             :             } else {
    2508           0 :                 ShowSevereError(state,
    2509           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    2510             :                                        RoutineName,
    2511             :                                        CurrentModuleObject,
    2512           0 :                                        WarehouseCoil(CoilID).Name,
    2513             :                                        cAlphaFieldNames(AlphaNum),
    2514             :                                        Alphas(AlphaNum)));
    2515           0 :                 ErrorsFound = true;
    2516             :             } // fan control type
    2517             : 
    2518          83 :             ++NumNum; // N11
    2519          83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2520          83 :                 WarehouseCoil(CoilID).RatedFanPower = Numbers(NumNum);
    2521             :             } else {
    2522           0 :                 ShowSevereError(state,
    2523           0 :                                 format("{}{}=\"{}\", {} was not input or was less than 0 ",
    2524             :                                        RoutineName,
    2525             :                                        CurrentModuleObject,
    2526           0 :                                        WarehouseCoil(CoilID).Name,
    2527             :                                        cNumericFieldNames(NumNum)));
    2528           0 :                 ErrorsFound = true;
    2529             :             } // coil fan power
    2530             : 
    2531          83 :             ++NumNum; // N12
    2532          83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2533          83 :                 WarehouseCoil(CoilID).RatedAirVolumeFlow = Numbers(NumNum);
    2534             :             } else {
    2535           0 :                 ShowSevereError(state,
    2536           0 :                                 format("{}{}=\"{}\", {} is required and was not input or was less than 0  ",
    2537             :                                        RoutineName,
    2538             :                                        CurrentModuleObject,
    2539           0 :                                        WarehouseCoil(CoilID).Name,
    2540             :                                        cNumericFieldNames(NumNum)));
    2541             :             } // air volume flow
    2542             : 
    2543          83 :             ++NumNum;                                       // N13
    2544          83 :             WarehouseCoil(CoilID).FanMinAirFlowRatio = 0.2; // default value
    2545          83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) WarehouseCoil(CoilID).FanMinAirFlowRatio = Numbers(NumNum);
    2546             : 
    2547             :             // Input defrost type
    2548          83 :             ++AlphaNum; // A8
    2549          83 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "Electric")) {
    2550          82 :                 WarehouseCoil(CoilID).defrostType = DefrostType::Elec;
    2551           1 :             } else if (Util::SameString(Alphas(AlphaNum), "HotFluid")) {
    2552           1 :                 WarehouseCoil(CoilID).defrostType = DefrostType::Fluid;
    2553           0 :             } else if (Util::SameString(Alphas(AlphaNum), "None")) {
    2554           0 :                 WarehouseCoil(CoilID).defrostType = DefrostType::None;
    2555           0 :             } else if (Util::SameString(Alphas(AlphaNum), "OffCycle")) {
    2556           0 :                 WarehouseCoil(CoilID).defrostType = DefrostType::OffCycle;
    2557             :             } else {
    2558           0 :                 ShowSevereError(state,
    2559           0 :                                 format(R"({}{}="{}", invalid  {}="{}".)",
    2560             :                                        RoutineName,
    2561             :                                        CurrentModuleObject,
    2562           0 :                                        WarehouseCoil(CoilID).Name,
    2563             :                                        cAlphaFieldNames(AlphaNum),
    2564             :                                        Alphas(AlphaNum)));
    2565           0 :                 ErrorsFound = true;
    2566             :             } // defrost type
    2567             : 
    2568          83 :             ++AlphaNum; // A9
    2569          83 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "TimeSchedule")) {
    2570          82 :                 WarehouseCoil(CoilID).DefrostControlType = DefrostCtrlType::Sched;
    2571           1 :             } else if (Util::SameString(Alphas(AlphaNum), "TemperatureTermination")) {
    2572           1 :                 WarehouseCoil(CoilID).DefrostControlType = DefrostCtrlType::TempTerm;
    2573             :             } else {
    2574           0 :                 ShowSevereError(state,
    2575           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    2576             :                                        RoutineName,
    2577             :                                        CurrentModuleObject,
    2578           0 :                                        WarehouseCoil(CoilID).Name,
    2579             :                                        cAlphaFieldNames(AlphaNum),
    2580             :                                        Alphas(AlphaNum)));
    2581           0 :                 ErrorsFound = true;
    2582             :             } // defrost control type
    2583             : 
    2584             :             // convert defrost schedule name to pointer
    2585          83 :             ++AlphaNum; // A10
    2586          83 :             WarehouseCoil(CoilID).DefrostSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum));
    2587          83 :             if (WarehouseCoil(CoilID).DefrostSchedPtr == 0) {
    2588           0 :                 ShowSevereError(state,
    2589           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    2590             :                                        RoutineName,
    2591             :                                        CurrentModuleObject,
    2592           0 :                                        WarehouseCoil(CoilID).Name,
    2593             :                                        cAlphaFieldNames(AlphaNum),
    2594             :                                        Alphas(AlphaNum)));
    2595           0 :                 ErrorsFound = true;
    2596             :             } else { //   check defrost schedule for values between 0 and 1
    2597          83 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).DefrostSchedPtr, ">=", 0.0, "<=", 1.0)) {
    2598           0 :                     ShowSevereError(state, format("{}{} = \"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2599           0 :                     ShowContinueError(state, format("Error found in {}={}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2600           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    2601           0 :                     ErrorsFound = true;
    2602             :                 } // checkschedulevalueMinMax
    2603             :             }     // check for valid schedule name
    2604             : 
    2605             :             // convert defrost drip-down schedule name to pointer
    2606             :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    2607          83 :             ++AlphaNum; // A11
    2608          83 :             if (!lAlphaBlanks(AlphaNum)) {
    2609          83 :                 WarehouseCoil(CoilID).DefrostDripDownSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum));
    2610          83 :                 if (WarehouseCoil(CoilID).DefrostDripDownSchedPtr == 0) {
    2611           0 :                     ShowSevereError(state,
    2612           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    2613             :                                            RoutineName,
    2614             :                                            CurrentModuleObject,
    2615           0 :                                            WarehouseCoil(CoilID).Name,
    2616             :                                            cAlphaFieldNames(AlphaNum),
    2617             :                                            Alphas(AlphaNum)));
    2618           0 :                     ErrorsFound = true;
    2619             :                 } else { // check schedule for values between 0 and 1
    2620          83 :                     if (!ScheduleManager::CheckScheduleValueMinMax(state, WarehouseCoil(CoilID).DefrostDripDownSchedPtr, ">=", 0.0, "<=", 1.0)) {
    2621           0 :                         ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2622           0 :                         ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2623           0 :                         ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    2624           0 :                         ErrorsFound = true;
    2625             :                     } // Check schedule value between 0 and 1
    2626             :                 }     // Check if drip down schedule name is valid
    2627             :             } else {  // .not. lAlphaBlanks  so use drip down schedule for defrost
    2628           0 :                 WarehouseCoil(CoilID).DefrostDripDownSchedPtr = WarehouseCoil(CoilID).DefrostSchedPtr;
    2629             :             } // .not. lAlphaBlanks
    2630             : 
    2631          83 :             ++NumNum; // N14
    2632          83 :             if (WarehouseCoil(CoilID).defrostType == DefrostType::OffCycle || WarehouseCoil(CoilID).defrostType == DefrostType::None) {
    2633           0 :                 WarehouseCoil(CoilID).DefrostCapacity = 0.0;
    2634             :                 // Don't even need to read Defrost capacity for those two defrost types.
    2635             :             } else { // have electric or hot gas/brine defrost
    2636          83 :                 if ((lNumericBlanks(NumNum)) || (Numbers(NumNum) <= 0.0)) {
    2637           0 :                     ShowSevereError(state,
    2638           0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    2639             :                                            RoutineName,
    2640             :                                            CurrentModuleObject,
    2641           0 :                                            WarehouseCoil(CoilID).Name,
    2642             :                                            cNumericFieldNames(NumNum),
    2643             :                                            cAlphaFieldNames(AlphaNum),
    2644             :                                            Alphas(AlphaNum)));
    2645           0 :                     ErrorsFound = true;
    2646             :                 } else {
    2647          83 :                     WarehouseCoil(CoilID).DefrostCapacity = Numbers(NumNum);
    2648             :                 } // Blank  or negative Defrost Capacity
    2649             : 
    2650             :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    2651             :                 // note this value is only used for temperature terminated defrost control type
    2652          83 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Elec) WarehouseCoil(CoilID).DefEnergyFraction = 0.7;
    2653          83 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Fluid) WarehouseCoil(CoilID).DefEnergyFraction = 0.3;
    2654             : 
    2655          83 :                 ++NumNum; // N15
    2656          83 :                 if (!lNumericBlanks(NumNum)) {
    2657           1 :                     if ((Numbers(NumNum) > 1.0) || (Numbers(NumNum) < 0.0)) {
    2658           0 :                         ShowWarningError(state,
    2659           0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    2660             :                                                 RoutineName,
    2661             :                                                 CurrentModuleObject,
    2662           0 :                                                 WarehouseCoil(CoilID).Name,
    2663             :                                                 cNumericFieldNames(NumNum)));
    2664             :                     } else {
    2665           1 :                         WarehouseCoil(CoilID).DefEnergyFraction = Numbers(NumNum);
    2666             :                     } // number out of range
    2667             :                 }     // lnumericblanks
    2668             :             }         // defrost type
    2669             : 
    2670          83 :             ++AlphaNum; // A12
    2671          83 :             if (lAlphaBlanks(AlphaNum) || Util::SameString(Alphas(AlphaNum), "Middle")) {
    2672          83 :                 WarehouseCoil(CoilID).VerticalLocation = VerticalLoc::Middle; // default position
    2673           0 :             } else if (Util::SameString(Alphas(AlphaNum), "Ceiling")) {
    2674           0 :                 WarehouseCoil(CoilID).VerticalLocation = VerticalLoc::Ceiling;
    2675           0 :             } else if (Util::SameString(Alphas(AlphaNum), "Floor")) {
    2676           0 :                 WarehouseCoil(CoilID).VerticalLocation = VerticalLoc::Floor;
    2677             :             } else {
    2678           0 :                 ShowSevereError(state,
    2679           0 :                                 format("{}{}=\"{}\", invalid  {} not found: {}",
    2680             :                                        RoutineName,
    2681             :                                        CurrentModuleObject,
    2682           0 :                                        WarehouseCoil(CoilID).Name,
    2683             :                                        cAlphaFieldNames(AlphaNum),
    2684             :                                        Alphas(AlphaNum)));
    2685           0 :                 ErrorsFound = true;
    2686             :             } // Vertical location class
    2687             : 
    2688          83 :             ++NumNum; // N16
    2689          83 :             WarehouseCoil(CoilID).DesignRefrigInventory = 0.0;
    2690          83 :             if (!lNumericBlanks(NumNum)) WarehouseCoil(CoilID).DesignRefrigInventory = Numbers(NumNum);
    2691             :         } // NumRefrigAirChillers
    2692             :     }     // NumRefrigerationAirChillers > 0
    2693             : 
    2694             :     //************ START Warehouse Coil SET INPUT **************
    2695             :     // One Set allowed per zone, but indiv coils within zone can be served by different compressor/condenser systems
    2696             : 
    2697         796 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
    2698             : 
    2699           1 :         state.dataRefrigCase->CheckChillerSetName.dimension(state.dataRefrigCase->NumRefrigChillerSets, true);
    2700             : 
    2701           1 :         CurrentModuleObject = "ZoneHVAC:RefrigerationChillerSet";
    2702          11 :         for (int SetID = 1; SetID <= state.dataRefrigCase->NumRefrigChillerSets; ++SetID) {
    2703          10 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2704             :                                                                      CurrentModuleObject,
    2705             :                                                                      SetID,
    2706             :                                                                      Alphas,
    2707             :                                                                      NumAlphas,
    2708             :                                                                      Numbers,
    2709             :                                                                      NumNumbers,
    2710             :                                                                      IOStatus,
    2711             :                                                                      lNumericBlanks,
    2712             :                                                                      lAlphaBlanks,
    2713             :                                                                      cAlphaFieldNames,
    2714             :                                                                      cNumericFieldNames);
    2715          10 :             AlphaNum = 1;
    2716          10 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2717             : 
    2718          10 :             AirChillerSet(SetID).Name = Alphas(AlphaNum);
    2719             : 
    2720          10 :             AlphaNum = 2;
    2721          10 :             if (!lAlphaBlanks(AlphaNum)) {
    2722           0 :                 AirChillerSet(SetID).SchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(AlphaNum)); // convert schedule name to pointer
    2723           0 :                 if (AirChillerSet(SetID).SchedPtr == 0) {
    2724           0 :                     ShowSevereError(state,
    2725           0 :                                     format("{}{}=\"{}\", invalid  {} not found: {}",
    2726             :                                            RoutineName,
    2727             :                                            CurrentModuleObject,
    2728           0 :                                            AirChillerSet(SetID).Name,
    2729             :                                            cAlphaFieldNames(AlphaNum),
    2730             :                                            Alphas(AlphaNum)));
    2731           0 :                     ErrorsFound = true;
    2732             :                 }    // ptr == 0
    2733             :             } else { // no schedule specified
    2734          10 :                 AirChillerSet(SetID).SchedPtr = AlwaysOn;
    2735             :             } // not blank
    2736             : 
    2737             :             //   check availability schedule for values between 0 and 1
    2738          10 :             if (AirChillerSet(SetID).SchedPtr > 0) {
    2739           0 :                 if (!ScheduleManager::CheckScheduleValueMinMax(state, AirChillerSet(SetID).SchedPtr, ">=", 0.0, "<=", 1.0)) {
    2740           0 :                     ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, CurrentModuleObject, AirChillerSet(SetID).Name));
    2741           0 :                     ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2742           0 :                     ShowContinueError(state, "schedule values must be (>=0., <=1.)");
    2743           0 :                     ErrorsFound = true;
    2744             :                 }
    2745             :             }
    2746             : 
    2747          10 :             ++AlphaNum;
    2748          10 :             AirChillerSet(SetID).ZoneName = Alphas(AlphaNum);
    2749          10 :             AirChillerSet(SetID).ZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    2750             : 
    2751          10 :             if (AirChillerSet(SetID).ZoneNum == 0) {
    2752           0 :                 ShowSevereError(state,
    2753           0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
    2754             :                                        RoutineName,
    2755             :                                        CurrentModuleObject,
    2756           0 :                                        AirChillerSet(SetID).Name,
    2757             :                                        cAlphaFieldNames(AlphaNum),
    2758             :                                        Alphas(AlphaNum)));
    2759           0 :                 ErrorsFound = true;
    2760             :             }
    2761          10 :             AirChillerSet(SetID).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, AirChillerSet(SetID).ZoneNum);
    2762          10 :             if (AirChillerSet(SetID).ZoneNodeNum == 0) {
    2763           0 :                 ShowSevereError(state,
    2764           0 :                                 format("{}{}=\"{}\" System Node Number not found for {} = {}",
    2765             :                                        RoutineName,
    2766             :                                        CurrentModuleObject,
    2767           0 :                                        AirChillerSet(SetID).Name,
    2768             :                                        cAlphaFieldNames(AlphaNum),
    2769             :                                        Alphas(AlphaNum)));
    2770           0 :                 ShowContinueError(state,
    2771             :                                   ".. Refrigeration chillers must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    2772           0 :                 ErrorsFound = true;
    2773             :             }
    2774          10 :             state.dataRefrigCase->RefrigPresentInZone(AirChillerSet(SetID).ZoneNum) = true;
    2775             : 
    2776          10 :             ++AlphaNum;
    2777          10 :             if (!lAlphaBlanks(AlphaNum)) {
    2778           0 :                 ShowMessage(state,
    2779           0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2780             :                                    "any air system. ",
    2781             :                                    RoutineName,
    2782             :                                    CurrentModuleObject,
    2783           0 :                                    AirChillerSet(SetID).Name,
    2784             :                                    cAlphaFieldNames(AlphaNum)));
    2785             :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2786             :                 // AirChillerSet(SetID)%NodeNumInlet = &
    2787             :                 //       NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2788             :                 //                    AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Inlet,1,DataLoopNode::ObjectIsNotParent)
    2789             :             }
    2790             : 
    2791          10 :             ++AlphaNum;
    2792          10 :             if (!lAlphaBlanks(AlphaNum)) {
    2793           0 :                 ShowMessage(state,
    2794           0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2795             :                                    "any air system. ",
    2796             :                                    RoutineName,
    2797             :                                    CurrentModuleObject,
    2798           0 :                                    AirChillerSet(SetID).Name,
    2799             :                                    cAlphaFieldNames(AlphaNum)));
    2800             :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2801             :                 // AirChillerSet(SetID)%NodeNumOutlet = &
    2802             :                 //         NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2803             :                 //                      AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Outlet,1,DataLoopNode::ObjectIsNotParent)
    2804             :             }
    2805             : 
    2806             :             // An extensible list is used to enter the individual names of each chiller in the set.
    2807             :             // These chillers will be dispatched in this list order to meet the required zone load
    2808          10 :             int NumChillersInSet = NumAlphas - AlphaNum;
    2809          10 :             int AlphaStartList = AlphaNum; //+ 1
    2810          10 :             AirChillerSet(SetID).NumCoils = NumChillersInSet;
    2811          10 :             if (!allocated(AirChillerSet(SetID).CoilNum)) AirChillerSet(SetID).CoilNum.allocate(NumChillersInSet);
    2812          93 :             for (int ChillerIndex = 1; ChillerIndex <= NumChillersInSet; ++ChillerIndex) {
    2813          83 :                 int AlphaListNum = AlphaStartList + ChillerIndex;
    2814          83 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2815          83 :                     int CoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2816          83 :                     if (CoilNum == 0) {
    2817           0 :                         ShowSevereError(state,
    2818           0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    2819             :                                                RoutineName,
    2820             :                                                CurrentModuleObject,
    2821           0 :                                                AirChillerSet(SetID).Name,
    2822             :                                                cAlphaFieldNames(AlphaListNum),
    2823             :                                                Alphas(AlphaListNum)));
    2824           0 :                         ErrorsFound = true;
    2825             :                     } // == 0
    2826          83 :                     AirChillerSet(SetID).CoilNum(ChillerIndex) = CoilNum;
    2827          83 :                     WarehouseCoil(CoilNum).ZoneName = AirChillerSet(SetID).ZoneName;
    2828          83 :                     WarehouseCoil(CoilNum).ZoneNum = AirChillerSet(SetID).ZoneNum;
    2829          83 :                     WarehouseCoil(CoilNum).ZoneNodeNum = AirChillerSet(SetID).ZoneNodeNum;
    2830             :                 } // ! = alphablanks
    2831             :             }     // CoilID over NumChillersInSet
    2832             :         }         // NumChillerSets
    2833             :     }             // NumChillerSets > 0
    2834             :     //************* End Air Chiller Sets
    2835             : 
    2836             :     //**** Read CaseAndWalkIn Lists **********************************************************
    2837         796 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    2838          27 :         CurrentModuleObject = "Refrigeration:CaseAndWalkInList";
    2839          89 :         for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationCaseAndWalkInLists; ++ListNum) {
    2840          62 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2841             :                                                                      CurrentModuleObject,
    2842             :                                                                      ListNum,
    2843             :                                                                      Alphas,
    2844             :                                                                      NumAlphas,
    2845             :                                                                      Numbers,
    2846             :                                                                      NumNumbers,
    2847             :                                                                      IOStatus,
    2848             :                                                                      lNumericBlanks,
    2849             :                                                                      lAlphaBlanks,
    2850             :                                                                      cAlphaFieldNames,
    2851             :                                                                      cNumericFieldNames);
    2852          62 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2853          62 :             CaseAndWalkInList(ListNum).Name = Alphas(1);
    2854             : 
    2855             :             // CaseAndWalkInList alphas include CaseAndWalkInList name and one name for each Case or WalkIn in list
    2856             :             // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    2857          62 :             int NumTotalLoadsOnList = NumAlphas - 1;
    2858          62 :             if (!allocated(CaseAndWalkInList(ListNum).WalkInItemNum)) CaseAndWalkInList(ListNum).WalkInItemNum.allocate(NumTotalLoadsOnList);
    2859          62 :             if (!allocated(CaseAndWalkInList(ListNum).CaseItemNum)) CaseAndWalkInList(ListNum).CaseItemNum.allocate(NumTotalLoadsOnList);
    2860          62 :             if (!allocated(CaseAndWalkInList(ListNum).CoilItemNum)) CaseAndWalkInList(ListNum).CoilItemNum.allocate(NumTotalLoadsOnList);
    2861             : 
    2862          62 :             int NumCasesOnList = 0;
    2863          62 :             int NumCoilsOnList = 0;
    2864          62 :             int NumWalkInsOnList = 0;
    2865          62 :             int LoadCount = 0;
    2866         307 :             for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    2867         245 :                 int AlphaListNum = 1 + NumLoad;
    2868         245 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2869         245 :                     ++LoadCount;
    2870         245 :                     int LoadWalkInNum = 0;
    2871         245 :                     int LoadCaseNum = 0;
    2872         245 :                     int LoadCoilNum = 0;
    2873         245 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) LoadWalkInNum = Util::FindItemInList(Alphas(AlphaListNum), WalkIn);
    2874         245 :                     if (state.dataRefrigCase->NumSimulationCases > 0) LoadCaseNum = Util::FindItemInList(Alphas(AlphaListNum), RefrigCase);
    2875         245 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0)
    2876          83 :                         LoadCoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2877         245 :                     if ((LoadWalkInNum == 0) && (LoadCaseNum == 0) && (LoadCoilNum == 0)) {
    2878           0 :                         ShowSevereError(state,
    2879           0 :                                         format("{}{}=\"{}\", has an invalid value of {}",
    2880             :                                                RoutineName,
    2881             :                                                CurrentModuleObject,
    2882             :                                                cAlphaFieldNames(AlphaListNum),
    2883             :                                                Alphas(AlphaListNum)));
    2884           0 :                         ErrorsFound = true;
    2885         245 :                     } else if ((LoadWalkInNum != 0) && (LoadCaseNum != 0) && (LoadCoilNum != 0)) {
    2886           0 :                         ShowSevereError(state,
    2887           0 :                                         format("{}{}=\"{}\", {} Case and WalkIns and Refrigerated Coils cannot have the same name.",
    2888             :                                                RoutineName,
    2889             :                                                CurrentModuleObject,
    2890             :                                                cAlphaFieldNames(AlphaListNum),
    2891             :                                                Alphas(AlphaListNum)));
    2892           0 :                         ErrorsFound = true;
    2893         245 :                     } else if (LoadWalkInNum != 0) {
    2894          15 :                         ++NumWalkInsOnList;
    2895          15 :                         CaseAndWalkInList(ListNum).WalkInItemNum(NumWalkInsOnList) = LoadWalkInNum;
    2896         230 :                     } else if (LoadCaseNum != 0) {
    2897         147 :                         ++NumCasesOnList;
    2898         147 :                         CaseAndWalkInList(ListNum).CaseItemNum(NumCasesOnList) = LoadCaseNum;
    2899          83 :                     } else if (LoadCoilNum != 0) {
    2900          83 :                         ++NumCoilsOnList;
    2901          83 :                         CaseAndWalkInList(ListNum).CoilItemNum(NumCoilsOnList) = LoadCoilNum;
    2902             :                     }
    2903             :                 } // lAlphaBlanks
    2904             :             }     // Num Total Loads on List
    2905          62 :             if (LoadCount == 0) {
    2906           0 :                 ShowSevereError(
    2907             :                     state,
    2908           0 :                     format(
    2909           0 :                         "{}{}, \"{}\" : degenerate list All entries were blank.", RoutineName, CurrentModuleObject, CaseAndWalkInList(ListNum).Name));
    2910           0 :                 ErrorsFound = true;
    2911             :             } // loadcount == 0
    2912          62 :             CaseAndWalkInList(ListNum).NumCases = NumCasesOnList;
    2913          62 :             CaseAndWalkInList(ListNum).NumCoils = NumCoilsOnList;
    2914          62 :             CaseAndWalkInList(ListNum).NumWalkIns = NumWalkInsOnList;
    2915             :         } // ListNum=1,NumSimulationCaseAndWalkInLists
    2916             :     }     //(NumSimulationCaseAndWalkInLists > 0)
    2917             : 
    2918             :     //**** End read CaseAndWalkIn Lists **********************************************************
    2919             : 
    2920             :     //************** Start RefrigerationRacks
    2921             : 
    2922         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    2923             : 
    2924          31 :         CurrentModuleObject = "Refrigeration:CompressorRack";
    2925             : 
    2926          92 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
    2927             : 
    2928          61 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2929             :                                                                      CurrentModuleObject,
    2930             :                                                                      RackNum,
    2931             :                                                                      Alphas,
    2932             :                                                                      NumAlphas,
    2933             :                                                                      Numbers,
    2934             :                                                                      NumNumbers,
    2935             :                                                                      IOStatus,
    2936             :                                                                      lNumericBlanks,
    2937             :                                                                      lAlphaBlanks,
    2938             :                                                                      cAlphaFieldNames,
    2939             :                                                                      cNumericFieldNames);
    2940          61 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2941             : 
    2942          61 :             RefrigRack(RackNum).Name = Alphas(1);
    2943          61 :             RefrigRack(RackNum).MyIdx = RackNum;
    2944          61 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).Name = Alphas(1);
    2945          61 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).SourceType = CurrentModuleObject;
    2946          61 :             if (Util::SameString(Alphas(2), "Outdoors")) {
    2947          34 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2948          27 :             } else if (Util::SameString(Alphas(2), "Zone")) {
    2949          27 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Zone;
    2950             :                 // don't need to set RefrigPresentInZone to .TRUE. here because only allowed to reject heat to zone
    2951             :                 // holding all served cases,  so already set when case read in
    2952             :             } else {
    2953           0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2954           0 :                 ShowWarningError(state,
    2955           0 :                                  format("{}, {} = \"{}\": {} defined as {} not found. Will assume {} is OUTDOORS and simulation continues.",
    2956             :                                         CurrentModuleObject,
    2957             :                                         cAlphaFieldNames(1),
    2958           0 :                                         RefrigRack(RackNum).Name,
    2959             :                                         cAlphaFieldNames(2),
    2960             :                                         Alphas(2),
    2961             :                                         cAlphaFieldNames(2)));
    2962             :             }
    2963             : 
    2964          61 :             RefrigRack(RackNum).RatedCOP = Numbers(1);
    2965             : 
    2966          61 :             if (RefrigRack(RackNum).RatedCOP <= 0.0) {
    2967           0 :                 ShowSevereError(state,
    2968           0 :                                 format("{}{}=\"{}\" {} must be greater than 0.0",
    2969             :                                        RoutineName,
    2970             :                                        CurrentModuleObject,
    2971           0 :                                        RefrigRack(RackNum).Name,
    2972             :                                        cNumericFieldNames(1)));
    2973           0 :                 ErrorsFound = true;
    2974             :             }
    2975             : 
    2976          61 :             RefrigRack(RackNum).COPFTempPtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    2977          61 :             if (RefrigRack(RackNum).COPFTempPtr == 0) {
    2978           0 :                 ShowSevereError(state,
    2979           0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
    2980             :                                        RoutineName,
    2981             :                                        CurrentModuleObject,
    2982           0 :                                        RefrigRack(RackNum).Name,
    2983             :                                        cAlphaFieldNames(3),
    2984             :                                        Alphas(3)));
    2985           0 :                 ErrorsFound = true;
    2986             :             }
    2987             : 
    2988         122 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2989          61 :                                                  RefrigRack(RackNum).COPFTempPtr, // Curve index
    2990             :                                                  {1},                             // Valid dimensions
    2991             :                                                  RoutineName,                     // Routine name
    2992             :                                                  CurrentModuleObject,             // Object Type
    2993          61 :                                                  RefrigRack(RackNum).Name,        // Object Name
    2994          61 :                                                  cAlphaFieldNames(3));            // Field Name
    2995             : 
    2996          61 :             RefrigRack(RackNum).CondenserFanPower = Numbers(2);
    2997          61 :             if (Numbers(2) < 0.0) {
    2998           0 :                 ShowSevereError(state,
    2999           0 :                                 format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    3000             :                                        RoutineName,
    3001             :                                        CurrentModuleObject,
    3002           0 :                                        RefrigRack(RackNum).Name,
    3003             :                                        cNumericFieldNames(2)));
    3004           0 :                 ErrorsFound = true;
    3005             :             }
    3006             : 
    3007          61 :             RefrigRack(RackNum).TotCondFTempPtr = Curve::GetCurveIndex(state, Alphas(4)); // convert curve name to number
    3008          61 :             if ((!lAlphaBlanks(4)) && RefrigRack(RackNum).TotCondFTempPtr == 0) {
    3009           0 :                 ShowSevereError(state,
    3010           0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
    3011             :                                        RoutineName,
    3012             :                                        CurrentModuleObject,
    3013           0 :                                        RefrigRack(RackNum).Name,
    3014             :                                        cAlphaFieldNames(4),
    3015             :                                        Alphas(4)));
    3016           0 :                 ErrorsFound = true;
    3017             :             }
    3018             : 
    3019          61 :             if (!lAlphaBlanks(4)) {
    3020          62 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3021          31 :                                                      RefrigRack(RackNum).TotCondFTempPtr, // Curve index
    3022             :                                                      {1},                                 // Valid dimensions
    3023             :                                                      RoutineName,                         // Routine name
    3024             :                                                      CurrentModuleObject,                 // Object Type
    3025          31 :                                                      RefrigRack(RackNum).Name,            // Object Name
    3026          31 :                                                      cAlphaFieldNames(4));                // Field Name
    3027             :             }
    3028             : 
    3029          61 :             if (Util::SameString(Alphas(5), "EvaporativelyCooled")) {
    3030           2 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    3031           2 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    3032           0 :                     ShowWarningError(state,
    3033           0 :                                      format("{}=\"{}\" Evap cooled {} not available with {} = Zone.",
    3034             :                                             CurrentModuleObject,
    3035           0 :                                             RefrigRack(RackNum).Name,
    3036             :                                             cAlphaFieldNames(5),
    3037             :                                             cAlphaFieldNames(2)));
    3038           0 :                     ShowContinueError(state, format("{} reset to Air Cooled and simulation continues.", cAlphaFieldNames(5)));
    3039           0 :                     RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3040             :                 }
    3041          59 :             } else if (Util::SameString(Alphas(5), "WaterCooled")) {
    3042           1 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    3043           1 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    3044           0 :                     ShowWarningError(state,
    3045           0 :                                      format("{}=\"{}\" Water cooled {} not available with {} = Zone.",
    3046             :                                             CurrentModuleObject,
    3047           0 :                                             RefrigRack(RackNum).Name,
    3048             :                                             cAlphaFieldNames(5),
    3049             :                                             cAlphaFieldNames(2)));
    3050           0 :                     ShowContinueError(state, format("{} reset to Air Cooled and simulation continues.", cAlphaFieldNames(5)));
    3051           0 :                     RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3052             :                 }
    3053             :             } else {
    3054          58 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3055             :             }
    3056             :             // Get water-cooled condenser input, if applicable
    3057          61 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    3058           2 :                 RefrigRack(RackNum).InletNode = NodeInputManager::GetOnlySingleNode(state,
    3059           1 :                                                                                     Alphas(6),
    3060             :                                                                                     ErrorsFound,
    3061             :                                                                                     DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    3062           1 :                                                                                     Alphas(1),
    3063             :                                                                                     DataLoopNode::NodeFluidType::Water,
    3064             :                                                                                     DataLoopNode::ConnectionType::Inlet,
    3065             :                                                                                     NodeInputManager::CompFluidStream::Primary,
    3066             :                                                                                     DataLoopNode::ObjectIsNotParent);
    3067           2 :                 RefrigRack(RackNum).OutletNode = NodeInputManager::GetOnlySingleNode(state,
    3068           1 :                                                                                      Alphas(7),
    3069             :                                                                                      ErrorsFound,
    3070             :                                                                                      DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    3071           1 :                                                                                      Alphas(1),
    3072             :                                                                                      DataLoopNode::NodeFluidType::Water,
    3073             :                                                                                      DataLoopNode::ConnectionType::Outlet,
    3074             :                                                                                      NodeInputManager::CompFluidStream::Primary,
    3075             :                                                                                      DataLoopNode::ObjectIsNotParent);
    3076             :                 // Check node connections
    3077           1 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(6), Alphas(7), "RefrigRack Nodes");
    3078             :                 // Get loop flow type
    3079           1 :                 if (Util::SameString(Alphas(8), "VariableFlow")) {
    3080           1 :                     RefrigRack(RackNum).FlowType = CndsrFlowType::VariableFlow;
    3081           0 :                 } else if (Util::SameString(Alphas(8), "ConstantFlow")) {
    3082           0 :                     RefrigRack(RackNum).FlowType = CndsrFlowType::ConstantFlow;
    3083             :                 } else {
    3084           0 :                     ShowSevereError(state,
    3085           0 :                                     format("{}{}=\"{}\", invalid  {} not recognized: {}",
    3086             :                                            RoutineName,
    3087             :                                            CurrentModuleObject,
    3088           0 :                                            RefrigRack(RackNum).Name,
    3089             :                                            cAlphaFieldNames(8),
    3090             :                                            Alphas(8)));
    3091           0 :                     ShowContinueError(state, "Check input value choices.");
    3092           0 :                     ErrorsFound = true;
    3093             :                 }
    3094             :                 // Get outlet temperature schedule for variable flow case
    3095           1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::VariableFlow) {
    3096           1 :                     if (lAlphaBlanks(9)) {
    3097           0 :                         RefrigRack(RackNum).OutletTempSchedPtr = 0;
    3098             :                     } else {
    3099           1 :                         RefrigRack(RackNum).OutletTempSchedPtr =
    3100           1 :                             ScheduleManager::GetScheduleIndex(state, Alphas(9)); // convert schedule name to pointer
    3101             :                     }
    3102           1 :                     if (RefrigRack(RackNum).OutletTempSchedPtr == 0) {
    3103           0 :                         ShowSevereError(state,
    3104           0 :                                         format("{}{}=\"{}\", invalid  {} : {}",
    3105             :                                                RoutineName,
    3106             :                                                CurrentModuleObject,
    3107           0 :                                                RefrigRack(RackNum).Name,
    3108             :                                                cAlphaFieldNames(9),
    3109             :                                                Alphas(9)));
    3110           0 :                         ShowContinueError(state, "A schedule with this name is not defined in this input data file.");
    3111           0 :                         ErrorsFound = true;
    3112             :                     }
    3113             :                 }
    3114             :                 // Get volumetric flow rate if applicable
    3115           1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::ConstantFlow) {
    3116           0 :                     RefrigRack(RackNum).DesVolFlowRate = Numbers(3);
    3117           0 :                     RefrigRack(RackNum).VolFlowRate = Numbers(3);
    3118             :                 }
    3119             :                 // Get maximum flow rates
    3120           1 :                 RefrigRack(RackNum).VolFlowRateMax = Numbers(4);
    3121             : 
    3122             :                 // Check constant flow for max violation, if applicable
    3123           1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::ConstantFlow && RefrigRack(RackNum).VolFlowRate > Numbers(4)) {
    3124           0 :                     ShowSevereError(state,
    3125           0 :                                     format("{}{}=\"{}\" {} > {}.",
    3126             :                                            RoutineName,
    3127             :                                            CurrentModuleObject,
    3128           0 :                                            RefrigRack(RackNum).Name,
    3129             :                                            cNumericFieldNames(3),
    3130             :                                            cNumericFieldNames(4)));
    3131           0 :                     ShowContinueError(state, "Revise flow rates.");
    3132           0 :                     ErrorsFound = true;
    3133             :                 }
    3134             :                 // Get max/min allowed water temps
    3135           1 :                 RefrigRack(RackNum).OutletTempMax = Numbers(5);
    3136           1 :                 RefrigRack(RackNum).InletTempMin = Numbers(6);
    3137             :                 // set flow request for plant sizing.
    3138           1 :                 PlantUtilities::RegisterPlantCompDesignFlow(state, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).VolFlowRateMax);
    3139             :             } // Water cooled condenser data
    3140             : 
    3141             :             // Get evaporative cooled condenser input
    3142          61 :             if (lAlphaBlanks(10)) {
    3143          60 :                 RefrigRack(RackNum).EvapSchedPtr = 0;
    3144             :             } else {
    3145           1 :                 RefrigRack(RackNum).EvapSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(10)); // convert schedule name to pointer
    3146             :                 //   check availability schedule for values >= 0
    3147           1 :                 if (RefrigRack(RackNum).EvapSchedPtr > 0) {
    3148           1 :                     if (!ScheduleManager::CheckScheduleValueMinMax(state, RefrigRack(RackNum).EvapSchedPtr, true, 0.0)) {
    3149           0 :                         ShowSevereError(state, format("{}{}=\"{}\" .", RoutineName, CurrentModuleObject, RefrigRack(RackNum).Name));
    3150           0 :                         ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(10), Alphas(10)));
    3151           0 :                         ShowContinueError(state, "schedule values must be (>=0.).");
    3152           0 :                         ErrorsFound = true;
    3153             :                     }
    3154             :                 } else {
    3155           0 :                     ShowSevereError(state,
    3156           0 :                                     format("{}{}=\"{}\", invalid  {} = {}",
    3157             :                                            RoutineName,
    3158             :                                            CurrentModuleObject,
    3159           0 :                                            RefrigRack(RackNum).Name,
    3160             :                                            cAlphaFieldNames(10),
    3161             :                                            Alphas(10)));
    3162           0 :                     ShowContinueError(state, "A schedule with this name is not defined in this input data file.");
    3163           0 :                     ErrorsFound = true;
    3164             :                 }
    3165             :             }
    3166             : 
    3167          61 :             RefrigRack(RackNum).EvapEffect = Numbers(7);
    3168          61 :             if (RefrigRack(RackNum).EvapEffect < 0.0 || RefrigRack(RackNum).EvapEffect > 1.0) {
    3169           0 :                 ShowSevereError(state,
    3170           0 :                                 format("{}{}=\"{}\" {} cannot be less than zero or greater than 1.0.",
    3171             :                                        RoutineName,
    3172             :                                        CurrentModuleObject,
    3173           0 :                                        RefrigRack(RackNum).Name,
    3174             :                                        cNumericFieldNames(7)));
    3175           0 :                 ErrorsFound = true;
    3176             :             }
    3177             : 
    3178          61 :             RefrigRack(RackNum).CondenserAirFlowRate = Numbers(8);
    3179          63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).CondenserAirFlowRate <= 0.0 &&
    3180           2 :                 RefrigRack(RackNum).CondenserAirFlowRate != Constant::AutoCalculate) {
    3181           0 :                 ShowSevereError(state,
    3182           0 :                                 format("{}{}=\"{}\", {} cannot be less than or equal to zero.",
    3183             :                                        RoutineName,
    3184             :                                        CurrentModuleObject,
    3185           0 :                                        RefrigRack(RackNum).Name,
    3186             :                                        cNumericFieldNames(8)));
    3187           0 :                 ErrorsFound = true;
    3188             :             }
    3189             : 
    3190             :             //   Basin heater power as a function of temperature must be greater than or equal to 0
    3191          61 :             RefrigRack(RackNum).BasinHeaterPowerFTempDiff = Numbers(9);
    3192          61 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && Numbers(9) < 0.0) {
    3193           0 :                 ShowSevereError(
    3194           0 :                     state, format("{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, RefrigRack(RackNum).Name, cNumericFieldNames(9)));
    3195           0 :                 ErrorsFound = true;
    3196             :             }
    3197             : 
    3198          61 :             RefrigRack(RackNum).BasinHeaterSetPointTemp = Numbers(10);
    3199          63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3200           2 :                 RefrigRack(RackNum).BasinHeaterSetPointTemp < 2.0) {
    3201           0 :                 ShowWarningError(state,
    3202           0 :                                  format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    3203             :                                         CurrentModuleObject,
    3204           0 :                                         RefrigRack(RackNum).Name,
    3205             :                                         cNumericFieldNames(10)));
    3206             :             }
    3207             : 
    3208          61 :             RefrigRack(RackNum).EvapPumpPower = Numbers(11);
    3209          63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).EvapPumpPower < 0.0 &&
    3210           2 :                 RefrigRack(RackNum).EvapPumpPower != Constant::AutoCalculate) {
    3211           0 :                 ShowSevereError(state,
    3212           0 :                                 format("{}{}=\"{}\", {} cannot be less than zero.",
    3213             :                                        RoutineName,
    3214             :                                        CurrentModuleObject,
    3215           0 :                                        RefrigRack(RackNum).Name,
    3216             :                                        cNumericFieldNames(11)));
    3217           0 :                 ErrorsFound = true;
    3218             :             }
    3219             : 
    3220             :             // Get Water System tank connections
    3221          61 :             RefrigRack(RackNum).SupplyTankName = Alphas(11);
    3222          61 :             if (lAlphaBlanks(11)) {
    3223          60 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    3224             :             } else {
    3225           1 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    3226           2 :                 WaterManager::SetupTankDemandComponent(state,
    3227           1 :                                                        RefrigRack(RackNum).Name,
    3228             :                                                        CurrentModuleObject,
    3229           1 :                                                        RefrigRack(RackNum).SupplyTankName,
    3230             :                                                        ErrorsFound,
    3231           1 :                                                        RefrigRack(RackNum).EvapWaterSupTankID,
    3232           1 :                                                        RefrigRack(RackNum).EvapWaterTankDemandARRID);
    3233             :             }
    3234             : 
    3235             :             // Check condenser air inlet node connection
    3236          61 :             if (lAlphaBlanks(12)) {
    3237          16 :                 RefrigRack(RackNum).OutsideAirNodeNum = 0;
    3238             :             } else {
    3239          90 :                 RefrigRack(RackNum).OutsideAirNodeNum =
    3240          90 :                     NodeInputManager::GetOnlySingleNode(state,
    3241          45 :                                                         Alphas(12),
    3242             :                                                         ErrorsFound,
    3243             :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    3244          45 :                                                         Alphas(1),
    3245             :                                                         DataLoopNode::NodeFluidType::Air,
    3246             :                                                         DataLoopNode::ConnectionType::OutsideAirReference,
    3247             :                                                         NodeInputManager::CompFluidStream::Primary,
    3248             :                                                         DataLoopNode::ObjectIsParent);
    3249          45 :                 if (!OutAirNodeManager::CheckOutAirNodeNumber(state, RefrigRack(RackNum).OutsideAirNodeNum)) {
    3250           0 :                     ShowSevereError(state,
    3251           0 :                                     format("{}{}=\"{}\", {} not found: {}",
    3252             :                                            RoutineName,
    3253             :                                            CurrentModuleObject,
    3254           0 :                                            RefrigRack(RackNum).Name,
    3255             :                                            cAlphaFieldNames(12),
    3256             :                                            Alphas(12)));
    3257           0 :                     ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    3258           0 :                     ErrorsFound = true;
    3259             :                 }
    3260             :             }
    3261             : 
    3262          61 :             if (!lAlphaBlanks(13)) RefrigRack(RackNum).EndUseSubcategory = Alphas(13);
    3263             : 
    3264             :             // Read all loads on this rack: cases and walk-ins and coils
    3265          61 :             NumCases = 0;
    3266          61 :             int NumCoils = 0;
    3267          61 :             NumWalkIns = 0;
    3268          61 :             RefrigRack(RackNum).NumCases = 0;
    3269          61 :             RefrigRack(RackNum).NumCoils = 0;
    3270          61 :             RefrigRack(RackNum).NumWalkIns = 0;
    3271          61 :             RefrigRack(RackNum).TotalRackLoad = 0.0;
    3272             : 
    3273             :             //   Read display case and walkin assignments for this rack
    3274          61 :             AlphaNum = 14;
    3275          61 :             if (lAlphaBlanks(AlphaNum)) {
    3276             :                 // No cases or walkins or coils specified, ie, rack has no load
    3277           0 :                 ShowSevereError(state,
    3278           0 :                                 format("{}{}=\"{}\" : has no loads, must have at least one of: {}",
    3279             :                                        RoutineName,
    3280             :                                        CurrentModuleObject,
    3281           0 :                                        RefrigRack(RackNum).Name,
    3282             :                                        cAlphaFieldNames(14)));
    3283           0 :                 ErrorsFound = true;
    3284             :             } else { // (.NOT. lAlphaBlanks(AlphaNum))
    3285             :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn, Coil, or CaseAndWalkInList name
    3286          61 :                 int CaseAndWalkInListNum = 0;
    3287          61 :                 int CaseNum = 0;
    3288          61 :                 int WalkInNum = 0;
    3289          61 :                 int CoilNum = 0;
    3290          61 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    3291          41 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    3292          61 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    3293          61 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    3294          61 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    3295          61 :                 int NumNameMatches = 0;
    3296          61 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    3297          61 :                 if (CaseNum != 0) ++NumNameMatches;
    3298          61 :                 if (WalkInNum != 0) ++NumNameMatches;
    3299          61 :                 if (CoilNum != 0) ++NumNameMatches;
    3300             : 
    3301          61 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin
    3302           0 :                     ErrorsFound = true;
    3303           0 :                     if (NumNameMatches == 0) {
    3304           0 :                         ShowSevereError(state,
    3305           0 :                                         format("{}{}=\"{}\" : has an invalid {}: {}",
    3306             :                                                RoutineName,
    3307             :                                                CurrentModuleObject,
    3308           0 :                                                RefrigRack(RackNum).Name,
    3309             :                                                cAlphaFieldNames(AlphaNum),
    3310             :                                                Alphas(AlphaNum)));
    3311           0 :                     } else if (NumNameMatches > 1) {
    3312           0 :                         ShowSevereError(state,
    3313           0 :                                         format("{}{}=\"{}\" : has a non-unique name that could be either a {}: {}",
    3314             :                                                RoutineName,
    3315             :                                                CurrentModuleObject,
    3316           0 :                                                RefrigRack(RackNum).Name,
    3317             :                                                cAlphaFieldNames(AlphaNum),
    3318             :                                                Alphas(AlphaNum)));
    3319             :                     }                                   // num matches = 0 or > 1
    3320          61 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    3321          25 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    3322          25 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    3323          25 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    3324          25 :                     RefrigRack(RackNum).NumCoils = NumCoils;
    3325          25 :                     RefrigRack(RackNum).NumCases = NumCases;
    3326          25 :                     RefrigRack(RackNum).NumWalkIns = NumWalkIns;
    3327          25 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    3328          25 :                     RefrigRack(RackNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    3329          25 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3330          25 :                     RefrigRack(RackNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    3331          25 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3332          25 :                     RefrigRack(RackNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    3333          36 :                 } else if (CoilNum != 0) { // Name points to a coil
    3334           0 :                     NumCoils = 1;
    3335           0 :                     RefrigRack(RackNum).NumCoils = 1;
    3336           0 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    3337           0 :                     RefrigRack(RackNum).CoilNum(NumCoils) = CoilNum;
    3338          36 :                 } else if (CaseNum != 0) { // Name points to a case
    3339          36 :                     NumCases = 1;
    3340          36 :                     RefrigRack(RackNum).NumCases = 1;
    3341          36 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3342          36 :                     RefrigRack(RackNum).CaseNum(NumCases) = CaseNum;
    3343           0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    3344           0 :                     NumWalkIns = 1;
    3345           0 :                     RefrigRack(RackNum).NumWalkIns = 1;
    3346           0 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3347           0 :                     RefrigRack(RackNum).WalkInNum(NumWalkIns) = WalkInNum;
    3348             :                 } // NumNameMatches /= 1
    3349             :             }     // blank input for loads on rack
    3350             : 
    3351          61 :             if (NumCases > 0) {
    3352         153 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    3353          92 :                     int caseID = RefrigRack(RackNum).CaseNum(caseIndex);
    3354             :                     // mark all cases on rack as used by this system (checking for unused or non-unique cases)
    3355          92 :                     ++RefrigCase(caseID).NumSysAttach;
    3356             :                     // determine total capacity on rack
    3357          92 :                     RefrigRack(RackNum).TotalRackLoad += RefrigCase(caseID).DesignRatedCap;
    3358             :                 } // CaseIndex=1,NumCases
    3359             :                 //     check that all refrigerated cases attached to a rack are to the same zone if heat rejection location is "Zone"
    3360             :                 //     however, won't matter if walk-in specified
    3361          88 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone && RefrigRack(RackNum).NumCases > 1 &&
    3362          88 :                     RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum != 0 && NumWalkIns < 1 && NumCoils < 1) {
    3363           0 :                     int ZoneNum = RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum;
    3364           0 :                     for (int caseIndex = 2; caseIndex <= RefrigRack(RackNum).NumCases; ++caseIndex) {
    3365           0 :                         if (RefrigCase(RefrigRack(RackNum).CaseNum(caseIndex)).ActualZoneNum == ZoneNum) continue;
    3366           0 :                         ShowSevereError(state,
    3367           0 :                                         format(R"({}{}="{}" : All cases attached to a rack must be in the same zone when {} equals "Zone".)",
    3368             :                                                RoutineName,
    3369             :                                                CurrentModuleObject,
    3370           0 :                                                RefrigRack(RackNum).Name,
    3371             :                                                cAlphaFieldNames(2)));
    3372           0 :                         ErrorsFound = true;
    3373           0 :                         break;
    3374             :                     }
    3375             :                 } // heat rejection location is zone
    3376             :             }     // numcases > 0
    3377             : 
    3378          61 :             if (NumCoils > 0) {
    3379           0 :                 RefrigRack(RackNum).CoilFlag = true;
    3380           0 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    3381           0 :                     int CoilNum = RefrigRack(RackNum).CoilNum(CoilIndex);
    3382             :                     // mark all Coils on rack as used by this system (checking for unused or non-unique Coils)
    3383           0 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    3384             :                     // determine total capacity on rack
    3385           0 :                     RefrigRack(RackNum).TotalRackLoad += WarehouseCoil(CoilNum).RatedSensibleCap;
    3386             :                 } // CoilIndex=1,NumCoils
    3387             :             }     // numcoils > 0
    3388             : 
    3389          61 :             if (NumWalkIns > 0) {
    3390           0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    3391           0 :                     int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInIndex);
    3392             :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    3393           0 :                     ++WalkIn(WalkInID).NumSysAttach;
    3394             :                     // determine total capacity on rack
    3395           0 :                     RefrigRack(RackNum).TotalRackLoad += WalkIn(WalkInID).DesignRatedCap;
    3396             :                 } // WalkInIndex=1,NumWalkIns
    3397             :             }     // NumWalkins
    3398             : 
    3399          61 :             if (NumWalkIns > 0 || NumCoils > 0) {
    3400             :                 // Get the heat rejection Zone node number from the zone name entered by the user (if heatrej location = zone)
    3401           0 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    3402           0 :                     if (lAlphaBlanks(15)) {
    3403           0 :                         ShowSevereError(
    3404             :                             state,
    3405           0 :                             format("{}{}=\"{}{} must be input if walkins or AirChillers connected to rack and heat rejection location = zone.",
    3406             :                                    RoutineName,
    3407             :                                    CurrentModuleObject,
    3408           0 :                                    RefrigRack(RackNum).Name,
    3409             :                                    cAlphaFieldNames(15)));
    3410           0 :                         ErrorsFound = true;
    3411             :                     } else { // alpha (15) not blank
    3412           0 :                         RefrigRack(RackNum).HeatRejectionZoneNum = Util::FindItemInList(Alphas(15), state.dataHeatBal->Zone);
    3413           0 :                         RefrigRack(RackNum).HeatRejectionZoneNodeNum =
    3414           0 :                             DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigRack(RackNum).HeatRejectionZoneNum);
    3415           0 :                         if (RefrigRack(RackNum).HeatRejectionZoneNum == 0) {
    3416           0 :                             ShowSevereError(state,
    3417           0 :                                             format("{}{}=\"{}\", invalid  {} not valid: {}",
    3418             :                                                    RoutineName,
    3419             :                                                    CurrentModuleObject,
    3420           0 :                                                    RefrigRack(RackNum).Name,
    3421             :                                                    cAlphaFieldNames(15),
    3422             :                                                    Alphas(15)));
    3423           0 :                             ErrorsFound = true;
    3424             :                         } else {
    3425           0 :                             state.dataRefrigCase->RefrigPresentInZone(RefrigRack(RackNum).HeatRejectionZoneNum) = true;
    3426             :                         } // zonenum == 0
    3427             :                     }     // alpha 15 blank
    3428             :                 }         // zone heat rej and walk-ins or coils present, must input heat rejection zone
    3429             :             }             // numwalkins or coils > 0
    3430             : 
    3431             :             // set condenser air flow and evap water pump power if autocalculated
    3432             :             // autocalculate condenser evap water pump if needed
    3433          63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3434           2 :                 RefrigRack(RackNum).EvapPumpPower == Constant::AutoCalculate) {
    3435           2 :                 RefrigRack(RackNum).EvapPumpPower = CondPumpRatePower * RefrigRack(RackNum).TotalRackLoad;
    3436             :             }
    3437             :             // autocalculate evap condenser air volume flow rate if needed
    3438          63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3439           2 :                 RefrigRack(RackNum).CondenserAirFlowRate == Constant::AutoCalculate) {
    3440           2 :                 RefrigRack(RackNum).CondenserAirFlowRate = AirVolRateEvapCond * RefrigRack(RackNum).TotalRackLoad;
    3441             :             }
    3442             : 
    3443             :         } // RackNum=1,NumRefrigeratedRacks
    3444             : 
    3445          31 :         state.dataRefrigCase->CheckEquipNameRackWaterCondenser.dimension(state.dataRefrigCase->NumRefrigeratedRacks, true);
    3446             :     } //(NumRefrigeratedRacks > 0)
    3447             : 
    3448         796 :     if (state.dataRefrigCase->NumRefrigSystems > 0 || state.dataRefrigCase->NumTransRefrigSystems > 0) {
    3449             : 
    3450          15 :         if (state.dataRefrigCase->NumRefrigSystems > 0 && state.dataRefrigCase->NumRefrigCondensers == 0) {
    3451           0 :             ShowSevereError(state,
    3452             :                             "Refrigeration:System objects were found during input processing, however no Rrefrigeration condenser objects (which "
    3453             :                             "may be either: ");
    3454           0 :             ShowContinueError(state,
    3455             :                               " Refrigeration:Condenser:AirCooled, Refrigeration:Condenser:WaterCooled, "
    3456             :                               "Refrigeration:Condenser:EvaporativeCooled,or Refrigeration:Condenser:CascadeCooled) were found.");
    3457           0 :             ErrorsFound = true;
    3458             :         }
    3459          15 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0 && state.dataRefrigCase->NumSimulationGasCooler == 0) {
    3460           0 :             ShowSevereError(state,
    3461             :                             "Refrigeration:TranscriticalSystem objects were found during input processing, however no Refrigeration gas cooler "
    3462             :                             "objects (Refrigeration:GasCooler:AirCooled) were found.");
    3463           0 :             ErrorsFound = true;
    3464             :         }
    3465          15 :         if (state.dataRefrigCase->NumSimulationCompressors == 0) {
    3466           0 :             ShowSevereError(
    3467             :                 state, "Refrigeration:System objects were found during input processing, however no Refrigeration:Compressor objects were found.");
    3468           0 :             ErrorsFound = true;
    3469             :         }
    3470             : 
    3471             :         //************ START CONDENSER INPUT  **************
    3472             : 
    3473          15 :         if (state.dataRefrigCase->NumSimulationCondAir > 0) {
    3474          12 :             CurrentModuleObject = "Refrigeration:Condenser:AirCooled";
    3475          44 :             for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumSimulationCondAir; ++CondNum) {
    3476          32 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3477             :                                                                          CurrentModuleObject,
    3478             :                                                                          CondNum,
    3479             :                                                                          Alphas,
    3480             :                                                                          NumAlphas,
    3481             :                                                                          Numbers,
    3482             :                                                                          NumNumbers,
    3483             :                                                                          IOStatus,
    3484             :                                                                          lNumericBlanks,
    3485             :                                                                          lAlphaBlanks,
    3486             :                                                                          cAlphaFieldNames,
    3487             :                                                                          cNumericFieldNames);
    3488          32 :                 GlobalNames::VerifyUniqueInterObjectName(
    3489          64 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3490          32 :                 Condenser(CondNum).Name = Alphas(1);
    3491          32 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3492          32 :                 Condenser(CondNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3493          32 :                 if (Condenser(CondNum).CapCurvePtr == 0) {
    3494           0 :                     ShowSevereError(state,
    3495           0 :                                     format("{}{}=\"{}\", invalid  {} not found:{}",
    3496             :                                            RoutineName,
    3497             :                                            CurrentModuleObject,
    3498           0 :                                            Condenser(CondNum).Name,
    3499             :                                            cAlphaFieldNames(2),
    3500             :                                            Alphas(2)));
    3501           0 :                     ErrorsFound = true;
    3502             :                 }
    3503             : 
    3504             :                 // set start of count for number of systems attached to this condenser
    3505          32 :                 Condenser(CondNum).NumSysAttach = 0;
    3506          32 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3507             : 
    3508             :                 // set CondenserType and rated temperature difference (51.7 - 35)C per ARI 460
    3509          32 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3510          32 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3511          32 :                 Condenser(CondNum).RatedDelT = CondARI460DelT; //= 16.7d0 ,Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
    3512          32 :                 Condenser(CondNum).RatedTCondense = CondARI460Tcond;
    3513          32 :                 if (Condenser(CondNum).CapCurvePtr > 0) {
    3514          32 :                     Condenser(CondNum).RatedCapacity = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, CondARI460DelT);
    3515             :                 }
    3516             :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    3517          32 :                 Condenser(CondNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3518          32 :                 if (Condenser(CondNum).RatedCapacity > 0.0) {
    3519          32 :                     Curve::GetCurveMinMaxValues(state, Condenser(CondNum).CapCurvePtr, DelTempMin, DelTempMax);
    3520          32 :                     Real64 Capmin = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMin) *
    3521          32 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug fix
    3522          32 :                     Real64 Capmax = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMax) *
    3523          32 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug
    3524          64 :                     Condenser(CondNum).TempSlope =
    3525          32 :                         (DelTempMax - DelTempMin) / ((Capmax - Capmin)); // * ( 1.0 - 7.17e-5 * Elevation ) ) //Mar 2011 bug fix
    3526          32 :                     Condenser(CondNum).MinCondLoad = Capmax - DelTempMax / Condenser(CondNum).TempSlope;
    3527             :                 } else {
    3528           0 :                     ShowSevereError(state,
    3529           0 :                                     format("{}{}=\"{}\" Condenser capacity curve per ARI 460 must be input and must be greater than 0 Watts at "
    3530             :                                            "16.7C temperature difference.",
    3531             :                                            RoutineName,
    3532             :                                            CurrentModuleObject,
    3533           0 :                                            Condenser(CondNum).Name));
    3534           0 :                     ErrorsFound = true;
    3535             :                 }
    3536             : 
    3537          32 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3538          32 :                 if (!lNumericBlanks(1)) Condenser(CondNum).RatedSubcool = Numbers(1);
    3539             : 
    3540             :                 // Get fan control type
    3541          32 :                 if (Util::SameString(Alphas(3), "FixedLinear")) {
    3542           0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeedLinear;
    3543          32 :                 } else if (Util::SameString(Alphas(3), "VariableSpeed")) {
    3544           9 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::VariableSpeed;
    3545          23 :                 } else if (Util::SameString(Alphas(3), "TwoSpeed")) {
    3546          16 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::TwoSpeed;
    3547             :                 } else {
    3548           7 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3549             :                 }                                                                             // Set fan control type
    3550             : 
    3551          32 :                 if (!lNumericBlanks(2)) Condenser(CondNum).RatedFanPower = Numbers(2);
    3552          32 :                 if ((lNumericBlanks(2)) || (Numbers(2) < 0.0)) {
    3553           0 :                     ShowSevereError(state,
    3554           0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    3555             :                                            RoutineName,
    3556             :                                            CurrentModuleObject,
    3557           0 :                                            Condenser(CondNum).Name,
    3558             :                                            cNumericFieldNames(2)));
    3559           0 :                     ErrorsFound = true;
    3560             :                 }
    3561             : 
    3562          32 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3563          32 :                 if (!lNumericBlanks(3)) Condenser(CondNum).FanMinAirFlowRatio = Numbers(3);
    3564             : 
    3565             :                 // Check condenser air inlet node connection
    3566             :                 // Jan 2011 - added ability to reject heat to a zone from air-cooled condenser
    3567          32 :                 Condenser(CondNum).CondenserRejectHeatToZone = false;
    3568          32 :                 if (lAlphaBlanks(4)) {
    3569           0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3570             :                 } else { // see if it's an outside air node name or an indoor zone name,
    3571             :                     // have to check inside first because outside check automatically generates an error message
    3572          32 :                     Condenser(CondNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    3573             :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    3574          32 :                     if (Condenser(CondNum).InletAirZoneNum != 0) {
    3575             :                         // set condenser flag (later used to set system flag) and zone flag
    3576           3 :                         Condenser(CondNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, Condenser(CondNum).InletAirZoneNum);
    3577           3 :                         Condenser(CondNum).CondenserRejectHeatToZone = true;
    3578           3 :                         state.dataRefrigCase->RefrigPresentInZone(Condenser(CondNum).InletAirZoneNum) = true;
    3579             :                     } else { // not in a conditioned zone, so see if it's outside
    3580          58 :                         Condenser(CondNum).InletAirNodeNum =
    3581          58 :                             NodeInputManager::GetOnlySingleNode(state,
    3582          29 :                                                                 Alphas(4),
    3583             :                                                                 ErrorsFound,
    3584             :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationCondenserAirCooled,
    3585          29 :                                                                 Alphas(1),
    3586             :                                                                 DataLoopNode::NodeFluidType::Air,
    3587             :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    3588             :                                                                 NodeInputManager::CompFluidStream::Primary,
    3589             :                                                                 DataLoopNode::ObjectIsParent);
    3590          29 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3591             :                             // not outside and not a zone
    3592           0 :                             ShowSevereError(state,
    3593           0 :                                             format("{}{}=\"{}\", {} not found: {}",
    3594             :                                                    RoutineName,
    3595             :                                                    CurrentModuleObject,
    3596           0 :                                                    Condenser(CondNum).Name,
    3597             :                                                    cAlphaFieldNames(4),
    3598             :                                                    Alphas(4)));
    3599           0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    3600           0 :                             ErrorsFound = true;
    3601             :                         } // checkoutairnodenumber
    3602             :                     }     // InletAirZoneNum \=0
    3603             :                 }         // Condenser air inlet node connection
    3604             : 
    3605          32 :                 Condenser(CondNum).EndUseSubcategory = "";
    3606          32 :                 if (!lAlphaBlanks(5)) Condenser(CondNum).EndUseSubcategory = Alphas(5);
    3607             : 
    3608          32 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3609          32 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3610          32 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3611          32 :                 if (!lNumericBlanks(4)) Condenser(CondNum).RefOpCharge = Numbers(4);
    3612          32 :                 if (!lNumericBlanks(5)) Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3613          32 :                 if (!lNumericBlanks(6)) Condenser(CondNum).RefPipingInventory = Numbers(6);
    3614             : 
    3615             :             } // Read input for REFRIGERATION:Condenser:AirCooled
    3616             :         }     // NumSimulationCondAir > 0
    3617             : 
    3618          15 :         if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
    3619           2 :             CurrentModuleObject = "Refrigeration:Condenser:EvaporativeCooled";
    3620           5 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondEvap; ++CondIndex) {
    3621           3 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir;
    3622           3 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3623             :                                                                          CurrentModuleObject,
    3624             :                                                                          CondIndex,
    3625             :                                                                          Alphas,
    3626             :                                                                          NumAlphas,
    3627             :                                                                          Numbers,
    3628             :                                                                          NumNumbers,
    3629             :                                                                          IOStatus,
    3630             :                                                                          lNumericBlanks,
    3631             :                                                                          lAlphaBlanks,
    3632             :                                                                          cAlphaFieldNames,
    3633             :                                                                          cNumericFieldNames);
    3634             : 
    3635           3 :                 GlobalNames::VerifyUniqueInterObjectName(
    3636           6 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3637           3 :                 Condenser(CondNum).Name = Alphas(1);
    3638           3 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3639             : 
    3640             :                 // set start of count for number of systems attached to this condenser
    3641           3 :                 Condenser(CondNum).NumSysAttach = 0;
    3642           3 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3643             : 
    3644             :                 // set CondenserType and rated Heat Rejection per ARI 490 rating
    3645           3 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    3646           3 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3647           3 :                 Condenser(CondNum).RatedTCondense = CondARI490Tcond;
    3648           3 :                 Condenser(CondNum).RatedDelT = CondARI490DelT;
    3649             : 
    3650           3 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3651           3 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3652             :                 } else {
    3653           0 :                     ShowSevereError(state,
    3654           0 :                                     format("{}{}=\"{}\" {} per ARI 490 must be input and must be greater than 0 Watts.",
    3655             :                                            RoutineName,
    3656             :                                            CurrentModuleObject,
    3657           0 :                                            Condenser(CondNum).Name,
    3658             :                                            cNumericFieldNames(1)));
    3659           0 :                     ErrorsFound = true;
    3660             :                 }
    3661             :                 // Calculate capacity elevation derate factor per ARI 490 barometric pressure correction factor
    3662           3 :                 Condenser(CondNum).EvapElevFact = 1.0 - 3.074e-5 * state.dataEnvrn->Elevation;
    3663             : 
    3664           3 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3665           3 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) Condenser(CondNum).RatedSubcool = Numbers(2);
    3666             : 
    3667             :                 // Get fan control type
    3668           3 :                 if (Util::SameString(Alphas(3), "FixedLinear")) {
    3669           0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeedLinear;
    3670           3 :                 } else if (Util::SameString(Alphas(2), "VariableSpeed")) {
    3671           2 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::VariableSpeed;
    3672           1 :                 } else if (Util::SameString(Alphas(2), "TwoSpeed")) {
    3673           1 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::TwoSpeed;
    3674             :                 } else {
    3675           0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3676             :                 }                                                                             // Set fan control type
    3677             : 
    3678           3 :                 Condenser(CondNum).RatedFanPower = Numbers(3);
    3679           3 :                 if (Numbers(3) < 0.0) {
    3680           0 :                     ShowSevereError(state,
    3681           0 :                                     format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    3682             :                                            RoutineName,
    3683             :                                            CurrentModuleObject,
    3684           0 :                                            Condenser(CondNum).Name,
    3685             :                                            cNumericFieldNames(3)));
    3686           0 :                     ErrorsFound = true;
    3687             :                 }
    3688             : 
    3689           3 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3690           3 :                 if (!lNumericBlanks(4)) Condenser(CondNum).FanMinAirFlowRatio = Numbers(4);
    3691             : 
    3692             :                 // Enter min and max and default coefficients for evap condenser HRCF correlation
    3693             :                 // Defaults taken from 2008 BAC equipment for R22, R134a, series CXV
    3694             :                 // Correlation coefficients for other manufacturers are very similar per Hugh Henderson's work
    3695           3 :                 Condenser(CondNum).EvapCoeff1 = 6.63;
    3696           3 :                 Condenser(CondNum).EvapCoeff2 = 0.468;
    3697           3 :                 Condenser(CondNum).EvapCoeff3 = 17.93;
    3698           3 :                 Condenser(CondNum).EvapCoeff4 = -0.322;
    3699           3 :                 Condenser(CondNum).MinCapFacEvap = 0.5;
    3700           3 :                 Condenser(CondNum).MaxCapFacEvap = 5.0;
    3701           3 :                 NumNum = 5; // added warnings if below not blank but unused due to limits
    3702           3 :                 if (!lNumericBlanks(NumNum)) {
    3703           3 :                     if (Numbers(NumNum) >= 0.0) {
    3704           3 :                         Condenser(CondNum).EvapCoeff1 = Numbers(NumNum);
    3705             :                     } else {
    3706           0 :                         ShowWarningError(state,
    3707           0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3708             :                                                 CurrentModuleObject,
    3709           0 :                                                 Condenser(CondNum).Name,
    3710             :                                                 cNumericFieldNames(NumNum)));
    3711             :                     }
    3712             :                 }
    3713           3 :                 NumNum = 6; // EvapCoeff2 can't be equal to 0 because used in a denominator
    3714           3 :                 if (!lNumericBlanks(NumNum)) {
    3715           3 :                     if (Numbers(NumNum) > 0.0) {
    3716           3 :                         Condenser(CondNum).EvapCoeff2 = Numbers(NumNum);
    3717             :                     } else {
    3718           0 :                         ShowWarningError(state,
    3719           0 :                                          format("{}=\"{}\", {} is less than or equal to 0 and was not used. Default was used.",
    3720             :                                                 CurrentModuleObject,
    3721           0 :                                                 Condenser(CondNum).Name,
    3722             :                                                 cNumericFieldNames(NumNum)));
    3723             :                     }
    3724             :                 }
    3725           3 :                 NumNum = 7;
    3726           3 :                 if (!lNumericBlanks(NumNum)) {
    3727           3 :                     if (Numbers(NumNum) >= 0.0) {
    3728           3 :                         Condenser(CondNum).EvapCoeff3 = Numbers(NumNum);
    3729             :                     } else {
    3730           0 :                         ShowWarningError(state,
    3731           0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3732             :                                                 CurrentModuleObject,
    3733           0 :                                                 Condenser(CondNum).Name,
    3734             :                                                 cNumericFieldNames(NumNum)));
    3735             :                     }
    3736             :                 }
    3737           3 :                 NumNum = 8;
    3738           3 :                 if (!lNumericBlanks(NumNum)) {
    3739           3 :                     if (Numbers(NumNum) >= -20.0) {
    3740           3 :                         Condenser(CondNum).EvapCoeff4 = Numbers(NumNum);
    3741             :                     } else {
    3742           0 :                         ShowWarningError(state,
    3743           0 :                                          format("{}=\"{}\", {} is less than -20 and was not used. Default was used.",
    3744             :                                                 CurrentModuleObject,
    3745           0 :                                                 Condenser(CondNum).Name,
    3746             :                                                 cNumericFieldNames(NumNum)));
    3747             :                     }
    3748             :                 }
    3749           3 :                 NumNum = 9;
    3750           3 :                 if (!lNumericBlanks(NumNum)) {
    3751           3 :                     if (Numbers(NumNum) >= 0.0) {
    3752           3 :                         Condenser(CondNum).MinCapFacEvap = Numbers(NumNum);
    3753             :                     } else {
    3754           0 :                         ShowWarningError(state,
    3755           0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3756             :                                                 CurrentModuleObject,
    3757           0 :                                                 Condenser(CondNum).Name,
    3758             :                                                 cNumericFieldNames(NumNum)));
    3759             :                     }
    3760             :                 }
    3761           3 :                 NumNum = 10;
    3762           3 :                 if (!lNumericBlanks(NumNum)) {
    3763           3 :                     if (Numbers(NumNum) >= 0.0) {
    3764           3 :                         Condenser(CondNum).MaxCapFacEvap = Numbers(NumNum);
    3765             :                     } else {
    3766           0 :                         ShowWarningError(state,
    3767           0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3768             :                                                 CurrentModuleObject,
    3769           0 :                                                 Condenser(CondNum).Name,
    3770             :                                                 cNumericFieldNames(NumNum)));
    3771             :                     }
    3772             :                 }
    3773             : 
    3774             :                 // Check condenser air inlet node connection
    3775           3 :                 if (lAlphaBlanks(3)) {
    3776           0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3777             :                 } else {
    3778           6 :                     Condenser(CondNum).InletAirNodeNum =
    3779           6 :                         NodeInputManager::GetOnlySingleNode(state,
    3780           3 :                                                             Alphas(3),
    3781             :                                                             ErrorsFound,
    3782             :                                                             DataLoopNode::ConnectionObjectType::RefrigerationCondenserEvaporativeCooled,
    3783           3 :                                                             Alphas(1),
    3784             :                                                             DataLoopNode::NodeFluidType::Air,
    3785             :                                                             DataLoopNode::ConnectionType::OutsideAirReference,
    3786             :                                                             NodeInputManager::CompFluidStream::Primary,
    3787             :                                                             DataLoopNode::ObjectIsParent);
    3788           3 :                     if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3789           0 :                         ShowSevereError(state,
    3790           0 :                                         format("{}{}=\"{}\", {} not found: {}",
    3791             :                                                RoutineName,
    3792             :                                                CurrentModuleObject,
    3793           0 :                                                Condenser(CondNum).Name,
    3794             :                                                cAlphaFieldNames(3),
    3795             :                                                Alphas(3)));
    3796           0 :                         ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    3797           0 :                         ErrorsFound = true;
    3798             :                     }
    3799             :                 } // Condenser air inlet node connection
    3800             : 
    3801           3 :                 NumNum = 11;
    3802           3 :                 Condenser(CondNum).RatedAirFlowRate = Numbers(NumNum);
    3803             :                 // Note the autocalculate feature for this value takes place in the system section because
    3804             :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3805             : 
    3806             :                 // Evaporative condensers basin heater power as a function of temperature must be greater than or equal to 0
    3807           3 :                 NumNum = 12;
    3808           3 :                 Condenser(CondNum).BasinHeaterPowerFTempDiff = Numbers(NumNum);
    3809           3 :                 if (Numbers(NumNum) < 0.0) {
    3810           0 :                     ShowSevereError(
    3811             :                         state,
    3812           0 :                         format(
    3813           0 :                             "{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(NumNum)));
    3814           0 :                     ErrorsFound = true;
    3815             :                 }
    3816             : 
    3817           3 :                 NumNum = 13;
    3818           3 :                 Condenser(CondNum).BasinHeaterSetPointTemp = 2.0; // default
    3819           3 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).BasinHeaterSetPointTemp = Numbers(NumNum);
    3820           3 :                 if (Condenser(CondNum).BasinHeaterSetPointTemp < 2.0) {
    3821           0 :                     ShowWarningError(state,
    3822           0 :                                      format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    3823             :                                             CurrentModuleObject,
    3824           0 :                                             Condenser(CondNum).Name,
    3825             :                                             cNumericFieldNames(NumNum)));
    3826             :                 }
    3827             : 
    3828           3 :                 NumNum = 14;
    3829           3 :                 Condenser(CondNum).EvapPumpPower = 1000.0; // default
    3830           3 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).EvapPumpPower = Numbers(NumNum);
    3831             :                 // Note the autocalculate feature for this value takes place in the system section because
    3832             :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3833             : 
    3834             :                 // Get Evaporative Water System tank connections
    3835           3 :                 Condenser(CondNum).SupplyTankName = Alphas(4);
    3836           3 :                 if (lAlphaBlanks(4)) {
    3837           0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    3838             :                 } else {
    3839           3 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    3840           6 :                     WaterManager::SetupTankDemandComponent(state,
    3841           3 :                                                            Condenser(CondNum).Name,
    3842             :                                                            CurrentModuleObject,
    3843           3 :                                                            Condenser(CondNum).SupplyTankName,
    3844             :                                                            ErrorsFound,
    3845           3 :                                                            Condenser(CondNum).EvapWaterSupTankID,
    3846           3 :                                                            Condenser(CondNum).EvapWaterTankDemandARRID);
    3847             :                 }
    3848             : 
    3849           3 :                 if (lAlphaBlanks(5)) {
    3850           0 :                     Condenser(CondNum).EvapSchedPtr = 0;
    3851             :                 } else {
    3852           3 :                     Condenser(CondNum).EvapSchedPtr = ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer
    3853             :                     //   check availability schedule for values >= 0
    3854           3 :                     if (Condenser(CondNum).EvapSchedPtr > 0) {
    3855           3 :                         if (!ScheduleManager::CheckScheduleValueMinMax(state, Condenser(CondNum).EvapSchedPtr, true, 0.0)) {
    3856           0 :                             ShowSevereError(state, format("{}{}=\"{}\" .", RoutineName, CurrentModuleObject, Condenser(CondNum).Name));
    3857           0 :                             ShowContinueError(state, format("Error found in {} = {}", cAlphaFieldNames(5), Alphas(5)));
    3858           0 :                             ShowContinueError(state, "schedule values must be (>=0.).");
    3859           0 :                             ErrorsFound = true;
    3860             :                         }
    3861             :                     } else {
    3862           0 :                         ShowSevereError(state,
    3863           0 :                                         format("{}{}=\"{}\", invalid  {} = {}",
    3864             :                                                RoutineName,
    3865             :                                                CurrentModuleObject,
    3866           0 :                                                Condenser(CondNum).Name,
    3867             :                                                cAlphaFieldNames(5),
    3868             :                                                Alphas(5)));
    3869           0 :                         ShowContinueError(state, "A schedule with this name is not defined in this input data file.");
    3870           0 :                         ErrorsFound = true;
    3871             :                     }
    3872             :                 } // Set Evap Schedule Pointer
    3873             : 
    3874           3 :                 Condenser(CondNum).EndUseSubcategory = "";
    3875           3 :                 if (!lAlphaBlanks(6)) Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3876             : 
    3877           3 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3878           3 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3879           3 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3880           3 :                 NumNum = 15;
    3881           3 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefOpCharge = Numbers(NumNum);
    3882           3 :                 NumNum = 16;
    3883           3 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefReceiverInventory = Numbers(NumNum);
    3884           3 :                 NumNum = 17;
    3885           3 :                 if (!lNumericBlanks(NumNum)) Condenser(CondNum).RefPipingInventory = Numbers(NumNum);
    3886             :             } // Read input for CONDENSER:REFRIGERATION:EVAPorativeCooled
    3887             :         }     // If NumSimulationCondEvap > 0
    3888             : 
    3889          15 :         if (state.dataRefrigCase->NumSimulationCondWater > 0) {
    3890           1 :             CurrentModuleObject = "Refrigeration:Condenser:WaterCooled";
    3891           2 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondWater; ++CondIndex) {
    3892           1 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap;
    3893           1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3894             :                                                                          CurrentModuleObject,
    3895             :                                                                          CondIndex,
    3896             :                                                                          Alphas,
    3897             :                                                                          NumAlphas,
    3898             :                                                                          Numbers,
    3899             :                                                                          NumNumbers,
    3900             :                                                                          IOStatus,
    3901             :                                                                          lNumericBlanks,
    3902             :                                                                          lAlphaBlanks,
    3903             :                                                                          cAlphaFieldNames,
    3904             :                                                                          cNumericFieldNames);
    3905             : 
    3906           1 :                 GlobalNames::VerifyUniqueInterObjectName(
    3907           2 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3908           1 :                 Condenser(CondNum).Name = Alphas(1);
    3909           1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3910             : 
    3911             :                 // set start of count for number of systems attached to this condenser
    3912           1 :                 Condenser(CondNum).NumSysAttach = 0;
    3913           1 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3914             : 
    3915             :                 // set CondenserType and rated Heat Rejection per ARI 450 rating
    3916           1 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    3917           1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3918           1 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3919           1 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3920             :                 } else {
    3921           0 :                     ShowSevereError(state,
    3922           0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 Watts.",
    3923             :                                            RoutineName,
    3924             :                                            CurrentModuleObject,
    3925           0 :                                            Condenser(CondNum).Name,
    3926             :                                            cNumericFieldNames(1)));
    3927           0 :                     ErrorsFound = true;
    3928             :                 }
    3929             : 
    3930           1 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3931           1 :                     Condenser(CondNum).RatedTCondense = Numbers(2);
    3932             :                 } else {
    3933           0 :                     ShowSevereError(state,
    3934           0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 C.",
    3935             :                                            RoutineName,
    3936             :                                            CurrentModuleObject,
    3937           0 :                                            Condenser(CondNum).Name,
    3938             :                                            cNumericFieldNames(2)));
    3939           0 :                     ErrorsFound = true;
    3940             :                 }
    3941             : 
    3942           1 :                 if (!lNumericBlanks(3)) {
    3943           1 :                     if (Numbers(3) >= 0.0) {
    3944           1 :                         Condenser(CondNum).RatedSubcool = Numbers(3);
    3945             :                     } else {
    3946           0 :                         ShowSevereError(state,
    3947           0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    3948             :                                                RoutineName,
    3949             :                                                CurrentModuleObject,
    3950           0 :                                                Condenser(CondNum).Name,
    3951             :                                                cNumericFieldNames(3)));
    3952           0 :                         ErrorsFound = true;
    3953             :                     }
    3954             :                 } else {
    3955           0 :                     Condenser(CondNum).RatedSubcool = 0.0; // default value
    3956             :                 }
    3957             : 
    3958           1 :                 if ((!lNumericBlanks(4)) && (Numbers(4) > 0.0)) {
    3959           1 :                     Condenser(CondNum).RatedWaterInletT = Numbers(4);
    3960           1 :                     Condenser(CondNum).RatedApproachT = Condenser(CondNum).RatedTCondense - Numbers(4);
    3961             :                 } else {
    3962           0 :                     ShowSevereError(state,
    3963           0 :                                     format("{}{}=\"{}\" {} must be input and greater than zero.",
    3964             :                                            RoutineName,
    3965             :                                            CurrentModuleObject,
    3966           0 :                                            Condenser(CondNum).Name,
    3967             :                                            cNumericFieldNames(4)));
    3968           0 :                     ErrorsFound = true;
    3969             :                 }
    3970             : 
    3971           2 :                 Condenser(CondNum).InletNode =
    3972           2 :                     NodeInputManager::GetOnlySingleNode(state,
    3973           1 :                                                         Alphas(2),
    3974             :                                                         ErrorsFound,
    3975             :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3976           1 :                                                         Alphas(1),
    3977             :                                                         DataLoopNode::NodeFluidType::Water,
    3978             :                                                         DataLoopNode::ConnectionType::Inlet,
    3979             :                                                         NodeInputManager::CompFluidStream::Primary,
    3980             :                                                         DataLoopNode::ObjectIsNotParent);
    3981           2 :                 Condenser(CondNum).OutletNode =
    3982           2 :                     NodeInputManager::GetOnlySingleNode(state,
    3983           1 :                                                         Alphas(3),
    3984             :                                                         ErrorsFound,
    3985             :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3986           1 :                                                         Alphas(1),
    3987             :                                                         DataLoopNode::NodeFluidType::Water,
    3988             :                                                         DataLoopNode::ConnectionType::Outlet,
    3989             :                                                         NodeInputManager::CompFluidStream::Primary,
    3990             :                                                         DataLoopNode::ObjectIsNotParent);
    3991             :                 // Check node connections
    3992           1 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Water Cooled Condenser Nodes");
    3993             :                 // Get loop flow type
    3994           1 :                 if (Util::SameString(Alphas(4), "VariableFlow")) { // set FlowType
    3995           1 :                     Condenser(CondNum).FlowType = CndsrFlowType::VariableFlow;
    3996           0 :                 } else if (Util::SameString(Alphas(4), "ConstantFlow")) {
    3997           0 :                     Condenser(CondNum).FlowType = CndsrFlowType::ConstantFlow;
    3998             :                 } else {
    3999           0 :                     ShowSevereError(state,
    4000           0 :                                     format("{}{}=\"{}\", invalid  {} not recognized: {}",
    4001             :                                            RoutineName,
    4002             :                                            CurrentModuleObject,
    4003           0 :                                            Condenser(CondNum).Name,
    4004             :                                            cAlphaFieldNames(4),
    4005             :                                            Alphas(4)));
    4006           0 :                     ShowContinueError(state, "Check input value choices.");
    4007           0 :                     ErrorsFound = true;
    4008             :                 } // Set FlowType
    4009             : 
    4010             :                 // Get outlet temperature schedule for variable flow case
    4011           1 :                 if (Condenser(CondNum).FlowType == CndsrFlowType::VariableFlow) {
    4012           1 :                     if (lAlphaBlanks(5)) {
    4013           0 :                         Condenser(CondNum).OutletTempSchedPtr = 0;
    4014             :                     } else {
    4015           1 :                         Condenser(CondNum).OutletTempSchedPtr =
    4016           1 :                             ScheduleManager::GetScheduleIndex(state, Alphas(5)); // convert schedule name to pointer
    4017             :                     }
    4018           1 :                     if (Condenser(CondNum).OutletTempSchedPtr == 0) {
    4019           0 :                         ShowSevereError(state,
    4020           0 :                                         format("{}{}=\"{}\", invalid  {} = {}",
    4021             :                                                RoutineName,
    4022             :                                                CurrentModuleObject,
    4023           0 :                                                Condenser(CondNum).Name,
    4024             :                                                cAlphaFieldNames(5),
    4025             :                                                Alphas(5)));
    4026           0 :                         ShowContinueError(state, "A schedule with this name is not defined in this input data file.");
    4027           0 :                         ErrorsFound = true;
    4028             :                     }
    4029             :                 } // Outlet temperature schedule
    4030             : 
    4031             :                 // Get volumetric flow rate if applicable
    4032           1 :                 if (Condenser(CondNum).FlowType == CndsrFlowType::ConstantFlow) {
    4033           0 :                     if ((!lNumericBlanks(5)) && (Numbers(5) > 0.0)) {
    4034           0 :                         Condenser(CondNum).DesVolFlowRate = Numbers(5);
    4035           0 :                         Condenser(CondNum).VolFlowRate = Numbers(5);
    4036             :                     } else {
    4037           0 :                         ShowSevereError(state,
    4038           0 :                                         format("{}{}=\"{}\" {} must be greater than zero.",
    4039             :                                                RoutineName,
    4040             :                                                CurrentModuleObject,
    4041           0 :                                                Condenser(CondNum).Name,
    4042             :                                                cNumericFieldNames(5)));
    4043           0 :                         ShowContinueError(state, "Revise flow rates.");
    4044           0 :                         ErrorsFound = true;
    4045             :                     }
    4046           0 :                     PlantUtilities::RegisterPlantCompDesignFlow(state, Condenser(CondNum).InletNode, Condenser(CondNum).DesVolFlowRate);
    4047             :                 }
    4048             : 
    4049             :                 // Get maximum flow rates
    4050           1 :                 if (Numbers(6) > 0.0) {
    4051           1 :                     Condenser(CondNum).VolFlowRateMax = Numbers(6);
    4052             :                     // Check constant flow for max violation, if applicable
    4053           1 :                     if (Condenser(CondNum).FlowType == CndsrFlowType::ConstantFlow && Condenser(CondNum).VolFlowRate > Numbers(6)) {
    4054           0 :                         ShowSevereError(state,
    4055           0 :                                         format("{}{}=\"{}\" {} > {} .",
    4056             :                                                RoutineName,
    4057             :                                                CurrentModuleObject,
    4058           0 :                                                Condenser(CondNum).Name,
    4059             :                                                cNumericFieldNames(5),
    4060             :                                                cNumericFieldNames(6)));
    4061           0 :                         ShowContinueError(state, "Revise flow rates.");
    4062           0 :                         ErrorsFound = true;
    4063             :                     } // Error check on max flow rate
    4064             :                 } else {
    4065           0 :                     ShowSevereError(state,
    4066           0 :                                     format("{}{}=\"{}\" {} must be greater than zero.",
    4067             :                                            RoutineName,
    4068             :                                            CurrentModuleObject,
    4069           0 :                                            Condenser(CondNum).Name,
    4070             :                                            cNumericFieldNames(6)));
    4071           0 :                     ErrorsFound = true;
    4072             :                 }
    4073             : 
    4074             :                 // Get max/min allowed water temps
    4075           1 :                 Condenser(CondNum).OutletTempMax = Numbers(7);
    4076           1 :                 Condenser(CondNum).InletTempMin = Numbers(8);
    4077             : 
    4078           1 :                 Condenser(CondNum).EndUseSubcategory = "";
    4079           1 :                 if (!lAlphaBlanks(6)) Condenser(CondNum).EndUseSubcategory = Alphas(6);
    4080             : 
    4081           1 :                 Condenser(CondNum).RefOpCharge = 0.0;
    4082           1 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    4083           1 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    4084           1 :                 if (!lNumericBlanks(9)) Condenser(CondNum).RefOpCharge = Numbers(9);
    4085           1 :                 if (!lNumericBlanks(10)) Condenser(CondNum).RefReceiverInventory = Numbers(10);
    4086           1 :                 if (!lNumericBlanks(11)) Condenser(CondNum).RefPipingInventory = Numbers(11);
    4087             : 
    4088             :             } // Read input for CONDENSER:REFRIGERATION:WaterCooled
    4089             : 
    4090           1 :             state.dataRefrigCase->CheckEquipNameWaterCondenser.dimension(state.dataRefrigCase->NumRefrigCondensers, true);
    4091             :         } // NumSimulationCondWater > 0
    4092             : 
    4093             :         // cascade condensers assumed to provide zero subcooling
    4094          15 :         if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
    4095           1 :             CurrentModuleObject = "Refrigeration:Condenser:Cascade";
    4096           2 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCascadeCondensers; ++CondIndex) {
    4097           1 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
    4098           1 :                               state.dataRefrigCase->NumSimulationCondWater;
    4099           1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4100             :                                                                          CurrentModuleObject,
    4101             :                                                                          CondIndex,
    4102             :                                                                          Alphas,
    4103             :                                                                          NumAlphas,
    4104             :                                                                          Numbers,
    4105             :                                                                          NumNumbers,
    4106             :                                                                          IOStatus,
    4107             :                                                                          lNumericBlanks,
    4108             :                                                                          lAlphaBlanks,
    4109             :                                                                          cAlphaFieldNames,
    4110             :                                                                          cNumericFieldNames);
    4111             : 
    4112           1 :                 GlobalNames::VerifyUniqueInterObjectName(
    4113           2 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    4114           1 :                 Condenser(CondNum).Name = Alphas(1);
    4115           1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    4116             : 
    4117             :                 // set start of count for number of systems attached to this condenser
    4118           1 :                 Condenser(CondNum).NumSysAttach = 0;
    4119           1 :                 if (!allocated(Condenser(CondNum).SysNum)) Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    4120             : 
    4121             :                 // set CondenserType
    4122           1 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Cascade;
    4123             : 
    4124           1 :                 if (!lNumericBlanks(1)) {
    4125           1 :                     Condenser(CondNum).RatedTCondense = Numbers(1);
    4126             :                 } else {
    4127           0 :                     ShowSevereError(
    4128             :                         state,
    4129           0 :                         format("{}{}=\"{}\" {} must be input.", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(1)));
    4130           0 :                     ErrorsFound = true;
    4131             :                 }
    4132             : 
    4133           1 :                 if (!lNumericBlanks(2)) {
    4134           1 :                     if (Numbers(2) >= 0.0) {
    4135           1 :                         Condenser(CondNum).RatedApproachT = Numbers(2);
    4136             :                     } else {
    4137           0 :                         ShowSevereError(state,
    4138           0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    4139             :                                                RoutineName,
    4140             :                                                CurrentModuleObject,
    4141           0 :                                                Condenser(CondNum).Name,
    4142             :                                                cNumericFieldNames(2)));
    4143           0 :                         ErrorsFound = true;
    4144             :                     }
    4145             :                 } else {
    4146           0 :                     Condenser(CondNum).RatedApproachT = DefaultCascadeCondApproach;
    4147             :                 }
    4148             : 
    4149           1 :                 if ((!lNumericBlanks(3)) && (Numbers(3) > 0.0)) {
    4150           1 :                     Condenser(CondNum).RatedCapacity = Numbers(3);
    4151             :                 } else {
    4152           0 :                     ShowSevereError(state,
    4153           0 :                                     format("{}{}=\"{}\" {} must be in put and must be greater than or equal to zero.",
    4154             :                                            RoutineName,
    4155             :                                            CurrentModuleObject,
    4156           0 :                                            Condenser(CondNum).Name,
    4157             :                                            cNumericFieldNames(3)));
    4158           0 :                     ErrorsFound = true;
    4159             :                 }
    4160             : 
    4161             :                 // Get condensing temperature type, either fixed by design or allowed to float to match other loads on supply system
    4162           1 :                 if (!lAlphaBlanks(2)) {
    4163           1 :                     if (Util::SameString(Alphas(2), "Fixed")) { // set Condenser Temperature Control Type
    4164           1 :                         Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempSet;
    4165           0 :                     } else if (Util::SameString(Alphas(2), "Float")) {
    4166           0 :                         Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempFloat;
    4167             :                     } else {
    4168           0 :                         ShowSevereError(state,
    4169           0 :                                         format("{}{}=\"{}\", invalid  {} not recognized: {}",
    4170             :                                                RoutineName,
    4171             :                                                CurrentModuleObject,
    4172           0 :                                                Condenser(CondNum).Name,
    4173             :                                                cAlphaFieldNames(2),
    4174             :                                                Alphas(2)));
    4175           0 :                         ShowContinueError(state, "Check input value choices.");
    4176           0 :                         ErrorsFound = true;
    4177             :                     }    // string comparison to key choices
    4178             :                 } else { // default is fixed/cascadetempset
    4179           0 :                     Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempSet;
    4180             :                 } // not blank
    4181             : 
    4182           1 :                 Condenser(CondNum).CascadeRatedEvapTemp = Condenser(CondNum).RatedTCondense - Condenser(CondNum).RatedApproachT;
    4183             : 
    4184             :                 // future - add refrigerant inventory on system side accepting reject heat (as was done for secondary)
    4185           1 :                 Condenser(CondNum).RefOpCharge = 0.0;
    4186           1 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    4187           1 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    4188           1 :                 if (!lNumericBlanks(4)) Condenser(CondNum).RefOpCharge = Numbers(4);
    4189           1 :                 if (!lNumericBlanks(5)) Condenser(CondNum).RefReceiverInventory = Numbers(5);
    4190           1 :                 if (!lNumericBlanks(6)) Condenser(CondNum).RefPipingInventory = Numbers(6);
    4191             : 
    4192             :             } // Read input for CONDENSER:REFRIGERATION:Cascade
    4193             :         }     // NumSimulationCascadeCondensers > 0
    4194             : 
    4195             :         //************ END CONDENSER INPUT   **************
    4196             : 
    4197             :         //**********  START GAS COOLER INPUT  **********
    4198             : 
    4199          15 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    4200           1 :             CurrentModuleObject = "Refrigeration:GasCooler:AirCooled";
    4201           2 :             for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    4202           1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4203             :                                                                          CurrentModuleObject,
    4204             :                                                                          GCNum,
    4205             :                                                                          Alphas,
    4206             :                                                                          NumAlphas,
    4207             :                                                                          Numbers,
    4208             :                                                                          NumNumbers,
    4209             :                                                                          IOStatus,
    4210             :                                                                          lNumericBlanks,
    4211             :                                                                          lAlphaBlanks,
    4212             :                                                                          cAlphaFieldNames,
    4213             :                                                                          cNumericFieldNames);
    4214           1 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4215           1 :                 GasCooler(GCNum).Name = Alphas(1);
    4216             : 
    4217           1 :                 GasCooler(GCNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    4218           1 :                 if (GasCooler(GCNum).CapCurvePtr == 0) {
    4219           0 :                     ShowSevereError(state,
    4220           0 :                                     format("{}{}=\"{}\", invalid {} not found:{}",
    4221             :                                            RoutineName,
    4222             :                                            CurrentModuleObject,
    4223           0 :                                            GasCooler(GCNum).Name,
    4224             :                                            cAlphaFieldNames(2),
    4225             :                                            Alphas(2)));
    4226           0 :                     ErrorsFound = true;
    4227             :                 }
    4228             : 
    4229             :                 // set start of count for number of systems attached to this gas cooler
    4230           1 :                 GasCooler(GCNum).NumSysAttach = 0;
    4231           1 :                 if (!allocated(GasCooler(GCNum).SysNum)) GasCooler(GCNum).SysNum.allocate(state.dataRefrigCase->NumTransRefrigSystems);
    4232             : 
    4233           1 :                 GasCooler(GCNum).RatedApproachT = 3.0; // rated CO2 gas cooler approach temperature
    4234           1 :                 if (GasCooler(GCNum).CapCurvePtr > 0) {
    4235           1 :                     GasCooler(GCNum).RatedCapacity = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, GasCooler(GCNum).RatedApproachT);
    4236             :                 }
    4237             :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    4238           1 :                 GasCooler(GCNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    4239           1 :                 if (GasCooler(GCNum).RatedCapacity > 0.0) {
    4240           1 :                     Curve::GetCurveMinMaxValues(state, GasCooler(GCNum).CapCurvePtr, DelTempMin, DelTempMax);
    4241           1 :                     Real64 Capmin = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMin) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    4242           1 :                     Real64 Capmax = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMax) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    4243           1 :                     GasCooler(GCNum).TempSlope = (DelTempMax - DelTempMin) / ((Capmax - Capmin));
    4244           1 :                     GasCooler(GCNum).MinCondLoad = Capmax - DelTempMax / GasCooler(GCNum).TempSlope;
    4245             :                 } else {
    4246           0 :                     ShowSevereError(
    4247             :                         state,
    4248           0 :                         format("{}{}=\"{}\" Gas Cooler capacity curve must be input and must be greater than 0 Watts at 3C temperature difference.",
    4249             :                                RoutineName,
    4250             :                                CurrentModuleObject,
    4251           0 :                                GasCooler(GCNum).Name));
    4252           0 :                     ErrorsFound = true;
    4253             :                 }
    4254             : 
    4255             :                 // Get fan control type
    4256           1 :                 if (Util::SameString(Alphas(3), "FixedLinear")) {
    4257           0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeedLinear;
    4258           1 :                 } else if (Util::SameString(Alphas(3), "VariableSpeed")) {
    4259           0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::VariableSpeed;
    4260           1 :                 } else if (Util::SameString(Alphas(3), "TwoSpeed")) {
    4261           0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::TwoSpeed;
    4262             :                 } else {
    4263           1 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    4264             :                 }                                                                           // Set fan control type
    4265             : 
    4266             :                 // Gas cooler fan power
    4267           1 :                 GasCooler(GCNum).RatedFanPower = 5000.0; // default value
    4268           1 :                 if (!lNumericBlanks(1)) GasCooler(GCNum).RatedFanPower = Numbers(1);
    4269           1 :                 if (Numbers(1) < 0.0) {
    4270           0 :                     ShowSevereError(state,
    4271           0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    4272             :                                            RoutineName,
    4273             :                                            CurrentModuleObject,
    4274           0 :                                            GasCooler(GCNum).Name,
    4275             :                                            cNumericFieldNames(1)));
    4276           0 :                     ErrorsFound = true;
    4277             :                 }
    4278             : 
    4279             :                 // Gas cooler minimum fan air flow ratio
    4280           1 :                 GasCooler(GCNum).FanMinAirFlowRatio = 0.2; // default value
    4281           1 :                 if (!lNumericBlanks(2)) GasCooler(GCNum).FanMinAirFlowRatio = Numbers(2);
    4282           1 :                 if ((GasCooler(GCNum).FanMinAirFlowRatio < 0.0) || (GasCooler(GCNum).FanMinAirFlowRatio > 1.0)) {
    4283           0 :                     ShowSevereError(state,
    4284           0 :                                     format("{}{}=\"{}\" {} must be a value between zero and one.  The default value (0.2) will be used.",
    4285             :                                            RoutineName,
    4286             :                                            CurrentModuleObject,
    4287           0 :                                            GasCooler(GCNum).Name,
    4288             :                                            cNumericFieldNames(2)));
    4289           0 :                     GasCooler(GCNum).FanMinAirFlowRatio = 0.2;
    4290             :                 }
    4291             : 
    4292             :                 // Gas cooler transition temperature
    4293           1 :                 GasCooler(GCNum).TransitionTemperature = 2.7e1; // default value
    4294           1 :                 if (!lNumericBlanks(3)) GasCooler(GCNum).TransitionTemperature = Numbers(3);
    4295           1 :                 if (GasCooler(GCNum).TransitionTemperature < 2.5e1) {
    4296           0 :                     ShowWarningError(state,
    4297           0 :                                      format("{}{}=\"{}\" {} is low (less than 25C).  Consider raising the transition temperature to operate for "
    4298             :                                             "longer periods of time in the subcritical region.",
    4299             :                                             RoutineName,
    4300             :                                             CurrentModuleObject,
    4301           0 :                                             GasCooler(GCNum).Name,
    4302             :                                             cNumericFieldNames(3)));
    4303             :                 }
    4304           1 :                 if (GasCooler(GCNum).TransitionTemperature > 30.978) {
    4305           0 :                     ShowWarningError(
    4306             :                         state,
    4307           0 :                         format("{}{}=\"{}\" {} is greater than the critical temperature of carbon dioxide.  The default value (27C) will be used.",
    4308             :                                RoutineName,
    4309             :                                CurrentModuleObject,
    4310           0 :                                GasCooler(GCNum).Name,
    4311             :                                cNumericFieldNames(3)));
    4312           0 :                     GasCooler(GCNum).TransitionTemperature = 2.7e1;
    4313             :                 }
    4314             : 
    4315             :                 // Gas cooler approach temperature for transcritical operation
    4316           1 :                 GasCooler(GCNum).GasCoolerApproachT = 3.0; // default value
    4317           1 :                 if (!lNumericBlanks(4)) GasCooler(GCNum).GasCoolerApproachT = Numbers(4);
    4318           1 :                 if (GasCooler(GCNum).GasCoolerApproachT < 0.0) {
    4319           0 :                     ShowSevereError(state,
    4320           0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    4321             :                                            RoutineName,
    4322             :                                            CurrentModuleObject,
    4323           0 :                                            GasCooler(GCNum).Name,
    4324             :                                            cNumericFieldNames(4)));
    4325           0 :                     ErrorsFound = true;
    4326             :                 }
    4327             : 
    4328             :                 // Gas cooler temperature difference for subcritical operation
    4329           1 :                 GasCooler(GCNum).SubcriticalTempDiff = 1.0e1; // default value
    4330           1 :                 if (!lNumericBlanks(5)) GasCooler(GCNum).SubcriticalTempDiff = Numbers(5);
    4331           1 :                 if (GasCooler(GCNum).SubcriticalTempDiff < 0.0) {
    4332           0 :                     ShowSevereError(state,
    4333           0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    4334             :                                            RoutineName,
    4335             :                                            CurrentModuleObject,
    4336           0 :                                            GasCooler(GCNum).Name,
    4337             :                                            cNumericFieldNames(5)));
    4338           0 :                     ErrorsFound = true;
    4339             :                 }
    4340             : 
    4341             :                 // Gas cooler minimum condensing temperature for subcritical operation
    4342           1 :                 GasCooler(GCNum).MinCondTemp = 1.0e1; // default value
    4343           1 :                 if (!lNumericBlanks(6)) GasCooler(GCNum).MinCondTemp = Numbers(6);
    4344           1 :                 if (GasCooler(GCNum).MinCondTemp > 30.9) {
    4345           0 :                     ShowSevereError(state,
    4346           0 :                                     format("{}{}=\"{}\" {} must be less than the critical temperature of carbon dioxide (31C).",
    4347             :                                            RoutineName,
    4348             :                                            CurrentModuleObject,
    4349           0 :                                            GasCooler(GCNum).Name,
    4350             :                                            cNumericFieldNames(6)));
    4351           0 :                     ErrorsFound = true;
    4352             :                 }
    4353             : 
    4354             :                 // Check GasCooler air inlet node connection
    4355           1 :                 GasCooler(GCNum).GasCoolerRejectHeatToZone = false;
    4356           1 :                 if (lAlphaBlanks(4)) {
    4357           1 :                     GasCooler(GCNum).InletAirNodeNum = 0;
    4358             :                 } else { // see if it's an outside air node name or an indoor zone name,
    4359             :                     // have to check inside first because outside check automatically generates an error message
    4360           0 :                     GasCooler(GCNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    4361             :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    4362           0 :                     if (GasCooler(GCNum).InletAirZoneNum != 0) {
    4363             :                         // set condenser flag (later used to set system flag) and zone flag
    4364           0 :                         GasCooler(GCNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, GasCooler(GCNum).InletAirZoneNum);
    4365           0 :                         GasCooler(GCNum).GasCoolerRejectHeatToZone = true;
    4366           0 :                         state.dataRefrigCase->RefrigPresentInZone(GasCooler(GCNum).InletAirZoneNum) = true;
    4367             :                     } else { // not in a conditioned zone, so see if it's outside
    4368           0 :                         GasCooler(GCNum).InletAirNodeNum =
    4369           0 :                             NodeInputManager::GetOnlySingleNode(state,
    4370           0 :                                                                 Alphas(4),
    4371             :                                                                 ErrorsFound,
    4372             :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationGasCoolerAirCooled,
    4373           0 :                                                                 Alphas(1),
    4374             :                                                                 DataLoopNode::NodeFluidType::Air,
    4375             :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    4376             :                                                                 NodeInputManager::CompFluidStream::Primary,
    4377             :                                                                 DataLoopNode::ObjectIsParent);
    4378           0 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, GasCooler(GCNum).InletAirNodeNum)) {
    4379             :                             // not outside and not a zone
    4380           0 :                             ShowSevereError(state,
    4381           0 :                                             format("{}{}=\"{}\", {} not found: {}",
    4382             :                                                    RoutineName,
    4383             :                                                    CurrentModuleObject,
    4384           0 :                                                    GasCooler(GCNum).Name,
    4385             :                                                    cAlphaFieldNames(4),
    4386             :                                                    Alphas(4)));
    4387           0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    4388           0 :                             ErrorsFound = true;
    4389             :                         } // checkoutairnodenumber
    4390             :                     }     // InletAirZoneNum \=0
    4391             :                 }         // Gas cooler air inlet node connection
    4392             : 
    4393           1 :                 GasCooler(GCNum).EndUseSubcategory = "";
    4394           1 :                 if (!lAlphaBlanks(5)) GasCooler(GCNum).EndUseSubcategory = Alphas(5);
    4395             : 
    4396           1 :                 GasCooler(GCNum).RefOpCharge = 0.0;
    4397           1 :                 GasCooler(GCNum).RefReceiverInventory = 0.0;
    4398           1 :                 GasCooler(GCNum).RefPipingInventory = 0.0;
    4399           1 :                 if (!lNumericBlanks(7)) GasCooler(GCNum).RefOpCharge = Numbers(7);
    4400           1 :                 if (!lNumericBlanks(8)) GasCooler(GCNum).RefReceiverInventory = Numbers(8);
    4401           1 :                 if (!lNumericBlanks(9)) GasCooler(GCNum).RefPipingInventory = Numbers(9);
    4402             : 
    4403             :             } // Read input for REFRIGERATION:GasCooler:AirCooled
    4404             :         }     // NumSimulationGasCooler > 0
    4405             : 
    4406             :         //**********  END GAS COOLER INPUT  **********
    4407             : 
    4408             :         //************ START SECONDARY LOOP INPUT (before system input) **************
    4409          15 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    4410           1 :             CurrentModuleObject = "Refrigeration:SecondarySystem";
    4411           3 :             for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    4412           2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4413             :                                                                          CurrentModuleObject,
    4414             :                                                                          SecondaryNum,
    4415             :                                                                          Alphas,
    4416             :                                                                          NumAlphas,
    4417             :                                                                          Numbers,
    4418             :                                                                          NumNumbers,
    4419             :                                                                          IOStatus,
    4420             :                                                                          lNumericBlanks,
    4421             :                                                                          lAlphaBlanks,
    4422             :                                                                          cAlphaFieldNames,
    4423             :                                                                          cNumericFieldNames);
    4424           2 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4425             : 
    4426           2 :                 Secondary(SecondaryNum).Name = Alphas(1);
    4427             : 
    4428             :                 //   Find the loads on the secondary loop: can be input in form of case or walkin or CaseAndWalkInList names
    4429           2 :                 Real64 NominalTotalCaseCap = 0.0;
    4430           2 :                 NumCases = 0;
    4431           2 :                 Real64 NominalTotalCoilCap = 0.0;
    4432           2 :                 int NumCoils = 0;
    4433           2 :                 NumWalkIns = 0;
    4434           2 :                 Real64 NominalTotalWalkInCap = 0.0;
    4435           2 :                 Secondary(SecondaryNum).RefInventory = 0.0;
    4436             : 
    4437             :                 //   Read display case and walkin assignments for this secondary
    4438           2 :                 AlphaNum = 2;
    4439           2 :                 if (lAlphaBlanks(AlphaNum)) {
    4440             :                     // No cases or walkins specified, ie, secondary has no load
    4441           0 :                     ShowSevereError(state,
    4442           0 :                                     format("{}{}=\"{}\", has no loads, must have at least one of: {}",
    4443             :                                            RoutineName,
    4444             :                                            CurrentModuleObject,
    4445           0 :                                            Secondary(SecondaryNum).Name,
    4446             :                                            cAlphaFieldNames(AlphaNum)));
    4447           0 :                     ErrorsFound = true;
    4448             :                 } else { // (.NOT. lAlphaBlanks(AlphaNum))
    4449             : 
    4450             :                     // Entry for Alphas(AlphaNum) can be either a Case, WalkIn Coil, or CaseAndWalkInList name
    4451           2 :                     int CaseAndWalkInListNum = 0;
    4452           2 :                     int CaseNum = 0;
    4453           2 :                     int WalkInNum = 0;
    4454           2 :                     int CoilNum = 0;
    4455           2 :                     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    4456           2 :                         CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    4457           2 :                     if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    4458           2 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    4459           2 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    4460           2 :                     int NumNameMatches = 0;
    4461           2 :                     if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    4462           2 :                     if (CaseNum != 0) ++NumNameMatches;
    4463           2 :                     if (WalkInNum != 0) ++NumNameMatches;
    4464           2 :                     if (CoilNum != 0) ++NumNameMatches;
    4465             : 
    4466           2 :                     if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    4467           0 :                         ErrorsFound = true;
    4468           0 :                         if (NumNameMatches == 0) {
    4469           0 :                             ShowSevereError(state,
    4470           0 :                                             format("{}{}=\"{}\", has an invalid {}: {}",
    4471             :                                                    RoutineName,
    4472             :                                                    CurrentModuleObject,
    4473           0 :                                                    Secondary(SecondaryNum).Name,
    4474             :                                                    cAlphaFieldNames(AlphaNum),
    4475             :                                                    Alphas(AlphaNum)));
    4476           0 :                         } else if (NumNameMatches > 1) {
    4477           0 :                             ShowSevereError(state,
    4478           0 :                                             format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    4479             :                                                    RoutineName,
    4480             :                                                    CurrentModuleObject,
    4481           0 :                                                    Secondary(SecondaryNum).Name,
    4482             :                                                    cAlphaFieldNames(AlphaNum),
    4483             :                                                    Alphas(AlphaNum)));
    4484             :                         }                                   // num matches = 0 or > 1
    4485           2 :                     } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    4486           2 :                         NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    4487           2 :                         NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    4488           2 :                         NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    4489           2 :                         Secondary(SecondaryNum).NumCases = NumCases;
    4490           2 :                         Secondary(SecondaryNum).NumCoils = NumCoils;
    4491           2 :                         Secondary(SecondaryNum).NumWalkIns = NumWalkIns;
    4492           2 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4493           2 :                         Secondary(SecondaryNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    4494           2 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4495           2 :                         Secondary(SecondaryNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    4496           2 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4497           2 :                         Secondary(SecondaryNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    4498           0 :                     } else if (CaseNum != 0) { // Name points to a case
    4499           0 :                         NumCases = 1;
    4500           0 :                         Secondary(SecondaryNum).NumCases = 1;
    4501           0 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4502           0 :                         Secondary(SecondaryNum).CaseNum(NumCases) = CaseNum;
    4503           0 :                     } else if (CoilNum != 0) { // Name points to a coil
    4504           0 :                         NumCoils = 1;
    4505           0 :                         Secondary(SecondaryNum).NumCoils = 1;
    4506           0 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4507           0 :                         Secondary(SecondaryNum).CoilNum(NumCoils) = CoilNum;
    4508           0 :                     } else if (WalkInNum != 0) { // Name points to a walkin
    4509           0 :                         NumWalkIns = 1;
    4510           0 :                         Secondary(SecondaryNum).NumWalkIns = 1;
    4511           0 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4512           0 :                         Secondary(SecondaryNum).WalkInNum(NumWalkIns) = WalkInNum;
    4513             :                     } // NumNameMatches /= 1
    4514             :                 }     // blank input for loads on secondary
    4515             : 
    4516           2 :                 if (NumCases > 0) {
    4517             :                     // Find lowest design T loop fluid out of secondary chiller
    4518             :                     // Sum rated capacity of all cases on Secondary
    4519           9 :                     for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    4520             :                         // mark all cases on Secondary as used by this Secondary - checking for unused or non-unique cases
    4521           7 :                         int CaseNum = Secondary(SecondaryNum).CaseNum(caseIndex);
    4522           7 :                         ++RefrigCase(CaseNum).NumSysAttach;
    4523           7 :                         NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedRTF;
    4524           7 :                         Secondary(SecondaryNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    4525           7 :                         if (caseIndex == 1) { // look for lowest case design evap T for Secondary
    4526           2 :                             Secondary(SecondaryNum).TMinNeeded = RefrigCase(CaseNum).EvapTempDesign;
    4527             :                         } else {
    4528           5 :                             Secondary(SecondaryNum).TMinNeeded = min(RefrigCase(CaseNum).EvapTempDesign, Secondary(SecondaryNum).TMinNeeded);
    4529             :                         }
    4530             :                     } // CaseIndex=1,NumCases
    4531             :                 }     // Numcases > 0
    4532             : 
    4533           2 :                 if (NumCoils > 0) {
    4534             :                     // Find lowest design T loop fluid out of secondary chiller
    4535             :                     // Sum rated capacity of all Coils on Secondary
    4536           0 :                     for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    4537             :                         // mark all Coils on Secondary as used by this Secondary - checking for unused or non-unique Coils
    4538           0 :                         int CoilNum = Secondary(SecondaryNum).CoilNum(CoilIndex);
    4539           0 :                         ++WarehouseCoil(CoilNum).NumSysAttach;
    4540           0 :                         NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    4541           0 :                         Secondary(SecondaryNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    4542           0 :                         if ((CoilIndex == 1) && (NumCases == 0)) { // look for lowest Coil design evap T for Secondary
    4543           0 :                             Secondary(SecondaryNum).TMinNeeded = WarehouseCoil(CoilNum).TEvapDesign;
    4544             :                         } else {
    4545           0 :                             Secondary(SecondaryNum).TMinNeeded = min(WarehouseCoil(CoilNum).TEvapDesign, Secondary(SecondaryNum).TMinNeeded);
    4546             :                         }
    4547             :                     } // CoilIndex=1,NumCoils
    4548             :                 }     // NumCoils > 0
    4549             : 
    4550           2 :                 if (NumWalkIns > 0) {
    4551             :                     // Find lowest design T loop fluid out of secondary chiller
    4552             :                     // Sum rated capacity of all WalkIns on Secondary
    4553           2 :                     for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    4554             :                         // mark all WalkIns on Secondary as used by this Secondary - checking for unused or non-unique WalkIns
    4555           1 :                         int WalkInID = Secondary(SecondaryNum).WalkInNum(WalkInIndex);
    4556           1 :                         ++WalkIn(WalkInID).NumSysAttach;
    4557           1 :                         NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    4558           1 :                         Secondary(SecondaryNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    4559           1 :                         if ((WalkInIndex == 1) && (NumCases == 0) && (NumCoils == 0)) { // look for lowest load design evap T for Secondary
    4560           0 :                             Secondary(SecondaryNum).TMinNeeded = WalkIn(WalkInID).TEvapDesign;
    4561             :                         } else {
    4562           1 :                             Secondary(SecondaryNum).TMinNeeded = min(Secondary(SecondaryNum).TMinNeeded, WalkIn(WalkInID).TEvapDesign);
    4563             :                         }
    4564             :                     } // WalkInIndex=1,NumWalkIns
    4565             :                 }     // Numwalkins > 0
    4566             : 
    4567             :                 // Get circulating fluid type
    4568           2 :                 AlphaNum = 3;
    4569           2 :                 if (!lAlphaBlanks(AlphaNum)) {
    4570           2 :                     if (Util::SameString(Alphas(AlphaNum), "FluidAlwaysLiquid")) {
    4571           1 :                         Secondary(SecondaryNum).FluidType = SecFluidType::AlwaysLiquid;
    4572           1 :                     } else if (Util::SameString(Alphas(AlphaNum), "FluidPhaseChange")) {
    4573           1 :                         Secondary(SecondaryNum).FluidType = SecFluidType::PhaseChange;
    4574             :                     } else {
    4575           0 :                         ShowSevereError(state,
    4576           0 :                                         format("{}{}=\"{}\"  {} not recognized = {}",
    4577             :                                                RoutineName,
    4578             :                                                CurrentModuleObject,
    4579           0 :                                                Secondary(SecondaryNum).Name,
    4580             :                                                cAlphaFieldNames(AlphaNum),
    4581             :                                                Alphas(AlphaNum)));
    4582           0 :                         ShowContinueError(state, "Input value choices should be FluidAlwaysLiquid or FluidPhaseChange.");
    4583           0 :                         ErrorsFound = true;
    4584             :                     } // Set FluidType
    4585             :                 } else {
    4586           0 :                     ShowSevereError(state,
    4587           0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4588             :                                            RoutineName,
    4589             :                                            CurrentModuleObject,
    4590           0 :                                            Secondary(SecondaryNum).Name,
    4591             :                                            cAlphaFieldNames(AlphaNum)));
    4592           0 :                     ErrorsFound = true;
    4593             :                 } // blank on cir fluid type
    4594             : 
    4595           2 :                 AlphaNum = 4;
    4596           2 :                 Secondary(SecondaryNum).FluidName = Alphas(AlphaNum);
    4597             :                 // Error messages for refrigerants and glycols already found in fluidproperties
    4598             : 
    4599             :                 // Note remainder of inputs for secondary don't follow IDD input order because of different interpretations
    4600             :                 //   and intermediate calculations used to assign default values for brine type vs. liquid overfeed/phase change loops
    4601             : 
    4602           2 :                 if (!lNumericBlanks(3)) {
    4603           2 :                     Secondary(SecondaryNum).TEvapDesign = Numbers(3);
    4604             :                 } else {
    4605           0 :                     ShowSevereError(state,
    4606           0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4607             :                                            RoutineName,
    4608             :                                            CurrentModuleObject,
    4609           0 :                                            Secondary(SecondaryNum).Name,
    4610             :                                            cNumericFieldNames(3)));
    4611           0 :                     ErrorsFound = true;
    4612             :                 } // blank on N3
    4613             : 
    4614           2 :                 if (!lNumericBlanks(4)) {
    4615           2 :                     Secondary(SecondaryNum).TApproachDifRated = Numbers(4);
    4616             :                 } else {
    4617           0 :                     ShowSevereError(state,
    4618           0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4619             :                                            RoutineName,
    4620             :                                            CurrentModuleObject,
    4621           0 :                                            Secondary(SecondaryNum).Name,
    4622             :                                            cNumericFieldNames(4)));
    4623           0 :                     ErrorsFound = true;
    4624             :                 } // blank on N4
    4625             : 
    4626             :                 //^^^^^^^Now look at input and once-only calculations required only for liquid/brine secondary loops^^^^^^^^^^^^^^^^^^^^^^
    4627             :                 //   Ensure that required input data is not missing prior to performing the following once-only calculations
    4628           2 :                 if (ErrorsFound) {
    4629           0 :                     ShowFatalError(state,
    4630           0 :                                    format("{}{}=\"{}\", Program terminated due to previous condition(s).",
    4631             :                                           RoutineName,
    4632             :                                           CurrentModuleObject,
    4633           0 :                                           Secondary(SecondaryNum).Name));
    4634             :                 } // ErrorsFound
    4635             : 
    4636           2 :                 Real64 CpBrineRated = 0.0;
    4637           2 :                 Real64 PumpTotRatedFlowVol(0.0);   // Rated flow from input pump data, m3/s
    4638           2 :                 Real64 SecondaryFlowVolRated(0.0); // Rated flow of secondary fluid, used to calculate capacity (m3/s)
    4639           2 :                 Real64 TBrineOutRated(0.0);        // Rated temperature of circ fluid LEAVING heat exchanger,C
    4640           2 :                 Real64 TBrineInRated(0.0);         // Rated temperature of circ fluid going INTO heat exchanger, C
    4641             : 
    4642           2 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4643           1 :                     if (!lNumericBlanks(5)) {
    4644           1 :                         Secondary(SecondaryNum).TRangeDifRated = Numbers(5);
    4645             :                     } else {
    4646           0 :                         ShowSevereError(state,
    4647           0 :                                         format("{}{}=\"{}\", {} must be specified.",
    4648             :                                                RoutineName,
    4649             :                                                CurrentModuleObject,
    4650           0 :                                                Secondary(SecondaryNum).Name,
    4651             :                                                cNumericFieldNames(5)));
    4652           0 :                         ShowContinueError(state, format("...when {}=\"FluidAlwaysLiquid\".", cAlphaFieldNames(3)));
    4653           0 :                         ErrorsFound = true;
    4654             :                     } // blank on N5
    4655             : 
    4656             :                     // Get fluid properties at rated conditions, will be used to calculate ht exchgr effectiveness
    4657           1 :                     TBrineOutRated = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4658           1 :                     TBrineInRated = TBrineOutRated + Secondary(SecondaryNum).TRangeDifRated;
    4659           1 :                     Real64 TBrineAverage = (TBrineOutRated + TBrineInRated) / 2.0;
    4660           1 :                     Secondary(SecondaryNum).TBrineAverage = TBrineAverage;
    4661           1 :                     DensityBrineRated = FluidProperties::GetDensityGlycol(
    4662           1 :                         state, Secondary(SecondaryNum).FluidName, TBrineAverage, Secondary(SecondaryNum).FluidID, TrackMessage);
    4663           1 :                     Secondary(SecondaryNum).DensityBrineRated = DensityBrineRated;
    4664           1 :                     CpBrineRated = FluidProperties::GetSpecificHeatGlycol(
    4665           1 :                         state, Secondary(SecondaryNum).FluidName, TBrineAverage, Secondary(SecondaryNum).FluidID, TrackMessage);
    4666           1 :                     Secondary(SecondaryNum).CpBrineRated = CpBrineRated;
    4667             : 
    4668             :                     // Users can input either design brine flow (m3/s), or capacity in W, or both.  Now have
    4669             :                     //  temperatures needed to calculate either the loop cooling capacity or fluid flow rate, if one was not input
    4670             :                     //  Don't need to save as a flow vol as a permanent var because calc whichever is missing here
    4671           1 :                     Real64 FlowMassRated(0.0); // Design mass flow rate of circ fluid in secondary loop(kg/s)
    4672           1 :                     if ((!lNumericBlanks(1)) && (!lNumericBlanks(2))) {
    4673             :                         // Both values input, check for approximate agreement
    4674           1 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4675           1 :                         SecondaryFlowVolRated = Numbers(2);
    4676           1 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4677           1 :                         Real64 NominalSecondaryCapacity = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4678           1 :                         Real64 TestDelta = (NominalSecondaryCapacity - Secondary(SecondaryNum).CoolingLoadRated) / NominalSecondaryCapacity;
    4679           1 :                         if (std::abs(TestDelta) > 0.2) {
    4680           0 :                             ShowWarningError(state,
    4681           0 :                                              format("{}=\"{} You may wish to check the system definition. Based upon the design flow rate and "
    4682             :                                                     "range temperature difference,  The nominal secondary loop heat exchanger capacity is, "
    4683             :                                                     "{:.0R} but the specified design capacity is,  {:.0R}",
    4684             :                                                     CurrentModuleObject,
    4685           0 :                                                     Secondary(SecondaryNum).Name,
    4686             :                                                     NominalSecondaryCapacity,
    4687           0 :                                                     Secondary(SecondaryNum).CoolingLoadRated));
    4688             :                         }
    4689           0 :                     } else if (!lNumericBlanks(1)) {
    4690           0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4691             :                         // Calc flow vol rated
    4692           0 :                         FlowMassRated = Secondary(SecondaryNum).CoolingLoadRated / (CpBrineRated * Secondary(SecondaryNum).TRangeDifRated);
    4693           0 :                         SecondaryFlowVolRated = FlowMassRated / DensityBrineRated;
    4694           0 :                     } else if (!lNumericBlanks(2)) {
    4695           0 :                         SecondaryFlowVolRated = Numbers(2);
    4696             :                         // Calc rated load
    4697           0 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4698           0 :                         Secondary(SecondaryNum).CoolingLoadRated = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4699             :                     } else {
    4700           0 :                         ShowSevereError(state,
    4701           0 :                                         format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4702             :                                                RoutineName,
    4703             :                                                CurrentModuleObject,
    4704           0 :                                                Secondary(SecondaryNum).Name,
    4705             :                                                cNumericFieldNames(1),
    4706             :                                                cNumericFieldNames(2)));
    4707           0 :                         ErrorsFound = true;
    4708             :                     } // Capacity Input via either or both options
    4709             : 
    4710           1 :                     if (!ErrorsFound) {
    4711             :                         // Calculate heat exchanger effectiveness based on rated flow and temperature differences
    4712           2 :                         Secondary(SecondaryNum).HeatExchangeEta =
    4713           1 :                             Secondary(SecondaryNum).CoolingLoadRated /
    4714           1 :                             (FlowMassRated * CpBrineRated * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign));
    4715           1 :                         Secondary(SecondaryNum).TBrineInRated = TBrineInRated;
    4716           1 :                         if (Secondary(SecondaryNum).HeatExchangeEta > 0.99) {
    4717           0 :                             ShowWarningError(
    4718             :                                 state,
    4719           0 :                                 format("{}=\"{} You may wish to check the system definition.  The heat exchanger effectiveness is, {:.2R}",
    4720             :                                        CurrentModuleObject,
    4721           0 :                                        Secondary(SecondaryNum).Name,
    4722           0 :                                        Secondary(SecondaryNum).HeatExchangeEta));
    4723           0 :                             Secondary(SecondaryNum).HeatExchangeEta = 0.99;
    4724             :                         }
    4725             :                     } else {
    4726           0 :                         ShowContinueError(state, "...remainder of this object input skipped due to previous errors");
    4727           0 :                         continue;
    4728             :                     }
    4729             : 
    4730           1 :                     PumpTotRatedFlowVol = SecondaryFlowVolRated;
    4731           1 :                     if (!lNumericBlanks(7)) PumpTotRatedFlowVol = Numbers(7);
    4732             : 
    4733             :                 } else { // FluidType = FluidTypePhaseChange     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4734           1 :                     if (!lNumericBlanks(1)) {
    4735           0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4736             :                     } else {
    4737           1 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalTotalCaseCap + NominalTotalWalkInCap;
    4738             :                         // first estimate, will later be adjusted to include pump power
    4739             :                     } // input capacity
    4740             : 
    4741           1 :                     Secondary(SecondaryNum).TCondense = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4742           1 :                     Secondary(SecondaryNum).CircRate = DefaultCircRate;
    4743           1 :                     if (!lNumericBlanks(10)) Secondary(SecondaryNum).CircRate = Numbers(10);
    4744             : 
    4745           1 :                     DensityPhaseChange = FluidProperties::GetSatDensityRefrig(state,
    4746           1 :                                                                               Secondary(SecondaryNum).FluidName,
    4747           1 :                                                                               Secondary(SecondaryNum).TCondense,
    4748             :                                                                               0.0,
    4749           1 :                                                                               Secondary(SecondaryNum).FluidID,
    4750             :                                                                               TrackMessageAlt);
    4751           1 :                     DeltaHPhaseChange = FluidProperties::GetSatEnthalpyRefrig(state,
    4752           1 :                                                                               Secondary(SecondaryNum).FluidName,
    4753           1 :                                                                               Secondary(SecondaryNum).TCondense,
    4754             :                                                                               1.0,
    4755           1 :                                                                               Secondary(SecondaryNum).FluidID,
    4756             :                                                                               TrackMessageAlt) -
    4757           1 :                                         FluidProperties::GetSatEnthalpyRefrig(state,
    4758           1 :                                                                               Secondary(SecondaryNum).FluidName,
    4759           1 :                                                                               Secondary(SecondaryNum).TCondense,
    4760             :                                                                               0.0,
    4761           1 :                                                                               Secondary(SecondaryNum).FluidID,
    4762             :                                                                               TrackMessageAlt);
    4763             : 
    4764             :                     // TotRatedFlowVol= capacity*circrate/deltahphasechange/density
    4765             :                     Real64 CalcTotFlowVol =
    4766           1 :                         Secondary(SecondaryNum).CoolingLoadRated * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4767           1 :                     PumpTotRatedFlowVol = CalcTotFlowVol;
    4768           1 :                     if (!lNumericBlanks(7)) {
    4769           0 :                         PumpTotRatedFlowVol = Numbers(7);
    4770           0 :                         Real64 CalcCircRate = DensityPhaseChange * DeltaHPhaseChange * PumpTotRatedFlowVol / Secondary(SecondaryNum).CoolingLoadRated;
    4771           0 :                         Real64 DiffCircRates = (CalcCircRate - Secondary(SecondaryNum).CircRate) / Secondary(SecondaryNum).CircRate;
    4772           0 :                         if (std::abs(DiffCircRates) > 0.3) {
    4773           0 :                             ShowWarningError(state,
    4774           0 :                                              format("{}=\"{} {} Produces a circulating rate of {:.2R} ;  A circulating rate of {:.2R} would need "
    4775             :                                                     "a {} of {:.2R} m3/s",
    4776             :                                                     CurrentModuleObject,
    4777           0 :                                                     Secondary(SecondaryNum).Name,
    4778             :                                                     cNumericFieldNames(7),
    4779             :                                                     CalcCircRate,
    4780           0 :                                                     Secondary(SecondaryNum).CircRate,
    4781             :                                                     cNumericFieldNames(7),
    4782             :                                                     CalcTotFlowVol));
    4783             :                         } // warning check on pump flow rate vs circ rate input
    4784             :                     }     // blank pump flow rate
    4785           1 :                     SecondaryFlowVolRated = PumpTotRatedFlowVol;
    4786             : 
    4787             :                 } // fluid type AlwaysLiquid or PhaseChange ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4788             : 
    4789             :                 // Read number of pumps (or pump stages) in secondary loop
    4790           2 :                 int NumPumps = 1; // default value
    4791           2 :                 if ((!lNumericBlanks(6)) && (Numbers(6) >= 1)) NumPumps = Numbers(6);
    4792           2 :                 Secondary(SecondaryNum).NumPumps = NumPumps;
    4793             :                 // Get pump power (users can input either power in W or head in Pa or both)
    4794             :                 // Assume pump impeller efficiency is 0.78 (consistent with E+ Pump auto-sizing assumption)
    4795             :                 // Assume pump motor efficiency is 0.85 (Goulds Pumps motor data sheet)
    4796             :                 // It is important that tot rated head must be for specific fluid
    4797           2 :                 Real64 PumpTotRatedHead(0.0); // Total pump rated head on secondary loop (Pa)
    4798             : 
    4799           2 :                 if ((!lNumericBlanks(8)) && (!lNumericBlanks(9))) {
    4800           0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4801           0 :                     PumpTotRatedHead = Numbers(9);
    4802           0 :                     Real64 ErrSecondPumpPower = (Secondary(SecondaryNum).PumpTotRatedPower -
    4803           0 :                                                  PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency)) /
    4804           0 :                                                 Secondary(SecondaryNum).PumpTotRatedPower;
    4805           0 :                     if (std::abs(ErrSecondPumpPower) > 0.35)
    4806           0 :                         ShowWarningError(
    4807             :                             state,
    4808           0 :                             format("{}=\"{} Input value for {} not consistent with input value for {}. {} will be used",
    4809             :                                    CurrentModuleObject,
    4810           0 :                                    Secondary(SecondaryNum).Name,
    4811             :                                    cNumericFieldNames(9),
    4812             :                                    cNumericFieldNames(8),
    4813             :                                    cNumericFieldNames(8))); // generous diff allowed because comparing to my assumed impeller and motor effs
    4814           2 :                 } else if (!lNumericBlanks(8)) {
    4815           0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4816           2 :                 } else if (!lNumericBlanks(9)) {
    4817           2 :                     PumpTotRatedHead = Numbers(9);
    4818           2 :                     Secondary(SecondaryNum).PumpTotRatedPower =
    4819           2 :                         PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4820             :                 } else {
    4821           0 :                     ShowSevereError(state,
    4822           0 :                                     format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4823             :                                            RoutineName,
    4824             :                                            CurrentModuleObject,
    4825           0 :                                            Secondary(SecondaryNum).Name,
    4826             :                                            cNumericFieldNames(8),
    4827             :                                            cNumericFieldNames(9)));
    4828           0 :                     ErrorsFound = true;
    4829             :                 } // Either or pump power Input variations (head or power)
    4830             : 
    4831             :                 // Get pump drive type
    4832           2 :                 AlphaNum = 5;
    4833           2 :                 Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Constant; // default
    4834           2 :                 if (!lAlphaBlanks(AlphaNum)) {
    4835           1 :                     if (Util::SameString(Alphas(AlphaNum), "Constant")) {
    4836           0 :                         Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Constant;
    4837           1 :                     } else if (Util::SameString(Alphas(AlphaNum), "Variable")) {
    4838           1 :                         Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Variable;
    4839             :                     } else {
    4840           0 :                         ShowSevereError(state,
    4841           0 :                                         format("{}{}=\"{}\"  {} not recognized = {}",
    4842             :                                                RoutineName,
    4843             :                                                CurrentModuleObject,
    4844           0 :                                                Secondary(SecondaryNum).Name,
    4845             :                                                cAlphaFieldNames(AlphaNum),
    4846             :                                                Alphas(AlphaNum)));
    4847           0 :                         ShowContinueError(state, "Check input value choices.");
    4848           0 :                         ErrorsFound = true;
    4849             :                     } // Set PumpControlType
    4850             :                 }     // blank on pump drive control type
    4851             : 
    4852             :                 //  Print warning if Pump Control = Constant and Variable Speed Curve is specified.
    4853           2 :                 if ((Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) && (!lAlphaBlanks(AlphaNum + 1))) {
    4854           0 :                     ShowWarningError(state,
    4855           0 :                                      format(R"({}{}="{}", A {} is specified even though {} is "CONSTANT".)",
    4856             :                                             RoutineName,
    4857             :                                             CurrentModuleObject,
    4858           0 :                                             Secondary(SecondaryNum).Name,
    4859             :                                             cAlphaFieldNames(AlphaNum + 1),
    4860             :                                             cAlphaFieldNames(AlphaNum)));
    4861           0 :                     ShowContinueError(state,
    4862           0 :                                       format("The secondary loop pump(s) will be modeled as constant speed and the {} will be ignored.",
    4863             :                                              cAlphaFieldNames(AlphaNum + 1)));
    4864             :                 }
    4865             : 
    4866           2 :                 if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4867             :                     // Set incremental flow and power amounts for pump dispatch
    4868           1 :                     Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4869           1 :                     Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4870             :                 } else { // Variable speed drive need to read in power curve
    4871           1 :                     AlphaNum = 6;
    4872           1 :                     Secondary(SecondaryNum).VarSpeedCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    4873           1 :                     if (Secondary(SecondaryNum).VarSpeedCurvePtr == 0) {
    4874           0 :                         ShowSevereError(state,
    4875           0 :                                         format("{}{}=\"{}\", invalid  {} not found:{}",
    4876             :                                                RoutineName,
    4877             :                                                CurrentModuleObject,
    4878           0 :                                                Secondary(SecondaryNum).Name,
    4879             :                                                cAlphaFieldNames(AlphaNum),
    4880             :                                                Alphas(AlphaNum)));
    4881           0 :                         ErrorsFound = true;
    4882             :                     }
    4883           2 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    4884           1 :                                                          Secondary(SecondaryNum).VarSpeedCurvePtr, // Curve index
    4885             :                                                          {1},                                      // Valid dimensions
    4886             :                                                          RoutineName,                              // Routine name
    4887             :                                                          CurrentModuleObject,                      // Object Type
    4888           1 :                                                          Secondary(SecondaryNum).Name,             // Object Name
    4889           1 :                                                          cAlphaFieldNames(AlphaNum));              // Field Name
    4890             :                 } // input power conditions/levels for constant or variable speed pump drives
    4891             : 
    4892             :                 // Default non-hermetic motor eff at 85% and all shaft power goes to heat in fluid
    4893             :                 // In a semi-hermetic motor, assume all power to motor goes to heat in fluid
    4894           2 :                 Secondary(SecondaryNum).PumpPowerToHeat = PumpMotorEfficiency;
    4895           2 :                 NumNum = 11;
    4896           2 :                 if (!lNumericBlanks(NumNum)) {
    4897           2 :                     if ((0.5 <= Numbers(NumNum)) && (1.0 >= Numbers(NumNum))) {
    4898           2 :                         Secondary(SecondaryNum).PumpPowerToHeat = Numbers(NumNum);
    4899             :                     } else {
    4900           0 :                         ShowWarningError(state,
    4901           0 :                                          format("{}{}=\"{}\" {} must be between 0.5 and 1.0. Default value of : {:.3R} will be used",
    4902             :                                                 RoutineName,
    4903             :                                                 CurrentModuleObject,
    4904           0 :                                                 Secondary(SecondaryNum).Name,
    4905             :                                                 cNumericFieldNames(NumNum),
    4906             :                                                 PumpMotorEfficiency));
    4907             :                     } // range of pump moter heat to fluid
    4908             :                 }     // blank input for pumppowertoheat
    4909             : 
    4910             :                 // Distribution piping heat gain - optional
    4911             :                 //  Input UA and Zone containing the bulk of the secondary coolant distribution piping
    4912             :                 //  This Zone ID will be used to determine the temperature used for distribution piping heat gain.
    4913             :                 //  Zone Id is only required if Sum UA Distribution Piping >0.0
    4914             :                 //  Get the Zone node number from the zone name entered by the user
    4915           2 :                 Secondary(SecondaryNum).SumUADistPiping = 0.0;
    4916           2 :                 AlphaNum = 7;
    4917           2 :                 NumNum = 12;
    4918           2 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4919           2 :                     Secondary(SecondaryNum).SumUADistPiping = Numbers(NumNum);
    4920           2 :                     Secondary(SecondaryNum).DistPipeZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4921           4 :                     Secondary(SecondaryNum).DistPipeZoneNodeNum =
    4922           2 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).DistPipeZoneNum);
    4923             : 
    4924           2 :                     if (Secondary(SecondaryNum).DistPipeZoneNum == 0) {
    4925           0 :                         ShowSevereError(state,
    4926           0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4927             :                                                RoutineName,
    4928             :                                                CurrentModuleObject,
    4929           0 :                                                Secondary(SecondaryNum).Name,
    4930             :                                                cAlphaFieldNames(AlphaNum),
    4931             :                                                Alphas(AlphaNum)));
    4932           0 :                         ErrorsFound = true;
    4933             :                     } else {
    4934           2 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).DistPipeZoneNum) = true;
    4935             :                     }
    4936             : 
    4937           2 :                     if (Secondary(SecondaryNum).DistPipeZoneNodeNum == 0) {
    4938           0 :                         ShowSevereError(
    4939             :                             state,
    4940           0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Distribution "
    4941             :                                    "piping heat gain cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections "
    4942             :                                    "object.) is defined to determine the environmental temperature surrounding the piping.",
    4943             :                                    RoutineName,
    4944             :                                    CurrentModuleObject,
    4945           0 :                                    Secondary(SecondaryNum).Name,
    4946             :                                    cAlphaFieldNames(AlphaNum),
    4947             :                                    Alphas(AlphaNum),
    4948             :                                    cNumericFieldNames(NumNum)));
    4949           0 :                         ErrorsFound = true;
    4950             :                     }
    4951           0 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    4952           0 :                     ShowWarningError(
    4953             :                         state,
    4954           0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Distribution piping heat gain will not be "
    4955             :                                "calculated unless a Zone is defined to deterimine the environmental temperature surrounding the piping.",
    4956             :                                RoutineName,
    4957             :                                CurrentModuleObject,
    4958           0 :                                Secondary(SecondaryNum).Name,
    4959             :                                cAlphaFieldNames(AlphaNum),
    4960             :                                cNumericFieldNames(NumNum)));
    4961           0 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4962           0 :                     ShowWarningError(
    4963             :                         state,
    4964           0 :                         format("{}{}=\"{}\", {} will not be used and distribution piping heat gain will not be calculated because {} was blank.",
    4965             :                                RoutineName,
    4966             :                                CurrentModuleObject,
    4967           0 :                                Secondary(SecondaryNum).Name,
    4968             :                                cAlphaFieldNames(AlphaNum),
    4969             :                                cNumericFieldNames(NumNum)));
    4970             :                 } // distribution piping
    4971             : 
    4972             :                 // Separator/receiver heat gain - optional
    4973             :                 //  Input UA and Zone containing the Separator/receiver
    4974             :                 //  This Zone ID will be used to determine the temperature used for Separator/receiver heat gain.
    4975             :                 //  Zone Id is only required if Sum UA Separator/receiver >0.0
    4976             :                 //  Get the Zone node number from the zone name entered by the user
    4977           2 :                 Secondary(SecondaryNum).SumUAReceiver = 0.0;
    4978           2 :                 AlphaNum = 8;
    4979           2 :                 NumNum = 13;
    4980           2 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4981           1 :                     Secondary(SecondaryNum).SumUAReceiver = Numbers(NumNum);
    4982           1 :                     Secondary(SecondaryNum).ReceiverZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4983           2 :                     Secondary(SecondaryNum).ReceiverZoneNodeNum =
    4984           1 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).ReceiverZoneNum);
    4985             : 
    4986           1 :                     if (Secondary(SecondaryNum).ReceiverZoneNum == 0) {
    4987           0 :                         ShowSevereError(state,
    4988           0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4989             :                                                RoutineName,
    4990             :                                                CurrentModuleObject,
    4991           0 :                                                Secondary(SecondaryNum).Name,
    4992             :                                                cAlphaFieldNames(AlphaNum),
    4993             :                                                Alphas(AlphaNum)));
    4994           0 :                         ErrorsFound = true;
    4995             :                     } else {
    4996           1 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).ReceiverZoneNum) = true;
    4997             :                     }
    4998           1 :                     if (Secondary(SecondaryNum).ReceiverZoneNodeNum == 0) {
    4999           0 :                         ShowSevereError(
    5000             :                             state,
    5001           0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Receiver heat gain "
    5002             :                                    "cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.) is defined "
    5003             :                                    "to determine the environmental temperature surrounding the Receiver.",
    5004             :                                    RoutineName,
    5005             :                                    CurrentModuleObject,
    5006           0 :                                    Secondary(SecondaryNum).Name,
    5007             :                                    cAlphaFieldNames(AlphaNum),
    5008             :                                    Alphas(AlphaNum),
    5009             :                                    cNumericFieldNames(NumNum)));
    5010           0 :                         ErrorsFound = true;
    5011             :                     }
    5012           1 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    5013           0 :                     ShowWarningError(
    5014             :                         state,
    5015           0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Receiver heat gain will not be calculated unless "
    5016             :                                "a Zone is defined to deterimine the environmental temperature surrounding the Receiver.",
    5017             :                                RoutineName,
    5018             :                                CurrentModuleObject,
    5019           0 :                                Secondary(SecondaryNum).Name,
    5020             :                                cAlphaFieldNames(AlphaNum),
    5021             :                                cNumericFieldNames(NumNum)));
    5022           1 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    5023           0 :                     ShowWarningError(state,
    5024           0 :                                      format("{}{}=\"{}\", {} will not be used and Receiver heat gain will not be calculated because {} was blank.",
    5025             :                                             RoutineName,
    5026             :                                             CurrentModuleObject,
    5027           0 :                                             Secondary(SecondaryNum).Name,
    5028             :                                             cAlphaFieldNames(AlphaNum),
    5029             :                                             cNumericFieldNames(NumNum)));
    5030             :                 } // Receiver
    5031             : 
    5032           2 :                 NumNum = 14;
    5033           2 :                 Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    5034           2 :                 if (!lNumericBlanks(NumNum)) Secondary(SecondaryNum).ChillerRefInventory = Numbers(NumNum);
    5035           2 :                 if (Secondary(SecondaryNum).ChillerRefInventory < 0.0) {
    5036           0 :                     Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    5037           0 :                     ShowWarningError(state,
    5038           0 :                                      format("{}{}=\"{}\", The value specified for {} is less than zero. The default value of zero will be used.",
    5039             :                                             RoutineName,
    5040             :                                             CurrentModuleObject,
    5041           0 :                                             Secondary(SecondaryNum).Name,
    5042             :                                             cNumericFieldNames(NumNum)));
    5043             :                 }
    5044             : 
    5045           2 :                 AlphaNum = 9;
    5046           2 :                 if (!lAlphaBlanks(AlphaNum)) Secondary(SecondaryNum).EndUseSubcategory = Alphas(AlphaNum);
    5047             : 
    5048             :                 // Error checks on secondary loop:
    5049             :                 // Note, rated capacities can be far off from operating capacities, but rough checks here
    5050             :                 //       (don't include dist piping or receiver heat gains).
    5051             :                 // Load limit logic here (maxvolflow and maxload used in calcs later)
    5052           2 :                 Secondary(SecondaryNum).MaxVolFlow = min(SecondaryFlowVolRated, PumpTotRatedFlowVol);
    5053           2 :                 Real64 NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    5054             : 
    5055           2 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    5056           1 :                     if (TBrineOutRated > (Secondary(SecondaryNum).TMinNeeded + 0.5)) {
    5057           0 :                         ShowWarningError(state,
    5058           0 :                                          format("{}=\"{} The design brine temperature to the refrigeration loads: {:.1R} ;",
    5059             :                                                 CurrentModuleObject,
    5060           0 :                                                 Secondary(SecondaryNum).Name,
    5061             :                                                 TBrineOutRated));
    5062           0 :                         ShowContinueError(state,
    5063           0 :                                           format(" is greater than the design inlet temperature for at least one of the cases or walkins: {:.1R}",
    5064           0 :                                                  Secondary(SecondaryNum).TMinNeeded));
    5065           0 :                         ShowContinueError(
    5066             :                             state, " Compare your Approach and Evaporating Temperature to the design inlet temperatures needed for the loads.");
    5067             :                         // ErrorsFound = .TRUE.
    5068             :                     } // Tbrine out warning
    5069           1 :                     Real64 CapacityAtMaxVolFlow = Secondary(SecondaryNum).MaxVolFlow * Secondary(SecondaryNum).HeatExchangeEta *
    5070           1 :                                                   (CpBrineRated * DensityBrineRated) * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign);
    5071           1 :                     Secondary(SecondaryNum).MaxLoad = min(Secondary(SecondaryNum).CoolingLoadRated, CapacityAtMaxVolFlow);
    5072             :                     Real64 DeltaCap1 =
    5073           1 :                         std::abs((Secondary(SecondaryNum).CoolingLoadRated - CapacityAtMaxVolFlow) / Secondary(SecondaryNum).CoolingLoadRated);
    5074           1 :                     if (DeltaCap1 > (0.3)) { // diff between chiller rating and capacity at max flow > 30%
    5075           0 :                         ShowWarningError(state,
    5076           0 :                                          format("{}=\"{}\" You may wish to check the system sizing.  The nominal secondary loop heat exchanger "
    5077             :                                                 "capacity is {:.0R} But the capacity based upon the maximum flow rate is {:.0R}",
    5078             :                                                 CurrentModuleObject,
    5079           0 :                                                 Secondary(SecondaryNum).Name,
    5080           0 :                                                 Secondary(SecondaryNum).CoolingLoadRated,
    5081             :                                                 CapacityAtMaxVolFlow));
    5082             :                     }                            // DeltaCap1 > .3
    5083             :                 } else {                         // Fluid type phase change                !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    5084           1 :                     if (lNumericBlanks(1)) {     // Chiller/evaporator capacity was not specified
    5085           1 :                         if (lNumericBlanks(7)) { // Pump power was not input, calc based on flow and head
    5086             :                             // need to refine because capacity calculated, but needs to include pump power (which was prev
    5087             :                             //   estimated based upon capacity which had been estimated as sum of case and walk-in capacities)
    5088           1 :                             PumpTotRatedFlowVol =
    5089           1 :                                 NominalSecondaryRefLoad * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    5090           2 :                             Secondary(SecondaryNum).PumpTotRatedPower =
    5091           1 :                                 PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    5092             :                             // need to recalc nominal load with new pump power value
    5093           1 :                             NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    5094           1 :                             if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    5095             :                                 // Set incremental flow and power amounts for pump dispatch
    5096           0 :                                 Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    5097           0 :                                 Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    5098             :                             } // constant speed pump
    5099             :                         }     // Pump power was not specified
    5100           1 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalSecondaryRefLoad;
    5101             :                     } // Chiller/evap capacity was not specified
    5102           1 :                     Secondary(SecondaryNum).MaxLoad = Secondary(SecondaryNum).CoolingLoadRated;
    5103             :                 } // SecFluidType
    5104             : 
    5105             :                 Real64 DeltaCap2 =
    5106           2 :                     std::abs((Secondary(SecondaryNum).CoolingLoadRated - NominalSecondaryRefLoad) / Secondary(SecondaryNum).CoolingLoadRated);
    5107           2 :                 if (DeltaCap2 > (0.3)) { // diff between chiller rating and sum of nominal loads > 30%
    5108           0 :                     ShowWarningError(
    5109             :                         state,
    5110           0 :                         format("{}=\"{}\" You may wish to check the system sizing. Total nominal refrigerating load is {:.0R} (Including cases, "
    5111             :                                "walk-ins, and pump heat).  The nominal secondary loop heat exchanger capacity is {:.0R}",
    5112             :                                CurrentModuleObject,
    5113           0 :                                Secondary(SecondaryNum).Name,
    5114             :                                NominalSecondaryRefLoad,
    5115           0 :                                Secondary(SecondaryNum).CoolingLoadRated));
    5116             :                 }
    5117             :                 // compare rated xt xchanger brine flow to the total rated pump flow
    5118           2 :                 if (SecondaryFlowVolRated > (1.1 * PumpTotRatedFlowVol)) {
    5119           0 :                     ShowWarningError(state,
    5120           0 :                                      format("{}=\"{}\" You may wish to check the pump sizing. Total nominal brine flow is {:.0R} m3/s, but the "
    5121             :                                             "total nominal pump flow rate is:  {:.0R} m3/s. ",
    5122             :                                             CurrentModuleObject,
    5123           0 :                                             Secondary(SecondaryNum).Name,
    5124             :                                             SecondaryFlowVolRated,
    5125             :                                             PumpTotRatedFlowVol));
    5126             :                 }
    5127             : 
    5128             :             } // Secondary Loops
    5129             :         }     //(  IF (NumSimulationSecondarySystems > 0)
    5130             : 
    5131             :         //************ END SECONDARY SYSTEM INPUT  **************
    5132             : 
    5133             :         //************ START Compressor INPUT  **************
    5134             : 
    5135          15 :         CurrentModuleObject = "Refrigeration:Compressor";
    5136         189 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    5137         174 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5138             :                                                                      CurrentModuleObject,
    5139             :                                                                      CompNum,
    5140             :                                                                      Alphas,
    5141             :                                                                      NumAlphas,
    5142             :                                                                      Numbers,
    5143             :                                                                      NumNumbers,
    5144             :                                                                      IOStatus,
    5145             :                                                                      lNumericBlanks,
    5146             :                                                                      lAlphaBlanks,
    5147             :                                                                      cAlphaFieldNames,
    5148             :                                                                      cNumericFieldNames);
    5149         174 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5150             : 
    5151         174 :             Compressor(CompNum).Name = Alphas(1);
    5152             : 
    5153         174 :             Compressor(CompNum).ElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    5154         174 :             if ((!lAlphaBlanks(2)) && Compressor(CompNum).ElecPowerCurvePtr == 0) {
    5155           0 :                 ShowSevereError(state,
    5156           0 :                                 format("{}{}=\"{}\", invalid  {} not found = {}",
    5157             :                                        RoutineName,
    5158             :                                        CurrentModuleObject,
    5159           0 :                                        Compressor(CompNum).Name,
    5160             :                                        cAlphaFieldNames(2),
    5161             :                                        Alphas(2)));
    5162           0 :                 ErrorsFound = true;
    5163             :             }
    5164             : 
    5165         174 :             Compressor(CompNum).CapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    5166         174 :             if ((!lAlphaBlanks(3)) && Compressor(CompNum).CapacityCurvePtr == 0) {
    5167           0 :                 ShowSevereError(state,
    5168           0 :                                 format("{}{}=\"{}\", invalid  {} not found = {}",
    5169             :                                        RoutineName,
    5170             :                                        CurrentModuleObject,
    5171           0 :                                        Compressor(CompNum).Name,
    5172             :                                        cAlphaFieldNames(3),
    5173             :                                        Alphas(3)));
    5174           0 :                 ErrorsFound = true;
    5175             :             }
    5176             : 
    5177             :             // Get superheat rating type (Either N1 or N2 Must be input)
    5178         174 :             if (((!lNumericBlanks(1)) && (!lNumericBlanks(2))) || (lNumericBlanks(1) && lNumericBlanks(2))) {
    5179           0 :                 ShowSevereError(state,
    5180           0 :                                 format("{}{}=\"{}\"One, and Only One of {} or {}",
    5181             :                                        RoutineName,
    5182             :                                        CurrentModuleObject,
    5183           0 :                                        Compressor(CompNum).Name,
    5184             :                                        cNumericFieldNames(1),
    5185             :                                        cNumericFieldNames(2)));
    5186           0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    5187           0 :                 ErrorsFound = true;
    5188         174 :             } else if (!lNumericBlanks(1)) {
    5189          83 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::Superheat;
    5190          83 :                 Compressor(CompNum).RatedSuperheat = Numbers(1);
    5191          91 :             } else if (!lNumericBlanks(2)) {
    5192          91 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::ReturnGasTemperature;
    5193          91 :                 Compressor(CompNum).RatedSuperheat = Numbers(2);
    5194             :             } // Set SuperheatRatingType
    5195             : 
    5196             :             // Get subcool rating type (Either N3 or N4 Must be input)
    5197         174 :             if (((!lNumericBlanks(3)) && (!lNumericBlanks(4))) || (lNumericBlanks(3) && lNumericBlanks(4))) {
    5198           0 :                 ShowSevereError(state,
    5199           0 :                                 format("{}{}=\"{}\" One, and Only One of {} or {}",
    5200             :                                        RoutineName,
    5201             :                                        CurrentModuleObject,
    5202           0 :                                        Compressor(CompNum).Name,
    5203             :                                        cNumericFieldNames(3),
    5204             :                                        cNumericFieldNames(4)));
    5205           0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    5206           0 :                 ErrorsFound = true;
    5207         174 :             } else if (!lNumericBlanks(3)) {
    5208          19 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::LiquidTemperature;
    5209          19 :                 Compressor(CompNum).RatedSubcool = Numbers(3);
    5210         155 :             } else if (!lNumericBlanks(4)) {
    5211         155 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::Subcooling;
    5212         155 :                 Compressor(CompNum).RatedSubcool = Numbers(4);
    5213             :             } // Set SubcoolRatingType
    5214             : 
    5215         174 :             Compressor(CompNum).EndUseSubcategory = "General";
    5216         174 :             if (!lAlphaBlanks(4)) Compressor(CompNum).EndUseSubcategory = Alphas(4);
    5217             : 
    5218             :             //  If the compressor is a transcritical CO compressor, get transcritical power and capacity curves
    5219         174 :             if (Util::SameString(Alphas(5), "Transcritical")) { // Mode of Operation = Transcritical
    5220           3 :                 Compressor(CompNum).TransFlag = true;
    5221           3 :                 Compressor(CompNum).TransElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(6)); // convert curve name to number
    5222           3 :                 if (lAlphaBlanks(6) && Compressor(CompNum).TransElecPowerCurvePtr == 0) {
    5223           0 :                     ShowSevereError(
    5224           0 :                         state, format("{}{}={}: {} not found.", RoutineName, CurrentModuleObject, Compressor(CompNum).Name, cAlphaFieldNames(6)));
    5225           0 :                     ErrorsFound = true;
    5226             :                 }
    5227           3 :                 Compressor(CompNum).TransCapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(7)); // convert curve name to number
    5228           3 :                 if (lAlphaBlanks(7) && Compressor(CompNum).TransCapacityCurvePtr == 0) {
    5229           0 :                     ShowSevereError(
    5230           0 :                         state, format("{}{}={}: {} not found.", RoutineName, CurrentModuleObject, Compressor(CompNum).Name, cAlphaFieldNames(7)));
    5231           0 :                     ErrorsFound = true;
    5232             :                 }
    5233         171 :             } else if ((Util::SameString(Alphas(5), "Subcritical")) || (lAlphaBlanks(5))) { // Mode of Operation = Subcritical
    5234         171 :                 Compressor(CompNum).TransFlag = false;
    5235         171 :                 if ((!lAlphaBlanks(6)) || (!lAlphaBlanks(7))) { // Transcritical compressor curves specified for subcritical compressor
    5236           0 :                     ShowWarningError(
    5237             :                         state,
    5238           0 :                         format("{}{}={} is specified to be a subcritical compressor, however transcritical compressor curve(s) are given.",
    5239             :                                RoutineName,
    5240             :                                CurrentModuleObject,
    5241           0 :                                Compressor(CompNum).Name));
    5242           0 :                     ShowContinueError(
    5243             :                         state,
    5244             :                         "The compressor will be modeled as a subcritical compressor and the transcritical compressor curve(s) will be ignored.");
    5245             :                 }
    5246             :             } else { // Invalid Mode of Operation
    5247           0 :                 ShowSevereError(state,
    5248           0 :                                 format("{}{}: {} for {}={}{}",
    5249             :                                        RoutineName,
    5250             :                                        CurrentModuleObject,
    5251             :                                        cAlphaFieldNames(5),
    5252           0 :                                        Compressor(CompNum).Name,
    5253             :                                        Alphas(5),
    5254             :                                        R"( is invalid. Valid choices are "Subcritical" or "Transcritical".)"));
    5255           0 :                 ErrorsFound = true;
    5256             :             }
    5257             : 
    5258             :         } // RefrigCompressor
    5259             : 
    5260             :         //************ END Compressor INPUT         **************
    5261             : 
    5262             :         //************ START Subcooler INPUT        **************
    5263          15 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    5264           1 :             CurrentModuleObject = "Refrigeration:Subcooler";
    5265           1 :             state.dataRefrigCase->NumSimulationMechSubcoolers = 0;
    5266           3 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    5267           2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5268             :                                                                          CurrentModuleObject,
    5269             :                                                                          SubcoolerNum,
    5270             :                                                                          Alphas,
    5271             :                                                                          NumAlphas,
    5272             :                                                                          Numbers,
    5273             :                                                                          NumNumbers,
    5274             :                                                                          IOStatus,
    5275             :                                                                          lNumericBlanks,
    5276             :                                                                          lAlphaBlanks,
    5277             :                                                                          cAlphaFieldNames,
    5278             :                                                                          cNumericFieldNames);
    5279           2 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5280             : 
    5281           2 :                 Subcooler(SubcoolerNum).Name = Alphas(1);
    5282             : 
    5283             :                 // Get subcooler type
    5284           2 :                 Subcooler(SubcoolerNum).subcoolerType = SubcoolerType::LiquidSuction; // default subcooler type
    5285           2 :                 if (Util::SameString(Alphas(2), "Mechanical")) {                      // set subcooler type
    5286           1 :                     Subcooler(SubcoolerNum).subcoolerType = SubcoolerType::Mechanical;
    5287           1 :                     ++state.dataRefrigCase->NumSimulationMechSubcoolers;
    5288           1 :                 } else if (Util::SameString(Alphas(2), "LiquidSuction")) {
    5289           1 :                     Subcooler(SubcoolerNum).subcoolerType = SubcoolerType::LiquidSuction;
    5290             :                 } else {
    5291           0 :                     ShowSevereError(state,
    5292           0 :                                     format("{}{}=\"{}\", {} not recognized = {}",
    5293             :                                            RoutineName,
    5294             :                                            CurrentModuleObject,
    5295           0 :                                            Subcooler(SubcoolerNum).Name,
    5296             :                                            cAlphaFieldNames(2),
    5297             :                                            Alphas(2)));
    5298           0 :                     ShowContinueError(state, "Check input value choices.");
    5299           0 :                     ErrorsFound = true;
    5300             :                 } // Set Subcooler Type
    5301             : 
    5302           2 :                 switch (Subcooler(SubcoolerNum).subcoolerType) {
    5303           1 :                 case SubcoolerType::LiquidSuction: {
    5304           1 :                     Subcooler(SubcoolerNum).LiqSuctDesignDelT = 10.0; // default value
    5305           1 :                     if (!lNumericBlanks(1)) Subcooler(SubcoolerNum).LiqSuctDesignDelT = Numbers(1);
    5306           1 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignDelT < 0.0) {
    5307           0 :                         ShowSevereError(state,
    5308           0 :                                         format("{}{}=\"{}\" {} cannot be less than zero.",
    5309             :                                                RoutineName,
    5310             :                                                CurrentModuleObject,
    5311           0 :                                                Subcooler(SubcoolerNum).Name,
    5312             :                                                cNumericFieldNames(1)));
    5313           0 :                         ErrorsFound = true;
    5314             :                     }
    5315             : 
    5316           1 :                     if (!lNumericBlanks(2)) {
    5317           1 :                         Subcooler(SubcoolerNum).LiqSuctDesignTliqIn = Numbers(2);
    5318             :                     } else {
    5319           0 :                         ShowSevereError(state,
    5320           0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5321             :                                                RoutineName,
    5322             :                                                CurrentModuleObject,
    5323           0 :                                                Subcooler(SubcoolerNum).Name,
    5324             :                                                cNumericFieldNames(2)));
    5325           0 :                         ErrorsFound = true;
    5326             :                     }
    5327             : 
    5328           1 :                     if (!lNumericBlanks(3)) {
    5329           1 :                         Subcooler(SubcoolerNum).LiqSuctDesignTvapIn = Numbers(3);
    5330             :                     } else {
    5331           0 :                         ShowSevereError(state,
    5332           0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5333             :                                                RoutineName,
    5334             :                                                CurrentModuleObject,
    5335           0 :                                                Subcooler(SubcoolerNum).Name,
    5336             :                                                cNumericFieldNames(3)));
    5337           0 :                         ErrorsFound = true;
    5338             :                     }
    5339           1 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignTvapIn > Subcooler(SubcoolerNum).LiqSuctDesignTliqIn) {
    5340           0 :                         ShowSevereError(state,
    5341           0 :                                         format("{}{}=\"{}\" {} cannot be greater than {}.",
    5342             :                                                RoutineName,
    5343             :                                                CurrentModuleObject,
    5344           0 :                                                Subcooler(SubcoolerNum).Name,
    5345             :                                                cNumericFieldNames(3),
    5346             :                                                cNumericFieldNames(2)));
    5347           0 :                         ErrorsFound = true;
    5348             :                     } // error check
    5349           1 :                 } break;
    5350           1 :                 case SubcoolerType::Mechanical: {
    5351           1 :                     Subcooler(SubcoolerNum).MechSourceSys = Alphas(3);
    5352             :                     // Error check on system name comes later after systems have been read
    5353             : 
    5354           1 :                     if (!lNumericBlanks(4)) {
    5355           1 :                         Subcooler(SubcoolerNum).MechControlTliqOut = Numbers(4);
    5356             :                     } else {
    5357           0 :                         ShowSevereError(state,
    5358           0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5359             :                                                RoutineName,
    5360             :                                                CurrentModuleObject,
    5361           0 :                                                Subcooler(SubcoolerNum).Name,
    5362             :                                                cNumericFieldNames(4)));
    5363           0 :                         ErrorsFound = true;
    5364             :                     } // error check
    5365           1 :                 } break;
    5366           0 :                 default:
    5367           0 :                     break;
    5368             :                 }
    5369             :             } // Subcooler Input
    5370             :         }     // If there are subcoolers
    5371             : 
    5372             :         // ********END SUBCOOLER INPUTS ************
    5373             : 
    5374             :         //**** Read TransferLoad Lists **********************************************************
    5375          15 :         if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    5376           1 :             CurrentModuleObject = "Refrigeration:TransferLoadList";
    5377           2 :             for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationTransferLoadLists; ++ListNum) {
    5378           1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5379             :                                                                          CurrentModuleObject,
    5380             :                                                                          ListNum,
    5381             :                                                                          Alphas,
    5382             :                                                                          NumAlphas,
    5383             :                                                                          Numbers,
    5384             :                                                                          NumNumbers,
    5385             :                                                                          IOStatus,
    5386             :                                                                          lNumericBlanks,
    5387             :                                                                          lAlphaBlanks,
    5388             :                                                                          cAlphaFieldNames,
    5389             :                                                                          cNumericFieldNames);
    5390           1 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5391             : 
    5392           1 :                 TransferLoadList(ListNum).Name = Alphas(1);
    5393             : 
    5394             :                 // Transfer load list alphas include TransferLoadList name and one name for each Secondary or Cascade Condenser in list
    5395             :                 // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    5396           1 :                 int NumTotalLoadsOnList = NumAlphas - 1;
    5397           1 :                 if (!allocated(TransferLoadList(ListNum).CascadeLoadItemNum))
    5398           1 :                     TransferLoadList(ListNum).CascadeLoadItemNum.allocate(NumTotalLoadsOnList);
    5399           1 :                 if (!allocated(TransferLoadList(ListNum).SecondaryItemNum)) TransferLoadList(ListNum).SecondaryItemNum.allocate(NumTotalLoadsOnList);
    5400             : 
    5401           1 :                 int NumSecondarysOnList = 0;
    5402           1 :                 int NumCascadeLoadsOnList = 0;
    5403           2 :                 for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    5404           1 :                     int AlphaListNum = 1 + NumLoad;
    5405           1 :                     int LoadCascadeNum = 0;
    5406           1 :                     int LoadSecondaryNum = 0;
    5407           1 :                     if (state.dataRefrigCase->NumRefrigCondensers > 0) LoadCascadeNum = Util::FindItemInList(Alphas(AlphaListNum), Condenser);
    5408           1 :                     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0)
    5409           1 :                         LoadSecondaryNum = Util::FindItemInList(Alphas(AlphaListNum), Secondary);
    5410           1 :                     if ((LoadCascadeNum == 0) && (LoadSecondaryNum == 0)) {
    5411           0 :                         ShowSevereError(state,
    5412           0 :                                         format("{}{}=\"{}\" : has an invalid value of {}",
    5413             :                                                RoutineName,
    5414             :                                                CurrentModuleObject,
    5415             :                                                cAlphaFieldNames(AlphaListNum),
    5416             :                                                Alphas(AlphaListNum)));
    5417           0 :                         ErrorsFound = true;
    5418           1 :                     } else if ((LoadCascadeNum != 0) && (LoadSecondaryNum != 0)) {
    5419           0 :                         ShowSevereError(state,
    5420           0 :                                         format("{}{}=\"{}\" : has a non-unique name : {}",
    5421             :                                                RoutineName,
    5422             :                                                CurrentModuleObject,
    5423             :                                                cAlphaFieldNames(AlphaListNum),
    5424             :                                                Alphas(AlphaListNum)));
    5425           0 :                         ErrorsFound = true;
    5426           1 :                     } else if (LoadCascadeNum != 0) {
    5427           0 :                         if (Condenser(LoadCascadeNum).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    5428           0 :                             ShowSevereError(state,
    5429           0 :                                             format("{}{}=\"{}\" : has a condenser listed as a transfer load that is not a cascade condenser: {}",
    5430             :                                                    RoutineName,
    5431             :                                                    CurrentModuleObject,
    5432           0 :                                                    System(RefrigSysNum).Name,
    5433             :                                                    Alphas(AlphaListNum)));
    5434           0 :                             ErrorsFound = true;
    5435             :                         } else {
    5436           0 :                             ++NumCascadeLoadsOnList;
    5437           0 :                             TransferLoadList(ListNum).CascadeLoadItemNum(NumCascadeLoadsOnList) = LoadCascadeNum;
    5438             :                         } // /= condenser cascade type
    5439           1 :                     } else if (LoadSecondaryNum != 0) {
    5440           1 :                         ++NumSecondarysOnList;
    5441           1 :                         TransferLoadList(ListNum).SecondaryItemNum(NumSecondarysOnList) = LoadSecondaryNum;
    5442             :                     }
    5443           1 :                     TransferLoadList(ListNum).NumSecondarys = NumSecondarysOnList;
    5444           1 :                     TransferLoadList(ListNum).NumCascadeLoads = NumCascadeLoadsOnList;
    5445             :                 } // Num Total Loads on List
    5446             :             }     // ListNum=1,NumSimulationTransferLoadLists
    5447             :         }         //(NumSimulationTransferLoadLists > 0)
    5448             : 
    5449             :         //**** End read transfer load Lists **********************************************************
    5450             : 
    5451             :         //**** Read Compressor Lists **********************************************************
    5452          15 :         CurrentModuleObject = "Refrigeration:CompressorList";
    5453          58 :         for (int ListNum = 1; ListNum <= NumCompressorLists; ++ListNum) {
    5454          43 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5455             :                                                                      CurrentModuleObject,
    5456             :                                                                      ListNum,
    5457             :                                                                      Alphas,
    5458             :                                                                      NumAlphas,
    5459             :                                                                      Numbers,
    5460             :                                                                      NumNumbers,
    5461             :                                                                      IOStatus,
    5462             :                                                                      lNumericBlanks,
    5463             :                                                                      lAlphaBlanks,
    5464             :                                                                      cAlphaFieldNames,
    5465             :                                                                      cNumericFieldNames);
    5466          43 :             CompressorLists(ListNum).NumCompressors = NumAlphas - 1;
    5467          43 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5468             : 
    5469          43 :             CompressorLists(ListNum).Name = Alphas(1);
    5470          43 :             if (!allocated(CompressorLists(ListNum).CompItemNum))
    5471          43 :                 CompressorLists(ListNum).CompItemNum.allocate(CompressorLists(ListNum).NumCompressors);
    5472             : 
    5473         217 :             for (int CompIndex = 1; CompIndex <= CompressorLists(ListNum).NumCompressors; ++CompIndex) {
    5474         174 :                 int AlphaListNum = CompIndex + 1; // same as do loop from 2 to end of list
    5475         174 :                 if (!lAlphaBlanks(AlphaListNum)) {
    5476         174 :                     CompressorLists(ListNum).CompItemNum(CompIndex) = Util::FindItemInList(Alphas(AlphaListNum), Compressor);
    5477         174 :                     if (CompressorLists(ListNum).CompItemNum(CompIndex) == 0) {
    5478           0 :                         ShowSevereError(state,
    5479           0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    5480             :                                                RoutineName,
    5481             :                                                CurrentModuleObject,
    5482           0 :                                                CompressorLists(ListNum).Name,
    5483             :                                                cAlphaFieldNames(AlphaListNum),
    5484             :                                                Alphas(AlphaListNum)));
    5485           0 :                         ErrorsFound = true;
    5486             :                     }
    5487             :                 }
    5488             :             } // NumCompressors in CompressorList
    5489             : 
    5490             :         } // NumCompressorLists
    5491             : 
    5492             :         // ********READ REFRIGERATION SYSTEMS  ***********
    5493             : 
    5494          15 :         CurrentModuleObject = "Refrigeration:System";
    5495          54 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    5496             : 
    5497          39 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5498             :                                                                      CurrentModuleObject,
    5499             :                                                                      RefrigSysNum,
    5500             :                                                                      Alphas,
    5501             :                                                                      NumAlphas,
    5502             :                                                                      Numbers,
    5503             :                                                                      NumNumbers,
    5504             :                                                                      IOStatus,
    5505             :                                                                      lNumericBlanks,
    5506             :                                                                      lAlphaBlanks,
    5507             :                                                                      cAlphaFieldNames,
    5508             :                                                                      cNumericFieldNames);
    5509          39 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5510             : 
    5511          39 :             System(RefrigSysNum).Name = Alphas(1);
    5512             : 
    5513             :             // Read all loads on this System: cases, walk-ins, cascade loads, and secondary loops
    5514          39 :             if (lAlphaBlanks(2) && lAlphaBlanks(3)) {
    5515             :                 // No cases, walkins, cascade loads, or secondary loops specified, ie, System has no load
    5516           0 :                 ShowSevereError(state,
    5517           0 :                                 format("{}{}=\"{}\", has no loads, must have at least one of: {} or {} objects attached.",
    5518             :                                        RoutineName,
    5519             :                                        CurrentModuleObject,
    5520           0 :                                        System(RefrigSysNum).Name,
    5521             :                                        cAlphaFieldNames(2),
    5522             :                                        cAlphaFieldNames(3)));
    5523           0 :                 ErrorsFound = true;
    5524             :             }
    5525          39 :             NumCases = 0;
    5526          39 :             System(RefrigSysNum).NumCases = 0;
    5527          39 :             int NumCoils = 0;
    5528          39 :             System(RefrigSysNum).NumCoils = 0;
    5529          39 :             NumWalkIns = 0;
    5530          39 :             System(RefrigSysNum).NumWalkIns = 0;
    5531          39 :             int NumSecondary = 0;
    5532          39 :             System(RefrigSysNum).NumSecondarys = 0;
    5533          39 :             System(RefrigSysNum).NumCascadeLoads = 0;
    5534          39 :             System(RefrigSysNum).NumNonCascadeLoads = 0;
    5535          39 :             Real64 NominalTotalCaseCap = 0.0;
    5536          39 :             Real64 NominalTotalCoilCap = 0.0;
    5537          39 :             Real64 NominalTotalWalkInCap = 0.0;
    5538          39 :             Real64 NominalTotalSecondaryCap = 0.0;
    5539             :             Real64 NominalTotalCoolingCap;
    5540          39 :             Real64 NominalTotalCascadeLoad = 0.0;
    5541          39 :             System(RefrigSysNum).RefInventory = 0.0;
    5542             : 
    5543             :             //   Check for case or walkin or CaseAndWalkInList names
    5544          39 :             AlphaNum = 2;
    5545          39 :             if (!lAlphaBlanks(AlphaNum)) {
    5546             : 
    5547             :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    5548          36 :                 int CaseAndWalkInListNum = 0;
    5549          36 :                 int CaseNum = 0;
    5550          36 :                 int WalkInNum = 0;
    5551          36 :                 int CoilNum = 0;
    5552          36 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    5553          36 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    5554          36 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    5555          36 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    5556          36 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    5557          36 :                 int NumNameMatches = 0;
    5558          36 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    5559          36 :                 if (CaseNum != 0) ++NumNameMatches;
    5560          36 :                 if (WalkInNum != 0) ++NumNameMatches;
    5561          36 :                 if (CoilNum != 0) ++NumNameMatches;
    5562             : 
    5563          36 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    5564           0 :                     ErrorsFound = true;
    5565           0 :                     if (NumNameMatches == 0) {
    5566           0 :                         ShowSevereError(state,
    5567           0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5568             :                                                RoutineName,
    5569             :                                                CurrentModuleObject,
    5570           0 :                                                System(RefrigSysNum).Name,
    5571             :                                                cAlphaFieldNames(AlphaNum),
    5572             :                                                Alphas(AlphaNum)));
    5573           0 :                     } else if (NumNameMatches > 1) {
    5574           0 :                         ShowSevereError(state,
    5575           0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    5576             :                                                RoutineName,
    5577             :                                                CurrentModuleObject,
    5578           0 :                                                System(RefrigSysNum).Name,
    5579             :                                                cAlphaFieldNames(AlphaNum),
    5580             :                                                Alphas(AlphaNum)));
    5581             :                     }                                   // num matches = 0 or > 1
    5582          36 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    5583          33 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    5584          33 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    5585          33 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    5586          33 :                     System(RefrigSysNum).NumCases = NumCases;
    5587          33 :                     System(RefrigSysNum).NumWalkIns = NumWalkIns;
    5588          33 :                     System(RefrigSysNum).NumCoils = NumCoils;
    5589          33 :                     if (NumCases > 0) {
    5590          22 :                         if (!allocated(System(RefrigSysNum).CaseNum)) System(RefrigSysNum).CaseNum.allocate(NumCases);
    5591          22 :                         System(RefrigSysNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    5592             :                     }
    5593          33 :                     if (NumCoils > 0) {
    5594           9 :                         if (!allocated(System(RefrigSysNum).CoilNum)) System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5595           9 :                         System(RefrigSysNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    5596             :                     }
    5597          33 :                     if (NumWalkIns > 0) {
    5598          13 :                         if (!allocated(System(RefrigSysNum).WalkInNum)) System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5599          13 :                         System(RefrigSysNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    5600             :                     }
    5601           3 :                 } else if (CaseNum != 0) { // Name points to a case
    5602           3 :                     NumCases = 1;
    5603           3 :                     System(RefrigSysNum).NumCases = 1;
    5604           3 :                     if (!allocated(System(RefrigSysNum).CaseNum)) System(RefrigSysNum).CaseNum.allocate(NumCases);
    5605           3 :                     System(RefrigSysNum).CaseNum(NumCases) = CaseNum;
    5606           0 :                 } else if (CoilNum != 0) { // Name points to a coil
    5607           0 :                     NumCoils = 1;
    5608           0 :                     System(RefrigSysNum).NumCoils = 1;
    5609           0 :                     if (!allocated(System(RefrigSysNum).CoilNum)) System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5610           0 :                     System(RefrigSysNum).CoilNum(NumCoils) = CoilNum;
    5611           0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    5612           0 :                     NumWalkIns = 1;
    5613           0 :                     System(RefrigSysNum).NumWalkIns = 1;
    5614           0 :                     if (!allocated(System(RefrigSysNum).WalkInNum)) System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5615           0 :                     System(RefrigSysNum).WalkInNum(NumWalkIns) = WalkInNum;
    5616             :                 } // NumNameMatches /= 1
    5617             :             }     // blank input for cases, walkins, or caseandwalkinlist
    5618             : 
    5619          39 :             if (NumCases > 0) {
    5620             :                 // Find lowest design evap T
    5621             :                 // Sum rated capacity of all cases on system
    5622         105 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    5623             :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    5624          80 :                     int CaseNum = System(RefrigSysNum).CaseNum(caseIndex);
    5625          80 :                     ++RefrigCase(CaseNum).NumSysAttach;
    5626          80 :                     NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap;
    5627          80 :                     System(RefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    5628          80 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    5629          25 :                         System(RefrigSysNum).TEvapDesign = RefrigCase(CaseNum).EvapTempDesign;
    5630             :                     } else {
    5631          55 :                         System(RefrigSysNum).TEvapDesign = min(RefrigCase(CaseNum).EvapTempDesign, System(RefrigSysNum).TEvapDesign);
    5632             :                     }
    5633             :                 } // CaseIndex=1,NumCases
    5634          25 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCases;
    5635             :             } // Numcases > 0
    5636             : 
    5637          39 :             if (NumCoils > 0) {
    5638             :                 // Find lowest design evap T
    5639             :                 // Sum rated capacity of all Coils on system
    5640          92 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    5641             :                     // mark all Coils on system as used by this system - checking for unused or non-unique Coils
    5642          83 :                     int CoilNum = System(RefrigSysNum).CoilNum(CoilIndex);
    5643          83 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    5644          83 :                     NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    5645          83 :                     System(RefrigSysNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    5646          83 :                     if ((CoilIndex == 1) && (System(RefrigSysNum).NumCases == 0)) { // look for lowest Coil design evap T for system
    5647           9 :                         System(RefrigSysNum).TEvapDesign = WarehouseCoil(CoilNum).TEvapDesign;
    5648             :                     } else {
    5649          74 :                         System(RefrigSysNum).TEvapDesign = min(WarehouseCoil(CoilNum).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5650             :                     }
    5651             :                 } // CoilIndex=1,NumCoils
    5652           9 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCoils;
    5653             :             } // NumCoils > 0
    5654             : 
    5655          39 :             if (NumWalkIns > 0) {
    5656          26 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    5657          13 :                     int WalkInID = System(RefrigSysNum).WalkInNum(WalkInIndex);
    5658             :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    5659          13 :                     ++WalkIn(WalkInID).NumSysAttach;
    5660          13 :                     NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    5661          13 :                     System(RefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    5662             :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    5663             :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    5664             :                     //  to either the rack or system.
    5665             :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    5666          13 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    5667             :                         // - 99 used as a flag for blank input error message for detailed systems
    5668           0 :                         ShowSevereError(state,
    5669           0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    5670             :                                                "electric and hotfluid defrost types",
    5671             :                                                RoutineName,
    5672           0 :                                                WalkIn(WalkInID).Name));
    5673           0 :                         ErrorsFound = true;
    5674             :                     }
    5675             :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    5676          13 :                     if ((WalkInIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0)) {
    5677             :                         // note use walk in index, not walkinid here to get
    5678             :                         // first walkin on this suction group/system
    5679           2 :                         System(RefrigSysNum).TEvapDesign = WalkIn(WalkInID).TEvapDesign;
    5680             :                     } else {
    5681          11 :                         System(RefrigSysNum).TEvapDesign = min(WalkIn(WalkInID).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5682             :                     }
    5683             :                 } // WalkInIndex=1,NumWalkIns
    5684          13 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumWalkIns;
    5685             :             } // numwalkins > 0
    5686             : 
    5687          39 :             AlphaNum = 3;
    5688             :             // Read Transfer Loads (Secondary and Cascade) assignments for this System ,
    5689             :             //     already allow more than one mech subcooler to load onto a system so they don't need to go in list
    5690          39 :             if (!lAlphaBlanks(AlphaNum)) {
    5691             : 
    5692             :                 // Entry for Alphas(AlphaNum) can be either a Secondary, CascadeLoad name or a TransferLoadList name
    5693           3 :                 int TransferLoadListNum = 0;
    5694           3 :                 int SecondaryNum = 0;
    5695           3 :                 int CascadeLoadNum = 0;
    5696           3 :                 if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0)
    5697           2 :                     TransferLoadListNum = Util::FindItemInList(Alphas(AlphaNum), TransferLoadList);
    5698           3 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) SecondaryNum = Util::FindItemInList(Alphas(AlphaNum), Secondary);
    5699           3 :                 if (state.dataRefrigCase->NumRefrigCondensers > 0) CascadeLoadNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5700           3 :                 int NumNameMatches = 0;
    5701           3 :                 if (TransferLoadListNum != 0) ++NumNameMatches;
    5702           3 :                 if (SecondaryNum != 0) ++NumNameMatches;
    5703           3 :                 if (CascadeLoadNum != 0) ++NumNameMatches;
    5704           3 :                 int NumCascadeLoad = 0;
    5705             : 
    5706           3 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single transfer load
    5707           0 :                     ErrorsFound = true;
    5708           0 :                     if (NumNameMatches == 0) {
    5709           0 :                         ShowSevereError(state,
    5710           0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5711             :                                                RoutineName,
    5712             :                                                CurrentModuleObject,
    5713           0 :                                                System(RefrigSysNum).Name,
    5714             :                                                cAlphaFieldNames(AlphaNum),
    5715             :                                                Alphas(AlphaNum)));
    5716           0 :                     } else if (NumNameMatches > 1) {
    5717           0 :                         ShowSevereError(state,
    5718           0 :                                         format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    5719             :                                                RoutineName,
    5720             :                                                CurrentModuleObject,
    5721           0 :                                                System(RefrigSysNum).Name,
    5722             :                                                cAlphaFieldNames(AlphaNum),
    5723             :                                                Alphas(AlphaNum)));
    5724             :                     }                                  // num matches = 0 or > 1
    5725           3 :                 } else if (TransferLoadListNum != 0) { // Name points to a transferLoad list
    5726           1 :                     NumSecondary = TransferLoadList(TransferLoadListNum).NumSecondarys;
    5727           1 :                     NumCascadeLoad = TransferLoadList(TransferLoadListNum).NumCascadeLoads;
    5728           1 :                     System(RefrigSysNum).NumSecondarys = NumSecondary;
    5729           1 :                     System(RefrigSysNum).NumCascadeLoads = NumCascadeLoad;
    5730           1 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5731           1 :                     System(RefrigSysNum).SecondaryNum({1, NumSecondary}) = TransferLoadList(TransferLoadListNum).SecondaryItemNum({1, NumSecondary});
    5732           1 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5733           2 :                     System(RefrigSysNum).CascadeLoadNum({1, NumCascadeLoad}) =
    5734           3 :                         TransferLoadList(TransferLoadListNum).CascadeLoadItemNum({1, NumCascadeLoad});
    5735           2 :                 } else if (SecondaryNum != 0) { // Name points to a secondary loop load
    5736           1 :                     NumSecondary = 1;
    5737           1 :                     System(RefrigSysNum).NumSecondarys = 1;
    5738           1 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5739           1 :                     System(RefrigSysNum).SecondaryNum(NumSecondary) = SecondaryNum;
    5740           1 :                 } else if (CascadeLoadNum != 0) { // Name points to a cascade condenser load
    5741           1 :                     NumCascadeLoad = 1;
    5742           1 :                     System(RefrigSysNum).NumCascadeLoads = 1;
    5743           1 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5744           1 :                     System(RefrigSysNum).CascadeLoadNum(NumCascadeLoad) = CascadeLoadNum;
    5745             :                 } // NumNameMatches /= 1
    5746             : 
    5747           3 :                 System(RefrigSysNum).CoilFlag = false;
    5748             :                 // Now need to loop through all transfer loads to see if they change the minimum required system evaporating temperature
    5749           3 :                 if (NumSecondary > 0) {
    5750           4 :                     for (int SecondaryIndex = 1; SecondaryIndex <= NumSecondary; ++SecondaryIndex) {
    5751           2 :                         int SecondaryID = System(RefrigSysNum).SecondaryNum(SecondaryIndex);
    5752           2 :                         if (SecondaryIndex == 1) { // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5753           2 :                             if (Secondary(SecondaryID).CoilFlag) System(RefrigSysNum).CoilFlag = true;
    5754           0 :                         } else if (Secondary(SecondaryID).CoilFlag != System(RefrigSysNum).CoilFlag) {
    5755           0 :                             ShowSevereError(
    5756             :                                 state,
    5757           0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5758             :                                        "step than case or walkin loads. Compare loads on system served by secondary loop \"{}",
    5759             :                                        RoutineName,
    5760             :                                        CurrentModuleObject,
    5761           0 :                                        System(RefrigSysNum).Name,
    5762           0 :                                        Secondary(SecondaryID).Name));
    5763           0 :                             ErrorsFound = true;
    5764             :                         } // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5765             :                         // mark all Secondarys on system as used by this system (checking for unused or non-unique Secondarys)
    5766           2 :                         ++Secondary(SecondaryID).NumSysAttach;
    5767           2 :                         NominalTotalSecondaryCap += Secondary(SecondaryID).CoolingLoadRated;
    5768           2 :                         System(RefrigSysNum).RefInventory += Secondary(SecondaryID).ChillerRefInventory;
    5769             :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5770           4 :                         if ((SecondaryIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0) &&
    5771           2 :                             (System(RefrigSysNum).NumWalkIns == 0)) {
    5772             :                             // note use secondary index above, not secondaryid here to get
    5773             :                             // first secondary on this suction group/system
    5774             :                             // note - TMinNeeded on secondary defined by cases and walkins served by secondary, not by
    5775             :                             //       the secondary's rated evaporating temperature (which is used to calc secondary heat
    5776             :                             //       exchanger effectiveness with other rated values)
    5777           2 :                             System(RefrigSysNum).TEvapDesign = Secondary(SecondaryID).TMinNeeded;
    5778             :                         } else {
    5779           0 :                             System(RefrigSysNum).TEvapDesign = min(Secondary(SecondaryID).TMinNeeded, System(RefrigSysNum).TEvapDesign);
    5780             :                         }
    5781             :                     } // SecondaryIndex=1,NumSecondary
    5782           2 :                     System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumSecondarys;
    5783             :                 } // numsecondary > 0
    5784             : 
    5785           3 :                 if (NumCascadeLoad > 0) {
    5786           2 :                     for (int cascadeLoadIndex = 1; cascadeLoadIndex <= NumCascadeLoad; ++cascadeLoadIndex) {
    5787           1 :                         int CondID = System(RefrigSysNum).CascadeLoadNum(cascadeLoadIndex);
    5788           1 :                         if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    5789           0 :                             ShowSevereError(state,
    5790           0 :                                             format("{}{}=\"{}\", has a  {}: {} cascade load that is not a cascade condenser.",
    5791             :                                                    RoutineName,
    5792             :                                                    CurrentModuleObject,
    5793           0 :                                                    System(RefrigSysNum).Name,
    5794             :                                                    cAlphaFieldNames(AlphaNum),
    5795             :                                                    Alphas(AlphaNum)));
    5796           0 :                             ErrorsFound = true;
    5797             :                         }
    5798             :                         // For a cascade condenser, need to identify the system absorbing the heat
    5799           1 :                         Condenser(CondID).CascadeSinkSystemID = RefrigSysNum;
    5800           1 :                         NominalTotalCascadeLoad += Condenser(CondID).RatedCapacity;
    5801             :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5802           1 :                         if (System(RefrigSysNum).NumNonCascadeLoads == 0) {
    5803           1 :                             if (cascadeLoadIndex == 1) {
    5804             :                                 // note use cascadeload index above, not condid here to get
    5805             :                                 // first cascade condenser served by this suction group/system
    5806           1 :                                 System(RefrigSysNum).TEvapDesign = Condenser(CondID).CascadeRatedEvapTemp;
    5807             :                             } else {
    5808           0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp, System(RefrigSysNum).TEvapDesign);
    5809             :                             }    // CascadeLoadIndex == 1
    5810             :                         } else { // (NumNonCascadeLoads > 0 so initial TEvapDesign set above with those other loads)
    5811           0 :                             if (Condenser(CondID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet)
    5812           0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp,
    5813           0 :                                                                        System(RefrigSysNum).TEvapDesign); // other wise TEvapDesign set by other loads
    5814             :                         }
    5815             :                     } // CascadeLoadIndex=1,NumCascadeLoad
    5816             :                 }     // CascadeLoadNum > 0
    5817             :             }         // yes/no blank input for transfer loads
    5818             : 
    5819             :             // check for consistency of loads (coils calc on sys time step, all others on zone time step, so can't mix on one system)
    5820          39 :             if (System(RefrigSysNum).CoilFlag) { // could already be true if serving secondary that serves coils
    5821           0 :                 if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5822           0 :                     ShowSevereError(state,
    5823           0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5824             :                                            "step than case or walkin loads.",
    5825             :                                            RoutineName,
    5826             :                                            CurrentModuleObject,
    5827           0 :                                            System(RefrigSysNum).Name));
    5828           0 :                     ErrorsFound = true;
    5829             :                 }
    5830             :             } else {                                     // no coils on secondary or no secondary
    5831          39 :                 if (System(RefrigSysNum).NumCoils > 0) { //(note, coilflag set to .FALSE. for all systems as default above
    5832           9 :                     System(RefrigSysNum).CoilFlag = true;
    5833           9 :                     if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5834           0 :                         ShowSevereError(state,
    5835           0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    5836             :                                                "time step than case or walkin loads.",
    5837             :                                                RoutineName,
    5838             :                                                CurrentModuleObject,
    5839           0 :                                                System(RefrigSysNum).Name));
    5840           0 :                         ErrorsFound = true;
    5841             :                     }
    5842             :                 } // NumCoils > 0
    5843             :             }     // Coil flag already true due to secondary coil loads
    5844             : 
    5845          39 :             NominalTotalCoolingCap = NominalTotalCaseCap + NominalTotalWalkInCap + NominalTotalSecondaryCap + NominalTotalCascadeLoad;
    5846             : 
    5847             :             // read condenser
    5848             :             // currently assumes one condenser per refrigeration system and but multiple systems allowed per condenser
    5849          39 :             AlphaNum = 4;
    5850          39 :             int NumCondensers = 1;
    5851          39 :             if (!allocated(System(RefrigSysNum).CondenserNum)) System(RefrigSysNum).CondenserNum.allocate(NumCondensers);
    5852          39 :             System(RefrigSysNum).NumCondensers = 1;
    5853             :             // Find condenser number, note condensers were read in one of four objects, but all read into same list
    5854          39 :             int CondNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5855          39 :             if (CondNum == 0) {
    5856           0 :                 ShowSevereError(state,
    5857           0 :                                 format("{}{}=\"{}\", has an invalid {} defined as {}",
    5858             :                                        RoutineName,
    5859             :                                        CurrentModuleObject,
    5860           0 :                                        System(RefrigSysNum).Name,
    5861             :                                        cAlphaFieldNames(AlphaNum),
    5862             :                                        Alphas(AlphaNum)));
    5863           0 :                 ErrorsFound = true;
    5864             :             } else {
    5865          39 :                 System(RefrigSysNum).CondenserNum(NumCondensers) = CondNum;
    5866             :                 // Now take care of case where multiple systems share a condenser
    5867          39 :                 ++Condenser(CondNum).NumSysAttach;
    5868          39 :                 Condenser(CondNum).SysNum(Condenser(CondNum).NumSysAttach) = RefrigSysNum;
    5869             :             }
    5870             : 
    5871          78 :             System(RefrigSysNum).RefInventory +=
    5872          39 :                 Condenser(CondNum).RefReceiverInventory + Condenser(CondNum).RefPipingInventory + Condenser(CondNum).RefOpCharge;
    5873          39 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) Condenser(CondNum).CascadeSysID = RefrigSysNum;
    5874          39 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) && (Condenser(CondNum).CondenserRejectHeatToZone))
    5875           3 :                 System(RefrigSysNum).SystemRejectHeatToZone = true;
    5876             : 
    5877             :             // Now do evaporative condenser auto-sizing because it is a function of the system's cooling load
    5878          39 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5879           4 :                 if (Condenser(CondNum).RatedAirFlowRate == Constant::AutoCalculate) {
    5880           0 :                     Condenser(CondNum).RatedAirFlowRate = AirVolRateEvapCond * Condenser(CondNum).RatedCapacity;
    5881             :                 }
    5882           4 :                 if (Condenser(CondNum).RatedAirFlowRate <= 0.0) {
    5883           0 :                     ShowSevereError(state,
    5884           0 :                                     format("{}{}=\"{}\", Evaporative Condenser Air Volume Flow Rate cannot be less than or equal to zero.",
    5885             :                                            RoutineName,
    5886             :                                            CurrentModuleObject,
    5887           0 :                                            Condenser(CondNum).Name));
    5888           0 :                     ErrorsFound = true;
    5889             :                 }
    5890           4 :                 if (Condenser(CondNum).EvapPumpPower == Constant::AutoCalculate) {
    5891           0 :                     Condenser(CondNum).EvapPumpPower = CondPumpRatePower * Condenser(CondNum).RatedCapacity;
    5892             :                 }
    5893           4 :                 if (Condenser(CondNum).EvapPumpPower < 0.0) {
    5894           0 :                     ShowSevereError(state,
    5895           0 :                                     format("{}{}=\"{}\", Design Evaporative Condenser Water Pump Power cannot be less than zero.",
    5896             :                                            RoutineName,
    5897             :                                            CurrentModuleObject,
    5898           0 :                                            Condenser(CondNum).Name));
    5899           0 :                     ErrorsFound = true;
    5900             :                 }
    5901             :             }
    5902             : 
    5903             :             // Read the compressor data.
    5904             :             // If the system consists of two stages of compression, these compressors will be the low-stage compressors.
    5905          39 :             AlphaNum = 5;
    5906          39 :             int NumCompressorsSys = 0;
    5907          39 :             if (lAlphaBlanks(AlphaNum)) {
    5908             :                 // blank input where must have compressor or compressor list input.
    5909           0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    5910           0 :                 ErrorsFound = true;
    5911             :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    5912             :                 int ListNum;
    5913          39 :                 if (NumCompressorLists > 0) {
    5914          39 :                     ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5915             :                 } else {
    5916           0 :                     ListNum = 0;
    5917             :                 }
    5918             :                 int CompNum;
    5919          39 :                 if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    5920          39 :                     CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5921             :                 } else {
    5922           0 :                     CompNum = 0;
    5923             :                 }
    5924          39 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    5925           0 :                     ShowSevereError(state,
    5926           0 :                                     format("{}{} {}, has an invalid or undefined value=\"{}\".",
    5927             :                                            RoutineName,
    5928             :                                            CurrentModuleObject,
    5929             :                                            cAlphaFieldNames(AlphaNum),
    5930             :                                            Alphas(AlphaNum)));
    5931           0 :                     ErrorsFound = true;
    5932          39 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    5933           0 :                     ShowSevereError(state,
    5934           0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    5935             :                                            RoutineName,
    5936             :                                            CurrentModuleObject,
    5937             :                                            cAlphaFieldNames(AlphaNum),
    5938             :                                            Alphas(AlphaNum)));
    5939           0 :                     ErrorsFound = true;
    5940          39 :                 } else if (ListNum != 0) {
    5941          39 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    5942          39 :                     System(RefrigSysNum).NumCompressors = NumCompressorsSys;
    5943          39 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5944          39 :                     System(RefrigSysNum).CompressorNum({1, NumCompressorsSys}) = CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    5945           0 :                 } else if (CompNum != 0) {
    5946           0 :                     NumCompressorsSys = 1;
    5947           0 :                     System(RefrigSysNum).NumCompressors = 1;
    5948           0 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5949           0 :                     System(RefrigSysNum).CompressorNum(NumCompressorsSys) = CompNum;
    5950             :                 }
    5951             :             }
    5952             : 
    5953          39 :             if (!lNumericBlanks(1)) {
    5954          39 :                 System(RefrigSysNum).TCondenseMin = Numbers(1);
    5955          39 :                 System(RefrigSysNum).TCondenseMinInput = System(RefrigSysNum).TCondenseMin;
    5956          39 :                 if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5957           4 :                     SetupEMSActuator(state,
    5958             :                                      "Refrigeration:System",
    5959           2 :                                      System(RefrigSysNum).Name,
    5960             :                                      "Minimum Condensing Temperature",
    5961             :                                      "[C]",
    5962           2 :                                      System(RefrigSysNum).EMSOverrideOnTCondenseMin,
    5963           2 :                                      System(RefrigSysNum).EMSOverrideValueTCondenseMin);
    5964             :                 }
    5965             :             } else {
    5966           0 :                 ShowSevereError(
    5967             :                     state,
    5968           0 :                     format("{}{}=\"{}\", {} must be defined.", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name, cNumericFieldNames(1)));
    5969           0 :                 ErrorsFound = true;
    5970             :             }
    5971          40 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) &&
    5972           1 :                 (System(RefrigSysNum).TCondenseMin > Condenser(CondNum).RatedTCondense))
    5973           0 :                 ShowWarningError(state,
    5974           0 :                                  format("{}=\"{}\", The system specified minimum condensing temperature is greater than the rated condensing "
    5975             :                                         "temperature for the cascade condenser. ",
    5976             :                                         CurrentModuleObject,
    5977           0 :                                         System(RefrigSysNum).Name));
    5978             : 
    5979          39 :             AlphaNum = 6;
    5980          39 :             System(RefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    5981             :             // error messages for refrigerants already found in fluidproperties
    5982             : 
    5983          39 :             AlphaNum = 7;
    5984          39 :             if (!lAlphaBlanks(AlphaNum)) {
    5985          39 :                 if (Util::SameString(Alphas(AlphaNum), "ConstantSuctionTemperature")) {
    5986          37 :                     System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::ConstantSuctionTemperature;
    5987           2 :                 } else if (Util::SameString(Alphas(AlphaNum), "FloatSuctionTemperature")) {
    5988           2 :                     System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::FloatSuctionTemperature;
    5989           2 :                     if (System(RefrigSysNum).CoilFlag) {
    5990           0 :                         ShowWarningError(state,
    5991           0 :                                          format("{}=\"{}\", The system specified a FloatSuctionTemperature, but that is not available with air "
    5992             :                                                 "chiller loads so ConstantSuctionTemperature will be used. ",
    5993             :                                                 CurrentModuleObject,
    5994           0 :                                                 System(RefrigSysNum).Name));
    5995             :                     } // coilflag
    5996             :                 } else {
    5997           0 :                     ShowSevereError(state,
    5998           0 :                                     format("{}{}=\"{}\", invalid  {} not found = {}",
    5999             :                                            RoutineName,
    6000             :                                            CurrentModuleObject,
    6001           0 :                                            System(RefrigSysNum).Name,
    6002             :                                            cAlphaFieldNames(AlphaNum),
    6003             :                                            Alphas(AlphaNum)));
    6004           0 :                     ErrorsFound = true;
    6005             :                 }
    6006             :             } else {
    6007           0 :                 System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::ConstantSuctionTemperature; // Default for blank
    6008             :             }
    6009             : 
    6010             :             // Count subcoolers on system and allocate
    6011          39 :             AlphaNum = 8;
    6012          39 :             System(RefrigSysNum).NumSubcoolers = 0;
    6013          39 :             if (!lAlphaBlanks(AlphaNum)) {
    6014           1 :                 ++System(RefrigSysNum).NumSubcoolers;
    6015             :             }
    6016          39 :             if (!lAlphaBlanks(AlphaNum + 1)) {
    6017           1 :                 ++System(RefrigSysNum).NumSubcoolers;
    6018             :             }
    6019             : 
    6020          39 :             if (System(RefrigSysNum).NumSubcoolers > 0) {
    6021           1 :                 if (!allocated(System(RefrigSysNum).SubcoolerNum)) System(RefrigSysNum).SubcoolerNum.allocate(System(RefrigSysNum).NumSubcoolers);
    6022           1 :                 int NumSubcooler = 1;
    6023           1 :                 if (!lAlphaBlanks(AlphaNum)) {
    6024           1 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    6025           1 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum));
    6026           1 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    6027           0 :                         ShowSevereError(state,
    6028           0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    6029             :                                                RoutineName,
    6030             :                                                CurrentModuleObject,
    6031           0 :                                                System(RefrigSysNum).Name,
    6032             :                                                cAlphaFieldNames(AlphaNum),
    6033             :                                                Alphas(AlphaNum)));
    6034           0 :                         ErrorsFound = true;
    6035             :                     } else {
    6036           1 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    6037             :                     }
    6038           1 :                     ++NumSubcooler;
    6039             :                 }
    6040           1 :                 if (!lAlphaBlanks(AlphaNum + 1)) {
    6041           1 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    6042           1 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum + 1));
    6043           1 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    6044           0 :                         ShowSevereError(state,
    6045           0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    6046             :                                                RoutineName,
    6047             :                                                CurrentModuleObject,
    6048           0 :                                                System(RefrigSysNum).Name,
    6049             :                                                cAlphaFieldNames(AlphaNum + 1),
    6050             :                                                Alphas(AlphaNum + 1)));
    6051           0 :                         ErrorsFound = true;
    6052             :                     } else {
    6053           1 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    6054             :                     }
    6055             :                 }
    6056             :             }
    6057             : 
    6058             :             // Suction piping heat gain - optional
    6059             :             //  Input UA and identify the Zone containing the bulk of the suction piping
    6060             :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    6061             :             //  The pipe heat gains are also counted as cooling credit for the zone.
    6062             :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    6063             :             //  Get the Zone and zone node numbers from the zone name entered by the user
    6064          39 :             AlphaNum = 10;
    6065          39 :             System(RefrigSysNum).SumUASuctionPiping = 0.0;
    6066          39 :             if (!lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    6067           2 :                 System(RefrigSysNum).SumUASuctionPiping = Numbers(2);
    6068           2 :                 System(RefrigSysNum).SuctionPipeActualZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    6069           4 :                 System(RefrigSysNum).SuctionPipeZoneNodeNum =
    6070           2 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, System(RefrigSysNum).SuctionPipeActualZoneNum);
    6071           2 :                 if (System(RefrigSysNum).SuctionPipeZoneNodeNum == 0) {
    6072           0 :                     ShowSevereError(
    6073             :                         state,
    6074           0 :                         format("{}{}=\"{}\", System Node Number not found for {} = {} even though {} is greater than zero. Suction piping heat gain "
    6075             :                                "cannot be calculated unless a Zone is defined to deterimine the environmental temperature surrounding the piping.",
    6076             :                                RoutineName,
    6077             :                                CurrentModuleObject,
    6078           0 :                                System(RefrigSysNum).Name,
    6079             :                                cAlphaFieldNames(AlphaNum),
    6080             :                                Alphas(AlphaNum),
    6081             :                                cNumericFieldNames(2)));
    6082           0 :                     ErrorsFound = true;
    6083             :                 } else {
    6084           2 :                     state.dataRefrigCase->RefrigPresentInZone(System(RefrigSysNum).SuctionPipeActualZoneNum) = true;
    6085             :                 }
    6086          37 :             } else if (!lNumericBlanks(2) && lAlphaBlanks(AlphaNum)) {
    6087           0 :                 ShowWarningError(state,
    6088           0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero. Suction piping heat gain will not be "
    6089             :                                         "calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    6090             :                                         RoutineName,
    6091             :                                         CurrentModuleObject,
    6092           0 :                                         System(RefrigSysNum).Name,
    6093             :                                         cAlphaFieldNames(AlphaNum),
    6094             :                                         cNumericFieldNames(2)));
    6095          37 :             } else if (lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    6096           0 :                 ShowWarningError(state,
    6097           0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    6098             :                                         RoutineName,
    6099             :                                         CurrentModuleObject,
    6100           0 :                                         System(RefrigSysNum).Name,
    6101             :                                         cAlphaFieldNames(AlphaNum),
    6102             :                                         cNumericFieldNames(2)));
    6103             :             } // suction piping heat gains
    6104             : 
    6105          39 :             AlphaNum = 11;
    6106          39 :             if (!lAlphaBlanks(AlphaNum)) System(RefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    6107             : 
    6108             :             // Single-stage or two-stage compression system
    6109          39 :             if (!lNumericBlanks(3)) {
    6110           2 :                 System(RefrigSysNum).NumStages = Numbers(3);
    6111           2 :                 if (System(RefrigSysNum).NumStages < 1 || System(RefrigSysNum).NumStages > 2) {
    6112           0 :                     ShowSevereError(state,
    6113           0 :                                     format("{}{}=\"{}\", {}{}",
    6114             :                                            RoutineName,
    6115             :                                            CurrentModuleObject,
    6116           0 :                                            System(RefrigSysNum).Name,
    6117             :                                            cNumericFieldNames(3),
    6118             :                                            R"( has an invalid value.  Only \"1\" or \"2\" compressor stages are allowed.)"));
    6119           0 :                     ErrorsFound = true;
    6120             :                 }
    6121             :             } else {
    6122          37 :                 System(RefrigSysNum).NumStages = 1; // Default for blank
    6123             :             }
    6124             : 
    6125             :             // Intercooler type
    6126             :             // None (0) for single-stage compression systems
    6127             :             // Flash intercooler (1) or coil-and-shell intercooler (2) for two-stage compression systems
    6128          39 :             AlphaNum = 12;
    6129          39 :             if (!lAlphaBlanks(AlphaNum)) {
    6130           2 :                 if (Util::SameString(Alphas(AlphaNum), "None")) {
    6131           0 :                     System(RefrigSysNum).IntercoolerType = 0;
    6132           2 :                 } else if (Util::SameString(Alphas(AlphaNum), "Flash Intercooler")) {
    6133           1 :                     System(RefrigSysNum).IntercoolerType = 1;
    6134           1 :                 } else if (Util::SameString(Alphas(AlphaNum), "Shell-and-Coil Intercooler")) {
    6135           1 :                     System(RefrigSysNum).IntercoolerType = 2;
    6136             :                 } else {
    6137           0 :                     ShowSevereError(state,
    6138           0 :                                     format("{}{}=\"{}\", Invalid {} specified.",
    6139             :                                            RoutineName,
    6140             :                                            CurrentModuleObject,
    6141           0 :                                            System(RefrigSysNum).Name,
    6142             :                                            cAlphaFieldNames(AlphaNum)));
    6143           0 :                     ShowContinueError(state, format("\"{}\" is not a recognized intercooler type.", Alphas(AlphaNum)));
    6144           0 :                     ErrorsFound = true;
    6145             :                 }
    6146             :             } else {
    6147          37 :                 System(RefrigSysNum).IntercoolerType = 0; // Default for blank
    6148             :             }
    6149             : 
    6150          39 :             if (System(RefrigSysNum).NumStages == 1 && (System(RefrigSysNum).IntercoolerType == 1 || System(RefrigSysNum).IntercoolerType == 2)) {
    6151           0 :                 ShowSevereError(
    6152           0 :                     state, format("{}{}=\"{}\", A single-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    6153           0 :                 ShowContinueError(state, "has been specified with an intercooler.  Verify that the number of compressor stages");
    6154           0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    6155           0 :                 ErrorsFound = true;
    6156          39 :             } else if (System(RefrigSysNum).NumStages == 2 && System(RefrigSysNum).IntercoolerType == 0) {
    6157           0 :                 ShowSevereError(state,
    6158           0 :                                 format("{}{}=\"{}\", A two-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    6159           0 :                 ShowContinueError(state, "has been specified without an intercooler.  Verify that the number of compressor stages");
    6160           0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    6161           0 :                 ErrorsFound = true;
    6162             :             }
    6163             : 
    6164             :             // Shell-and-coil intercooler effectiveness
    6165          39 :             if (!lNumericBlanks(4)) {
    6166           1 :                 System(RefrigSysNum).IntercoolerEffectiveness = Numbers(4);
    6167           1 :                 if (System(RefrigSysNum).IntercoolerEffectiveness < 0.0 || System(RefrigSysNum).IntercoolerEffectiveness > 1.0) {
    6168           0 :                     ShowWarningError(state,
    6169           0 :                                      format("{}{}=\"{}\", The specified value for the", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    6170           0 :                     ShowContinueError(
    6171             :                         state,
    6172           0 :                         format("{} = {:.2R} is invalid.  This value must be", cNumericFieldNames(4), System(RefrigSysNum).IntercoolerEffectiveness));
    6173           0 :                     ShowContinueError(state, "between 0.0 and 1.0.  The default value of 0.8 will be used.");
    6174           0 :                     System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    6175             :                 }
    6176             :             } else {
    6177          38 :                 System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    6178             :             }
    6179             : 
    6180             :             // Read the high-stage compressor info, if two-stage compression has been specified.
    6181          39 :             AlphaNum = 13;
    6182          39 :             int NumHiStageCompressorsSys = 0;
    6183          39 :             if (System(RefrigSysNum).NumStages == 2) {
    6184           2 :                 if (lAlphaBlanks(AlphaNum)) {
    6185             :                     // blank input where must have high-stage compressor or compressor list input.
    6186           0 :                     ShowSevereError(state,
    6187           0 :                                     format("{}{}=\"{}\", {} must be input for two-stage compression systems.",
    6188             :                                            RoutineName,
    6189             :                                            CurrentModuleObject,
    6190           0 :                                            System(RefrigSysNum).Name,
    6191             :                                            cAlphaFieldNames(AlphaNum)));
    6192           0 :                     ErrorsFound = true;
    6193             :                 } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    6194           2 :                     int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6195           2 :                     int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6196           2 :                     if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6197           0 :                         ShowSevereError(state,
    6198           0 :                                         format(R"({}{}="{}", {} has an invalid or undefined value="{}".)",
    6199             :                                                RoutineName,
    6200             :                                                CurrentModuleObject,
    6201           0 :                                                System(RefrigSysNum).Name,
    6202             :                                                cAlphaFieldNames(AlphaNum),
    6203             :                                                Alphas(AlphaNum)));
    6204           0 :                         ErrorsFound = true;
    6205           2 :                     } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6206           0 :                         ShowSevereError(state,
    6207           0 :                                         format(R"({}{}="{}", {} has a non-unique name used for both Compressor and CompressorList name: "{}".)",
    6208             :                                                RoutineName,
    6209             :                                                CurrentModuleObject,
    6210           0 :                                                System(RefrigSysNum).Name,
    6211             :                                                cAlphaFieldNames(AlphaNum),
    6212             :                                                Alphas(AlphaNum)));
    6213           0 :                         ErrorsFound = true;
    6214           2 :                     } else if (ListNum != 0) {
    6215           2 :                         NumHiStageCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6216           2 :                         System(RefrigSysNum).NumHiStageCompressors = NumHiStageCompressorsSys;
    6217           2 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum))
    6218           2 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    6219           4 :                         System(RefrigSysNum).HiStageCompressorNum({1, NumHiStageCompressorsSys}) =
    6220           6 :                             CompressorLists(ListNum).CompItemNum({1, NumHiStageCompressorsSys});
    6221           0 :                     } else if (CompNum != 0) {
    6222           0 :                         NumHiStageCompressorsSys = 1;
    6223           0 :                         System(RefrigSysNum).NumHiStageCompressors = 1;
    6224           0 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum))
    6225           0 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    6226           0 :                         System(RefrigSysNum).HiStageCompressorNum(NumHiStageCompressorsSys) = CompNum;
    6227             :                     }
    6228             :                 }
    6229             :             }
    6230             : 
    6231             :             // Determine intercooler pressure and temperature at design conditions
    6232          39 :             if (System(RefrigSysNum).NumStages == 2) {
    6233           2 :                 Real64 PCond = FluidProperties::GetSatPressureRefrig(state,
    6234           2 :                                                                      System(RefrigSysNum).RefrigerantName,
    6235           2 :                                                                      Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense,
    6236           2 :                                                                      System(RefrigSysNum).RefIndex,
    6237             :                                                                      RoutineName);
    6238           2 :                 Real64 PEvap = FluidProperties::GetSatPressureRefrig(
    6239           2 :                     state, System(RefrigSysNum).RefrigerantName, System(RefrigSysNum).TEvapDesign, System(RefrigSysNum).RefIndex, RoutineName);
    6240           2 :                 System(RefrigSysNum).PIntercooler = std::sqrt(PCond * PEvap);
    6241           2 :                 System(RefrigSysNum).TIntercooler = FluidProperties::GetSatTemperatureRefrig(
    6242           2 :                     state, System(RefrigSysNum).RefrigerantName, System(RefrigSysNum).PIntercooler, System(RefrigSysNum).RefIndex, RoutineName);
    6243             :             } // NumStages
    6244             : 
    6245             :             // Sum capacity of single-stage compressors or low-stage compressors if two-stage system
    6246          39 :             Real64 NominalTotalCompCap = 0.0;
    6247         199 :             for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6248         160 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6249         160 :                 if (!Compressor(CompNum).TransFlag) {          //  Subcritical Compressor
    6250         160 :                     if (System(RefrigSysNum).NumStages == 1) { //  Single-stage compression
    6251         154 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6252         154 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6253         154 :                                                                        System(RefrigSysNum).TEvapDesign,
    6254         154 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6255         154 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6256         154 :                         ++Compressor(CompNum).NumSysAttach;
    6257             :                     } else { //  Two-stage compression, low-stage compressors
    6258           6 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6259           6 :                             state, Compressor(CompNum).CapacityCurvePtr, System(RefrigSysNum).TEvapDesign, System(RefrigSysNum).TIntercooler);
    6260           6 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6261           6 :                         ++Compressor(CompNum).NumSysAttach;
    6262             :                     }    // NumStages
    6263             :                 } else { //  Transcritical compressor attached to subcritical refigeration cycle
    6264           0 :                     ShowSevereError(state,
    6265           0 :                                     format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    6266             :                                            RoutineName,
    6267             :                                            CurrentModuleObject));
    6268           0 :                     ShowContinueError(state,
    6269             :                                       "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    6270             :                                       "transcritical compressors are connected only to transcritical systems.");
    6271           0 :                     ErrorsFound = true;
    6272             :                 } // .NOT. Compressor(CompNum)%TransFlag
    6273             :             }
    6274             : 
    6275          39 :             Real64 NominalTotalHiStageCompCap(0.0); // Total of nominal high-stage compressor capacities, used for rough input check (W)
    6276             : 
    6277             :             // Sum capacity of high-stage compressors if two stage system
    6278          39 :             if (System(RefrigSysNum).NumStages == 2) {
    6279          10 :                 for (int CompIndex = 1; CompIndex <= NumHiStageCompressorsSys; ++CompIndex) {
    6280           8 :                     int CompNum = System(RefrigSysNum).HiStageCompressorNum(CompIndex);
    6281           8 :                     if (!Compressor(CompNum).TransFlag) { //  Subcritical Compressor
    6282           8 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6283           8 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6284           8 :                                                                        System(RefrigSysNum).TIntercooler,
    6285           8 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6286           8 :                         NominalTotalHiStageCompCap += Compressor(CompNum).NomCap;
    6287           8 :                         ++Compressor(CompNum).NumSysAttach;
    6288             :                     } else { //  Transcritical compressor attached to subcritical refigeration cycle
    6289           0 :                         ShowSevereError(state,
    6290           0 :                                         format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    6291             :                                                RoutineName,
    6292             :                                                CurrentModuleObject));
    6293           0 :                         ShowContinueError(state,
    6294             :                                           "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    6295             :                                           "transcritical compressors are connected only to transcritical systems.");
    6296           0 :                         ErrorsFound = true;
    6297             :                     }
    6298             :                 }
    6299             :             } // NumStages
    6300             : 
    6301             :             // Compare the rated capacity of compressor, condenser, and cases.
    6302             :             // Note, rated capacities can be far off from operating capacities, but rough check.
    6303          39 :             Real64 NominalCondCap = Condenser(System(RefrigSysNum).CondenserNum(1)).RatedCapacity;
    6304          39 :             if (System(RefrigSysNum).SystemRejectHeatToZone) NominalCondCap *= 2.0;
    6305          39 :             if (System(RefrigSysNum).NumStages == 1) { // Single-stage system
    6306          37 :                 if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6307           2 :                     ShowWarningError(state,
    6308           2 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    6309             :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6310             :                                             CurrentModuleObject,
    6311           1 :                                             System(RefrigSysNum).Name,
    6312             :                                             NominalTotalCoolingCap,
    6313             :                                             NominalCondCap,
    6314             :                                             NominalTotalCompCap));
    6315             :                 }
    6316           2 :             } else if (System(RefrigSysNum).NumStages == 2) { // Two-stage system
    6317           2 :                 if ((NominalTotalHiStageCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6318           0 :                     ShowWarningError(state,
    6319           0 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    6320             :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6321             :                                             CurrentModuleObject,
    6322           0 :                                             System(RefrigSysNum).Name,
    6323             :                                             NominalTotalCoolingCap,
    6324             :                                             NominalCondCap,
    6325             :                                             NominalTotalCompCap));
    6326             :                 }
    6327             :             } // NumStages
    6328             : 
    6329             :         } // Refrigeration systems
    6330             : 
    6331             :         // Assign coilflags to compressors, condensers, and subcoolers (coils calc on sys time step, all other refrig loads on zone time step, so
    6332             :         // can't mix on one system) need to do here once again after all cascade condensers and cascade sink systems have been identified
    6333          54 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    6334             :             // assign flags to all condensers to match system below condenser (system rejecting heat to cascade condenser)
    6335          39 :             int CondNum = System(RefrigSysNum).CondenserNum(1); // right now only have one condenser per system
    6336          39 :             Condenser(CondNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    6337         199 :             for (int CompIndex = 1; CompIndex <= System(RefrigSysNum).NumCompressors; ++CompIndex) {
    6338         160 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6339         160 :                 Compressor(CompNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    6340             :             }
    6341             : 
    6342             :         } // assign coil flags to all condensers
    6343             : 
    6344             :         // Finished setting cascade condenser coilflags to match system rejecting heat to the cascade condenser
    6345             :         // Now have to see if there's a mismatch in the coilflag with the system absorbing heat from the cascade condenser
    6346             :         // 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
    6347             :         // 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)
    6348          54 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems;
    6349             :              ++RefrigSysNum) { // check flags for systems reflect all cascade loads
    6350          39 :             if (System(RefrigSysNum).NumCascadeLoads == 0) continue;
    6351           1 :             if (System(RefrigSysNum).CoilFlag) { // system already identified as serving coils
    6352           0 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
    6353           0 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) continue;
    6354           0 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) continue; // this condenser is not a cascade load on this system
    6355           0 :                     if (!Condenser(CondID).CoilFlag) {
    6356             :                         // would mean system already serving coil loads and this condenser cooling system with case-type loads
    6357           0 :                         ShowSevereError(state,
    6358           0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    6359             :                                                "time step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    6360             :                                                RoutineName,
    6361             :                                                CurrentModuleObject,
    6362           0 :                                                System(RefrigSysNum).Name,
    6363           0 :                                                Condenser(CondID).Name));
    6364           0 :                         ErrorsFound = true;
    6365             :                     }
    6366             :                 }    // CondID
    6367             :             } else { // %coilflag == false, so no coil loads prev identified directly or through secondary loop
    6368             :                 // Flag to help verify load type with loads served by systems cooled by cascade condensers
    6369           1 :                 bool CaseLoads = false;
    6370           1 :                 int NumCascadeLoadsChecked = 0;
    6371           4 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) { // look at All cascade condenser loads on system
    6372           3 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) continue;
    6373           1 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) continue; // this condenser is not a cascade load on this system
    6374           1 :                     ++NumCascadeLoadsChecked;
    6375           1 :                     if ((CaseLoads) && (!Condenser(CondID).CoilFlag) && (!System(RefrigSysNum).CoilFlag)) continue;
    6376             :                     // all loads to date are case-type and properly flagged with consistent coilflags
    6377             :                     //(note caseloads could be true if prev cascade load checked is serving a case-type system)
    6378           1 :                     if (NumCascadeLoadsChecked == 1) {
    6379           1 :                         if (Condenser(CondID).CoilFlag) {
    6380           0 :                             System(RefrigSysNum).CoilFlag = true;
    6381             :                             // setting system coilflag if 1st cascade condenser served has coils (system has no case-type loads up to this point)
    6382             :                         } else { // condenser is not serving coils, but case-type loads
    6383           1 :                             CaseLoads = true;
    6384             :                             // system coilflag already set to false
    6385             :                         }    // Condenser%CoilFlag
    6386             :                     } else { // numcascadeloadschecked > 1
    6387           0 :                         if (System(RefrigSysNum).CoilFlag != Condenser(CondID).CoilFlag) {
    6388           0 :                             ShowSevereError(
    6389             :                                 state,
    6390           0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    6391             :                                        "step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    6392             :                                        RoutineName,
    6393             :                                        CurrentModuleObject,
    6394           0 :                                        System(RefrigSysNum).Name,
    6395           0 :                                        Condenser(CondID).Name));
    6396           0 :                             ErrorsFound = true;
    6397             :                         }
    6398             :                     } // numcascadeloadschecked > 1
    6399             :                 }     // CondID
    6400             :             }         //(System%coilflag)
    6401             :         }             // Refrigeration systems checking coilflag consistency with cascade condenser loads
    6402             : 
    6403             :     } //(NumRefrigSystems > 0)
    6404             : 
    6405             :     // after the systems have been read, can finish the mechanical subcooler/system interactions
    6406             :     // System%NumMechSCServed=0
    6407         796 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    6408           3 :         for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6409           2 :             if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) continue;
    6410           2 :             Subcooler(SubcoolerNum).MechSourceSysID =
    6411           1 :                 state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:System", Subcooler(SubcoolerNum).MechSourceSys);
    6412           1 :             if (Subcooler(SubcoolerNum).MechSourceSysID == 0) {
    6413           0 :                 ShowSevereError(state,
    6414           0 :                                 format(R"({}{}="{}", Mechanical Subcooler has an invalid Source Refrigeration:System="{}".)",
    6415             :                                        RoutineName,
    6416             :                                        CurrentModuleObject,
    6417           0 :                                        Subcooler(SubcoolerNum).Name,
    6418           0 :                                        Subcooler(SubcoolerNum).MechSourceSys));
    6419           0 :                 ErrorsFound = true;
    6420             :             } else {
    6421           1 :                 if (System(Subcooler(SubcoolerNum).MechSourceSysID).CoilFlag != Subcooler(SubcoolerNum).CoilFlag) {
    6422           0 :                     ShowSevereError(state,
    6423           0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    6424             :                                            "step than case or walkin loads. Compare loads on system served by mechanical subcooler \"{}",
    6425             :                                            RoutineName,
    6426             :                                            CurrentModuleObject,
    6427           0 :                                            System(RefrigSysNum).Name,
    6428           0 :                                            Subcooler(SubcoolerNum).Name));
    6429           0 :                     ErrorsFound = true;
    6430             :                 }
    6431             :             } // error check
    6432             :         }     // numsubcoolers
    6433             : 
    6434           3 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    6435           6 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6436           4 :                 if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) continue;
    6437           2 :                 if (Subcooler(SubcoolerNum).MechSourceSysID == RefrigSysNum) {
    6438           1 :                     ++System(RefrigSysNum).NumMechSCServed;
    6439             :                 }
    6440             :             }
    6441           2 :             if (System(RefrigSysNum).NumMechSCServed > 0) {
    6442           1 :                 if (!allocated(System(RefrigSysNum).MechSCLoad))
    6443           1 :                     System(RefrigSysNum).MechSCLoad.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
    6444             :             }
    6445             :         }
    6446             :     } // NumSimulationSubcoolers > 0
    6447             : 
    6448             :     // **********  READ TRANSCRITICAL REFRIGERATION SYSTEMS  **********
    6449             : 
    6450         796 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    6451           1 :         CurrentModuleObject = "Refrigeration:TranscriticalSystem";
    6452           2 :         for (int TransRefrigSysNum = 1; TransRefrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransRefrigSysNum) {
    6453           1 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    6454             :                                                                      CurrentModuleObject,
    6455             :                                                                      TransRefrigSysNum,
    6456             :                                                                      Alphas,
    6457             :                                                                      NumAlphas,
    6458             :                                                                      Numbers,
    6459             :                                                                      NumNumbers,
    6460             :                                                                      IOStatus,
    6461             :                                                                      lNumericBlanks,
    6462             :                                                                      lAlphaBlanks,
    6463             :                                                                      cAlphaFieldNames,
    6464             :                                                                      cNumericFieldNames);
    6465           1 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    6466             : 
    6467           1 :             TransSystem(TransRefrigSysNum).Name = Alphas(1);
    6468             : 
    6469             :             // Read refrigerant for this system
    6470           1 :             AlphaNum = 8;
    6471           1 :             TransSystem(TransRefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    6472             :             // error messages for refrigerants already found in fluidproperties
    6473             : 
    6474             :             // Read Transcritical System Type:  SingleStage or TwoStage
    6475           1 :             if (lAlphaBlanks(2)) {
    6476             :                 // No system type specified
    6477           0 :                 ShowSevereError(
    6478             :                     state,
    6479           0 :                     format("{}{}=\"{}\", has no system type specified.", RoutineName, CurrentModuleObject, TransSystem(TransRefrigSysNum).Name));
    6480           0 :                 ShowContinueError(state, R"(  System type must be specified as "SingleStage" or "TwoStage".)");
    6481           0 :                 ErrorsFound = true;
    6482             :             }
    6483           1 :             if (Util::SameString(Alphas(2), "SingleStage")) {
    6484           0 :                 TransSystem(TransRefrigSysNum).TransSysType = 1;
    6485           1 :             } else if (Util::SameString(Alphas(2), "TwoStage")) {
    6486           1 :                 TransSystem(TransRefrigSysNum).TransSysType = 2;
    6487             :             } else {
    6488           0 :                 ShowSevereError(state,
    6489           0 :                                 format(R"({}{}="{}", has an incorrect System Type specified as "{}".)",
    6490             :                                        RoutineName,
    6491             :                                        CurrentModuleObject,
    6492           0 :                                        TransSystem(TransRefrigSysNum).Name,
    6493             :                                        Alphas(2)));
    6494           0 :                 ShowContinueError(state, R"(  System type must be specified as "SingleStage" or "TwoStage".)");
    6495           0 :                 ErrorsFound = true;
    6496             :             }
    6497             : 
    6498             :             // Read all loads (display cases and walk-ins) on this Transcritical System
    6499           1 :             if (lAlphaBlanks(3) && lAlphaBlanks(4)) {
    6500             :                 // No loads specified - display error
    6501           0 :                 ShowSevereError(state, format("{}{}=\"{}\", has no loads.", RoutineName, CurrentModuleObject, TransSystem(TransRefrigSysNum).Name));
    6502           0 :                 ShowContinueError(
    6503           0 :                     state, format("  The system must have at least one of: {} or {} objects attached.", cAlphaFieldNames(3), cAlphaFieldNames(4)));
    6504           0 :                 ErrorsFound = true;
    6505           1 :             } else if (lAlphaBlanks(3) && TransSystem(TransRefrigSysNum).TransSysType == 1) {
    6506             :                 // No medium temperature loads specified for a SingleStage system - display error
    6507           0 :                 ShowSevereError(state,
    6508           0 :                                 format("{}{}=\"{}{}",
    6509             :                                        RoutineName,
    6510             :                                        CurrentModuleObject,
    6511           0 :                                        TransSystem(TransRefrigSysNum).Name,
    6512             :                                        R"(", is a "SingleStage" system but no medium temperature loads are specified.)"));
    6513           0 :                 ShowContinueError(state, format("  The system must have at least one {} object attached.", cAlphaFieldNames(3)));
    6514           0 :                 ErrorsFound = true;
    6515           1 :             } else if (lAlphaBlanks(4) && TransSystem(TransRefrigSysNum).TransSysType == 2) {
    6516             :                 // No low temperature loads specified for a TwoStage system - display error
    6517           0 :                 ShowSevereError(state,
    6518           0 :                                 format("{}{}=\"{}{}",
    6519             :                                        RoutineName,
    6520             :                                        CurrentModuleObject,
    6521           0 :                                        TransSystem(TransRefrigSysNum).Name,
    6522             :                                        R"(", is a "TwoStage" system but no low temperature loads are specified.)"));
    6523           0 :                 ShowContinueError(state, format("  The system must have at least one {} object attached.", cAlphaFieldNames(4)));
    6524           0 :                 ErrorsFound = true;
    6525             :             }
    6526             : 
    6527           1 :             int NumCasesMT = 0;
    6528           1 :             TransSystem(TransRefrigSysNum).NumCasesMT = 0;
    6529           1 :             int NumCasesLT = 0;
    6530           1 :             TransSystem(TransRefrigSysNum).NumCasesLT = 0;
    6531           1 :             int NumWalkInsMT = 0;
    6532           1 :             TransSystem(TransRefrigSysNum).NumWalkInsMT = 0;
    6533           1 :             int NumWalkInsLT = 0;
    6534           1 :             TransSystem(TransRefrigSysNum).NumWalkInsLT = 0;
    6535           1 :             Real64 NominalTotalCaseCapMT = 0.0;
    6536           1 :             Real64 NominalTotalCaseCapLT = 0.0;
    6537           1 :             Real64 NominalTotalWalkInCapMT = 0.0;
    6538           1 :             Real64 NominalTotalWalkInCapLT = 0.0;
    6539             :             Real64 NominalTotalCoolingCap;
    6540           1 :             TransSystem(TransRefrigSysNum).RefInventory = 0.0;
    6541             : 
    6542             :             //   Check for Medium Temperature Case or Walk-In or CaseAndWalkInList names
    6543           1 :             AlphaNum = 3;
    6544             : 
    6545           1 :             if (!lAlphaBlanks(AlphaNum)) {
    6546             : 
    6547             :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6548           1 :                 int CaseAndWalkInListNum = 0;
    6549           1 :                 int CaseNum = 0;
    6550           1 :                 int WalkInNum = 0;
    6551           1 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    6552           1 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6553           1 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6554           1 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6555           1 :                 int NumNameMatches = 0;
    6556           1 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    6557           1 :                 if (CaseNum != 0) ++NumNameMatches;
    6558           1 :                 if (WalkInNum != 0) ++NumNameMatches;
    6559             : 
    6560           1 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    6561           0 :                     ErrorsFound = true;
    6562           0 :                     if (NumNameMatches == 0) {
    6563           0 :                         ShowSevereError(state,
    6564           0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    6565             :                                                RoutineName,
    6566             :                                                CurrentModuleObject,
    6567           0 :                                                TransSystem(TransRefrigSysNum).Name,
    6568             :                                                cAlphaFieldNames(AlphaNum),
    6569             :                                                Alphas(AlphaNum)));
    6570           0 :                     } else if (NumNameMatches > 1) {
    6571           0 :                         ShowSevereError(state,
    6572           0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    6573             :                                                RoutineName,
    6574             :                                                CurrentModuleObject,
    6575           0 :                                                TransSystem(TransRefrigSysNum).Name,
    6576             :                                                cAlphaFieldNames(AlphaNum),
    6577             :                                                Alphas(AlphaNum)));
    6578             :                     }                                   // num matches = 0 or > 1
    6579           1 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6580           1 :                     NumCasesMT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6581           1 :                     NumWalkInsMT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6582           1 :                     TransSystem(TransRefrigSysNum).NumCasesMT = NumCasesMT;
    6583           1 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = NumWalkInsMT;
    6584           1 :                     if (NumCasesMT > 0) {
    6585           1 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6586           2 :                         TransSystem(TransRefrigSysNum).CaseNumMT({1, NumCasesMT}) =
    6587           3 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesMT});
    6588             :                     }
    6589           1 :                     if (NumWalkInsMT > 0) {
    6590           0 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6591           0 :                         TransSystem(TransRefrigSysNum).WalkInNumMT({1, NumWalkInsMT}) =
    6592           0 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsMT});
    6593             :                     }
    6594           0 :                 } else if (CaseNum != 0) { // Name points to a case
    6595           0 :                     NumCasesMT = 1;
    6596           0 :                     TransSystem(TransRefrigSysNum).NumCasesMT = 1;
    6597           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6598           0 :                     TransSystem(TransRefrigSysNum).CaseNumMT(NumCases) = CaseNum;
    6599           0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6600           0 :                     NumWalkInsMT = 1;
    6601           0 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = 1;
    6602           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6603           0 :                     TransSystem(TransRefrigSysNum).WalkInNumMT(NumWalkIns) = WalkInNum;
    6604             :                 } // NumNameMatches /= 1
    6605             :             }     // blank input for cases, walkins, or caseandwalkinlist
    6606             : 
    6607           1 :             if (NumCasesMT > 0) {
    6608             :                 // Find lowest design evap T
    6609             :                 // Sum rated capacity of all MT cases on system
    6610           4 :                 for (int caseIndex = 1; caseIndex <= NumCasesMT; ++caseIndex) {
    6611             :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6612           3 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumMT(caseIndex);
    6613           3 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6614           3 :                     NominalTotalCaseCapMT += RefrigCase(CaseNum).DesignRatedCap;
    6615           3 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6616           3 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6617           1 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = RefrigCase(CaseNum).EvapTempDesign;
    6618             :                     } else {
    6619           2 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6620           2 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6621             :                     }
    6622             :                 } // CaseIndex=1,NumCases
    6623             :             }     // NumcasesMT > 0
    6624             : 
    6625           1 :             if (NumWalkInsMT > 0) {
    6626           0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsMT; ++WalkInIndex) {
    6627           0 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumMT(WalkInIndex);
    6628             :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6629           0 :                     ++WalkIn(WalkInID).NumSysAttach;
    6630           0 :                     NominalTotalWalkInCapMT += WalkIn(WalkInID).DesignRatedCap;
    6631           0 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6632             :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6633             :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6634             :                     //  to either the rack or system.
    6635             :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6636           0 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6637             :                         // - 99 used as a flag for blank input error message for detailed systems
    6638           0 :                         ShowSevereError(state,
    6639           0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6640             :                                                "electric and hotfluid defrost types",
    6641             :                                                RoutineName,
    6642           0 :                                                WalkIn(WalkInID).Name));
    6643           0 :                         ErrorsFound = true;
    6644             :                     }
    6645             :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6646           0 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesMT == 0)) {
    6647             :                         // note use walk in index, not walkinid here to get
    6648             :                         // first walkin on this suction group/system
    6649           0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = WalkIn(WalkInID).TEvapDesign;
    6650             :                     } else {
    6651           0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6652           0 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6653             :                     }
    6654             :                 } // WalkInIndex=1,NumWalkIns
    6655             :             }     // NumWalkInsMT > 0
    6656             : 
    6657             :             //   Check for Low Temperature Case or Walk-In or CaseAndWalkInList names
    6658           1 :             AlphaNum = 4;
    6659           1 :             if (!lAlphaBlanks(AlphaNum)) {
    6660             : 
    6661             :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6662           1 :                 int CaseAndWalkInListNum = 0;
    6663           1 :                 int CaseNum = 0;
    6664           1 :                 int WalkInNum = 0;
    6665           1 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0)
    6666           1 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6667           1 :                 if (state.dataRefrigCase->NumSimulationCases > 0) CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6668           1 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6669           1 :                 int NumNameMatches = 0;
    6670           1 :                 if (CaseAndWalkInListNum != 0) ++NumNameMatches;
    6671           1 :                 if (CaseNum != 0) ++NumNameMatches;
    6672           1 :                 if (WalkInNum != 0) ++NumNameMatches;
    6673             : 
    6674           1 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    6675           0 :                     ErrorsFound = true;
    6676           0 :                     if (NumNameMatches == 0) {
    6677           0 :                         ShowSevereError(state,
    6678           0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    6679             :                                                RoutineName,
    6680             :                                                CurrentModuleObject,
    6681           0 :                                                TransSystem(TransRefrigSysNum).Name,
    6682             :                                                cAlphaFieldNames(AlphaNum),
    6683             :                                                Alphas(AlphaNum)));
    6684           0 :                     } else if (NumNameMatches > 1) {
    6685           0 :                         ShowSevereError(state,
    6686           0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    6687             :                                                RoutineName,
    6688             :                                                CurrentModuleObject,
    6689           0 :                                                TransSystem(TransRefrigSysNum).Name,
    6690             :                                                cAlphaFieldNames(AlphaNum),
    6691             :                                                Alphas(AlphaNum)));
    6692             :                     }                                   // num matches = 0 or > 1
    6693           1 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6694           1 :                     NumCasesLT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6695           1 :                     NumWalkInsLT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6696           1 :                     TransSystem(TransRefrigSysNum).NumCasesLT = NumCasesLT;
    6697           1 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = NumWalkInsLT;
    6698           1 :                     if (NumCasesLT > 0) {
    6699           1 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6700           2 :                         TransSystem(TransRefrigSysNum).CaseNumLT({1, NumCasesLT}) =
    6701           3 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesLT});
    6702             :                     }
    6703           1 :                     if (NumWalkInsLT > 0) {
    6704           1 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6705           2 :                         TransSystem(TransRefrigSysNum).WalkInNumLT({1, NumWalkInsLT}) =
    6706           3 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsLT});
    6707             :                     }
    6708           0 :                 } else if (CaseNum != 0) { // Name points to a case
    6709           0 :                     NumCasesLT = 1;
    6710           0 :                     TransSystem(TransRefrigSysNum).NumCasesLT = 1;
    6711           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6712           0 :                     TransSystem(TransRefrigSysNum).CaseNumLT(NumCases) = CaseNum;
    6713           0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6714           0 :                     NumWalkInsLT = 1;
    6715           0 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = 1;
    6716           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6717           0 :                     TransSystem(TransRefrigSysNum).WalkInNumLT(NumWalkIns) = WalkInNum;
    6718             :                 } // NumNameMatches /= 1
    6719             :             }     // blank input for cases, walkins, or caseandwalkinlist
    6720             : 
    6721           1 :             if (NumCasesLT > 0) {
    6722             :                 // Find lowest design evap T
    6723             :                 // Sum rated capacity of all LT cases on system
    6724           5 :                 for (int caseIndex = 1; caseIndex <= NumCasesLT; ++caseIndex) {
    6725             :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6726           4 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumLT(caseIndex);
    6727           4 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6728           4 :                     NominalTotalCaseCapLT += RefrigCase(CaseNum).DesignRatedCap;
    6729           4 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6730           4 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6731           1 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = RefrigCase(CaseNum).EvapTempDesign;
    6732             :                     } else {
    6733           3 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6734           3 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6735             :                     }
    6736             :                 } // CaseIndex=1,NumCases
    6737             :             }     // NumcasesLT > 0
    6738             : 
    6739           1 :             if (NumWalkInsLT > 0) {
    6740           2 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsLT; ++WalkInIndex) {
    6741           1 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumLT(WalkInIndex);
    6742             :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6743           1 :                     ++WalkIn(WalkInID).NumSysAttach;
    6744           1 :                     NominalTotalWalkInCapLT += WalkIn(WalkInID).DesignRatedCap;
    6745           1 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6746             :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6747             :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6748             :                     //  to either the rack or system.
    6749             :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6750           1 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6751             :                         // - 99 used as a flag for blank input error message for detailed systems
    6752           0 :                         ShowSevereError(state,
    6753           0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6754             :                                                "electric and hotfluid defrost types",
    6755             :                                                RoutineName,
    6756           0 :                                                WalkIn(WalkInID).Name));
    6757           0 :                         ErrorsFound = true;
    6758             :                     }
    6759             :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6760           1 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesLT == 0)) {
    6761             :                         // note use walk in index, not walkinid here to get
    6762             :                         // first walkin on this suction group/system
    6763           0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = WalkIn(WalkInID).TEvapDesign;
    6764             :                     } else {
    6765           1 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6766           1 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6767             :                     }
    6768             :                 } // WalkInIndex=1,NumWalkIns
    6769             :             }     // NumWalkInsMT > 0
    6770             : 
    6771           1 :             NominalTotalCoolingCap = NominalTotalCaseCapMT + NominalTotalCaseCapLT + NominalTotalWalkInCapMT + NominalTotalWalkInCapLT;
    6772             : 
    6773             :             // Read Gas Cooler
    6774             :             // currently assumes one gas cooler per refrigeration system and but multiple systems allowed per gas cooler
    6775           1 :             AlphaNum = 5;
    6776           1 :             int NumGasCoolers = 1;
    6777           1 :             if (!allocated(TransSystem(TransRefrigSysNum).GasCoolerNum)) TransSystem(TransRefrigSysNum).GasCoolerNum.allocate(NumGasCoolers);
    6778           1 :             TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6779             :             // Find gascooler number
    6780           1 :             int GCNum = Util::FindItemInList(Alphas(AlphaNum), GasCooler);
    6781             : 
    6782           1 :             if (GCNum == 0) { //  Invalid Gas Cooler attached to Transcritical Refrigeration System
    6783           0 :                 ShowSevereError(state,
    6784           0 :                                 format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    6785             :                                        RoutineName,
    6786             :                                        CurrentModuleObject,
    6787           0 :                                        TransSystem(TransRefrigSysNum).Name,
    6788             :                                        cAlphaFieldNames(AlphaNum),
    6789             :                                        Alphas(AlphaNum)));
    6790           0 :                 ErrorsFound = true;
    6791           1 :             } else if (GCNum != 0) { //  Gas Cooler attached to Transcritical Refrigeration System
    6792           1 :                 TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers) = GCNum;
    6793           1 :                 TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6794             :                 // Now take care of case where multiple systems share a gas cooler
    6795           1 :                 ++GasCooler(GCNum).NumSysAttach;
    6796           1 :                 GasCooler(GCNum).SysNum(GasCooler(GCNum).NumSysAttach) = TransRefrigSysNum;
    6797           2 :                 TransSystem(TransRefrigSysNum).RefInventory +=
    6798           1 :                     GasCooler(GCNum).RefReceiverInventory + GasCooler(GCNum).RefPipingInventory + GasCooler(GCNum).RefOpCharge;
    6799           1 :                 if (GasCooler(GCNum).GasCoolerRejectHeatToZone) TransSystem(TransRefrigSysNum).SystemRejectHeatToZone = true;
    6800             :             }
    6801             : 
    6802             :             // Read High Pressure Compressor
    6803           1 :             AlphaNum = 6;
    6804           1 :             int NumCompressorsSys = 0;
    6805           1 :             if (lAlphaBlanks(AlphaNum)) {
    6806             :                 // blank input where must have compressor or compressor list input.
    6807           0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    6808           0 :                 ErrorsFound = true;
    6809             :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    6810           1 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6811           1 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6812           1 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6813           0 :                     ShowSevereError(state,
    6814           0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6815             :                                            RoutineName,
    6816             :                                            CurrentModuleObject,
    6817             :                                            cAlphaFieldNames(AlphaNum),
    6818             :                                            Alphas(AlphaNum)));
    6819           0 :                     ErrorsFound = true;
    6820           1 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6821           0 :                     ShowSevereError(state,
    6822           0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6823             :                                            RoutineName,
    6824             :                                            CurrentModuleObject,
    6825             :                                            cAlphaFieldNames(AlphaNum),
    6826             :                                            Alphas(AlphaNum)));
    6827           0 :                     ErrorsFound = true;
    6828           1 :                 } else if (ListNum != 0) {
    6829           1 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6830           1 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = NumCompressorsSys;
    6831           1 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP))
    6832           1 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6833           2 :                     TransSystem(TransRefrigSysNum).CompressorNumHP({1, NumCompressorsSys}) =
    6834           3 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6835           0 :                 } else if (CompNum != 0) {
    6836           0 :                     NumCompressorsSys = 1;
    6837           0 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = 1;
    6838           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP))
    6839           0 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6840           0 :                     TransSystem(TransRefrigSysNum).CompressorNumHP(NumCompressorsSys) = CompNum;
    6841             :                 }
    6842             :                 // Sum rated capacity of all HP compressors on system
    6843           1 :                 NominalTotalCompCapHP = 0.0;
    6844           4 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6845           3 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumHP(CompIndex);
    6846             : 
    6847           3 :                     if (Compressor(CompNum).TransFlag) { //  Calculate nominal capacity of transcritical Compressor
    6848             :                         Real64 GCOutletH =
    6849           3 :                             FluidProperties::GetSupHeatEnthalpyRefrig(state,
    6850           3 :                                                                       TransSystem(TransRefrigSysNum).RefrigerantName,
    6851           3 :                                                                       GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletT,
    6852           3 :                                                                       GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletP,
    6853             :                                                                       RefrigIndex,
    6854             :                                                                       RoutineNameNoColon);
    6855           3 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6856           3 :                             state, Compressor(CompNum).TransCapacityCurvePtr, TransSystem(TransRefrigSysNum).TEvapDesignMT, GCOutletH);
    6857           3 :                         NominalTotalCompCapHP += Compressor(CompNum).NomCap;
    6858           3 :                         ++Compressor(CompNum).NumSysAttach;
    6859             :                     } else { //  Subcritical compressor attached to transcritical system - show error
    6860           0 :                         ShowSevereError(
    6861             :                             state,
    6862           0 :                             format("{}{}, No transcritical CO2 compressors are attached to the transcritical refrigeration system, \"{}\".",
    6863             :                                    RoutineName,
    6864             :                                    CurrentModuleObject,
    6865           0 :                                    TransSystem(TransRefrigSysNum).Name));
    6866           0 :                         ErrorsFound = true;
    6867             :                     }
    6868             :                 }
    6869             :             }
    6870             : 
    6871             :             // Read Low Pressure Compressor
    6872           1 :             AlphaNum = 7;
    6873           1 :             NumCompressorsSys = 0;
    6874             : 
    6875           1 :             if ((lAlphaBlanks(AlphaNum)) && (TransSystem(TransRefrigSysNum).TransSysType == 2)) {
    6876             :                 // TwoStage system type is specified but low pressure compressor input is blank
    6877           0 :                 ShowSevereError(state,
    6878           0 :                                 format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"TwoStage\", "
    6879             :                                        "however, the \"{}\" is not given.",
    6880             :                                        RoutineName,
    6881             :                                        CurrentModuleObject,
    6882           0 :                                        TransSystem(TransRefrigSysNum).Name,
    6883             :                                        cAlphaFieldNames(AlphaNum)));
    6884           0 :                 ErrorsFound = true;
    6885           1 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).TransSysType == 1)) {
    6886             :                 // SingleStage system type with low pressure compressors specified. Ignore low pressure compressors
    6887           0 :                 ShowWarningError(state,
    6888           0 :                                  format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"SingleStage\", "
    6889             :                                         "however, a \"{}\" was found.  The low pressure compressors will be ignored and will not simulated.",
    6890             :                                         RoutineName,
    6891             :                                         CurrentModuleObject,
    6892           0 :                                         TransSystem(TransRefrigSysNum).Name,
    6893             :                                         cAlphaFieldNames(AlphaNum)));
    6894           1 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).TransSysType == 2)) {
    6895             :                 // TwoStage system with low pressure compressors specified
    6896           1 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6897           1 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6898           1 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6899           0 :                     ShowSevereError(state,
    6900           0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6901             :                                            RoutineName,
    6902             :                                            CurrentModuleObject,
    6903             :                                            cAlphaFieldNames(AlphaNum),
    6904             :                                            Alphas(AlphaNum)));
    6905           0 :                     ErrorsFound = true;
    6906           1 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6907           0 :                     ShowSevereError(state,
    6908           0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6909             :                                            RoutineName,
    6910             :                                            CurrentModuleObject,
    6911             :                                            cAlphaFieldNames(AlphaNum),
    6912             :                                            Alphas(AlphaNum)));
    6913           0 :                     ErrorsFound = true;
    6914           1 :                 } else if (ListNum != 0) {
    6915           1 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6916           1 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = NumCompressorsSys;
    6917           1 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP))
    6918           1 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6919           2 :                     TransSystem(TransRefrigSysNum).CompressorNumLP({1, NumCompressorsSys}) =
    6920           3 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6921           0 :                 } else if (CompNum != 0) {
    6922           0 :                     NumCompressorsSys = 1;
    6923           0 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = 1;
    6924           0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP))
    6925           0 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6926           0 :                     TransSystem(TransRefrigSysNum).CompressorNumLP(NumCompressorsSys) = CompNum;
    6927             :                 }
    6928             :                 // Sum rated capacity of all LP compressors on system
    6929           1 :                 NominalTotalCompCapLP = 0.0;
    6930           4 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6931           3 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumLP(CompIndex);
    6932           3 :                     if (TransSystem(TransRefrigSysNum).TransSysType == 2) { //  Calculate capacity of LP compressors
    6933           3 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6934           3 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6935           3 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignLT,
    6936           3 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6937           3 :                         NominalTotalCompCapLP += Compressor(CompNum).NomCap;
    6938           3 :                         ++Compressor(CompNum).NumSysAttach;
    6939             :                     }
    6940             :                 }
    6941             :             }
    6942             : 
    6943             :             // Read Receiver Pressure
    6944           1 :             if (!lNumericBlanks(1)) {
    6945           1 :                 TransSystem(TransRefrigSysNum).PReceiver = Numbers(1);
    6946             :             } else { // Default value receiver pressure = 4000000 Pa
    6947           0 :                 TransSystem(TransRefrigSysNum).PReceiver = 4.0e6;
    6948             :             }
    6949             : 
    6950             :             // Check receiver temperature against minimum condensing temperature (from gas cooler input) and design evaporator temperatures
    6951           1 :             TransSystem(TransRefrigSysNum).TReceiver = FluidProperties::GetSatTemperatureRefrig(
    6952           1 :                 state, TransSystem(TransRefrigSysNum).RefrigerantName, TransSystem(TransRefrigSysNum).PReceiver, RefrigIndex, RoutineNameNoColon);
    6953           1 :             if (TransSystem(TransRefrigSysNum).TReceiver > GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp) {
    6954           0 :                 ShowWarningError(state,
    6955           0 :                                  format("{}{}=\"{}: The receiver temperature ({:.2R}C) is greater than the minimum condensing temperature "
    6956             :                                         "specified for subcritical operation ({:.2R}C).",
    6957             :                                         RoutineName,
    6958             :                                         CurrentModuleObject,
    6959           0 :                                         TransSystem(TransRefrigSysNum).Name,
    6960           0 :                                         TransSystem(TransRefrigSysNum).TReceiver,
    6961           0 :                                         GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp));
    6962           0 :                 ShowContinueError(state, "  The minimum condensing temperature will be set at 5C greater than the receiver temperature.");
    6963           0 :                 GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp = TransSystem(TransRefrigSysNum).TReceiver + 5.0;
    6964             :             }
    6965           1 :             if (NominalTotalCompCapLP > 0.0) {
    6966           1 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignLT) {
    6967           0 :                     ShowSevereError(state,
    6968           0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6969             :                                            "low temperature loads ({:.2R}C).",
    6970             :                                            RoutineName,
    6971             :                                            CurrentModuleObject,
    6972           0 :                                            TransSystem(TransRefrigSysNum).Name,
    6973           0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6974           0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignLT));
    6975           0 :                     ShowContinueError(state,
    6976             :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6977             :                                       "the low temperature loads.");
    6978           0 :                     ShowContinueError(state,
    6979             :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6980           0 :                     ErrorsFound = true;
    6981             :                 }
    6982             :             }
    6983           1 :             if (NominalTotalCompCapHP > 0.0) {
    6984           1 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignMT) {
    6985           0 :                     ShowSevereError(state,
    6986           0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6987             :                                            "medium temperature loads ({:.2R}C).",
    6988             :                                            RoutineName,
    6989             :                                            CurrentModuleObject,
    6990           0 :                                            TransSystem(TransRefrigSysNum).Name,
    6991           0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6992           0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignMT));
    6993           0 :                     ShowContinueError(state,
    6994             :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6995             :                                       "the medium temperature loads.");
    6996           0 :                     ShowContinueError(state,
    6997             :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6998           0 :                     ErrorsFound = true;
    6999             :                 }
    7000             :             }
    7001             : 
    7002             :             // Read subcooler effectiveness
    7003           1 :             if (!lNumericBlanks(2)) {
    7004           1 :                 TransSystem(TransRefrigSysNum).SCEffectiveness = Numbers(2);
    7005             :             } else { // Default value effectiveness = 0.4
    7006           0 :                 TransSystem(TransRefrigSysNum).PReceiver = 0.4;
    7007             :             }
    7008             :             // Check subcooler effectiveness value, must be value between 0 and 1
    7009           1 :             if ((TransSystem(TransRefrigSysNum).SCEffectiveness < 0) || (TransSystem(TransRefrigSysNum).SCEffectiveness > 1)) {
    7010           0 :                 ShowSevereError(state,
    7011           0 :                                 format("{}{}=\"{}: The value for subcooler effectivness is invalid.  The subcooler effectivenss must be a value "
    7012             :                                        "greater than or equal to zero and less than or equal to one.",
    7013             :                                        RoutineName,
    7014             :                                        CurrentModuleObject,
    7015           0 :                                        TransSystem(TransRefrigSysNum).Name));
    7016           0 :                 ErrorsFound = true;
    7017             :             }
    7018             : 
    7019             :             // Suction piping heat gain - optional
    7020             :             //  Input UA and identify the Zone containing the bulk of the suction piping
    7021             :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    7022             :             //  The pipe heat gains are also counted as cooling credit for the zone.
    7023             :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    7024             :             //  Get the Zone and zone node numbers from the zone name entered by the user
    7025           1 :             AlphaNum = 9; // Medium temperature suction piping
    7026           1 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = 0.0;
    7027           1 :             if (!lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    7028           0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = Numbers(3);
    7029           0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    7030           0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT =
    7031           0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT);
    7032           0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT == 0) {
    7033           0 :                     ShowSevereError(state,
    7034           0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    7035             :                                            RoutineName,
    7036             :                                            CurrentModuleObject,
    7037           0 :                                            TransSystem(TransRefrigSysNum).Name,
    7038             :                                            cAlphaFieldNames(AlphaNum),
    7039             :                                            Alphas(AlphaNum),
    7040             :                                            cNumericFieldNames(3)));
    7041           0 :                     ShowContinueError(state,
    7042             :                                       "  The medium temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    7043             :                                       "deterimine the environmental temperature surrounding the piping.");
    7044           0 :                     ErrorsFound = true;
    7045             :                 } else {
    7046           0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT) = true;
    7047             :                 }
    7048           1 :             } else if (!lNumericBlanks(3) && lAlphaBlanks(AlphaNum)) {
    7049           0 :                 ShowWarningError(state,
    7050           0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    7051             :                                         RoutineName,
    7052             :                                         CurrentModuleObject,
    7053           0 :                                         TransSystem(TransRefrigSysNum).Name,
    7054             :                                         cAlphaFieldNames(AlphaNum),
    7055             :                                         cNumericFieldNames(3)));
    7056           0 :                 ShowContinueError(state,
    7057             :                                   "  The medium temperature suction piping heat gain will not be calculated unless a Zone is defined to "
    7058             :                                   "determine the environmental temperature surrounding the piping.");
    7059           1 :             } else if (lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    7060           0 :                 ShowWarningError(state,
    7061           0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    7062             :                                         RoutineName,
    7063             :                                         CurrentModuleObject,
    7064           0 :                                         TransSystem(TransRefrigSysNum).Name,
    7065             :                                         cAlphaFieldNames(AlphaNum),
    7066             :                                         cNumericFieldNames(3)));
    7067             :             } // Medium temperature suction piping heat gains
    7068             : 
    7069           1 :             AlphaNum = 10; // Low temperature suction piping
    7070           1 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = 0.0;
    7071           1 :             if (!lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    7072           0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = Numbers(4);
    7073           0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    7074           0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT =
    7075           0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT);
    7076           0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT == 0) {
    7077           0 :                     ShowSevereError(state,
    7078           0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    7079             :                                            RoutineName,
    7080             :                                            CurrentModuleObject,
    7081           0 :                                            TransSystem(TransRefrigSysNum).Name,
    7082             :                                            cAlphaFieldNames(AlphaNum),
    7083             :                                            Alphas(AlphaNum),
    7084             :                                            cNumericFieldNames(4)));
    7085           0 :                     ShowContinueError(state,
    7086             :                                       "  The low temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    7087             :                                       "deterimine the environmental temperature surrounding the piping.");
    7088           0 :                     ErrorsFound = true;
    7089             :                 } else {
    7090           0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT) = true;
    7091             :                 }
    7092           1 :             } else if (!lNumericBlanks(4) && lAlphaBlanks(AlphaNum)) {
    7093           0 :                 ShowWarningError(state,
    7094           0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    7095             :                                         RoutineName,
    7096             :                                         CurrentModuleObject,
    7097           0 :                                         TransSystem(TransRefrigSysNum).Name,
    7098             :                                         cAlphaFieldNames(AlphaNum),
    7099             :                                         cNumericFieldNames(4)));
    7100           0 :                 ShowContinueError(state,
    7101             :                                   "  The low temperature suction piping heat gain will not be calculated unless a Zone is defined to determine "
    7102             :                                   "the environmental temperature surrounding the piping.");
    7103           1 :             } else if (lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    7104           0 :                 ShowWarningError(state,
    7105           0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    7106             :                                         RoutineName,
    7107             :                                         CurrentModuleObject,
    7108           0 :                                         TransSystem(TransRefrigSysNum).Name,
    7109             :                                         cAlphaFieldNames(AlphaNum),
    7110             :                                         cNumericFieldNames(4)));
    7111             :             } // Low temperature suction piping heat gains
    7112             : 
    7113           1 :             AlphaNum = 11;
    7114           1 :             if (!lAlphaBlanks(AlphaNum)) TransSystem(TransRefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    7115             : 
    7116             :             // Compare the rated capacity of compressor, condenser, and cases.
    7117             :             // Note, rated capacities can be far off from operating capacities, but rough check.
    7118           1 :             Real64 NominalCondCap = GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedCapacity;
    7119           1 :             Real64 NominalTotalCompCap = NominalTotalCompCapHP + NominalTotalCompCapLP;
    7120           1 :             if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    7121           0 :                 ShowWarningError(
    7122           0 :                     state, format("{}=\"{}\", You may wish to check the system sizing.", CurrentModuleObject, TransSystem(TransRefrigSysNum).Name));
    7123           0 :                 ShowContinueError(
    7124             :                     state,
    7125           0 :                     format("Total nominal cooling capacity is {:.0R}W. Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    7126             :                            NominalTotalCoolingCap,
    7127             :                            NominalCondCap,
    7128             :                            NominalTotalCompCap));
    7129             :             }
    7130             : 
    7131             :         } // Transcritical refrigeration systems
    7132             : 
    7133             :     } //(NumTransRefrigSystems > 0)
    7134             : 
    7135         796 :     DayValues.deallocate();
    7136         796 :     Alphas.deallocate();
    7137         796 :     Numbers.deallocate();
    7138         796 :     cAlphaFieldNames.deallocate();
    7139         796 :     cNumericFieldNames.deallocate();
    7140         796 :     lAlphaBlanks.deallocate();
    7141         796 :     lNumericBlanks.deallocate();
    7142             : 
    7143         796 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    7144             :         // Find unused and non-unique display case objects to report in eio and err file and sum
    7145             :         //    all HVAC RA fractions and write error message if greater than 1 for any zone
    7146         750 :         for (int ZoneIndex = 1; ZoneIndex <= state.dataGlobal->NumOfZones; ++ZoneIndex) { // numofzones from dataglobals
    7147         714 :             Real64 TempRAFraction = CaseRAFraction(ZoneIndex).TotalCaseRAFraction;
    7148        2918 :             for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    7149             :                 // TempRaFraction already includes contributions from ALL cases in zone
    7150             :                 // Want to delete portion from unused cases (numsysattach = 0)that will never be simulated
    7151        2204 :                 if (RefrigCase(CaseNum).ActualZoneNum != ZoneIndex || RefrigCase(CaseNum).NumSysAttach > 0) continue;
    7152           0 :                 TempRAFraction -= RefrigCase(CaseNum).RAFrac;
    7153             :             } // NumSimulationCases
    7154         714 :             if (TempRAFraction > 1.0) {
    7155           0 :                 ShowSevereError(
    7156             :                     state,
    7157           0 :                     format("{}: Refrigeration:Case, Refrigerated case return air fraction for all cases in zone=\"{}\" is greater than 1.0.",
    7158             :                            RoutineName,
    7159           0 :                            CaseRAFraction(ZoneIndex).ZoneName));
    7160             :                 // check in comment, can't use "currentModuleObject" because not in get input subroutine where that is known
    7161           0 :                 ErrorsFound = true;
    7162             :             }
    7163             :         } // ZoneIndex=1,DataGlobals::NumOfZones
    7164             : 
    7165          36 :         CaseRAFraction.deallocate(); // only used for input check just completed
    7166             :         // check for cases not connected to systems and cases connected
    7167             :         // more than once (twice in a system or to more than one system)
    7168             : 
    7169          36 :         state.dataRefrigCase->NumUnusedRefrigCases = 0;
    7170         222 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    7171         186 :             if (RefrigCase(CaseNum).NumSysAttach == 1) continue;
    7172           0 :             if (RefrigCase(CaseNum).NumSysAttach < 1) {
    7173           0 :                 ++state.dataRefrigCase->NumUnusedRefrigCases;
    7174           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7175             :                     //  individual case names listed if DataGlobals::DisplayExtraWarnings option selected
    7176           0 :                     ShowWarningError(state, format("{}: Refrigeration:Case=\"{}\" unused. ", RoutineName, RefrigCase(CaseNum).Name));
    7177             :                 } // display extra warnings - give a list of unused cases
    7178             :             }     // unused case
    7179           0 :             if (RefrigCase(CaseNum).NumSysAttach > 1) {
    7180           0 :                 ErrorsFound = true;
    7181           0 :                 ShowSevereError(
    7182           0 :                     state, format("{}: Refrigeration:Case=\"{}\", Same refrigerated case name referenced ", RoutineName, RefrigCase(CaseNum).Name));
    7183           0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7184             :             } // if looking for same case attached to multiple systems/racks
    7185             :         }     // NumSimulationCases
    7186             : 
    7187          36 :         if ((state.dataRefrigCase->NumUnusedRefrigCases > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7188             :             //  write to error file,
    7189             :             //  summary number of unused cases given if DataGlobals::DisplayExtraWarnings option not selected
    7190           0 :             ShowWarningError(state,
    7191           0 :                              format("Refrigeration:Case -> {} unused refrigerated case(s) found during input processing.",
    7192           0 :                                     state.dataRefrigCase->NumUnusedRefrigCases));
    7193           0 :             ShowContinueError(state, "  These refrigerated cases are in the input file but are not connected to a ");
    7194           0 :             ShowContinueError(state, "  Refrigeration:CompressorRack, Refrigeration:System, or Refrigeration:SecondarySystem object.");
    7195           0 :             ShowContinueError(state, "  These unused refrigeration cases will not be simulated.");
    7196           0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7197             :         } // NumUnusedRefrigCases
    7198             :     }     // numsimulation cases > 0
    7199             : 
    7200         796 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    7201             :         // check for compressors not connected to systems and compressors connected more than once
    7202             :         // (twice in a system or to more than one system)
    7203          15 :         state.dataRefrigCase->NumUnusedCompressors = 0;
    7204         189 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    7205         174 :             if (Compressor(CompNum).NumSysAttach == 1) continue;
    7206           0 :             if (Compressor(CompNum).NumSysAttach < 1) {
    7207           0 :                 ++state.dataRefrigCase->NumUnusedCompressors;
    7208           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7209             :                     //  individual compressor names listed if DataGlobals::DisplayExtraWarnings option selected
    7210           0 :                     ShowWarningError(state, format("{}: Refrigeration:Compressor=\"{}\" unused. ", RoutineName, Compressor(CompNum).Name));
    7211             :                 } // display extra warnings - give a list of unused compressors
    7212             :             }     // unused compressor
    7213           0 :             if (Compressor(CompNum).NumSysAttach > 1) {
    7214           0 :                 ErrorsFound = true;
    7215           0 :                 ShowSevereError(state,
    7216           0 :                                 format("{}: Refrigeration:Compressor=\"{}\", Same refrigeration compressor name referenced",
    7217             :                                        RoutineName,
    7218           0 :                                        Compressor(CompNum).Name));
    7219           0 :                 ShowContinueError(state, " by more than one refrigeration system.");
    7220             :             } // looking for same compressor attached to multiple systems/racks
    7221             :         }     // NumSimulationCompressors
    7222             : 
    7223          15 :         if ((state.dataRefrigCase->NumUnusedCompressors > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7224             :             //  write to error file,
    7225             :             //  summary number of unused compressors given if DataGlobals::DisplayExtraWarnings option not selected
    7226           0 :             ShowWarningError(state,
    7227           0 :                              format("Refrigeration:Compressor -> {} unused refrigeration compressor(s) found during input processing.",
    7228           0 :                                     state.dataRefrigCase->NumUnusedCompressors));
    7229           0 :             ShowContinueError(state,
    7230             :                               "  Those refrigeration compressors are in the input file but are not connected to a Refrigeration:System object.");
    7231           0 :             ShowContinueError(state, "   These unused refrigeration compressors will not be simulated.");
    7232           0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7233             :         } // NumUnusedCompressors
    7234             :     }     // NumSimulationCompressors > 0
    7235             : 
    7236         796 :     int NumUnusedWalkIns = 0;
    7237         796 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7238             :         // check for refrigeration WalkIns not connected to any systems and
    7239             :         //  refrigeration WalkIns connected more than once
    7240          28 :         for (int WalkInNum = 1; WalkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInNum) {
    7241          15 :             if (WalkIn(WalkInNum).NumSysAttach == 1) continue;
    7242           0 :             if (WalkIn(WalkInNum).NumSysAttach < 1) {
    7243           0 :                 ++NumUnusedWalkIns;
    7244           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7245             :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    7246           0 :                     ShowWarningError(state, format("{}: Refrigeration:WalkIn=\"{}\" unused. ", RoutineName, WalkIn(WalkInNum).Name));
    7247             :                 } // display extra warnings - give a list of unused WalkIns
    7248             :             }     // unused walkin
    7249           0 :             if (WalkIn(WalkInNum).NumSysAttach > 1) {
    7250           0 :                 ErrorsFound = true;
    7251           0 :                 ShowSevereError(
    7252           0 :                     state, format("{}: Refrigeration:WalkIn=\"{}\", Same Refrigeration WalkIn name referenced", RoutineName, WalkIn(WalkInNum).Name));
    7253           0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7254             :             } // if looking for same walk in attached to multiple systems/racks
    7255             :         }     // NumSimulationWalkIns
    7256             : 
    7257          13 :         if ((NumUnusedWalkIns > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7258             :             //  write to error file,
    7259             :             //  summary number of unused walkins given if DataGlobals::DisplayExtraWarnings option not selected
    7260           0 :             ShowWarningError(
    7261             :                 state,
    7262           0 :                 format("{}Refrigeration:WalkIn -> {} unused refrigeration WalkIns found during input processing.", RoutineName, NumUnusedWalkIns));
    7263           0 :             ShowContinueError(state, "   Those refrigeration WalkIns are in the input file but are not connected to a ");
    7264           0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    7265           0 :             ShowContinueError(state, "   These unused refrigeration WalkIns will not be simulated.");
    7266           0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7267             :         } // NumUnusedWalkIns
    7268             :     }     // NumSimulationWalkIns > 0
    7269             : 
    7270         796 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7271             :         // check for air chillers not connected to any systems and
    7272             :         //  air chillers connected more than once
    7273           1 :         state.dataRefrigCase->NumUnusedCoils = 0;
    7274          84 :         for (int CoilNum = 1; CoilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilNum) {
    7275          83 :             if (WarehouseCoil(CoilNum).NumSysAttach == 1) continue;
    7276           0 :             if (WarehouseCoil(CoilNum).NumSysAttach < 1) {
    7277           0 :                 ++NumUnusedWalkIns;
    7278           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7279             :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    7280           0 :                     ShowWarningError(state, format("{}: Refrigeration:AirChiller=\"{}\" unused. ", RoutineName, WarehouseCoil(CoilNum).Name));
    7281             :                 } // display extra warnings - give a list of unused chillers
    7282             :             }     // unused chiller
    7283           0 :             if (WarehouseCoil(CoilNum).NumSysAttach > 1) {
    7284           0 :                 ErrorsFound = true;
    7285           0 :                 ShowSevereError(state,
    7286           0 :                                 format("{}: Refrigeration:AirChiller=\"{}\", Same Refrigeration Air Chiller name referenced",
    7287             :                                        RoutineName,
    7288           0 :                                        WarehouseCoil(CoilNum).Name));
    7289           0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7290             :             } // if looking for same walk in attached to multiple systems/racks
    7291             :         }     // NumSimulationRefrigAirchillers
    7292             : 
    7293           1 :         if ((state.dataRefrigCase->NumUnusedCoils > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7294             :             //  write to error file,
    7295             :             //  summary number of unused air chillers given if DataGlobals::DisplayExtraWarnings option not selected
    7296           0 :             ShowWarningError(state,
    7297           0 :                              format("{}Refrigeration:AirChiller -> {} unused refrigeration air chillers found during input processing.",
    7298             :                                     RoutineName,
    7299           0 :                                     state.dataRefrigCase->NumUnusedCoils));
    7300           0 :             ShowContinueError(state, "   Those refrigeration air chillers are in the input file but are not connected to a ");
    7301           0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    7302           0 :             ShowContinueError(state, "   These unused refrigeration air chillers will not be simulated.");
    7303           0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7304             :         } // NumUnusedAirChllerss
    7305             :     }     // NumSimulationAirChillers > 0
    7306             : 
    7307         796 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    7308             :         // check for refrigeration Secondarys not connected to detailed systems and
    7309             :         //  refrigeration Secondarys connected more than once
    7310           1 :         state.dataRefrigCase->NumUnusedSecondarys = 0;
    7311           3 :         for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    7312           2 :             if (Secondary(SecondaryNum).NumSysAttach == 1) continue;
    7313           0 :             if (Secondary(SecondaryNum).NumSysAttach < 1) {
    7314           0 :                 ++state.dataRefrigCase->NumUnusedSecondarys;
    7315           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7316             :                     //  individual secondary names listed if DataGlobals::DisplayExtraWarnings option selected
    7317           0 :                     ShowWarningError(state, format("{}: Refrigeration:Secondary=\"{}\" unused. ", RoutineName, Secondary(SecondaryNum).Name));
    7318             :                 } // display extra warnings - give a list of unused Secondaries
    7319             :             }     // unused secondary
    7320           0 :             if (Secondary(SecondaryNum).NumSysAttach > 1) {
    7321           0 :                 ErrorsFound = true;
    7322           0 :                 ShowSevereError(state,
    7323           0 :                                 format("{}: Refrigeration:Secondary=\"{}\", Same Refrigeration Secondary name referenced",
    7324             :                                        RoutineName,
    7325           0 :                                        Secondary(SecondaryNum).Name));
    7326           0 :                 ShowContinueError(state, "   by more than one refrigeration system");
    7327             :             } // looking for same secondary loop attached to multiple systems/racks
    7328             :         }     // NumSimulationSecondarys
    7329             : 
    7330           1 :         if ((state.dataRefrigCase->NumUnusedSecondarys > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7331             :             //  write to error file,
    7332             :             //  summary number of unused secondaries given if DataGlobals::DisplayExtraWarnings option not selected
    7333           0 :             ShowWarningError(state,
    7334           0 :                              format("{}Refrigeration:Secondary -> {} unused refrigeration Secondary Loops found during input processing.",
    7335             :                                     RoutineName,
    7336           0 :                                     state.dataRefrigCase->NumUnusedSecondarys));
    7337           0 :             ShowContinueError(state, "  Those refrigeration Secondary Loops are in the input file but are not connected to a refrigeration system.");
    7338           0 :             ShowContinueError(state, "   These unused refrigeration secondaries will not be simulated.");
    7339           0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7340             :         } // NumUnusedSecondarys
    7341             :     }     // NumSimulationSecondarySystems > 0
    7342             : 
    7343         796 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    7344             :         // Check for presence of shared condensers and for unused condensers
    7345             :         //     - determines number of loops through refrigeration simulation
    7346             :         //       because of dependence of performance on total condenser load
    7347          14 :         state.dataRefrigCase->NumSimulationSharedCondensers = 0;
    7348          14 :         state.dataRefrigCase->NumUnusedCondensers = 0;
    7349          51 :         for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumRefrigCondensers; ++CondNum) {
    7350          37 :             if (Condenser(CondNum).NumSysAttach == 1) continue;
    7351           2 :             if (Condenser(CondNum).NumSysAttach < 1) {
    7352           0 :                 ++state.dataRefrigCase->NumUnusedCondensers;
    7353           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7354             :                     //  individual condenser names listed if DataGlobals::DisplayExtraWarnings option selected
    7355           0 :                     ShowWarningError(state, format("{}: Refrigeration:Condenser=\"{}\" unused. ", RoutineName, Condenser(CondNum).Name));
    7356             :                 } // display extra warnings - give a list of unused condensers
    7357             :             }     // unused condenser
    7358           2 :             if (Condenser(CondNum).NumSysAttach > 1) {
    7359           2 :                 ++state.dataRefrigCase->NumSimulationSharedCondensers;
    7360             :             } // looking for shared condensers
    7361             :         }     // CondNum
    7362             : 
    7363          14 :         if ((state.dataRefrigCase->NumUnusedCondensers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7364             :             //  write to error file,
    7365             :             //  summary number of unused condensers given if DataGlobals::DisplayExtraWarnings option not selected
    7366           0 :             ShowWarningError(state,
    7367           0 :                              format("{}Refrigeration condenser -> {} unused refrigeration condensers found during input processing.",
    7368             :                                     RoutineName,
    7369           0 :                                     state.dataRefrigCase->NumUnusedCondensers));
    7370           0 :             ShowContinueError(state, "  Those refrigeration condensers are in the input file but are not connected to a refrigeration system.");
    7371           0 :             ShowContinueError(state, "   These unused refrigeration condensers will not be simulated.");
    7372           0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7373             :         } // NumUnusedCondensers and displayextra warnings
    7374             :     }     // DataHeatBalance::NumRefrigCondensers > 0
    7375             : 
    7376         796 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    7377             :         // Check for presence of shared gas coolers and for unused gas coolers
    7378           1 :         state.dataRefrigCase->NumSimulationSharedGasCoolers = 0;
    7379           1 :         state.dataRefrigCase->NumUnusedGasCoolers = 0;
    7380           2 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    7381           1 :             if (GasCooler(GCNum).NumSysAttach == 1) continue;
    7382           0 :             if (GasCooler(GCNum).NumSysAttach < 1) {
    7383           0 :                 ++state.dataRefrigCase->NumUnusedGasCoolers;
    7384           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7385             :                     //  individual gas cooler names listed if DataGlobals::DisplayExtraWarnings option selected
    7386           0 :                     ShowWarningError(state, format("{}: Refrigeration:GasCooler=\"{}\" unused. ", RoutineName, GasCooler(GCNum).Name));
    7387             :                 } // display extra warnings - give a list of unused gas coolers
    7388             :             }     // unused gas cooler
    7389           0 :             if (GasCooler(GCNum).NumSysAttach > 1) {
    7390           0 :                 ++state.dataRefrigCase->NumSimulationSharedGasCoolers;
    7391             :             } // looking for shared gas coolers
    7392             :         }     // GCNum
    7393             : 
    7394           1 :         if ((state.dataRefrigCase->NumUnusedGasCoolers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7395             :             //  write to error file,
    7396             :             //  summary number of unused gas coolers given if DataGlobals::DisplayExtraWarnings option not selected
    7397           0 :             ShowWarningError(state,
    7398           0 :                              format("{}Refrigeration gas cooler -> {} unused refrigeration gas cooler(s) found during input processing.",
    7399             :                                     RoutineName,
    7400           0 :                                     state.dataRefrigCase->NumUnusedGasCoolers));
    7401           0 :             ShowContinueError(state, "  These refrigeration gas coolers are in the input file but are not connected to a refrigeration system.");
    7402           0 :             ShowContinueError(state, "  These unused refrigeration gas coolers will not be simulated.");
    7403           0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7404             :         } // NumUnusedGasCoolers and displayextra warnings
    7405             :     }     // NumSimulationGasCooler > 0
    7406             : 
    7407             :     // echo input to eio file.
    7408         796 :     ReportRefrigerationComponents(state);
    7409             : 
    7410         796 :     if (ErrorsFound) {
    7411           0 :         ShowFatalError(state, format("{} Previous errors cause program termination", RoutineName));
    7412             :     }
    7413         796 : }
    7414             : 
    7415         796 : void SetupReportInput(EnergyPlusData &state)
    7416             : {
    7417             :     // SUBROUTINE INFORMATION:
    7418             :     //       AUTHOR         Richard Raustad, FSEC
    7419             :     //       DATE WRITTEN   Oct/Nov 2004
    7420             :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008 and 09
    7421             :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
    7422             :     //       RE-ENGINEERED  na
    7423             : 
    7424             :     // PURPOSE OF THIS SUBROUTINE:
    7425             :     // Set up the report variables.
    7426             : 
    7427         796 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
    7428         796 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
    7429         796 :     auto &System = state.dataRefrigCase->System;
    7430         796 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
    7431         796 :     auto &Condenser = state.dataRefrigCase->Condenser;
    7432         796 :     auto &Compressor = state.dataRefrigCase->Compressor;
    7433         796 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
    7434         796 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
    7435         796 :     auto &Secondary = state.dataRefrigCase->Secondary;
    7436         796 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
    7437         796 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
    7438         796 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
    7439         796 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
    7440             : 
    7441         796 :     std::string Walkin_and_zone_name; // concat name for walk-in/zone credit reporting
    7442             : 
    7443         796 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    7444             :         // Setup Report Variables for simulated Refrigerated Case (do not report unused cases)
    7445             :         // CurrentModuleObject='Refrigeration:Case'
    7446         222 :         for (int caseNum = 1; caseNum <= state.dataRefrigCase->NumSimulationCases; ++caseNum) {
    7447         186 :             auto &thisCase = RefrigCase(caseNum);
    7448         186 :             if (thisCase.NumSysAttach == 1) {
    7449         372 :                 SetupOutputVariable(state,
    7450             :                                     "Refrigeration Case Evaporator Total Cooling Rate",
    7451             :                                     Constant::Units::W,
    7452         186 :                                     thisCase.TotalCoolingLoad,
    7453             :                                     OutputProcessor::TimeStepType::Zone,
    7454             :                                     OutputProcessor::StoreType::Average,
    7455         186 :                                     thisCase.Name);
    7456         372 :                 SetupOutputVariable(state,
    7457             :                                     "Refrigeration Case Evaporator Total Cooling Energy",
    7458             :                                     Constant::Units::J,
    7459         186 :                                     thisCase.TotalCoolingEnergy,
    7460             :                                     OutputProcessor::TimeStepType::Zone,
    7461             :                                     OutputProcessor::StoreType::Sum,
    7462         186 :                                     thisCase.Name,
    7463             :                                     Constant::eResource::EnergyTransfer,
    7464             :                                     OutputProcessor::Group::Building,
    7465             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7466             :                                     "", // End-use sub category
    7467         186 :                                     thisCase.ZoneName);
    7468         372 :                 SetupOutputVariable(state,
    7469             :                                     "Refrigeration Case Evaporator Sensible Cooling Rate",
    7470             :                                     Constant::Units::W,
    7471         186 :                                     thisCase.SensCoolingEnergyRate,
    7472             :                                     OutputProcessor::TimeStepType::Zone,
    7473             :                                     OutputProcessor::StoreType::Average,
    7474         186 :                                     thisCase.Name);
    7475         372 :                 SetupOutputVariable(state,
    7476             :                                     "Refrigeration Case Evaporator Sensible Cooling Energy",
    7477             :                                     Constant::Units::J,
    7478         186 :                                     thisCase.SensCoolingEnergy,
    7479             :                                     OutputProcessor::TimeStepType::Zone,
    7480             :                                     OutputProcessor::StoreType::Sum,
    7481         186 :                                     thisCase.Name);
    7482         372 :                 SetupOutputVariable(state,
    7483             :                                     "Refrigeration Case Evaporator Latent Cooling Rate",
    7484             :                                     Constant::Units::W,
    7485         186 :                                     thisCase.LatCoolingEnergyRate,
    7486             :                                     OutputProcessor::TimeStepType::Zone,
    7487             :                                     OutputProcessor::StoreType::Average,
    7488         186 :                                     thisCase.Name);
    7489         372 :                 SetupOutputVariable(state,
    7490             :                                     "Refrigeration Case Evaporator Latent Cooling Energy",
    7491             :                                     Constant::Units::J,
    7492         186 :                                     thisCase.LatCoolingEnergy,
    7493             :                                     OutputProcessor::TimeStepType::Zone,
    7494             :                                     OutputProcessor::StoreType::Sum,
    7495         186 :                                     thisCase.Name);
    7496             : 
    7497         372 :                 SetupOutputVariable(state,
    7498             :                                     "Refrigeration Case Zone Sensible Cooling Rate",
    7499             :                                     Constant::Units::W,
    7500         186 :                                     thisCase.SensZoneCreditCoolRate,
    7501             :                                     OutputProcessor::TimeStepType::Zone,
    7502             :                                     OutputProcessor::StoreType::Average,
    7503         186 :                                     thisCase.Name);
    7504         372 :                 SetupOutputVariable(state,
    7505             :                                     "Refrigeration Case Zone Sensible Cooling Energy",
    7506             :                                     Constant::Units::J,
    7507         186 :                                     thisCase.SensZoneCreditCool,
    7508             :                                     OutputProcessor::TimeStepType::Zone,
    7509             :                                     OutputProcessor::StoreType::Sum,
    7510         186 :                                     thisCase.Name);
    7511         372 :                 SetupOutputVariable(state,
    7512             :                                     "Refrigeration Case Zone Sensible Heating Rate",
    7513             :                                     Constant::Units::W,
    7514         186 :                                     thisCase.SensZoneCreditHeatRate,
    7515             :                                     OutputProcessor::TimeStepType::Zone,
    7516             :                                     OutputProcessor::StoreType::Average,
    7517         186 :                                     thisCase.Name);
    7518         372 :                 SetupOutputVariable(state,
    7519             :                                     "Refrigeration Case Zone Sensible Heating Energy",
    7520             :                                     Constant::Units::J,
    7521         186 :                                     thisCase.SensZoneCreditHeat,
    7522             :                                     OutputProcessor::TimeStepType::Zone,
    7523             :                                     OutputProcessor::StoreType::Sum,
    7524         186 :                                     thisCase.Name);
    7525             : 
    7526         372 :                 SetupOutputVariable(state,
    7527             :                                     "Refrigeration Case Zone Latent Rate",
    7528             :                                     Constant::Units::W,
    7529         186 :                                     thisCase.LatZoneCreditRate,
    7530             :                                     OutputProcessor::TimeStepType::Zone,
    7531             :                                     OutputProcessor::StoreType::Average,
    7532         186 :                                     thisCase.Name);
    7533         372 :                 SetupOutputVariable(state,
    7534             :                                     "Refrigeration Case Zone Latent Energy",
    7535             :                                     Constant::Units::J,
    7536         186 :                                     thisCase.LatZoneCredit,
    7537             :                                     OutputProcessor::TimeStepType::Zone,
    7538             :                                     OutputProcessor::StoreType::Sum,
    7539         186 :                                     thisCase.Name);
    7540             : 
    7541         372 :                 SetupOutputVariable(state,
    7542             :                                     "Refrigeration Case Return Air Sensible Cooling Rate",
    7543             :                                     Constant::Units::W,
    7544         186 :                                     thisCase.SensHVACCreditCoolRate,
    7545             :                                     OutputProcessor::TimeStepType::Zone,
    7546             :                                     OutputProcessor::StoreType::Average,
    7547         186 :                                     thisCase.Name);
    7548         372 :                 SetupOutputVariable(state,
    7549             :                                     "Refrigeration Case Return Air Sensible Cooling Energy",
    7550             :                                     Constant::Units::J,
    7551         186 :                                     thisCase.SensHVACCreditCool,
    7552             :                                     OutputProcessor::TimeStepType::Zone,
    7553             :                                     OutputProcessor::StoreType::Sum,
    7554         186 :                                     thisCase.Name);
    7555         372 :                 SetupOutputVariable(state,
    7556             :                                     "Refrigeration Case Return Air Sensible Heating Rate",
    7557             :                                     Constant::Units::W,
    7558         186 :                                     thisCase.SensHVACCreditHeatRate,
    7559             :                                     OutputProcessor::TimeStepType::Zone,
    7560             :                                     OutputProcessor::StoreType::Average,
    7561         186 :                                     thisCase.Name);
    7562         372 :                 SetupOutputVariable(state,
    7563             :                                     "Refrigeration Case Return Air Sensible Heating Energy",
    7564             :                                     Constant::Units::J,
    7565         186 :                                     thisCase.SensHVACCreditHeat,
    7566             :                                     OutputProcessor::TimeStepType::Zone,
    7567             :                                     OutputProcessor::StoreType::Sum,
    7568         186 :                                     thisCase.Name);
    7569             : 
    7570         372 :                 SetupOutputVariable(state,
    7571             :                                     "Refrigeration Case Return Air Latent Rate",
    7572             :                                     Constant::Units::W,
    7573         186 :                                     thisCase.LatHVACCreditRate,
    7574             :                                     OutputProcessor::TimeStepType::Zone,
    7575             :                                     OutputProcessor::StoreType::Average,
    7576         186 :                                     thisCase.Name);
    7577         372 :                 SetupOutputVariable(state,
    7578             :                                     "Refrigeration Case Return Air Latent Energy",
    7579             :                                     Constant::Units::J,
    7580         186 :                                     thisCase.LatHVACCredit,
    7581             :                                     OutputProcessor::TimeStepType::Zone,
    7582             :                                     OutputProcessor::StoreType::Sum,
    7583         186 :                                     thisCase.Name);
    7584             : 
    7585         372 :                 SetupOutputVariable(state,
    7586             :                                     "Refrigeration Case Evaporator Fan Electricity Rate",
    7587             :                                     Constant::Units::W,
    7588         186 :                                     thisCase.ElecFanPower,
    7589             :                                     OutputProcessor::TimeStepType::Zone,
    7590             :                                     OutputProcessor::StoreType::Average,
    7591         186 :                                     thisCase.Name);
    7592         372 :                 SetupOutputVariable(state,
    7593             :                                     "Refrigeration Case Evaporator Fan Electricity Energy",
    7594             :                                     Constant::Units::J,
    7595         186 :                                     thisCase.ElecFanConsumption,
    7596             :                                     OutputProcessor::TimeStepType::Zone,
    7597             :                                     OutputProcessor::StoreType::Sum,
    7598         186 :                                     thisCase.Name,
    7599             :                                     Constant::eResource::Electricity,
    7600             :                                     OutputProcessor::Group::Building,
    7601             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7602             :                                     "General",
    7603         186 :                                     thisCase.ZoneName);
    7604         372 :                 SetupOutputVariable(state,
    7605             :                                     "Refrigeration Case Lighting Electricity Rate",
    7606             :                                     Constant::Units::W,
    7607         186 :                                     thisCase.ElecLightingPower,
    7608             :                                     OutputProcessor::TimeStepType::Zone,
    7609             :                                     OutputProcessor::StoreType::Average,
    7610         186 :                                     thisCase.Name);
    7611         372 :                 SetupOutputVariable(state,
    7612             :                                     "Refrigeration Case Lighting Electricity Energy",
    7613             :                                     Constant::Units::J,
    7614         186 :                                     thisCase.ElecLightingConsumption,
    7615             :                                     OutputProcessor::TimeStepType::Zone,
    7616             :                                     OutputProcessor::StoreType::Sum,
    7617         186 :                                     thisCase.Name,
    7618             :                                     Constant::eResource::Electricity,
    7619             :                                     OutputProcessor::Group::Building,
    7620             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7621             :                                     "General",
    7622         186 :                                     thisCase.ZoneName);
    7623             : 
    7624             :                 // Report defrost energy curve value only for cases having electric or hot-gas defrost with temperature termination
    7625         186 :                 if (thisCase.defrostType == RefCaseDefrostType::ElectricTerm || thisCase.defrostType == RefCaseDefrostType::HotFluidTerm) {
    7626         116 :                     SetupOutputVariable(state,
    7627             :                                         "Refrigeration Case Defrost Energy Correction Curve Value",
    7628             :                                         Constant::Units::None,
    7629          58 :                                         thisCase.DefEnergyCurveValue,
    7630             :                                         OutputProcessor::TimeStepType::Zone,
    7631             :                                         OutputProcessor::StoreType::Average,
    7632          58 :                                         thisCase.Name);
    7633             :                 }
    7634             : 
    7635         372 :                 SetupOutputVariable(state,
    7636             :                                     "Refrigeration Case Latent Credit Curve Value",
    7637             :                                     Constant::Units::None,
    7638         186 :                                     thisCase.LatEnergyCurveValue,
    7639             :                                     OutputProcessor::TimeStepType::Zone,
    7640             :                                     OutputProcessor::StoreType::Average,
    7641         186 :                                     thisCase.Name);
    7642             : 
    7643             :                 // Report only for cases having anti-sweat heaters
    7644         186 :                 if (thisCase.AntiSweatControlType > ASHtrCtrlType::None) {
    7645         158 :                     SetupOutputVariable(state,
    7646             :                                         "Refrigeration Case Anti Sweat Electricity Rate",
    7647             :                                         Constant::Units::W,
    7648          79 :                                         thisCase.ElecAntiSweatPower,
    7649             :                                         OutputProcessor::TimeStepType::Zone,
    7650             :                                         OutputProcessor::StoreType::Average,
    7651          79 :                                         thisCase.Name);
    7652         158 :                     SetupOutputVariable(state,
    7653             :                                         "Refrigeration Case Anti Sweat Electricity Energy",
    7654             :                                         Constant::Units::J,
    7655          79 :                                         thisCase.ElecAntiSweatConsumption,
    7656             :                                         OutputProcessor::TimeStepType::Zone,
    7657             :                                         OutputProcessor::StoreType::Sum,
    7658          79 :                                         thisCase.Name,
    7659             :                                         Constant::eResource::Electricity,
    7660             :                                         OutputProcessor::Group::Building,
    7661             :                                         OutputProcessor::EndUseCat::Refrigeration,
    7662             :                                         "General",
    7663          79 :                                         thisCase.ZoneName);
    7664             :                 }
    7665             : 
    7666             :                 // Report only for cases using electric defrost
    7667             : 
    7668         186 :                 if (thisCase.defrostType == RefCaseDefrostType::Electric || thisCase.defrostType == RefCaseDefrostType::ElectricOnDemand ||
    7669         158 :                     thisCase.defrostType == RefCaseDefrostType::ElectricTerm) {
    7670          92 :                     SetupOutputVariable(state,
    7671             :                                         "Refrigeration Case Defrost Electricity Rate",
    7672             :                                         Constant::Units::W,
    7673          46 :                                         thisCase.ElecDefrostPower,
    7674             :                                         OutputProcessor::TimeStepType::Zone,
    7675             :                                         OutputProcessor::StoreType::Average,
    7676          46 :                                         thisCase.Name);
    7677          92 :                     SetupOutputVariable(state,
    7678             :                                         "Refrigeration Case Defrost Electricity Energy",
    7679             :                                         Constant::Units::J,
    7680          46 :                                         thisCase.ElecDefrostConsumption,
    7681             :                                         OutputProcessor::TimeStepType::Zone,
    7682             :                                         OutputProcessor::StoreType::Sum,
    7683          46 :                                         thisCase.Name,
    7684             :                                         Constant::eResource::Electricity,
    7685             :                                         OutputProcessor::Group::Building,
    7686             :                                         OutputProcessor::EndUseCat::Refrigeration,
    7687             :                                         "General",
    7688          46 :                                         thisCase.ZoneName);
    7689             :                 }
    7690             : 
    7691             :                 // register refrigeration case credits as internal gains
    7692         186 :                 if (thisCase.ActualZoneNum > 0) {
    7693         186 :                     SetupZoneInternalGain(state,
    7694             :                                           thisCase.ActualZoneNum,
    7695             :                                           thisCase.Name,
    7696             :                                           DataHeatBalance::IntGainType::RefrigerationCase,
    7697             :                                           &thisCase.SensZoneCreditRate,
    7698             :                                           &thisCase.SensHVACCreditRate,
    7699             :                                           nullptr,
    7700             :                                           &thisCase.LatZoneCreditRate,
    7701             :                                           &thisCase.LatHVACCreditRate,
    7702             :                                           nullptr,
    7703             :                                           nullptr,
    7704             :                                           thisCase.ZoneRANode);
    7705             :                 }
    7706             :             } // END IF (.NOT. RefrigCase(CaseNum)%unusedCase)
    7707             :         }
    7708             :     } // NumSimulationCases > 0
    7709             : 
    7710         796 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7711             :         // Setup Report Variables for simulated  Walk In (do not report unused WalkIns)
    7712             :         // CurrentModuleObject='Refrigeration:WalkIn'
    7713          28 :         for (int walkInNum = 1; walkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInNum) {
    7714          15 :             auto &walkin = WalkIn(walkInNum);
    7715          15 :             if (walkin.NumSysAttach == 1) { // ensure no unuseds reported
    7716          30 :                 SetupOutputVariable(state,
    7717             :                                     "Refrigeration Walk In Evaporator Total Cooling Rate",
    7718             :                                     Constant::Units::W,
    7719          15 :                                     walkin.TotalCoolingLoad,
    7720             :                                     OutputProcessor::TimeStepType::Zone,
    7721             :                                     OutputProcessor::StoreType::Average,
    7722          15 :                                     walkin.Name);
    7723          30 :                 SetupOutputVariable(state,
    7724             :                                     "Refrigeration Walk In Evaporator Total Cooling Energy",
    7725             :                                     Constant::Units::J,
    7726          15 :                                     walkin.TotalCoolingEnergy,
    7727             :                                     OutputProcessor::TimeStepType::Zone,
    7728             :                                     OutputProcessor::StoreType::Sum,
    7729          15 :                                     walkin.Name);
    7730          30 :                 SetupOutputVariable(state,
    7731             :                                     "Refrigeration Walk In Evaporator Sensible Cooling Rate",
    7732             :                                     Constant::Units::W,
    7733          15 :                                     walkin.TotSensCoolingEnergyRate,
    7734             :                                     OutputProcessor::TimeStepType::Zone,
    7735             :                                     OutputProcessor::StoreType::Average,
    7736          15 :                                     walkin.Name);
    7737          30 :                 SetupOutputVariable(state,
    7738             :                                     "Refrigeration Walk In Evaporator Sensible Cooling Energy",
    7739             :                                     Constant::Units::J,
    7740          15 :                                     walkin.TotSensCoolingEnergy,
    7741             :                                     OutputProcessor::TimeStepType::Zone,
    7742             :                                     OutputProcessor::StoreType::Sum,
    7743          15 :                                     walkin.Name);
    7744          30 :                 SetupOutputVariable(state,
    7745             :                                     "Refrigeration Walk In Evaporator Latent Cooling Rate",
    7746             :                                     Constant::Units::W,
    7747          15 :                                     walkin.TotLatCoolingEnergyRate,
    7748             :                                     OutputProcessor::TimeStepType::Zone,
    7749             :                                     OutputProcessor::StoreType::Average,
    7750          15 :                                     walkin.Name);
    7751          30 :                 SetupOutputVariable(state,
    7752             :                                     "Refrigeration Walk In Evaporator Latent Cooling Energy",
    7753             :                                     Constant::Units::J,
    7754          15 :                                     walkin.TotLatCoolingEnergy,
    7755             :                                     OutputProcessor::TimeStepType::Zone,
    7756             :                                     OutputProcessor::StoreType::Sum,
    7757          15 :                                     walkin.Name);
    7758          30 :                 SetupOutputVariable(state,
    7759             :                                     "Refrigeration Walk In Ancillary Electricity Rate",
    7760             :                                     Constant::Units::W,
    7761          15 :                                     walkin.TotalElecPower,
    7762             :                                     OutputProcessor::TimeStepType::Zone,
    7763             :                                     OutputProcessor::StoreType::Average,
    7764          15 :                                     walkin.Name);
    7765          30 :                 SetupOutputVariable(state,
    7766             :                                     "Refrigeration Walk In Ancillary Electricity Energy",
    7767             :                                     Constant::Units::J,
    7768          15 :                                     walkin.TotalElecConsumption,
    7769             :                                     OutputProcessor::TimeStepType::Zone,
    7770             :                                     OutputProcessor::StoreType::Sum,
    7771          15 :                                     walkin.Name);
    7772          30 :                 SetupOutputVariable(state,
    7773             :                                     "Refrigeration Walk In Fan Electricity Rate",
    7774             :                                     Constant::Units::W,
    7775          15 :                                     walkin.ElecFanPower,
    7776             :                                     OutputProcessor::TimeStepType::Zone,
    7777             :                                     OutputProcessor::StoreType::Average,
    7778          15 :                                     walkin.Name);
    7779          30 :                 SetupOutputVariable(state,
    7780             :                                     "Refrigeration Walk In Fan Electricity Energy",
    7781             :                                     Constant::Units::J,
    7782          15 :                                     walkin.ElecFanConsumption,
    7783             :                                     OutputProcessor::TimeStepType::Zone,
    7784             :                                     OutputProcessor::StoreType::Sum,
    7785          15 :                                     walkin.Name,
    7786             :                                     Constant::eResource::Electricity,
    7787             :                                     OutputProcessor::Group::Building,
    7788             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7789             :                                     "General");
    7790          30 :                 SetupOutputVariable(state,
    7791             :                                     "Refrigeration Walk In Lighting Electricity Rate",
    7792             :                                     Constant::Units::W,
    7793          15 :                                     walkin.ElecLightingPower,
    7794             :                                     OutputProcessor::TimeStepType::Zone,
    7795             :                                     OutputProcessor::StoreType::Average,
    7796          15 :                                     walkin.Name);
    7797          30 :                 SetupOutputVariable(state,
    7798             :                                     "Refrigeration Walk In Lighting Electricity Energy",
    7799             :                                     Constant::Units::J,
    7800          15 :                                     walkin.ElecLightingConsumption,
    7801             :                                     OutputProcessor::TimeStepType::Zone,
    7802             :                                     OutputProcessor::StoreType::Sum,
    7803          15 :                                     walkin.Name,
    7804             :                                     Constant::eResource::Electricity,
    7805             :                                     OutputProcessor::Group::Building,
    7806             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7807             :                                     "General");
    7808          30 :                 SetupOutputVariable(state,
    7809             :                                     "Refrigeration Walk In Heater Electricity Rate",
    7810             :                                     Constant::Units::W,
    7811          15 :                                     walkin.ElecHeaterPower,
    7812             :                                     OutputProcessor::TimeStepType::Zone,
    7813             :                                     OutputProcessor::StoreType::Average,
    7814          15 :                                     walkin.Name);
    7815          30 :                 SetupOutputVariable(state,
    7816             :                                     "Refrigeration Walk In Heater Electricity Energy",
    7817             :                                     Constant::Units::J,
    7818          15 :                                     walkin.ElecHeaterConsumption,
    7819             :                                     OutputProcessor::TimeStepType::Zone,
    7820             :                                     OutputProcessor::StoreType::Sum,
    7821          15 :                                     walkin.Name,
    7822             :                                     Constant::eResource::Electricity,
    7823             :                                     OutputProcessor::Group::Building,
    7824             :                                     OutputProcessor::EndUseCat::Refrigeration,
    7825             :                                     "General");
    7826             : 
    7827             :                 // Report only for WalkIns using electric defrost
    7828          15 :                 if (walkin.defrostType == WalkinClrDefrostType::Elec) {
    7829          26 :                     SetupOutputVariable(state,
    7830             :                                         "Refrigeration Walk In Defrost Electricity Rate",
    7831             :                                         Constant::Units::W,
    7832          13 :                                         walkin.ElecDefrostPower,
    7833             :                                         OutputProcessor::TimeStepType::Zone,
    7834             :                                         OutputProcessor::StoreType::Average,
    7835          13 :                                         walkin.Name);
    7836          26 :                     SetupOutputVariable(state,
    7837             :                                         "Refrigeration Walk In Defrost Electricity Energy",
    7838             :                                         Constant::Units::J,
    7839          13 :                                         walkin.ElecDefrostConsumption,
    7840             :                                         OutputProcessor::TimeStepType::Zone,
    7841             :                                         OutputProcessor::StoreType::Sum,
    7842          13 :                                         walkin.Name,
    7843             :                                         Constant::eResource::Electricity,
    7844             :                                         OutputProcessor::Group::Building,
    7845             :                                         OutputProcessor::EndUseCat::Refrigeration,
    7846             :                                         "General");
    7847             :                 }
    7848             : 
    7849             :                 // Report walkin variables that are specified for each zone exposed to the walkin
    7850             :                 // For "IDOut" variable in SetupOutputVariable, need to create a single name that includes
    7851             :                 //    both the walk-in name and the zone name - see "Walkin_and_zone_name" concatination
    7852             :                 //    This new variable name is important if using an rvi file!
    7853          30 :                 for (int zoneId = 1; zoneId <= walkin.NumZones; ++zoneId) {
    7854             : 
    7855          15 :                     Walkin_and_zone_name = walkin.Name + "InZone" + walkin.ZoneName(zoneId);
    7856             : 
    7857          30 :                     SetupOutputVariable(state,
    7858             :                                         "Refrigeration Walk In Zone Sensible Cooling Rate",
    7859             :                                         Constant::Units::W,
    7860          15 :                                         walkin.SensZoneCreditCoolRate(zoneId),
    7861             :                                         OutputProcessor::TimeStepType::Zone,
    7862             :                                         OutputProcessor::StoreType::Average,
    7863             :                                         Walkin_and_zone_name);
    7864          30 :                     SetupOutputVariable(state,
    7865             :                                         "Refrigeration Walk In Zone Sensible Cooling Energy",
    7866             :                                         Constant::Units::J,
    7867          15 :                                         walkin.SensZoneCreditCool(zoneId),
    7868             :                                         OutputProcessor::TimeStepType::Zone,
    7869             :                                         OutputProcessor::StoreType::Sum,
    7870             :                                         Walkin_and_zone_name);
    7871          30 :                     SetupOutputVariable(state,
    7872             :                                         "Refrigeration Walk In Zone Sensible Heating Rate",
    7873             :                                         Constant::Units::W,
    7874          15 :                                         walkin.SensZoneCreditHeatRate(zoneId),
    7875             :                                         OutputProcessor::TimeStepType::Zone,
    7876             :                                         OutputProcessor::StoreType::Average,
    7877             :                                         Walkin_and_zone_name);
    7878          30 :                     SetupOutputVariable(state,
    7879             :                                         "Refrigeration Walk In Zone Sensible Heating Energy",
    7880             :                                         Constant::Units::J,
    7881          15 :                                         walkin.SensZoneCreditHeat(zoneId),
    7882             :                                         OutputProcessor::TimeStepType::Zone,
    7883             :                                         OutputProcessor::StoreType::Sum,
    7884             :                                         Walkin_and_zone_name);
    7885          30 :                     SetupOutputVariable(state,
    7886             :                                         "Refrigeration Walk In Zone Latent Rate",
    7887             :                                         Constant::Units::W,
    7888          15 :                                         walkin.LatZoneCreditRate(zoneId),
    7889             :                                         OutputProcessor::TimeStepType::Zone,
    7890             :                                         OutputProcessor::StoreType::Average,
    7891             :                                         Walkin_and_zone_name);
    7892          30 :                     SetupOutputVariable(state,
    7893             :                                         "Refrigeration Walk In Zone Latent Energy",
    7894             :                                         Constant::Units::J,
    7895          15 :                                         walkin.LatZoneCredit(zoneId),
    7896             :                                         OutputProcessor::TimeStepType::Zone,
    7897             :                                         OutputProcessor::StoreType::Sum,
    7898             :                                         Walkin_and_zone_name);
    7899             : 
    7900          15 :                     if (walkin.ZoneNum(zoneId) > 0)
    7901          30 :                         SetupZoneInternalGain(state,
    7902          15 :                                               walkin.ZoneNum(zoneId),
    7903             :                                               Walkin_and_zone_name,
    7904             :                                               DataHeatBalance::IntGainType::RefrigerationWalkIn,
    7905          15 :                                               &walkin.SensZoneCreditRate(zoneId),
    7906             :                                               nullptr,
    7907             :                                               nullptr,
    7908          15 :                                               &walkin.LatZoneCreditRate(zoneId));
    7909             : 
    7910             :                 } // ZoneID
    7911             :             }     //(.NOT.  WalkIn( WalkInNum)%unusedWalkIn)
    7912             :         }         // NumSimulationWalkIns
    7913             :     }             // NumSimulationWalkIns > 0
    7914             : 
    7915         796 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7916             :         // Setup Report Variables for simulated Warehouse coils (do not report unused warehouse coils)
    7917             :         // CurrentModuleObject='Refrigeration:AirChiller'
    7918          84 :         for (int coilNum = 1; coilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilNum) {
    7919          83 :             auto &coil = WarehouseCoil(coilNum);
    7920          83 :             if (coil.NumSysAttach == 1) { // ensure no unuseds reported
    7921         166 :                 SetupOutputVariable(state,
    7922             :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    7923             :                                     Constant::Units::W,
    7924          83 :                                     coil.TotalCoolingLoad,
    7925             :                                     OutputProcessor::TimeStepType::System,
    7926             :                                     OutputProcessor::StoreType::Average,
    7927          83 :                                     coil.Name);
    7928         166 :                 SetupOutputVariable(state,
    7929             :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    7930             :                                     Constant::Units::J,
    7931          83 :                                     coil.TotalCoolingEnergy,
    7932             :                                     OutputProcessor::TimeStepType::System,
    7933             :                                     OutputProcessor::StoreType::Sum,
    7934          83 :                                     coil.Name);
    7935         166 :                 SetupOutputVariable(state,
    7936             :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    7937             :                                     Constant::Units::W,
    7938          83 :                                     coil.SensCoolingEnergyRate,
    7939             :                                     OutputProcessor::TimeStepType::System,
    7940             :                                     OutputProcessor::StoreType::Average,
    7941          83 :                                     coil.Name);
    7942         166 :                 SetupOutputVariable(state,
    7943             :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    7944             :                                     Constant::Units::J,
    7945          83 :                                     coil.SensCoolingEnergy,
    7946             :                                     OutputProcessor::TimeStepType::System,
    7947             :                                     OutputProcessor::StoreType::Sum,
    7948          83 :                                     coil.Name);
    7949         166 :                 SetupOutputVariable(state,
    7950             :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    7951             :                                     Constant::Units::W,
    7952          83 :                                     coil.LatCreditRate,
    7953             :                                     OutputProcessor::TimeStepType::System,
    7954             :                                     OutputProcessor::StoreType::Average,
    7955          83 :                                     coil.Name);
    7956         166 :                 SetupOutputVariable(state,
    7957             :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    7958             :                                     Constant::Units::J,
    7959          83 :                                     coil.LatCreditEnergy,
    7960             :                                     OutputProcessor::TimeStepType::System,
    7961             :                                     OutputProcessor::StoreType::Sum,
    7962          83 :                                     coil.Name);
    7963         166 :                 SetupOutputVariable(state,
    7964             :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    7965             :                                     Constant::Units::kg_s,
    7966          83 :                                     coil.LatKgPerS_ToZone,
    7967             :                                     OutputProcessor::TimeStepType::System,
    7968             :                                     OutputProcessor::StoreType::Average,
    7969          83 :                                     coil.Name);
    7970         166 :                 SetupOutputVariable(state,
    7971             :                                     "Refrigeration Zone Air Chiller Total Electricity Rate",
    7972             :                                     Constant::Units::W,
    7973          83 :                                     coil.TotalElecPower,
    7974             :                                     OutputProcessor::TimeStepType::System,
    7975             :                                     OutputProcessor::StoreType::Average,
    7976          83 :                                     coil.Name);
    7977         166 :                 SetupOutputVariable(state,
    7978             :                                     "Refrigeration Zone Air Chiller Total Electricity Energy",
    7979             :                                     Constant::Units::J,
    7980          83 :                                     coil.TotalElecConsumption,
    7981             :                                     OutputProcessor::TimeStepType::System,
    7982             :                                     OutputProcessor::StoreType::Sum,
    7983          83 :                                     coil.Name); // components are metered seperately
    7984         166 :                 SetupOutputVariable(state,
    7985             :                                     "Refrigeration Zone Air Chiller Fan Electricity Rate",
    7986             :                                     Constant::Units::W,
    7987          83 :                                     coil.ElecFanPower,
    7988             :                                     OutputProcessor::TimeStepType::System,
    7989             :                                     OutputProcessor::StoreType::Average,
    7990          83 :                                     coil.Name);
    7991         166 :                 SetupOutputVariable(state,
    7992             :                                     "Refrigeration Zone Air Chiller Fan Electric Energy",
    7993             :                                     Constant::Units::J,
    7994          83 :                                     coil.ElecFanConsumption,
    7995             :                                     OutputProcessor::TimeStepType::System,
    7996             :                                     OutputProcessor::StoreType::Sum,
    7997          83 :                                     coil.Name,
    7998             :                                     Constant::eResource::Electricity,
    7999             :                                     OutputProcessor::Group::Building,
    8000             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8001             :                                     "General");
    8002         166 :                 SetupOutputVariable(state,
    8003             :                                     "Refrigeration Zone Air Chiller Heater Electricity Rate",
    8004             :                                     Constant::Units::W,
    8005          83 :                                     coil.ElecHeaterPower,
    8006             :                                     OutputProcessor::TimeStepType::System,
    8007             :                                     OutputProcessor::StoreType::Average,
    8008          83 :                                     coil.Name);
    8009         166 :                 SetupOutputVariable(state,
    8010             :                                     "Refrigeration Zone Air Chiller Heater Electricity Energy",
    8011             :                                     Constant::Units::J,
    8012          83 :                                     coil.ElecHeaterConsumption,
    8013             :                                     OutputProcessor::TimeStepType::System,
    8014             :                                     OutputProcessor::StoreType::Sum,
    8015          83 :                                     coil.Name,
    8016             :                                     Constant::eResource::Electricity,
    8017             :                                     OutputProcessor::Group::Building,
    8018             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8019             :                                     "General");
    8020         166 :                 SetupOutputVariable(state,
    8021             :                                     "Refrigeration Zone Air Chiller Sensible Heat Ratio",
    8022             :                                     Constant::Units::None,
    8023          83 :                                     coil.SensHeatRatio,
    8024             :                                     OutputProcessor::TimeStepType::System,
    8025             :                                     OutputProcessor::StoreType::Average,
    8026          83 :                                     coil.Name);
    8027         166 :                 SetupOutputVariable(state,
    8028             :                                     "Refrigeration Zone Air Chiller Frost Accumulation Mass",
    8029             :                                     Constant::Units::kg,
    8030          83 :                                     coil.KgFrost,
    8031             :                                     OutputProcessor::TimeStepType::System,
    8032             :                                     OutputProcessor::StoreType::Average,
    8033          83 :                                     coil.Name);
    8034         166 :                 SetupOutputVariable(state,
    8035             :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Rate",
    8036             :                                     Constant::Units::W,
    8037          83 :                                     coil.ReportTotalCoolCreditRate,
    8038             :                                     OutputProcessor::TimeStepType::System,
    8039             :                                     OutputProcessor::StoreType::Average,
    8040          83 :                                     coil.Name);
    8041         166 :                 SetupOutputVariable(state,
    8042             :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Energy",
    8043             :                                     Constant::Units::J,
    8044          83 :                                     coil.ReportTotalCoolCreditEnergy,
    8045             :                                     OutputProcessor::TimeStepType::System,
    8046             :                                     OutputProcessor::StoreType::Sum,
    8047          83 :                                     coil.Name);
    8048         166 :                 SetupOutputVariable(state,
    8049             :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Rate",
    8050             :                                     Constant::Units::W,
    8051          83 :                                     coil.ReportSensCoolCreditRate,
    8052             :                                     OutputProcessor::TimeStepType::System,
    8053             :                                     OutputProcessor::StoreType::Average,
    8054          83 :                                     coil.Name);
    8055         166 :                 SetupOutputVariable(state,
    8056             :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Energy",
    8057             :                                     Constant::Units::J,
    8058          83 :                                     coil.ReportSensCoolCreditEnergy,
    8059             :                                     OutputProcessor::TimeStepType::System,
    8060             :                                     OutputProcessor::StoreType::Sum,
    8061          83 :                                     coil.Name);
    8062         166 :                 SetupOutputVariable(state,
    8063             :                                     "Refrigeration Zone Air Chiller Zone Heating Rate",
    8064             :                                     Constant::Units::W,
    8065          83 :                                     coil.ReportHeatingCreditRate,
    8066             :                                     OutputProcessor::TimeStepType::System,
    8067             :                                     OutputProcessor::StoreType::Average,
    8068          83 :                                     coil.Name);
    8069         166 :                 SetupOutputVariable(state,
    8070             :                                     "Refrigeration Zone Air Chiller Zone Heating Energy",
    8071             :                                     Constant::Units::J,
    8072          83 :                                     coil.ReportHeatingCreditEnergy,
    8073             :                                     OutputProcessor::TimeStepType::System,
    8074             :                                     OutputProcessor::StoreType::Sum,
    8075          83 :                                     coil.Name);
    8076             : 
    8077             :                 // Report only for Warehouse coils using electric defrost
    8078          83 :                 if (coil.defrostType == DefrostType::Elec) {
    8079         164 :                     SetupOutputVariable(state,
    8080             :                                         "Refrigeration Zone Air Chiller Defrost Electricity Rate",
    8081             :                                         Constant::Units::W,
    8082          82 :                                         coil.ElecDefrostPower,
    8083             :                                         OutputProcessor::TimeStepType::System,
    8084             :                                         OutputProcessor::StoreType::Average,
    8085          82 :                                         coil.Name);
    8086         164 :                     SetupOutputVariable(state,
    8087             :                                         "Refrigeration Zone Air Chiller Defrost Electricity Energy",
    8088             :                                         Constant::Units::J,
    8089          82 :                                         coil.ElecDefrostConsumption,
    8090             :                                         OutputProcessor::TimeStepType::System,
    8091             :                                         OutputProcessor::StoreType::Sum,
    8092          82 :                                         coil.Name,
    8093             :                                         Constant::eResource::Electricity,
    8094             :                                         OutputProcessor::Group::Building,
    8095             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8096             :                                         "General");
    8097             :                 } // electric defrost coil
    8098             :             }     //(.NOT.  coil%unusedWarehouseCoil)
    8099             :         }         // NumSimulationWarehouseCoils
    8100             :     }             // NumSimulationRefrigAirChillers > 0
    8101             : 
    8102             :     // There are no report variables for Chiller sets because they are
    8103             :     // used to pass the demand to the coils, but are NOT used to provide the
    8104             :     // cooling energy to the zone (because more than one set may cool a zone)
    8105             : 
    8106             :     // Report sum of all refrigeration interactions with each zone
    8107             : 
    8108        5852 :     for (int zoneID = 1; zoneID <= state.dataGlobal->NumOfZones; ++zoneID) {
    8109        5056 :         if (state.dataRefrigCase->RefrigPresentInZone(zoneID)) {
    8110          69 :             if (state.dataRefrigCase->HaveCasesOrWalkins) {
    8111         118 :                 SetupOutputVariable(state,
    8112             :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Rate",
    8113             :                                     Constant::Units::W,
    8114          59 :                                     state.dataHeatBal->RefrigCaseCredit(zoneID).SenCaseCreditToZone,
    8115             :                                     OutputProcessor::TimeStepType::Zone,
    8116             :                                     OutputProcessor::StoreType::Average,
    8117          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8118         118 :                 SetupOutputVariable(state,
    8119             :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Energy",
    8120             :                                     Constant::Units::J,
    8121          59 :                                     CaseWIZoneReport(zoneID).SenCaseCreditToZoneEnergy,
    8122             :                                     OutputProcessor::TimeStepType::Zone,
    8123             :                                     OutputProcessor::StoreType::Sum,
    8124          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8125         118 :                 SetupOutputVariable(state,
    8126             :                                     "Refrigeration Zone Case and Walk In Heating Rate",
    8127             :                                     Constant::Units::W,
    8128          59 :                                     CaseWIZoneReport(zoneID).HeatingToZoneRate,
    8129             :                                     OutputProcessor::TimeStepType::Zone,
    8130             :                                     OutputProcessor::StoreType::Average,
    8131          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8132         118 :                 SetupOutputVariable(state,
    8133             :                                     "Refrigeration Zone Case and Walk In Heating Energy",
    8134             :                                     Constant::Units::J,
    8135          59 :                                     CaseWIZoneReport(zoneID).HeatingToZoneEnergy,
    8136             :                                     OutputProcessor::TimeStepType::Zone,
    8137             :                                     OutputProcessor::StoreType::Sum,
    8138          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8139         118 :                 SetupOutputVariable(state,
    8140             :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Rate",
    8141             :                                     Constant::Units::W,
    8142          59 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneRate,
    8143             :                                     OutputProcessor::TimeStepType::Zone,
    8144             :                                     OutputProcessor::StoreType::Average,
    8145          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8146         118 :                 SetupOutputVariable(state,
    8147             :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Energy",
    8148             :                                     Constant::Units::J,
    8149          59 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneEnergy,
    8150             :                                     OutputProcessor::TimeStepType::Zone,
    8151             :                                     OutputProcessor::StoreType::Sum,
    8152          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8153         118 :                 SetupOutputVariable(state,
    8154             :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Rate",
    8155             :                                     Constant::Units::W,
    8156          59 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneRate,
    8157             :                                     OutputProcessor::TimeStepType::Zone,
    8158             :                                     OutputProcessor::StoreType::Average,
    8159          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8160         118 :                 SetupOutputVariable(state,
    8161             :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Energy",
    8162             :                                     Constant::Units::J,
    8163          59 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneEnergy,
    8164             :                                     OutputProcessor::TimeStepType::Zone,
    8165             :                                     OutputProcessor::StoreType::Sum,
    8166          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8167         118 :                 SetupOutputVariable(state,
    8168             :                                     "Refrigeration Zone Case and Walk In Total Cooling Rate",
    8169             :                                     Constant::Units::W,
    8170          59 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneRate,
    8171             :                                     OutputProcessor::TimeStepType::Zone,
    8172             :                                     OutputProcessor::StoreType::Average,
    8173          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8174         118 :                 SetupOutputVariable(state,
    8175             :                                     "Refrigeration Zone Case and Walk In Total Cooling Energy",
    8176             :                                     Constant::Units::J,
    8177          59 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneEnergy,
    8178             :                                     OutputProcessor::TimeStepType::Zone,
    8179             :                                     OutputProcessor::StoreType::Sum,
    8180          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8181         118 :                 SetupOutputVariable(state,
    8182             :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Rate",
    8183             :                                     Constant::Units::W,
    8184          59 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneRate,
    8185             :                                     OutputProcessor::TimeStepType::Zone,
    8186             :                                     OutputProcessor::StoreType::Average,
    8187          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8188         118 :                 SetupOutputVariable(state,
    8189             :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Energy",
    8190             :                                     Constant::Units::J,
    8191          59 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneEnergy,
    8192             :                                     OutputProcessor::TimeStepType::Zone,
    8193             :                                     OutputProcessor::StoreType::Sum,
    8194          59 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8195             :             } // HaveCasesOrWalkIns
    8196             : 
    8197          69 :             if (state.dataRefrigCase->HaveChillers) {
    8198          20 :                 SetupOutputVariable(state,
    8199             :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Rate",
    8200             :                                     Constant::Units::W,
    8201          10 :                                     CoilSysCredit(zoneID).SenCreditToZoneRate,
    8202             :                                     OutputProcessor::TimeStepType::System,
    8203             :                                     OutputProcessor::StoreType::Average,
    8204          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8205          20 :                 SetupOutputVariable(state,
    8206             :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Energy",
    8207             :                                     Constant::Units::J,
    8208          10 :                                     CoilSysCredit(zoneID).SenCreditToZoneEnergy,
    8209             :                                     OutputProcessor::TimeStepType::System,
    8210             :                                     OutputProcessor::StoreType::Sum,
    8211          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8212          20 :                 SetupOutputVariable(state,
    8213             :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    8214             :                                     Constant::Units::W,
    8215          10 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneRate,
    8216             :                                     OutputProcessor::TimeStepType::System,
    8217             :                                     OutputProcessor::StoreType::Average,
    8218          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8219          20 :                 SetupOutputVariable(state,
    8220             :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    8221             :                                     Constant::Units::J,
    8222          10 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneEnergy,
    8223             :                                     OutputProcessor::TimeStepType::System,
    8224             :                                     OutputProcessor::StoreType::Sum,
    8225          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8226          20 :                 SetupOutputVariable(state,
    8227             :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    8228             :                                     Constant::Units::W,
    8229          10 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneRate,
    8230             :                                     OutputProcessor::TimeStepType::System,
    8231             :                                     OutputProcessor::StoreType::Average,
    8232          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8233          20 :                 SetupOutputVariable(state,
    8234             :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    8235             :                                     Constant::Units::J,
    8236          10 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneEnergy,
    8237             :                                     OutputProcessor::TimeStepType::System,
    8238             :                                     OutputProcessor::StoreType::Sum,
    8239          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8240          20 :                 SetupOutputVariable(state,
    8241             :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    8242             :                                     Constant::Units::kg_s,
    8243          10 :                                     CoilSysCredit(zoneID).ReportH2ORemovedKgPerS_FromZoneRate,
    8244             :                                     OutputProcessor::TimeStepType::System,
    8245             :                                     OutputProcessor::StoreType::Average,
    8246          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8247          20 :                 SetupOutputVariable(state,
    8248             :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    8249             :                                     Constant::Units::W,
    8250          10 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneRate,
    8251             :                                     OutputProcessor::TimeStepType::System,
    8252             :                                     OutputProcessor::StoreType::Average,
    8253          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8254          20 :                 SetupOutputVariable(state,
    8255             :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    8256             :                                     Constant::Units::J,
    8257          10 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneEnergy,
    8258             :                                     OutputProcessor::TimeStepType::System,
    8259             :                                     OutputProcessor::StoreType::Sum,
    8260          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8261          20 :                 SetupOutputVariable(state,
    8262             :                                     "Refrigeration Zone Air Chiller Heating Rate",
    8263             :                                     Constant::Units::W,
    8264          10 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneRate,
    8265             :                                     OutputProcessor::TimeStepType::System,
    8266             :                                     OutputProcessor::StoreType::Average,
    8267          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8268          20 :                 SetupOutputVariable(state,
    8269             :                                     "Refrigeration Zone Air Chiller Heating Energy",
    8270             :                                     Constant::Units::J,
    8271          10 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneEnergy,
    8272             :                                     OutputProcessor::TimeStepType::System,
    8273             :                                     OutputProcessor::StoreType::Sum,
    8274          10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8275             :             } // HaveChillers
    8276             :         }     // RefrigPresentInZone(ZoneID)
    8277             :     }         // ZoneID
    8278             : 
    8279         796 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    8280             :         // CurrentModuleObject='Refrigeration:SecondarySystem'
    8281           3 :         for (int secondNum = 1; secondNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondNum) {
    8282           2 :             auto &secondary = Secondary(secondNum);
    8283           2 :             if (secondary.NumSysAttach == 1) {
    8284           2 :                 if (secondary.CoilFlag) { // secondary system serves chillers and is solved on HVAC time step
    8285           0 :                     SetupOutputVariable(state,
    8286             :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Rate",
    8287             :                                         Constant::Units::W,
    8288           0 :                                         secondary.PumpPowerTotal,
    8289             :                                         OutputProcessor::TimeStepType::System,
    8290             :                                         OutputProcessor::StoreType::Average,
    8291           0 :                                         secondary.Name);
    8292           0 :                     SetupOutputVariable(state,
    8293             :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Energy",
    8294             :                                         Constant::Units::J,
    8295           0 :                                         secondary.PumpElecEnergyTotal,
    8296             :                                         OutputProcessor::TimeStepType::System,
    8297             :                                         OutputProcessor::StoreType::Sum,
    8298           0 :                                         secondary.Name,
    8299             :                                         Constant::eResource::Electricity,
    8300             :                                         OutputProcessor::Group::Plant,
    8301             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8302             :                                         secondary.EndUseSubcategory);
    8303           0 :                     SetupOutputVariable(state,
    8304             :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Rate",
    8305             :                                         Constant::Units::W,
    8306           0 :                                         secondary.TotalRefrigLoad,
    8307             :                                         OutputProcessor::TimeStepType::System,
    8308             :                                         OutputProcessor::StoreType::Average,
    8309           0 :                                         secondary.Name);
    8310           0 :                     SetupOutputVariable(state,
    8311             :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Energy",
    8312             :                                         Constant::Units::J,
    8313           0 :                                         secondary.TotalRefrigEnergy,
    8314             :                                         OutputProcessor::TimeStepType::System,
    8315             :                                         OutputProcessor::StoreType::Sum,
    8316           0 :                                         secondary.Name);
    8317           0 :                     SetupOutputVariable(state,
    8318             :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Rate",
    8319             :                                         Constant::Units::W,
    8320           0 :                                         secondary.TotalCoolingLoad,
    8321             :                                         OutputProcessor::TimeStepType::System,
    8322             :                                         OutputProcessor::StoreType::Average,
    8323           0 :                                         secondary.Name);
    8324           0 :                     SetupOutputVariable(state,
    8325             :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Energy",
    8326             :                                         Constant::Units::J,
    8327           0 :                                         secondary.TotalCoolingEnergy,
    8328             :                                         OutputProcessor::TimeStepType::System,
    8329             :                                         OutputProcessor::StoreType::Sum,
    8330           0 :                                         secondary.Name);
    8331           0 :                     SetupOutputVariable(state,
    8332             :                                         "Refrigeration Air Chiller Secondary Loop Estimated Refrigerant Inventory Mass",
    8333             :                                         Constant::Units::kg,
    8334           0 :                                         secondary.RefInventory,
    8335             :                                         OutputProcessor::TimeStepType::System,
    8336             :                                         OutputProcessor::StoreType::Average,
    8337           0 :                                         secondary.Name);
    8338           0 :                     SetupOutputVariable(state,
    8339             :                                         "Refrigeration Air Chiller Secondary Loop Volume Flow Rate",
    8340             :                                         Constant::Units::m3_s,
    8341           0 :                                         secondary.FlowVolActual,
    8342             :                                         OutputProcessor::TimeStepType::System,
    8343             :                                         OutputProcessor::StoreType::Average,
    8344           0 :                                         secondary.Name);
    8345           0 :                     SetupOutputVariable(state,
    8346             :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Rate",
    8347             :                                         Constant::Units::W,
    8348           0 :                                         secondary.DistPipeHeatGain,
    8349             :                                         OutputProcessor::TimeStepType::System,
    8350             :                                         OutputProcessor::StoreType::Average,
    8351           0 :                                         secondary.Name);
    8352           0 :                     SetupOutputVariable(state,
    8353             :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Energy",
    8354             :                                         Constant::Units::J,
    8355           0 :                                         secondary.DistPipeHeatGainEnergy,
    8356             :                                         OutputProcessor::TimeStepType::System,
    8357             :                                         OutputProcessor::StoreType::Sum,
    8358           0 :                                         secondary.Name);
    8359           0 :                     SetupOutputVariable(state,
    8360             :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Rate",
    8361             :                                         Constant::Units::W,
    8362           0 :                                         secondary.ReceiverHeatGain,
    8363             :                                         OutputProcessor::TimeStepType::System,
    8364             :                                         OutputProcessor::StoreType::Average,
    8365           0 :                                         secondary.Name);
    8366           0 :                     SetupOutputVariable(state,
    8367             :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Energy",
    8368             :                                         Constant::Units::J,
    8369           0 :                                         secondary.ReceiverHeatGainEnergy,
    8370             :                                         OutputProcessor::TimeStepType::System,
    8371             :                                         OutputProcessor::StoreType::Sum,
    8372           0 :                                         secondary.Name);
    8373             :                 } else { // Secondary loop serves cases and walk-ins on zone(load) time step
    8374           4 :                     SetupOutputVariable(state,
    8375             :                                         "Refrigeration Secondary Loop Pump Electricity Rate",
    8376             :                                         Constant::Units::W,
    8377           2 :                                         secondary.PumpPowerTotal,
    8378             :                                         OutputProcessor::TimeStepType::Zone,
    8379             :                                         OutputProcessor::StoreType::Average,
    8380           2 :                                         secondary.Name);
    8381           4 :                     SetupOutputVariable(state,
    8382             :                                         "Refrigeration Secondary Loop Pump Electricity Energy",
    8383             :                                         Constant::Units::J,
    8384           2 :                                         secondary.PumpElecEnergyTotal,
    8385             :                                         OutputProcessor::TimeStepType::Zone,
    8386             :                                         OutputProcessor::StoreType::Sum,
    8387           2 :                                         secondary.Name,
    8388             :                                         Constant::eResource::Electricity,
    8389             :                                         OutputProcessor::Group::Plant,
    8390             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8391             :                                         secondary.EndUseSubcategory);
    8392           4 :                     SetupOutputVariable(state,
    8393             :                                         "Refrigeration Secondary Loop Load Heat Transfer Rate",
    8394             :                                         Constant::Units::W,
    8395           2 :                                         secondary.TotalRefrigLoad,
    8396             :                                         OutputProcessor::TimeStepType::Zone,
    8397             :                                         OutputProcessor::StoreType::Average,
    8398           2 :                                         secondary.Name);
    8399           4 :                     SetupOutputVariable(state,
    8400             :                                         "Refrigeration Secondary Loop Load Heat Transfer Energy",
    8401             :                                         Constant::Units::J,
    8402           2 :                                         secondary.TotalRefrigEnergy,
    8403             :                                         OutputProcessor::TimeStepType::Zone,
    8404             :                                         OutputProcessor::StoreType::Sum,
    8405           2 :                                         secondary.Name);
    8406           4 :                     SetupOutputVariable(state,
    8407             :                                         "Refrigeration Secondary Loop Total Heat Transfer Rate",
    8408             :                                         Constant::Units::W,
    8409           2 :                                         secondary.TotalCoolingLoad,
    8410             :                                         OutputProcessor::TimeStepType::Zone,
    8411             :                                         OutputProcessor::StoreType::Average,
    8412           2 :                                         secondary.Name);
    8413           4 :                     SetupOutputVariable(state,
    8414             :                                         "Refrigeration Secondary Loop Total Heat Transfer Energy",
    8415             :                                         Constant::Units::J,
    8416           2 :                                         secondary.TotalCoolingEnergy,
    8417             :                                         OutputProcessor::TimeStepType::Zone,
    8418             :                                         OutputProcessor::StoreType::Sum,
    8419           2 :                                         secondary.Name);
    8420           4 :                     SetupOutputVariable(state,
    8421             :                                         "Refrigeration Secondary Loop Estimated Refrigerant Inventory Mass",
    8422             :                                         Constant::Units::kg,
    8423           2 :                                         secondary.RefInventory,
    8424             :                                         OutputProcessor::TimeStepType::Zone,
    8425             :                                         OutputProcessor::StoreType::Average,
    8426           2 :                                         secondary.Name);
    8427           4 :                     SetupOutputVariable(state,
    8428             :                                         "Refrigeration Secondary Loop Volume Flow Rate",
    8429             :                                         Constant::Units::m3_s,
    8430           2 :                                         secondary.FlowVolActual,
    8431             :                                         OutputProcessor::TimeStepType::Zone,
    8432             :                                         OutputProcessor::StoreType::Average,
    8433           2 :                                         secondary.Name);
    8434           4 :                     SetupOutputVariable(state,
    8435             :                                         "Refrigeration Secondary Loop Pipe Heat Gain Rate",
    8436             :                                         Constant::Units::W,
    8437           2 :                                         secondary.DistPipeHeatGain,
    8438             :                                         OutputProcessor::TimeStepType::Zone,
    8439             :                                         OutputProcessor::StoreType::Average,
    8440           2 :                                         secondary.Name);
    8441           4 :                     SetupOutputVariable(state,
    8442             :                                         "Refrigeration Secondary Loop Pipe Heat Gain Energy",
    8443             :                                         Constant::Units::J,
    8444           2 :                                         secondary.DistPipeHeatGainEnergy,
    8445             :                                         OutputProcessor::TimeStepType::Zone,
    8446             :                                         OutputProcessor::StoreType::Sum,
    8447           2 :                                         secondary.Name);
    8448           4 :                     SetupOutputVariable(state,
    8449             :                                         "Refrigeration Secondary Loop Receiver Heat Gain Rate",
    8450             :                                         Constant::Units::W,
    8451           2 :                                         secondary.ReceiverHeatGain,
    8452             :                                         OutputProcessor::TimeStepType::Zone,
    8453             :                                         OutputProcessor::StoreType::Average,
    8454           2 :                                         secondary.Name);
    8455           4 :                     SetupOutputVariable(state,
    8456             :                                         "Refrigeration Secondary Loop Receiver Heat Gain Energy",
    8457             :                                         Constant::Units::J,
    8458           2 :                                         secondary.ReceiverHeatGainEnergy,
    8459             :                                         OutputProcessor::TimeStepType::Zone,
    8460             :                                         OutputProcessor::StoreType::Sum,
    8461           2 :                                         secondary.Name);
    8462             :                 } // NOT coilflag so on Zone timestep
    8463           2 :                 if (secondary.ReceiverZoneNum > 0) {
    8464           1 :                     SetupZoneInternalGain(state,
    8465             :                                           secondary.ReceiverZoneNum,
    8466             :                                           secondary.Name,
    8467             :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryReceiver,
    8468             :                                           &secondary.ReceiverZoneHeatGain);
    8469             :                 }
    8470           2 :                 if (secondary.DistPipeZoneNum > 0) {
    8471           2 :                     SetupZoneInternalGain(state,
    8472             :                                           secondary.DistPipeZoneNum,
    8473             :                                           secondary.Name,
    8474             :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryPipe,
    8475             :                                           &secondary.DistPipeZoneHeatGain);
    8476             :                 }
    8477             :             } // not an unused
    8478             :         }     // NumSimulationSecondarySystems
    8479             :     }         // NumSimulationSecondarySystems > 0
    8480             : 
    8481             :     // Setup Report Variables for Refrigeration Compressor Rack
    8482         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    8483             :         // CurrentModuleObject='Refrigeration:CompressorRack'
    8484          92 :         for (int rackNum = 1; rackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++rackNum) {
    8485          61 :             auto &rack = RefrigRack(rackNum);
    8486          61 :             if (rack.CoilFlag) { // rack serves chillers and is solved on HVAC time step
    8487           0 :                 SetupOutputVariable(state,
    8488             :                                     "Refrigeration Air Chiller Compressor Rack Electricity Rate",
    8489             :                                     Constant::Units::W,
    8490           0 :                                     rack.RackCompressorPower,
    8491             :                                     OutputProcessor::TimeStepType::System,
    8492             :                                     OutputProcessor::StoreType::Average,
    8493           0 :                                     rack.Name);
    8494           0 :                 SetupOutputVariable(state,
    8495             :                                     "Refrigeration Air Chiller Compressor Rack Electricity Energy",
    8496             :                                     Constant::Units::J,
    8497           0 :                                     rack.RackElecConsumption,
    8498             :                                     OutputProcessor::TimeStepType::System,
    8499             :                                     OutputProcessor::StoreType::Sum,
    8500           0 :                                     rack.Name,
    8501             :                                     Constant::eResource::Electricity,
    8502             :                                     OutputProcessor::Group::Plant,
    8503             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8504             :                                     rack.EndUseSubcategory);
    8505           0 :                 SetupOutputVariable(state,
    8506             :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Rate",
    8507             :                                     Constant::Units::W,
    8508           0 :                                     rack.ActualCondenserFanPower,
    8509             :                                     OutputProcessor::TimeStepType::System,
    8510             :                                     OutputProcessor::StoreType::Average,
    8511           0 :                                     rack.Name);
    8512           0 :                 SetupOutputVariable(state,
    8513             :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Energy",
    8514             :                                     Constant::Units::J,
    8515           0 :                                     rack.CondenserFanConsumption,
    8516             :                                     OutputProcessor::TimeStepType::System,
    8517             :                                     OutputProcessor::StoreType::Sum,
    8518           0 :                                     rack.Name,
    8519             :                                     Constant::eResource::Electricity,
    8520             :                                     OutputProcessor::Group::Plant,
    8521             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8522             :                                     rack.EndUseSubcategory);
    8523           0 :                 SetupOutputVariable(state,
    8524             :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Rate",
    8525             :                                     Constant::Units::W,
    8526           0 :                                     rack.RackCapacity,
    8527             :                                     OutputProcessor::TimeStepType::System,
    8528             :                                     OutputProcessor::StoreType::Average,
    8529           0 :                                     rack.Name);
    8530           0 :                 SetupOutputVariable(state,
    8531             :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Energy",
    8532             :                                     Constant::Units::J,
    8533           0 :                                     rack.RackCoolingEnergy,
    8534             :                                     OutputProcessor::TimeStepType::System,
    8535             :                                     OutputProcessor::StoreType::Sum,
    8536           0 :                                     rack.Name,
    8537             :                                     Constant::eResource::EnergyTransfer,
    8538             :                                     OutputProcessor::Group::Plant,
    8539             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8540             :                                     rack.EndUseSubcategory);
    8541           0 :                 SetupOutputVariable(state,
    8542             :                                     "Refrigeration Air Chiller Compressor Rack COP",
    8543             :                                     Constant::Units::W_W,
    8544           0 :                                     rack.RackCompressorCOP,
    8545             :                                     OutputProcessor::TimeStepType::System,
    8546             :                                     OutputProcessor::StoreType::Average,
    8547           0 :                                     rack.Name);
    8548             : 
    8549           0 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8550           0 :                     SetupOutputVariable(state,
    8551             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8552             :                                         Constant::Units::W,
    8553           0 :                                         rack.ActualEvapPumpPower,
    8554             :                                         OutputProcessor::TimeStepType::System,
    8555             :                                         OutputProcessor::StoreType::Average,
    8556           0 :                                         rack.Name);
    8557           0 :                     SetupOutputVariable(state,
    8558             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8559             :                                         Constant::Units::J,
    8560           0 :                                         rack.EvapPumpConsumption,
    8561             :                                         OutputProcessor::TimeStepType::System,
    8562             :                                         OutputProcessor::StoreType::Sum,
    8563           0 :                                         rack.Name,
    8564             :                                         Constant::eResource::Electricity,
    8565             :                                         OutputProcessor::Group::Plant,
    8566             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8567             :                                         rack.EndUseSubcategory);
    8568           0 :                     SetupOutputVariable(state,
    8569             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8570             :                                         Constant::Units::W,
    8571           0 :                                         rack.BasinHeaterPower,
    8572             :                                         OutputProcessor::TimeStepType::System,
    8573             :                                         OutputProcessor::StoreType::Average,
    8574           0 :                                         rack.Name);
    8575           0 :                     SetupOutputVariable(state,
    8576             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8577             :                                         Constant::Units::J,
    8578           0 :                                         rack.BasinHeaterConsumption,
    8579             :                                         OutputProcessor::TimeStepType::System,
    8580             :                                         OutputProcessor::StoreType::Sum,
    8581           0 :                                         rack.Name,
    8582             :                                         Constant::eResource::Electricity,
    8583             :                                         OutputProcessor::Group::Plant,
    8584             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8585             :                                         rack.EndUseSubcategory);
    8586           0 :                     SetupOutputVariable(state,
    8587             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8588             :                                         Constant::Units::m3_s,
    8589           0 :                                         rack.EvapWaterConsumpRate,
    8590             :                                         OutputProcessor::TimeStepType::System,
    8591             :                                         OutputProcessor::StoreType::Average,
    8592           0 :                                         rack.Name);
    8593           0 :                     SetupOutputVariable(state,
    8594             :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume",
    8595             :                                         Constant::Units::m3,
    8596           0 :                                         rack.EvapWaterConsumption,
    8597             :                                         OutputProcessor::TimeStepType::System,
    8598             :                                         OutputProcessor::StoreType::Sum,
    8599           0 :                                         rack.Name,
    8600             :                                         Constant::eResource::Water,
    8601             :                                         OutputProcessor::Group::Plant,
    8602             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8603             :                                         rack.EndUseSubcategory);
    8604             :                 } // Evap condenser
    8605             : 
    8606           0 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8607           0 :                     SetupOutputVariable(state,
    8608             :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Rate",
    8609             :                                         Constant::Units::W,
    8610           0 :                                         rack.SensZoneCreditHeatRate,
    8611             :                                         OutputProcessor::TimeStepType::System,
    8612             :                                         OutputProcessor::StoreType::Average,
    8613           0 :                                         rack.Name);
    8614           0 :                     SetupOutputVariable(state,
    8615             :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Energy",
    8616             :                                         Constant::Units::J,
    8617           0 :                                         rack.SensZoneCreditHeat,
    8618             :                                         OutputProcessor::TimeStepType::System,
    8619             :                                         OutputProcessor::StoreType::Sum,
    8620           0 :                                         rack.Name);
    8621             : 
    8622           0 :                     SetupOutputVariable(state,
    8623             :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Rate",
    8624             :                                         Constant::Units::W,
    8625           0 :                                         rack.SensHVACCreditHeatRate,
    8626             :                                         OutputProcessor::TimeStepType::System,
    8627             :                                         OutputProcessor::StoreType::Average,
    8628           0 :                                         rack.Name);
    8629           0 :                     SetupOutputVariable(state,
    8630             :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Energy",
    8631             :                                         Constant::Units::J,
    8632           0 :                                         rack.SensHVACCreditHeat,
    8633             :                                         OutputProcessor::TimeStepType::System,
    8634             :                                         OutputProcessor::StoreType::Sum,
    8635           0 :                                         rack.Name);
    8636             : 
    8637             :                     // If CoilFlag is true and Location is Zone, GetRefrigerationInput ensures you must have a Heat Rejection Zone provided already
    8638           0 :                     SetupZoneInternalGain(state,
    8639             :                                           rack.HeatRejectionZoneNum,
    8640             :                                           rack.Name,
    8641             :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8642             :                                           &rack.SensZoneCreditHeatRate,
    8643             :                                           &rack.SensHVACCreditHeatRate);
    8644             : 
    8645             :                 } // LocationZone
    8646             : 
    8647             :             } else { // Rack serves cases and walkins on zone (load) time step
    8648             : 
    8649         122 :                 SetupOutputVariable(state,
    8650             :                                     "Refrigeration Compressor Rack Electricity Rate",
    8651             :                                     Constant::Units::W,
    8652          61 :                                     rack.RackCompressorPower,
    8653             :                                     OutputProcessor::TimeStepType::Zone,
    8654             :                                     OutputProcessor::StoreType::Average,
    8655          61 :                                     rack.Name);
    8656         122 :                 SetupOutputVariable(state,
    8657             :                                     "Refrigeration Compressor Rack Electricity Energy",
    8658             :                                     Constant::Units::J,
    8659          61 :                                     rack.RackElecConsumption,
    8660             :                                     OutputProcessor::TimeStepType::Zone,
    8661             :                                     OutputProcessor::StoreType::Sum,
    8662          61 :                                     rack.Name,
    8663             :                                     Constant::eResource::Electricity,
    8664             :                                     OutputProcessor::Group::Plant,
    8665             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8666             :                                     rack.EndUseSubcategory);
    8667         122 :                 SetupOutputVariable(state,
    8668             :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Rate",
    8669             :                                     Constant::Units::W,
    8670          61 :                                     rack.ActualCondenserFanPower,
    8671             :                                     OutputProcessor::TimeStepType::Zone,
    8672             :                                     OutputProcessor::StoreType::Average,
    8673          61 :                                     rack.Name);
    8674         122 :                 SetupOutputVariable(state,
    8675             :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Energy",
    8676             :                                     Constant::Units::J,
    8677          61 :                                     rack.CondenserFanConsumption,
    8678             :                                     OutputProcessor::TimeStepType::Zone,
    8679             :                                     OutputProcessor::StoreType::Sum,
    8680          61 :                                     rack.Name,
    8681             :                                     Constant::eResource::Electricity,
    8682             :                                     OutputProcessor::Group::Plant,
    8683             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8684             :                                     rack.EndUseSubcategory);
    8685         122 :                 SetupOutputVariable(state,
    8686             :                                     "Refrigeration Compressor Rack Total Heat Transfer Rate",
    8687             :                                     Constant::Units::W,
    8688          61 :                                     rack.RackCapacity,
    8689             :                                     OutputProcessor::TimeStepType::Zone,
    8690             :                                     OutputProcessor::StoreType::Average,
    8691          61 :                                     rack.Name);
    8692         122 :                 SetupOutputVariable(state,
    8693             :                                     "Refrigeration Compressor Rack Total Heat Transfer Energy",
    8694             :                                     Constant::Units::J,
    8695          61 :                                     rack.RackCoolingEnergy,
    8696             :                                     OutputProcessor::TimeStepType::Zone,
    8697             :                                     OutputProcessor::StoreType::Sum,
    8698          61 :                                     rack.Name,
    8699             :                                     Constant::eResource::EnergyTransfer,
    8700             :                                     OutputProcessor::Group::Plant,
    8701             :                                     OutputProcessor::EndUseCat::Refrigeration,
    8702             :                                     rack.EndUseSubcategory);
    8703         122 :                 SetupOutputVariable(state,
    8704             :                                     "Refrigeration Compressor Rack COP",
    8705             :                                     Constant::Units::W_W,
    8706          61 :                                     rack.RackCompressorCOP,
    8707             :                                     OutputProcessor::TimeStepType::Zone,
    8708             :                                     OutputProcessor::StoreType::Average,
    8709          61 :                                     rack.Name);
    8710             : 
    8711          61 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8712           4 :                     SetupOutputVariable(state,
    8713             :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8714             :                                         Constant::Units::W,
    8715           2 :                                         rack.ActualEvapPumpPower,
    8716             :                                         OutputProcessor::TimeStepType::Zone,
    8717             :                                         OutputProcessor::StoreType::Average,
    8718           2 :                                         rack.Name);
    8719           4 :                     SetupOutputVariable(state,
    8720             :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8721             :                                         Constant::Units::J,
    8722           2 :                                         rack.EvapPumpConsumption,
    8723             :                                         OutputProcessor::TimeStepType::Zone,
    8724             :                                         OutputProcessor::StoreType::Sum,
    8725           2 :                                         rack.Name,
    8726             :                                         Constant::eResource::Electricity,
    8727             :                                         OutputProcessor::Group::Plant,
    8728             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8729             :                                         rack.EndUseSubcategory);
    8730           4 :                     SetupOutputVariable(state,
    8731             :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8732             :                                         Constant::Units::W,
    8733           2 :                                         rack.BasinHeaterPower,
    8734             :                                         OutputProcessor::TimeStepType::Zone,
    8735             :                                         OutputProcessor::StoreType::Average,
    8736           2 :                                         rack.Name);
    8737           4 :                     SetupOutputVariable(state,
    8738             :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8739             :                                         Constant::Units::J,
    8740           2 :                                         rack.BasinHeaterConsumption,
    8741             :                                         OutputProcessor::TimeStepType::Zone,
    8742             :                                         OutputProcessor::StoreType::Sum,
    8743           2 :                                         rack.Name,
    8744             :                                         Constant::eResource::Electricity,
    8745             :                                         OutputProcessor::Group::Plant,
    8746             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8747             :                                         rack.EndUseSubcategory);
    8748           4 :                     SetupOutputVariable(state,
    8749             :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8750             :                                         Constant::Units::m3_s,
    8751           2 :                                         rack.EvapWaterConsumpRate,
    8752             :                                         OutputProcessor::TimeStepType::Zone,
    8753             :                                         OutputProcessor::StoreType::Average,
    8754           2 :                                         rack.Name);
    8755           4 :                     SetupOutputVariable(state,
    8756             :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume",
    8757             :                                         Constant::Units::m3,
    8758           2 :                                         rack.EvapWaterConsumption,
    8759             :                                         OutputProcessor::TimeStepType::Zone,
    8760             :                                         OutputProcessor::StoreType::Sum,
    8761           2 :                                         rack.Name,
    8762             :                                         Constant::eResource::Water,
    8763             :                                         OutputProcessor::Group::Plant,
    8764             :                                         OutputProcessor::EndUseCat::Refrigeration,
    8765             :                                         rack.EndUseSubcategory);
    8766             :                 } // condenser evap
    8767             : 
    8768          61 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8769          54 :                     SetupOutputVariable(state,
    8770             :                                         "Refrigeration Compressor Rack Zone Sensible Heating Rate",
    8771             :                                         Constant::Units::W,
    8772          27 :                                         rack.SensZoneCreditHeatRate,
    8773             :                                         OutputProcessor::TimeStepType::Zone,
    8774             :                                         OutputProcessor::StoreType::Average,
    8775          27 :                                         rack.Name);
    8776          54 :                     SetupOutputVariable(state,
    8777             :                                         "Refrigeration Compressor Rack Zone Sensible Heating Energy",
    8778             :                                         Constant::Units::J,
    8779          27 :                                         rack.SensZoneCreditHeat,
    8780             :                                         OutputProcessor::TimeStepType::Zone,
    8781             :                                         OutputProcessor::StoreType::Sum,
    8782          27 :                                         rack.Name);
    8783             : 
    8784          54 :                     SetupOutputVariable(state,
    8785             :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Rate",
    8786             :                                         Constant::Units::W,
    8787          27 :                                         rack.SensHVACCreditHeatRate,
    8788             :                                         OutputProcessor::TimeStepType::Zone,
    8789             :                                         OutputProcessor::StoreType::Average,
    8790          27 :                                         rack.Name);
    8791          54 :                     SetupOutputVariable(state,
    8792             :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Energy",
    8793             :                                         Constant::Units::J,
    8794          27 :                                         rack.SensHVACCreditHeat,
    8795             :                                         OutputProcessor::TimeStepType::Zone,
    8796             :                                         OutputProcessor::StoreType::Sum,
    8797          27 :                                         rack.Name);
    8798             : 
    8799             :                     // if Location is Zone, GetRefrigerationInputEither checks that you have at least one load and that either:
    8800             :                     // * You have only cases, and they must be all in the same zone
    8801             :                     // * Or you must have a Heat Rejection Zone provided
    8802          27 :                     int rackZoneNum = -1;
    8803          27 :                     if (rack.HeatRejectionZoneNum > 0) {
    8804           0 :                         rackZoneNum = rack.HeatRejectionZoneNum;
    8805             :                     } else {
    8806          27 :                         rackZoneNum = RefrigCase(rack.CaseNum(1)).ActualZoneNum;
    8807             :                     }
    8808          27 :                     SetupZoneInternalGain(state,
    8809             :                                           rackZoneNum,
    8810             :                                           rack.Name,
    8811             :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8812             :                                           &rack.SensZoneCreditHeatRate,
    8813             :                                           &rack.SensHVACCreditHeatRate);
    8814             : 
    8815             :                 } // location zone
    8816             :             }     // Serves coils or case/walkin loads
    8817             : 
    8818          61 :             if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) { // on HVAC time step no matter what
    8819           2 :                 SetupOutputVariable(state,
    8820             :                                     "Refrigeration Compressor Rack Condenser Mass Flow Rate",
    8821             :                                     Constant::Units::kg_s,
    8822           1 :                                     rack.MassFlowRate,
    8823             :                                     OutputProcessor::TimeStepType::System,
    8824             :                                     OutputProcessor::StoreType::Average,
    8825           1 :                                     rack.Name);
    8826             : 
    8827           2 :                 SetupOutputVariable(state,
    8828             :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Rate",
    8829             :                                     Constant::Units::W,
    8830           1 :                                     rack.CondLoad,
    8831             :                                     OutputProcessor::TimeStepType::System,
    8832             :                                     OutputProcessor::StoreType::Average,
    8833           1 :                                     rack.Name);
    8834             : 
    8835           2 :                 SetupOutputVariable(state,
    8836             :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Energy",
    8837             :                                     Constant::Units::J,
    8838           1 :                                     rack.CondEnergy,
    8839             :                                     OutputProcessor::TimeStepType::System,
    8840             :                                     OutputProcessor::StoreType::Sum,
    8841           1 :                                     rack.Name,
    8842             :                                     Constant::eResource::EnergyTransfer,
    8843             :                                     OutputProcessor::Group::Plant,
    8844             :                                     OutputProcessor::EndUseCat::Heating);
    8845             : 
    8846             :             } // Condenser cooling water
    8847             :         }     // Refrigerated Racks
    8848             :     }         // NumRefrigeratedRacks > 0
    8849             : 
    8850         796 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
    8851             :         // CurrentModuleObject='Refrigeration:System'
    8852          53 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++refrigSysNum) {
    8853          39 :             auto &sys = System(refrigSysNum);
    8854          39 :             if (sys.CoilFlag) { // system serves chillers and is solved on HVAC time step
    8855           9 :                 if (sys.NumStages == 1) {
    8856          18 :                     SetupOutputVariable(state,
    8857             :                                         "Refrigeration Air Chiller System Total Compressor Electricity Rate",
    8858             :                                         Constant::Units::W,
    8859           9 :                                         sys.TotCompPower,
    8860             :                                         OutputProcessor::TimeStepType::System,
    8861             :                                         OutputProcessor::StoreType::Average,
    8862           9 :                                         sys.Name);
    8863          18 :                     SetupOutputVariable(state,
    8864             :                                         "Refrigeration Air Chiller System Total Compressor Electricity Energy",
    8865             :                                         Constant::Units::J,
    8866           9 :                                         sys.TotCompElecConsump,
    8867             :                                         OutputProcessor::TimeStepType::System,
    8868             :                                         OutputProcessor::StoreType::Sum,
    8869           9 :                                         sys.Name);
    8870           0 :                 } else if (sys.NumStages == 2) {
    8871           0 :                     SetupOutputVariable(state,
    8872             :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Rate",
    8873             :                                         Constant::Units::W,
    8874           0 :                                         sys.TotCompPower,
    8875             :                                         OutputProcessor::TimeStepType::System,
    8876             :                                         OutputProcessor::StoreType::Average,
    8877           0 :                                         sys.Name);
    8878           0 :                     SetupOutputVariable(state,
    8879             :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Energy",
    8880             :                                         Constant::Units::J,
    8881           0 :                                         sys.TotCompElecConsump,
    8882             :                                         OutputProcessor::TimeStepType::System,
    8883             :                                         OutputProcessor::StoreType::Sum,
    8884           0 :                                         sys.Name);
    8885           0 :                     SetupOutputVariable(state,
    8886             :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Rate",
    8887             :                                         Constant::Units::W,
    8888           0 :                                         sys.TotHiStageCompPower,
    8889             :                                         OutputProcessor::TimeStepType::System,
    8890             :                                         OutputProcessor::StoreType::Average,
    8891           0 :                                         sys.Name);
    8892           0 :                     SetupOutputVariable(state,
    8893             :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Energy",
    8894             :                                         Constant::Units::J,
    8895           0 :                                         sys.TotHiStageCompElecConsump,
    8896             :                                         OutputProcessor::TimeStepType::System,
    8897             :                                         OutputProcessor::StoreType::Sum,
    8898           0 :                                         sys.Name);
    8899           0 :                     SetupOutputVariable(state,
    8900             :                                         "Refrigeration Air Chiller System Total Low and High Stage Compressor Electricity Energy",
    8901             :                                         Constant::Units::J,
    8902           0 :                                         sys.TotCompElecConsumpTwoStage,
    8903             :                                         OutputProcessor::TimeStepType::System,
    8904             :                                         OutputProcessor::StoreType::Sum,
    8905           0 :                                         sys.Name);
    8906             :                 } // NumStages
    8907          18 :                 SetupOutputVariable(state,
    8908             :                                     "Refrigeration Air Chiller System Average Compressor COP",
    8909             :                                     Constant::Units::W_W,
    8910           9 :                                     sys.AverageCompressorCOP,
    8911             :                                     OutputProcessor::TimeStepType::System,
    8912             :                                     OutputProcessor::StoreType::Average,
    8913           9 :                                     sys.Name);
    8914          18 :                 SetupOutputVariable(state,
    8915             :                                     "Refrigeration Air Chiller System Total Air Chiller Heat Transfer Rate",
    8916             :                                     Constant::Units::W,
    8917           9 :                                     sys.TotalCoolingLoad,
    8918             :                                     OutputProcessor::TimeStepType::System,
    8919             :                                     OutputProcessor::StoreType::Average,
    8920           9 :                                     sys.Name);
    8921          18 :                 SetupOutputVariable(state,
    8922             :                                     "Refrigeration Air Chiller System Total Case and Walk In Heat Transfer Energy",
    8923             :                                     Constant::Units::J,
    8924           9 :                                     sys.TotalCoolingEnergy,
    8925             :                                     OutputProcessor::TimeStepType::System,
    8926             :                                     OutputProcessor::StoreType::Sum,
    8927           9 :                                     sys.Name);
    8928          18 :                 SetupOutputVariable(state,
    8929             :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Rate",
    8930             :                                     Constant::Units::W,
    8931           9 :                                     sys.TotTransferLoad,
    8932             :                                     OutputProcessor::TimeStepType::System,
    8933             :                                     OutputProcessor::StoreType::Average,
    8934           9 :                                     sys.Name);
    8935          18 :                 SetupOutputVariable(state,
    8936             :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Energy",
    8937             :                                     Constant::Units::J,
    8938           9 :                                     sys.TotTransferEnergy,
    8939             :                                     OutputProcessor::TimeStepType::System,
    8940             :                                     OutputProcessor::StoreType::Sum,
    8941           9 :                                     sys.Name);
    8942          18 :                 SetupOutputVariable(state,
    8943             :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Rate",
    8944             :                                     Constant::Units::W,
    8945           9 :                                     sys.PipeHeatLoad,
    8946             :                                     OutputProcessor::TimeStepType::System,
    8947             :                                     OutputProcessor::StoreType::Average,
    8948           9 :                                     sys.Name);
    8949          18 :                 SetupOutputVariable(state,
    8950             :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Energy",
    8951             :                                     Constant::Units::J,
    8952           9 :                                     sys.PipeHeatEnergy,
    8953             :                                     OutputProcessor::TimeStepType::System,
    8954             :                                     OutputProcessor::StoreType::Sum,
    8955           9 :                                     sys.Name);
    8956           9 :                 if (sys.NumStages == 1) {
    8957          18 :                     SetupOutputVariable(state,
    8958             :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Rate",
    8959             :                                         Constant::Units::W,
    8960           9 :                                         sys.TotCompCapacity,
    8961             :                                         OutputProcessor::TimeStepType::System,
    8962             :                                         OutputProcessor::StoreType::Average,
    8963           9 :                                         sys.Name);
    8964          18 :                     SetupOutputVariable(state,
    8965             :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Energy",
    8966             :                                         Constant::Units::J,
    8967           9 :                                         sys.TotCompCoolingEnergy,
    8968             :                                         OutputProcessor::TimeStepType::System,
    8969             :                                         OutputProcessor::StoreType::Sum,
    8970           9 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8971           0 :                 } else if (sys.NumStages == 2) {
    8972           0 :                     SetupOutputVariable(state,
    8973             :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Rate",
    8974             :                                         Constant::Units::W,
    8975           0 :                                         sys.TotCompCapacity,
    8976             :                                         OutputProcessor::TimeStepType::System,
    8977             :                                         OutputProcessor::StoreType::Average,
    8978           0 :                                         sys.Name);
    8979           0 :                     SetupOutputVariable(state,
    8980             :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Energy",
    8981             :                                         Constant::Units::J,
    8982           0 :                                         sys.TotCompCoolingEnergy,
    8983             :                                         OutputProcessor::TimeStepType::System,
    8984             :                                         OutputProcessor::StoreType::Sum,
    8985           0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8986           0 :                     SetupOutputVariable(state,
    8987             :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Rate",
    8988             :                                         Constant::Units::W,
    8989           0 :                                         sys.TotHiStageCompCapacity,
    8990             :                                         OutputProcessor::TimeStepType::System,
    8991             :                                         OutputProcessor::StoreType::Average,
    8992           0 :                                         sys.Name);
    8993           0 :                     SetupOutputVariable(state,
    8994             :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Energy",
    8995             :                                         Constant::Units::J,
    8996           0 :                                         sys.TotHiStageCompCoolingEnergy,
    8997             :                                         OutputProcessor::TimeStepType::System,
    8998             :                                         OutputProcessor::StoreType::Sum,
    8999           0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9000             :                 }                                  // NumStages
    9001          18 :                 SetupOutputVariable(state,
    9002             :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Rate",
    9003             :                                     Constant::Units::W,
    9004           9 :                                     sys.NetHeatRejectLoad,
    9005             :                                     OutputProcessor::TimeStepType::System,
    9006             :                                     OutputProcessor::StoreType::Average,
    9007           9 :                                     sys.Name);
    9008          18 :                 SetupOutputVariable(state,
    9009             :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Energy",
    9010             :                                     Constant::Units::J,
    9011           9 :                                     sys.NetHeatRejectEnergy,
    9012             :                                     OutputProcessor::TimeStepType::System,
    9013             :                                     OutputProcessor::StoreType::Sum,
    9014           9 :                                     sys.Name);
    9015          18 :                 SetupOutputVariable(state,
    9016             :                                     "Refrigeration Air Chiller System Estimated Refrigerant Inventory Mass",
    9017             :                                     Constant::Units::kg,
    9018           9 :                                     sys.RefInventory,
    9019             :                                     OutputProcessor::TimeStepType::System,
    9020             :                                     OutputProcessor::StoreType::Average,
    9021           9 :                                     sys.Name);
    9022           9 :                 if (sys.NumStages == 1) {
    9023          18 :                     SetupOutputVariable(state,
    9024             :                                         "Refrigeration Air Chiller System Estimated Refrigerant Mass Flow Rate",
    9025             :                                         Constant::Units::kg_s,
    9026           9 :                                         sys.RefMassFlowComps,
    9027             :                                         OutputProcessor::TimeStepType::System,
    9028             :                                         OutputProcessor::StoreType::Average,
    9029           9 :                                         sys.Name);
    9030           0 :                 } else if (sys.NumStages == 2) {
    9031           0 :                     SetupOutputVariable(state,
    9032             :                                         "Refrigeration Air Chiller System Estimated Low Stage Refrigerant Mass Flow Rate",
    9033             :                                         Constant::Units::kg_s,
    9034           0 :                                         sys.RefMassFlowComps,
    9035             :                                         OutputProcessor::TimeStepType::System,
    9036             :                                         OutputProcessor::StoreType::Average,
    9037           0 :                                         sys.Name);
    9038           0 :                     SetupOutputVariable(state,
    9039             :                                         "Refrigeration Air Chiller System Estimated High Stage Refrigerant Mass Flow Rate",
    9040             :                                         Constant::Units::kg_s,
    9041           0 :                                         sys.RefMassFlowHiStageComps,
    9042             :                                         OutputProcessor::TimeStepType::System,
    9043             :                                         OutputProcessor::StoreType::Average,
    9044           0 :                                         sys.Name);
    9045             :                 } // NumStages
    9046           9 :                 if (sys.NumStages == 2) {
    9047           0 :                     SetupOutputVariable(state,
    9048             :                                         "Refrigeration Air Chiller System Intercooler Temperature",
    9049             :                                         Constant::Units::C,
    9050           0 :                                         sys.TIntercooler,
    9051             :                                         OutputProcessor::TimeStepType::System,
    9052             :                                         OutputProcessor::StoreType::Average,
    9053           0 :                                         sys.Name);
    9054           0 :                     SetupOutputVariable(state,
    9055             :                                         "Refrigeration Air Chiller System Intercooler Pressure",
    9056             :                                         Constant::Units::Pa,
    9057           0 :                                         sys.PIntercooler,
    9058             :                                         OutputProcessor::TimeStepType::System,
    9059             :                                         OutputProcessor::StoreType::Average,
    9060           0 :                                         sys.Name);
    9061             :                 }
    9062          18 :                 SetupOutputVariable(state,
    9063             :                                     "Refrigeration Air Chiller System Condensing Temperature",
    9064             :                                     Constant::Units::C,
    9065           9 :                                     sys.TCondense,
    9066             :                                     OutputProcessor::TimeStepType::System,
    9067             :                                     OutputProcessor::StoreType::Average,
    9068           9 :                                     sys.Name);
    9069          18 :                 SetupOutputVariable(state,
    9070             :                                     "Refrigeration Air Chiller System Evaporating Temperature",
    9071             :                                     Constant::Units::C,
    9072           9 :                                     sys.TEvapNeeded,
    9073             :                                     OutputProcessor::TimeStepType::System,
    9074             :                                     OutputProcessor::StoreType::Average,
    9075           9 :                                     sys.Name);
    9076          18 :                 SetupOutputVariable(state,
    9077             :                                     "Refrigeration Air Chiller System Suction Temperature",
    9078             :                                     Constant::Units::C,
    9079           9 :                                     sys.TCompIn,
    9080             :                                     OutputProcessor::TimeStepType::System,
    9081             :                                     OutputProcessor::StoreType::Average,
    9082           9 :                                     sys.Name);
    9083          18 :                 SetupOutputVariable(state,
    9084             :                                     "Refrigeration Air Chiller System TXV Liquid Temperature",
    9085             :                                     Constant::Units::C,
    9086           9 :                                     sys.TLiqInActual,
    9087             :                                     OutputProcessor::TimeStepType::System,
    9088             :                                     OutputProcessor::StoreType::Average,
    9089           9 :                                     sys.Name);
    9090          18 :                 SetupOutputVariable(state,
    9091             :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Rate",
    9092             :                                     Constant::Units::W,
    9093           9 :                                     sys.LSHXTrans,
    9094             :                                     OutputProcessor::TimeStepType::System,
    9095             :                                     OutputProcessor::StoreType::Average,
    9096           9 :                                     sys.Name);
    9097          18 :                 SetupOutputVariable(state,
    9098             :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Energy",
    9099             :                                     Constant::Units::J,
    9100           9 :                                     sys.LSHXTransEnergy,
    9101             :                                     OutputProcessor::TimeStepType::System,
    9102             :                                     OutputProcessor::StoreType::Sum,
    9103           9 :                                     sys.Name);
    9104             :             } else { // NOT System(SysNum)%CoilFlag, so serving loads on zone timestep
    9105          30 :                 if (sys.NumStages == 1) {
    9106          56 :                     SetupOutputVariable(state,
    9107             :                                         "Refrigeration System Total Compressor Electricity Rate",
    9108             :                                         Constant::Units::W,
    9109          28 :                                         sys.TotCompPower,
    9110             :                                         OutputProcessor::TimeStepType::Zone,
    9111             :                                         OutputProcessor::StoreType::Average,
    9112          28 :                                         sys.Name);
    9113          56 :                     SetupOutputVariable(state,
    9114             :                                         "Refrigeration System Total Compressor Electricity Energy",
    9115             :                                         Constant::Units::J,
    9116          28 :                                         sys.TotCompElecConsump,
    9117             :                                         OutputProcessor::TimeStepType::Zone,
    9118             :                                         OutputProcessor::StoreType::Sum,
    9119          28 :                                         sys.Name);
    9120           2 :                 } else if (sys.NumStages == 2) {
    9121           4 :                     SetupOutputVariable(state,
    9122             :                                         "Refrigeration System Total Low Stage Compressor Electricity Rate",
    9123             :                                         Constant::Units::W,
    9124           2 :                                         sys.TotCompPower,
    9125             :                                         OutputProcessor::TimeStepType::Zone,
    9126             :                                         OutputProcessor::StoreType::Average,
    9127           2 :                                         sys.Name);
    9128           4 :                     SetupOutputVariable(state,
    9129             :                                         "Refrigeration System Total Low Stage Compressor Electricity Energy",
    9130             :                                         Constant::Units::J,
    9131           2 :                                         sys.TotCompElecConsump,
    9132             :                                         OutputProcessor::TimeStepType::Zone,
    9133             :                                         OutputProcessor::StoreType::Sum,
    9134           2 :                                         sys.Name);
    9135           4 :                     SetupOutputVariable(state,
    9136             :                                         "Refrigeration System Total High Stage Compressor Electricity Rate",
    9137             :                                         Constant::Units::W,
    9138           2 :                                         sys.TotHiStageCompPower,
    9139             :                                         OutputProcessor::TimeStepType::Zone,
    9140             :                                         OutputProcessor::StoreType::Average,
    9141           2 :                                         sys.Name);
    9142           4 :                     SetupOutputVariable(state,
    9143             :                                         "Refrigeration System Total High Stage Compressor Electricity Energy",
    9144             :                                         Constant::Units::J,
    9145           2 :                                         sys.TotHiStageCompElecConsump,
    9146             :                                         OutputProcessor::TimeStepType::Zone,
    9147             :                                         OutputProcessor::StoreType::Sum,
    9148           2 :                                         sys.Name);
    9149           4 :                     SetupOutputVariable(state,
    9150             :                                         "Refrigeration System Total Low and High Stage Compressor Electricity Energy",
    9151             :                                         Constant::Units::J,
    9152           2 :                                         sys.TotCompElecConsumpTwoStage,
    9153             :                                         OutputProcessor::TimeStepType::Zone,
    9154             :                                         OutputProcessor::StoreType::Sum,
    9155           2 :                                         sys.Name);
    9156             :                 } // NumStages
    9157          60 :                 SetupOutputVariable(state,
    9158             :                                     "Refrigeration System Average Compressor COP",
    9159             :                                     Constant::Units::W_W,
    9160          30 :                                     sys.AverageCompressorCOP,
    9161             :                                     OutputProcessor::TimeStepType::Zone,
    9162             :                                     OutputProcessor::StoreType::Average,
    9163          30 :                                     sys.Name);
    9164          60 :                 SetupOutputVariable(state,
    9165             :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Rate",
    9166             :                                     Constant::Units::W,
    9167          30 :                                     sys.TotalCoolingLoad,
    9168             :                                     OutputProcessor::TimeStepType::Zone,
    9169             :                                     OutputProcessor::StoreType::Average,
    9170          30 :                                     sys.Name);
    9171          60 :                 SetupOutputVariable(state,
    9172             :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Energy",
    9173             :                                     Constant::Units::J,
    9174          30 :                                     sys.TotalCoolingEnergy,
    9175             :                                     OutputProcessor::TimeStepType::Zone,
    9176             :                                     OutputProcessor::StoreType::Sum,
    9177          30 :                                     sys.Name);
    9178          60 :                 SetupOutputVariable(state,
    9179             :                                     "Refrigeration System Total Transferred Load Heat Transfer Rate",
    9180             :                                     Constant::Units::W,
    9181          30 :                                     sys.TotTransferLoad,
    9182             :                                     OutputProcessor::TimeStepType::Zone,
    9183             :                                     OutputProcessor::StoreType::Average,
    9184          30 :                                     sys.Name);
    9185          60 :                 SetupOutputVariable(state,
    9186             :                                     "Refrigeration System Total Transferred Load Heat Transfer Energy",
    9187             :                                     Constant::Units::J,
    9188          30 :                                     sys.TotTransferEnergy,
    9189             :                                     OutputProcessor::TimeStepType::Zone,
    9190             :                                     OutputProcessor::StoreType::Sum,
    9191          30 :                                     sys.Name);
    9192          60 :                 SetupOutputVariable(state,
    9193             :                                     "Refrigeration System Total Suction Pipe Heat Gain Rate",
    9194             :                                     Constant::Units::W,
    9195          30 :                                     sys.PipeHeatLoad,
    9196             :                                     OutputProcessor::TimeStepType::Zone,
    9197             :                                     OutputProcessor::StoreType::Average,
    9198          30 :                                     sys.Name);
    9199          60 :                 SetupOutputVariable(state,
    9200             :                                     "Refrigeration System Total Suction Pipe Heat Gain Energy",
    9201             :                                     Constant::Units::J,
    9202          30 :                                     sys.PipeHeatEnergy,
    9203             :                                     OutputProcessor::TimeStepType::Zone,
    9204             :                                     OutputProcessor::StoreType::Sum,
    9205          30 :                                     sys.Name);
    9206          30 :                 if (sys.NumStages == 1) {
    9207          56 :                     SetupOutputVariable(state,
    9208             :                                         "Refrigeration System Total Compressor Heat Transfer Rate",
    9209             :                                         Constant::Units::W,
    9210          28 :                                         sys.TotCompCapacity,
    9211             :                                         OutputProcessor::TimeStepType::Zone,
    9212             :                                         OutputProcessor::StoreType::Average,
    9213          28 :                                         sys.Name);
    9214          56 :                     SetupOutputVariable(state,
    9215             :                                         "Refrigeration System Total Compressor Heat Transfer Energy",
    9216             :                                         Constant::Units::J,
    9217          28 :                                         sys.TotCompCoolingEnergy,
    9218             :                                         OutputProcessor::TimeStepType::Zone,
    9219             :                                         OutputProcessor::StoreType::Sum,
    9220          28 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9221           2 :                 } else if (sys.NumStages == 2) {
    9222           4 :                     SetupOutputVariable(state,
    9223             :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Rate",
    9224             :                                         Constant::Units::W,
    9225           2 :                                         sys.TotCompCapacity,
    9226             :                                         OutputProcessor::TimeStepType::Zone,
    9227             :                                         OutputProcessor::StoreType::Average,
    9228           2 :                                         sys.Name);
    9229           4 :                     SetupOutputVariable(state,
    9230             :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Energy",
    9231             :                                         Constant::Units::J,
    9232           2 :                                         sys.TotCompCoolingEnergy,
    9233             :                                         OutputProcessor::TimeStepType::Zone,
    9234             :                                         OutputProcessor::StoreType::Sum,
    9235           2 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9236           4 :                     SetupOutputVariable(state,
    9237             :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Rate",
    9238             :                                         Constant::Units::W,
    9239           2 :                                         sys.TotHiStageCompCapacity,
    9240             :                                         OutputProcessor::TimeStepType::Zone,
    9241             :                                         OutputProcessor::StoreType::Average,
    9242           2 :                                         sys.Name);
    9243           4 :                     SetupOutputVariable(state,
    9244             :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Energy",
    9245             :                                         Constant::Units::J,
    9246           2 :                                         sys.TotHiStageCompCoolingEnergy,
    9247             :                                         OutputProcessor::TimeStepType::Zone,
    9248             :                                         OutputProcessor::StoreType::Sum,
    9249           2 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9250             :                 }                                  // NumStages
    9251          60 :                 SetupOutputVariable(state,
    9252             :                                     "Refrigeration System Net Rejected Heat Transfer Rate",
    9253             :                                     Constant::Units::W,
    9254          30 :                                     sys.NetHeatRejectLoad,
    9255             :                                     OutputProcessor::TimeStepType::Zone,
    9256             :                                     OutputProcessor::StoreType::Average,
    9257          30 :                                     sys.Name);
    9258          60 :                 SetupOutputVariable(state,
    9259             :                                     "Refrigeration System Net Rejected Heat Transfer Energy",
    9260             :                                     Constant::Units::J,
    9261          30 :                                     sys.NetHeatRejectEnergy,
    9262             :                                     OutputProcessor::TimeStepType::Zone,
    9263             :                                     OutputProcessor::StoreType::Sum,
    9264          30 :                                     sys.Name);
    9265          60 :                 SetupOutputVariable(state,
    9266             :                                     "Refrigeration System Estimated Refrigerant Inventory Mass",
    9267             :                                     Constant::Units::kg,
    9268          30 :                                     sys.RefInventory,
    9269             :                                     OutputProcessor::TimeStepType::Zone,
    9270             :                                     OutputProcessor::StoreType::Average,
    9271          30 :                                     sys.Name);
    9272          30 :                 if (sys.NumStages == 1) {
    9273          56 :                     SetupOutputVariable(state,
    9274             :                                         "Refrigeration System Estimated Refrigerant Mass Flow Rate",
    9275             :                                         Constant::Units::kg_s,
    9276          28 :                                         sys.RefMassFlowComps,
    9277             :                                         OutputProcessor::TimeStepType::Zone,
    9278             :                                         OutputProcessor::StoreType::Average,
    9279          28 :                                         sys.Name);
    9280           2 :                 } else if (sys.NumStages == 2) {
    9281           4 :                     SetupOutputVariable(state,
    9282             :                                         "Refrigeration System Estimated Low Stage Refrigerant Mass Flow Rate",
    9283             :                                         Constant::Units::kg_s,
    9284           2 :                                         sys.RefMassFlowComps,
    9285             :                                         OutputProcessor::TimeStepType::Zone,
    9286             :                                         OutputProcessor::StoreType::Average,
    9287           2 :                                         sys.Name);
    9288           4 :                     SetupOutputVariable(state,
    9289             :                                         "Refrigeration System Estimated High Stage Refrigerant Mass Flow Rate",
    9290             :                                         Constant::Units::kg_s,
    9291           2 :                                         sys.RefMassFlowHiStageComps,
    9292             :                                         OutputProcessor::TimeStepType::Zone,
    9293             :                                         OutputProcessor::StoreType::Average,
    9294           2 :                                         sys.Name);
    9295             :                 } // NumStages
    9296          30 :                 if (sys.NumStages == 2) {
    9297           4 :                     SetupOutputVariable(state,
    9298             :                                         "Refrigeration System Intercooler Temperature",
    9299             :                                         Constant::Units::C,
    9300           2 :                                         sys.TIntercooler,
    9301             :                                         OutputProcessor::TimeStepType::Zone,
    9302             :                                         OutputProcessor::StoreType::Average,
    9303           2 :                                         sys.Name);
    9304           4 :                     SetupOutputVariable(state,
    9305             :                                         "Refrigeration System Intercooler Pressure",
    9306             :                                         Constant::Units::Pa,
    9307           2 :                                         sys.PIntercooler,
    9308             :                                         OutputProcessor::TimeStepType::Zone,
    9309             :                                         OutputProcessor::StoreType::Average,
    9310           2 :                                         sys.Name);
    9311             :                 }
    9312          60 :                 SetupOutputVariable(state,
    9313             :                                     "Refrigeration System Condensing Temperature",
    9314             :                                     Constant::Units::C,
    9315          30 :                                     sys.TCondense,
    9316             :                                     OutputProcessor::TimeStepType::Zone,
    9317             :                                     OutputProcessor::StoreType::Average,
    9318          30 :                                     sys.Name);
    9319          60 :                 SetupOutputVariable(state,
    9320             :                                     "Refrigeration System Evaporating Temperature",
    9321             :                                     Constant::Units::C,
    9322          30 :                                     sys.TEvapNeeded,
    9323             :                                     OutputProcessor::TimeStepType::Zone,
    9324             :                                     OutputProcessor::StoreType::Average,
    9325          30 :                                     sys.Name);
    9326          60 :                 SetupOutputVariable(state,
    9327             :                                     "Refrigeration System Suction Pipe Suction Temperature",
    9328             :                                     Constant::Units::C,
    9329          30 :                                     sys.TCompIn,
    9330             :                                     OutputProcessor::TimeStepType::Zone,
    9331             :                                     OutputProcessor::StoreType::Average,
    9332          30 :                                     sys.Name);
    9333          60 :                 SetupOutputVariable(state,
    9334             :                                     "Refrigeration System Thermostatic Expansion Valve Liquid Temperature",
    9335             :                                     Constant::Units::C,
    9336          30 :                                     sys.TLiqInActual,
    9337             :                                     OutputProcessor::TimeStepType::Zone,
    9338             :                                     OutputProcessor::StoreType::Average,
    9339          30 :                                     sys.Name);
    9340          60 :                 SetupOutputVariable(state,
    9341             :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Rate",
    9342             :                                     Constant::Units::W,
    9343          30 :                                     sys.LSHXTrans,
    9344             :                                     OutputProcessor::TimeStepType::Zone,
    9345             :                                     OutputProcessor::StoreType::Average,
    9346          30 :                                     sys.Name);
    9347          60 :                 SetupOutputVariable(state,
    9348             :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Energy",
    9349             :                                     Constant::Units::J,
    9350          30 :                                     sys.LSHXTransEnergy,
    9351             :                                     OutputProcessor::TimeStepType::Zone,
    9352             :                                     OutputProcessor::StoreType::Sum,
    9353          30 :                                     sys.Name);
    9354             :             } // System(coilflag)
    9355             : 
    9356          39 :             if (sys.SystemRejectHeatToZone) {
    9357           3 :                 if (Condenser(sys.CondenserNum(1)).InletAirZoneNum > 0)
    9358           3 :                     SetupZoneInternalGain(state,
    9359           3 :                                           Condenser(sys.CondenserNum(1)).InletAirZoneNum,
    9360             :                                           sys.Name,
    9361             :                                           DataHeatBalance::IntGainType::RefrigerationSystemAirCooledCondenser,
    9362             :                                           &sys.NetHeatRejectLoad);
    9363             : 
    9364           3 :                 if (sys.SuctionPipeActualZoneNum > 0)
    9365           0 :                     SetupZoneInternalGain(state,
    9366             :                                           sys.SuctionPipeActualZoneNum,
    9367             :                                           sys.Name,
    9368             :                                           DataHeatBalance::IntGainType::RefrigerationSystemSuctionPipe,
    9369             :                                           &sys.PipeHeatLoad);
    9370             :             }
    9371             :         } // numrefrigsystems
    9372             : 
    9373             :         // Report Compressor ENERGY here, not on system level for meters.
    9374         182 :         for (int compNum = 1; compNum <= state.dataRefrigCase->NumSimulationCompressors; ++compNum) {
    9375         168 :             auto &comp = Compressor(compNum);
    9376             :             // CurrentModuleObject='Refrigeration:Compressor'
    9377         168 :             if (comp.NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9378         168 :                 if (comp.CoilFlag) {      // Compressor serving system with chillers on HVAC time step
    9379         142 :                     SetupOutputVariable(state,
    9380             :                                         "Refrigeration Air Chiller System Compressor Electricity Rate",
    9381             :                                         Constant::Units::W,
    9382          71 :                                         comp.Power,
    9383             :                                         OutputProcessor::TimeStepType::System,
    9384             :                                         OutputProcessor::StoreType::Average,
    9385          71 :                                         comp.Name);
    9386         142 :                     SetupOutputVariable(state,
    9387             :                                         "Refrigeration Air Chiller System Compressor Electricity Energy",
    9388             :                                         Constant::Units::J,
    9389          71 :                                         comp.ElecConsumption,
    9390             :                                         OutputProcessor::TimeStepType::System,
    9391             :                                         OutputProcessor::StoreType::Sum,
    9392          71 :                                         comp.Name,
    9393             :                                         Constant::eResource::Electricity,
    9394             :                                         OutputProcessor::Group::Plant,
    9395             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9396             :                                         comp.EndUseSubcategory);
    9397         142 :                     SetupOutputVariable(state,
    9398             :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Rate",
    9399             :                                         Constant::Units::W,
    9400          71 :                                         comp.Capacity,
    9401             :                                         OutputProcessor::TimeStepType::System,
    9402             :                                         OutputProcessor::StoreType::Average,
    9403          71 :                                         comp.Name);
    9404         142 :                     SetupOutputVariable(state,
    9405             :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Energy",
    9406             :                                         Constant::Units::J,
    9407          71 :                                         comp.CoolingEnergy,
    9408             :                                         OutputProcessor::TimeStepType::System,
    9409             :                                         OutputProcessor::StoreType::Sum,
    9410          71 :                                         comp.Name);
    9411         142 :                     SetupOutputVariable(state,
    9412             :                                         "Refrigeration Air Chiller System Compressor Runtime Fraction",
    9413             :                                         Constant::Units::None,
    9414          71 :                                         comp.LoadFactor,
    9415             :                                         OutputProcessor::TimeStepType::System,
    9416             :                                         OutputProcessor::StoreType::Average,
    9417          71 :                                         comp.Name);
    9418             :                 } else { // serve cases/walkins on zone time step
    9419         194 :                     SetupOutputVariable(state,
    9420             :                                         "Refrigeration Compressor Electricity Rate",
    9421             :                                         Constant::Units::W,
    9422          97 :                                         comp.Power,
    9423             :                                         OutputProcessor::TimeStepType::Zone,
    9424             :                                         OutputProcessor::StoreType::Average,
    9425          97 :                                         comp.Name);
    9426         194 :                     SetupOutputVariable(state,
    9427             :                                         "Refrigeration Compressor Electricity Energy",
    9428             :                                         Constant::Units::J,
    9429          97 :                                         comp.ElecConsumption,
    9430             :                                         OutputProcessor::TimeStepType::Zone,
    9431             :                                         OutputProcessor::StoreType::Sum,
    9432          97 :                                         comp.Name,
    9433             :                                         Constant::eResource::Electricity,
    9434             :                                         OutputProcessor::Group::Plant,
    9435             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9436             :                                         comp.EndUseSubcategory);
    9437         194 :                     SetupOutputVariable(state,
    9438             :                                         "Refrigeration Compressor Heat Transfer Rate",
    9439             :                                         Constant::Units::W,
    9440          97 :                                         comp.Capacity,
    9441             :                                         OutputProcessor::TimeStepType::Zone,
    9442             :                                         OutputProcessor::StoreType::Average,
    9443          97 :                                         comp.Name);
    9444         194 :                     SetupOutputVariable(state,
    9445             :                                         "Refrigeration Compressor Heat Transfer Energy",
    9446             :                                         Constant::Units::J,
    9447          97 :                                         comp.CoolingEnergy,
    9448             :                                         OutputProcessor::TimeStepType::Zone,
    9449             :                                         OutputProcessor::StoreType::Sum,
    9450          97 :                                         comp.Name);
    9451         194 :                     SetupOutputVariable(state,
    9452             :                                         "Refrigeration Compressor Runtime Fraction",
    9453             :                                         Constant::Units::None,
    9454          97 :                                         comp.LoadFactor,
    9455             :                                         OutputProcessor::TimeStepType::Zone,
    9456             :                                         OutputProcessor::StoreType::Average,
    9457          97 :                                         comp.Name);
    9458             :                 } // Serve coils on HVAC time step or cases/walkins on Zone time step
    9459             :             }     // NumSysAttach
    9460             :         }         // CompNum on NumSimulationCompressors
    9461             : 
    9462             :         // Report Variables for Refrigeration Condensers
    9463          51 :         for (int condNum = 1; condNum <= state.dataRefrigCase->NumRefrigCondensers; ++condNum) {
    9464          37 :             auto &cond = Condenser(condNum);
    9465             :             // CurrentModuleObject='Refrigeration:Condenser:*'
    9466          37 :             if (cond.CoilFlag) { // Condenser serving system with chillers on HVAC time step
    9467          18 :                 SetupOutputVariable(state,
    9468             :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Rate",
    9469             :                                     Constant::Units::W,
    9470           9 :                                     cond.CondLoad,
    9471             :                                     OutputProcessor::TimeStepType::System,
    9472             :                                     OutputProcessor::StoreType::Average,
    9473           9 :                                     cond.Name);
    9474          18 :                 SetupOutputVariable(state,
    9475             :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Energy",
    9476             :                                     Constant::Units::J,
    9477           9 :                                     cond.CondEnergy,
    9478             :                                     OutputProcessor::TimeStepType::System,
    9479             :                                     OutputProcessor::StoreType::Sum,
    9480           9 :                                     cond.Name);
    9481             : 
    9482           9 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9483          18 :                     SetupOutputVariable(state,
    9484             :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Rate",
    9485             :                                         Constant::Units::W,
    9486           9 :                                         cond.TotalHeatRecoveredLoad,
    9487             :                                         OutputProcessor::TimeStepType::System,
    9488             :                                         OutputProcessor::StoreType::Average,
    9489           9 :                                         cond.Name);
    9490          18 :                     SetupOutputVariable(state,
    9491             :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Energy",
    9492             :                                         Constant::Units::J,
    9493           9 :                                         cond.TotalHeatRecoveredEnergy,
    9494             :                                         OutputProcessor::TimeStepType::System,
    9495             :                                         OutputProcessor::StoreType::Sum,
    9496           9 :                                         cond.Name);
    9497          18 :                     SetupOutputVariable(state,
    9498             :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9499             :                                         Constant::Units::W,
    9500           9 :                                         cond.ExternalHeatRecoveredLoad,
    9501             :                                         OutputProcessor::TimeStepType::System,
    9502             :                                         OutputProcessor::StoreType::Average,
    9503           9 :                                         cond.Name);
    9504          18 :                     SetupOutputVariable(state,
    9505             :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9506             :                                         Constant::Units::J,
    9507           9 :                                         cond.ExternalEnergyRecovered,
    9508             :                                         OutputProcessor::TimeStepType::System,
    9509             :                                         OutputProcessor::StoreType::Sum,
    9510           9 :                                         cond.Name);
    9511          18 :                     SetupOutputVariable(state,
    9512             :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Rate",
    9513             :                                         Constant::Units::W,
    9514           9 :                                         cond.InternalHeatRecoveredLoad,
    9515             :                                         OutputProcessor::TimeStepType::System,
    9516             :                                         OutputProcessor::StoreType::Average,
    9517           9 :                                         cond.Name);
    9518          18 :                     SetupOutputVariable(state,
    9519             :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Energy",
    9520             :                                         Constant::Units::J,
    9521           9 :                                         cond.InternalEnergyRecovered,
    9522             :                                         OutputProcessor::TimeStepType::System,
    9523             :                                         OutputProcessor::StoreType::Sum,
    9524           9 :                                         cond.Name);
    9525             :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9526             : 
    9527           9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9528          18 :                     SetupOutputVariable(state,
    9529             :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    9530             :                                         Constant::Units::W,
    9531           9 :                                         cond.ActualFanPower,
    9532             :                                         OutputProcessor::TimeStepType::System,
    9533             :                                         OutputProcessor::StoreType::Average,
    9534           9 :                                         cond.Name);
    9535          18 :                     SetupOutputVariable(state,
    9536             :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    9537             :                                         Constant::Units::J,
    9538           9 :                                         cond.FanElecEnergy,
    9539             :                                         OutputProcessor::TimeStepType::System,
    9540             :                                         OutputProcessor::StoreType::Sum,
    9541           9 :                                         cond.Name,
    9542             :                                         Constant::eResource::Electricity,
    9543             :                                         OutputProcessor::Group::Plant,
    9544             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9545             :                                         cond.EndUseSubcategory);
    9546             :                 } // Air cooled
    9547             : 
    9548           9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9549           0 :                     SetupOutputVariable(state,
    9550             :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    9551             :                                         Constant::Units::W,
    9552           0 :                                         cond.ActualFanPower,
    9553             :                                         OutputProcessor::TimeStepType::System,
    9554             :                                         OutputProcessor::StoreType::Average,
    9555           0 :                                         cond.Name);
    9556           0 :                     SetupOutputVariable(state,
    9557             :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    9558             :                                         Constant::Units::J,
    9559           0 :                                         cond.FanElecEnergy,
    9560             :                                         OutputProcessor::TimeStepType::System,
    9561             :                                         OutputProcessor::StoreType::Sum,
    9562           0 :                                         cond.Name,
    9563             :                                         Constant::eResource::Electricity,
    9564             :                                         OutputProcessor::Group::Plant,
    9565             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9566             :                                         cond.EndUseSubcategory);
    9567           0 :                     SetupOutputVariable(state,
    9568             :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Rate",
    9569             :                                         Constant::Units::W,
    9570           0 :                                         cond.ActualEvapPumpPower,
    9571             :                                         OutputProcessor::TimeStepType::System,
    9572             :                                         OutputProcessor::StoreType::Average,
    9573           0 :                                         cond.Name);
    9574           0 :                     SetupOutputVariable(state,
    9575             :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Energy",
    9576             :                                         Constant::Units::J,
    9577           0 :                                         cond.EvapPumpConsumption,
    9578             :                                         OutputProcessor::TimeStepType::System,
    9579             :                                         OutputProcessor::StoreType::Sum,
    9580           0 :                                         cond.Name,
    9581             :                                         Constant::eResource::Electricity,
    9582             :                                         OutputProcessor::Group::Plant,
    9583             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9584             :                                         cond.EndUseSubcategory);
    9585           0 :                     SetupOutputVariable(state,
    9586             :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Rate",
    9587             :                                         Constant::Units::W,
    9588           0 :                                         cond.BasinHeaterPower,
    9589             :                                         OutputProcessor::TimeStepType::System,
    9590             :                                         OutputProcessor::StoreType::Average,
    9591           0 :                                         cond.Name);
    9592           0 :                     SetupOutputVariable(state,
    9593             :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Energy",
    9594             :                                         Constant::Units::J,
    9595           0 :                                         cond.BasinHeaterConsumption,
    9596             :                                         OutputProcessor::TimeStepType::System,
    9597             :                                         OutputProcessor::StoreType::Sum,
    9598           0 :                                         cond.Name,
    9599             :                                         Constant::eResource::Electricity,
    9600             :                                         OutputProcessor::Group::Plant,
    9601             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9602             :                                         cond.EndUseSubcategory);
    9603           0 :                     SetupOutputVariable(state,
    9604             :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume Flow Rate",
    9605             :                                         Constant::Units::m3_s,
    9606           0 :                                         cond.EvapWaterConsumpRate,
    9607             :                                         OutputProcessor::TimeStepType::System,
    9608             :                                         OutputProcessor::StoreType::Average,
    9609           0 :                                         cond.Name);
    9610           0 :                     SetupOutputVariable(state,
    9611             :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume",
    9612             :                                         Constant::Units::m3,
    9613           0 :                                         cond.EvapWaterConsumption,
    9614             :                                         OutputProcessor::TimeStepType::System,
    9615             :                                         OutputProcessor::StoreType::Sum,
    9616           0 :                                         cond.Name,
    9617             :                                         Constant::eResource::Water,
    9618             :                                         OutputProcessor::Group::Plant,
    9619             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9620             :                                         cond.EndUseSubcategory);
    9621             :                 } // Evaporative Condenser Variables
    9622             : 
    9623           9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9624           0 :                     SetupOutputVariable(state,
    9625             :                                         "Refrigeration Air Chiller System Condenser Fluid Mass Flow Rate",
    9626             :                                         Constant::Units::kg_s,
    9627           0 :                                         cond.MassFlowRate,
    9628             :                                         OutputProcessor::TimeStepType::System,
    9629             :                                         OutputProcessor::StoreType::Average,
    9630           0 :                                         cond.Name);
    9631             : 
    9632             :                 } // Water-cooled Condenser variables
    9633             : 
    9634             :             } else { // Serving loads/systems with cases and walkins on zone time step
    9635             : 
    9636          56 :                 SetupOutputVariable(state,
    9637             :                                     "Refrigeration System Condenser Heat Transfer Rate",
    9638             :                                     Constant::Units::W,
    9639          28 :                                     cond.CondLoad,
    9640             :                                     OutputProcessor::TimeStepType::Zone,
    9641             :                                     OutputProcessor::StoreType::Average,
    9642          28 :                                     cond.Name);
    9643          56 :                 SetupOutputVariable(state,
    9644             :                                     "Refrigeration System Condenser Heat Transfer Energy",
    9645             :                                     Constant::Units::J,
    9646          28 :                                     cond.CondEnergy,
    9647             :                                     OutputProcessor::TimeStepType::Zone,
    9648             :                                     OutputProcessor::StoreType::Sum,
    9649          28 :                                     cond.Name);
    9650             : 
    9651          28 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9652          54 :                     SetupOutputVariable(state,
    9653             :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Rate",
    9654             :                                         Constant::Units::W,
    9655          27 :                                         cond.TotalHeatRecoveredLoad,
    9656             :                                         OutputProcessor::TimeStepType::Zone,
    9657             :                                         OutputProcessor::StoreType::Average,
    9658          27 :                                         cond.Name);
    9659          54 :                     SetupOutputVariable(state,
    9660             :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Energy",
    9661             :                                         Constant::Units::J,
    9662          27 :                                         cond.TotalHeatRecoveredEnergy,
    9663             :                                         OutputProcessor::TimeStepType::Zone,
    9664             :                                         OutputProcessor::StoreType::Sum,
    9665          27 :                                         cond.Name);
    9666          54 :                     SetupOutputVariable(state,
    9667             :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9668             :                                         Constant::Units::W,
    9669          27 :                                         cond.ExternalHeatRecoveredLoad,
    9670             :                                         OutputProcessor::TimeStepType::Zone,
    9671             :                                         OutputProcessor::StoreType::Average,
    9672          27 :                                         cond.Name);
    9673          54 :                     SetupOutputVariable(state,
    9674             :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9675             :                                         Constant::Units::J,
    9676          27 :                                         cond.ExternalEnergyRecovered,
    9677             :                                         OutputProcessor::TimeStepType::Zone,
    9678             :                                         OutputProcessor::StoreType::Sum,
    9679          27 :                                         cond.Name);
    9680          54 :                     SetupOutputVariable(state,
    9681             :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Rate",
    9682             :                                         Constant::Units::W,
    9683          27 :                                         cond.InternalHeatRecoveredLoad,
    9684             :                                         OutputProcessor::TimeStepType::Zone,
    9685             :                                         OutputProcessor::StoreType::Average,
    9686          27 :                                         cond.Name);
    9687          54 :                     SetupOutputVariable(state,
    9688             :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Energy",
    9689             :                                         Constant::Units::J,
    9690          27 :                                         cond.InternalEnergyRecovered,
    9691             :                                         OutputProcessor::TimeStepType::Zone,
    9692             :                                         OutputProcessor::StoreType::Sum,
    9693          27 :                                         cond.Name);
    9694             :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9695             : 
    9696          28 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9697          46 :                     SetupOutputVariable(state,
    9698             :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9699             :                                         Constant::Units::W,
    9700          23 :                                         cond.ActualFanPower,
    9701             :                                         OutputProcessor::TimeStepType::Zone,
    9702             :                                         OutputProcessor::StoreType::Average,
    9703          23 :                                         cond.Name);
    9704          46 :                     SetupOutputVariable(state,
    9705             :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9706             :                                         Constant::Units::J,
    9707          23 :                                         cond.FanElecEnergy,
    9708             :                                         OutputProcessor::TimeStepType::Zone,
    9709             :                                         OutputProcessor::StoreType::Sum,
    9710          23 :                                         cond.Name,
    9711             :                                         Constant::eResource::Electricity,
    9712             :                                         OutputProcessor::Group::Plant,
    9713             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9714             :                                         cond.EndUseSubcategory);
    9715             :                 } // Air cooled
    9716             : 
    9717          28 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9718           6 :                     SetupOutputVariable(state,
    9719             :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9720             :                                         Constant::Units::W,
    9721           3 :                                         cond.ActualFanPower,
    9722             :                                         OutputProcessor::TimeStepType::Zone,
    9723             :                                         OutputProcessor::StoreType::Average,
    9724           3 :                                         cond.Name);
    9725           6 :                     SetupOutputVariable(state,
    9726             :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9727             :                                         Constant::Units::J,
    9728           3 :                                         cond.FanElecEnergy,
    9729             :                                         OutputProcessor::TimeStepType::Zone,
    9730             :                                         OutputProcessor::StoreType::Sum,
    9731           3 :                                         cond.Name,
    9732             :                                         Constant::eResource::Electricity,
    9733             :                                         OutputProcessor::Group::Plant,
    9734             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9735             :                                         cond.EndUseSubcategory);
    9736           6 :                     SetupOutputVariable(state,
    9737             :                                         "Refrigeration System Condenser Pump Electricity Rate",
    9738             :                                         Constant::Units::W,
    9739           3 :                                         cond.ActualEvapPumpPower,
    9740             :                                         OutputProcessor::TimeStepType::Zone,
    9741             :                                         OutputProcessor::StoreType::Average,
    9742           3 :                                         cond.Name);
    9743           6 :                     SetupOutputVariable(state,
    9744             :                                         "Refrigeration System Condenser Pump Electricity Energy",
    9745             :                                         Constant::Units::J,
    9746           3 :                                         cond.EvapPumpConsumption,
    9747             :                                         OutputProcessor::TimeStepType::Zone,
    9748             :                                         OutputProcessor::StoreType::Sum,
    9749           3 :                                         cond.Name,
    9750             :                                         Constant::eResource::Electricity,
    9751             :                                         OutputProcessor::Group::Plant,
    9752             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9753             :                                         cond.EndUseSubcategory);
    9754           6 :                     SetupOutputVariable(state,
    9755             :                                         "Refrigeration System Condenser Basin Heater Electricity Rate",
    9756             :                                         Constant::Units::W,
    9757           3 :                                         cond.BasinHeaterPower,
    9758             :                                         OutputProcessor::TimeStepType::Zone,
    9759             :                                         OutputProcessor::StoreType::Average,
    9760           3 :                                         cond.Name);
    9761           6 :                     SetupOutputVariable(state,
    9762             :                                         "Refrigeration System Condenser Basin Heater Electricity Energy",
    9763             :                                         Constant::Units::J,
    9764           3 :                                         cond.BasinHeaterConsumption,
    9765             :                                         OutputProcessor::TimeStepType::Zone,
    9766             :                                         OutputProcessor::StoreType::Sum,
    9767           3 :                                         cond.Name,
    9768             :                                         Constant::eResource::Electricity,
    9769             :                                         OutputProcessor::Group::Plant,
    9770             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9771             :                                         cond.EndUseSubcategory);
    9772           6 :                     SetupOutputVariable(state,
    9773             :                                         "Refrigeration System Condenser Evaporated Water Volume Flow Rate",
    9774             :                                         Constant::Units::m3_s,
    9775           3 :                                         cond.EvapWaterConsumpRate,
    9776             :                                         OutputProcessor::TimeStepType::Zone,
    9777             :                                         OutputProcessor::StoreType::Average,
    9778           3 :                                         cond.Name);
    9779           6 :                     SetupOutputVariable(state,
    9780             :                                         "Refrigeration System Condenser Evaporated Water Volume",
    9781             :                                         Constant::Units::m3,
    9782           3 :                                         cond.EvapWaterConsumption,
    9783             :                                         OutputProcessor::TimeStepType::Zone,
    9784             :                                         OutputProcessor::StoreType::Sum,
    9785           3 :                                         cond.Name,
    9786             :                                         Constant::eResource::Water,
    9787             :                                         OutputProcessor::Group::Plant,
    9788             :                                         OutputProcessor::EndUseCat::Refrigeration,
    9789             :                                         cond.EndUseSubcategory);
    9790             :                 } // Evaporative Condenser Variables
    9791             : 
    9792          28 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9793           2 :                     SetupOutputVariable(state,
    9794             :                                         "Refrigeration System Condenser Water Mass Flow Rate",
    9795             :                                         Constant::Units::kg_s,
    9796           1 :                                         cond.MassFlowRate,
    9797             :                                         OutputProcessor::TimeStepType::System,
    9798             :                                         OutputProcessor::StoreType::Average,
    9799           1 :                                         cond.Name);
    9800             : 
    9801             :                 } // Water-cooled Condenser variables
    9802             :             }     // Condenser%CoilFlag to distinguish HVAC vs Zone time steps
    9803             :         }         // CondNum on DataHeatBalance::NumRefrigCondensers
    9804             : 
    9805          14 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    9806           3 :             for (int subcoolNum = 1; subcoolNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++subcoolNum) {
    9807           2 :                 auto &cooler = Subcooler(subcoolNum);
    9808             :                 // CurrentModuleObject='Refrigeration:Subcooler'
    9809           2 :                 if (cooler.CoilFlag) { // Subcooler serving system with chillers on HVAC time step
    9810           0 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9811           0 :                         SetupOutputVariable(state,
    9812             :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Rate",
    9813             :                                             Constant::Units::W,
    9814           0 :                                             cooler.MechSCTransLoad,
    9815             :                                             OutputProcessor::TimeStepType::Zone,
    9816             :                                             OutputProcessor::StoreType::Average,
    9817           0 :                                             cooler.Name);
    9818           0 :                         SetupOutputVariable(state,
    9819             :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Energy",
    9820             :                                             Constant::Units::J,
    9821           0 :                                             cooler.MechSCTransEnergy,
    9822             :                                             OutputProcessor::TimeStepType::Zone,
    9823             :                                             OutputProcessor::StoreType::Sum,
    9824           0 :                                             cooler.Name);
    9825             :                     }
    9826             :                 } else { // Subcooler on system serving cases and/or walkins
    9827           2 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9828           2 :                         SetupOutputVariable(state,
    9829             :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Rate",
    9830             :                                             Constant::Units::W,
    9831           1 :                                             cooler.MechSCTransLoad,
    9832             :                                             OutputProcessor::TimeStepType::System,
    9833             :                                             OutputProcessor::StoreType::Average,
    9834           1 :                                             cooler.Name);
    9835           2 :                         SetupOutputVariable(state,
    9836             :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Energy",
    9837             :                                             Constant::Units::J,
    9838           1 :                                             cooler.MechSCTransEnergy,
    9839             :                                             OutputProcessor::TimeStepType::System,
    9840             :                                             OutputProcessor::StoreType::Sum,
    9841           1 :                                             cooler.Name);
    9842             :                     }
    9843             :                 } // Subcoolers on system serving chillers
    9844             :             }     // Subcoolnum on NumSimulationSubcoolers
    9845             :         }         // NumSimulationSubcoolers > 0
    9846             : 
    9847             :     } // NumRefrigSystems > 0
    9848             : 
    9849         796 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9850             :         // CurrentModuleObject='Refrigeration:TranscriticalSystem'
    9851           2 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++refrigSysNum) {
    9852           1 :             auto &sys = TransSystem(refrigSysNum);
    9853             :             // for both SingleStage and TwoStage systems (medium temperature loads present)
    9854           2 :             SetupOutputVariable(state,
    9855             :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Rate",
    9856             :                                 Constant::Units::W,
    9857           1 :                                 sys.TotCompPowerHP,
    9858             :                                 OutputProcessor::TimeStepType::Zone,
    9859             :                                 OutputProcessor::StoreType::Average,
    9860           1 :                                 sys.Name);
    9861           2 :             SetupOutputVariable(state,
    9862             :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Energy",
    9863             :                                 Constant::Units::J,
    9864           1 :                                 sys.TotCompElecConsumpHP,
    9865             :                                 OutputProcessor::TimeStepType::Zone,
    9866             :                                 OutputProcessor::StoreType::Sum,
    9867           1 :                                 sys.Name);
    9868           2 :             SetupOutputVariable(state,
    9869             :                                 "Refrigeration Transcritical System Total Compressor Electricity Energy",
    9870             :                                 Constant::Units::J,
    9871           1 :                                 sys.TotCompElecConsump,
    9872             :                                 OutputProcessor::TimeStepType::Zone,
    9873             :                                 OutputProcessor::StoreType::Sum,
    9874           1 :                                 sys.Name);
    9875           2 :             SetupOutputVariable(state,
    9876             :                                 "Refrigeration Transcritical System Average COP",
    9877             :                                 Constant::Units::W_W,
    9878           1 :                                 sys.AverageCompressorCOP,
    9879             :                                 OutputProcessor::TimeStepType::Zone,
    9880             :                                 OutputProcessor::StoreType::Average,
    9881           1 :                                 sys.Name);
    9882           2 :             SetupOutputVariable(state,
    9883             :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Rate",
    9884             :                                 Constant::Units::W,
    9885           1 :                                 sys.TotalCoolingLoadMT,
    9886             :                                 OutputProcessor::TimeStepType::Zone,
    9887             :                                 OutputProcessor::StoreType::Average,
    9888           1 :                                 sys.Name);
    9889           2 :             SetupOutputVariable(state,
    9890             :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Energy",
    9891             :                                 Constant::Units::J,
    9892           1 :                                 sys.TotalCoolingEnergyMT,
    9893             :                                 OutputProcessor::TimeStepType::Zone,
    9894             :                                 OutputProcessor::StoreType::Sum,
    9895           1 :                                 sys.Name);
    9896           2 :             SetupOutputVariable(state,
    9897             :                                 "Refrigeration Transcritical System Total Cases and Walk Ins Heat Transfer Energy",
    9898             :                                 Constant::Units::J,
    9899           1 :                                 sys.TotalCoolingEnergy,
    9900             :                                 OutputProcessor::TimeStepType::Zone,
    9901             :                                 OutputProcessor::StoreType::Sum,
    9902           1 :                                 sys.Name);
    9903           2 :             SetupOutputVariable(state,
    9904             :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Rate",
    9905             :                                 Constant::Units::W,
    9906           1 :                                 sys.PipeHeatLoadMT,
    9907             :                                 OutputProcessor::TimeStepType::Zone,
    9908             :                                 OutputProcessor::StoreType::Average,
    9909           1 :                                 sys.Name);
    9910           2 :             SetupOutputVariable(state,
    9911             :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Energy",
    9912             :                                 Constant::Units::J,
    9913           1 :                                 sys.PipeHeatEnergyMT,
    9914             :                                 OutputProcessor::TimeStepType::Zone,
    9915             :                                 OutputProcessor::StoreType::Sum,
    9916           1 :                                 sys.Name);
    9917           2 :             SetupOutputVariable(state,
    9918             :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Rate",
    9919             :                                 Constant::Units::W,
    9920           1 :                                 sys.TotCompCapacityHP,
    9921             :                                 OutputProcessor::TimeStepType::Zone,
    9922             :                                 OutputProcessor::StoreType::Average,
    9923           1 :                                 sys.Name);
    9924           2 :             SetupOutputVariable(state,
    9925             :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Energy",
    9926             :                                 Constant::Units::J,
    9927           1 :                                 sys.TotCompCoolingEnergyHP,
    9928             :                                 OutputProcessor::TimeStepType::Zone,
    9929             :                                 OutputProcessor::StoreType::Sum,
    9930           1 :                                 sys.Name); // indiv compressors go to meter, not system sum
    9931           2 :             SetupOutputVariable(state,
    9932             :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Rate",
    9933             :                                 Constant::Units::W,
    9934           1 :                                 sys.NetHeatRejectLoad,
    9935             :                                 OutputProcessor::TimeStepType::Zone,
    9936             :                                 OutputProcessor::StoreType::Average,
    9937           1 :                                 sys.Name);
    9938           2 :             SetupOutputVariable(state,
    9939             :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Energy",
    9940             :                                 Constant::Units::J,
    9941           1 :                                 sys.NetHeatRejectEnergy,
    9942             :                                 OutputProcessor::TimeStepType::Zone,
    9943             :                                 OutputProcessor::StoreType::Sum,
    9944           1 :                                 sys.Name);
    9945           2 :             SetupOutputVariable(state,
    9946             :                                 "Refrigeration Transcritical System Estimated Refrigerant Inventory Mass",
    9947             :                                 Constant::Units::kg,
    9948           1 :                                 sys.RefInventory,
    9949             :                                 OutputProcessor::TimeStepType::Zone,
    9950             :                                 OutputProcessor::StoreType::Average,
    9951           1 :                                 sys.Name);
    9952           2 :             SetupOutputVariable(state,
    9953             :                                 "Refrigeration Transcritical System Refrigerant Mass Flow Rate",
    9954             :                                 Constant::Units::kg_s,
    9955           1 :                                 sys.RefMassFlowComps,
    9956             :                                 OutputProcessor::TimeStepType::Zone,
    9957             :                                 OutputProcessor::StoreType::Average,
    9958           1 :                                 sys.Name);
    9959           2 :             SetupOutputVariable(state,
    9960             :                                 "Refrigeration Transcritical System Medium Temperature Evaporating Temperature",
    9961             :                                 Constant::Units::C,
    9962           1 :                                 sys.TEvapNeededMT,
    9963             :                                 OutputProcessor::TimeStepType::Zone,
    9964             :                                 OutputProcessor::StoreType::Average,
    9965           1 :                                 sys.Name);
    9966           2 :             SetupOutputVariable(state,
    9967             :                                 "Refrigeration Transcritical System Medium Temperature Suction Temperature",
    9968             :                                 Constant::Units::C,
    9969           1 :                                 sys.TCompInHP,
    9970             :                                 OutputProcessor::TimeStepType::Zone,
    9971             :                                 OutputProcessor::StoreType::Average,
    9972           1 :                                 sys.Name);
    9973           1 :             if (sys.TransSysType == 2) { // for TwoStage system only (low temperature loads present)
    9974           2 :                 SetupOutputVariable(state,
    9975             :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Rate",
    9976             :                                     Constant::Units::W,
    9977           1 :                                     sys.TotCompPowerLP,
    9978             :                                     OutputProcessor::TimeStepType::Zone,
    9979             :                                     OutputProcessor::StoreType::Average,
    9980           1 :                                     sys.Name);
    9981           2 :                 SetupOutputVariable(state,
    9982             :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Energy",
    9983             :                                     Constant::Units::J,
    9984           1 :                                     sys.TotCompElecConsumpLP,
    9985             :                                     OutputProcessor::TimeStepType::Zone,
    9986             :                                     OutputProcessor::StoreType::Sum,
    9987           1 :                                     sys.Name);
    9988           2 :                 SetupOutputVariable(state,
    9989             :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Rate",
    9990             :                                     Constant::Units::W,
    9991           1 :                                     sys.TotalCoolingLoadLT,
    9992             :                                     OutputProcessor::TimeStepType::Zone,
    9993             :                                     OutputProcessor::StoreType::Average,
    9994           1 :                                     sys.Name);
    9995           2 :                 SetupOutputVariable(state,
    9996             :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Energy",
    9997             :                                     Constant::Units::J,
    9998           1 :                                     sys.TotalCoolingEnergyLT,
    9999             :                                     OutputProcessor::TimeStepType::Zone,
   10000             :                                     OutputProcessor::StoreType::Sum,
   10001           1 :                                     sys.Name);
   10002           2 :                 SetupOutputVariable(state,
   10003             :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Rate",
   10004             :                                     Constant::Units::W,
   10005           1 :                                     sys.PipeHeatLoadLT,
   10006             :                                     OutputProcessor::TimeStepType::Zone,
   10007             :                                     OutputProcessor::StoreType::Average,
   10008           1 :                                     sys.Name);
   10009           2 :                 SetupOutputVariable(state,
   10010             :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Energy",
   10011             :                                     Constant::Units::J,
   10012           1 :                                     sys.PipeHeatEnergyLT,
   10013             :                                     OutputProcessor::TimeStepType::Zone,
   10014             :                                     OutputProcessor::StoreType::Sum,
   10015           1 :                                     sys.Name);
   10016           2 :                 SetupOutputVariable(state,
   10017             :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Rate",
   10018             :                                     Constant::Units::W,
   10019           1 :                                     sys.TotCompCapacityLP,
   10020             :                                     OutputProcessor::TimeStepType::Zone,
   10021             :                                     OutputProcessor::StoreType::Average,
   10022           1 :                                     sys.Name);
   10023           2 :                 SetupOutputVariable(state,
   10024             :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Energy",
   10025             :                                     Constant::Units::J,
   10026           1 :                                     sys.TotCompCoolingEnergyLP,
   10027             :                                     OutputProcessor::TimeStepType::Zone,
   10028             :                                     OutputProcessor::StoreType::Sum,
   10029           1 :                                     sys.Name); // indiv compressors go to meter, not system sum
   10030           2 :                 SetupOutputVariable(state,
   10031             :                                     "Refrigeration Transcritical System Low Temperature Evaporating Temperature",
   10032             :                                     Constant::Units::C,
   10033           1 :                                     sys.TEvapNeededLT,
   10034             :                                     OutputProcessor::TimeStepType::Zone,
   10035             :                                     OutputProcessor::StoreType::Average,
   10036           1 :                                     sys.Name);
   10037           2 :                 SetupOutputVariable(state,
   10038             :                                     "Refrigeration Transcritical System Low Temperature Suction Temperature",
   10039             :                                     Constant::Units::C,
   10040           1 :                                     sys.TCompInLP,
   10041             :                                     OutputProcessor::TimeStepType::Zone,
   10042             :                                     OutputProcessor::StoreType::Average,
   10043           1 :                                     sys.Name);
   10044             :             } // (sys%TransSysType == 2)
   10045             : 
   10046           1 :             if (sys.SystemRejectHeatToZone) {
   10047           0 :                 if (GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum > 0)
   10048           0 :                     SetupZoneInternalGain(state,
   10049           0 :                                           GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum,
   10050             :                                           sys.Name,
   10051             :                                           DataHeatBalance::IntGainType::RefrigerationTransSysAirCooledGasCooler,
   10052             :                                           &sys.NetHeatRejectLoad);
   10053             :             } // (sys%SystemRejectHeatToZone)
   10054           1 :             if (sys.SuctionPipeActualZoneNumMT > 0) {
   10055           0 :                 SetupZoneInternalGain(state,
   10056             :                                       sys.SuctionPipeActualZoneNumMT,
   10057             :                                       sys.Name,
   10058             :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeMT,
   10059             :                                       &sys.PipeHeatLoadMT);
   10060             :             } // sys%SuctionPipeActualZoneNumMT > 0
   10061           1 :             if (sys.SuctionPipeActualZoneNumLT > 0) {
   10062           0 :                 SetupZoneInternalGain(state,
   10063             :                                       sys.SuctionPipeActualZoneNumLT,
   10064             :                                       sys.Name,
   10065             :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeLT,
   10066             :                                       &sys.PipeHeatLoadLT);
   10067             :             } // sys%SuctionPipeActualZoneNumLT > 0
   10068             : 
   10069             :             // Report Compressor ENERGY here, not on system level for meters.
   10070             :             // LP compressors
   10071           4 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsLP; ++compIndex) {
   10072           3 :                 int compNum = sys.CompressorNumLP(compIndex);
   10073             :                 // CurrentModuleObject='Refrigeration:Compressor'
   10074           3 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
   10075           6 :                     SetupOutputVariable(state,
   10076             :                                         "Refrigeration Compressor Electricity Rate",
   10077             :                                         Constant::Units::W,
   10078           3 :                                         Compressor(compNum).Power,
   10079             :                                         OutputProcessor::TimeStepType::Zone,
   10080             :                                         OutputProcessor::StoreType::Average,
   10081           3 :                                         Compressor(compNum).Name);
   10082           6 :                     SetupOutputVariable(state,
   10083             :                                         "Refrigeration Compressor Electricity Energy",
   10084             :                                         Constant::Units::J,
   10085           3 :                                         Compressor(compNum).ElecConsumption,
   10086             :                                         OutputProcessor::TimeStepType::Zone,
   10087             :                                         OutputProcessor::StoreType::Sum,
   10088           3 :                                         Compressor(compNum).Name,
   10089             :                                         Constant::eResource::Electricity,
   10090             :                                         OutputProcessor::Group::Plant,
   10091             :                                         OutputProcessor::EndUseCat::Refrigeration,
   10092           3 :                                         Compressor(compNum).EndUseSubcategory);
   10093           6 :                     SetupOutputVariable(state,
   10094             :                                         "Refrigeration Compressor Heat Transfer Rate",
   10095             :                                         Constant::Units::W,
   10096           3 :                                         Compressor(compNum).Capacity,
   10097             :                                         OutputProcessor::TimeStepType::Zone,
   10098             :                                         OutputProcessor::StoreType::Average,
   10099           3 :                                         Compressor(compNum).Name);
   10100           6 :                     SetupOutputVariable(state,
   10101             :                                         "Refrigeration Compressor Heat Transfer Energy",
   10102             :                                         Constant::Units::J,
   10103           3 :                                         Compressor(compNum).CoolingEnergy,
   10104             :                                         OutputProcessor::TimeStepType::Zone,
   10105             :                                         OutputProcessor::StoreType::Sum,
   10106           3 :                                         Compressor(compNum).Name);
   10107           6 :                     SetupOutputVariable(state,
   10108             :                                         "Refrigeration Compressor Runtime Fraction",
   10109             :                                         Constant::Units::None,
   10110           3 :                                         Compressor(compNum).LoadFactor,
   10111             :                                         OutputProcessor::TimeStepType::Zone,
   10112             :                                         OutputProcessor::StoreType::Average,
   10113           3 :                                         Compressor(compNum).Name);
   10114             :                 } // NumSysAttach
   10115             :             }     // sys%NumCompressorsLP
   10116             : 
   10117             :             // HP compressors
   10118           4 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsHP; ++compIndex) {
   10119           3 :                 int compNum = sys.CompressorNumHP(compIndex);
   10120             :                 // CurrentModuleObject='Refrigeration:Compressor'
   10121           3 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
   10122           6 :                     SetupOutputVariable(state,
   10123             :                                         "Refrigeration Compressor Electricity Rate",
   10124             :                                         Constant::Units::W,
   10125           3 :                                         Compressor(compNum).Power,
   10126             :                                         OutputProcessor::TimeStepType::Zone,
   10127             :                                         OutputProcessor::StoreType::Average,
   10128           3 :                                         Compressor(compNum).Name);
   10129           6 :                     SetupOutputVariable(state,
   10130             :                                         "Refrigeration Compressor Electricity Energy",
   10131             :                                         Constant::Units::J,
   10132           3 :                                         Compressor(compNum).ElecConsumption,
   10133             :                                         OutputProcessor::TimeStepType::Zone,
   10134             :                                         OutputProcessor::StoreType::Sum,
   10135           3 :                                         Compressor(compNum).Name,
   10136             :                                         Constant::eResource::Electricity,
   10137             :                                         OutputProcessor::Group::Plant,
   10138             :                                         OutputProcessor::EndUseCat::Refrigeration,
   10139           3 :                                         Compressor(compNum).EndUseSubcategory);
   10140           6 :                     SetupOutputVariable(state,
   10141             :                                         "Refrigeration Compressor Heat Transfer Rate",
   10142             :                                         Constant::Units::W,
   10143           3 :                                         Compressor(compNum).Capacity,
   10144             :                                         OutputProcessor::TimeStepType::Zone,
   10145             :                                         OutputProcessor::StoreType::Average,
   10146           3 :                                         Compressor(compNum).Name);
   10147           6 :                     SetupOutputVariable(state,
   10148             :                                         "Refrigeration Compressor Heat Transfer Energy",
   10149             :                                         Constant::Units::J,
   10150           3 :                                         Compressor(compNum).CoolingEnergy,
   10151             :                                         OutputProcessor::TimeStepType::Zone,
   10152             :                                         OutputProcessor::StoreType::Sum,
   10153           3 :                                         Compressor(compNum).Name);
   10154           6 :                     SetupOutputVariable(state,
   10155             :                                         "Refrigeration Compressor Runtime Fraction",
   10156             :                                         Constant::Units::None,
   10157           3 :                                         Compressor(compNum).LoadFactor,
   10158             :                                         OutputProcessor::TimeStepType::Zone,
   10159             :                                         OutputProcessor::StoreType::Average,
   10160           3 :                                         Compressor(compNum).Name);
   10161             :                 } // NumSysAttach
   10162             :             }     // sys%NumCompressorsHP
   10163             : 
   10164             :         } // NumTransRefrigSystems
   10165             :     }     // (NumTransRefrigSystems > 0)
   10166             : 
   10167         796 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10168           2 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
   10169           1 :             auto &cooler = GasCooler(GCNum);
   10170             :             // CurrentModuleObject='Refrigeration:GasCooler:AirCooled'
   10171           2 :             SetupOutputVariable(state,
   10172             :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Rate",
   10173             :                                 Constant::Units::W,
   10174           1 :                                 cooler.GasCoolerLoad,
   10175             :                                 OutputProcessor::TimeStepType::Zone,
   10176             :                                 OutputProcessor::StoreType::Average,
   10177           1 :                                 cooler.Name);
   10178           2 :             SetupOutputVariable(state,
   10179             :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Energy",
   10180             :                                 Constant::Units::J,
   10181           1 :                                 cooler.GasCoolerEnergy,
   10182             :                                 OutputProcessor::TimeStepType::Zone,
   10183             :                                 OutputProcessor::StoreType::Sum,
   10184           1 :                                 cooler.Name);
   10185           2 :             SetupOutputVariable(state,
   10186             :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Rate",
   10187             :                                 Constant::Units::W,
   10188           1 :                                 cooler.ActualFanPower,
   10189             :                                 OutputProcessor::TimeStepType::Zone,
   10190             :                                 OutputProcessor::StoreType::Average,
   10191           1 :                                 cooler.Name);
   10192           2 :             SetupOutputVariable(state,
   10193             :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Energy",
   10194             :                                 Constant::Units::J,
   10195           1 :                                 cooler.FanElecEnergy,
   10196             :                                 OutputProcessor::TimeStepType::Zone,
   10197             :                                 OutputProcessor::StoreType::Sum,
   10198           1 :                                 cooler.Name,
   10199             :                                 Constant::eResource::Electricity,
   10200             :                                 OutputProcessor::Group::Plant,
   10201             :                                 OutputProcessor::EndUseCat::Refrigeration,
   10202             :                                 cooler.EndUseSubcategory);
   10203           2 :             SetupOutputVariable(state,
   10204             :                                 "Refrigeration Transcritical System Gas Cooler Outlet Temperature",
   10205             :                                 Constant::Units::C,
   10206           1 :                                 cooler.TGasCoolerOut,
   10207             :                                 OutputProcessor::TimeStepType::Zone,
   10208             :                                 OutputProcessor::StoreType::Average,
   10209           1 :                                 cooler.Name);
   10210           2 :             SetupOutputVariable(state,
   10211             :                                 "Refrigeration Transcritical System Gas Cooler Outlet Pressure",
   10212             :                                 Constant::Units::Pa,
   10213           1 :                                 cooler.PGasCoolerOut,
   10214             :                                 OutputProcessor::TimeStepType::Zone,
   10215             :                                 OutputProcessor::StoreType::Average,
   10216           1 :                                 cooler.Name);
   10217           2 :             SetupOutputVariable(state,
   10218             :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Rate",
   10219             :                                 Constant::Units::W,
   10220           1 :                                 cooler.InternalHeatRecoveredLoad,
   10221             :                                 OutputProcessor::TimeStepType::Zone,
   10222             :                                 OutputProcessor::StoreType::Average,
   10223           1 :                                 cooler.Name);
   10224           2 :             SetupOutputVariable(state,
   10225             :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Energy",
   10226             :                                 Constant::Units::J,
   10227           1 :                                 cooler.InternalEnergyRecovered,
   10228             :                                 OutputProcessor::TimeStepType::Zone,
   10229             :                                 OutputProcessor::StoreType::Sum,
   10230           1 :                                 cooler.Name);
   10231             :         } // GCNum on NumSimulationGasCooler
   10232             :     }     // (NumSimulationGasCooler >0)
   10233         796 : }
   10234             : 
   10235      464456 : void InitRefrigeration(EnergyPlusData &state)
   10236             : {
   10237             :     // SUBROUTINE INFORMATION:
   10238             :     //       AUTHOR         Richard Raustad, FSEC
   10239             :     //       DATE WRITTEN   Oct/Nov 2004
   10240             :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008
   10241             :     //       RE-ENGINEERED  na
   10242             : 
   10243             :     // PURPOSE OF THIS SUBROUTINE:
   10244             :     // Initialize (zero) global variables before simulating compressor racks and refrigerated cases
   10245             :     // Several variables in this module are accumulative.  For example, unmet compressor loads are carried over
   10246             :     // to the next time step. Ice loads are accumulated until melted by a defrost.  Because this module can be
   10247             :     // called multiple times during any single time step, these summations need to be saved ONLY on the last time
   10248             :     // through any given time step.
   10249             : 
   10250             :     // It is necessary to decrease the condenser load by the amount of heat used elsewhere
   10251             :     //   via desuperheating water heaters and heating coils.
   10252             :     //   Because the refrigeration system is solved before the HVAC time step loops, the
   10253             :     //   refrigeration system must use the values lagged from the previous time step. In
   10254             :     //   terms of energy, this should balance out and is preferable to not making the correction,
   10255             :     //   in which case the condenser cooling water/air/fan energy are charged with energy
   10256             :     //   loads that have been accounted elsewhere.  For consistency, the lagged value must be used,
   10257             :     //   even if the Zone time step is repeated.  Therefore, the lagged variables are saved
   10258             :     //   here for use during successive iterations of same zone/load time step.
   10259             : 
   10260             :     // METHODOLOGY EMPLOYED:
   10261             :     // Global variables for Case Credit are located in DataHeatBalance. To Zone variables are used in the Air Heat
   10262             :     // Balance in ZoneTempPredictorCorrector to calculate the zone load. To HVAC variables are used in
   10263             :     // ZoneEquipmentManager to add the portion of case credits attributed to the HVAC system to the zone return air node.
   10264             : 
   10265             :     // Because we can't know apriori whether or not the time step will be repeated, we save the most recent
   10266             :     // addition/subtraction to/from each accumulating variable.  If the time step is repeated,
   10267             :     // this most recent addition/subtraction is reversed before the rest of the refrigeration simulation begins.
   10268             : 
   10269             :     // Used to adjust accumulative variables when time step is repeated
   10270             : 
   10271      464456 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10272      464456 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10273      464456 :     auto &System = state.dataRefrigCase->System;
   10274      464456 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   10275      464456 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10276      464456 :     auto &Compressor = state.dataRefrigCase->Compressor;
   10277      464456 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   10278      464456 :     auto &Secondary = state.dataRefrigCase->Secondary;
   10279      464456 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10280      464456 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10281      464456 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   10282      464456 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   10283             : 
   10284             :     // Zero display case, air-coil, and walk-in cooler credits (summed by zone)
   10285             :     // to 0 each zone or sys time step
   10286             :     // These 'casecredit' variables are also used to transfer energy from zone-located
   10287             :     // compressor-rack condenser heat rejection, heat absorption by distribution piping,
   10288             :     // suction piping, and receiver shells to zone
   10289      464456 :     if (state.dataGlobal->NumOfZones > 0) {
   10290      464456 :         if (state.dataRefrigCase->UseSysTimeStep) {
   10291     5343915 :             for (int i = CoilSysCredit.l(), e = CoilSysCredit.u(); i <= e; ++i) {
   10292     4987654 :                 CoilSysCredit(i).reset();
   10293             :             }
   10294             :         } // UseSysTimeStep = true
   10295             : 
   10296             :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is false
   10297      572651 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10298      108195 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10299             : 
   10300     3411399 :             for (auto &credit : state.dataHeatBal->RefrigCaseCredit) {
   10301     3306095 :                 credit.reset();
   10302      105304 :             }
   10303     3411399 :             for (auto &zoneReport : CaseWIZoneReport) {
   10304     3306095 :                 zoneReport.reset();
   10305             :             }
   10306             :         }
   10307             :     }
   10308             : 
   10309      464456 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   10310             :         // RefrigCase ALLOCATED to NumSimulationCases
   10311      571096 :         for (auto &refrig : RefrigCase) {
   10312      465792 :             refrig.reset_init();
   10313             :         }
   10314             :     } // NumSimulationCases
   10315             : 
   10316      464456 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10317             :         // WalkIn ALLOCATED to NumSimulationWalkIns
   10318       83632 :         for (int i = WalkIn.l(), e = WalkIn.u(); i <= e; ++i) {
   10319       48317 :             WalkIn(i).reset_init();
   10320             :         }
   10321             :     }
   10322             : 
   10323      464456 :     if (state.dataRefrigCase->HaveChillers) {
   10324             :         // HaveChillers is TRUE when NumSimulationRefrigAirChillers > 0
   10325             :         // WarehouseCoil ALLOCATED to NumSimulationRefrigAirChillers
   10326    30168768 :         for (int i = WarehouseCoil.l(), e = WarehouseCoil.u(); i <= e; ++i) {
   10327    29809616 :             WarehouseCoil(i).reset_init();
   10328             :         }
   10329             :     }
   10330             : 
   10331      464456 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   10332             :         // HaveRefrigRacks TRUE when NumRefrigeratedRacks > 0
   10333             :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   10334      257970 :         for (int i = RefrigRack.l(), e = RefrigRack.u(); i <= e; ++i) {
   10335      171752 :             RefrigRack(i).reset_init();
   10336             :         }
   10337      257970 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack)
   10338      257970 :             e.AvailCapacity = 0.0;
   10339             :         // Note don't reset basin heat to zero when no load because heater would remain on
   10340             :         // RefrigRack.BasinHeaterPower = 0.0;
   10341             :         // RefrigRack.BasinHeaterConsumption = 0.0;
   10342             :     }
   10343             : 
   10344      464456 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10345             :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   10346     3701521 :         for (int i = Condenser.l(), e = Condenser.u(); i <= e; ++i) {
   10347     3307054 :             Condenser(i).reset_init();
   10348             :         }
   10349             :         // N don't reset basin heat to zero when no load because heater would remain on
   10350     3701521 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10351     3307054 :             e.AvailCapacity = 0.0;
   10352     3307054 :             e.AvailTemperature = 0.0;
   10353      394467 :         }
   10354             :     }
   10355             : 
   10356      464456 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10357             :         // GasCooler ALLOCATED to NumSimulationGasCooler
   10358        4056 :         for (int i = GasCooler.l(), e = GasCooler.u(); i <= e; ++i) {
   10359        2028 :             GasCooler(i).reset_init();
   10360             :         }
   10361             :     }
   10362             : 
   10363      464456 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
   10364             :         // Compressor ALLOCATED to NumSimulationCompressors
   10365    26176769 :         for (int i = Compressor.l(), e = Compressor.u(); i <= e; ++i) {
   10366    25780274 :             Compressor(i).reset_init();
   10367             :         }
   10368             :     }
   10369             : 
   10370      464456 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
   10371             :         // HaveDetailedRefrig is TRUE when NumRefrigSystems > 0
   10372             :         // System is ALLOCATED to NumRefrigSystems
   10373     3705577 :         for (int i = System.l(), e = System.u(); i <= e; ++i) {
   10374     3311110 :             System(i).reset_init();
   10375             :         }
   10376             :     }
   10377             : 
   10378      464456 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
   10379             :         // HaveDetailedTransRefrig is TRUE when NumTransRefrigSystems > 0
   10380             :         // TransSystem is ALLOCATED to NumTransRefrigSystems
   10381        4056 :         for (int i = TransSystem.l(), e = TransSystem.u(); i <= e; ++i) {
   10382        2028 :             TransSystem(i).reset_init();
   10383             :         }
   10384             :     }
   10385             : 
   10386      464456 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10387             :         // Secondary is ALLOCATED to NumSimulationSecondarySystems
   10388        6084 :         for (int i = Secondary.l(), e = Secondary.u(); i <= e; ++i) {
   10389        4056 :             Secondary(i).reset_init();
   10390             :         }
   10391             :     }
   10392             : 
   10393             :     // Accumulative and carry-over variables are not zeroed at start of each time step, only at begining of environment
   10394      464456 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag) {
   10395         308 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   10396        1635 :             for (int i = RefrigCase.l(), e = RefrigCase.u(); i <= e; ++i) {
   10397        1333 :                 RefrigCase(i).reset_init_accum();
   10398             :             }
   10399             :         }
   10400         308 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10401         360 :             for (auto &e : System)
   10402         262 :                 e.UnmetEnergy = 0.0;
   10403             :         }
   10404         308 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10405         210 :             for (auto &e : WalkIn) {
   10406         118 :                 e.KgFrost = 0.0;
   10407         118 :                 e.StoredEnergy = 0.0;
   10408             :             }
   10409         210 :             for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10410         118 :                 WalkIn(walkInID).IceTemp = WalkIn(walkInID).TEvapDesign;
   10411             :             }
   10412             :         }
   10413         308 :         if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10414         504 :             for (auto &e : WarehouseCoil) {
   10415         498 :                 e.KgFrost = 0.0;
   10416         498 :                 e.KgFrostSaved = 0.0;
   10417             :             }
   10418         504 :             for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10419         498 :                 WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).TEvapDesign;
   10420         498 :                 WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).TEvapDesign;
   10421             :             }
   10422             :         }
   10423         308 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10424          18 :             for (auto &e : Secondary)
   10425          12 :                 e.UnmetEnergy = 0.0;
   10426             :         }
   10427         308 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   10428         772 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
   10429         514 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10430         514 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10431         258 :             }
   10432         772 :             for (auto &e : RefrigRack) {
   10433         514 :                 e.LaggedUsedWaterHeater = 0.0;
   10434         514 :                 e.LaggedUsedHVACCoil = 0.0;
   10435             :             }
   10436             :         }
   10437         308 :         if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10438         348 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10439         250 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10440         250 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10441          98 :             }
   10442         348 :             for (auto &e : Condenser) {
   10443         250 :                 e.LaggedUsedWaterHeater = 0.0;
   10444         250 :                 e.LaggedUsedHVACCoil = 0.0;
   10445             :             }
   10446             :         }
   10447         570 :         for (int systemId = 1; systemId <= state.dataRefrigCase->NumRefrigSystems; ++systemId) {
   10448         262 :             if (allocated(System(systemId).MechSCLoad)) System(systemId).MechSCLoad = 0.0;
   10449         262 :             System(systemId).LSHXTrans = 0.0;
   10450         262 :             System(systemId).LSHXTransEnergy = 0.0;
   10451             :         }
   10452             : 
   10453         308 :         if (state.dataGlobal->NumOfTimeStepInHour > 0.0) state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->NumOfTimeStepInHour);
   10454         308 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = false;
   10455             : 
   10456             :     } // ( DataGlobals::BeginEnvrnFlag && MyBeginEnvrnFlag )
   10457             : 
   10458      464456 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = true;
   10459             : 
   10460             :     // Avoid multiplying accumulation if go through zone/load time step more than once.
   10461      464456 :     if (!state.dataGlobal->WarmupFlag) { // because no accumulation is done during warm up
   10462             :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   10463       48464 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10464       14112 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10465             :             // Used to determine whether the zone time step is a repetition
   10466       13920 :             Real64 MyCurrentTime = (state.dataGlobal->HourOfDay - 1) + state.dataGlobal->TimeStep * state.dataRefrigCase->TimeStepFraction;
   10467       13920 :             if (std::abs(MyCurrentTime - state.dataRefrigCase->MyCurrentTimeSaved) < MySmallNumber) {
   10468             :                 // If the time step is repeated, need to return to correct values at start of time step
   10469           0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
   10470           0 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
   10471           0 :                         RefrigCase(caseID).DefrostEnergy = RefrigCase(caseID).DefrostEnergySaved;
   10472           0 :                         RefrigCase(caseID).StockingEnergy = RefrigCase(caseID).StockingEnergySaved;
   10473           0 :                         RefrigCase(caseID).WarmEnvEnergy = RefrigCase(caseID).WarmEnvEnergySaved;
   10474           0 :                         RefrigCase(caseID).KgFrost = RefrigCase(caseID).KgFrostSaved;
   10475           0 :                         RefrigCase(caseID).StoredEnergy = RefrigCase(caseID).StoredEnergySaved;
   10476             :                     } // CaseID
   10477             :                 }     // NumSimulationCases
   10478           0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10479           0 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10480           0 :                         WalkIn(walkInID).KgFrost = WalkIn(walkInID).KgFrostSaved;
   10481           0 :                         WalkIn(walkInID).StoredEnergy = WalkIn(walkInID).StoredEnergySaved;
   10482           0 :                         WalkIn(walkInID).IceTemp = WalkIn(walkInID).IceTempSaved;
   10483             :                     }
   10484             :                 }
   10485           0 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10486           0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10487           0 :                         if (System(systemID).CoilFlag) continue;
   10488           0 :                         System(systemID).UnmetEnergy = System(systemID).UnmetEnergySaved;
   10489             :                     }
   10490             :                 }
   10491           0 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   10492           0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
   10493           0 :                         TransSystem(systemID).UnmetEnergyMT = TransSystem(systemID).UnmetEnergySavedMT;
   10494           0 :                         TransSystem(systemID).UnmetEnergyLT = TransSystem(systemID).UnmetEnergySavedLT;
   10495             :                     }
   10496             :                 }
   10497           0 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10498           0 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
   10499           0 :                         if (Secondary(secondID).CoilFlag) continue;
   10500           0 :                         Secondary(secondID).UnmetEnergy = Secondary(secondID).UnmetEnergySaved;
   10501             :                     }
   10502             :                 }
   10503             : 
   10504             :             } else {
   10505             :                 // First time through this Zone time step, so set saved values to those in place at start of this time step
   10506       13920 :                 state.dataRefrigCase->MyCurrentTimeSaved = MyCurrentTime;
   10507       13920 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
   10508       77760 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
   10509       63840 :                         RefrigCase(caseID).DefrostEnergySaved = RefrigCase(caseID).DefrostEnergy;
   10510       63840 :                         RefrigCase(caseID).StockingEnergySaved = RefrigCase(caseID).StockingEnergy;
   10511       63840 :                         RefrigCase(caseID).WarmEnvEnergySaved = RefrigCase(caseID).WarmEnvEnergy;
   10512       63840 :                         RefrigCase(caseID).KgFrostSaved = RefrigCase(caseID).KgFrost;
   10513       63840 :                         RefrigCase(caseID).StoredEnergySaved = RefrigCase(caseID).StoredEnergy;
   10514             :                     } // caseid
   10515             :                 }     // numsimulationcases
   10516       13920 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10517       11520 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10518        6624 :                         WalkIn(walkInID).KgFrostSaved = WalkIn(walkInID).KgFrost;
   10519        6624 :                         WalkIn(walkInID).StoredEnergySaved = WalkIn(walkInID).StoredEnergy;
   10520        6624 :                         WalkIn(walkInID).IceTempSaved = WalkIn(walkInID).IceTemp;
   10521             :                     }
   10522             :                 }
   10523       13920 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10524       15840 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10525       10944 :                         if (System(systemID).CoilFlag) continue;
   10526       10944 :                         System(systemID).UnmetEnergySaved = System(systemID).UnmetEnergy;
   10527             :                     }
   10528             :                 }
   10529       13920 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   10530         576 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
   10531         288 :                         TransSystem(systemID).UnmetEnergySavedMT = TransSystem(systemID).UnmetEnergyMT;
   10532         288 :                         TransSystem(systemID).UnmetEnergySavedLT = TransSystem(systemID).UnmetEnergyLT;
   10533             :                     }
   10534             :                 }
   10535       13920 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10536         864 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
   10537         576 :                         if (Secondary(secondID).CoilFlag) continue;
   10538         576 :                         Secondary(secondID).UnmetEnergySaved = Secondary(secondID).UnmetEnergy;
   10539             :                     }
   10540             :                 }
   10541             :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
   10542       13920 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
   10543       33888 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
   10544       45120 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
   10545       22560 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
   10546       22560 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
   10547       22560 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10548             :                     }
   10549             :                 }
   10550       13920 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10551       15264 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10552       20736 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10553       10368 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10554       10368 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10555       10368 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10556             :                     }
   10557             :                 }
   10558             :             } // repeating same time step
   10559             : 
   10560             :         } else { // using UseSysTimeStep as a flag for a chiller system
   10561             : 
   10562             :             // Used to determine whether the system time step is a repetition
   10563       20432 :             Real64 MyStepStartTime = state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed;
   10564       20432 :             if (std::abs(MyStepStartTime - state.dataRefrigCase->MyStepStartTimeSaved) < MySmallNumber) {
   10565             :                 // If the time step is repeated, need to return to correct values at start of time step
   10566       19576 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10567     1644384 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10568     1624808 :                         WarehouseCoil(coilID).KgFrost = WarehouseCoil(coilID).KgFrostSaved;
   10569     1624808 :                         WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).IceTempSaved;
   10570             :                     }
   10571             :                 }
   10572             :             } else { // First time through this system time step or hvac loop,
   10573             :                 // so set saved values to those in place at start of this time step
   10574         856 :                 state.dataRefrigCase->MyStepStartTimeSaved = MyStepStartTime;
   10575         856 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10576       71904 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10577       71048 :                         WarehouseCoil(coilID).KgFrostSaved = WarehouseCoil(coilID).KgFrost;
   10578       71048 :                         WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).IceTemp;
   10579             :                     }
   10580             :                 }
   10581             :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
   10582         856 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
   10583           0 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
   10584           0 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
   10585           0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
   10586           0 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
   10587           0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10588             :                     }
   10589             :                 }
   10590         856 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10591        8560 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10592       15408 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10593        7704 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10594        7704 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10595        7704 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10596             :                     }
   10597             :                 }
   10598             :             } // if first time
   10599             :         }     //(.NOT. UseSysTimeStep)
   10600             : 
   10601             :     } // warm up flag
   10602             : 
   10603      464456 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
   10604       26130 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10605       19503 :             for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10606       13002 :                 if (System(systemID).EMSOverrideOnTCondenseMin) {
   10607           0 :                     System(systemID).TCondenseMin = System(systemID).EMSOverrideValueTCondenseMin;
   10608             :                 } else {
   10609       13002 :                     System(systemID).TCondenseMin = System(systemID).TCondenseMinInput;
   10610             :                 }
   10611             :             }
   10612             :         }
   10613             :     }
   10614      464456 : }
   10615             : 
   10616       71428 : void InitRefrigerationPlantConnections(EnergyPlusData &state)
   10617             : {
   10618             : 
   10619             :     // SUBROUTINE INFORMATION:
   10620             :     //       AUTHOR         B. Griffith
   10621             :     //       DATE WRITTEN   Dec 2010
   10622             :     //       MODIFIED       na
   10623             :     //       RE-ENGINEERED  na
   10624             : 
   10625             :     // PURPOSE OF THIS SUBROUTINE:
   10626             :     // do inits that should only occur when component model routines
   10627             :     // are entered from plant, for water cooled Condensers and Refrigeration Racks
   10628             : 
   10629             :     static constexpr std::string_view RoutineName = "InitRefrigerationPlantConnections";
   10630             : 
   10631       71428 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10632       71428 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10633             : 
   10634             :     // initialize plant topology information, if applicable
   10635       71428 :     if (state.dataRefrigCase->MyReferPlantScanFlag && allocated(state.dataPlnt->PlantLoop)) {
   10636           4 :         for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10637           2 :             if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10638             : 
   10639           1 :             bool errFlag = false;
   10640           2 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10641           1 :                                                     Condenser(RefCondLoop).Name,
   10642             :                                                     DataPlant::PlantEquipmentType::RefrigSystemWaterCondenser,
   10643           1 :                                                     Condenser(RefCondLoop).plantLoc,
   10644             :                                                     errFlag,
   10645             :                                                     _,
   10646             :                                                     _,
   10647             :                                                     _,
   10648             :                                                     _,
   10649             :                                                     _);
   10650           1 :             if (errFlag) {
   10651           0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10652             :             }
   10653             : 
   10654           1 :             Real64 rho = FluidProperties::GetDensityGlycol(state,
   10655           1 :                                                            state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).FluidName,
   10656             :                                                            20.0,
   10657           1 :                                                            state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).FluidIndex,
   10658             :                                                            RoutineName);
   10659             : 
   10660           1 :             if (Condenser(RefCondLoop).FlowType == CndsrFlowType::ConstantFlow) {
   10661           0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10662           1 :             } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::VariableFlow) {
   10663           1 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10664             :             }
   10665             :         }
   10666             : 
   10667           6 :         for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10668           4 :             if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10669             : 
   10670           1 :             bool errFlag = false;
   10671           2 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10672           1 :                                                     RefrigRack(RefCompRackLoop).Name,
   10673             :                                                     DataPlant::PlantEquipmentType::RefrigerationWaterCoolRack,
   10674           1 :                                                     RefrigRack(RefCompRackLoop).plantLoc,
   10675             :                                                     errFlag,
   10676             :                                                     _,
   10677             :                                                     _,
   10678             :                                                     _,
   10679             :                                                     _,
   10680             :                                                     _);
   10681           1 :             if (errFlag) {
   10682           0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10683             :             }
   10684             : 
   10685           1 :             Real64 rho = FluidProperties::GetDensityGlycol(state,
   10686           1 :                                                            state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).FluidName,
   10687             :                                                            20.0,
   10688           1 :                                                            state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).FluidIndex,
   10689             :                                                            RoutineName);
   10690             : 
   10691           1 :             if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::ConstantFlow) {
   10692           0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10693           1 :             } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::VariableFlow) {
   10694           1 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10695             :             }
   10696             :         }
   10697             : 
   10698           2 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10699       71426 :     } else if (state.dataRefrigCase->MyReferPlantScanFlag && !state.dataGlobal->AnyPlantInModel) {
   10700           0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10701             :     }
   10702             : 
   10703       71428 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag) {
   10704             : 
   10705             :         // do plant inits, if applicable
   10706          12 :         if (!state.dataRefrigCase->MyReferPlantScanFlag) {
   10707          24 :             for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10708          12 :                 if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10709             : 
   10710           6 :                 Real64 rho = FluidProperties::GetDensityGlycol(state,
   10711           6 :                                                                state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).FluidName,
   10712             :                                                                20.0,
   10713           6 :                                                                state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).FluidIndex,
   10714             :                                                                RoutineName);
   10715             : 
   10716           6 :                 if (Condenser(RefCondLoop).FlowType == CndsrFlowType::ConstantFlow) {
   10717           0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10718           6 :                 } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::VariableFlow) {
   10719           6 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10720             :                 }
   10721             : 
   10722          18 :                 PlantUtilities::InitComponentNodes(
   10723           6 :                     state, 0.0, Condenser(RefCondLoop).MassFlowRateMax, Condenser(RefCondLoop).InletNode, Condenser(RefCondLoop).OutletNode);
   10724             :             }
   10725          36 :             for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10726          24 :                 if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) continue;
   10727             : 
   10728           6 :                 Real64 rho = FluidProperties::GetDensityGlycol(state,
   10729           6 :                                                                state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).FluidName,
   10730             :                                                                20.0,
   10731           6 :                                                                state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).FluidIndex,
   10732             :                                                                RoutineName);
   10733             : 
   10734           6 :                 if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::ConstantFlow) {
   10735           0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10736           6 :                 } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::VariableFlow) {
   10737           6 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10738             :                 }
   10739             : 
   10740          18 :                 PlantUtilities::InitComponentNodes(state,
   10741             :                                                    0.0,
   10742           6 :                                                    RefrigRack(RefCompRackLoop).MassFlowRateMax,
   10743           6 :                                                    RefrigRack(RefCompRackLoop).InletNode,
   10744           6 :                                                    RefrigRack(RefCompRackLoop).OutletNode);
   10745             :             }
   10746             :         }
   10747          12 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = false;
   10748             : 
   10749             :     } //(DataGlobals::BeginEnvrnFlag .AND. MyBeginEnvrnFlag)
   10750             : 
   10751       71428 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = true;
   10752       71428 : }
   10753             : 
   10754      171218 : void RefrigRackData::CalcRackSystem(EnergyPlusData &state)
   10755             : {
   10756             : 
   10757             :     // SUBROUTINE INFORMATION:
   10758             :     //       AUTHOR         Richard Raustad, FSEC
   10759             :     //       DATE WRITTEN   Oct/Nov 2004
   10760             :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
   10761             :     //       RE-ENGINEERED  na
   10762             : 
   10763             :     // PURPOSE OF THIS SUBROUTINE:
   10764             :     // Calculate compressor rack load, power, energy consumption, and condenser fan/pump power and consumption
   10765             : 
   10766             :     // METHODOLOGY EMPLOYED:
   10767             :     // Loop through cases attached to each rack and determine total load on compressor rack
   10768             : 
   10769             :     // REFERENCES:
   10770             :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   10771             :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   10772             : 
   10773             :     Real64 COPFTempOutput;          // Curve value for COPFTemp curve object
   10774             :     Real64 CondenserFrac;           // Fraction of condenser power as a function of outdoor temperature
   10775             :     Real64 TotalHeatRejectedToZone; // Total compressor and condenser fan heat rejected to zone (based on CaseRAFactor)
   10776             :     int HeatRejectZoneNum;          // Index to zone where heat is rejected
   10777             :     int HeatRejectZoneNodeNum;      // Index to zone where heat is rejected
   10778             :     Real64 OutWbTemp;               // Outdoor wet bulb temp at condenser air inlet node [C]
   10779             :     Real64 OutDbTemp;               // Outdoor dry bulb temp at condenser air inlet node [C]
   10780             :     Real64 EffectTemp;              // Effective outdoor temp when using evap condenser cooling [C]
   10781             :     Real64 HumRatIn;                // Humidity ratio of inlet air to condenser [kg/kg]
   10782             :     Real64 HumRatOut;               // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   10783             :     Real64 BPress;                  // Barometric pressure at condenser air inlet node [Pa]
   10784             :     bool EvapAvail;                 // Control for evap condenser availability
   10785             : 
   10786      171218 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10787      171218 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10788      171218 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10789      171218 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   10790             : 
   10791      171218 :     state.dataRefrigCase->TotalRackDeliveredCapacity = 0.0;
   10792      171218 :     state.dataRefrigCase->CompressorCOPactual = 0.0;
   10793      171218 :     state.dataRefrigCase->TotalCompressorPower = 0.0;
   10794      171218 :     state.dataRefrigCase->TotalCondenserFanPower = 0.0;
   10795      171218 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   10796      171218 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   10797      171218 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   10798      171218 :     TotalHeatRejectedToZone = 0.0;
   10799      171218 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   10800      171218 :     state.dataRefrigCase->RackSenCreditToZone = 0.0;
   10801      171218 :     state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10802      171218 :     CondenserFrac = 0.0;
   10803      171218 :     EvapAvail = true;
   10804      171218 :     HeatRejectZoneNum = 0;
   10805      171218 :     HeatRejectZoneNodeNum = 0;
   10806             : 
   10807             :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   10808             :     // (all chiller coils within a set are located in the same zone)
   10809             :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   10810             :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   10811             :     // In that subroutine, dispatch coils within each set in order specified for each zone
   10812             :     //  Below will assign loads to refrigeration system or secondary loop
   10813             :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   10814             :     // with interactions will not be known for the intital calls with first HVAC time step. They will,
   10815             :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   10816             :     // that's why important where init goes, don't want to zero out data should keep
   10817      171218 :     if (state.dataRefrigCase->UseSysTimeStep) {
   10818           0 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   10819           0 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   10820             :         }
   10821             :     }
   10822             : 
   10823      171218 :     if (this->NumCoils > 0) {
   10824           0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   10825           0 :             int CoilID = this->CoilNum(CoilIndex);
   10826             :             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   10827             :             // increment TotalCoolingLoad for Compressors/condenser on each system
   10828           0 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WarehouseCoil(CoilID).TotalCoolingLoad;
   10829             :             //      System(SysNum)%TotalCondDefrostCredit=System(SysNum)%TotalCondDefrostCredit + WarehouseCoil(CoilID)%HotDefrostCondCredit
   10830             :         } // NumCoils systems
   10831             :     }     // System(SysNum)%NumCoils > 0
   10832             : 
   10833      171218 :     if (this->NumCases > 0) {
   10834      409806 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   10835      238588 :             int CaseID = this->CaseNum(caseNum);
   10836      238588 :             RefrigCase(CaseID).CalculateCase(state);
   10837             : 
   10838             :             //   add evaporator load for all cases connected to rack
   10839      238588 :             state.dataRefrigCase->TotalRackDeliveredCapacity += RefrigCase(CaseID).TotalCoolingLoad;
   10840             : 
   10841             :             //   sensible and latent case credits already calculated in "CalculateCase"
   10842             :             //   Now need to calculate amount of condenser heat rejection that should be applied to zone
   10843             :             //                                     (used when HeatRejectionLocation = LocationZone)
   10844             :             //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10845             :             //   rejection goes to that zone - that is, no heat rejection goes to the HVAC return air
   10846      238588 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10847       62310 :                 if (this->NumWalkIns == 0) {
   10848       62310 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad * (1.0 - state.dataRefrigCase->CaseRAFactor);
   10849             :                     //  CaseRAFactor is a module variable calculated in CalculateCase
   10850             :                     //   find zone number of first case on rack (all cases are in the same zone
   10851             :                     //  if HeatRejectionLocation = LocationZone and no walk-ins)
   10852       62310 :                     HeatRejectZoneNum = RefrigCase(this->CaseNum(1)).ActualZoneNum;
   10853       62310 :                     HeatRejectZoneNodeNum = RefrigCase(this->CaseNum(1)).ZoneNodeNum;
   10854             :                 } else { // have walk ins so no reduction in condenser heat rejection for caseRA factor
   10855           0 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad;
   10856             :                 } // no walk ins
   10857             :             }
   10858             :         } // NumCases
   10859             :     }     // Numcases on rack > 0
   10860             : 
   10861      171218 :     if (this->NumWalkIns > 0) {
   10862           0 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   10863           0 :             int WalkInID = this->WalkInNum(WalkInIndex);
   10864           0 :             WalkIn(WalkInID).CalculateWalkIn(state);
   10865           0 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WalkIn(WalkInID).TotalCoolingLoad;
   10866           0 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10867           0 :                 TotalHeatRejectedToZone += WalkIn(WalkInID).TotalCoolingLoad;
   10868           0 :                 HeatRejectZoneNum = this->HeatRejectionZoneNum;
   10869           0 :                 HeatRejectZoneNodeNum = this->HeatRejectionZoneNodeNum;
   10870             :             } // reject heat to zone
   10871             :         }     // WalkInIndex
   10872             :     }         // NumWalkIns>0
   10873             : 
   10874      171218 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10875       62310 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp);
   10876       62310 :         EvapAvail = false;
   10877             :     } else {
   10878      108908 :         if (this->OutsideAirNodeNum != 0) {
   10879      106886 :             OutDbTemp = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Temp;
   10880      106886 :             BPress = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Press;
   10881             :         } else {
   10882        2022 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   10883        2022 :             BPress = state.dataEnvrn->OutBaroPress;
   10884             :         }
   10885      108908 :         EffectTemp = OutDbTemp;
   10886             : 
   10887             :         // IF schedule exists, evap condenser can be scheduled OFF
   10888             :         // Check schedule to determine evap condenser availability
   10889      108908 :         if (this->EvapSchedPtr > 0 && ScheduleManager::GetCurrentScheduleValue(state, this->EvapSchedPtr) == 0) EvapAvail = false;
   10890             : 
   10891             :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   10892             :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   10893             :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   10894             :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   10895             :         //  climates.  To accommodate such applications, the variable EvapCutOutTdb is used as an extra
   10896             :         //  check.
   10897      108908 :         if (OutDbTemp < EvapCutOutTdb) EvapAvail = false;
   10898             : 
   10899      108908 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10900             :             // determine temps for evap cooling
   10901        2026 :             if (this->OutsideAirNodeNum != 0) {
   10902        2026 :                 HumRatIn = state.dataLoopNodes->Node(this->OutsideAirNodeNum).HumRat;
   10903             :             } else {
   10904           0 :                 HumRatIn = state.dataEnvrn->OutHumRat;
   10905             :             } // outsideairnode
   10906        2026 :             OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   10907        2026 :             EffectTemp = OutWbTemp + (1.0 - this->EvapEffect) * (OutDbTemp - OutWbTemp);
   10908             :         } // evapAvail
   10909             : 
   10910             :         // Obtain water-cooled condenser inlet/outlet temps
   10911      108908 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   10912        2022 :             this->InletTemp = state.dataLoopNodes->Node(this->InletNode).Temp;
   10913        2022 :             EffectTemp = state.dataLoopNodes->Node(this->InletNode).Temp + 5.0; // includes approach temp
   10914        2022 :             if (this->InletTemp < this->InletTempMin) {
   10915           0 :                 if (this->LowTempWarnIndex == 0) {
   10916           0 :                     ShowWarningMessage(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10917           0 :                     ShowContinueError(state,
   10918             :                                       "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature "
   10919             :                                       "and/or minimum temperature setpoints.");
   10920             :                 } // LowTempWarnIndex
   10921           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10922           0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10923             :                                                    " - Condenser inlet temp lower than minimum allowed ... continues",
   10924           0 :                                                this->LowTempWarnIndex);
   10925             :                 // END IF  !LowTempWarn
   10926             :             } // InletTempMin
   10927             :         }     // DataHeatBalance::RefrigCondenserType::Water
   10928             : 
   10929      108908 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, EffectTemp);
   10930             :     } // Location Zone
   10931             : 
   10932      171218 :     state.dataRefrigCase->CompressorCOPactual = this->RatedCOP * COPFTempOutput;
   10933             : 
   10934      171218 :     if (state.dataRefrigCase->CompressorCOPactual > 0.0) {
   10935      171218 :         state.dataRefrigCase->TotalCompressorPower = state.dataRefrigCase->TotalRackDeliveredCapacity / state.dataRefrigCase->CompressorCOPactual;
   10936      171218 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalCompressorPower + state.dataRefrigCase->TotalRackDeliveredCapacity;
   10937             :     } else {
   10938           0 :         if (this->ShowCOPWarning) {
   10939           0 :             ShowWarningError(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10940           0 :             ShowContinueError(state, " The calculated COP has a value of zero or is negative. Refer to Engineering Documentation for");
   10941           0 :             ShowContinueError(state, " further explanation of Compressor Rack COP as a Function of Temperature Curve.");
   10942           0 :             this->ShowCOPWarning = false;
   10943             :         }
   10944             :     }
   10945             : 
   10946             :     // calculate condenser fan usage here if not water-cooled; if water-cooled, fan is in separate tower object
   10947             :     // fan loads > 0 only if the connected cases are operating
   10948      171218 :     if (state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0 && this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10949      166800 :         if (this->TotCondFTempPtr != 0) {
   10950       83544 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10951             :                 CondenserFrac =
   10952       15356 :                     max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp)));
   10953       15356 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10954       15356 :                 state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += this->CondenserFanPower * CondenserFrac;
   10955             :             } else {
   10956       68188 :                 CondenserFrac = max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, EffectTemp)));
   10957       68188 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10958             :             } // location zone
   10959             :         } else {
   10960       83256 :             CondenserFrac = 1.0;
   10961       83256 :             state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10962             :         } // TotCondFTempPtr
   10963             :     }     // Cooling Water type
   10964             : 
   10965             :     // calculate evap water use and water pump power, if applicable
   10966             :     // assumes pump runs whenever evap cooling is available to minimize scaling
   10967      171218 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10968        2026 :         state.dataRefrigCase->TotalCondenserPumpPower = this->EvapPumpPower;
   10969        2026 :         HumRatOut = Psychrometrics::PsyWFnTdbTwbPb(state, EffectTemp, OutWbTemp, BPress);
   10970        8104 :         state.dataRefrigCase->TotalEvapWaterUseRate = this->CondenserAirFlowRate * CondenserFrac *
   10971        4052 :                                                       Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn) * (HumRatOut - HumRatIn) /
   10972        2026 :                                                       Psychrometrics::RhoH2O(EffectTemp);
   10973             :     } // evapAvail
   10974             :     // calculate basin water heater load
   10975      171218 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   10976        4044 :         if ((state.dataRefrigCase->TotalRackDeliveredCapacity == 0.0) && (EvapAvail) && (OutDbTemp < this->BasinHeaterSetPointTemp)) {
   10977           0 :             state.dataRefrigCase->TotalBasinHeatPower = max(0.0, this->BasinHeaterPowerFTempDiff * (this->BasinHeaterSetPointTemp - OutDbTemp));
   10978             :             // provide warning if no heater power exists
   10979           0 :             if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   10980           0 :                 if (this->EvapFreezeWarnIndex == 0) {
   10981           0 :                     ShowWarningMessage(
   10982             :                         state,
   10983           0 :                         format("Refrigeration Compressor Rack {} - Evap cooling of condenser underway with no basin heater power", this->Name));
   10984           0 :                     ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   10985           0 :                     ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   10986             :                 } // EvapFreezeWarnIndex == 0
   10987           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10988           0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10989             :                                                    " - Evap cooling of condenser underway with no basin heater power ... continues",
   10990           0 :                                                this->EvapFreezeWarnIndex);
   10991             :                 // END IF
   10992             :             } // TotalBasinHeatPower == 0 when at outdoor freezing conditions
   10993             :         }     // cap
   10994             :     }         // evap condenser type
   10995             : 
   10996             :     // add in compressor and condenser fan power to rack heat rejection variables if the heat rejection location is to the zone
   10997             :     //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10998             :     //   rejection goes to that zone - that is, no condenser heat rejection goes to the HVAC return air
   10999      171218 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   11000       62310 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalRackDeliveredCapacity + state.dataRefrigCase->TotalCompressorPower +
   11001       62310 :                                                    state.dataRefrigCase->TotalCondenserFanPower;
   11002       62310 :         if (HeatRejectZoneNum > 0 && state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0) {
   11003       61674 :             if (this->NumWalkIns == 0) {
   11004             :                 //       rack report variables for condenser heat to Zone and/or HVAC
   11005             :                 //       The difference between TotalHeatRejectedToZone and TotalRackDeliveredCapacity is the heat sent to return air
   11006      123348 :                 state.dataRefrigCase->RackSenCreditToZone =
   11007       61674 :                     state.dataRefrigCase->TotalCondenserHeat * (TotalHeatRejectedToZone / state.dataRefrigCase->TotalRackDeliveredCapacity);
   11008       61674 :                 state.dataRefrigCase->RackSenCreditToHVAC = state.dataRefrigCase->TotalCondenserHeat - state.dataRefrigCase->RackSenCreditToZone;
   11009             :             } else { // walkins present and no rack heat rejection goes to return air
   11010           0 :                 state.dataRefrigCase->RackSenCreditToZone = state.dataRefrigCase->TotalCondenserHeat;
   11011           0 :                 state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   11012             :             } // walkins present
   11013             :             //     Update globals for use in Air Heat Balance and Zone Equipment Manager
   11014       61674 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += state.dataRefrigCase->RackSenCreditToZone;
   11015             : 
   11016       61674 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToHVAC += state.dataRefrigCase->RackSenCreditToHVAC;
   11017             :         } // zone # > 0 and tot del cap > 0
   11018             :     }     // rack heat rejection to zone
   11019      171218 : }
   11020             : 
   11021      171218 : void RefrigRackData::ReportRackSystem(EnergyPlusData &state, int const RackNum)
   11022             : {
   11023             : 
   11024             :     // SUBROUTINE INFORMATION:
   11025             :     //       AUTHOR         Richard Raustad, FSEC
   11026             :     //       DATE WRITTEN   Oct/Nov 2004
   11027             :     //       MODIFIED       Hudson, ORNL Feb 2007, July 2007
   11028             :     //       RE-ENGINEERED  na
   11029             : 
   11030             :     // PURPOSE OF THIS SUBROUTINE:
   11031             :     // To report compressor rack variables
   11032             : 
   11033      171218 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   11034      171218 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   11035             : 
   11036      171218 :     this->RackCompressorPower = state.dataRefrigCase->TotalCompressorPower;
   11037      171218 :     this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * LocalTimeStep * Constant::SecInHour;
   11038      171218 :     this->ActualCondenserFanPower = state.dataRefrigCase->TotalCondenserFanPower;
   11039      171218 :     this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * LocalTimeStep * Constant::SecInHour;
   11040      171218 :     this->RackCapacity = state.dataRefrigCase->TotalRackDeliveredCapacity;
   11041      171218 :     this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * LocalTimeStep * Constant::SecInHour;
   11042      171218 :     this->RackCompressorCOP = state.dataRefrigCase->CompressorCOPactual;
   11043      171218 :     this->SensHVACCreditHeatRate = state.dataRefrigCase->RackSenCreditToHVAC;
   11044      171218 :     this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * LocalTimeStep * Constant::SecInHour;
   11045      171218 :     this->SensZoneCreditHeatRate = state.dataRefrigCase->RackSenCreditToZone;
   11046      171218 :     this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * LocalTimeStep * Constant::SecInHour;
   11047      171218 :     this->EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   11048      171218 :     this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * LocalTimeStep * Constant::SecInHour;
   11049      171218 :     this->ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   11050      171218 :     this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * LocalTimeStep * Constant::SecInHour;
   11051      171218 :     this->BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   11052      171218 :     this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * LocalTimeStep * Constant::SecInHour;
   11053      171218 :     this->CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   11054      171218 :     this->CondEnergy = state.dataRefrigCase->TotalCondenserHeat * LocalTimeStep * Constant::SecInHour;
   11055             :     // Set total rack heat rejection used for heat reclaim. Do not allow heat reclaim on stand alone (indoor) display cases.
   11056      171218 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   11057       62310 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity = 0.0;
   11058             :     } else {
   11059      108908 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity =
   11060      108908 :             state.dataRefrigCase->TotalRackDeliveredCapacity * (1.0 + 1.0 / state.dataRefrigCase->CompressorCOPactual);
   11061             :     }
   11062             : 
   11063             :     // set water system demand request (if needed)
   11064      171218 :     if (this->EvapWaterSupplyMode == WaterSupply::FromTank) {
   11065        2022 :         int DemandARRID = this->EvapWaterTankDemandARRID;
   11066        2022 :         int RackTankID = this->EvapWaterSupTankID;
   11067        2022 :         state.dataWaterData->WaterStorage(RackTankID).VdotRequestDemand(DemandARRID) = this->EvapWaterConsumpRate;
   11068             :     }
   11069             : 
   11070      171218 :     SumZoneImpacts(state);
   11071      171218 : }
   11072             : 
   11073      464384 : void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to refrigerated case
   11074             : {
   11075             : 
   11076             :     // SUBROUTINE INFORMATION:
   11077             :     //       AUTHOR         Richard Raustad and Don Shirey, FSEC
   11078             :     //       DATE WRITTEN   Oct/Nov 2004
   11079             :     //       MODIFIED       Therese Stovall, ORNL, May 2008
   11080             :     //       RE-ENGINEERED  na
   11081             : 
   11082             :     // PURPOSE OF THIS SUBROUTINE:
   11083             :     // To model refrigerated cases.
   11084             : 
   11085             :     // METHODOLOGY EMPLOYED:
   11086             :     // Case performance is based on a latent component calculated using a user input curve object. The sensible
   11087             :     // component is made up of all equipment loads (fan, light, anti-sweat) and the sensible case credit
   11088             :     // calculated during initialization. A master schedule is used for the refrigerated case operation and
   11089             :     // additional schedules control the lights and defrost operation.
   11090             :     // The fan is assumed to be off for Hot-Gas and Electric defrost.
   11091             : 
   11092             :     // Unmet loads are accumulated to be met the following time step.  This usually occurs only during the
   11093             :     // defrost period, so the case calls for full capacity at the end of defrost to make up for the sensible
   11094             :     // case gains during the defrost period. This feature is also used if needed for restocking loads.
   11095             : 
   11096             :     // REFERENCES:
   11097             : 
   11098             :     // "Calculation of Humidity Effects on Energy Requirements of Refrigerated Display Cases",
   11099             :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3687 (CH-93-16-4) (RP-596)
   11100             : 
   11101             :     // "Effects of Store Relative Humidity on Refrigerated Display Case Performance",
   11102             :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3686 (CH-93-16-1) (RP-596)
   11103             : 
   11104             :     // "Analysis of Supermarket Dehumidification Alternatives",
   11105             :     //  Electric Power Research Institute, EPRI TR-100352, Project 2891-03 Final Report, Nov. 1992.
   11106             : 
   11107             :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   11108             :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   11109             : 
   11110      464384 :     Real64 CaseCreditFraction(0.0);      // Reduction in case credits due to e.g., reduced door openings at night
   11111      464384 :     Real64 DefrostSchedule(0.0);         // Display case defrost schedule
   11112      464384 :     Real64 DefrostDripDownSchedule(0.0); // Display case drip-down schedule (allows coil to drain after defrost)
   11113      464384 :     Real64 DefrostRatio(0.0);            // ratio of defrost energy at current zone temp/humrat to defrost
   11114             :     //    capacity at design condition
   11115      464384 :     Real64 LatentRatio(0.0); // ratio of latent capacity at current zone temp/humrat to
   11116             :     //    latent capacity at design condition
   11117      464384 :     Real64 LatentCap_Actual(0.0);   // Refrigerated case latent capacity at specific operating conditions
   11118      464384 :     Real64 LatentCaseCredit(0.0);   // Latent case credit delivered to zone (W)
   11119      464384 :     Real64 SensibleCap_Actual(0.0); // Refrigerated case sensible capacity at specific operating conditions
   11120      464384 :     Real64 SensibleLoadPrime(0.0);  // Sensible load due to cond, conv, rad, infil (W)
   11121      464384 :     Real64 TotalCap_Actual(0.0);    // Refrigerated case total capacity at specific operating conditions
   11122      464384 :     Real64 TotalLightingLoad(0.0);  // Total lighting energy rate (W)
   11123      464384 :     Real64 TotalFan(0.0);           // Total fan energy rate (W)
   11124      464384 :     Real64 TotalAntiSweat(0.0);     // Total anti-sweat heater energy rate (W)
   11125             : 
   11126             :     // Refrigerated display case defrost type (parameters)
   11127             :     // DefNone             = 0
   11128             :     // DefOffCycle         = 1
   11129             :     // DefHotFluid           = 2
   11130             :     // DefHotFluidOnDemand   = 3 (not available)
   11131             :     // DefHotFluidTerm       = 4
   11132             :     // DefElectric         = 5
   11133             :     // DefElectricOnDemand = 6 (not available)
   11134             :     // DefElectricTerm     = 7
   11135             : 
   11136      464384 :     state.dataRefrigCase->CaseRAFactor = 0.0;
   11137             : 
   11138             :     // Zone relative humidity (%)
   11139      464384 :     Real64 ZoneRHPercent = Psychrometrics::PsyRhFnTdbWPb(state,
   11140      464384 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).Temp,
   11141      464384 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat,
   11142      464384 :                                                          state.dataEnvrn->OutBaroPress) *
   11143      464384 :                            100.0;
   11144             : 
   11145             :     // Zone dew point (C)
   11146      464384 :     Real64 ZoneDewPoint = Psychrometrics::PsyTdpFnWPb(state, state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat, state.dataEnvrn->OutBaroPress);
   11147             : 
   11148             :     // Display case operating temperature
   11149      464384 :     Real64 TCase = this->Temperature;
   11150             : 
   11151             :     // GET ALL SCHEDULES (note all schedules can be fractions if on/off a portion of time step)
   11152             :     // case schedule should be coincident with the zone time step otherwise the simulation proceeds
   11153             : 
   11154             :     // Current value of case operating (availability) schedule
   11155      464384 :     Real64 CaseSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr);
   11156      464384 :     if (CaseSchedule <= 0) return;
   11157             :     // get defrost schedule
   11158      464384 :     if (this->defrostType > RefCaseDefrostType::None) {
   11159      369674 :         DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr);
   11160      369674 :         DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostDripDownSchedPtr);
   11161             :         // next statement In case user doesn't understand concept of drip down schedule
   11162      369674 :         DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   11163             :     } else {
   11164       94710 :         DefrostSchedule = 0.0;
   11165       94710 :         DefrostDripDownSchedule = 0.0;
   11166             :     }
   11167             : 
   11168      464384 :     Real64 StockingSchedule(0.0); // Current value of product stocking schedule (W/m)
   11169             : 
   11170             :     // get product stocking schedule and load due to product stocking, if no schedule exists load is 0
   11171      464384 :     if (this->StockingSchedPtr > 0) {
   11172      464384 :         StockingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->StockingSchedPtr);
   11173             :     } else {
   11174           0 :         StockingSchedule = 0.0;
   11175             :     }
   11176             :     // get lighting schedule and total load due to lighting
   11177      464384 :     Real64 LightingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->LightingSchedPtr);
   11178             : 
   11179             :     // if case credit reduction fraction schedule exists, modify both sensible and latent case credits
   11180             :     // according to schedule - used to account for variable case envelope, such as night covers.
   11181      464384 :     if (this->CaseCreditFracSchedPtr != 0) {
   11182      299584 :         CaseCreditFraction = ScheduleManager::GetCurrentScheduleValue(state, this->CaseCreditFracSchedPtr);
   11183             :     } else {
   11184      164800 :         CaseCreditFraction = 1.0;
   11185             :     }
   11186             : 
   11187             :     // CALCULATE AUX LOADS DUE TO LIGHTS, FAN AND STOCKING
   11188      464384 :     TotalLightingLoad = this->DesignLighting * LightingSchedule;
   11189             : 
   11190             :     // Lighting energy to case
   11191      464384 :     Real64 TotalLightToCase = TotalLightingLoad * this->LightingFractionToCase;
   11192             : 
   11193             :     // Lighting energy to zone
   11194      464384 :     Real64 TotalLightToZone = TotalLightingLoad - TotalLightToCase;
   11195             :     // cycle fan according to defrost schedule
   11196             :     // turn fan on for none or off-cycle defrost types
   11197      464384 :     if (this->defrostType == RefCaseDefrostType::None || this->defrostType == RefCaseDefrostType::OffCycle) {
   11198      227480 :         TotalFan = this->DesignFanPower;
   11199             :     } else {
   11200      236904 :         TotalFan = this->DesignFanPower * (1.0 - DefrostDripDownSchedule);
   11201             :     }
   11202             :     // get  load due to product stocking
   11203             :     // accumulate stocking loads for reporting to help evaluate any cumulative unmet loads problems
   11204             :     // only accumulate energy during actual simulation (so same if DD's are switched)
   11205             : 
   11206             :     // Total load due to stocking case product (W)
   11207      464384 :     Real64 StockingLoad = StockingSchedule * this->Length;
   11208      464384 :     if (!state.dataGlobal->WarmupFlag) {
   11209       63840 :         Real64 DeltaStockingEnergy = (StockingLoad * state.dataGlobal->TimeStepZoneSec);
   11210       63840 :         this->StockingEnergy += DeltaStockingEnergy;
   11211             :     } // warm up
   11212             :     // CALCULTE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   11213             :     // Anti-sweat heater capacity
   11214      464384 :     switch (this->AntiSweatControlType) {
   11215      302642 :     case ASHtrCtrlType::None: {
   11216      302642 :         TotalAntiSweat = 0.0;
   11217      302642 :     } break;
   11218           0 :     case ASHtrCtrlType::Constant: {
   11219           0 :         TotalAntiSweat = this->AntiSweatPower;
   11220           0 :     } break;
   11221       78172 :     case ASHtrCtrlType::Linear: {
   11222       78172 :         TotalAntiSweat =
   11223       78172 :             this->AntiSweatPower * min(1.0, max(0.0, 1.0 - (this->RatedAmbientRH - ZoneRHPercent) / (this->RatedAmbientRH - this->HumAtZeroAS)));
   11224       78172 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   11225       78172 :     } break;
   11226           0 :     case ASHtrCtrlType::DewPoint: {
   11227           0 :         TotalAntiSweat = this->AntiSweatPower * min(1.0, max(0.0, (ZoneDewPoint - TCase) / (this->RatedAmbientDewPoint - TCase)));
   11228           0 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   11229           0 :     } break;
   11230       83570 :     case ASHtrCtrlType::HeatBalance: {
   11231       83570 :         if (this->Rcase > 0.0) {
   11232       83570 :             TotalAntiSweat = (((ZoneDewPoint - state.dataLoopNodes->Node(this->ZoneNodeNum).Temp) * this->Height / Rair) +
   11233       83570 :                               ((ZoneDewPoint - TCase) * this->Height / this->Rcase));
   11234       83570 :             TotalAntiSweat = min(this->AntiSweatPower, max(this->MinimumASPower, TotalAntiSweat));
   11235             :         } else {
   11236           0 :             TotalAntiSweat = 0.0;
   11237             :         }
   11238       83570 :     } break;
   11239           0 :     default: {
   11240             :         // should never execute this CASE statement
   11241           0 :         TotalAntiSweat = 0.0;
   11242           0 :     } break;
   11243             :     }
   11244      464384 :     TotalAntiSweat *= this->Length;
   11245             : 
   11246             :     // Anti-sweat heater energy to case
   11247      464384 :     Real64 TotalASHeaterToCase = this->ASHeaterFractionToCase * TotalAntiSweat;
   11248             : 
   11249             :     // Anti-sweat heater energy to zone
   11250      464384 :     Real64 TotalASHeaterToZone = TotalAntiSweat - TotalASHeaterToCase;
   11251             : 
   11252             :     // latent capacity correction term at off-design conditions
   11253      464384 :     switch (this->LatentEnergyCurveType) {
   11254      376088 :     case EnergyEqnForm::CaseTemperatureMethod: {
   11255      376088 :         Real64 LatCapModFrac = Curve::CurveValue(state, this->LatCapCurvePtr, TCase);
   11256      376088 :         LatentRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * LatCapModFrac));
   11257      376088 :     } break;
   11258       36392 :     case EnergyEqnForm::RHCubic: {
   11259       36392 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneRHPercent));
   11260       36392 :     } break;
   11261       51904 :     case EnergyEqnForm::DPCubic: {
   11262       51904 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneDewPoint));
   11263       51904 :     } break;
   11264           0 :     default:
   11265           0 :         break;
   11266             :     }
   11267             : 
   11268             :     // calculate latent case load (assumes no moisture load due to stocking)
   11269             :     // assume sensible case credits continue to accumulate in case during defrost/dripdown,
   11270             :     //    but latent credits/load and capacity only applied outside dripdownschedule
   11271             : 
   11272             :     // Latent load placed on case at actual zone conditions (W)
   11273      464384 :     Real64 LatentLoad = this->DesignLatentCap * LatentRatio * CaseCreditFraction * (1.0 - DefrostDripDownSchedule);
   11274      464384 :     LatentCaseCredit = -LatentLoad;
   11275             :     // adjust sensible loads and case credit for actual zone temperature
   11276             :     // If zone temp rises above rated ambient temperature, total load can exceed case design capacity,
   11277             :     // so unmet cooling loads are accumulated to meet in the next time step. (Case credit fraction allows
   11278             :     //  extra insulation, e.g. night covers, or imitating a better insulated walk-in cooler)
   11279             : 
   11280             :     // used to look at extra sensible load due to excursions in zone T
   11281      464384 :     Real64 ZoneTempFactor = (state.dataLoopNodes->Node(ZoneNodeNum).Temp - TCase) / (this->RatedAmbientTemp - TCase);
   11282      464384 :     SensibleLoadPrime = this->DesignSensCaseCredit * ZoneTempFactor * CaseCreditFraction;
   11283             : 
   11284             :     // Sensible load due to heaters, lighting (W)
   11285      464384 :     Real64 SensibleLoadAux = TotalLightToCase + TotalASHeaterToCase + TotalFan + StockingLoad;
   11286             : 
   11287             :     // Total sensible load on case, may not = capacity applied (W)
   11288      464384 :     Real64 SensibleLoadTotal = SensibleLoadPrime + SensibleLoadAux;
   11289             :     // include lighting and anti-sweat power not attributed to case load to sensible case credit
   11290             : 
   11291             :     // Sensible case credit delivered to zone (W)
   11292      464384 :     Real64 SensibleCaseCredit = TotalLightToZone + TotalASHeaterToZone - SensibleLoadPrime;
   11293             : 
   11294             :     // FROST:  keep track of frost build up on evaporator coil
   11295             :     // avoid accumulation during warm-up to avoid reverse dd test problem
   11296      464384 :     if (!state.dataGlobal->WarmupFlag) {
   11297       63840 :         Real64 DeltaFreezeKgFrost = LatentLoad * state.dataGlobal->TimeStepZoneSec / IcetoVaporEnthalpy;
   11298       63840 :         this->KgFrost += DeltaFreezeKgFrost;
   11299             :     }
   11300             : 
   11301      464384 :     if (TCase > TempTooHotToFrost) this->KgFrost = 0.0;
   11302             : 
   11303      464384 :     Real64 DefrostLoad_Actual(0.0); // heat load on case due to defrost (W)
   11304      464384 :     Real64 DefrostCap_Actual(0.0);  // power used to defrost (W)
   11305             : 
   11306             :     // DEFROST CALCULATIONS
   11307      464384 :     if (DefrostSchedule > 0.0) {
   11308        9661 :         if (this->defrostType != RefCaseDefrostType::None && this->defrostType != RefCaseDefrostType::OffCycle) {
   11309        7309 :             DefrostCap_Actual = this->DesignDefrostCap * DefrostSchedule;
   11310        7309 :             if (this->defrostType == RefCaseDefrostType::ElectricTerm || this->defrostType == RefCaseDefrostType::HotFluidTerm) {
   11311             :                 // calculate correction term for temperature termination defrost control
   11312        3248 :                 switch (this->DefrostEnergyCurveType) {
   11313        3248 :                 case EnergyEqnForm::CaseTemperatureMethod: {
   11314        3248 :                     Real64 DefCapModFrac = Curve::CurveValue(state, this->DefCapCurvePtr, TCase);
   11315        3248 :                     DefrostRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * DefCapModFrac));
   11316        3248 :                 } break;
   11317           0 :                 case EnergyEqnForm::RHCubic: {
   11318           0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneRHPercent));
   11319           0 :                 } break;
   11320           0 :                 case EnergyEqnForm::DPCubic: {
   11321           0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneDewPoint));
   11322           0 :                 } break;
   11323           0 :                 case EnergyEqnForm::None: {
   11324           0 :                     DefrostRatio = 1.0;
   11325           0 :                 } break;
   11326           0 :                 default:
   11327           0 :                     break;
   11328             :                 }
   11329        3248 :                 DefrostCap_Actual *= DefrostRatio;
   11330             :             }
   11331             : 
   11332             :             // frost load at start of time step (kg of ice)
   11333        7309 :             Real64 StartFrostKg = this->KgFrost;
   11334             : 
   11335             :             // Energy form of defrost capacity (J)
   11336        7309 :             Real64 defrostEnergy = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11337             : 
   11338             :             // Frost melted by defrost during a time step (kg)
   11339        7309 :             Real64 FrostMeltedKg = min(defrostEnergy / IceMeltEnthalpy, StartFrostKg);
   11340        7309 :             this->KgFrost -= FrostMeltedKg;
   11341             : 
   11342             :             // Reduce defrost heat load on case by amount of ice melted during time step
   11343             :             // However, don't reduce the defrost capacity applied
   11344             : 
   11345        7309 :             DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour;
   11346             : 
   11347        7309 :             if (!state.dataGlobal->WarmupFlag) { // avoid reverse dd test problems
   11348             :                 // keep running total of defrost energy above that needed to melt frost for use in evaluating
   11349             :                 //      problems of excessive unmet loads
   11350        1008 :                 this->DeltaDefrostEnergy = max(0.0, (defrostEnergy - (FrostMeltedKg * IceMeltEnthalpy)));
   11351        1008 :                 this->DefrostEnergy += this->DeltaDefrostEnergy;
   11352             :             }
   11353             :             // If hot brine or hot gas is used for defrost, need to reduce condenser load
   11354             :             // Note this condenser credit is not applied in compressor-rack systems.
   11355        7309 :             if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11356        4256 :                 this->defrostType != RefCaseDefrostType::ElectricTerm)
   11357        3248 :                 this->HotDefrostCondCredit = DefrostCap_Actual * DefrostSchedule;
   11358        7309 :         } else { // no defrost or off-cycle defrost
   11359        2352 :             DefrostCap_Actual = 0.0;
   11360        2352 :             DefrostLoad_Actual = 0.0;
   11361        2352 :             this->KgFrost = 0.0;
   11362             :             // Off-Cycle defrost is assumed to melt all the ice
   11363             :         } // defrost type
   11364             : 
   11365             :     } else { // DefrostSchedule = 0, so no defrost load or capacity
   11366      454723 :         DefrostLoad_Actual = 0.0;
   11367      454723 :         DefrostCap_Actual = 0.0;
   11368             :     } // Defrost calculations
   11369             : 
   11370             :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   11371             :     // total load on case at zone conditions (W)
   11372      464384 :     Real64 TotalLoad_Actual = SensibleLoadTotal + LatentLoad + DefrostLoad_Actual;
   11373             : 
   11374             :     // Rate needed to serve all stored energy during single time step (W)
   11375      464384 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour;
   11376      464384 :     Real64 LoadRequested = TotalLoad_Actual + StoredEnergyRate;
   11377             : 
   11378             :     // prorate available cooling capacity for portion of time off due to drip down.
   11379      464384 :     Real64 CapAvail = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule);
   11380      464384 :     if (CapAvail >= LoadRequested) {
   11381             :         // Have more at least as much capacity available as needed, even counting stored energy
   11382      442557 :         TotalCap_Actual = LoadRequested;
   11383      442557 :         SensibleCap_Actual = SensibleLoadTotal + StoredEnergyRate;
   11384      442557 :         LatentCap_Actual = LatentLoad;
   11385      442557 :         this->StoredEnergy = 0.0;
   11386             :     } else {
   11387             :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   11388       21827 :         TotalCap_Actual = CapAvail;
   11389       21827 :         LatentCap_Actual = min(LatentLoad, CapAvail); // Latent load should never be > capavail, but just in case...
   11390       21827 :         SensibleCap_Actual = TotalCap_Actual - LatentCap_Actual;
   11391       21827 :         if (!state.dataGlobal->WarmupFlag) this->StoredEnergy += (TotalLoad_Actual - CapAvail) * state.dataGlobal->TimeStepZoneSec;
   11392             :     } // CapAvail vs Load requested
   11393             : 
   11394             :     // Reset DefrostLoad_Actual to zero for non-electric defrost types, for reporting purposes
   11395      464384 :     if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11396      381140 :         this->defrostType != RefCaseDefrostType::ElectricTerm)
   11397      344748 :         DefrostCap_Actual = 0.0;
   11398             : 
   11399      464384 :     Real64 caseRAFraction = min(0.8, this->RAFrac);
   11400      464384 :     state.dataRefrigCase->CaseRAFactor = (1.0 - ((0.8 - caseRAFraction) / 0.8)) * 0.5;
   11401             : 
   11402             :     // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   11403             :     //   Zone Equipment Manager. Sum case credits to zone and case credits to HVAC
   11404             : 
   11405             :     //** this needs a moisture variable NonAirSystemMoistureResponse (equivalent of NonAirSystemResponse) to properly
   11406             :     //** allocate moisture to the zone when the HVAC system is off.
   11407             : 
   11408             :     // Amount of sensible case credit applied to zone load (W)
   11409      464384 :     Real64 CaseSenCreditToZone = SensibleCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11410             : 
   11411             :     // Amount of latent case credit applied to zone load (W)
   11412      464384 :     Real64 CaseLatCreditToZone = LatentCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11413             : 
   11414             :     // Amount of sensible case credit applied to HVAC RA duct (W)
   11415      464384 :     Real64 CaseSenCreditToHVAC = SensibleCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11416             : 
   11417             :     // Amount of latent case credit applied to HVAC RA duct (W)
   11418      464384 :     Real64 CaseLatCreditToHVAC = LatentCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11419             : 
   11420      464384 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToZone += CaseSenCreditToZone;
   11421      464384 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToZone += CaseLatCreditToZone;
   11422      464384 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToHVAC += CaseSenCreditToHVAC;
   11423      464384 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToHVAC += CaseLatCreditToHVAC;
   11424             : 
   11425             :     // ReportRefrigeratedCase(CaseID)
   11426      464384 :     this->TotalCoolingLoad = TotalCap_Actual;
   11427      464384 :     this->TotalCoolingEnergy = TotalCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11428      464384 :     this->SensCoolingEnergyRate = SensibleCap_Actual;
   11429      464384 :     this->SensCoolingEnergy = SensibleCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11430      464384 :     this->LatCoolingEnergyRate = LatentCap_Actual;
   11431      464384 :     this->LatCoolingEnergy = LatentCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11432             : 
   11433      464384 :     this->SensZoneCreditRate = CaseSenCreditToZone; // both positive or negative
   11434             :     // This rate can be positive or negative, split into separate output variables and always report positive value
   11435      464384 :     if (CaseSenCreditToZone <= 0.0) {
   11436      429345 :         this->SensZoneCreditCoolRate = -CaseSenCreditToZone;
   11437      429345 :         this->SensZoneCreditCool = -CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11438      429345 :         this->SensZoneCreditHeatRate = 0.0;
   11439      429345 :         this->SensZoneCreditHeat = 0.0;
   11440             :     } else {
   11441       35039 :         this->SensZoneCreditHeatRate = CaseSenCreditToZone;
   11442       35039 :         this->SensZoneCreditHeat = CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11443       35039 :         this->SensZoneCreditCoolRate = 0.0;
   11444       35039 :         this->SensZoneCreditCool = 0.0;
   11445             :     }
   11446             : 
   11447             :     // This rate should always be negative
   11448      464384 :     this->LatZoneCreditRate = CaseLatCreditToZone;
   11449      464384 :     this->LatZoneCredit = CaseLatCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11450             : 
   11451      464384 :     this->SensHVACCreditRate = CaseSenCreditToHVAC;
   11452             :     // This rate can be positive or negative, split into separate output variables and always report positive value
   11453      464384 :     if (CaseSenCreditToHVAC <= 0.0) {
   11454      431346 :         this->SensHVACCreditCoolRate = -CaseSenCreditToHVAC;
   11455      431346 :         this->SensHVACCreditCool = -CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11456      431346 :         this->SensHVACCreditHeatRate = 0.0;
   11457      431346 :         this->SensHVACCreditHeat = 0.0;
   11458             :     } else {
   11459       33038 :         this->SensHVACCreditHeatRate = CaseSenCreditToHVAC;
   11460       33038 :         this->SensHVACCreditHeat = CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11461       33038 :         this->SensHVACCreditCoolRate = 0.0;
   11462       33038 :         this->SensHVACCreditCool = 0.0;
   11463             :     }
   11464             : 
   11465             :     // This rate should always be negative
   11466      464384 :     this->LatHVACCreditRate = CaseLatCreditToHVAC;
   11467      464384 :     this->LatHVACCredit = CaseLatCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11468             : 
   11469      464384 :     this->ElecFanPower = TotalFan;
   11470      464384 :     this->ElecFanConsumption = TotalFan * state.dataGlobal->TimeStepZoneSec;
   11471      464384 :     this->ElecAntiSweatPower = TotalAntiSweat;
   11472      464384 :     this->ElecAntiSweatConsumption = TotalAntiSweat * state.dataGlobal->TimeStepZoneSec;
   11473      464384 :     this->ElecLightingPower = TotalLightingLoad;
   11474      464384 :     this->ElecLightingConsumption = TotalLightingLoad * state.dataGlobal->TimeStepZoneSec;
   11475      464384 :     this->ElecDefrostPower = DefrostCap_Actual;
   11476      464384 :     this->ElecDefrostConsumption = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11477             : 
   11478      464384 :     this->DefEnergyCurveValue = DefrostRatio;
   11479      464384 :     this->LatEnergyCurveValue = LatentRatio;
   11480             : 
   11481             :     //**************************************************************************************************
   11482             :     // Cap Energy and Kg Frost to avoid floating overflow errors
   11483             :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   11484             : 
   11485             :     // Collect extra sensible load above design for possible warning if that is determining factor in
   11486             :     // excessively large stored energy
   11487      464384 :     if ((ZoneTempFactor * CaseCreditFraction) > 1.0) {
   11488      111143 :         if (!state.dataGlobal->WarmupFlag) {
   11489       14973 :             Real64 DeltaWarmEnvEnergy = (SensibleLoadPrime - this->DesignSensCaseCredit) * state.dataGlobal->TimeStepZoneSec;
   11490       14973 :             this->WarmEnvEnergy += DeltaWarmEnvEnergy;
   11491             :         }
   11492             :     }
   11493             : 
   11494      464384 :     if (this->DefrostEnergy > MyLargeNumber) this->DefrostEnergy = MyLargeNumber;
   11495      464384 :     if (this->WarmEnvEnergy > MyLargeNumber) this->WarmEnvEnergy = MyLargeNumber;
   11496      464384 :     if (this->StockingEnergy > MyLargeNumber) this->StockingEnergy = MyLargeNumber;
   11497      464384 :     if (this->StoredEnergy > MyLargeNumber) {
   11498           0 :         this->StoredEnergy = MyLargeNumber;
   11499           0 :         if (this->ShowStoreEnergyWarning) {
   11500           0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   11501           0 :             if (this->StockingEnergy >= this->DefrostEnergy) {
   11502           0 :                 if (this->StockingEnergy >= this->WarmEnvEnergy) {
   11503           0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with stocking.");
   11504           0 :                     ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   11505           0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11506             :                 } else {
   11507           0 :                     ShowContinueError(state,
   11508             :                                       " This case has insufficient capacity to meet excess energy associated with a zone enviroment temperature "
   11509             :                                       "greater than the design ambient for the case.");
   11510           0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   11511           0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11512             :                 } // Stocking energy > warm environment energy
   11513             :             } else {
   11514           0 :                 if (this->DefrostEnergy >= this->WarmEnvEnergy) {
   11515           0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with defrost.");
   11516           0 :                     ShowContinueError(state, " Refer to documentation for further explanation of defrost control requirements and");
   11517           0 :                     ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Defrost Capacity.");
   11518             :                 } else {
   11519           0 :                     ShowContinueError(state,
   11520             :                                       " This case has insufficient capacity to meet excess energy associated with a zone enviroment temperature "
   11521             :                                       "greater than the design ambient for the case.");
   11522           0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   11523           0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11524             :                 }                                 // defrost energy > warm environment energy
   11525             :             }                                     // stock > defrost ELSE
   11526           0 :             this->ShowStoreEnergyWarning = false; // only give this warning once for any one case
   11527             :         }                                         // showstoreenergy warning true
   11528             :     }                                             // stored energy > large number
   11529             : 
   11530      464384 :     if (this->KgFrost > MyLargeNumber) {
   11531           0 :         this->KgFrost = MyLargeNumber;
   11532           0 :         if (this->ShowFrostWarning) {
   11533           0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   11534           0 :             ShowContinueError(state, " This case has insufficient defrost capacity to remove the excess frost accumulation.");
   11535           0 :             ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   11536           0 :             ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Latent Heat Ratio.");
   11537           0 :             this->ShowFrostWarning = false;
   11538             :         }
   11539             :     }
   11540             : }
   11541             : 
   11542           1 : PlantComponent *RefrigCondenserData::factory(EnergyPlusData &state, std::string const &objectName)
   11543             : {
   11544             :     // Process the input data for boilers if it hasn't been done already
   11545           1 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   11546           0 :         CheckRefrigerationInput(state);
   11547           0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   11548             :     }
   11549             :     // Now look for this particular object in list
   11550           2 :     for (auto &obj : state.dataRefrigCase->Condenser) {
   11551           2 :         if (obj.Name == objectName) {
   11552           1 :             return &obj;
   11553             :         }
   11554             :     }
   11555             :     // If we didn't find it, fatal
   11556             :     ShowFatalError(state, format("LocalRefrigCondenserFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   11557             :     // Shut up the compiler
   11558             :     return nullptr; // LCOV_EXCL_LINE
   11559             : }
   11560             : 
   11561           5 : void RefrigCondenserData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11562             : {
   11563           5 :     InitRefrigeration(state);
   11564           5 :     InitRefrigerationPlantConnections(state);
   11565           5 : }
   11566             : 
   11567       35133 : void RefrigCondenserData::simulate(EnergyPlusData &state,
   11568             :                                    [[maybe_unused]] const PlantLocation &calledFromLocation,
   11569             :                                    bool const FirstHVACIteration,
   11570             :                                    [[maybe_unused]] Real64 &CurLoad,
   11571             :                                    [[maybe_unused]] bool const RunFlag)
   11572             : {
   11573             : 
   11574             :     // SUBROUTINE INFORMATION:
   11575             :     //       AUTHOR         Randy Hudson, ORNL
   11576             :     //       DATE WRITTEN   July 2007
   11577             :     //       MODIFIED       Therese Stovall, ORNL May 2008
   11578             :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   11579             :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   11580             :     //       RE-ENGINEERED  na
   11581             : 
   11582             :     // PURPOSE OF THIS SUBROUTINE:
   11583             :     // Simulates the water-cooled refrigeration condenser object.
   11584             :     // Modified to add condensers for detailed refrigeration systems and to
   11585             :     // avoid double-counting heat rejection that has been used in desuperheater
   11586             :     // hvac coils or water heaters.
   11587             : 
   11588             :     // METHODOLOGY EMPLOYED:
   11589             :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   11590             :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   11591             : 
   11592             :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   11593       35133 :     int PlantInletNode(0);
   11594       35133 :     int PlantOutletNode(0);
   11595       35133 :     PlantLocation PlantLoc{};
   11596             : 
   11597       35133 :     InitRefrigerationPlantConnections(state);
   11598             : 
   11599       35133 :     std::string TypeName;
   11600       35133 :     std::string ErrIntro;
   11601             : 
   11602             :     // set variables depending upon system type
   11603       35133 :     PlantInletNode = this->InletNode;
   11604       35133 :     PlantOutletNode = this->OutletNode;
   11605       35133 :     PlantLoc = this->plantLoc;
   11606             : 
   11607       35133 :     state.dataRefrigCase->TotalCondenserHeat = this->CondLoad;
   11608       35133 :     TypeName = "Refrigeration:Condenser:WaterCooled";
   11609       35133 :     ErrIntro = "Condenser for refrigeration system ";
   11610             : 
   11611             :     // Current condenser is water cooled
   11612             :     // Make demand request on first HVAC iteration
   11613             : 
   11614             :     // get cooling fluid properties
   11615       35133 :     Real64 rho = FluidProperties::GetDensityGlycol(state,
   11616       35133 :                                                    state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidName,
   11617             :                                                    this->InletTemp,
   11618       35133 :                                                    state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidIndex,
   11619             :                                                    RoutineName);
   11620       35133 :     Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
   11621       35133 :                                                        state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidName,
   11622             :                                                        this->InletTemp,
   11623       35133 :                                                        state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidIndex,
   11624             :                                                        RoutineName);
   11625             : 
   11626       35133 :     if (this->FlowType == CndsrFlowType::VariableFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11627             : 
   11628       34752 :         this->OutletTemp = ScheduleManager::GetCurrentScheduleValue(state, this->OutletTempSchedPtr);
   11629             : 
   11630       34752 :         if (this->OutletTemp == this->InletTemp) {
   11631             : 
   11632           0 :             if (this->HighInletWarnIndex == 0) {
   11633           0 :                 ShowSevereError(
   11634             :                     state,
   11635           0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11636           0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11637             :             }
   11638           0 :             ShowRecurringWarningErrorAtEnd(state,
   11639           0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11640           0 :                                            this->HighInletWarnIndex);
   11641           0 :             this->VolFlowRate = 9999.0;
   11642           0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11643             :         } else {
   11644       34752 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11645       34752 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11646             :             // Check for maximum flow in the component
   11647       34752 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11648           0 :                 if (this->HighFlowWarnIndex == 0) {
   11649           0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11650           0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11651           0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11652             :                 } // HighFlowWarnIndex
   11653           0 :                 ShowRecurringWarningErrorAtEnd(
   11654           0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11655             :                 // END IF
   11656           0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11657             :             }
   11658             :         } // compare outlet T to inlet T
   11659             : 
   11660         381 :     } else if (this->FlowType == CndsrFlowType::ConstantFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11661             :         // this part for constant flow condition
   11662           0 :         this->VolFlowRate = this->DesVolFlowRate;
   11663           0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11664             : 
   11665         381 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11666         381 :         this->MassFlowRate = 0.0;
   11667             : 
   11668             :     } // on flow type
   11669             :     // check against plant, might get changed.
   11670       35133 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11671             : 
   11672       35133 :     this->VolFlowRate = this->MassFlowRate / rho;
   11673             : 
   11674       35133 :     if (this->MassFlowRate > 0) {
   11675       32550 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11676             :     } else {
   11677        2583 :         this->OutletTemp = this->InletTemp;
   11678        2583 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11679             : 
   11680          48 :             ShowRecurringWarningErrorAtEnd(
   11681             :                 state,
   11682          32 :                 TypeName + this->Name +
   11683             :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11684          16 :                 this->NoFlowWarnIndex);
   11685             :         }
   11686             :     }
   11687             :     // Check outlet water temp for max value
   11688       35133 :     if (this->OutletTemp > this->OutletTempMax) {
   11689           0 :         if (this->HighTempWarnIndex == 0) {
   11690           0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11691           0 :             ShowContinueError(state,
   11692             :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11693             :         }
   11694           0 :         ShowRecurringWarningErrorAtEnd(
   11695           0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", this->HighTempWarnIndex);
   11696             :     }
   11697             : 
   11698       35133 :     this->UpdateCondenserOutletNode(state);
   11699       35133 : }
   11700             : 
   11701           1 : PlantComponent *RefrigRackData::factory(EnergyPlusData &state, std::string const &objectName)
   11702             : {
   11703             :     // Process the input data for boilers if it hasn't been done already
   11704           1 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   11705           0 :         CheckRefrigerationInput(state);
   11706           0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   11707             :     }
   11708             :     // Now look for this particular object in list
   11709           2 :     for (auto &obj : state.dataRefrigCase->RefrigRack) {
   11710           2 :         if (obj.Name == objectName) {
   11711           1 :             return &obj;
   11712             :         }
   11713             :     }
   11714             :     // If we didn't find it, fatal
   11715             :     ShowFatalError(state, format("LocalRefrigRackFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   11716             :     // Shut up the compiler
   11717             :     return nullptr; // LCOV_EXCL_LINE
   11718             : }
   11719             : 
   11720           5 : void RefrigRackData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11721             : {
   11722           5 :     InitRefrigeration(state);
   11723           5 :     InitRefrigerationPlantConnections(state);
   11724           5 : }
   11725             : 
   11726       36285 : void RefrigRackData::simulate(EnergyPlusData &state,
   11727             :                               [[maybe_unused]] const PlantLocation &calledFromLocation,
   11728             :                               bool const FirstHVACIteration,
   11729             :                               [[maybe_unused]] Real64 &CurLoad,
   11730             :                               [[maybe_unused]] bool const RunFlag)
   11731             : {
   11732             : 
   11733             :     // SUBROUTINE INFORMATION:
   11734             :     //       AUTHOR         Randy Hudson, ORNL
   11735             :     //       DATE WRITTEN   July 2007
   11736             :     //       MODIFIED       Therese Stovall, ORNL May 2008
   11737             :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   11738             :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   11739             :     //       RE-ENGINEERED  na
   11740             : 
   11741             :     // PURPOSE OF THIS SUBROUTINE:
   11742             :     // Simulates the water-cooled refrigeration condenser object.
   11743             :     // Modified to add condensers for detailed refrigeration systems and to
   11744             :     // avoid double-counting heat rejection that has been used in desuperheater
   11745             :     // hvac coils or water heaters.
   11746             : 
   11747             :     // METHODOLOGY EMPLOYED:
   11748             :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   11749             :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   11750             : 
   11751             :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   11752       36285 :     int PlantInletNode(0);
   11753       36285 :     int PlantOutletNode(0);
   11754       36285 :     PlantLocation PlantLoc{};
   11755             : 
   11756       36285 :     InitRefrigerationPlantConnections(state);
   11757             : 
   11758       36285 :     std::string TypeName;
   11759       36285 :     std::string ErrIntro;
   11760             : 
   11761             :     // set variables depending upon system type
   11762       36285 :     PlantInletNode = this->InletNode;
   11763       36285 :     PlantOutletNode = this->OutletNode;
   11764       36285 :     PlantLoc = this->plantLoc;
   11765             : 
   11766       72570 :     state.dataRefrigCase->TotalCondenserHeat =
   11767       36285 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(this->MyIdx).AvailCapacity - this->LaggedUsedWaterHeater - this->LaggedUsedHVACCoil;
   11768       36285 :     TypeName = "Refrigeration:CompressorRack:";
   11769       36285 :     ErrIntro = "Condenser for refrigeration rack ";
   11770             : 
   11771             :     // Current condenser is water cooled
   11772             :     // Make demand request on first HVAC iteration
   11773             : 
   11774             :     // get cooling fluid properties
   11775       36285 :     Real64 rho = FluidProperties::GetDensityGlycol(state,
   11776       36285 :                                                    state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidName,
   11777             :                                                    this->InletTemp,
   11778       36285 :                                                    state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidIndex,
   11779             :                                                    RoutineName);
   11780       36285 :     Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
   11781       36285 :                                                        state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidName,
   11782             :                                                        this->InletTemp,
   11783       36285 :                                                        state.dataPlnt->PlantLoop(PlantLoc.loopNum).FluidIndex,
   11784             :                                                        RoutineName);
   11785             : 
   11786       36285 :     if (this->FlowType == CndsrFlowType::VariableFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11787       35904 :         this->OutletTemp = ScheduleManager::GetCurrentScheduleValue(state, this->OutletTempSchedPtr);
   11788             : 
   11789       35904 :         if (this->OutletTemp == this->InletTemp) {
   11790             : 
   11791           0 :             if (this->HighInletWarnIndex == 0) {
   11792           0 :                 ShowSevereError(
   11793             :                     state,
   11794           0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11795           0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11796             :             }
   11797           0 :             ShowRecurringWarningErrorAtEnd(state,
   11798           0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11799           0 :                                            this->HighInletWarnIndex);
   11800           0 :             this->VolFlowRate = 9999.0;
   11801           0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11802             :         } else {
   11803       35904 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11804       35904 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11805             :             // Check for maximum flow in the component
   11806       35904 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11807           0 :                 if (this->HighFlowWarnIndex == 0) {
   11808           0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11809           0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11810           0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11811             :                 } // HighFlowWarnIndex
   11812           0 :                 ShowRecurringWarningErrorAtEnd(
   11813           0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11814             :                 // END IF
   11815           0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11816             :             }
   11817             :         } // compare outlet T to inlet T
   11818             : 
   11819         381 :     } else if (this->FlowType == CndsrFlowType::ConstantFlow && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11820             :         // this part for constant flow condition
   11821           0 :         this->VolFlowRate = this->DesVolFlowRate;
   11822           0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11823             : 
   11824         381 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11825         381 :         this->MassFlowRate = 0.0;
   11826             : 
   11827             :     } // on flow type
   11828             :     // check against plant, might get changed.
   11829       36285 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11830             : 
   11831       36285 :     this->VolFlowRate = this->MassFlowRate / rho;
   11832             : 
   11833       36285 :     if (this->MassFlowRate > 0) {
   11834       33630 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11835             :     } else {
   11836        2655 :         this->OutletTemp = this->InletTemp;
   11837        2655 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11838             : 
   11839          48 :             ShowRecurringWarningErrorAtEnd(
   11840             :                 state,
   11841          32 :                 TypeName + this->Name +
   11842             :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11843          16 :                 this->NoFlowWarnIndex);
   11844             :         }
   11845             :     }
   11846             :     // Check outlet water temp for max value
   11847       36285 :     if (this->OutletTemp > this->OutletTempMax) {
   11848           0 :         if (this->HighTempWarnIndex == 0) {
   11849           0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11850           0 :             ShowContinueError(state,
   11851             :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11852             :         }
   11853           0 :         ShowRecurringWarningErrorAtEnd(
   11854           0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", HighTempWarnIndex);
   11855             :     }
   11856             : 
   11857       36285 :     this->UpdateCondenserOutletNode(state);
   11858       36285 : }
   11859             : 
   11860       35133 : void RefrigCondenserData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11861             : {
   11862             : 
   11863             :     // SUBROUTINE INFORMATION:
   11864             :     //       AUTHOR         Randy Hudson, ORNL
   11865             :     //       DATE WRITTEN   July 2007
   11866             :     //       MODIFIED       na
   11867             :     //       RE-ENGINEERED  na
   11868             : 
   11869             :     // PURPOSE OF THIS SUBROUTINE:
   11870             :     // Updates the node variables with local variables.
   11871             : 
   11872             :     // Pass all variables from inlet to outlet node
   11873       35133 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11874             : 
   11875             :     // Set outlet node variables that are possibly changed
   11876       35133 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11877       35133 : }
   11878           0 : void RefrigCondenserData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11879             : {
   11880           0 : }
   11881           1 : void RefrigCondenserData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11882             : {
   11883           1 : }
   11884             : 
   11885       36285 : void RefrigRackData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11886             : {
   11887             : 
   11888             :     // SUBROUTINE INFORMATION:
   11889             :     //       AUTHOR         Randy Hudson, ORNL
   11890             :     //       DATE WRITTEN   July 2007
   11891             :     //       MODIFIED       na
   11892             :     //       RE-ENGINEERED  na
   11893             : 
   11894             :     // PURPOSE OF THIS SUBROUTINE:
   11895             :     // Updates the node variables with local variables.
   11896             : 
   11897             :     // Pass all variables from inlet to outlet node
   11898       36285 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11899             : 
   11900             :     // Set outlet node variables that are possibly changed
   11901       36285 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11902       36285 : }
   11903           0 : void RefrigRackData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11904             : {
   11905           0 : }
   11906             : 
   11907           1 : void RefrigRackData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11908             : {
   11909           1 : }
   11910             : 
   11911      391473 : void SimulateDetailedRefrigerationSystems(EnergyPlusData &state)
   11912             : {
   11913             : 
   11914             :     // SUBROUTINE INFORMATION:
   11915             :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   11916             :     //       DATE WRITTEN   Spring 2008
   11917             :     //       Based upon ManageRefrigeratedCaseRacks by Richard Raustad, FSEC
   11918             :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004
   11919             :     //       RE-ENGINEERED  na
   11920             : 
   11921             :     // PURPOSE OF THIS SUBROUTINE:
   11922             :     // This subroutine is called to simulate detailed refrigeration systems
   11923             : 
   11924             :     // METHODOLOGY EMPLOYED:
   11925             :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases.  The sum
   11926             :     // of the total heat transfer for all attached cases determines the load on the compressor rack.
   11927             :     // Iterations are used here to account for load transfer between independent refrigeration systems
   11928             :     // via mechanical subcoolers.
   11929             :     // The logical variable, UseSysTimeStep, determines whether we are evaluating only systems driven by
   11930             :     // ZoneEquipmentManager on the system time step, or only system driven by HVACManager on the zone time step.
   11931             : 
   11932             :     static constexpr std::string_view RoutineName = "SimulateDetailedRefrigerationSystems";
   11933      391473 :     Real64 constexpr MaxDelTFloatFrac = 0.5; // max fraction allowed for difference between case and evaporator temperature
   11934             : 
   11935      391473 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   11936      391473 :     auto &System = state.dataRefrigCase->System;
   11937      391473 :     auto &Condenser = state.dataRefrigCase->Condenser;
   11938      391473 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   11939      391473 :     auto &Secondary = state.dataRefrigCase->Secondary;
   11940      391473 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   11941      391473 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   11942      391473 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   11943      391473 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   11944             : 
   11945      391473 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   11946      391473 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   11947             : 
   11948             :     // Cascade condenser assumes a constant approach delta T (Tcond - Tevap), not f(load)
   11949             : 
   11950             :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   11951             :     // (all chiller coils within a set are located in the same zone)
   11952             :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   11953             :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   11954             :     // In that subroutine, dispatch coils within each set in order specified for each zone
   11955             :     //  Below will assign loads to refrigeration system or secondary loop
   11956             :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   11957             :     // with interactions will not be known for the intital calls with first HVAC time step. They will,
   11958             :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   11959             :     // that's why important where init goes, don't want to zero out data should keep
   11960      391473 :     if (state.dataRefrigCase->UseSysTimeStep) {
   11961     3918805 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   11962     3562550 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   11963             :         }
   11964             :     }
   11965             : 
   11966             :     // Do refrigeration system loop outside of iterative solution to initialize time step and
   11967             :     //  calculate case, walk-in, and secondary loop loads (that won't change during balance
   11968             :     //  of refrigeration system iterations) and prepare initial estimates for the iterative system solution
   11969     3676292 :     for (auto &thisSys : System) {
   11970             :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11971     3284819 :         if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11972     3284819 :             if (thisSys.NumCases > 0) {
   11973      256970 :                 for (int CaseIndex = 1; CaseIndex <= thisSys.NumCases; ++CaseIndex) {
   11974      197488 :                     auto &thisCase = RefrigCase(thisSys.CaseNum(CaseIndex));
   11975      197488 :                     thisCase.CalculateCase(state);
   11976             :                     //  TevapDesign calc in Get Input to meet lowest evap temp of any load on the system.
   11977             :                     //  Tevap needed is either fixed at this design value,
   11978             :                     //  or allowed to float to meet lowest T needed among all loads served by the system
   11979             :                     //  (Floating Tevap = Design Tevap unless load <= Design cap)
   11980      197488 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11981      183334 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11982             :                     } else { // calculate floating T evap
   11983       14154 :                         Real64 LoadFrac = min(1.0, (thisCase.TotalCoolingLoad / thisCase.DesignRatedCap));
   11984       14154 :                         Real64 MaxTEvap = thisCase.Temperature - (thisCase.Temperature - thisCase.EvapTempDesign) * max(LoadFrac, MaxDelTFloatFrac);
   11985             :                         // Compare Tevap for this case to max allowed for all previous cases on this suction group and set at the MINIMUM of the
   11986             :                         // two
   11987       14154 :                         if (CaseIndex == 1) { // note use case index, not caseid here to get first case on this suction group/system
   11988        4044 :                             thisSys.TEvapNeeded = MaxTEvap;
   11989             :                         } else {
   11990       10110 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11991             :                         }
   11992             :                     } // floating or constant evap temperature
   11993             :                     // increment TotalCoolingLoad for Compressors/condenser on each system and defrost condenser credits for heat recovery
   11994      197488 :                     thisSys.TotalCoolingLoad += thisCase.TotalCoolingLoad;
   11995      197488 :                     thisSys.TotalCondDefrostCredit += thisCase.HotDefrostCondCredit;
   11996             :                 } // NumCases
   11997             :             }     // Num of cases > 0
   11998             : 
   11999     3284819 :             if (thisSys.NumWalkIns > 0) {
   12000       88300 :                 for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkIns; ++WalkInIndex) {
   12001       44150 :                     auto &thisWalkIn = WalkIn(thisSys.WalkInNum(WalkInIndex));
   12002       44150 :                     thisWalkIn.CalculateWalkIn(state);
   12003       44150 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12004       42128 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12005             :                     } else { // calculate floating T evap
   12006        2022 :                         Real64 LoadFrac = min(1.0, (thisWalkIn.TotalCoolingLoad / thisWalkIn.DesignRatedCap));
   12007             :                         Real64 MaxTEvap =
   12008        2022 :                             thisWalkIn.Temperature - (thisWalkIn.Temperature - thisWalkIn.TEvapDesign) * max(LoadFrac, MaxDelTFloatFrac);
   12009             :                         //  Compare maxTevap for this walk in to max allowed for cases and for all
   12010             :                         //  previous walk ins on this suction group and set at the MINIMUM of the two
   12011        2022 :                         if (WalkInIndex == 1 && thisSys.NumCases == 0) {
   12012           0 :                             thisSys.TEvapNeeded = MaxTEvap;
   12013             :                         } else {
   12014        2022 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   12015             :                         }
   12016             :                     } // floating or constant evap temperature
   12017             :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   12018       44150 :                     thisSys.TotalCoolingLoad += thisWalkIn.TotalCoolingLoad;
   12019       44150 :                     thisSys.TotalCondDefrostCredit += thisWalkIn.HotDefrostCondCredit;
   12020             :                 } // NumWalkIns systems
   12021             :             }     // thisSys%NumWalkIns > 0
   12022             : 
   12023     3284819 :             if (thisSys.NumCoils > 0) {
   12024    32775460 :                 for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   12025    29569165 :                     int CoilID = thisSys.CoilNum(CoilIndex);
   12026             :                     // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   12027    29569165 :                     thisSys.TEvapNeeded = thisSys.TEvapDesign; // floating or constant evap temperature
   12028             :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   12029    29569165 :                     thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   12030    29569165 :                     thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   12031             :                 } // NumCoils systems
   12032             :             }     // thisSys%NumCoils > 0
   12033             : 
   12034     3284819 :             if (thisSys.NumSecondarys > 0) {
   12035        8088 :                 for (int SecondIndex = 1; SecondIndex <= thisSys.NumSecondarys; ++SecondIndex) {
   12036        4044 :                     int SecondID = thisSys.SecondaryNum(SecondIndex);
   12037        4044 :                     Secondary(SecondID).CalculateSecondary(state, SecondID);
   12038        4044 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12039        4044 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12040             :                     } else { // check for lowest T evap design among the secondary systems and
   12041             :                         //  Compare Tevap for this second to max allowed for cases, walk ins, and
   12042             :                         //  for all previous secondary loops on this suction group and set
   12043             :                         //  at the MINIMUM (note secondary loops control capacity with
   12044             :                         //  brine flow rate, so don't float above their design evap temperature)
   12045           0 :                         if (SecondIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   12046           0 :                             thisSys.TEvapNeeded = Secondary(SecondID).TEvapDesign;
   12047             :                         } else {
   12048           0 :                             thisSys.TEvapNeeded = min(Secondary(SecondID).TEvapDesign, thisSys.TEvapNeeded);
   12049             :                         }
   12050             :                     } // floating or constant evap temperature
   12051             :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   12052        4044 :                     thisSys.SumSecondaryLoopLoad += Secondary(SecondID).TotalCoolingLoad;
   12053        4044 :                     thisSys.TotalCondDefrostCredit += Secondary(SecondID).HotDefrostCondCredit;
   12054             :                 } // NumSecondarys systems
   12055             :             }     // thisSys%NumSecondarys > 0
   12056             : 
   12057             :             // add suction pipe heat gains (W) if input by user
   12058             :             // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   12059             :             //  condenser and compressor loads. However, secondary dist piping and receiver gains are included
   12060             :             //  in the total secondary system loads.
   12061     3284819 :             thisSys.PipeHeatLoad = 0.0;
   12062     3284819 :             if (thisSys.SumUASuctionPiping > MySmallNumber) {
   12063        4044 :                 Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNum)
   12064        4044 :                                                  .Temp; // Temperature for zone identified as environment for suction pipe heat gains, C
   12065        4044 :                 thisSys.PipeHeatLoad = thisSys.SumUASuctionPiping * (SuctionPipeZoneTemp - thisSys.TEvapNeeded);
   12066             :                 // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   12067             :                 //     from refrigcasecredit (- for cooling zone, + for heating zone)
   12068        4044 :                 int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNum;
   12069        4044 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   12070           0 :                     CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate -= thisSys.PipeHeatLoad;
   12071           0 :                     CoilSysCredit(SuctionPipeActualZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate;
   12072             :                 }
   12073             :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12074        8088 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12075        4044 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12076        4044 :                     state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoad;
   12077             :                 } // UseSysTimeStep
   12078             :             }
   12079             :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag)))
   12080             :     }     // SysNum
   12081             : 
   12082             :     // Need to know if mechanical subcoolers or cascade condensers or shared condensers
   12083             :     //    are present. If so, energy transfer between
   12084             :     //    detailed refrigeration systems requires additional iteration at this level.
   12085             : 
   12086      391473 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system,
   12087      780924 :     if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) || (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) ||
   12088      780924 :         (state.dataRefrigCase->NumSimulationSharedCondensers > 0) || (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0))
   12089      364343 :         StartMechSubcoolLoop = 1;
   12090             : 
   12091      391473 :     bool FirstSCLoop = true; // Flag first time through multi-system loop used when mech subcoolers present
   12092             : 
   12093     1511632 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3;
   12094             :          ++LoopNum) { // Note, for cascade cond loads compared requiring 5 iterations to 3, no difference.
   12095             : 
   12096    10853964 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   12097     9733805 :             auto &thisSys = System(SysNum);
   12098             :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12099     9733805 :             if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   12100     9733805 :                 thisSys.SumMechSCLoad = 0.0;
   12101     9733805 :                 thisSys.SumCascadeLoad = 0.0;
   12102     9733805 :                 thisSys.SumCascadeCondCredit = 0.0;
   12103     9733805 :                 thisSys.SumMechSCBenefit = 0.0;
   12104             : 
   12105     9733805 :                 if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) && (!FirstSCLoop)) {
   12106             :                     // This loop places load on system providing mechanical subcooling
   12107       24264 :                     for (int SubcoolID = 1; SubcoolID <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolID) {
   12108       16176 :                         if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) continue;
   12109        8088 :                         if (Subcooler(SubcoolID).MechSourceSysID != SysNum) continue;
   12110             :                         // don't have summechscload until second subcooler pass, set to zero on first pass
   12111        4044 :                         thisSys.SumMechSCLoad += thisSys.MechSCLoad(SubcoolID);
   12112             :                         // subcooler should not drive Tevap for supplying system,
   12113             :                         //    but check to see if T controlled can be met or if Tevap is at a higher temperature
   12114        4044 :                         if (Subcooler(SubcoolID).MechControlTliqOut < thisSys.TEvapNeeded) {
   12115           0 :                             ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12116           0 :                             ShowContinueError(state, " Evaporating temperature greater than the controlled ");
   12117           0 :                             ShowContinueError(state, format(" liquid outlet temperature for SUBCOOLER:{}", Subcooler(SubcoolID).Name));
   12118             :                         }
   12119             :                     } // SubcoolId
   12120             : 
   12121        8088 :                     if (thisSys.NumSubcoolers > 0) {
   12122       12132 :                         for (int SubcoolerIndex = 1; SubcoolerIndex <= thisSys.NumSubcoolers; ++SubcoolerIndex) {
   12123        8088 :                             int SubcoolID = thisSys.SubcoolerNum(SubcoolerIndex);
   12124        8088 :                             if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) continue;
   12125        4044 :                             thisSys.SumMechSCBenefit = Subcooler(SubcoolID).MechSCTransLoad;
   12126             :                         } // subcoolerindex
   12127             :                     }     // System(sysid)%numsubcoolers > 0
   12128             :                 }         // NumSimulationMechSubcoolers > 0 and not first loop
   12129             : 
   12130             :                 // This loop places load on system absorbing heat from cascade condenser and &
   12131             :                 //     condenser heat reclaim credits from hot gas/brine defrosts
   12132     9733805 :                 if ((thisSys.NumCascadeLoads > 0) && (!FirstSCLoop)) {
   12133        8088 :                     for (int CascadeLoadIndex = 1; CascadeLoadIndex <= thisSys.NumCascadeLoads; ++CascadeLoadIndex) {
   12134        4044 :                         int CascadeLoadID = thisSys.CascadeLoadNum(CascadeLoadIndex);
   12135        4044 :                         if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12136        4044 :                             thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12137             :                         } else { // check for lowest T evap design among the CascadeLoad systems and
   12138             :                             //  Compare Tevap for this Cascade to max allowed for cases, walk ins, and
   12139             :                             //  for all previous CascadeLoad loops on this suction group and set
   12140             :                             //  at the MINIMUM
   12141           0 :                             if (Condenser(CascadeLoadID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet) {
   12142             :                                 // if float then set tevap based upon other loads
   12143           0 :                                 if (CascadeLoadIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   12144           0 :                                     thisSys.TEvapNeeded = Condenser(CascadeLoadID).CascadeRatedEvapTemp;
   12145             :                                 } else {
   12146           0 :                                     thisSys.TEvapNeeded = min(Condenser(CascadeLoadID).CascadeRatedEvapTemp, thisSys.TEvapNeeded);
   12147             :                                 }
   12148             :                             }
   12149             :                         } // floating or constant system evap temperature
   12150             :                         // increment Cascade condenser Loads for Compressors/condenser on each system
   12151             :                         // place any defrost credits on the same system absorbing the cascade condenser load
   12152             :                         // (CascadeSysID identifies the condenser producing the defrost credits, that is, the lower temp system)
   12153        4044 :                         thisSys.SumCascadeLoad += Condenser(CascadeLoadID).CondLoad;
   12154        4044 :                         thisSys.SumCascadeCondCredit += System(Condenser(CascadeLoadID).CascadeSysID).TotalCondDefrostCredit;
   12155             : 
   12156             :                     } // NumCascadeLoads
   12157             :                 }     // thisSys%NumCascadeLoads > 0
   12158             : 
   12159             :                 // only calc detailed system if have load (could be zero first time through if only load is cascade condenser)
   12160     9733805 :                 thisSys.TotalSystemLoad = thisSys.TotalCoolingLoad + thisSys.SumSecondaryLoopLoad + thisSys.SumMechSCLoad + thisSys.SumCascadeLoad;
   12161     9733805 :                 if (thisSys.TotalSystemLoad > 0.0) {
   12162     9158204 :                     thisSys.CpSatVapEvap = FluidProperties::GetSatSpecificHeatRefrig(
   12163     9158204 :                         state, thisSys.RefrigerantName, thisSys.TEvapNeeded, 1.0, thisSys.RefIndex, RoutineName);
   12164     9158204 :                     thisSys.HCaseOut = FluidProperties::GetSatEnthalpyRefrig(
   12165     9158204 :                                            state, thisSys.RefrigerantName, thisSys.TEvapNeeded, 1.0, thisSys.RefIndex, RoutineName) +
   12166     9158204 :                                        thisSys.CpSatVapEvap * CaseSuperheat;
   12167             :                     // Establish estimates to start solution loop
   12168     9158204 :                     switch (Condenser(thisSys.CondenserNum(1)).CondenserType) {
   12169     9133940 :                     case DataHeatBalance::RefrigCondenserType::Air: {
   12170     9133940 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 16.7;
   12171             :                         // 16.7C is delta T at rating point for air-cooled condensers, just estimate, so ok for zone-located condensers
   12172     9133940 :                     } break;
   12173       16176 :                     case DataHeatBalance::RefrigCondenserType::Evap: {
   12174       16176 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 15.0;
   12175             :                         // 15C is delta T at rating point for evap-cooled condensers
   12176       16176 :                     } break;
   12177        2022 :                     case DataHeatBalance::RefrigCondenserType::Water: {
   12178             :                         // define starting estimate at temperature of water exiting condenser
   12179        2022 :                         thisSys.TCondense = state.dataLoopNodes->Node(Condenser(thisSys.CondenserNum(1)).OutletNode).Temp;
   12180        2022 :                     } break;
   12181        6066 :                     case DataHeatBalance::RefrigCondenserType::Cascade: {
   12182             :                         //?Don't need estimate for cascade condenser because it doesn't iterate?
   12183        6066 :                     } break;
   12184           0 :                     default:
   12185           0 :                         break;
   12186             :                     }
   12187             : 
   12188             :                     // Produce first time step estimates, assume no subcoolers
   12189     9158204 :                     thisSys.HSatLiqCond =
   12190     9158204 :                         FluidProperties::GetSatEnthalpyRefrig(state, thisSys.RefrigerantName, thisSys.TCondense, 0.0, thisSys.RefIndex, RoutineName);
   12191     9158204 :                     thisSys.CpSatLiqCond = FluidProperties::GetSatSpecificHeatRefrig(
   12192     9158204 :                         state, thisSys.RefrigerantName, thisSys.TCondense, 0.0, thisSys.RefIndex, RoutineName);
   12193     9158204 :                     thisSys.HCaseIn = thisSys.HSatLiqCond - thisSys.CpSatLiqCond * Condenser(thisSys.CondenserNum(1)).RatedSubcool;
   12194     9158204 :                     thisSys.RefMassFlowtoLoads = thisSys.TotalSystemLoad / (thisSys.HCaseOut - thisSys.HCaseIn);
   12195     9158204 :                     thisSys.RefMassFlowComps = thisSys.RefMassFlowtoLoads;
   12196             : 
   12197     9158204 :                     if (thisSys.NumStages == 2) { // Two-stage compression system
   12198             :                         // Initial guess for high-stage mass flow rate in two-stage compression systems
   12199        4044 :                         thisSys.RefMassFlowHiStageComps = thisSys.RefMassFlowComps / 0.65;
   12200             :                     }
   12201             : 
   12202     9158204 :                     thisSys.CalcDetailedSystem(state, SysNum);
   12203             : 
   12204             :                     bool DeRate; // If true, need to derate aircoils because load can't be met by system
   12205             : 
   12206             :                     // With air chiller coils, don't use unmet energy, instead reduce capacity on coils to match avail compressor/cond capacity
   12207             :                     // current loads on compressor, exclusive of unmet loads from prev time steps
   12208     9158204 :                     Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12209     9158204 :                     if ((thisSys.CoilFlag) && (CurrentLoads > (thisSys.TotCompCapacity * 1.001))) {
   12210       90934 :                         DeRate = true;
   12211       90934 :                         FinalRateCoils(state, DeRate, SourceType::DetailedSystem, SysNum, CurrentLoads, thisSys.TotCompCapacity);
   12212       90934 :                         thisSys.TotalCoolingLoad = 0.0;
   12213       90934 :                         thisSys.TotalCondDefrostCredit = 0.0;
   12214     1127963 :                         for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   12215     1037029 :                             int CoilID = thisSys.CoilNum(CoilIndex);
   12216             :                             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   12217     1037029 :                             if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12218     1037029 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12219             :                             } else { // calculate floating T evap
   12220           0 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12221           0 :                                 ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12222           0 :                                 ShowContinueError(state, " Floating evaporator temperature model not yet available for warehouse coil systems. ");
   12223             :                             } // floating or constant evap temperature
   12224             :                             // increment TotalCoolingLoad for Compressors/condenser on each system
   12225     1037029 :                             thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   12226     1037029 :                             thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   12227             :                         } // NumCoils systems
   12228       90934 :                         if (thisSys.NumStages == 2 &&
   12229           0 :                             thisSys.TotHiStageCompCapacity < (thisSys.TotalCoolingLoad + thisSys.LSHXTrans + thisSys.TotCompPower)) {
   12230           0 :                             ShowRecurringWarningErrorAtEnd(state,
   12231           0 :                                                            "Refrigeration:System: " + thisSys.Name +
   12232             :                                                                ":The specified high-stage compressors for this system are unable to meet the sum "
   12233             :                                                                "of the refrigeration loads, ",
   12234           0 :                                                            thisSys.HiStageWarnIndex1);
   12235           0 :                             ShowRecurringContinueErrorAtEnd(
   12236           0 :                                 state, " subcooler loads (if any), and low-stage compressor loads for this sytem.", thisSys.HiStageWarnIndex2);
   12237             :                         } // Hi-stage capacity<(load+LSHX load + lo-stage compressor load)
   12238             :                     }     // CoilFlag (Numcoils > 0) and load > capacity
   12239             : 
   12240             :                 } // thisSys%TotalSystemLoad > 0
   12241             :             }     //(((.NOT. UseSysTimeStep).AND.(.NOT. thisSys%CoilFlag)).OR.((UseSysTimeStep).AND.(thisSys%CoilFlag)))
   12242             :         }         // SysNum over NumRefrigSystems
   12243     1120159 :         FirstSCLoop = false;
   12244             :     } // LoopNum, three times for buildings with multiple detailed systems connected with mechanical subcoolers
   12245             :     // or cascade condensers or shared condensers or warehouse coils that might need to be de-rated
   12246             : 
   12247             :     // Dealing with unmet load has to be done outside iterative loop
   12248     3676292 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   12249     3284819 :         auto &thisSys = System(SysNum);
   12250             :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12251     6569638 :         if ((((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) &&
   12252     3284819 :             (!state.dataGlobal->WarmupFlag)) {
   12253      193104 :             Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12254      193104 :             Real64 CurrentHiStageLoads(0.0); // Current loads on high-stage compressor, exclusive of unmet loads from
   12255      193104 :             if (thisSys.NumStages == 2) {
   12256         576 :                 CurrentHiStageLoads = CurrentLoads + thisSys.TotCompPower;
   12257             :             } // NumStages==2
   12258      193104 :             if (thisSys.CoilFlag) {
   12259             :                 // don't use 'unmet energy' with air chillers, see 'derate'
   12260      182160 :                 thisSys.UnmetEnergy = 0.0;
   12261      182160 :                 thisSys.UnmetHiStageEnergy = 0.0;
   12262             :             } else {
   12263             :                 // Meeting current and possibly some portion of the previously unmet energy
   12264             :                 // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   12265             :                 // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   12266             :                 // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   12267       10944 :                 thisSys.UnmetEnergy += (CurrentLoads - thisSys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12268       10944 :                 if (thisSys.NumStages == 2) {
   12269         576 :                     thisSys.UnmetHiStageEnergy += (CurrentHiStageLoads - thisSys.TotHiStageCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12270             :                 }
   12271       10944 :                 if (thisSys.UnmetEnergy > MyLargeNumber) {
   12272           0 :                     thisSys.UnmetEnergy = MyLargeNumber;
   12273           0 :                     if (state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum)) {
   12274           0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12275           0 :                         ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   12276           0 :                         ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this sytem.");
   12277           0 :                         state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum) = false;
   12278             :                     } // show warning
   12279             :                 }     // > mylarge number
   12280       10944 :                 if (thisSys.UnmetHiStageEnergy > MyLargeNumber) {
   12281           0 :                     thisSys.UnmetHiStageEnergy = MyLargeNumber;
   12282           0 :                     if (state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum)) {
   12283           0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12284           0 :                         ShowContinueError(state, " The specified high-stage compressors for this system are unable to meet ");
   12285           0 :                         ShowContinueError(state, " the sum of the refrigerated case loads, subcooler loads (if any) and ");
   12286           0 :                         ShowContinueError(state, " low-stage compressor loads for this sytem.");
   12287           0 :                         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum) = false;
   12288             :                     } // show warning
   12289             :                 }     // > mylarge number
   12290             :             }         // numcoils > 0
   12291             : 
   12292             :             // Zone-located air-cooled condenser reject heat also has to be outside iterative loop
   12293      193104 :             if (thisSys.SystemRejectHeatToZone) {
   12294         864 :                 int CondInletAirZoneNum = Condenser(thisSys.CondenserNum(1)).InletAirZoneNum;
   12295         864 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   12296           0 :                     CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate += thisSys.NetHeatRejectLoad; // Adding heat is positive
   12297           0 :                     CoilSysCredit(CondInletAirZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate;
   12298             :                 }
   12299             :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12300        1728 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12301         864 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12302         864 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone +=
   12303         864 :                         thisSys.NetHeatRejectLoad; // Adding heat is positive
   12304             :                 }                                  // UseSystimestep
   12305             :             }                                      // Reject heat to zone
   12306             : 
   12307             :             // Report variables
   12308      193104 :             thisSys.TotTransferLoad = thisSys.SumMechSCLoad - thisSys.SumMechSCBenefit + thisSys.SumSecondaryLoopLoad + thisSys.SumCascadeLoad;
   12309      193104 :             thisSys.TotTransferEnergy = thisSys.TotTransferLoad * LocalTimeStep * Constant::SecInHour;
   12310      193104 :             thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * LocalTimeStep * Constant::SecInHour;
   12311      193104 :             thisSys.TotalCoolingEnergy = thisSys.TotalCoolingLoad * LocalTimeStep * Constant::SecInHour;
   12312             :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag))).and.not
   12313             :           // WarmupFlag
   12314             :     }     // SysNum = 1,NumRefrigSystems
   12315             : 
   12316             :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   12317             :     //   LatOutputProvided = CoilSysCredit(ZoneNum)%LatKgPerS_ToZoneRate
   12318             :     //   SysOutputProvided = CoilSysCredit(ZoneNum)%SenCreditToZoneRate
   12319             :     // Note that case credit is negative for cooling, thus subtract positive value calculated for coil
   12320             :     //   Note this is done whether or not the coils are derated.
   12321      391473 :     if (state.dataRefrigCase->UseSysTimeStep) {
   12322     5343825 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12323     4987570 :             auto &zoneCredit = CoilSysCredit(ZoneNum);
   12324   418955880 :             for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
   12325   413968310 :                 auto &coil = WarehouseCoil(CoilID);
   12326   413968310 :                 if (coil.ZoneNum != ZoneNum) continue;
   12327    29569165 :                 zoneCredit.SenCreditToZoneRate -= coil.SensCreditRate;
   12328    29569165 :                 zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * LocalTimeStep * Constant::SecInHour;
   12329    29569165 :                 zoneCredit.LatKgPerS_ToZoneRate -= coil.LatKgPerS_ToZone;
   12330    29569165 :                 zoneCredit.LatCreditToZoneRate -= coil.LatCreditRate;
   12331    29569165 :                 zoneCredit.LatCreditToZoneEnergy -= coil.LatCreditEnergy;
   12332             :             }
   12333             :         }
   12334             :     }
   12335             : 
   12336      391473 :     SumZoneImpacts(state);
   12337      391473 : }
   12338             : 
   12339        2022 : void SimulateDetailedTransRefrigSystems(EnergyPlusData &state)
   12340             : {
   12341             : 
   12342             :     // SUBROUTINE INFORMATION:
   12343             :     //       AUTHOR         Brian A. Fricke, ORNL
   12344             :     //       DATE WRITTEN   Fall 2011
   12345             :     //       RE-ENGINEERED  na
   12346             : 
   12347             :     // PURPOSE OF THIS SUBROUTINE:
   12348             :     // This subroutine is called to simulate detailed transcritical CO2 refrigeration systems
   12349             : 
   12350             :     // METHODOLOGY EMPLOYED:
   12351             :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases and
   12352             :     // walk-ins. The sum of the total heat transfer for all attached cases and walk-ins determines
   12353             :     // the load on the compressors. Iterations are used here to account for sharing of gas coolers
   12354             :     // between independent refrigeration systems.
   12355             : 
   12356             :     static constexpr std::string_view RoutineName = "SimulateDetailedTransRefrigSystems";
   12357             : 
   12358        2022 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   12359        2022 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   12360        2022 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   12361        2022 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   12362             : 
   12363        2022 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   12364        2022 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   12365             : 
   12366             :     //  Do transcritical CO2 refrigeration system loop outside of iterative solution to initialize time step and
   12367             :     //  calculate case and and walk-ins (that won't change during balance of refrigeration system iterations)
   12368             :     //  and prepare initial estimates for the iterative system solution
   12369             : 
   12370             :     //  TransCritSysFlag = .TRUE.
   12371        4044 :     for (auto &thisSys : TransSystem) {
   12372             :         // Only do those systems appropriate for this analysis, supermarket type on load time step
   12373        2022 :         if (thisSys.NumCasesMT > 0) {
   12374        8088 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesMT; ++CaseIndex) {
   12375        6066 :                 int CaseID = thisSys.CaseNumMT(CaseIndex);
   12376        6066 :                 RefrigCase(CaseID).CalculateCase(state);
   12377             :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   12378             :                 //  TEvapNeededMT is fixed at this design value.
   12379        6066 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   12380             :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12381        6066 :                 thisSys.TotalCoolingLoadMT += RefrigCase(CaseID).TotalCoolingLoad;
   12382        6066 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12383             :             } // NumCasesMT
   12384             :         }     // Num of MT cases > 0
   12385             : 
   12386        2022 :         if (thisSys.NumCasesLT > 0) {
   12387       10110 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesLT; ++CaseIndex) {
   12388        8088 :                 int CaseID = thisSys.CaseNumLT(CaseIndex);
   12389        8088 :                 RefrigCase(CaseID).CalculateCase(state);
   12390             :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   12391             :                 //  TEvapNeededLT is fixed at this design value.
   12392        8088 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12393             :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12394        8088 :                 thisSys.TotalCoolingLoadLT += RefrigCase(CaseID).TotalCoolingLoad;
   12395        8088 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12396             :             } // NumCasesLT
   12397             :         }     // Num of LT cases > 0
   12398             : 
   12399        2022 :         if (thisSys.NumWalkInsMT > 0) {
   12400           0 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsMT; ++WalkInIndex) {
   12401           0 :                 int WalkInID = thisSys.WalkInNumMT(WalkInIndex);
   12402           0 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   12403             :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   12404             :                 //  TEvapNeededMT is fixed at this design value.
   12405           0 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   12406             :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   12407           0 :                 thisSys.TotalCoolingLoadMT += WalkIn(WalkInID).TotalCoolingLoad;
   12408           0 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   12409             :             } // NumWalkInsMT systems
   12410             :         }     // thisSys%NumWalkInsMT > 0
   12411             : 
   12412        2022 :         if (thisSys.NumWalkInsLT > 0) {
   12413        4044 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsLT; ++WalkInIndex) {
   12414        2022 :                 int WalkInID = thisSys.WalkInNumLT(WalkInIndex);
   12415        2022 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   12416             :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   12417             :                 //  TEvapNeeded is fixed at this design value.
   12418        2022 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12419             :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   12420        2022 :                 thisSys.TotalCoolingLoadLT += WalkIn(WalkInID).TotalCoolingLoad;
   12421        2022 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   12422             :             } // NumWalkInsLT systems
   12423             :         }     // thisSys%NumWalkInsLT > 0
   12424             : 
   12425             :         // add suction pipe heat gains (W) if input by user
   12426             :         // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   12427             :         //  gas cooler and compressor loads.
   12428        2022 :         thisSys.PipeHeatLoadMT = 0.0;
   12429        2022 :         if (thisSys.SumUASuctionPipingMT > MySmallNumber) {
   12430           0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumMT).Temp;
   12431           0 :             thisSys.PipeHeatLoadMT = thisSys.SumUASuctionPipingMT * (SuctionPipeZoneTemp - thisSys.TEvapNeededMT);
   12432             :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   12433             :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   12434           0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumMT;
   12435             :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12436           0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12437           0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12438           0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadMT;
   12439             :             } // UseSysTimeStep
   12440             :         }
   12441             : 
   12442        2022 :         thisSys.PipeHeatLoadLT = 0.0;
   12443        2022 :         if (thisSys.SumUASuctionPipingLT > MySmallNumber) {
   12444           0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumLT).Temp;
   12445           0 :             thisSys.PipeHeatLoadLT = thisSys.SumUASuctionPipingLT * (SuctionPipeZoneTemp - thisSys.TEvapNeededLT);
   12446             :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   12447             :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   12448           0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumLT;
   12449             :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12450           0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12451           0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12452           0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadLT;
   12453             :             } // UseSysTimeStep
   12454             :         }
   12455             : 
   12456             :     } // SysNum
   12457             : 
   12458             :     // Need to know if shared gas coolers are present. If so, energy
   12459             :     // transfer between detailed transcritical refrigeration systems
   12460             :     // requires additional iteration at this level.
   12461             : 
   12462        2022 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system, don't loop
   12463        2022 :     if (state.dataRefrigCase->NumSimulationSharedGasCoolers > 0) StartMechSubcoolLoop = 1;
   12464             : 
   12465        4044 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3; ++LoopNum) {
   12466        4044 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12467        2022 :             auto &sys = TransSystem(SysNum);
   12468             :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12469             :             // only calc detailed system if have load
   12470        2022 :             sys.TotalSystemLoadMT = sys.TotalCoolingLoadMT;
   12471        2022 :             if (sys.TransSysType == 2) {
   12472        2022 :                 sys.TotalSystemLoadLT = sys.TotalCoolingLoadLT;
   12473             :             }
   12474        2022 :             sys.TotalSystemLoad = sys.TotalSystemLoadLT + sys.TotalSystemLoadMT;
   12475        2022 :             if (sys.TotalSystemLoad > 0.0) {
   12476        2022 :                 if (sys.TransSysType == 2) {
   12477        2022 :                     sys.CpSatVapEvapLT =
   12478        2022 :                         FluidProperties::GetSatSpecificHeatRefrig(state, sys.RefrigerantName, sys.TEvapNeededLT, 1.0, sys.RefIndex, RoutineName);
   12479        2022 :                     sys.HCaseOutLT =
   12480        2022 :                         FluidProperties::GetSatEnthalpyRefrig(state, sys.RefrigerantName, sys.TEvapNeededLT, 1.0, sys.RefIndex, RoutineName) +
   12481        2022 :                         sys.CpSatVapEvapLT * TransCaseSuperheat;
   12482             :                 }
   12483        2022 :                 sys.CpSatVapEvapMT =
   12484        2022 :                     FluidProperties::GetSatSpecificHeatRefrig(state, sys.RefrigerantName, sys.TEvapNeededMT, 1.0, sys.RefIndex, RoutineName);
   12485        2022 :                 sys.HCaseOutMT =
   12486        2022 :                     FluidProperties::GetSatEnthalpyRefrig(state, sys.RefrigerantName, sys.TEvapNeededMT, 1.0, sys.RefIndex, RoutineName) +
   12487        2022 :                     sys.CpSatVapEvapMT * TransCaseSuperheat;
   12488             : 
   12489             :                 // Produce first time step estimates.
   12490             :                 // Assume no subcoolers and neglect flow through bypass.
   12491        2022 :                 sys.TReceiver = FluidProperties::GetSatTemperatureRefrig(state, sys.RefrigerantName, sys.PReceiver, sys.RefIndex, RoutineName);
   12492        2022 :                 sys.HSatLiqReceiver =
   12493        2022 :                     FluidProperties::GetSatEnthalpyRefrig(state, sys.RefrigerantName, sys.TReceiver, 0.0, sys.RefIndex, RoutineName);
   12494        2022 :                 sys.CpSatLiqReceiver =
   12495        2022 :                     FluidProperties::GetSatSpecificHeatRefrig(state, sys.RefrigerantName, sys.TReceiver, 0.0, sys.RefIndex, RoutineName);
   12496        2022 :                 sys.HCaseInMT = sys.HSatLiqReceiver;
   12497        2022 :                 sys.HCaseInLT = sys.HSatLiqReceiver;
   12498        2022 :                 sys.RefMassFlowtoLTLoads = 0.0;
   12499        2022 :                 sys.RefMassFlowCompsLP = 0.0;
   12500        2022 :                 sys.DelHSubcoolerDis = 0.0;
   12501        2022 :                 sys.DelHSubcoolerSuc = 0.0;
   12502        2022 :                 if (sys.TransSysType == 2) {
   12503        2022 :                     sys.RefMassFlowtoLTLoads = sys.TotalSystemLoadLT / (sys.HCaseOutLT - sys.HCaseInLT);
   12504        2022 :                     sys.RefMassFlowCompsLP = sys.RefMassFlowtoLTLoads;
   12505             :                 } // (thisSys%TransSysType == 2)
   12506        2022 :                 sys.RefMassFlowtoMTLoads = sys.TotalSystemLoadMT / (sys.HCaseOutMT - sys.HCaseInMT);
   12507        2022 :                 sys.RefMassFlowCompsHP = sys.RefMassFlowtoLTLoads + sys.RefMassFlowtoMTLoads;
   12508             : 
   12509        2022 :                 sys.CalcDetailedTransSystem(state, SysNum);
   12510             :                 //       TransCritSysFlag = .FALSE.
   12511             : 
   12512             :             } // TransSystem(SysNum)%TotalSystemLoad > 0
   12513             :         }     // SysNum over NumRefrigSystems
   12514             :     }         // LoopNum, three times for buildings with multiple detailed systems connected with shared gas coolers
   12515             : 
   12516             :     // Unmet load is done outside iterative loop
   12517        4044 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12518        2022 :         auto &sys = TransSystem(SysNum);
   12519             :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12520        2022 :         if ((!state.dataRefrigCase->UseSysTimeStep) && (!state.dataGlobal->WarmupFlag)) {
   12521         288 :             Real64 CurrentLoads = sys.TotalSystemLoad;
   12522             :             // Meeting current and possibly some portion of the previously unmet energy
   12523             :             // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   12524             :             // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   12525             :             // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   12526         288 :             sys.UnmetEnergy += (CurrentLoads - sys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12527             : 
   12528         288 :             if (sys.UnmetEnergy > MyLargeNumber) {
   12529           0 :                 sys.UnmetEnergy = MyLargeNumber;
   12530           0 :                 if (state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum)) {
   12531           0 :                     ShowWarningError(state, format("Refrigeration:TranscriticalSystem: {}", sys.Name));
   12532           0 :                     ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   12533           0 :                     ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this sytem.");
   12534           0 :                     state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum) = false;
   12535             :                 } // show warning
   12536             :             }     // > mylarge number
   12537             : 
   12538             :             // Zone-located air-cooled gas cooler reject heat also has to be outside iterative loop
   12539         288 :             if (sys.SystemRejectHeatToZone) {
   12540           0 :                 int CondInletAirZoneNum = GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum;
   12541             :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12542           0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12543           0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12544           0 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone += sys.NetHeatRejectLoad; // Adding heat is positive
   12545             :                 }                                                                                                          // UseSystimestep
   12546             :             }                                                                                                              // Reject heat to zone
   12547             : 
   12548             :             // Report variables
   12549         288 :             sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * LocalTimeStep * Constant::SecInHour;
   12550         288 :             sys.TotalCoolingEnergy = (sys.TotalCoolingLoadMT + sys.TotalCoolingLoadMT) * LocalTimeStep * Constant::SecInHour;
   12551             :         } //(.NOT. UseSysTimeStep).AND. (.not. WarmupFlag)
   12552             :     }     // SysNum = 1,NumTransRefrigSystems
   12553             : 
   12554             :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   12555             : 
   12556        2022 :     SumZoneImpacts(state);
   12557        2022 : }
   12558             : 
   12559     9158204 : void RefrigSystemData::CalcDetailedSystem(EnergyPlusData &state, int const SysNum)
   12560             : {
   12561             : 
   12562             :     // SUBROUTINE INFORMATION:
   12563             :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   12564             :     //       DATE WRITTEN   Spring 2008
   12565             :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   12566             :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   12567             :     //       RE-ENGINEERED  na
   12568             : 
   12569             :     // PURPOSE OF THIS SUBROUTINE:
   12570             :     // Find the power and energy needed to meet the refrigeration loads for a particular detailed
   12571             :     // refrigeration system comprised of multiple cases, one condenser, and multiple compressors.
   12572             : 
   12573             :     // METHODOLOGY EMPLOYED:
   12574             :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   12575             :     // Using the initial estimate for condensing temperature, dispatch the compressors to
   12576             :     // determine the needed power, energy consumption, and refrigerant mass flow.
   12577             :     // Calculate the condenser fan/pump power and consumption.
   12578             :     // Calculate the condensing temperature as a function of environment and load.
   12579             :     // Resolve the impact of subcooler heat transfer between and among systems
   12580             :     // Iterate until the calculated refrigerant mass flow through the compressors converges, which
   12581             :     // typically requires less than 5 iterations. This was found to be more sensitive than converging
   12582             :     // upon the calculated condensing temperature.
   12583             : 
   12584             :     // REFERENCES:
   12585             :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12586             :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12587             : 
   12588             :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   12589             :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   12590             :     //  Master of Science, University of Wisconsin-Madison, 1999
   12591             : 
   12592     9158204 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12593             : 
   12594     9158204 :     bool NotBalanced = true;
   12595     9158204 :     int NumIter = 0;
   12596     9158204 :     Real64 ErrorMassFlowComps(0.0);        // Error in calculated low stage compressor mass flow (single- or two-stage systems)
   12597     9158204 :     Real64 ErrorMassFlowHiStageComps(0.0); // Error in calculated high-stage compressor mass flow (two-stage systems only)
   12598             : 
   12599             :     // Balance This Refrigeration System using calculated refrigerant flow
   12600     9158204 :     Real64 MassFlowHiStageCompsStart(0.0); // Mass flow through high-stage compressors (two-stage systems only)
   12601             : 
   12602    37414932 :     while (NotBalanced) {
   12603             :         // Set values for iteration convergence tolerance check
   12604    28256728 :         ++NumIter;
   12605             :         // Mass flow through (low-stage) compressors (single- or two-stage systems)
   12606    28256728 :         Real64 MassFlowCompsStart = this->RefMassFlowComps;
   12607             : 
   12608    28256728 :         if (this->NumStages == 2) { // Two-stage systems
   12609       14160 :             MassFlowHiStageCompsStart = this->RefMassFlowHiStageComps;
   12610             :         }
   12611             : 
   12612    28256728 :         if (this->NumSubcoolers > 0) this->CalculateSubcoolers(state);
   12613    28256728 :         this->CalculateCompressors(state);
   12614    28256728 :         this->CalculateCondensers(state, SysNum);
   12615    28256728 :         this->RefMassFlowtoLoads = this->TotalSystemLoad / (this->HCaseOut - this->HCaseIn);
   12616    28256728 :         if (NumIter < 2) continue;
   12617             :         // Previously did error check on calculated Tcondense, but not sensitive enough
   12618    19098524 :         if ((this->RefMassFlowtoLoads == 0.0) || (MassFlowCompsStart == 0.0)) { //.OR. (MassFlowCasesStart == 0.0)
   12619           0 :             ShowWarningError(state, format("Refrigeration:System: {} showing zero refrigeration flow.", this->Name));
   12620             :         } else {
   12621    19098524 :             ErrorMassFlowComps = std::abs(MassFlowCompsStart - this->RefMassFlowComps) / MassFlowCompsStart;
   12622    19098524 :             if (this->NumStages == 2) { // Two-stage systems
   12623       10116 :                 ErrorMassFlowHiStageComps = std::abs(MassFlowHiStageCompsStart - this->RefMassFlowHiStageComps) / MassFlowCompsStart;
   12624             :             }
   12625             :         } // denominator zero check
   12626    19098524 :         if (NumIter > 20) break;
   12627    19098524 :         if (ErrorMassFlowComps < ErrorTol) {
   12628     9160842 :             if (this->NumStages == 1 || (this->NumStages == 2 && ErrorMassFlowHiStageComps < ErrorTol)) {
   12629     9158204 :                 NotBalanced = false;
   12630             :             }
   12631             :         }
   12632             :     } // error check
   12633     9158204 : }
   12634             : 
   12635        2022 : void TransRefrigSystemData::CalcDetailedTransSystem(EnergyPlusData &state, int const SysNum)
   12636             : {
   12637             : 
   12638             :     // SUBROUTINE INFORMATION:
   12639             :     //       AUTHOR         Brian A. Fricke, ORNL
   12640             :     //       DATE WRITTEN   Fall 2011
   12641             :     //       MODIFIED       na
   12642             :     //       RE-ENGINEERED  na
   12643             : 
   12644             :     // PURPOSE OF THIS SUBROUTINE:
   12645             :     // Find the power and energy needed to meet the refrigeration loads for a detailed transcritical
   12646             :     // CO2 refrigeration system comprised of multiple cases and walk-ins, one gas cooler, and
   12647             :     // multiple compressors.
   12648             : 
   12649             :     // METHODOLOGY EMPLOYED:
   12650             :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   12651             :     // Dispatch the compressors to determine the needed power, energy consumption, and refrigerant
   12652             :     // mass flow. Calculate the gas cooler fan power and consumption. Calculate the gas cooler
   12653             :     // outlet temperature and pressure as a function of ambient temperature. Iterate until the
   12654             :     // calculated refrigerant mass flow through the receiver bypass converges, which typically
   12655             :     // requires less than 5 iterations.
   12656             : 
   12657        2022 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12658             : 
   12659        2022 :     int NumIter(0);            // Iteration counter
   12660        2022 :     bool NotBalanced(true);    // Flag to indicate convergence, based on system balance
   12661        2022 :     Real64 MassFlowStart(0.5); // Initial refrigerant mass flow through receiver bypass
   12662             :     Real64 ErrorMassFlow;      // Error in calculated refrigerant mass flow through receiver bypass
   12663             : 
   12664       12550 :     while (NotBalanced) {
   12665       10701 :         ++NumIter;
   12666             : 
   12667       10701 :         if (this->NumGasCoolers >= 1) this->CalcGasCooler(state, SysNum);
   12668       10701 :         this->CalculateTransCompressors(state);
   12669       10701 :         if (NumIter < 2) continue;
   12670        8679 :         if ((this->RefMassFlowReceiverBypass == 0.0) || (MassFlowStart == 0.0)) {
   12671           0 :             ShowSevereError(state,
   12672           0 :                             format("Refrigeration:TranscriticalSystem: {} showing zero refrigerant flow through receiver bypass.", this->Name));
   12673           0 :             ShowContinueError(state, format("Receiver Bypass Flow = {:.6R}", this->RefMassFlowReceiverBypass));
   12674           0 :             ShowContinueError(state, "Check input file to ensure that refrigeration loads on this system are not zero.");
   12675             :         } else {
   12676        8679 :             ErrorMassFlow = std::abs(MassFlowStart - this->RefMassFlowReceiverBypass) / MassFlowStart;
   12677        8679 :             MassFlowStart = this->RefMassFlowReceiverBypass;
   12678             :         } // denominator zero check
   12679        8679 :         if (NumIter > 20) break;
   12680        8506 :         if (ErrorMassFlow < ErrorTol) NotBalanced = false;
   12681             :     } // error check
   12682        2022 : }
   12683             : 
   12684    28256728 : void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysNum)
   12685             : {
   12686             : 
   12687             :     // SUBROUTINE INFORMATION:
   12688             :     //       AUTHOR         Therese Stovall and C. R. Hudson, ORNL, Assisted by Hugh Henderson
   12689             :     //       DATE WRITTEN   Spring 2008
   12690             :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   12691             :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   12692             :     //       RE-ENGINEERED  na
   12693             : 
   12694             :     // PURPOSE OF THIS SUBROUTINE:
   12695             :     // Find the condenser heat rejection for a particular detailed
   12696             :     // refrigeration system and condensing temperature (part of iterative soln for cond temp).
   12697             : 
   12698             :     // METHODOLOGY EMPLOYED:
   12699             :     // Calculate the condenser fan/pump power and consumption
   12700             :     // using manufacturer's rating data and fan power correlations
   12701             :     // from ASHRAE and evaporative effectiveness based on enthalpy
   12702             :     // similar to work done by Manske.
   12703             : 
   12704             :     // From Heejin Cho, Re variable frequency drive fans,
   12705             :     // "From HVAC forums, I learned that it is common practice to set a
   12706             :     // minimum frequency at 15 or 20 Hz to protect motors from overheating. The
   12707             :     // full speed is at 60 Hz. The ratio of minimum and maximum frequencies
   12708             :     // will correspond to the ratio of minimum and maximum flow rates."
   12709             : 
   12710             :     // REFERENCES:
   12711             :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12712             :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12713             : 
   12714             :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   12715             :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   12716             :     //  Master of Science, University of Wisconsin-Madison, 1999
   12717             : 
   12718             :     // Lawrence Berkeley Laboratory and Resource Dynamics, Improving Fan System Performance,
   12719             :     //   A Sourcebook for Industry, DOE/GO-102003-1294, April 2003
   12720             : 
   12721    28256728 :     Real64 constexpr BleedRateConstant = 5.0E-10; // water purge rate for evaporative
   12722             :     //  condensers (m3/W-s) equal to 3 GPM per 100 tons (BAC Engineering Reference)
   12723             : 
   12724    28256728 :     auto &System = state.dataRefrigCase->System;
   12725    28256728 :     auto &Condenser = state.dataRefrigCase->Condenser;
   12726             : 
   12727             :     int CondID;               // Condenser Number
   12728             :     int CondCreditWarnIndex1; // Used to sum up warning count
   12729             :     int CondCreditWarnIndex2; // Used to sum up warning count
   12730             :     int CondCreditWarnIndex3; // Used to sum up warning count
   12731             :     int CondCreditWarnIndex4; // Used to sum up warning count
   12732             :     int CondCreditWarnIndex5; // Used to sum up warning count
   12733             :     int CondCreditWarnIndex6; // Used to sum up warning count
   12734             :     int CondCreditWarnIndex7; // Used to sum up warning count
   12735             :     int Sysloop;              // counter over number of systems attached to this condenser
   12736             :     int SystemID;             // System number rejecting heat to this condenser
   12737             :     bool EvapAvail;           // Control for evap condenser availability
   12738             : 
   12739             :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   12740             :     Real64 AirDensity;                  // Density of air at condenser inlet [kg/m3]
   12741             :     Real64 AirDensityDry;               // Density of dry air at condenser inlet temperature [kg/m3]
   12742             :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded condenser [W]
   12743             :     Real64 BPress;                      // Barometric pressure at condenser air inlet node [Pa]
   12744             :     Real64 CapFac;                      // Capacity Factor
   12745             :     Real64 Effectiveness;               // for evap condenser, =capacity/max cap, where max cap is cap if Tairout equal Tcondense
   12746             :     Real64 EnthalpyAtTcond;             // enthalpy of saturated air at Tcondense
   12747             :     Real64 EnthalpyAirIn;               // Enthalpy of air entering condenser [J/kg]
   12748             :     Real64 EnthalpyAirOut;              // Enthalpy of air leaving condenser [J/kg]
   12749             :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   12750             :     Real64 FanPowerRatio;               // Calculated fan power ratio
   12751    28256728 :     Real64 HRCF(0.0);                   // Heat Rejection Capacity Factor (convention for evap condensers)
   12752             :     Real64 HRCFFullFlow;                // Heat Rejection Capacity Factor at full air flow
   12753             :     Real64 HumRatIn;                    // Humidity ratio of inlet air to condenser [kg/kg]
   12754             :     Real64 HumRatOut;                   // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   12755    28256728 :     Real64 OutWbTemp(0.0);              // Outdoor wet bulb temp at condenser air inlet node [C]
   12756             :     Real64 OutDbTemp;                   // Outdoor dry bulb temp at condenser air inlet node [C]
   12757             :     Real64 PurgeRate;                   // Rate of water blow-down/bleed/purge in evap condenser (m3/s)
   12758             :     Real64 RatedFanPower;               // local variable equal to input condenser value
   12759             :     Real64 RatedAirFlowRate;            // local variable equal to input condenser value
   12760             :     Real64 SinkTemp;                    // Heat sink temperature used to derate fan power at reduced loads [C]
   12761             :     Real64 TCondCalc;                   // Calculated Condensing temperature
   12762             :     Real64 TotalCondDefrostCreditLocal; // total cond credit from hot gas/brine defr for cases etc. served
   12763             :     //     directly by all systems served by this condenser [W]
   12764             :     Real64 TotalCondDefCredfromSysID;    // cond credit for single system [W]
   12765    28256728 :     Real64 TotalLoadFromThisSystem(0.0); // total heat rejection load from the detailed system id'd in subroutine call [W]
   12766             :     Real64 TotalLoadFromSystems;         // total heat rejection load from all systems served by this condenser [W]
   12767             : 
   12768    28256728 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   12769    28256728 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   12770             : 
   12771             :     // Initialize this condenser for this time step
   12772    28256728 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   12773    28256728 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   12774    28256728 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12775    28256728 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   12776    28256728 :     ActualFanPower = 0.0;
   12777    28256728 :     TotalCondDefrostCreditLocal = 0.0;
   12778    28256728 :     TotalLoadFromSystems = 0.0;
   12779    28256728 :     EvapAvail = true;
   12780    28256728 :     CondID = this->CondenserNum(1);
   12781    28256728 :     auto &condenser = Condenser(CondID);
   12782    28256728 :     RatedFanPower = condenser.RatedFanPower;
   12783    28256728 :     RatedAirFlowRate = condenser.RatedAirFlowRate;
   12784    28256728 :     FanMinAirFlowRatio = condenser.FanMinAirFlowRatio;
   12785    28256728 :     CondCreditWarnIndex1 = condenser.CondCreditWarnIndex1;
   12786    28256728 :     CondCreditWarnIndex2 = condenser.CondCreditWarnIndex2;
   12787    28256728 :     CondCreditWarnIndex3 = condenser.CondCreditWarnIndex3;
   12788    28256728 :     CondCreditWarnIndex4 = condenser.CondCreditWarnIndex4;
   12789    28256728 :     CondCreditWarnIndex5 = condenser.CondCreditWarnIndex5;
   12790    28256728 :     CondCreditWarnIndex6 = condenser.CondCreditWarnIndex6;
   12791    28256728 :     CondCreditWarnIndex7 = condenser.CondCreditWarnIndex7;
   12792             : 
   12793             :     // Sum total condenser load and defrost credits for all systems connected to this condenser
   12794             :     //  The system values will match the last time that system was solved, so some of the values may be
   12795             :     //  from the previous overall solution iteration.  However, solution goes through 3 iterations if
   12796             :     //  there are any shared condensers, so that's ok.
   12797    56602721 :     for (Sysloop = 1; Sysloop <= condenser.NumSysAttach; ++Sysloop) {
   12798    28345993 :         SystemID = condenser.SysNum(Sysloop);
   12799    28345993 :         TotalCondDefCredfromSysID = System(SystemID).TotalCondDefrostCredit + System(SystemID).SumCascadeCondCredit;
   12800    28345993 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   12801             :         // total heat rejection load from a single detailed system [W]
   12802             :         Real64 TotalLoadFromSysID =
   12803    28345993 :             System(SystemID).TotalSystemLoad + System(SystemID).TotCompPower + System(SystemID).TotHiStageCompPower + System(SystemID).PipeHeatLoad;
   12804    28345993 :         TotalLoadFromSystems += TotalLoadFromSysID;
   12805    28345993 :         if (SystemID == SysNum) TotalLoadFromThisSystem = TotalLoadFromSysID;
   12806             :     } // Sysloop over every system connected to this condenser
   12807             : 
   12808             :     // for cascade condensers, condenser defrost credit gets passed on to the primary system condenser
   12809    28256728 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) TotalCondDefrostCreditLocal = 0.0;
   12810             : 
   12811             :     // Calculate Total Heat rejection needed.  Assume hermetic compressors - conservative assumption
   12812             :     // Note that heat rejection load carried by desuperheater hvac coils or water heaters is the
   12813             :     // lagged variable from the previous time step because these are calculated after the refrigeration
   12814             :     // system is solved.
   12815    28256728 :     condenser.ExternalHeatRecoveredLoad = condenser.LaggedUsedWaterHeater + condenser.LaggedUsedHVACCoil;
   12816    28256728 :     condenser.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12817    28256728 :     condenser.TotalHeatRecoveredLoad = condenser.ExternalHeatRecoveredLoad + TotalCondDefrostCreditLocal;
   12818             : 
   12819    28256728 :     state.dataRefrigCase->TotalCondenserHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal - condenser.ExternalHeatRecoveredLoad;
   12820    28256728 :     if (state.dataRefrigCase->TotalCondenserHeat < 0.0) {
   12821             : 
   12822           6 :         state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12823           6 :         if (!state.dataGlobal->WarmupFlag) {
   12824          18 :             ShowRecurringWarningErrorAtEnd(state,
   12825          12 :                                            "Refrigeration:System: " + this->Name +
   12826             :                                                ":heat reclaimed(defrost,other purposes) >current condenser load. ",
   12827             :                                            CondCreditWarnIndex1);
   12828           6 :             ShowRecurringContinueErrorAtEnd(
   12829             :                 state, "For heat recovered for defrost: ASHRAE rule of thumb: <= 25% of the load on a rack ", CondCreditWarnIndex2);
   12830           6 :             ShowRecurringContinueErrorAtEnd(
   12831             :                 state, "should be in defrost at the same time. Consider diversifying defrost schedules.", CondCreditWarnIndex3);
   12832           6 :             ShowRecurringContinueErrorAtEnd(
   12833             :                 state,
   12834             :                 "For heat recovered for other purposes: this warning may be an artifact of refrigeration calculation at the load",
   12835             :                 CondCreditWarnIndex4);
   12836           6 :             ShowRecurringContinueErrorAtEnd(
   12837             :                 state,
   12838             :                 "time step and heat recovery at the system time step. In that case, and ONLY if it occurs a large number of times",
   12839             :                 CondCreditWarnIndex5);
   12840           6 :             ShowRecurringContinueErrorAtEnd(
   12841             :                 state, "(relative to the number of time steps in the simulation), there may be a mis-match between the", CondCreditWarnIndex6);
   12842           6 :             ShowRecurringContinueErrorAtEnd(
   12843             :                 state, "operating schedules of the refrigeration system and the heat recovery load.", CondCreditWarnIndex7);
   12844             :         } // not warmup
   12845             :     }     // total condenser heat < 0
   12846             : 
   12847             :     // Water side of water-cooled condensers simulated in SimRefrigCondenser,
   12848             :     //   Here, we just need load and condensing temperatures.
   12849             :     //   Condensing temperature a fixed delta (the rated approach temperature) from inlet water temp so long as above minimum.
   12850             :     //   Note, if condensing temperature falls below minimum, get warning and reset but no change in water-side calculations.
   12851    28256728 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   12852             :         // Obtain water-cooled condenser inlet/outlet temps
   12853        6066 :         condenser.InletTemp = state.dataLoopNodes->Node(condenser.InletNode).Temp;
   12854        6066 :         TCondCalc = state.dataLoopNodes->Node(condenser.InletNode).Temp + condenser.RatedApproachT;
   12855        6066 :         if ((condenser.InletTemp < condenser.InletTempMin) || (TCondCalc < this->TCondenseMin)) {
   12856           0 :             this->TCondense = this->TCondenseMin;
   12857             :             // condenser.LowTempWarn += 1;
   12858           0 :             if (condenser.LowTempWarnIndex == 0) {
   12859           0 :                 ShowWarningMessage(state, format("Refrigeration:Condenser:WaterCooled {}", condenser.Name));
   12860           0 :                 ShowContinueError(state,
   12861             :                                   "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature and/or "
   12862             :                                   "minimum temperature setpoints relative to minimum allowed condensing temperature.");
   12863             :             }
   12864           0 :             ShowRecurringWarningErrorAtEnd(state,
   12865           0 :                                            "Refrigeration:Condenser:WaterCooled " + condenser.Name +
   12866             :                                                " - Condenser inlet temp lower than minimum allowed ... continues",
   12867           0 :                                            condenser.LowTempWarnIndex);
   12868             :             // END IF
   12869             :         } else {
   12870        6066 :             this->TCondense = TCondCalc;
   12871             :         }
   12872             : 
   12873    28250662 :     } else if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) ||
   12874       75727 :                (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap)) {
   12875             :         // Condensing Temp, fan and other aux loads for air-cooled or evap-cooled
   12876             : 
   12877             :         // The rated capacity of air-cooled condenser was adjusted for elevation in get input step
   12878    28238529 :         CapFac = state.dataRefrigCase->TotalCondenserHeat / condenser.RatedCapacity;
   12879             :         // See whether condenser is at ground level or if other air conditions(ie node) have been specified.
   12880             :         //    Note that air-cooled condensers can draw air from, and reject heat to, a conditioned zone
   12881             :         //    But evaporative condensers cannot.
   12882             :         // Provides effective condensing temperature for air-cooled condenser (or evap if evap is scheduled off)
   12883    28238529 :         if (condenser.InletAirNodeNum != 0) {
   12884    28238529 :             OutDbTemp = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Temp;
   12885    28238529 :             BPress = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Press;
   12886    28238529 :             HumRatIn = state.dataLoopNodes->Node(condenser.InletAirNodeNum).HumRat;
   12887             :         } else {
   12888           0 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   12889           0 :             BPress = state.dataEnvrn->OutBaroPress;
   12890           0 :             HumRatIn = state.dataEnvrn->OutHumRat;
   12891             :         }
   12892    28238529 :         AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn);
   12893    28238529 :         AirDensityDry = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, 0.0);
   12894             :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   12895             :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   12896             :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   12897             :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   12898             :         //  climates.  To accomodate such applications, the variable EvapCutOutTdb is used as an extra
   12899             :         //  check.
   12900             : 
   12901    28238529 :         if (OutDbTemp < EvapCutOutTdb) EvapAvail = false;
   12902             : 
   12903             :         // Check schedule to determine evap condenser availability
   12904             :         // IF schedule exists, evap condenser can be scheduled OFF
   12905    28302123 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (condenser.EvapSchedPtr > 0) &&
   12906       63594 :             (ScheduleManager::GetCurrentScheduleValue(state, condenser.EvapSchedPtr) == 0))
   12907       32675 :             EvapAvail = false;
   12908             : 
   12909             :         // Calculate condensing temperatures for air-cooled and evap-cooled
   12910    28238529 :         if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   12911             :             // Manufacturer's HRCF regressed to produce a function of the form:
   12912             :             // (Tcondense-Twb)=A1 + A2*hrcf + A3/hrcf + A4*Twb
   12913             :             // HRCF defined as rated capacity divided by load
   12914             :             // Apply ARI490 elevation correction factor here for evap condenser, then apply hrcf limits
   12915       63594 :             if (CapFac > 0.0) {
   12916       63594 :                 HRCF = condenser.EvapElevFact / CapFac;
   12917             :                 // Condenser(CondNum)%EvapElevFact=1.0d0-3.074D-5*Elevation
   12918             :             } else {
   12919           0 :                 HRCF = MyLargeNumber;
   12920             :             }
   12921       63594 :             HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12922       63594 :             HRCF = max(HRCF, condenser.MinCapFacEvap);
   12923       63594 :             if (EvapAvail) {
   12924       30919 :                 OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   12925       30919 :                 SinkTemp = OutWbTemp;
   12926             :             } else {         // evaporative condenser with water spray scheduled off so use Tdb
   12927       32675 :                 HRCF /= 3.0; // reference Menske, cap of evap cond operating dry about 1/3 of rated cap
   12928       32675 :                 HRCF = max(HRCF, condenser.MinCapFacEvap);
   12929       32675 :                 SinkTemp = OutDbTemp;
   12930             :             } // evap avail, still in evap condenser
   12931       63594 :             TCondCalc = condenser.EvapCoeff1 + condenser.EvapCoeff2 * HRCF + condenser.EvapCoeff3 / HRCF + (1.0 + condenser.EvapCoeff4) * SinkTemp;
   12932             :         } else { // air-cooled condenser
   12933             :             // MinCondLoad and TempSlope came from condenser capacity curve, using curve backwards
   12934    28174935 :             TCondCalc = OutDbTemp + (state.dataRefrigCase->TotalCondenserHeat - condenser.MinCondLoad) * condenser.TempSlope;
   12935    28174935 :             SinkTemp = OutDbTemp;
   12936             :         } // if evap-cooled condenser
   12937             : 
   12938             :         // Fan energy calculations apply to both air- and evap-cooled condensers
   12939             :         // Compare calculated condensing temps to minimum allowed to determine fan power/operating mode
   12940    28238529 :         if (TCondCalc >= this->TCondenseMin) {
   12941     7926194 :             this->TCondense = TCondCalc;
   12942     7926194 :             ActualFanPower = RatedFanPower;
   12943     7926194 :             AirVolRatio = 1.0;
   12944             : 
   12945             :         } else { // need to reduce fan speed to reduce air flow and keep Tcond at or above Tcond min
   12946    20312335 :             this->TCondense = this->TCondenseMin;
   12947    20312335 :             TCondCalc = this->TCondenseMin;
   12948             :             // recalculate CapFac at current delta T
   12949    20312335 :             if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
   12950             :                 // current maximum condenser capacity at delta T present for minimum condensing temperature [W]
   12951    20297358 :                 Real64 CurMaxCapacity = Curve::CurveValue(state, condenser.CapCurvePtr, (this->TCondenseMin - OutDbTemp));
   12952    20297358 :                 CapFac = state.dataRefrigCase->TotalCondenserHeat / CurMaxCapacity;
   12953    20297358 :                 AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   12954    20297358 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12955             :             } else { // condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap
   12956       14977 :                 HRCFFullFlow = HRCF;
   12957             :                 // if evap condenser need to back calculate the operating capacity using HRCF relationship, given known Tcond
   12958       14977 :                 Real64 QuadBterm = condenser.EvapCoeff1 - (this->TCondense - SinkTemp) + condenser.EvapCoeff4 * SinkTemp;
   12959       14977 :                 Real64 Sqrtterm = pow_2(QuadBterm) - 4.0 * condenser.EvapCoeff2 * condenser.EvapCoeff3;
   12960       14977 :                 if (Sqrtterm < 0.0) { // only happens for very high wet bulb temps
   12961           0 :                     HRCF = condenser.EvapElevFact * condenser.MaxCapFacEvap;
   12962           0 :                     if (!EvapAvail) HRCF /= 3.0;
   12963           0 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12964             :                 } else {
   12965       14977 :                     HRCF = condenser.EvapElevFact * (-QuadBterm - std::sqrt(Sqrtterm)) / (2.0 * condenser.EvapCoeff2);
   12966       14977 :                     if (!EvapAvail) HRCF /= 3.0;
   12967       14977 :                     HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12968       14977 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12969             :                 }                             // sqrtterm
   12970       14977 :                 CapFac = HRCF / HRCFFullFlow; // note, HRCFFullFlow previously limited between min and max,so can't be zero
   12971       14977 :                 if (EvapAvail) {
   12972        5094 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentEvap)); // Fans limited by minimum air flow ratio
   12973             :                 } else {                                                                             // evap not available
   12974        9883 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry));  // Fans limited by minimum air flow ratio
   12975             :                 }                                                                                    // evap available
   12976       14977 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12977             :             } // condenser type = DataHeatBalance::RefrigCondenserType::Air with else for evap
   12978             : 
   12979    20312335 :             switch (condenser.FanSpeedControlType) {
   12980       71213 :             case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   12981       71213 :                 FanPowerRatio = std::pow(AirVolRatio, 2.5);
   12982       71213 :                 ActualFanPower = FanPowerRatio * RatedFanPower;
   12983       71213 :             } break;
   12984       29424 :             case FanSpeedCtrlType::ConstantSpeed: {
   12985       29424 :                 ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12986       29424 :             } break;
   12987           0 :             case FanSpeedCtrlType::ConstantSpeedLinear: {
   12988           0 :                 ActualFanPower = AirVolRatio * RatedFanPower;
   12989           0 :             } break;
   12990    20211698 :             case FanSpeedCtrlType::TwoSpeed: {
   12991             :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   12992             :                 // 1/2 speed corresonds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   12993             :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   12994    20211698 :                 Real64 const air_vol_fan_power_fac(std::exp(1.0 - AirVolRatio) * RatedFanPower);
   12995    20211698 :                 ActualFanPower = AirVolRatio * air_vol_fan_power_fac;
   12996    20211698 :                 if (CapFac < CapFac60Percent) ActualFanPower = ((AirVolRatio + 0.4) * FanHalfSpeedRatio) * air_vol_fan_power_fac;
   12997    20211698 :             } break;
   12998           0 :             default:
   12999           0 :                 break;
   13000             :             } // fan speed control type
   13001             :         }     // Tcondense >= Tcondense minimum
   13002             : 
   13003    28238529 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (EvapAvail)) {
   13004             :             // calculate evap water use,  need to include bleed down/purge water as well as water
   13005             :             // actually evaporated.  Use BAC Engineering Reference value of 3 gpm/100 tons because it's more
   13006             :             // conservative than the ASHRAE value.
   13007             :             //  Also, based on experience, running the evap water when outdoor T near freezing
   13008             :             //  leads to 'spectacular' ice, so schedule evap off when Tdb <=4 C.
   13009             :             // Calculate bleed/purge rate of water loss as a function of capacity, 3 gpm/100 tons refrigeration
   13010       30919 :             PurgeRate = state.dataRefrigCase->TotalCondenserHeat * BleedRateConstant;
   13011       30919 :             EnthalpyAirIn = Psychrometrics::PsyHFnTdbW(OutDbTemp, HumRatIn);
   13012             :             // calculate effectiveness at rated conditions, so use Tcondcalc)
   13013       30919 :             EnthalpyAtTcond = Psychrometrics::PsyHFnTdbRhPb(state, TCondCalc, 1.0, BPress);
   13014       30919 :             Effectiveness = state.dataRefrigCase->TotalCondenserHeat / (RatedAirFlowRate * AirDensity * (EnthalpyAtTcond - EnthalpyAirIn));
   13015             :             // need to limit max effectiveness for errors due to working beyond limits of HRCF in manuf data
   13016       30919 :             Effectiveness = min(Effectiveness, 0.9);
   13017       30919 :             EnthalpyAirOut = EnthalpyAirIn + Effectiveness * (EnthalpyAtTcond - EnthalpyAirIn);
   13018             :             // Air leaving the evaporative condenser is saturated
   13019       30919 :             Real64 TAirOut = Psychrometrics::PsyTsatFnHPb(state, EnthalpyAirOut, BPress);
   13020       30919 :             HumRatOut = Psychrometrics::PsyWFnTdpPb(state, TAirOut, BPress);
   13021       61838 :             state.dataRefrigCase->TotalEvapWaterUseRate =
   13022       30919 :                 PurgeRate + RatedAirFlowRate * AirVolRatio * AirDensityDry * (HumRatOut - HumRatIn) / Psychrometrics::RhoH2O(OutWbTemp);
   13023             :             // assumes evap water pump runs whenever evap cooling is available to minimize scaling
   13024       30919 :             state.dataRefrigCase->TotalCondenserPumpPower = condenser.EvapPumpPower;
   13025             :             // calculate basin water heater load
   13026       30919 :             if (state.dataRefrigCase->TotalCondenserHeat == 0.0 && OutDbTemp < condenser.BasinHeaterSetPointTemp) {
   13027           0 :                 state.dataRefrigCase->TotalBasinHeatPower =
   13028           0 :                     max(0.0, condenser.BasinHeaterPowerFTempDiff * (condenser.BasinHeaterSetPointTemp - OutDbTemp));
   13029             :                 // provide warning if no heater power exists
   13030           0 :                 if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   13031             :                     // condenser.EvapFreezeWarn = condenser.EvapFreezeWarn + 1;
   13032           0 :                     if (condenser.EvapFreezeWarnIndex == 0) {
   13033           0 :                         ShowWarningMessage(
   13034             :                             state,
   13035           0 :                             format("Refrigeration Condenser {} - Evap cooling of condenser underway with no basin heater power", condenser.Name));
   13036           0 :                         ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   13037           0 :                         ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   13038             :                     }
   13039           0 :                     ShowRecurringWarningErrorAtEnd(state,
   13040           0 :                                                    "Refrigeration Condenser " + condenser.Name +
   13041             :                                                        " - Evap cooling of condenser underway with no basin heater power ... continues",
   13042           0 :                                                    condenser.EvapFreezeWarnIndex);
   13043             :                     // END IF  !freeze warnings <= 5
   13044             :                 } // basin power == 0
   13045             :             }     // no load and cold outside
   13046             :         }         // EvapAvail
   13047             : 
   13048    28250662 :     } else if (condenser.CondenserType ==
   13049             :                DataHeatBalance::RefrigCondenserType::Cascade) { // continuing Condenser type = water, (evap or air), or cascade
   13050             :         // Cascade condenser does not iterate.  Condensing temperature specified as a load on higher temp system
   13051             :         //    or floats to meet other loads on that system
   13052             :         // therese ** future - here and for new phase change heat exchanger - need to handle unmet loads!
   13053             : 
   13054       12133 :         this->TCondense = condenser.RatedTCondense;
   13055             : 
   13056       12133 :         if ((this->NumNonCascadeLoads > 0) && (condenser.CascadeTempControl == CascadeCndsrTempCtrlType::TempFloat)) {
   13057           0 :             this->TCondense = System(condenser.CascadeSinkSystemID).TEvapNeeded + condenser.RatedApproachT;
   13058           0 :             if (this->TCondense < this->TCondenseMin) {
   13059           0 :                 this->TCondense = this->TCondenseMin;
   13060           0 :                 ShowRecurringWarningErrorAtEnd(state,
   13061           0 :                                                "Refrigeration Condenser " + condenser.Name +
   13062             :                                                    " - Cascade condenser floating condensing temperature less than specified minimum condensing "
   13063             :                                                    "temperature. Minimum specified temperature used for system below cascade condenser. No "
   13064             :                                                    "correction made for system absorbing heat rejected by the cascade condenser.",
   13065           0 :                                                condenser.EvapFreezeWarnIndex);
   13066             :             } // floating condensing temperature less than specified min for system
   13067             :         }     // floating temperature
   13068             :     }         // Condenser type = water, (evap or air), or cascade
   13069             : 
   13070    28256728 :     condenser.ActualFanPower = ActualFanPower;
   13071    28256728 :     condenser.FanElecEnergy = ActualFanPower * LocalTimeStep * Constant::SecInHour;
   13072    28256728 :     condenser.EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   13073    28256728 :     condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * LocalTimeStep * Constant::SecInHour;
   13074    28256728 :     condenser.ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   13075    28256728 :     condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * LocalTimeStep * Constant::SecInHour;
   13076    28256728 :     condenser.BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   13077    28256728 :     condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * LocalTimeStep * Constant::SecInHour;
   13078    28256728 :     condenser.CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   13079    28256728 :     condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * LocalTimeStep * Constant::SecInHour;
   13080    28256728 :     condenser.CondCreditWarnIndex1 = CondCreditWarnIndex1;
   13081    28256728 :     condenser.CondCreditWarnIndex2 = CondCreditWarnIndex2;
   13082    28256728 :     condenser.CondCreditWarnIndex3 = CondCreditWarnIndex3;
   13083    28256728 :     condenser.CondCreditWarnIndex4 = CondCreditWarnIndex4;
   13084    28256728 :     condenser.CondCreditWarnIndex5 = CondCreditWarnIndex5;
   13085    28256728 :     condenser.CondCreditWarnIndex6 = CondCreditWarnIndex6;
   13086    28256728 :     condenser.CondCreditWarnIndex7 = CondCreditWarnIndex7;
   13087    28256728 :     condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour;
   13088    28256728 :     condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour;
   13089    28256728 :     condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour;
   13090    28256728 :     this->NetHeatRejectLoad = state.dataRefrigCase->TotalCondenserHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   13091    28256728 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * LocalTimeStep * Constant::SecInHour;
   13092             : 
   13093             :     // set water system demand request (if needed)
   13094    28256728 :     if (condenser.EvapWaterSupplyMode == WaterSupply::FromTank) {
   13095       63594 :         state.dataWaterData->WaterStorage(condenser.EvapWaterSupTankID).VdotRequestDemand(condenser.EvapWaterTankDemandARRID) =
   13096       63594 :             condenser.EvapWaterConsumpRate;
   13097             :     }
   13098    28256728 : }
   13099             : 
   13100       10701 : void TransRefrigSystemData::CalcGasCooler(EnergyPlusData &state, int const SysNum)
   13101             : {
   13102             : 
   13103             :     // SUBROUTINE INFORMATION:
   13104             :     //       AUTHOR         Brian A. Fricke, ORNL
   13105             :     //       DATE WRITTEN   Fall 2011
   13106             :     //       MODIFIED       na
   13107             :     //       RE-ENGINEERED  na
   13108             : 
   13109             :     // PURPOSE OF THIS SUBROUTINE:
   13110             :     // Find the gas cooler outlet temperature, the optimum gas cooler pressure, heat rejection,
   13111             :     // fan power, and fan energy for a detailed transcritical CO2 refrigeration system.
   13112             : 
   13113             :     // METHODOLOGY EMPLOYED:
   13114             :     // For a specified gas cooler outlet temperature in transcritical operation, there is an optimal gas cooler
   13115             :     // pressure which produces the highest COP. A curve-fit equation similar to that presented by Ge and Tassou
   13116             :     // (2011) and Sawalha (2008) is used to determine the optimum gas cooler pressure for a given gas cooler
   13117             :     // outlet temperature. In subcritical operation, the condensing temperature and pressure are allowed to
   13118             :     // float with ambient conditions, above the minimum condensing temperature.
   13119             : 
   13120             :     // REFERENCES:
   13121             :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13122             :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   13123             :     //     Journal of Refrigeration 34: 527-539.
   13124             :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13125             :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   13126             :     //     Refrigeration 34: 540-549.
   13127             :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13128             :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   13129             :     //     Refrigeration 31: 516-524.
   13130             :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13131             :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   13132             :     //     Refrigeration 31: 525-534.
   13133             : 
   13134             :     static constexpr std::string_view RoutineName = "RefrigeratedCase:CalcGasCooler";
   13135             : 
   13136       10701 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   13137       10701 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13138             : 
   13139             :     int GasCoolerCreditWarnIndex;       // Warning counter
   13140             :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded gas cooler [W]
   13141             :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   13142             :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   13143             :     Real64 FanPowerRatio;               // Calculated fan power ratio
   13144             :     Real64 OutDbTemp;                   // Outdoor dry bulb temperature at gas cooler air inlet node [C]
   13145             :     Real64 RatedFanPower;               // Rated fan power for this gas cooler [W]
   13146             :     Real64 TotalCondDefCredfromSysID;   // Gas cooler defrost credit for single system [W]
   13147             :     Real64 TotalCondDefrostCreditLocal; // Total gas cooler credit from hot gas/brine defrost for cases etc. served
   13148             :     //     directly by all systems served by this gas cooler [W]
   13149             :     Real64 TotalGasCoolerHeat;           // Total gas cooler heat from system [W]
   13150             :     Real64 TotalLoadFromSysID;           // Total heat rejection load from a single detailed system [W]
   13151             :     Real64 TotalLoadFromSystems;         // Total heat rejection load from all systems served by this condenser [W]
   13152       10701 :     Real64 TotalLoadFromThisSystem(0.0); // Total heat rejection load from the detailed system identified in subroutine call [W]
   13153             : 
   13154       10701 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   13155       10701 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   13156             : 
   13157             :     // Initialize this gas cooler for this time step
   13158       10701 :     ActualFanPower = 0.0;
   13159       10701 :     TotalCondDefrostCreditLocal = 0.0;
   13160       10701 :     TotalLoadFromSystems = 0.0;
   13161       10701 :     int GasCoolerID = this->GasCoolerNum(1);
   13162       10701 :     auto &cooler = GasCooler(GasCoolerID);
   13163       10701 :     RatedFanPower = cooler.RatedFanPower;
   13164       10701 :     FanMinAirFlowRatio = cooler.FanMinAirFlowRatio;
   13165       10701 :     GasCoolerCreditWarnIndex = cooler.GasCoolerCreditWarnIndex;
   13166             : 
   13167       21402 :     for (int Sysloop = 1; Sysloop <= cooler.NumSysAttach; ++Sysloop) {
   13168       10701 :         int SystemID = cooler.SysNum(Sysloop);
   13169       10701 :         TotalCondDefCredfromSysID = TransSystem(SystemID).TotalCondDefrostCredit;
   13170       10701 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   13171       10701 :         TotalLoadFromSysID = TransSystem(SystemID).TotalSystemLoadLT + TransSystem(SystemID).TotalSystemLoadMT +
   13172       10701 :                              TransSystem(SystemID).TotCompPowerLP + TransSystem(SystemID).TotCompPowerHP + TransSystem(SystemID).PipeHeatLoadLT +
   13173       10701 :                              TransSystem(SystemID).PipeHeatLoadMT;
   13174       10701 :         TotalLoadFromSystems += TotalLoadFromSysID;
   13175       10701 :         if (SystemID == SysNum) TotalLoadFromThisSystem = TotalLoadFromSysID;
   13176             :     } // Sysloop over every system connected to this gas cooler
   13177             : 
   13178             :     // Calculate Total Heat rejection needed.
   13179       10701 :     cooler.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13180       10701 :     cooler.TotalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13181       10701 :     TotalGasCoolerHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal;
   13182             : 
   13183       10701 :     if (TotalGasCoolerHeat < 0.0) {
   13184           0 :         TotalGasCoolerHeat = 0.0;
   13185           0 :         if (!state.dataGlobal->WarmupFlag)
   13186           0 :             ShowRecurringWarningErrorAtEnd(state,
   13187           0 :                                            "Refrigeration:TranscriticalSystem: " + this->Name +
   13188             :                                                ":heat reclaimed (defrost,other purposes) is greater than current gas cooler load. ASHRAE rule of "
   13189             :                                                "thumb: <= 25% of the load on a system should be in defrost at the same time. Consider "
   13190             :                                                "diversifying defrost schedules.",
   13191             :                                            GasCoolerCreditWarnIndex);
   13192             :     } // total gas cooler heat < 0
   13193             : 
   13194             :     // The rated capacity of air-cooled gas cooler was adjusted for elevation in get input step
   13195       10701 :     Real64 CapFac = TotalGasCoolerHeat / cooler.RatedCapacity;
   13196             :     // See whether gas cooler is at ground level or if other air conditions (ie node) have been specified.
   13197             :     // Note that air-cooled gas coolers can draw air from, and reject heat to, a conditioned zone.
   13198       10701 :     if (cooler.InletAirNodeNum != 0) {
   13199           0 :         OutDbTemp = state.dataLoopNodes->Node(cooler.InletAirNodeNum).Temp;
   13200             :     } else {
   13201       10701 :         OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   13202             :     }
   13203             :     // Determine gas cooler outlet temperature and pressure
   13204             :     // Transcritical:  Gas cooler outlet temperature based on ambient temperature and approach temperature.
   13205             :     //                 Determine optimum gas cooler pressure to maximize COP.
   13206             :     // Subcritical:  Allow condensing temperature and pressure to float between minimum condensing temperature and
   13207             :     //               transition temperature.
   13208       10701 :     if (OutDbTemp > cooler.TransitionTemperature) { // Gas cooler in transcritical operation
   13209        4375 :         cooler.TGasCoolerOut = OutDbTemp + cooler.GasCoolerApproachT;
   13210        4375 :         cooler.PGasCoolerOut = 1.0e5 * (2.3083 * state.dataEnvrn->OutDryBulbTemp + 11.9);
   13211        4375 :         if (cooler.PGasCoolerOut < 7.5e6) { // Ensure gas cooler pressure is at least 7.5 MPa for transcritical operation
   13212         427 :             cooler.PGasCoolerOut = 7.5e6;
   13213             :         }
   13214        4375 :         cooler.HGasCoolerOut = FluidProperties::GetSupHeatEnthalpyRefrig(
   13215        4375 :             state, this->RefrigerantName, cooler.TGasCoolerOut, cooler.PGasCoolerOut, this->RefIndex, RoutineName);
   13216        4375 :         cooler.TransOpFlag = true;
   13217             :     } else { // Gas cooler in subcritical operation
   13218        6326 :         cooler.TGasCoolerOut = OutDbTemp + cooler.SubcriticalTempDiff;
   13219        6326 :         if (cooler.TGasCoolerOut > 30.978) { //  Gas temperature should be less than critical temperature
   13220        1966 :             cooler.PGasCoolerOut = 7.2e6;    //  Fix the pressure to be subcritical
   13221        1966 :             cooler.TGasCoolerOut =
   13222        1966 :                 FluidProperties::GetSatTemperatureRefrig(state, this->RefrigerantName, cooler.PGasCoolerOut, this->RefIndex, RoutineName);
   13223        4360 :         } else if (cooler.TGasCoolerOut > cooler.MinCondTemp) { //  Allow condensing temperature to float above the minimum
   13224        4360 :             cooler.PGasCoolerOut =
   13225        4360 :                 FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, cooler.TGasCoolerOut, this->RefIndex, RoutineName);
   13226             :         } else { //  Don't allow condensing temperature to drop below minimum
   13227           0 :             cooler.TGasCoolerOut = cooler.MinCondTemp;
   13228           0 :             cooler.PGasCoolerOut =
   13229           0 :                 FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, cooler.TGasCoolerOut, this->RefIndex, RoutineName);
   13230             :         }
   13231        6326 :         cooler.HGasCoolerOut =
   13232        6326 :             FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, cooler.TGasCoolerOut, 0.0, this->RefIndex, RoutineName);
   13233        6326 :         cooler.TransOpFlag = false;
   13234             :     } // (OutDbTemp > TransitionTemperature)
   13235             : 
   13236       10701 :     if (cooler.TGasCoolerOut < 30.978) {
   13237        7126 :         cooler.CpGasCoolerOut =
   13238        7126 :             FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, cooler.TGasCoolerOut, 0.0, this->RefIndex, RoutineName);
   13239             :     } else {
   13240        3575 :         cooler.CpGasCoolerOut = 0.0;
   13241             :     }
   13242             : 
   13243             :     // Gas cooler fan energy calculations
   13244       10701 :     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   13245             : 
   13246       10701 :     switch (cooler.FanSpeedControlType) {
   13247           0 :     case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   13248           0 :         FanPowerRatio = std::pow(AirVolRatio, 2.5);
   13249           0 :         ActualFanPower = FanPowerRatio * RatedFanPower;
   13250           0 :     } break;
   13251       10701 :     case FanSpeedCtrlType::ConstantSpeed: {
   13252       10701 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13253       10701 :     } break;
   13254           0 :     case FanSpeedCtrlType::ConstantSpeedLinear: {
   13255           0 :         ActualFanPower = AirVolRatio * RatedFanPower;
   13256           0 :     } break;
   13257           0 :     case FanSpeedCtrlType::TwoSpeed: {
   13258             :         // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   13259             :         // 1/2 speed corresonds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   13260             :         // dampers are used to control flow within those two ranges as in FanConstantSpeed
   13261           0 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13262           0 :         if (CapFac < CapFac60Percent) ActualFanPower = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13263           0 :     } break;
   13264           0 :     default:
   13265           0 :         break;
   13266             :     } // fan speed control type
   13267             : 
   13268       10701 :     cooler.ActualFanPower = ActualFanPower;
   13269       10701 :     cooler.FanElecEnergy = ActualFanPower * LocalTimeStep * Constant::SecInHour;
   13270       10701 :     cooler.GasCoolerLoad = TotalGasCoolerHeat;
   13271       10701 :     cooler.GasCoolerEnergy = TotalGasCoolerHeat * LocalTimeStep * Constant::SecInHour;
   13272       10701 :     cooler.GasCoolerCreditWarnIndex = GasCoolerCreditWarnIndex;
   13273       10701 :     cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour;
   13274       10701 :     cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * LocalTimeStep * Constant::SecInHour;
   13275       10701 :     this->NetHeatRejectLoad = TotalGasCoolerHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   13276       10701 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * LocalTimeStep * Constant::SecInHour;
   13277       10701 : }
   13278             : 
   13279    28256728 : void RefrigSystemData::CalculateCompressors(EnergyPlusData &state)
   13280             : {
   13281             : 
   13282             :     // SUBROUTINE INFORMATION:
   13283             :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   13284             :     //       DATE WRITTEN   Spring 2008
   13285             :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   13286             :     //       RE-ENGINEERED  na
   13287             : 
   13288             :     // PURPOSE OF THIS SUBROUTINE:
   13289             :     // Find the Compressor power, energy, capacity, and efficiency for a particular detailed
   13290             :     // refrigeration system.  Routine is capable of modeling single-stage and two-stage
   13291             :     // compression refrigeration systems.
   13292             : 
   13293             :     // METHODOLOGY EMPLOYED:
   13294             :     // USe ARI compressor performance curves, the evaporating temperature and condensing temperature
   13295             : 
   13296             :     // REFERENCES:
   13297             :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   13298             :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   13299             : 
   13300             :     // ARI Standard 540, 2004, Standard for Performance Rating of Positive Displacement Refrigerant
   13301             :     //  Compressors and Compressor Units, Air-Conditioning & Refrigeration Institute,Arlington VA
   13302             : 
   13303             :     // SUBROUTINE PARAMETER DEFINITIONS:
   13304             :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c, future allow input?
   13305             :     //   May want to allow input to reflect larger pipes selected to reduce delta P and increase compressor efficiency.
   13306             :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   13307    28256728 :     Real64 constexpr DelTSuctPipes(1.0);  // Tsat drop corresponding to P drop in suction pipes, ASHRAE 2006 p 2.4 (C)
   13308    28256728 :     Real64 constexpr DelTDischPipes(0.5); // Tsat drop corresponding to P drop in discharge pipes, ASHRAE 2006 p 2.5 (C)
   13309             : 
   13310             :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateCompressors");
   13311             :     Real64 CaseEnthalpyChangeRated;   // Enthalpy change in cases at compressor rated cond, J/kg
   13312             :     Real64 CapacityCorrection;        // Capacity at existing subcool/superheat over cap at rated conditions
   13313             :     Real64 CpSatVapCondense;          // Specific heat of vapor at cond temp J/kg-C
   13314             :     Real64 DensityRated;              // Density of inlet gas at rated superheat, m3/kg
   13315             :     Real64 DensityActual;             // Density of superheated gas at compressor inlet, m3/kg
   13316    28256728 :     Real64 HCompInRated(0.0);         // Enthalpy entering compressor at rated superheat, J/kg //Autodesk:Init
   13317    28256728 :     Real64 HCaseInRated(0.0);         // Enthalpy entering cases at rated subcooling, J/kg //Autodesk:Init
   13318             :     Real64 HSatVapCondense;           // Enthalpy of saturated vapor at T condense, J/kg
   13319             :     Real64 HsatVaporforTevapneeded;   // Enthalpy saturated vapor at temperature needed at evaporator
   13320             :     Real64 LFLastComp;                // Load factor for last compressor dispatched
   13321             :     Real64 MassCorrection;            // Mass flow at existing subcool/superheat over cap at rated conditions
   13322             :     Real64 NeededCapacity;            // Sum of case loads and mech subcooler loads on suction group
   13323             :     Real64 PSuction;                  // Suction Pressure
   13324             :     Real64 PCond;                     // Condensing pressure
   13325             :     Real64 PEvap;                     // Evaporating pressure
   13326             :     Real64 TCompOutEstimate;          // Estimated temperature out of the compressor, used to flag whether heat reclaim is reasonable, C
   13327    28256728 :     Real64 TempInRated(0.0);          // Temperature entering compressor at rated superheat, C //Autodesk:Init
   13328             :     Real64 TotalEnthalpyChangeActual; // Actual enthalpy change in cases and cold side of LSHX, J/kg
   13329             :     Real64 TsatforPsuct;              // Tsat for PSuction, C
   13330    28256728 :     Real64 TsatforPdisch(0.0);        // Tsat for Pdischarge, c
   13331             :     int NumComps;                     // Number of low-stage or high-stage compressors in system
   13332             :     Real64 HHiStageCompIn;            // Enthalpy at inlet of high-stage compressor (J/kg)
   13333    28256728 :     Real64 HCaseInRated_base(0.0), HCompInRated_base(0.0); // Autodesk:Tuned Intermediate values for performance tuning
   13334             : 
   13335    28256728 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13336    28256728 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13337             : 
   13338    28256728 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   13339    28256728 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   13340    28256728 :     Real64 const LocalTimeStepSec(LocalTimeStep * Constant::SecInHour);
   13341             : 
   13342    28256728 :     int CondID = this->CondenserNum(1);
   13343    28256728 :     auto const &Condenser1 = Condenser(CondID);
   13344    28256728 :     Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / LocalTimeStepSec)); // Load due to previously unmet compressor loads
   13345    28256728 :     Real64 const NeededCapacity_base(this->TotalSystemLoad + AccumLoad + this->PipeHeatLoad + this->LSHXTrans);
   13346             : 
   13347             :     // Before dispatching compressors, zero sum of compressor outputs and zero each compressor
   13348    28256728 :     this->TotCompCapacity = 0.0;
   13349    28256728 :     this->RefMassFlowComps = 0.0;
   13350    28256728 :     this->TotCompPower = 0.0;
   13351    28256728 :     if (this->NumStages == 2) {
   13352       14160 :         this->TotHiStageCompCapacity = 0.0;
   13353       14160 :         this->RefMassFlowHiStageComps = 0.0;
   13354       14160 :         this->TotHiStageCompPower = 0.0;
   13355             :     }
   13356             : 
   13357   241313473 :     for (int CompIndex = 1; CompIndex <= this->NumCompressors; ++CompIndex) {
   13358   213056745 :         int CompID = this->CompressorNum(CompIndex);
   13359   213056745 :         auto &compressor = Compressor(CompID);
   13360   213056745 :         compressor.Power = 0.0;
   13361   213056745 :         compressor.MassFlow = 0.0;
   13362   213056745 :         compressor.Capacity = 0.0;
   13363   213056745 :         compressor.ElecConsumption = 0.0;
   13364   213056745 :         compressor.CoolingEnergy = 0.0;
   13365   213056745 :         compressor.LoadFactor = 0.0;
   13366             :     }
   13367    28256728 :     if (this->NumStages == 2) {
   13368       70800 :         for (int CompIndex = 1; CompIndex <= this->NumHiStageCompressors; ++CompIndex) {
   13369       56640 :             int CompID = this->HiStageCompressorNum(CompIndex);
   13370       56640 :             auto &compressor = Compressor(CompID);
   13371       56640 :             compressor.Power = 0.0;
   13372       56640 :             compressor.MassFlow = 0.0;
   13373       56640 :             compressor.Capacity = 0.0;
   13374       56640 :             compressor.ElecConsumption = 0.0;
   13375       56640 :             compressor.CoolingEnergy = 0.0;
   13376       56640 :             compressor.LoadFactor = 0.0;
   13377             :         }
   13378             :     }
   13379             : 
   13380             :     // Determine properties at case inlet and compressor inlet
   13381    56527616 :     for (int StageIndex = 1; StageIndex <= min(2, this->NumStages); ++StageIndex) {
   13382    28270888 :         if (StageIndex == 1) {                                    // Do single-stage or low-stage calculations
   13383    28256728 :             if (this->NumStages == 1) {                           // Single-stage system
   13384    28242568 :                 NeededCapacity = NeededCapacity_base;             // because compressor capacity rated from txv to comp inlet
   13385    28242568 :                 TsatforPdisch = this->TCondense + DelTDischPipes; // need (Psat of (Tcond + delT corresponding to delP disch Pipes))
   13386    28242568 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes; // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13387             :                 HsatVaporforTevapneeded =
   13388    28242568 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TEvapNeeded, 1.0, this->RefIndex, RoutineName);
   13389    28242568 :                 this->HSatLiqCond =
   13390    28242568 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   13391    28242568 :                 this->CpSatLiqCond =
   13392    28242568 :                     FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   13393             :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   13394             :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   13395             :                 // Calculate both here unless set previously by subcooler subroutine
   13396             :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   13397             :                 // future - visit how parameter 'casesuperheat' applies when using walk-ins or transfer loads
   13398    28242568 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   13399    28217680 :                     this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13400    28217680 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13401    28217680 :                     this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool;
   13402    28217680 :                     this->HCompIn = this->HCaseOut;
   13403             :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   13404       24888 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   13405             :                 } // whether or not subcooler routine used
   13406    28242568 :                 PSuction = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, TsatforPsuct, this->RefIndex, RoutineName);
   13407    28242568 :                 NumComps = this->NumCompressors;
   13408             :             } else { // Low-stage side of two-stage system
   13409       14160 :                 PCond = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, this->TCondense, this->RefIndex, RoutineName);
   13410       14160 :                 PEvap = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, this->TEvapNeeded, this->RefIndex, RoutineName);
   13411       14160 :                 this->PIntercooler = std::sqrt(PCond * PEvap);
   13412       14160 :                 this->TIntercooler =
   13413       14160 :                     FluidProperties::GetSatTemperatureRefrig(state, this->RefrigerantName, this->PIntercooler, this->RefIndex, RoutineName);
   13414       14160 :                 NeededCapacity = NeededCapacity_base;                // because compressor capacity rated from txv to comp inlet
   13415       14160 :                 TsatforPdisch = this->TIntercooler + DelTDischPipes; // need (Psat of (Tinter + delT corresponding to delP disch Pipes))
   13416       14160 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes;    // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13417             :                 HsatVaporforTevapneeded =
   13418       14160 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TEvapNeeded, 1.0, this->RefIndex, RoutineName);
   13419       14160 :                 this->HSatLiqCond =
   13420       14160 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   13421       14160 :                 this->CpSatLiqCond =
   13422       14160 :                     FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   13423             :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   13424             :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   13425             :                 // Calculate both here unless set previously by subcooler subroutine
   13426             :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   13427       14160 :                 if (this->NumSubcoolers == 0) {       // No subcooler on this system
   13428       14160 :                     if (this->IntercoolerType == 1) { // Flash Intercooler
   13429        7080 :                         this->HCaseIn =
   13430        7080 :                             FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 0.0, this->RefIndex, RoutineName);
   13431        7080 :                         this->TLiqInActual = this->TIntercooler;
   13432        7080 :                     } else if (this->IntercoolerType == 2) { // Shell-and-Coil Intercooler
   13433        7080 :                         this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool -
   13434        7080 :                                              this->IntercoolerEffectiveness * (this->TCondense - Condenser1.RatedSubcool - this->TIntercooler);
   13435        7080 :                         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - this->TLiqInActual);
   13436             :                     }                                                  // IntercoolerType
   13437       14160 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13438       14160 :                     this->HCompIn = this->HCaseOut;
   13439             :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   13440           0 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   13441             :                 } // whether or not subcooler routine used
   13442       14160 :                 PSuction = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, TsatforPsuct, this->RefIndex, RoutineName);
   13443       14160 :                 NumComps = this->NumCompressors;
   13444             :             }    // NumStages
   13445             :         } else { // Two-stage system, high-stage side
   13446       14160 :             NeededCapacity = NeededCapacity_base + this->TotCompPower;
   13447       14160 :             TsatforPdisch = this->TCondense + DelTDischPipes;
   13448       14160 :             TsatforPsuct = this->TIntercooler;
   13449             :             HsatVaporforTevapneeded =
   13450       14160 :                 FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 1.0, this->RefIndex, RoutineName);
   13451             :             //                HSatLiqCond = FluidProperties::GetSatEnthalpyRefrig(state, RefrigerantName, TCondense, 0.0, RefIndex,
   13452             :             // RoutineName
   13453             :             //);
   13454             :             ////Autodesk:Tuned These don't change for 2nd stage
   13455             :             //                CpSatLiqCond = FluidProperties::GetSatSpecificHeatRefrig(RefrigerantName, TCondense, 0.0, RefIndex,
   13456             :             // RoutineName );
   13457             :             ////Autodesk:Tuned These don't change for 2nd stage
   13458       14160 :             this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13459       14160 :             this->TCompIn = this->TIntercooler;
   13460             :             //      System(SysNum)%TLiqInActual = System(SysNum)%TCondense-Condenser(System(SysNum)%CondenserNum(1))%RatedSubcool
   13461       14160 :             this->HCompIn = HsatVaporforTevapneeded;
   13462       14160 :             PSuction = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, TsatforPsuct, this->RefIndex, RoutineName);
   13463       14160 :             NumComps = this->NumHiStageCompressors;
   13464             :         } // StageIndex
   13465             : 
   13466             :         // dispatch compressors to meet load, note they were listed in compressor list in dispatch order
   13467    28270888 :         DensityActual = FluidProperties::GetSupHeatDensityRefrig(state,
   13468             :                                                                  this->RefrigerantName,
   13469             :                                                                  this->TCompIn,
   13470             :                                                                  PSuction,
   13471    28270888 :                                                                  this->RefIndex,
   13472             :                                                                  RoutineName); // Autodesk:Tuned Hoisted out of CompIndex loop
   13473    28270888 :         TotalEnthalpyChangeActual = this->HCompIn - this->HCaseIn;             // Autodesk:Tuned Hoisted out of CompIndex loop
   13474    28270888 :         if (this->NumStages == 2) {                                            // Autodesk:Tuned Hoisted out of CompIndex loop
   13475       28320 :             if (StageIndex == 1) {
   13476             :                 HCaseInRated_base =
   13477       14160 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 0.0, this->RefIndex, RoutineName);
   13478       14160 :             } else if (StageIndex == 2) {
   13479             :                 HCompInRated_base =
   13480       14160 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 1.0, this->RefIndex, RoutineName);
   13481             :             }
   13482             :         }
   13483    62448640 :         for (int CompIndex = 1; CompIndex <= NumComps; ++CompIndex) {
   13484             :             int CompID;
   13485    61908871 :             if (StageIndex == 1) {
   13486    61886227 :                 CompID = this->CompressorNum(CompIndex);
   13487             :             } else {
   13488       22644 :                 CompID = this->HiStageCompressorNum(CompIndex);
   13489             :             } // StageIndex
   13490    61908871 :             auto &compressor = Compressor(CompID);
   13491             : 
   13492             :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13493    61908871 :             switch (compressor.SubcoolRatingType) {
   13494    54847410 :             case CompRatingType::Subcooling: {
   13495    54847410 :                 if (this->NumStages == 1) { // Single-stage system
   13496    54802463 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13497       44947 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13498       22303 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * compressor.RatedSubcool;
   13499       22644 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13500       22644 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13501             :                 } // NumStages
   13502    54847410 :             } break;
   13503     7061461 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13504     7061461 :                 if (this->NumStages == 1) {           // Single-stage system
   13505     7061461 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   13506           0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13507           0 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * (this->TIntercooler - compressor.RatedSubcool);
   13508           0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13509           0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   13510             :                 } // NumStages
   13511     7061461 :             } break;
   13512           0 :             default:
   13513           0 :                 break;
   13514             :             } // Compressor SubcoolRatingType
   13515    61908871 :             switch (compressor.SuperheatRatingType) {
   13516    61387496 :             case CompRatingType::Superheat: {
   13517    61387496 :                 if (this->NumStages == 1) { // Single-stage system
   13518    61365193 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13519    61365193 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   13520       22303 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13521       22303 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13522       22303 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   13523           0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13524           0 :                     HCompInRated = HCompInRated_base + this->CpSatVapEvap * compressor.RatedSuperheat;
   13525           0 :                     TempInRated = this->TIntercooler + compressor.RatedSuperheat;
   13526             :                 } // NumStages
   13527    61387496 :             } break;
   13528      521375 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13529      521375 :                 if (this->NumStages == 1) {              // Single-stage system
   13530      498731 :                     TempInRated = compressor.RatedSuperheat;
   13531      498731 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   13532       22644 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13533           0 :                     TempInRated = compressor.RatedSuperheat;
   13534           0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   13535       22644 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13536       22644 :                     TempInRated = compressor.RatedSuperheat;
   13537       22644 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TIntercooler);
   13538             :                 } // NumStages
   13539      521375 :             } break;
   13540           0 :             default:
   13541           0 :                 break;
   13542             :             } // Compressor SuperheatRatingType
   13543             : 
   13544    61908871 :             CaseEnthalpyChangeRated = HCompInRated - HCaseInRated;
   13545    61908871 :             DensityRated = FluidProperties::GetSupHeatDensityRefrig(state, this->RefrigerantName, TempInRated, PSuction, this->RefIndex, RoutineName);
   13546             :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13547             :             //  the increase in capacity due to extra subcooling
   13548    61908871 :             MassCorrection = DensityActual / DensityRated;
   13549    61908871 :             CapacityCorrection = MassCorrection * TotalEnthalpyChangeActual / CaseEnthalpyChangeRated;
   13550    61908871 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsuct, TsatforPdisch);
   13551    61908871 :             compressor.Capacity = CapacityCorrection * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsuct, TsatforPdisch);
   13552    61908871 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActual;
   13553             : 
   13554             :             // calculate load factor for last compressor addded
   13555             :             // assumes either cycling or part load eff = full load eff for last compressor
   13556    61908871 :             if (StageIndex == 1) { // Single-stage or low-stage compressors
   13557    61886227 :                 if ((this->TotCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13558    27716959 :                     LFLastComp = (NeededCapacity - this->TotCompCapacity) / compressor.Capacity;
   13559    27716959 :                     compressor.Power *= LFLastComp;
   13560    27716959 :                     compressor.MassFlow *= LFLastComp;
   13561    27716959 :                     compressor.Capacity *= LFLastComp;
   13562    27716959 :                     this->TotCompCapacity += compressor.Capacity;
   13563    27716959 :                     this->RefMassFlowComps += compressor.MassFlow;
   13564    27716959 :                     this->TotCompPower += compressor.Power;
   13565    27716959 :                     compressor.ElecConsumption = compressor.Power * LocalTimeStepSec;
   13566    27716959 :                     compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec;
   13567    27716959 :                     compressor.LoadFactor = LFLastComp;
   13568    27716959 :                     break; // numcomps do
   13569             :                 } else {   //>= needed capacity
   13570    34169268 :                     this->TotCompCapacity += compressor.Capacity;
   13571    34169268 :                     this->RefMassFlowComps += compressor.MassFlow;
   13572    34169268 :                     this->TotCompPower += compressor.Power;
   13573             :                 }    //>= needed capacity
   13574             :             } else { // high-stage compressors (for two-stage systems only)
   13575       22644 :                 if ((this->TotHiStageCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13576       14160 :                     LFLastComp = (NeededCapacity - this->TotHiStageCompCapacity) / compressor.Capacity;
   13577       14160 :                     compressor.Power *= LFLastComp;
   13578       14160 :                     compressor.MassFlow *= LFLastComp;
   13579       14160 :                     compressor.Capacity *= LFLastComp;
   13580       14160 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13581       14160 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13582       14160 :                     this->TotHiStageCompPower += compressor.Power;
   13583       14160 :                     this->FlowRatioIntercooler = this->RefMassFlowComps / this->RefMassFlowHiStageComps;
   13584       14160 :                     compressor.ElecConsumption = compressor.Power * LocalTimeStepSec;
   13585       14160 :                     compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec;
   13586       14160 :                     compressor.LoadFactor = LFLastComp;
   13587       14160 :                     break; // numcomps do
   13588             :                 } else {   //>= needed capacity
   13589        8484 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13590        8484 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13591        8484 :                     this->TotHiStageCompPower += compressor.Power;
   13592             :                 } //>= needed capacity
   13593             :             }     // StageIndex
   13594    34177752 :             compressor.ElecConsumption = compressor.Power * LocalTimeStepSec;
   13595    34177752 :             compressor.CoolingEnergy = compressor.Capacity * LocalTimeStepSec;
   13596    34177752 :             compressor.LoadFactor = 1.0;
   13597             :         } // NumComps
   13598             :     }
   13599             : 
   13600             :     // Calculate enthalpy at compressor discharge
   13601    28256728 :     if (this->NumStages == 1) { // Single-stage or low-stage compressors
   13602    28242568 :         this->HCompOut = this->HCompIn + this->TotCompPower / this->RefMassFlowComps;
   13603             :         // error found 9/19/2011, was System(SysNum)%TotCompPower*LocalTimeStep*DataGlobals::SecInHour/System(SysNum)%RefMassFlowComps
   13604             :     } else { // High-stage compressors (only for two-stage systems)
   13605       14160 :         HHiStageCompIn = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 1.0, this->RefIndex, RoutineName);
   13606       14160 :         this->HCompOut = HHiStageCompIn + this->TotHiStageCompPower / this->RefMassFlowHiStageComps;
   13607             :     }
   13608             : 
   13609             :     // Calculate superheat energy available for desuperheaters
   13610    28256728 :     HSatVapCondense = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 1.0, this->RefIndex, RoutineName);
   13611    28256728 :     CpSatVapCondense = FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 1.0, this->RefIndex, RoutineName);
   13612    28256728 :     if (this->NumStages == 1) { // Single-stage systems
   13613    28242568 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowComps * (this->HCompOut - HSatVapCondense);
   13614             :     } else { // Two-stage systems
   13615       14160 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowHiStageComps * (this->HCompOut - HSatVapCondense);
   13616             :     } // NumStages
   13617             : 
   13618             :     // No function available to get Tout as f(Pout, Hout), so use estimate based on constant cp in superheat range...
   13619             :     //  Use average of Tcondense and Tout of condenser as check for whether heat reclaim is reasonable.
   13620    28256728 :     TCompOutEstimate = this->TCondense + (this->HCompOut - HSatVapCondense) / CpSatVapCondense;
   13621             : 
   13622    28256728 :     state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailTemperature = (TsatforPdisch + TCompOutEstimate) / 2.0;
   13623    28256728 :     this->AverageCompressorCOP = this->TotCompCapacity / (this->TotCompPower + this->TotHiStageCompPower);
   13624    28256728 :     this->TotCompElecConsump = this->TotCompPower * LocalTimeStepSec;
   13625    28256728 :     if (this->NumStages == 2) {
   13626       14160 :         this->TotHiStageCompElecConsump = this->TotHiStageCompPower * LocalTimeStepSec;
   13627       14160 :         this->TotCompElecConsumpTwoStage = this->TotCompElecConsump + this->TotHiStageCompElecConsump;
   13628             :     }
   13629    28256728 :     this->TotCompCoolingEnergy = this->TotCompCapacity * LocalTimeStepSec;
   13630    28256728 :     this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * LocalTimeStepSec;
   13631    28256728 : }
   13632             : 
   13633       10701 : void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state)
   13634             : {
   13635             : 
   13636             :     // SUBROUTINE INFORMATION:
   13637             :     //       AUTHOR         Brian A. Fricke, ORNL
   13638             :     //       DATE WRITTEN   Fall 2011
   13639             :     //       RE-ENGINEERED  na
   13640             : 
   13641             :     // PURPOSE OF THIS SUBROUTINE:
   13642             :     // Find the compressor power, energy, capacity, and efficiency for a detailed transcritical CO2
   13643             :     // refrigeration system.
   13644             : 
   13645             :     // METHODOLOGY EMPLOYED:
   13646             :     // Use AHRI compressor performance curves for subcritical compressor operation, AHRI-style compressor
   13647             :     // performance curves for transcritical compressor operation, the evaporating temperature of the
   13648             :     // medium- and low-temperature loads, and the gas cooler outlet conditions (temperature, pressure
   13649             :     // and enthalpy).
   13650             : 
   13651             :     // REFERENCES:
   13652             :     // ANSI/AHRI. 2004. Standard 540, Standard for Performance Rating of Positive Displacement Refrigerant
   13653             :     //     Comprssors and Compressor Units. Arlington, VA: Air-Conditioning, Heating, and Refrigeration
   13654             :     //     Institute.
   13655             :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13656             :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   13657             :     //     Journal of Refrigeration 34: 527-539.
   13658             :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13659             :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   13660             :     //     Refrigeration 34: 540-549.
   13661             :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13662             :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   13663             :     //     Refrigeration 31: 516-524.
   13664             :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13665             :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   13666             :     //     Refrigeration 31: 525-534.
   13667             : 
   13668             :     // SUBROUTINE PARAMETER DEFINITIONS:
   13669             :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c.
   13670             :     // For the same pressure drop, CO2 has a corresponding temperature penalty 5 to 10 times smaller than
   13671             :     // ammonia and R-134a (ASHRAE Handbook of Refrigeration, 2010, p. 3.7).  Ignore pressure drop for CO2 calculations.
   13672             :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   13673             : 
   13674       10701 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   13675             : 
   13676             :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateTransCompressors");
   13677             :     int Iter;                           // Iteration counter
   13678             :     Real64 CapacityCorrectionMT;        // Capacity at existing subcool/superheat over cap at rated conditions for MT loads
   13679             :     Real64 CaseEnthalpyChangeRatedMT;   // Enthalpy change in medium temperature cases at compressor rated cond, J/kg
   13680             :     Real64 CaseEnthalpyChangeRatedLT;   // Enthalpy change in low temperature cases at compressor rated cond, J/kg
   13681             :     Real64 DensityActualLT;             // Density of superheated gas at LP compressor inlet, m3/kg
   13682             :     Real64 DensityActualMT;             // Density of superheated gas at HP compressor inlet, m3/kg
   13683             :     Real64 DensityRatedHP;              // Density of high pressure compressor inlet gas at rated superheat, m3/kg
   13684             :     Real64 DensityRatedLP;              // Density of low pressure compressor inlet gas at rated superheat, m3/kg
   13685             :     Real64 HCaseInRatedLT;              // Enthalpy entering low temperature cases at rated subcooling, J/kg
   13686             :     Real64 HCaseInRatedMT;              // Enthalpy entering medium temperature cases at rated subcooling, J/kg
   13687       10701 :     Real64 HCompInRatedHP(0.0);         // Enthalpy entering high pressure compressor at rated superheat, J/kg
   13688             :     Real64 HCompInRatedLP;              // Enthalpy entering low pressure compressor at rated superheat, J/kg
   13689             :     Real64 HGCOutlet;                   // Enthalpy at gas cooler outlet, J/kg
   13690             :     Real64 HIdeal;                      // Ideal enthalpy at subcooler (for 100% effectiveness)
   13691             :     Real64 HsatLiqforTevapNeededMT;     // Enthalpy of saturated liquid at MT evaporator, J/kg
   13692             :     Real64 HsatVaporforTevapneededMT;   // Enthlapy of saturated vapor at MT evaporator (transcritical cycle), J/kg
   13693             :     Real64 HsatVaporforTevapneededLT;   // Enthlapy of saturated vapor at LT evaporator (transcritical cycle), J/kg
   13694             :     Real64 LFLastComp;                  // Load factor for last compressor dispatched
   13695             :     Real64 MassCorrectionLT;            // Mass flow at existing subcool/superheat over cap at rated conditions for LT loads
   13696             :     Real64 MassCorrectionMT;            // Mass flow at existing subcool/superheat over cap at rated conditions for MT loads
   13697             :     Real64 NeededCapacityLT;            // Sum of LT case loads and mech subcooler loads (transcritical cycle), W
   13698             :     Real64 NeededCapacityMT;            // Sum of MT case loads and mech subcooler loads (transcritical cycle), W
   13699             :     Real64 PSuctionLT;                  // Suction pressure in low temperature cases, Pa
   13700             :     Real64 PSuctionMT;                  // Suction pressure in medium temperature cases, Pa
   13701             :     Real64 PGCOutlet;                   // Gas cooler outlet pressure, Pa
   13702       10701 :     Real64 QualityReceiver(0.0);        // Refrigerant quality in the receiver
   13703             :     Real64 SubcoolEffect;               // Heat exchanger effectiveness of the subcooler
   13704             :     Real64 TempInRatedHP;               // Temperature entering high pressure compressor at rated superheat, C
   13705             :     Real64 TempInRatedLP;               // Temperature entering low pressure compressor at rated superheat, C
   13706             :     Real64 TsatforPdisLT;               // Low temperature saturated discharge temperature (transcritical cycle), C
   13707             :     Real64 TsatforPdisMT;               // Medium temperature saturated discharge temperature (transcritical cycle), C
   13708             :     Real64 TsatforPsucLT;               // Low temperature saturated suction temperature (transcritical cycle), C
   13709             :     Real64 TsatforPsucMT;               // Medium temperature saturated suction temperature (transcritical cycle), C
   13710             :     Real64 TSubcoolerColdIn;            // Suction gas temperature at the inlet of the subcooler, C
   13711             :     Real64 TotalEnthalpyChangeActualLT; // Actual enthalpy change in LT cases, J/kg
   13712             :     Real64 TotalEnthalpyChangeActualMT; // Actual enthalpy change in MT cases, J/kg
   13713             :     Real64 TotalRefMassFlow;            // Total mass flow through high pressure side of system, kg/s
   13714             :     Real64 Xu;                          // Initial upper guess for iterative search
   13715             :     Real64 Xl;                          // Initial lower guess for iterative search
   13716       10701 :     Real64 Xnew(0.0);                   // New guess for iterative search
   13717             : 
   13718       10701 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13719       10701 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13720             : 
   13721       10701 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   13722       10701 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   13723             : 
   13724             :     // Determine refrigerating capacity needed
   13725             :     // Load due to previously unmet low temperature compressor loads (transcritical system)
   13726             :     Real64 AccumLoadLT;
   13727       10701 :     NeededCapacityLT = 0.0;
   13728       10701 :     if (this->TransSysType == 2) {
   13729       10701 :         AccumLoadLT = max(0.0, (this->UnmetEnergyLT / LocalTimeStep / Constant::SecInHour));
   13730       10701 :         NeededCapacityLT = this->TotalSystemLoadLT + AccumLoadLT + this->PipeHeatLoadLT;
   13731             :     } // (TransSystem(SysNum)%TransSysType == 2)
   13732             : 
   13733             :     // Load due to previously unmet medium temperature compressor loads (transcritical system)
   13734       10701 :     Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / LocalTimeStep / Constant::SecInHour));
   13735       10701 :     NeededCapacityMT = this->TotalSystemLoadMT + AccumLoadMT + this->PipeHeatLoadMT;
   13736             : 
   13737             :     // Determine refrigerant properties at receiver
   13738       10701 :     this->CpSatLiqReceiver =
   13739       10701 :         FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TReceiver, 0.0, this->RefIndex, RoutineName);
   13740             : 
   13741             :     // Enthalpy at the receiver bypass, J/kg
   13742       10701 :     Real64 HReceiverBypass = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TReceiver, 1.0, this->RefIndex, RoutineName);
   13743             : 
   13744             :     // Determine refrigerant properties at low temperature (LT) loads (if present)
   13745             :     // Dispatch low pressure (LP) compressors as necessary
   13746       10701 :     if (this->TransSysType == 2) { // LT side of TwoStage transcritical system
   13747       10701 :         this->HCaseInLT = this->HSatLiqReceiver;
   13748             :         // TCompInLP and HCompInLP include case superheat plus effect of suction line heat gain
   13749       10701 :         this->TCompInLP = this->TEvapNeededLT + TransCaseSuperheat + this->PipeHeatLoadLT / (this->CpSatVapEvapLT * this->RefMassFlowtoLTLoads);
   13750       10701 :         this->HCompInLP = this->HCaseOutLT + this->PipeHeatLoadLT / this->RefMassFlowtoLTLoads;
   13751       10701 :         TsatforPsucLT = this->TEvapNeededLT;
   13752       10701 :         TsatforPdisLT = this->TEvapNeededMT;
   13753             :         HsatVaporforTevapneededLT =
   13754       10701 :             FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TEvapNeededLT, 1.0, this->RefIndex, RoutineName);
   13755             :         HsatLiqforTevapNeededMT =
   13756       10701 :             FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TEvapNeededMT, 0.0, this->RefIndex, RoutineName);
   13757       10701 :         PSuctionLT = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, TsatforPsucLT, this->RefIndex, RoutineName);
   13758             :         DensityActualLT =
   13759       10701 :             FluidProperties::GetSupHeatDensityRefrig(state, this->RefrigerantName, this->TCompInLP, PSuctionLT, this->RefIndex, RoutineName);
   13760       10701 :         TotalEnthalpyChangeActualLT = this->HCompInLP - this->HCaseInLT;
   13761             : 
   13762             :         // Dispatch low pressure (LP) compressors
   13763             :         // Before dispatching LP compressors, zero sum of compressor outputs and zero each compressor
   13764       10701 :         this->TotCompCapacityLP = 0.0;
   13765       10701 :         this->RefMassFlowCompsLP = 0.0;
   13766       10701 :         this->TotCompPowerLP = 0.0;
   13767             : 
   13768       42804 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13769       32103 :             int CompID = this->CompressorNumLP(CompIndex);
   13770       32103 :             Compressor(CompID).Power = 0.0;
   13771       32103 :             Compressor(CompID).MassFlow = 0.0;
   13772       32103 :             Compressor(CompID).Capacity = 0.0;
   13773       32103 :             Compressor(CompID).ElecConsumption = 0.0;
   13774       32103 :             Compressor(CompID).CoolingEnergy = 0.0;
   13775       32103 :             Compressor(CompID).LoadFactor = 0.0;
   13776             :         }
   13777             : 
   13778       16140 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13779       16140 :             int CompID = this->CompressorNumLP(CompIndex);
   13780       16140 :             auto &compressor = Compressor(CompID);
   13781             :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13782       16140 :             switch (compressor.SubcoolRatingType) {
   13783       16140 :             case CompRatingType::Subcooling: {
   13784       16140 :                 HCaseInRatedLT = HsatLiqforTevapNeededMT - this->CpSatLiqReceiver * compressor.RatedSubcool;
   13785       16140 :             } break;
   13786           0 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13787             :                 HCaseInRatedLT =
   13788           0 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, compressor.RatedSubcool, 0.0, this->RefIndex, RoutineName);
   13789           0 :             } break;
   13790           0 :             default:
   13791           0 :                 break;
   13792             :             }
   13793       16140 :             switch (compressor.SuperheatRatingType) {
   13794       16140 :             case CompRatingType::Superheat: {
   13795       16140 :                 HCompInRatedLP = HsatVaporforTevapneededLT + this->CpSatVapEvapLT * compressor.RatedSuperheat;
   13796       16140 :                 TempInRatedLP = this->TEvapNeededLT + compressor.RatedSuperheat;
   13797       16140 :             } break;
   13798           0 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in
   13799             :                                                          // "CompRatingType::Superheat"
   13800           0 :                 TempInRatedLP = compressor.RatedSuperheat;
   13801           0 :                 HCompInRatedLP = FluidProperties::GetSupHeatEnthalpyRefrig(
   13802           0 :                     state, this->RefrigerantName, compressor.RatedSuperheat, PSuctionLT, this->RefIndex, RoutineName);
   13803           0 :             } break;
   13804           0 :             default:
   13805           0 :                 break;
   13806             :             }
   13807             : 
   13808       16140 :             CaseEnthalpyChangeRatedLT = HCompInRatedLP - HCaseInRatedLT;
   13809             :             DensityRatedLP =
   13810       16140 :                 FluidProperties::GetSupHeatDensityRefrig(state, this->RefrigerantName, TempInRatedLP, PSuctionLT, this->RefIndex, RoutineName);
   13811             : 
   13812             :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13813             :             //  the increase in capacity due to extra subcooling
   13814       16140 :             MassCorrectionLT = DensityActualLT / DensityRatedLP;
   13815             :             // Capacity at existing subcool/superheat over cap at rated conditions for LT loads
   13816       16140 :             Real64 CapacityCorrectionLT = MassCorrectionLT * TotalEnthalpyChangeActualLT / CaseEnthalpyChangeRatedLT;
   13817       16140 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13818       16140 :             compressor.Capacity = CapacityCorrectionLT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13819       16140 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActualLT;
   13820       16140 :             compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour;
   13821       16140 :             compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour;
   13822       16140 :             compressor.LoadFactor = 1.0;
   13823       16140 :             if ((this->TotCompCapacityLP + compressor.Capacity) >= NeededCapacityLT) {
   13824       10701 :                 LFLastComp = (NeededCapacityLT - this->TotCompCapacityLP) / compressor.Capacity;
   13825       10701 :                 compressor.Power *= LFLastComp;
   13826       10701 :                 compressor.MassFlow *= LFLastComp;
   13827       10701 :                 compressor.Capacity *= LFLastComp;
   13828       10701 :                 this->TotCompCapacityLP += compressor.Capacity;
   13829       10701 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13830       10701 :                 this->TotCompPowerLP += compressor.Power;
   13831       10701 :                 compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour;
   13832       10701 :                 compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour;
   13833       10701 :                 compressor.LoadFactor = LFLastComp;
   13834       10701 :                 break;
   13835             :             } else {
   13836        5439 :                 this->TotCompCapacityLP += compressor.Capacity;
   13837        5439 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13838        5439 :                 this->TotCompPowerLP += compressor.Power;
   13839             :             }
   13840             :         } // NumCompressorsLP
   13841       10701 :         this->HCompOutLP = this->HCompInLP + this->TotCompPowerLP / this->RefMassFlowCompsLP;
   13842             :     } // (TransSystem(SysNum)%TransSysType == 2)
   13843             : 
   13844             :     // Determine refrigerant properties at medium temperature (MT) loads
   13845             :     // Dispatch high pressure (HP) compressors as necessary
   13846       10701 :     TsatforPsucMT = this->TEvapNeededMT;
   13847       10701 :     if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Transcritical system is operating in transcritical region
   13848        4375 :         HGCOutlet = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13849             :     } else { // Transcritical system is operating in subcritical region
   13850        6326 :         TsatforPdisMT = GasCooler(this->GasCoolerNum(1)).TGasCoolerOut;
   13851             :     }
   13852       10701 :     PSuctionMT = FluidProperties::GetSatPressureRefrig(state, this->RefrigerantName, TsatforPsucMT, this->RefIndex, RoutineName);
   13853       10701 :     PGCOutlet = GasCooler(this->GasCoolerNum(1)).PGasCoolerOut;
   13854             :     HsatVaporforTevapneededMT =
   13855       10701 :         FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TEvapNeededMT, 1.0, this->RefIndex, RoutineName);
   13856       10701 :     this->HCaseInMT = this->HSatLiqReceiver;
   13857             :     // Enthalpy of refrigerant after leaving medium temperature loads and low pressure compressors
   13858             : 
   13859             :     // Combined enthalpy from the outlets of the LP compressor and MT loads, J/kg
   13860       10701 :     Real64 HCaseOutLTMT = (this->RefMassFlowtoLTLoads * this->HCompOutLP + this->RefMassFlowtoMTLoads * this->HCaseOutMT + this->PipeHeatLoadMT) /
   13861       10701 :                           (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13862             : 
   13863             :     // Total refrigerant flow rate is total flow from LT and MT loads divided by (1-x) where x is the quality of the
   13864             :     // refrigerant entering the receiver.  The receiver bypass flow rate is (x)*(Total Flow).
   13865             :     // Iterate to find the quality of the refrigerant entering the receiver.
   13866       10701 :     Xu = 1.0; // upper bound on quality
   13867       10701 :     Xl = 0.0; // lower bound on quality
   13868       10701 :     if ((GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis) > this->HSatLiqReceiver) {
   13869       80814 :         for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations to find receiver quality
   13870       80814 :             QualityReceiver = (Xu + Xl) / 2.0;
   13871             :             Real64 Hnew =
   13872       80814 :                 FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TReceiver, QualityReceiver, this->RefIndex, RoutineName);
   13873             : 
   13874             :             // estimated QualityReceiver is too high
   13875       80814 :             if (Hnew > (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) {
   13876       44582 :                 Xu = QualityReceiver;
   13877             :             } else { // estimated QualityReceiver is too low
   13878       36232 :                 Xl = QualityReceiver;
   13879             :             }
   13880       80814 :             if (std::abs((Hnew - (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) / Hnew) < ErrorTol) break;
   13881             :         }
   13882       10701 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) / (1.0 - QualityReceiver);
   13883       10701 :         this->RefMassFlowReceiverBypass = QualityReceiver * TotalRefMassFlow;
   13884             :     } else {
   13885           0 :         this->RefMassFlowReceiverBypass = 0.0;
   13886           0 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13887             :     } // %HGasCoolerOut > TransSystem(SysNum)%HSatLiqReceiver)
   13888             : 
   13889       10701 :     this->HCompInHP = (HCaseOutLTMT * (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) + HReceiverBypass * this->RefMassFlowReceiverBypass) /
   13890       10701 :                       (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads + this->RefMassFlowReceiverBypass);
   13891             : 
   13892             :     // Iterate to find the suction temperature entering subcooler
   13893       10701 :     Xl = FluidProperties::GetSatTemperatureRefrig(state, this->RefrigerantName, PSuctionMT, this->RefIndex, RoutineName);
   13894       10701 :     Xu = Xl + 50.0;
   13895       55697 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13896       55697 :         Xnew = (Xu + Xl) / 2.0;
   13897       55697 :         Real64 Hnew = FluidProperties::GetSupHeatEnthalpyRefrig(state, this->RefrigerantName, Xnew, PSuctionMT, this->RefIndex, RoutineName);
   13898       55697 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13899       30438 :             Xu = Xnew;
   13900             :         } else { // xnew is too low
   13901       25259 :             Xl = Xnew;
   13902             :         }
   13903       55697 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) break;
   13904             :     }
   13905       10701 :     TSubcoolerColdIn = Xnew;
   13906             : 
   13907             :     // Modify receiver inlet enthalpy and HP compressor inlet enthalpy to account for subcooler
   13908       10701 :     HIdeal = FluidProperties::GetSupHeatEnthalpyRefrig(
   13909       10701 :         state, this->RefrigerantName, GasCooler(this->GasCoolerNum(1)).TGasCoolerOut, PSuctionMT, this->RefIndex, RoutineName);
   13910             :     // Only use subcooler if suction gas inlet temperature less than gas cooler outlet temperature
   13911       10701 :     if (TSubcoolerColdIn < GasCooler(this->GasCoolerNum(1)).TGasCoolerOut) {
   13912       10701 :         SubcoolEffect = this->SCEffectiveness;
   13913             :     } else {
   13914           0 :         SubcoolEffect = 0.0;
   13915             :     } // (TSubcoolerColdIn < GasCooler(SysNum)%TGasCoolerOut)
   13916       10701 :     this->DelHSubcoolerSuc = SubcoolEffect * (HIdeal - this->HCompInHP);
   13917       10701 :     this->HCompInHP += this->DelHSubcoolerSuc;
   13918       10701 :     this->DelHSubcoolerDis = -this->DelHSubcoolerSuc;
   13919             : 
   13920             :     // Iterate to find the temperature at the inlet of the high pressure (HP) compressors
   13921       10701 :     Xl = FluidProperties::GetSatTemperatureRefrig(state, this->RefrigerantName, PSuctionMT, this->RefIndex, RoutineName);
   13922       10701 :     Xu = Xl + 50.0;
   13923       53149 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13924       53149 :         Xnew = (Xu + Xl) / 2.0;
   13925       53149 :         Real64 Hnew = FluidProperties::GetSupHeatEnthalpyRefrig(state, this->RefrigerantName, Xnew, PSuctionMT, this->RefIndex, RoutineName);
   13926       53149 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13927       22851 :             Xu = Xnew;
   13928             :         } else { // xnew is too low
   13929       30298 :             Xl = Xnew;
   13930             :         }
   13931       53149 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) break;
   13932             :     }
   13933       10701 :     this->TCompInHP = Xnew;
   13934             : 
   13935             :     //  For capacity correction of HP compressors, consider subcooler, receiver, MT loads, LT loads and LP compressors
   13936             :     //  to constitute the "load".  The actual and rated conditions at the exit of the gas cooler and the inlet of the
   13937             :     //  HP compressors are used for capacity correction calculations.
   13938             :     DensityActualMT =
   13939       10701 :         FluidProperties::GetSupHeatDensityRefrig(state, this->RefrigerantName, this->TCompInHP, PSuctionMT, this->RefIndex, RoutineName);
   13940       10701 :     TotalEnthalpyChangeActualMT = this->HCompInHP - GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13941             : 
   13942             :     // Dispatch HP compressors
   13943             :     // Before dispatching HP compressors, zero sum of compressor outputs and zero each compressor
   13944       10701 :     this->TotCompCapacityHP = 0.0;
   13945       10701 :     this->RefMassFlowCompsHP = 0.0;
   13946       10701 :     this->TotCompPowerHP = 0.0;
   13947             : 
   13948       42804 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13949       32103 :         int CompID = this->CompressorNumHP(CompIndex);
   13950       32103 :         auto &compressor = Compressor(CompID);
   13951       32103 :         compressor.Power = 0.0;
   13952       32103 :         compressor.MassFlow = 0.0;
   13953       32103 :         compressor.Capacity = 0.0;
   13954       32103 :         compressor.ElecConsumption = 0.0;
   13955       32103 :         compressor.CoolingEnergy = 0.0;
   13956       32103 :         compressor.LoadFactor = 0.0;
   13957             :     }
   13958             : 
   13959             :     // Dispatch High Pressure compressors to meet load, note they were listed in compressor list in dispatch order
   13960       12525 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13961       12525 :         int CompID = this->CompressorNumHP(CompIndex);
   13962       12525 :         auto &compressor = Compressor(CompID);
   13963             :         // Need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13964             :         // Transcritical operation requires rated superheat
   13965             :         // Subcritical operation requires rated subcool and rated superheat
   13966       12525 :         switch (compressor.SubcoolRatingType) {
   13967       12525 :         case CompRatingType::Subcooling: {
   13968       12525 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13969        6326 :                 HCaseInRatedMT =
   13970        6326 :                     GasCooler(this->GasCoolerNum(1)).HGasCoolerOut - GasCooler(this->GasCoolerNum(1)).CpGasCoolerOut * compressor.RatedSubcool;
   13971             :             } else { // Transcritical operation
   13972        6199 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13973             :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13974       12525 :         } break;
   13975           0 :         case CompRatingType::LiquidTemperature: {                // have rated liquid temperature stored in "RatedSubcool"
   13976           0 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13977             :                 HCaseInRatedMT =
   13978           0 :                     FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, compressor.RatedSubcool, 0.0, this->RefIndex, RoutineName);
   13979             :             } else { // Transcritical operation
   13980           0 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13981             :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13982           0 :         } break;
   13983           0 :         default:
   13984           0 :             break;
   13985             :         }
   13986       12525 :         switch (compressor.SuperheatRatingType) {
   13987       12525 :         case CompRatingType::Superheat: {
   13988       12525 :             HCompInRatedHP = HsatVaporforTevapneededMT + this->CpSatVapEvapMT * compressor.RatedSuperheat;
   13989       12525 :             TempInRatedHP = this->TEvapNeededMT + compressor.RatedSuperheat;
   13990       12525 :         } break;
   13991           0 :         case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13992           0 :             TempInRatedHP = compressor.RatedSuperheat;
   13993           0 :             HCompInRatedHP = FluidProperties::GetSupHeatEnthalpyRefrig(
   13994           0 :                 state, this->RefrigerantName, compressor.RatedSuperheat, PSuctionMT, this->RefIndex, RoutineName);
   13995           0 :         } break;
   13996           0 :         default:
   13997           0 :             break;
   13998             :         }
   13999             : 
   14000       12525 :         CaseEnthalpyChangeRatedMT = HCompInRatedHP - HCaseInRatedMT;
   14001             :         DensityRatedHP =
   14002       12525 :             FluidProperties::GetSupHeatDensityRefrig(state, this->RefrigerantName, TempInRatedHP, PSuctionMT, this->RefIndex, RoutineName);
   14003             :         //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   14004             :         //  the increase in capacity due to extra subcooling
   14005       12525 :         MassCorrectionMT = DensityActualMT / DensityRatedHP;
   14006       12525 :         CapacityCorrectionMT = MassCorrectionMT * TotalEnthalpyChangeActualMT / CaseEnthalpyChangeRatedMT;
   14007             : 
   14008       12525 :         if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // System is operating in transcritical region
   14009        6199 :             compressor.Power = Curve::CurveValue(state, compressor.TransElecPowerCurvePtr, TsatforPsucMT, PGCOutlet);
   14010        6199 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.TransCapacityCurvePtr, TsatforPsucMT, HGCOutlet);
   14011             :         } else { // System is operating in subcritical region
   14012        6326 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucMT, TsatforPdisMT);
   14013        6326 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucMT, TsatforPdisMT);
   14014             :         } // (GasCooler(SysNum)%TransOpFlag)
   14015             :         //  Mass flow through HP compressors is HP compressor refrigerating capacity divided by MT load, LT load and LP compressor power
   14016       12525 :         compressor.MassFlow = TotalRefMassFlow * compressor.Capacity / (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP);
   14017       12525 :         compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour;
   14018       12525 :         compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour;
   14019       12525 :         compressor.LoadFactor = 1.0;
   14020             :         // calculate load factor for last compressor added
   14021             :         // assumes either cycling or part load eff = full load eff for last compressor
   14022       12525 :         if ((this->TotCompCapacityHP + compressor.Capacity) >= (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP)) {
   14023       10701 :             LFLastComp = ((NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP) - this->TotCompCapacityHP) / compressor.Capacity;
   14024       10701 :             compressor.Power *= LFLastComp;
   14025       10701 :             compressor.MassFlow *= LFLastComp;
   14026       10701 :             compressor.Capacity *= LFLastComp;
   14027       10701 :             this->TotCompCapacityHP += compressor.Capacity;
   14028       10701 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   14029       10701 :             this->TotCompPowerHP += compressor.Power;
   14030       10701 :             compressor.ElecConsumption = compressor.Power * LocalTimeStep * Constant::SecInHour;
   14031       10701 :             compressor.CoolingEnergy = compressor.Capacity * LocalTimeStep * Constant::SecInHour;
   14032       10701 :             compressor.LoadFactor = LFLastComp;
   14033       10701 :             break;
   14034             :         } else {
   14035        1824 :             this->TotCompCapacityHP += compressor.Capacity;
   14036        1824 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   14037        1824 :             this->TotCompPowerHP += compressor.Power;
   14038             :         }
   14039             : 
   14040             :     } // NumCompressorsHP
   14041             : 
   14042       10701 :     this->HCompOutHP = this->HCompInHP + this->TotCompPowerHP / this->RefMassFlowCompsHP;
   14043       10701 :     this->RefMassFlowComps = this->RefMassFlowCompsLP + this->RefMassFlowCompsHP;
   14044       10701 :     this->TotCompCapacity = this->TotCompCapacityHP + this->TotCompCapacityLP;
   14045       10701 :     this->AverageCompressorCOP = (this->TotCompCapacityHP - this->TotCompPowerLP) / (this->TotCompPowerLP + this->TotCompPowerHP);
   14046       10701 :     this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * LocalTimeStep * Constant::SecInHour;
   14047       10701 :     this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * LocalTimeStep * Constant::SecInHour;
   14048       10701 : }
   14049             : 
   14050       24888 : void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state)
   14051             : {
   14052             : 
   14053             :     // SUBROUTINE INFORMATION:
   14054             :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   14055             :     //       DATE WRITTEN   Spring 2008
   14056             :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   14057             :     //       RE-ENGINEERED  na
   14058             : 
   14059             :     // PURPOSE OF THIS SUBROUTINE:
   14060             :     // Find the subcooler energy exchange and refrigerant states for a particular detailed
   14061             :     // refrigeration system. Use the refrigerant property subroutines in FluidProperties.cc
   14062             : 
   14063             :     // METHODOLOGY EMPLOYED:
   14064             :     // Use refrigerant properties and heat exchanger correlations.  NOTE:  Assumes any Mech subcooler
   14065             :     // immediately follows condenser outlet (after pipe loss) and comes before any LSHX
   14066             : 
   14067             :     // REFERENCES:
   14068             :     // ASHRAE 1006 Section 2: Refrigeration Accessories
   14069             : 
   14070             :     static constexpr std::string_view RoutineName = "CalculateSubcoolers";
   14071       24888 :     Real64 TLiqInActualLocal = 0.0; // Liquid T in, after condenser, before any mechanical subcooler
   14072             : 
   14073       24888 :     auto &System = state.dataRefrigCase->System;
   14074       24888 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14075       24888 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   14076             : 
   14077       24888 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   14078       24888 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   14079             : 
   14080             :     // HCaseIn has to be recalculated as the starting point for the subcoolers here because
   14081             :     //  of the multiple number of iterations through this subroutine and because Tcondense is evolving.
   14082       24888 :     if (this->NumStages == 1) { // Single-stage compression system
   14083       24888 :         this->HSatLiqCond = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14084       24888 :         this->CpSatLiqCond =
   14085       24888 :             FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14086       24888 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser(this->CondenserNum(1)).RatedSubcool;
   14087             : 
   14088             :         // Two-stage compression with flash intercooler
   14089           0 :     } else if (this->NumStages == 2 && this->IntercoolerType == 1) {
   14090           0 :         this->HSatLiqCond = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14091           0 :         this->CpSatLiqCond =
   14092           0 :             FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14093           0 :         this->HCaseIn = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TIntercooler, 0.0, this->RefIndex, RoutineName);
   14094             : 
   14095             :         // Two-stage compression with shell-and-coil intercooler
   14096           0 :     } else if (this->NumStages == 2 && this->IntercoolerType == 2) {
   14097           0 :         TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   14098           0 :                             this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   14099           0 :         this->HSatLiqCond = FluidProperties::GetSatEnthalpyRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14100           0 :         this->CpSatLiqCond =
   14101           0 :             FluidProperties::GetSatSpecificHeatRefrig(state, this->RefrigerantName, this->TCondense, 0.0, this->RefIndex, RoutineName);
   14102           0 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - TLiqInActualLocal);
   14103             :     } // NumStages and IntercoolerType
   14104             : 
   14105       74664 :     for (int SubcoolerIndex = 1; SubcoolerIndex <= this->NumSubcoolers; ++SubcoolerIndex) {
   14106       49776 :         int SubcoolerID = this->SubcoolerNum(SubcoolerIndex);
   14107       49776 :         auto &cooler = Subcooler(SubcoolerID);
   14108             :         // set up local variables for convenience
   14109       49776 :         Real64 DelTLiqDes = cooler.LiqSuctDesignDelT;
   14110       49776 :         Real64 TVapInDes = cooler.LiqSuctDesignTvapIn;
   14111       49776 :         Real64 TLiqInDes = cooler.LiqSuctDesignTliqIn;
   14112       49776 :         Real64 ControlTLiqOut = cooler.MechControlTliqOut;
   14113       49776 :         Real64 CpLiquid = this->CpSatLiqCond;
   14114       49776 :         Real64 CpVapor = this->CpSatVapEvap;
   14115       49776 :         if (this->NumStages == 1) { // Single-stage compression system
   14116       49776 :             TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool;
   14117             : 
   14118             :             // Two-stage compression with flash intercooler
   14119           0 :         } else if (this->NumStages == 2 && this->IntercoolerType == 1) {
   14120           0 :             TLiqInActualLocal = this->TIntercooler;
   14121             : 
   14122             :             // Two-stage compression with shell-and-coil intercooler
   14123           0 :         } else if (this->NumStages == 2 && this->IntercoolerType == 2) {
   14124           0 :             TLiqInActualLocal =
   14125           0 :                 this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   14126           0 :                 this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   14127             :         } // NumStages and IntercoolerType
   14128             : 
   14129       49776 :         switch (cooler.subcoolerType) {
   14130             :             // Mechanical subcoolers required to come first in order to take advantage of delT
   14131             :             //  from lshx. taken care of because subcooler ID assigned in that order in input.
   14132       24888 :         case SubcoolerType::Mechanical: {
   14133       24888 :             Real64 mechSCLoad = this->RefMassFlowtoLoads * CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   14134       24888 :             this->HCaseIn -= CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   14135             :             // refrigeration benefit to System(sysnum)
   14136             :             // refrigeration load must be assigned properly according to input
   14137       24888 :             int SysProvideID = cooler.MechSourceSysID;
   14138       24888 :             System(SysProvideID).MechSCLoad(SubcoolerID) = mechSCLoad;
   14139       24888 :             cooler.MechSCTransLoad = mechSCLoad;
   14140       24888 :             cooler.MechSCTransEnergy = mechSCLoad * LocalTimeStep * Constant::SecInHour;
   14141             :             // Reset inlet temperature for any LSHX that follows this mech subcooler
   14142       24888 :             TLiqInActualLocal = ControlTLiqOut;
   14143       24888 :             this->TCompIn = this->TEvapNeeded + CaseSuperheat;
   14144       24888 :         } break;
   14145       24888 :         case SubcoolerType::LiquidSuction: {
   14146       24888 :             Real64 LSHXeffectiveness = DelTLiqDes / (TLiqInDes - TVapInDes);
   14147       24888 :             Real64 TVapInActual = this->TEvapNeeded + CaseSuperheat;
   14148       24888 :             Real64 DelTempActual = LSHXeffectiveness * (TLiqInActualLocal - TVapInActual);
   14149       24888 :             TLiqInActualLocal -= DelTempActual;
   14150       24888 :             Real64 SubcoolLoad = this->RefMassFlowtoLoads * CpLiquid * DelTempActual;
   14151       24888 :             Real64 SubcoolerSupHeat = SubcoolLoad / CpVapor / this->RefMassFlowComps;
   14152       24888 :             this->TCompIn = TVapInActual + SubcoolerSupHeat;
   14153       24888 :             this->HCaseIn -= SubcoolLoad / this->RefMassFlowtoLoads;
   14154       24888 :             this->LSHXTrans = SubcoolLoad;
   14155       24888 :             this->LSHXTransEnergy = SubcoolLoad * LocalTimeStep * Constant::SecInHour;
   14156       24888 :         } break;
   14157           0 :         default:
   14158           0 :             break;
   14159             :         }
   14160             : 
   14161       49776 :         this->TLiqInActual = TLiqInActualLocal;
   14162             :     }
   14163       24888 : }
   14164             : 
   14165           2 : void GetRefrigeratedRackIndex(EnergyPlusData &state,
   14166             :                               std::string const &Name,
   14167             :                               int &IndexPtr,
   14168             :                               DataHeatBalance::RefrigSystemType const SysType,
   14169             :                               bool &ErrorsFound,
   14170             :                               std::string_view const ThisObjectType,
   14171             :                               bool const SuppressWarning)
   14172             : {
   14173             : 
   14174             :     // SUBROUTINE INFORMATION:
   14175             :     //       AUTHOR         Richard Raustad
   14176             :     //       DATE WRITTEN   June 2007
   14177             :     //       MODIFIED       Therese Stovall May 2008
   14178             :     //       RE-ENGINEERED  na
   14179             :     // PURPOSE OF THIS SUBROUTINE:
   14180             :     // This subroutine sets an index for a given refrigerated rack or refrigeration condenser
   14181             :     //  -- issues error message if the rack or condenser is not found.
   14182             : 
   14183           2 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14184           2 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14185             : 
   14186           2 :     CheckRefrigerationInput(state);
   14187             : 
   14188           2 :     switch (SysType) {
   14189           1 :     case DataHeatBalance::RefrigSystemType::Rack: {
   14190           1 :         IndexPtr = Util::FindItemInList(Name, RefrigRack);
   14191           1 :         if (IndexPtr == 0) {
   14192           0 :             if (SuppressWarning) {
   14193             :                 //     No warning printed if only searching for the existence of a refrigerated rack
   14194             :             } else {
   14195           0 :                 if (!ThisObjectType.empty()) {
   14196           0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   14197             :                 } else {
   14198           0 :                     if (!ThisObjectType.empty()) {
   14199           0 :                         ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   14200             :                     } else {
   14201           0 :                         ShowSevereError(state, format("GetRefrigeratedRackIndex: Rack not found={}", Name));
   14202             :                     }
   14203             :                 }
   14204             :             }
   14205           0 :             ErrorsFound = true;
   14206             :         }
   14207           1 :     } break;
   14208           1 :     case DataHeatBalance::RefrigSystemType::Detailed: {
   14209           1 :         IndexPtr = Util::FindItemInList(Name, Condenser);
   14210           1 :         if (IndexPtr == 0) {
   14211           0 :             if (SuppressWarning) {
   14212             :                 //     No warning printed if only searching for the existence of a refrigeration Condenser
   14213             :             } else {
   14214           0 :                 if (!ThisObjectType.empty()) {
   14215           0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Condenser not found={}", ThisObjectType, Name));
   14216             :                 } else {
   14217           0 :                     ShowSevereError(state, format("GetRefrigeratedRackIndex: Condenser not found={}", Name));
   14218             :                 }
   14219             :             }
   14220             :         }
   14221           1 :         ErrorsFound = true;
   14222           1 :     } break;
   14223           0 :     default:
   14224           0 :         break;
   14225             :     }
   14226           2 : }
   14227             : 
   14228         796 : void ReportRefrigerationComponents(EnergyPlusData &state)
   14229             : {
   14230             : 
   14231             :     // SUBROUTINE INFORMATION:
   14232             :     //       AUTHOR         Richard Raustad, FSEC
   14233             :     //       DATE WRITTEN   October 2004
   14234             :     //       MODIFIED       Shirey, FSEC Dec 2004; Lawrie, Mar 2008 - Node names, not numbers.
   14235             :     //       MODIFIED       Stovall - 2008 to 2010, new refrig variables and move orphan reporting to input.
   14236             :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
   14237             :     //       RE-ENGINEERED  na
   14238             : 
   14239             :     // PURPOSE OF THIS SUBROUTINE:
   14240             :     // To report information from the input deck for refrigerated cases and racks to the eio and err file.
   14241             : 
   14242         796 :     std::string ChrOut;
   14243         796 :     std::string ChrOut2;
   14244             : 
   14245         796 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   14246         796 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14247         796 :     auto &System = state.dataRefrigCase->System;
   14248         796 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   14249         796 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14250         796 :     auto &Compressor = state.dataRefrigCase->Compressor;
   14251         796 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   14252         796 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   14253         796 :     auto &Secondary = state.dataRefrigCase->Secondary;
   14254         796 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   14255         796 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   14256         796 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   14257             : 
   14258             :     static constexpr std::string_view Format_104(
   14259             :         "! <Refrigeration Compressor Rack>,Compressor Rack Name, # Refrigerated Cases Connected,# WalkIn Coolers "
   14260             :         "Connected, Heat Rejection Location, Condenser Type, COP");
   14261             :     static constexpr std::string_view Format_105(
   14262             :         "!  <Refrigeration Case>,Refrigeration Case Number, Refrigeration Case Name,Zone Name,Zone Node #,Zone "
   14263             :         "Node Name,Capacity (W/m),LHR,Temperature (C),Length (m),Fan (W/m),Installed Lighting (W/m),Anti-Sweat "
   14264             :         "(W/m),Defrost (W/m)");
   14265             :     static constexpr std::string_view Format_108("!  <Refrigeration Compressor>,Compressor Number,Compressor Name,Nominal Capacity (W)");
   14266             :     static constexpr std::string_view Format_109("! <#Refrigeration Compressor Racks>,Number of Refrigeration Compressor Racks");
   14267             :     static constexpr std::string_view Format_117("! <#Detailed Refrigeration Systems>,Number of Detailed Refrigeration Systems");
   14268             :     static constexpr std::string_view Format_118(
   14269             :         "! <Detailed Refrigeration System>,Refrigeration System Name,Refrigerant Used, # Refrigerated Cases "
   14270             :         "Connected, # WalkInCoolers Connected, #Air Chillers Connected, # Secondary Loops Served, # Cascade Condensers "
   14271             :         "Served, # Mechanical Subcoolers Served, # Compressors Connected, # Compression Stages, Intercooler Type, "
   14272             :         "Intercooler Effectiveness, # Subcoolers Connected, Minimum Condensing Temperature (C)");
   14273             :     static constexpr std::string_view Format_119(
   14274             :         "!  <Refrigeration Walk In Cooler>, Walk In Number, Walk In Name,Capacity (W),Temperature (C),Coil Fan "
   14275             :         "(W), Circulating Fan (W), Lighting (W),Heaters (W),Defrost (W), # Zones");
   14276             :     static constexpr std::string_view Format_120(
   14277             :         "! <#Detailed Transcritical Refrigeration Systems>,Number of Detailed Transcritical Refrigeration Systems");
   14278             :     static constexpr std::string_view Format_121(
   14279             :         "! <Detailed Transcritical Refrigeration System>,Transcritical Refrigeration System Name,Refrigerant Used, # "
   14280             :         "Medium Temperature Refrigerated Cases Connected, # Low Temperature Refrigerated Cases Connected, # Medium "
   14281             :         "Temperature WalkInCoolers Connected, # Low Temperature WalkInCoolers Connected, # High Pressure Compressors "
   14282             :         "Connected, # Low Pressure Compressors Connected, Minimum Condensing Temperature (C)");
   14283             :     static constexpr std::string_view Format_123("!  <Secondary Load>, Secondary System Served Name, Secondary Number");
   14284             :     static constexpr std::string_view Format_126(
   14285             :         "!  <Refrigeration Mechanical Subcooler>, Subcooler Number, Subcooler Name, Name of System Providing "
   14286             :         "Cooling, Design Outlet Temperature (C)");
   14287             :     static constexpr std::string_view Format_127("!  <Refrigeration Liquid Suction Subcooler>, Subcooler Number, Subcooler Name, Design Subcooling "
   14288             :                                                  "(DeltaC),Design liquid inlet temperature (C), Design vapor inlet temperature (C)");
   14289             :     static constexpr std::string_view Format_128("!  <Cascade Load>, System Name Connected, Condenser Number, Condenser Name");
   14290             :     static constexpr std::string_view Format_129(
   14291             :         "!  <Refrigeration Condenser:Air-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   14292             :         "(C),Rated Capacity (W), Rated Fan Power (W)");
   14293             :     static constexpr std::string_view Format_130(
   14294             :         "!  <Refrigeration Condenser:Water-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   14295             :         "(C),Rated Capacity (W), Rated Water Inlet Temperature (C), Rated Water Flow Rate (m3/s)");
   14296             :     static constexpr std::string_view Format_131(
   14297             :         "!  <Refrigeration Condenser:Evaporative-Cooled>,Condenser Number,Condenser Name,Rated Capacity (W), Rated Fan Power (W)");
   14298             :     static constexpr std::string_view Format_132(
   14299             :         "!  <Refrigeration Condenser:Cascade>, Condenser Number, Condenser Name, Condensing Temperature Control "
   14300             :         "Type, Rated Condensing Temperature (C), Capacity (W), Approach Temperature Difference (DeltaC)");
   14301             :     static constexpr std::string_view Format_133(
   14302             :         "! <Secondary Refrigeration System: Fluid Always Liquid>, Secondary Number, Secondary Name, # Refrigerated "
   14303             :         "Cases Connected, # WalkIn Coolers Connected, Fluid Name, Capacity (W),Evap Temperature in Secondary "
   14304             :         "Evaporator (C), Approach Temperature Difference (DeltaC), Temperature Range (DeltaC), TotalPumpPower (W)");
   14305             :     static constexpr std::string_view Format_134(
   14306             :         "!      <Walk-In Surfaces Facing Zone>, ZoneName, Wall/Ceiling Area (m2), UValue (W/m2-C), AreaStockDoors "
   14307             :         "(m2), HeightStockDoors, UValueStockDoors (W/m2-C), AreaGlassDoors (m2), HeightGlassDoors (m),  "
   14308             :         "UValueGlassDoors (W/m2-C)");
   14309             :     static constexpr std::string_view Format_141("!  <Mechanical Subcooler Load>, Subcooler Number, Subcooler Name");
   14310             :     static constexpr std::string_view Format_142("! <#Secondary Refrigeration Systems>,Number of Secondary Refrigeration Systems");
   14311             :     static constexpr std::string_view Format_146(
   14312             :         "! <Secondary Refrigeration System: Liquid Overfeed>, Secondary Number, Secondary Name, # Refrigerated Cases "
   14313             :         "Connected, # WalkIn Coolers Connected, #Air Coils Connected Fluid Name, Capacity (W),Evap Temperature in "
   14314             :         "Secondary Evaporator (C), Approach Temperature Difference (DeltaC), Circulating Rate, TotalPumpPower (W)");
   14315             :     static constexpr std::string_view Format_148("! <#ZoneHVAC/Refrigeration Air Chiller Sets>,Number of ZoneHVAC/Refrigeration Air Chiller Sets");
   14316             :     static constexpr std::string_view Format_149(
   14317             :         "! <ZoneHVAC/Refrigeration Air Chiller Set>,Chiller Set Name, # Air Chillers Connected, Zone Location");
   14318             :     static constexpr std::string_view Format_151(
   14319             :         "!  <Refrigeration Air Chiller>,Refrigeration Chiller Number, Refrigeration Chiller Name,Zone Name,Zone "
   14320             :         "Node #,Zone Node Name,Sensible Capacity (W/C),Sensible Capacity (W),Evaporating Temperature (C),DT1 (C),Fan "
   14321             :         "Power (W),Heater (W),Defrost (W), Air Flow Rate (m3/s)");
   14322             :     static constexpr std::string_view Format_152("!  <Air Chiller Load>, Air Chiller Name, Air Chiller Number, Zone Name,");
   14323             :     static constexpr std::string_view Format_160(
   14324             :         "!  <Refrigeration GasCooler:Air-Cooled>,Gas Cooler Number, Gas Cooler Name, Rated Outlet Pressure "
   14325             :         "(Pa),Rated Outlet Temperature (C), Rated Approach Temperature (C), Rated Capacity (W), Rated Fan Power (W)");
   14326             : 
   14327             :     // write all headers applicable to this simulation
   14328         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14329          31 :         print(state.files.eio, "{}\n", Format_109); // Intro to refrigeration case racks
   14330          31 :         print(state.files.eio, "{}\n", Format_104); // Refrigeration Rack header
   14331             :     }                                               //(NumRefrigeratedRacks > 0)
   14332         796 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14333          14 :         print(state.files.eio, "{}\n", Format_117); // Intro to detailed systems
   14334          14 :         print(state.files.eio, "{}\n", Format_118); // Detailed system header
   14335          14 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   14336             :     }                                               //(NumRefrigSystems > 0)
   14337         796 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14338           1 :         print(state.files.eio, "{}\n", Format_142); // Intro to Secondary systems
   14339           1 :         int CountSecPhase = 0;
   14340           1 :         int CountSecBrine = 0;
   14341           3 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14342           2 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::AlwaysLiquid) && (CountSecBrine == 0)) {
   14343           1 :                 print(state.files.eio, "{}\n", Format_133); // Secondary system header for brine type systems
   14344           1 :                 ++CountSecBrine;
   14345             :             }
   14346           2 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::PhaseChange) && (CountSecPhase == 0)) {
   14347           1 :                 print(state.files.eio, "{}\n", Format_146); // Secondary system header for liquid overfeed/phase change systems
   14348           1 :                 ++CountSecPhase;
   14349             :             }
   14350             :         }
   14351           1 :         print(state.files.eio, "{}\n", Format_123); //  Secondary system load header
   14352             :     }                                               //(NumSimulationSecondarySystems > 0)
   14353         796 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14354           1 :         print(state.files.eio, "{}\n", Format_148); // Intro to Chiller set
   14355           1 :         print(state.files.eio, "{}\n", Format_149); // Chiller set header
   14356           1 :         print(state.files.eio, "{}\n", Format_151); // Intro to Air Chiller
   14357           1 :         print(state.files.eio, "{}\n", Format_152); // Air chiller header
   14358             :     }                                               //(NumRefrigSystems > 0)
   14359         796 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   14360          36 :         print(state.files.eio, "{}\n", Format_105); //  Case header
   14361             :     }                                               //(NumSimulationCases > 0)
   14362         796 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14363          13 :         print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14364          13 :         print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14365             :     }                                               //(NumSimulationWalkIns > 0)
   14366         796 :     if (state.dataRefrigCase->NumSimulationCondAir > 0) {
   14367          12 :         print(state.files.eio, "{}\n", Format_129); //  Condenser, Air-Cooled header
   14368             :     }                                               //(NumSimulationCondAir > 0)
   14369         796 :     if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
   14370           2 :         print(state.files.eio, "{}\n", Format_131); //  Condenser, Evaporative-Cooled header
   14371             :     }                                               //(NumSimulationCondEvap > 0)
   14372         796 :     if (state.dataRefrigCase->NumSimulationCondWater > 0) {
   14373           1 :         print(state.files.eio, "{}\n", Format_130); //  Condenser, Water-Cooled header
   14374             :     }                                               //(NumSimulationCondWater > 0)
   14375         796 :     if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
   14376           1 :         print(state.files.eio, "{}\n", Format_132); //  Condenser, Cascade header
   14377           1 :         print(state.files.eio, "{}\n", Format_128); //  Cascade Load header
   14378             :     }                                               //(NumSimulationCascadeCondensers > 0)
   14379         796 :     if (state.dataRefrigCase->NumSimulationMechSubcoolers > 0) {
   14380           1 :         print(state.files.eio, "{}\n", Format_141); //  Mech subcooler loads served header
   14381           1 :         print(state.files.eio, "{}\n", Format_126); //  Mechanical Subcooler header
   14382             :     }                                               //(NumSimulationMechSubcoolers > 0)
   14383         796 :     if ((state.dataRefrigCase->NumSimulationSubcoolers - state.dataRefrigCase->NumSimulationMechSubcoolers) > 0) {
   14384           1 :         print(state.files.eio, "{}\n", Format_127); //  LSHX Subcooler header
   14385             :     }                                               //((NumSimulationSubcoolers - NumSimulationMechSubcoolers) > 0)
   14386             : 
   14387         796 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14388           1 :         print(state.files.eio, "{}\n", Format_120); // Intro to detailed transcriticial refrigeration system
   14389           1 :         print(state.files.eio, "{}\n", Format_121); // Detailed system header
   14390           1 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   14391           1 :             print(state.files.eio, "{}\n", Format_105); //  Case header
   14392             :         }                                               //(NumSimulationCases > 0)
   14393           1 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14394           1 :             print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14395           1 :             print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14396             :         }                                               //(NumSimulationWalkIns > 0)
   14397           1 :         print(state.files.eio, "{}\n", Format_108);     // Compressor header (Always have compressor if have detailed system)
   14398           1 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   14399           1 :             print(state.files.eio, "{}\n", Format_160); //  Gas Cooler, Air-Cooled header
   14400             :         }                                               //(NumSimulationGasCooler > 0)
   14401             :     }                                                   //(NumTransRefrigSystems > 0)
   14402             : 
   14403         796 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14404          31 :         print(state.files.eio, "#Refrigeration Compressor Racks, {}\n", state.dataRefrigCase->NumRefrigeratedRacks);
   14405          92 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   14406          61 :             if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Outdoors) {
   14407          34 :                 ChrOut = "Outdoors";
   14408             :             } else {
   14409          27 :                 ChrOut = "Zone";
   14410             :             }
   14411          61 :             switch (RefrigRack(RackNum).CondenserType) {
   14412          58 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14413          58 :                 ChrOut2 = "Air-Cooled";
   14414          58 :             } break;
   14415           2 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14416           2 :                 ChrOut2 = "Evap-Cooled";
   14417           2 :             } break;
   14418           1 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14419           1 :                 ChrOut2 = "Water-Cooled";
   14420           1 :             } break;
   14421           0 :             default:
   14422           0 :                 break;
   14423             :             }
   14424          61 :             print(state.files.eio,
   14425             :                   " Refrigeration Compressor Rack,{},{},{},{},{},{:.3R}\n",
   14426          61 :                   RefrigRack(RackNum).Name,
   14427          61 :                   RefrigRack(RackNum).NumCases,
   14428          61 :                   RefrigRack(RackNum).NumWalkIns,
   14429             :                   ChrOut,
   14430             :                   ChrOut2,
   14431          61 :                   RefrigRack(RackNum).RatedCOP);
   14432         153 :             for (int CaseNum = 1; CaseNum <= RefrigRack(RackNum).NumCases; ++CaseNum) {
   14433          92 :                 int CaseID = RefrigRack(RackNum).CaseNum(CaseNum);
   14434          92 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14435          92 :                     print(state.files.eio,
   14436             :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14437             :                           CaseID,
   14438          92 :                           RefrigCase(CaseID).Name,
   14439          92 :                           RefrigCase(CaseID).ZoneName,
   14440          92 :                           RefrigCase(CaseID).ZoneNodeNum,
   14441          92 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14442          92 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14443          92 :                           RefrigCase(CaseID).RatedLHR,
   14444          92 :                           RefrigCase(CaseID).Temperature,
   14445          92 :                           RefrigCase(CaseID).Length,
   14446          92 :                           RefrigCase(CaseID).OperatingFanPower,
   14447          92 :                           RefrigCase(CaseID).LightingPower,
   14448          92 :                           RefrigCase(CaseID).AntiSweatPower,
   14449          92 :                           RefrigCase(CaseID).DefrostPower); // Installed lighting power, may not be rated power
   14450             :                 }
   14451             :             } // numcases
   14452             : 
   14453          61 :             for (int WalkInNum = 1; WalkInNum <= RefrigRack(RackNum).NumWalkIns; ++WalkInNum) {
   14454           0 :                 int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInNum);
   14455           0 :                 print(state.files.eio,
   14456             :                       "   Refrigeration Walk In Cooler,  {},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14457             :                       WalkInID,
   14458           0 :                       WalkIn(WalkInID).Name,
   14459           0 :                       WalkIn(WalkInID).DesignRatedCap,
   14460           0 :                       WalkIn(WalkInID).Temperature,
   14461           0 :                       WalkIn(WalkInID).CoilFanPower,
   14462           0 :                       WalkIn(WalkInID).CircFanPower,
   14463           0 :                       WalkIn(WalkInID).ElecFanPower,
   14464           0 :                       WalkIn(WalkInID).DesignLighting,
   14465           0 :                       WalkIn(WalkInID).HeaterPower,
   14466           0 :                       WalkIn(WalkInID).DefrostCapacity,
   14467           0 :                       WalkIn(WalkInID).NumZones);
   14468           0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14469           0 :                     print(state.files.eio,
   14470             :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14471           0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14472           0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14473           0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14474           0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14475           0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14476           0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14477           0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14478           0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14479           0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14480             :                 } // zones for walk ins on rack
   14481             :             }     // walk ins on rack
   14482             : 
   14483          61 :             for (int CoilNum = 1; CoilNum <= RefrigRack(RackNum).NumCoils; ++CoilNum) {
   14484           0 :                 int CoilID = RefrigRack(RackNum).CoilNum(CoilNum);
   14485           0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14486             :             } // numairchillers
   14487             :         }     // numracks
   14488             :     }         //(NumRefrigeratedRacks > 0)
   14489             : 
   14490         796 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14491          14 :         print(state.files.eio, "#Detailed Refrigeration Systems,{}\n", state.dataRefrigCase->NumRefrigSystems);
   14492          53 :         for (int SystemNum = 1; SystemNum <= state.dataRefrigCase->NumRefrigSystems; ++SystemNum) {
   14493          39 :             print(state.files.eio,
   14494             :                   " Detailed Refrigeration System,{},{},{},{},{},{},{},{},{},{},{},{:.2R},{},{:.1R}\n",
   14495          39 :                   System(SystemNum).Name,
   14496          39 :                   System(SystemNum).RefrigerantName,
   14497          39 :                   System(SystemNum).NumCases,
   14498          39 :                   System(SystemNum).NumWalkIns,
   14499          39 :                   System(SystemNum).NumCoils,
   14500          39 :                   System(SystemNum).NumSecondarys,
   14501          39 :                   System(SystemNum).NumCascadeLoads,
   14502          39 :                   System(SystemNum).NumMechSCServed,
   14503          39 :                   System(SystemNum).NumCompressors + System(SystemNum).NumHiStageCompressors,
   14504          39 :                   System(SystemNum).NumStages,
   14505          39 :                   System(SystemNum).IntercoolerType,
   14506          39 :                   System(SystemNum).IntercoolerEffectiveness,
   14507          39 :                   System(SystemNum).NumSubcoolers,
   14508          39 :                   System(SystemNum).TCondenseMin);
   14509             : 
   14510         119 :             for (int CaseNum = 1; CaseNum <= System(SystemNum).NumCases; ++CaseNum) {
   14511          80 :                 int CaseID = System(SystemNum).CaseNum(CaseNum);
   14512          80 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14513          80 :                     print(state.files.eio,
   14514             :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14515             :                           CaseID,
   14516          80 :                           RefrigCase(CaseID).Name,
   14517          80 :                           RefrigCase(CaseID).ZoneName,
   14518          80 :                           RefrigCase(CaseID).ZoneNodeNum,
   14519          80 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14520          80 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14521          80 :                           RefrigCase(CaseID).RatedLHR,
   14522          80 :                           RefrigCase(CaseID).Temperature,
   14523          80 :                           RefrigCase(CaseID).Length,
   14524          80 :                           RefrigCase(CaseID).OperatingFanPower,
   14525          80 :                           RefrigCase(CaseID).LightingPower,
   14526          80 :                           RefrigCase(CaseID).AntiSweatPower,
   14527          80 :                           RefrigCase(CaseID).DefrostPower);
   14528             :                 }
   14529             :             } // NumCases on system
   14530          52 :             for (int WalkInNum = 1; WalkInNum <= System(SystemNum).NumWalkIns; ++WalkInNum) {
   14531          13 :                 int WalkInID = System(SystemNum).WalkInNum(WalkInNum);
   14532          13 :                 print(state.files.eio,
   14533             :                       "   Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14534             :                       WalkInID,
   14535          13 :                       WalkIn(WalkInID).Name,
   14536          13 :                       WalkIn(WalkInID).DesignRatedCap,
   14537          13 :                       WalkIn(WalkInID).Temperature,
   14538          13 :                       WalkIn(WalkInID).CoilFanPower,
   14539          13 :                       WalkIn(WalkInID).CircFanPower,
   14540          13 :                       WalkIn(WalkInID).DesignLighting,
   14541          13 :                       WalkIn(WalkInID).HeaterPower,
   14542          13 :                       WalkIn(WalkInID).DefrostCapacity,
   14543          13 :                       WalkIn(WalkInID).NumZones);
   14544          26 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14545          13 :                     print(state.files.eio,
   14546             :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14547          13 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14548          13 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14549          13 :                           WalkIn(WalkInID).UValue(ZoneID),
   14550          13 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14551          13 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14552          13 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14553          13 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14554          13 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14555          13 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14556             :                 } // Num zones for each walk in on system
   14557             :             }     // NumWalkIns on system
   14558             : 
   14559         122 :             for (int CoilNum = 1; CoilNum <= System(SystemNum).NumCoils; ++CoilNum) {
   14560          83 :                 int CoilID = System(SystemNum).CoilNum(CoilNum);
   14561          83 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14562             :             } // numairchillers
   14563             : 
   14564          40 :             for (int CascadeLoadNum = 1; CascadeLoadNum <= System(SystemNum).NumCascadeLoads; ++CascadeLoadNum) {
   14565           1 :                 int CascadeLoadID = System(SystemNum).CascadeLoadNum(CascadeLoadNum);
   14566           1 :                 print(state.files.eio,
   14567             :                       "   Cascade Load,{},{},{}\n",
   14568           1 :                       System(Condenser(CascadeLoadID).CascadeSysID).Name,
   14569             :                       CascadeLoadID,
   14570           1 :                       Condenser(CascadeLoadID).Name);
   14571             :             } // cascade load on detailed system
   14572             : 
   14573          41 :             for (int SecondaryNum = 1; SecondaryNum <= System(SystemNum).NumSecondarys; ++SecondaryNum) {
   14574           2 :                 int SecondaryID = System(SystemNum).SecondaryNum(SecondaryNum);
   14575           2 :                 print(state.files.eio, "   Secondary Load,{},{}\n", Secondary(SecondaryID).Name, SecondaryID);
   14576             :             } // secondary load on detailed system
   14577             : 
   14578          43 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
   14579           4 :                 if (Subcooler(SubcoolerNum).MechSourceSysID != SystemNum) continue;
   14580           1 :                 print(state.files.eio, "   Mechanical Subcooler Load, {},{}\n", SubcoolerNum, Subcooler(SubcoolerNum).Name);
   14581             :             } // Num sim subcoolers, looking only for NumSMech Subcoolers served by this system
   14582             : 
   14583          39 :             if (System(SystemNum).NumStages == 1) { // Single-stage compression system
   14584         191 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14585         154 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14586         154 :                     print(state.files.eio, "   Refrigeration Compressor,{},{},{:.0R}\n", CompID, Compressor(CompID).Name, Compressor(CompID).NomCap);
   14587             :                 }                                          // NumCompressors
   14588           2 :             } else if (System(SystemNum).NumStages == 2) { // Two-stage compression system
   14589             :                 // Low-stage compressors
   14590           8 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14591           6 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14592           6 :                     print(state.files.eio,
   14593             :                           "   Refrigeration Low-Stage Compressor,{},{},{:.0R}\n",
   14594             :                           CompID,
   14595           6 :                           Compressor(CompID).Name,
   14596           6 :                           Compressor(CompID).NomCap);
   14597             :                 } // NumCompressors
   14598             :                 // High-stage compressors
   14599          10 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumHiStageCompressors; ++CompressorNum) {
   14600           8 :                     int CompID = System(SystemNum).HiStageCompressorNum(CompressorNum);
   14601           8 :                     print(state.files.eio,
   14602             :                           "   Refrigeration High-Stage Compressor,{},{},{:.0R}\n",
   14603             :                           CompID,
   14604           8 :                           Compressor(CompID).Name,
   14605           8 :                           Compressor(CompID).NomCap);
   14606             :                 } // NumHiStageCompressors
   14607             :             }     // NumStages
   14608             : 
   14609          39 :             int CondID = System(SystemNum).CondenserNum(1);
   14610          39 :             switch (Condenser(CondID).CondenserType) {
   14611          33 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14612          33 :                 print(state.files.eio,
   14613             :                       "   Refrigeration Condenser:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R}\n",
   14614             :                       CondID,
   14615          33 :                       Condenser(CondID).Name,
   14616          33 :                       Condenser(CondID).RatedTCondense,
   14617          33 :                       Condenser(CondID).RatedCapacity,
   14618          33 :                       Condenser(CondID).RatedFanPower);
   14619          33 :             } break;
   14620           4 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14621           4 :                 print(state.files.eio,
   14622             :                       "   Refrigeration Condenser:Evaporative-Cooled,{},{},{:.1R},{:.1R}\n",
   14623             :                       CondID,
   14624           4 :                       Condenser(CondID).Name,
   14625           4 :                       Condenser(CondID).RatedCapacity,
   14626           4 :                       Condenser(CondID).RatedFanPower);
   14627           4 :             } break;
   14628           1 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14629           1 :                 print(state.files.eio,
   14630             :                       "   Refrigeration Condenser:Water-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14631             :                       CondID,
   14632           1 :                       Condenser(CondID).Name,
   14633           1 :                       Condenser(CondID).RatedTCondense,
   14634           1 :                       Condenser(CondID).RatedCapacity,
   14635           1 :                       Condenser(CondID).InletTemp,
   14636           1 :                       Condenser(CondID).DesVolFlowRate);
   14637           1 :             } break;
   14638           1 :             case DataHeatBalance::RefrigCondenserType::Cascade: {
   14639             : 
   14640           1 :                 switch (Condenser(CondID).CascadeTempControl) {
   14641           1 :                 case CascadeCndsrTempCtrlType::TempSet: {
   14642           1 :                     ChrOut = "Fixed";
   14643           1 :                 } break;
   14644           0 :                 case CascadeCndsrTempCtrlType::TempFloat: {
   14645           0 :                     ChrOut = "Floating";
   14646           0 :                 } break;
   14647           0 :                 default:
   14648           0 :                     break;
   14649             :                 } // cascade temperature control
   14650           1 :                 print(state.files.eio,
   14651             :                       "   Refrigeration Condenser:Cascade,{},{},{},{:.1R},{:.1R},{:.1R}\n",
   14652             :                       CondID,
   14653           1 :                       Condenser(CondID).Name,
   14654             :                       ChrOut,
   14655           1 :                       Condenser(CondID).RatedTCondense,
   14656           1 :                       Condenser(CondID).RatedCapacity,
   14657           1 :                       Condenser(CondID).RatedApproachT);
   14658           1 :             } break;
   14659           0 :             default:
   14660           0 :                 break;
   14661             :             } // condenser type
   14662             : 
   14663          41 :             for (int SubcoolerNum = 1; SubcoolerNum <= System(SystemNum).NumSubcoolers; ++SubcoolerNum) {
   14664           2 :                 int SubcoolerID = System(SystemNum).SubcoolerNum(SubcoolerNum);
   14665           2 :                 switch (Subcooler(SubcoolerID).subcoolerType) {
   14666           1 :                 case SubcoolerType::LiquidSuction: {
   14667           1 :                     print(state.files.eio,
   14668             :                           "   Refrigeration Liquid Suction Subcooler,{},{},{:.1R},{:.1R},{:.1R}\n",
   14669             :                           SubcoolerID,
   14670           1 :                           Subcooler(SubcoolerID).Name,
   14671           1 :                           Subcooler(SubcoolerID).LiqSuctDesignDelT,
   14672           1 :                           Subcooler(SubcoolerID).LiqSuctDesignTliqIn,
   14673           1 :                           Subcooler(SubcoolerID).LiqSuctDesignTvapIn);
   14674           1 :                 } break;
   14675           1 :                 case SubcoolerType::Mechanical: {
   14676           1 :                     print(state.files.eio,
   14677             :                           "   Refrigeration Mechanical Subcooler,{},{},{},{:.1R}\n",
   14678             :                           SubcoolerID,
   14679           1 :                           Subcooler(SubcoolerID).Name,
   14680           1 :                           Subcooler(SubcoolerID).MechSourceSys,
   14681           1 :                           Subcooler(SubcoolerID).MechControlTliqOut);
   14682           1 :                 } break;
   14683           0 :                 default:
   14684           0 :                     break;
   14685             :                 }
   14686             :             } // NumSubcoolers
   14687             : 
   14688             :         } // NumRefrigSystems
   14689             :     }     //(NumRefrigSystems > 0)
   14690             : 
   14691         796 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14692           1 :         print(state.files.eio, "#Detailed Transcritical Refrigeration Systems,{}\n", state.dataRefrigCase->NumTransRefrigSystems);
   14693           2 :         for (int TransSystemNum = 1; TransSystemNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransSystemNum) {
   14694           1 :             print(state.files.eio,
   14695             :                   " Detailed Transcritical Refrigeration System,{},{},{},{},{},{},{},{},{:.1R}\n",
   14696           1 :                   TransSystem(TransSystemNum).Name,
   14697           1 :                   TransSystem(TransSystemNum).RefrigerantName,
   14698           1 :                   TransSystem(TransSystemNum).NumCasesMT,
   14699           1 :                   TransSystem(TransSystemNum).NumCasesLT,
   14700           1 :                   TransSystem(TransSystemNum).NumWalkInsMT,
   14701           1 :                   TransSystem(TransSystemNum).NumWalkInsLT,
   14702           1 :                   TransSystem(TransSystemNum).NumCompressorsHP,
   14703           1 :                   TransSystem(TransSystemNum).NumCompressorsLP,
   14704           1 :                   GasCooler(TransSystem(TransSystemNum).GasCoolerNum(1)).MinCondTemp);
   14705             : 
   14706           4 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesMT; ++CaseNum) {
   14707           3 :                 int CaseID = TransSystem(TransSystemNum).CaseNumMT(CaseNum);
   14708           3 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14709           3 :                     print(state.files.eio,
   14710             :                           "   Medium Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14711             :                           CaseID,
   14712           3 :                           RefrigCase(CaseID).Name,
   14713           3 :                           RefrigCase(CaseID).ZoneName,
   14714           3 :                           RefrigCase(CaseID).ZoneNodeNum,
   14715           3 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14716           3 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14717           3 :                           RefrigCase(CaseID).RatedLHR,
   14718           3 :                           RefrigCase(CaseID).Temperature,
   14719           3 :                           RefrigCase(CaseID).Length,
   14720           3 :                           RefrigCase(CaseID).OperatingFanPower,
   14721           3 :                           RefrigCase(CaseID).LightingPower,
   14722           3 :                           RefrigCase(CaseID).AntiSweatPower,
   14723           3 :                           RefrigCase(CaseID).DefrostPower);
   14724             :                 }
   14725             :             } // NumCasesMT on system
   14726           5 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesLT; ++CaseNum) {
   14727           4 :                 int CaseID = TransSystem(TransSystemNum).CaseNumLT(CaseNum);
   14728           4 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14729           4 :                     print(state.files.eio,
   14730             :                           "   Low Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14731             :                           CaseID,
   14732           4 :                           RefrigCase(CaseID).Name,
   14733           4 :                           RefrigCase(CaseID).ZoneName,
   14734           4 :                           RefrigCase(CaseID).ZoneNodeNum,
   14735           4 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14736           4 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14737           4 :                           RefrigCase(CaseID).RatedLHR,
   14738           4 :                           RefrigCase(CaseID).Temperature,
   14739           4 :                           RefrigCase(CaseID).Length,
   14740           4 :                           RefrigCase(CaseID).OperatingFanPower,
   14741           4 :                           RefrigCase(CaseID).LightingPower,
   14742           4 :                           RefrigCase(CaseID).AntiSweatPower,
   14743           4 :                           RefrigCase(CaseID).DefrostPower);
   14744             :                 }
   14745             :             } // NumCasesLT on system
   14746           1 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsMT; ++WalkInNum) {
   14747           0 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumMT(WalkInNum);
   14748           0 :                 print(state.files.eio,
   14749             :                       "   Medium Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14750             :                       WalkInID,
   14751           0 :                       WalkIn(WalkInID).Name,
   14752           0 :                       WalkIn(WalkInID).DesignRatedCap,
   14753           0 :                       WalkIn(WalkInID).Temperature,
   14754           0 :                       WalkIn(WalkInID).CoilFanPower,
   14755           0 :                       WalkIn(WalkInID).CircFanPower,
   14756           0 :                       WalkIn(WalkInID).DesignLighting,
   14757           0 :                       WalkIn(WalkInID).HeaterPower,
   14758           0 :                       WalkIn(WalkInID).DefrostCapacity,
   14759           0 :                       WalkIn(WalkInID).NumZones);
   14760           0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14761           0 :                     print(state.files.eio,
   14762             :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14763           0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14764           0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14765           0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14766           0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14767           0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14768           0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14769           0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14770           0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14771           0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14772             :                 } // Num zones for each walk in on system
   14773             :             }     // NumWalkInsMT on system
   14774           2 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsLT; ++WalkInNum) {
   14775           1 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumLT(WalkInNum);
   14776           1 :                 print(state.files.eio,
   14777             :                       "   Low Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14778             :                       WalkInID,
   14779           1 :                       WalkIn(WalkInID).Name,
   14780           1 :                       WalkIn(WalkInID).DesignRatedCap,
   14781           1 :                       WalkIn(WalkInID).Temperature,
   14782           1 :                       WalkIn(WalkInID).CoilFanPower,
   14783           1 :                       WalkIn(WalkInID).CircFanPower,
   14784           1 :                       WalkIn(WalkInID).DesignLighting,
   14785           1 :                       WalkIn(WalkInID).HeaterPower,
   14786           1 :                       WalkIn(WalkInID).DefrostCapacity,
   14787           1 :                       WalkIn(WalkInID).NumZones);
   14788           2 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14789           1 :                     print(state.files.eio,
   14790             :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14791           1 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14792           1 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14793           1 :                           WalkIn(WalkInID).UValue(ZoneID),
   14794           1 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14795           1 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14796           1 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14797           1 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14798           1 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14799           1 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14800             :                 } // Num zones for each walk in on system
   14801             :             }     // NumWalkInsLT on system
   14802             : 
   14803           4 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsHP; ++CompressorNum) {
   14804           3 :                 int CompID = TransSystem(TransSystemNum).CompressorNumHP(CompressorNum);
   14805           3 :                 print(state.files.eio,
   14806             :                       "   High Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14807             :                       CompID,
   14808           3 :                       Compressor(CompID).Name,
   14809           3 :                       Compressor(CompID).NomCap);
   14810             :             } // NumCompressorsHP
   14811           4 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsLP; ++CompressorNum) {
   14812           3 :                 int CompID = TransSystem(TransSystemNum).CompressorNumLP(CompressorNum);
   14813           3 :                 print(state.files.eio,
   14814             :                       "   Low Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14815             :                       CompID,
   14816           3 :                       Compressor(CompID).Name,
   14817           3 :                       Compressor(CompID).NomCap);
   14818             :             } // NumCompressorsLP
   14819             : 
   14820           1 :             if (TransSystem(TransSystemNum).NumGasCoolers >= 1) {
   14821           1 :                 int GasCoolerID = TransSystem(TransSystemNum).GasCoolerNum(1);
   14822           1 :                 print(state.files.eio,
   14823             :                       "   Refrigeration GasCooler:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14824             :                       GasCoolerID,
   14825           1 :                       GasCooler(GasCoolerID).Name,
   14826           1 :                       GasCooler(GasCoolerID).RatedOutletP,
   14827           1 :                       GasCooler(GasCoolerID).RatedOutletT,
   14828           1 :                       GasCooler(GasCoolerID).RatedApproachT,
   14829           1 :                       GasCooler(GasCoolerID).RatedCapacity,
   14830           1 :                       GasCooler(GasCoolerID).RatedFanPower);
   14831             :             } // System(SystemNum)%NumGasCoolers >= 1
   14832             : 
   14833             :         } // NumTransRefrigSystems
   14834             :     }     //(NumTransRefrigSystems > 0)
   14835             : 
   14836         796 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14837           1 :         print(state.files.eio, "#Secondary Refrigeration Systems,{}\n", state.dataRefrigCase->NumSimulationSecondarySystems);
   14838           3 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14839           2 :             switch (Secondary(SecondaryID).FluidType) {
   14840           1 :             case SecFluidType::AlwaysLiquid: {
   14841           1 :                 print(state.files.eio,
   14842             :                       "Secondary Refrigeration System: Fluid Always Liquid,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14843             :                       SecondaryID,
   14844           1 :                       Secondary(SecondaryID).Name,
   14845           1 :                       Secondary(SecondaryID).NumCases,
   14846           1 :                       Secondary(SecondaryID).NumWalkIns,
   14847           1 :                       Secondary(SecondaryID).FluidName,
   14848           1 :                       Secondary(SecondaryID).CoolingLoadRated,
   14849           1 :                       Secondary(SecondaryID).TEvapDesign,
   14850           1 :                       Secondary(SecondaryID).TApproachDifRated,
   14851           1 :                       Secondary(SecondaryID).TRangeDifRated,
   14852           1 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14853           1 :             } break;
   14854           1 :             case SecFluidType::PhaseChange: {
   14855           1 :                 print(state.files.eio,
   14856             :                       "Secondary Refrigeration System: Liquid Overfeed,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14857             :                       SecondaryID,
   14858           1 :                       Secondary(SecondaryID).Name,
   14859           1 :                       Secondary(SecondaryID).NumCases,
   14860           1 :                       Secondary(SecondaryID).NumWalkIns,
   14861           1 :                       Secondary(SecondaryID).FluidName,
   14862           1 :                       Secondary(SecondaryID).CoolingLoadRated,
   14863           1 :                       Secondary(SecondaryID).TEvapDesign,
   14864           1 :                       Secondary(SecondaryID).TApproachDifRated,
   14865           1 :                       Secondary(SecondaryID).CircRate,
   14866           1 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14867           1 :             } break;
   14868           0 :             default:
   14869           0 :                 break;
   14870             :             }
   14871           9 :             for (int CaseNum = 1; CaseNum <= Secondary(SecondaryID).NumCases; ++CaseNum) {
   14872           7 :                 int CaseID = Secondary(SecondaryID).CaseNum(CaseNum);
   14873           7 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14874           7 :                     print(state.files.eio,
   14875             :                           "  Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14876             :                           CaseID,
   14877           7 :                           RefrigCase(CaseID).Name,
   14878           7 :                           RefrigCase(CaseID).ZoneName,
   14879           7 :                           RefrigCase(CaseID).ZoneNodeNum,
   14880           7 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14881           7 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14882           7 :                           RefrigCase(CaseID).RatedLHR,
   14883           7 :                           RefrigCase(CaseID).Temperature,
   14884           7 :                           RefrigCase(CaseID).Length,
   14885           7 :                           RefrigCase(CaseID).OperatingFanPower,
   14886           7 :                           RefrigCase(CaseID).LightingPower,
   14887           7 :                           RefrigCase(CaseID).AntiSweatPower,
   14888           7 :                           RefrigCase(CaseID).DefrostPower);
   14889             :                 }
   14890             :             } // NumCases on secondary on secondary system
   14891             : 
   14892           3 :             for (int WalkInNum = 1; WalkInNum <= Secondary(SecondaryID).NumWalkIns; ++WalkInNum) {
   14893           1 :                 int WalkInID = Secondary(SecondaryID).WalkInNum(WalkInNum);
   14894           1 :                 print(state.files.eio,
   14895             :                       "  Walk In,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14896             :                       WalkInID,
   14897           1 :                       WalkIn(WalkInID).Name,
   14898           1 :                       WalkIn(WalkInID).DesignRatedCap,
   14899           1 :                       WalkIn(WalkInID).Temperature,
   14900           1 :                       WalkIn(WalkInID).CoilFanPower,
   14901           1 :                       WalkIn(WalkInID).CircFanPower,
   14902           1 :                       WalkIn(WalkInID).DesignLighting,
   14903           1 :                       WalkIn(WalkInID).HeaterPower,
   14904           1 :                       WalkIn(WalkInID).DefrostCapacity);
   14905           2 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14906           1 :                     print(state.files.eio,
   14907             :                           "    Walk In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14908           1 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14909           1 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14910           1 :                           WalkIn(WalkInID).UValue(ZoneID),
   14911           1 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14912           1 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14913           1 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14914           1 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14915           1 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14916           1 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14917             :                 } // zones for walk ins on secondary
   14918             :             }     // walk ins on secondary
   14919             : 
   14920           2 :             for (int CoilNum = 1; CoilNum <= Secondary(SecondaryID).NumCoils; ++CoilNum) {
   14921           0 :                 int CoilID = Secondary(SecondaryID).CoilNum(CoilNum);
   14922           0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14923             :             } // numairchillers
   14924             :         }     // secondary
   14925             :     }         // numsimulationsecondarys
   14926             : 
   14927         796 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14928           1 :         print(state.files.eio, "#ZoneHVAC/Refrigeration Air Chiller Sets,{}\n", state.dataRefrigCase->NumRefrigChillerSets);
   14929          11 :         for (int ChillerSetNum = 1; ChillerSetNum <= state.dataRefrigCase->NumRefrigChillerSets; ++ChillerSetNum) {
   14930          10 :             print(state.files.eio,
   14931             :                   "ZoneHVAC/Refrigeration Air Chiller Set,{},{},{},{}\n",
   14932          10 :                   AirChillerSet(ChillerSetNum).Name,
   14933             :                   ChillerSetNum,
   14934          10 :                   AirChillerSet(ChillerSetNum).NumCoils,
   14935          10 :                   AirChillerSet(ChillerSetNum).ZoneName);
   14936             : 
   14937          93 :             for (int CoilNum = 1; CoilNum <= AirChillerSet(ChillerSetNum).NumCoils; ++CoilNum) {
   14938          83 :                 int CoilID = AirChillerSet(ChillerSetNum).CoilNum(CoilNum);
   14939          83 :                 print(state.files.eio,
   14940             :                       "   Refrigeration Air Chiller,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14941             :                       CoilID,
   14942          83 :                       WarehouseCoil(CoilID).Name,
   14943          83 :                       WarehouseCoil(CoilID).ZoneName,
   14944          83 :                       WarehouseCoil(CoilID).ZoneNodeNum,
   14945          83 :                       state.dataLoopNodes->NodeID(WarehouseCoil(CoilID).ZoneNodeNum),
   14946          83 :                       WarehouseCoil(CoilID).UnitLoadFactorSens,
   14947          83 :                       WarehouseCoil(CoilID).RatedSensibleCap,
   14948          83 :                       WarehouseCoil(CoilID).TEvapDesign,
   14949          83 :                       WarehouseCoil(CoilID).RatedTemperatureDif,
   14950          83 :                       WarehouseCoil(CoilID).RatedFanPower,
   14951          83 :                       WarehouseCoil(CoilID).HeaterPower,
   14952          83 :                       WarehouseCoil(CoilID).DefrostCapacity,
   14953          83 :                       WarehouseCoil(CoilID).RatedAirVolumeFlow);
   14954             :             } // numairchillers
   14955             :         }     // DataHeatBalance::NumRefrigChillerSets
   14956             :     }         // DataHeatBalance::NumRefrigChillerSets
   14957         796 : }
   14958             : 
   14959       48194 : void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to  Walk In
   14960             : {
   14961             : 
   14962             :     // SUBROUTINE INFORMATION:
   14963             :     //       AUTHOR         Therese Stovall, ORNL, May 2009
   14964             :     //       DATE WRITTEN   Oct/Nov 2004
   14965             :     //       MODIFIED       na
   14966             :     //       RE-ENGINEERED  na
   14967             : 
   14968             :     // PURPOSE OF THIS SUBROUTINE:
   14969             :     // To model Walk In Coolers.
   14970             : 
   14971             :     // METHODOLOGY EMPLOYED:
   14972             :     // Walk-in cooler performance is based on the ASHRAE load model, which includes
   14973             :     // infiltration through door openings and sensible loss through walls/ceilings identified
   14974             :     // by the user as sum of UA for each zone. A sub-floor heater is assumed to be sized so that
   14975             :     // the temperature of the slab beneath the floor insulation is the same as the ground
   14976             :     // temperature (to avoid ground freezing and heaving).
   14977             :     // All equipment loads (fan, light, heaters) are modeled as well.  Sensible and latent
   14978             :     // exchange with multiple adjoining zones is included. A master schedule is used for the Walk In operation and
   14979             :     // additional schedules control the lights, defrost, and heater operation.
   14980             : 
   14981             :     // The fan is assumed to be off for Hot-Gas, Hot-Brine, and Electric defrost. The user can choose
   14982             :     // to include the load due to bringing the coil mass up from the evaporating temperature to the melting temperature
   14983             :     //  if they choose.  Otherwise this factor is set to zero.
   14984             : 
   14985             :     // Unmet loads are accumulated to be met the following time step.  This usually occurs during defrost and
   14986             :     // restocking.
   14987             : 
   14988             :     // REFERENCES:
   14989             :     // ASHRAE 2006 Handbook, chapters 13 and 14.
   14990             :     // Gosney, W.B., Olama, G.A.-L., Heat and Enthalpy Gains through Cold Room Doorways,
   14991             :     //     Proceedings of the Institute of Refrigeration, vol. 72, pp 31-41, 1975
   14992             : 
   14993       48194 :     Real64 constexpr DefaultWalkInDoorOpenFactor(0.05); // walk in door open factor (fraction time open)
   14994             : 
   14995             :     static constexpr std::string_view RoutineName("CalculateWalkIn");
   14996       48194 :     Real64 CapApplied(0.0);          // Walk In total capacity at specific operating conditions
   14997       48194 :     Real64 DefrostSchedule(0.0);     // WalkIn defrost schedule, between 0 and 1
   14998       48194 :     Real64 DefrostEnergyNeeded(0.0); // Energy needed to melt all ice, used with temperature termination (J)
   14999       48194 :     Real64 DensityFactorFm(0.0);     // called Fm in ASHRAE 2010 eq 13 page 24.5 for door infiltration
   15000       48194 :     Real64 DensitySqRtFactor(0.0);   // from ASHRAE 2010 eq 12 page 24.4 for door infiltration
   15001             : 
   15002             :     // Current value of WalkIn operating (availability) schedule
   15003       48194 :     Real64 WalkInSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr);
   15004       48194 :     if (WalkInSchedule <= 0) return;
   15005             :     // GET OTHER SCHEDULES
   15006       48194 :     DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr);
   15007       48194 :     Real64 DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostDripDownSchedPtr);
   15008             :     // next statement In case user doesn't understand concept of drip down schedule
   15009       48194 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   15010             : 
   15011             :     // next four values optional, so set to default before checking for schedule
   15012       48194 :     Real64 StockingLoad(0.0); // Total load due to stocking WalkIn product (W)
   15013       48194 :     Real64 LightingSchedule = 1.0;
   15014       48194 :     Real64 HeaterSchedule = 1.0;
   15015       48194 :     Real64 CircFanSchedule = 1.0;
   15016       48194 :     if (this->StockingSchedPtr > 0) StockingLoad = ScheduleManager::GetCurrentScheduleValue(state, this->StockingSchedPtr);
   15017       48194 :     if (this->LightingSchedPtr > 0) LightingSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->LightingSchedPtr);
   15018       48194 :     if (this->HeaterSchedPtr > 0) HeaterSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->HeaterSchedPtr);
   15019       48194 :     if (this->CircFanSchedPtr > 0) CircFanSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->CircFanSchedPtr);
   15020             : 
   15021             :     // Set local subroutine variables for convenience
   15022       48194 :     Real64 TWalkIn = this->Temperature; // WalkIn operating temperature (C)
   15023             : 
   15024             :     // Enthalpy of air corresponding to walk in temperature and 90% assumed RH (J/kg)
   15025       48194 :     Real64 EnthalpyAirWalkIn = Psychrometrics::PsyHFnTdbRhPb(state, TWalkIn, 0.9, state.dataEnvrn->OutBaroPress); // assume 90%RH in cooler
   15026             : 
   15027             :     // corresponds to walk in temp and 90% assumed RH(kg water/kg dry air)
   15028       48194 :     Real64 HumRatioAirWalkIn = Psychrometrics::PsyWFnTdbH(state, TWalkIn, EnthalpyAirWalkIn);
   15029       48194 :     Real64 DensityAirWalkIn = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TWalkIn, HumRatioAirWalkIn);
   15030       48194 :     Real64 Conv = state.dataEnvrn->Latitude * 2.0 * Constant::Pi / 360.0; // Convert DataEnvironment::Latitude to radians
   15031       48194 :     Real64 Gravity = 9.780373 * (1.0 + 0.0052891 * pow_2(std::sin(Conv)) - 0.0000059 * pow_2(std::sin(2.0 * Conv)));
   15032             : 
   15033             :     // CALCULATE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   15034             :     // set to zero before summing over zones
   15035       48194 :     Real64 SensibleLoadTotal(0.0); // Total sensible load on WalkIn over all zones (W)
   15036       48194 :     Real64 LatentLoadTotal(0.0);   // total latent load on WalkIn over all zones (W)
   15037       48194 :     Real64 ZoneLatentLoad(0.0);    // Latent WalkIn credit delivered to zone (W)
   15038             : 
   15039       48194 :     this->SensZoneCreditRate = 0.0;
   15040       48194 :     this->SensZoneCreditCoolRate = 0.0;
   15041       48194 :     this->SensZoneCreditCool = 0.0;
   15042       48194 :     this->SensZoneCreditHeatRate = 0.0;
   15043       48194 :     this->SensZoneCreditHeat = 0.0;
   15044       48194 :     this->LatZoneCreditRate = 0.0;
   15045             : 
   15046             :     // Start zone loop:
   15047       96388 :     for (int ZoneID = 1; ZoneID <= this->NumZones; ++ZoneID) {
   15048       48194 :         int zoneNum = this->ZoneNum(ZoneID);
   15049       48194 :         int zoneNodeNum = this->ZoneNodeNum(ZoneID);
   15050       48194 :         Real64 ZoneDryBulb = state.dataLoopNodes->Node(zoneNodeNum).Temp; // Dry Bulb Temperature of adjacent zone
   15051       48194 :         Real64 WalkInLatLoad = -ZoneLatentLoad;                           // Walk in cooler latent load facing particular zone (W)
   15052       48194 :         Real64 DelTemp = ZoneDryBulb - TWalkIn;                           // Difference between zone and walk in temperatures (C)
   15053       48194 :         Real64 StockDoorArea = this->AreaStockDr(ZoneID);
   15054       48194 :         Real64 GlassDoorArea = this->AreaGlassDr(ZoneID);                          // facing a particular zone (m2)
   15055       48194 :         Real64 UAOtherSurfaces = this->SurfaceArea(ZoneID) * this->UValue(ZoneID); // UA for non-door surfaces facing a certain zone (W/C)
   15056       48194 :         Real64 ZInfilSensLoad(0.0);                                                // Sensible load due to infiltration in one zone
   15057       48194 :         Real64 ZdoorSensLoad(0.0);                                                 // Sensible load due to UA delta T through closed door in one zone
   15058             : 
   15059             :         // Derate compared to fully developed flow through 100% open door
   15060       48194 :         Real64 DoorFlowFactor = 0.8;               // see ASHRAE Refrigeration, p13.5, 2006
   15061       48194 :         if (DelTemp <= 11.0) DoorFlowFactor = 1.1; // from ASHRAE Refrigeration Loads
   15062             : 
   15063             :         // Get infiltration loads if either type of door is present in this zone
   15064       48194 :         if (StockDoorArea > 0.0 || GlassDoorArea > 0.0) {
   15065             :             // Zone relative humidity fraction (decimal)
   15066      192776 :             Real64 ZoneRHFrac = Psychrometrics::PsyRhFnTdbWPb(state,
   15067       48194 :                                                               state.dataLoopNodes->Node(zoneNodeNum).Temp,
   15068       48194 :                                                               state.dataLoopNodes->Node(zoneNodeNum).HumRat,
   15069       48194 :                                                               state.dataEnvrn->OutBaroPress,
   15070             :                                                               RoutineName);
   15071             :             // Enthalpy of the air in a particular zone (J/kg)
   15072       48194 :             Real64 EnthalpyZoneAir = Psychrometrics::PsyHFnTdbRhPb(state, ZoneDryBulb, ZoneRHFrac, state.dataEnvrn->OutBaroPress, RoutineName);
   15073       48194 :             Real64 HumRatioZoneAir = Psychrometrics::PsyWFnTdbH(state, ZoneDryBulb, EnthalpyZoneAir, RoutineName);
   15074             :             Real64 DensityZoneAir =
   15075       48194 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneDryBulb, HumRatioZoneAir, RoutineName);
   15076       48194 :             if (DensityZoneAir < DensityAirWalkIn) { // usual case when walk in is colder than zone
   15077       48194 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityZoneAir / DensityAirWalkIn);
   15078       48194 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityAirWalkIn / DensityZoneAir, 0.333)), 1.5);
   15079             :             } else { // temperature inversion with zone colder and/or drier than walk-in, infiltration in reverse direction
   15080             :                 // The enthalpy difference will show whether the energy transport is reversed
   15081             :                 //(same air mass exchange in either direction )
   15082             :                 // That is, these factors establish the magnitude of the exchange air flow, not direction
   15083           0 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityAirWalkIn / DensityZoneAir);
   15084           0 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityZoneAir / DensityAirWalkIn, 0.333)), 1.5);
   15085             :             } // check for density in zone and in walk-in to avoid taking sqrt of neg number
   15086             : 
   15087       48194 :             Real64 StockDoorInfLoad = 0.0;  // infiltration through stock doors in a particular zone (W)
   15088       48194 :             Real64 StockDoorSensHeat = 0.0; // sensible heat gain through stock doors (UA*delta T) (W)
   15089       48194 :             Real64 DoorProtectEff(0.0);     // Door protection effectiveness
   15090       48194 :             Real64 DrHeight(0.0);           // Door height (m)
   15091       48194 :             Real64 DrArea(0.0);             // Door area (m2)
   15092       48194 :             Real64 FullFlowInfLoad(0.0);    // Total load (lat + sens) due to 100% open doors w/ fully developed flow (W)
   15093             : 
   15094       48194 :             if (StockDoorArea > 0.0) {
   15095       48194 :                 switch (this->StockDoorProtectType(ZoneID)) {
   15096             :                     // Values from ASHRAE Ref p 13.6
   15097       25952 :                 case WIStockDoor::None: {
   15098       25952 :                     DoorProtectEff = 0.0;
   15099       25952 :                 } break;
   15100           0 :                 case WIStockDoor::AirCurtain: {
   15101           0 :                     DoorProtectEff = 0.5;
   15102           0 :                 } break;
   15103       22242 :                 case WIStockDoor::StripCurtain: {
   15104       22242 :                     DoorProtectEff = 0.9;
   15105       22242 :                 } break;
   15106           0 :                 default:
   15107           0 :                     break;
   15108             :                 }
   15109       48194 :                 DrHeight = this->HeightStockDr(ZoneID);
   15110       48194 :                 DrArea = StockDoorArea;
   15111             :                 // if exists, get Stock Door Zone schedule
   15112       48194 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor;
   15113       48194 :                 if (this->StockDoorOpenSchedPtr(ZoneID) > 0)
   15114       48194 :                     DoorOpenFactor = ScheduleManager::GetCurrentScheduleValue(state, this->StockDoorOpenSchedPtr(ZoneID));
   15115             : 
   15116       48194 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   15117       48194 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   15118       48194 :                 StockDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   15119       48194 :                 StockDoorSensHeat = DrArea * this->UValueStockDr(ZoneID) * DelTemp;
   15120             :             } // have stock doors
   15121             : 
   15122       48194 :             Real64 GlassDoorSensHeat(0.0); // sensible heat gain through glass reach-in doors (UA*delta T) (W)
   15123       48194 :             Real64 GlassDoorInfLoad = 0.0; // infiltration through glass reach-in doors in a particular zone (W)
   15124             : 
   15125       48194 :             if (GlassDoorArea > 0.0) {
   15126           0 :                 DoorProtectEff = 0.5; // Assume glass doors have air curtain
   15127           0 :                 DrHeight = this->HeightGlassDr(ZoneID);
   15128           0 :                 DrArea = GlassDoorArea;
   15129             :                 // get Glass Door Zone schedule
   15130           0 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor; // default value
   15131           0 :                 if (this->GlassDoorOpenSchedPtr(ZoneID) > 0)
   15132           0 :                     DoorOpenFactor = ScheduleManager::GetCurrentScheduleValue(state, this->GlassDoorOpenSchedPtr(ZoneID));
   15133             : 
   15134           0 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   15135           0 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   15136           0 :                 GlassDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   15137           0 :                 GlassDoorSensHeat = DrArea * this->UValueGlassDr(ZoneID) * DelTemp;
   15138             :             } // have Glass doors
   15139             : 
   15140             :             // assume mass dry air infiltrating into walk-in == mass out into zone,
   15141             :             //                       that is, equal air exchange (ASHRAE 2006 Refrigeration)
   15142       48194 :             Real64 ZoneInfilLoad = -StockDoorInfLoad - GlassDoorInfLoad; // Walk in cooler infiltration load (sens + latent) in certain zone (W)
   15143       48194 :             Real64 MassDryAirRate =
   15144       48194 :                 -ZoneInfilLoad / (EnthalpyZoneAir - EnthalpyAirWalkIn); // Mass dry air infiltrating into/out-of walkin through doors (kg/s)
   15145       48194 :             Real64 WaterRemovRate =
   15146       48194 :                 MassDryAirRate * (HumRatioZoneAir - HumRatioAirWalkIn); // Walk in cooler removes water at this rate in this zone (kg/s)
   15147             :             // Just as with cases,  we assume no latent credit (water removal = 0) to zone or load on cooler during dripdown
   15148             :             // To be consistent with the treatment of refrigerated cases, latent load
   15149             :             //  and latent credit are bothbased on reducing the infiltrating vapor to ice.  (This is
   15150             :             //  slightly greater than if the latent credit were based upon condensing out the water as liquid.)
   15151             :             //  then it would be: ZoneLatentLoad = -WaterRemovRate * WaterToVaporEnthalpy * (1.0d0-DefrostDripDownSchedule)
   15152       48194 :             ZoneLatentLoad = -WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   15153       48194 :             ZInfilSensLoad = ZoneInfilLoad - (-WaterRemovRate * IcetoVaporEnthalpy); // done to avoid moving latent to sens during dripdown
   15154       48194 :             ZdoorSensLoad = -GlassDoorSensHeat - StockDoorSensHeat;
   15155       48194 :             WalkInLatLoad = -ZoneLatentLoad;
   15156       48194 :             if (this->TEvapDesign <= 0.0) { // water turned to ice on coil
   15157       48194 :                 WalkInLatLoad = WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   15158             :                 // FROST:  keep track of frost build up on evaporator coil
   15159             :                 //         avoid accumulation during warm-up to avoid reverse dd test problem
   15160       48194 :                 if (!state.dataGlobal->WarmupFlag) {
   15161        6624 :                     Real64 FrostChangekg = (WaterRemovRate * state.dataGlobal->TimeStepZoneSec) * (1.0 - DefrostDripDownSchedule);
   15162        6624 :                     this->KgFrost += FrostChangekg;
   15163             :                 }
   15164             :             } // water to ice
   15165             :         }     // No doors
   15166             : 
   15167             :         // Sensible WalkIn credit delivered to a particular zone (W)
   15168       48194 :         Real64 ZoneSensLoad = ZInfilSensLoad + ZdoorSensLoad - UAOtherSurfaces * DelTemp;
   15169       48194 :         Real64 WalkInSensLoad = -ZoneSensLoad; // Walk in cooler sensible load facing particular zone (W)
   15170             : 
   15171             :         // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   15172             :         //   Zone Equipment Manager. Sum walk-in credits to zone using existing 'casecredit' variable
   15173             :         //   No return air fractions are applied to walk-ins, and no latent in stocking -
   15174             : 
   15175       48194 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).SenCaseCreditToZone += ZoneSensLoad;
   15176       48194 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).LatCaseCreditToZone += ZoneLatentLoad;
   15177             : 
   15178             :         // Set up report variables for each zone for this walk-in
   15179             :         // Sensible heat exchange can be positive or negative, split into separate output variables and always report positive value
   15180       48194 :         this->SensZoneCreditRate(ZoneID) = ZoneSensLoad;
   15181       48194 :         if (ZoneSensLoad <= 0.0) {
   15182       48194 :             this->SensZoneCreditCoolRate(ZoneID) = -ZoneSensLoad;
   15183       48194 :             this->SensZoneCreditCool(ZoneID) = -ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15184       48194 :             this->SensZoneCreditHeatRate(ZoneID) = 0.0;
   15185       48194 :             this->SensZoneCreditHeat(ZoneID) = 0.0;
   15186             :         } else {
   15187           0 :             this->SensZoneCreditHeatRate(ZoneID) = ZoneSensLoad;
   15188           0 :             this->SensZoneCreditHeat(ZoneID) = ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15189           0 :             this->SensZoneCreditCoolRate(ZoneID) = 0.0;
   15190           0 :             this->SensZoneCreditCool(ZoneID) = 0.0;
   15191             :         }
   15192             :         // This rate should always be negative
   15193       48194 :         this->LatZoneCreditRate(ZoneID) = ZoneLatentLoad;
   15194       48194 :         this->LatZoneCredit(ZoneID) = ZoneLatentLoad * state.dataGlobal->TimeStepZoneSec;
   15195             : 
   15196             :         // Running total over all zones, use later to dispatch capacity
   15197       48194 :         SensibleLoadTotal += WalkInSensLoad;
   15198       48194 :         LatentLoadTotal += WalkInLatLoad;
   15199             : 
   15200             :     } // Do loop over zones for zone-condition-related sensible and latent loads
   15201             : 
   15202             :     // cooling coil fan power default is 375W, = 1/2 HP (Tyler showed 1/3 to 3/4 hp)
   15203             : 
   15204             :     // CALCULATE AUX LOADS DUE TO LIGHTS, FANS AND HEATERS
   15205       48194 :     Real64 LightLoad = this->DesignLighting * LightingSchedule; // Total lighting energy rate (W)
   15206             :     // turn coil fan off during defrost/drip - down period
   15207             : 
   15208             :     // Total fan energy rate (W)
   15209       48194 :     Real64 FanLoad = this->CircFanPower * CircFanSchedule + this->CoilFanPower * (1.0 - DefrostDripDownSchedule);
   15210       48194 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   15211             :     // Calculate floor load - using 'DataEnvironment::GroundTemp' assigned in weather manager (can be entered by user if desired)
   15212             :     //    Default value is 18C.
   15213             :     // Total floor energy rate (W)
   15214             :     Real64 FloorLoad =
   15215       48194 :         this->FloorArea * this->FloorUValue * (state.dataEnvrn->GroundTemp[(int)DataEnvironment::GroundTempType::BuildingSurface] - TWalkIn);
   15216             : 
   15217             :     Real64 DefrostLoad;
   15218             : 
   15219             :     // DEFROST CALCULATIONS
   15220       48194 :     if ((DefrostSchedule > 0.0) && (this->defrostType != WalkinClrDefrostType::None) && (this->defrostType != WalkinClrDefrostType::OffCycle)) {
   15221         616 :         DefrostLoad = this->DefrostCapacity * DefrostSchedule;                  // W
   15222         616 :         Real64 StartFrostKg = this->KgFrost;                                    // frost load at start of time step (kg of ice)
   15223         616 :         Real64 DefrostEnergy = DefrostLoad * state.dataGlobal->TimeStepZoneSec; // Joules
   15224         616 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   15225             :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   15226             :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   15227             :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   15228             :             //  others and xfer heat to environment)
   15229             :             //  Assume full ice melting satisfies temperature control.
   15230             :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   15231           0 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // Joules avail to melt ice
   15232           0 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   15233           0 :             if (StartFrostKg > 0.0) {
   15234           0 :                 if (this->IceTemp < 0.0) {
   15235           0 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   15236           0 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   15237           0 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   15238           0 :                         this->IceTemp = 0.0;
   15239           0 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   15240             :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   15241           0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   15242           0 :                         AvailDefrostEnergy = 0.0;
   15243             :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   15244             :                 }     // IceTemp < 0,  need to raise temperature of ice
   15245             :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   15246           0 :                 Real64 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15247           0 :                 if (FrostChangekg < StartFrostKg) {
   15248           0 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour;
   15249           0 :                     if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   15250             :                     // DefrostSchedule not changed
   15251             :                 } else { // all frost melted during time step, so need to terminate defrost
   15252             :                     //  see Aug 8 page 3 notes
   15253           0 :                     this->KgFrost = 0.0;
   15254           0 :                     DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   15255           0 :                                           this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   15256           0 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (this->DefrostCapacity * state.dataGlobal->TimeStepZoneSec)));
   15257             :                     // reduce load on walkin by energy put into ice melting
   15258           0 :                     DefrostLoad = max(0.0,
   15259           0 :                                       (DefrostSchedule * this->DefrostCapacity -
   15260           0 :                                        (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / state.dataGlobal->TimeStepZoneSec));
   15261           0 :                     this->IceTemp = this->TEvapDesign;
   15262             : 
   15263             :                 }    // frost melted during time step less than amount of ice at start
   15264             :             } else { // no frost present so terminate defrost and reset ice temperature for start of next defrost
   15265           0 :                 DefrostLoad = 0.0;
   15266           0 :                 DefrostSchedule = 0.0;
   15267           0 :                 this->IceTemp = this->TEvapDesign;
   15268             :             } // have frost present
   15269             : 
   15270             :         } else { // Not temperature control type
   15271         616 :             Real64 FrostChangekg = min(DefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15272             :             // Reduce defrost heat load on walkin by amount of ice melted during time step
   15273         616 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::SecInHour;
   15274         616 :             if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   15275             :             // DefrostSchedule not changed
   15276             :         } // Temperature termination control type
   15277             : 
   15278         616 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   15279       47578 :         DefrostLoad = 0.0;
   15280             :     } // Defrost calculations
   15281             : 
   15282       48194 :     if (this->defrostType == WalkinClrDefrostType::Elec) {
   15283       35218 :         this->ElecDefrostConsumption = this->DefrostCapacity * DefrostSchedule * state.dataGlobal->TimeStepZoneSec;
   15284       35218 :         this->ElecDefrostPower = this->DefrostCapacity * DefrostSchedule;
   15285             :     } else {
   15286       12976 :         this->ElecDefrostConsumption = 0.0;
   15287       12976 :         this->ElecDefrostPower = 0.0;
   15288             :     }
   15289             : 
   15290             :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   15291       48194 :     if (this->defrostType == WalkinClrDefrostType::Fluid) this->HotDefrostCondCredit = this->DefrostCapacity * DefrostSchedule;
   15292             : 
   15293             :     // loads reflects that walk ins continue to accumulate loads, even during defrost
   15294             :     // but cap is used to report portion met by active system while operating
   15295             : 
   15296             :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   15297       48194 :     SensibleLoadTotal += LightLoad + HeaterLoad + FanLoad + StockingLoad + DefrostLoad + FloorLoad;
   15298       48194 :     Real64 LoadTotal = SensibleLoadTotal + LatentLoadTotal; // total load in time step (W)
   15299             : 
   15300             :     // Account for difference between load and capacity. Assume rack or system able to provide
   15301             :     // rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   15302             :     //  Here we are calculating the load the walk-in cooler places on the refrigeration compressor systems.
   15303             :     //  Meet current load to the extent possible.  If extra capacity available,
   15304             :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   15305             :     //  (e.g. as it is during defrost cycles) save the unmet/stored load to be met in
   15306             :     //  succeeding time steps. This is an artificial way of recognizing that the internal
   15307             :     //  temperature will increase by a small amount during defrost and the system will have to
   15308             :     //  run full out until the temperature is brought back down.
   15309             : 
   15310             :     // Rate needed to serve all stored energy during single time step (W)
   15311       48194 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour;
   15312       48194 :     Real64 LoadRequested = LoadTotal + StoredEnergyRate; // Load necessary to meet current and all stored energy needs (W)
   15313             : 
   15314             :     Real64 LatentCapApplied;        // Walk In latent capacity at specific operating conditions
   15315       48194 :     Real64 SensibleCapApplied(0.0); // Walk In sensible capacity at specific operating conditions
   15316             : 
   15317             :     // prorate available cooling capacity for portion of time off due to drip down.
   15318       48194 :     Real64 MaxCap = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule); // Design chilling capacity reduced according to drip-down schedule (W)
   15319             : 
   15320       48194 :     if (MaxCap >= LoadRequested) {
   15321             :         // Have more at least as much capacity available as needed, even counting stored energy
   15322       47160 :         CapApplied = LoadRequested;
   15323       47160 :         SensibleCapApplied = SensibleLoadTotal + StoredEnergyRate;
   15324       47160 :         LatentCapApplied = LatentLoadTotal;
   15325       47160 :         this->StoredEnergy = 0.0;
   15326             :     } else {
   15327             :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   15328        1034 :         CapApplied = MaxCap;
   15329        1034 :         LatentCapApplied = min(LatentLoadTotal, MaxCap); // Latent load should never be > capavail, but just in case...
   15330        1034 :         SensibleCapApplied = CapApplied - LatentCapApplied;
   15331        1034 :         if (!state.dataGlobal->WarmupFlag) this->StoredEnergy += (LoadTotal - MaxCap) * state.dataGlobal->TimeStepZoneSec;
   15332             :     } // CapAvail vs Load requested
   15333             : 
   15334             :     // ReportWalkIn( WalkInID)
   15335       48194 :     this->TotalCoolingLoad = CapApplied;
   15336       48194 :     this->TotalCoolingEnergy = CapApplied * state.dataGlobal->TimeStepZoneSec;
   15337       48194 :     this->TotSensCoolingEnergyRate = SensibleCapApplied;
   15338       48194 :     this->TotSensCoolingEnergy = SensibleCapApplied * state.dataGlobal->TimeStepZoneSec;
   15339       48194 :     this->TotLatCoolingEnergyRate = LatentCapApplied;
   15340       48194 :     this->TotLatCoolingEnergy = LatentCapApplied * state.dataGlobal->TimeStepZoneSec;
   15341             : 
   15342       48194 :     this->ElecFanPower = FanLoad;
   15343       48194 :     this->ElecFanConsumption = FanLoad * state.dataGlobal->TimeStepZoneSec;
   15344       48194 :     this->ElecHeaterPower = HeaterLoad;
   15345       48194 :     this->ElecHeaterConsumption = HeaterLoad * state.dataGlobal->TimeStepZoneSec;
   15346       48194 :     this->ElecLightingPower = LightLoad;
   15347       48194 :     this->ElecLightingConsumption = LightLoad * state.dataGlobal->TimeStepZoneSec;
   15348       48194 :     this->TotalElecPower = FanLoad + HeaterLoad + LightLoad + this->ElecDefrostPower;
   15349       48194 :     this->TotalElecConsumption = this->TotalElecPower * state.dataGlobal->TimeStepZoneSec;
   15350             : 
   15351             :     //**************************************************************************************************
   15352             :     // Cap Energy and Kg Frost to avoid floating overflow errors
   15353             :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   15354       48194 :     if (this->StoredEnergy > MyLargeNumber) {
   15355           0 :         this->StoredEnergy = MyLargeNumber;
   15356           0 :         if (this->ShowUnmetWIEnergyWarning) {
   15357           0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   15358           0 :             ShowContinueError(state, " This walk-in cooler has insufficient capacity to meet the loads");
   15359           0 :             ShowContinueError(state,
   15360           0 :                               format("... Occurrence info = {}, {} {}",
   15361           0 :                                      state.dataEnvrn->EnvironmentName,
   15362           0 :                                      state.dataEnvrn->CurMnDy,
   15363           0 :                                      General::CreateSysTimeIntervalString(state)));
   15364           0 :             ShowContinueError(state, " Refer to documentation for further explanation of Total Cooling Capacity.");
   15365           0 :             this->ShowUnmetWIEnergyWarning = false;
   15366             :         } // ShowStoreEnergyWarning
   15367             :     }     // stored energy > large number
   15368       48194 :     if (this->KgFrost > MyLargeNumber) {
   15369           0 :         this->KgFrost = MyLargeNumber;
   15370           0 :         if (this->ShowWIFrostWarning) {
   15371           0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   15372           0 :             ShowContinueError(state, " This walkin cooler has insufficient defrost capacity to remove the excess frost accumulation.");
   15373           0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   15374           0 :             ShowContinueError(state,
   15375           0 :                               format("... Occurrence info = {}, {} {}",
   15376           0 :                                      state.dataEnvrn->EnvironmentName,
   15377           0 :                                      state.dataEnvrn->CurMnDy,
   15378           0 :                                      General::CreateSysTimeIntervalString(state)));
   15379           0 :             this->ShowWIFrostWarning = false;
   15380             :         }
   15381             :     }
   15382             : }
   15383             : 
   15384        4044 : void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const SecondaryNum)
   15385             : {
   15386             :     // SUBROUTINE INFORMATION:
   15387             :     //       AUTHOR         Therese Stovall, ORNL
   15388             :     //       DATE WRITTEN   Spring 2009
   15389             :     //       RE-ENGINEERED  na
   15390             : 
   15391             :     // PURPOSE OF THIS SUBROUTINE:
   15392             :     // Find the total cooling load, pump power, and needed primary refrigerant supply temperature
   15393             :     // for a secondary system.
   15394             : 
   15395             :     // METHODOLOGY EMPLOYED:
   15396             :     // Sum the loads for the cases and walk-ins supplied by a secondary loop.
   15397             :     // Calculate the pumping power.
   15398             :     // Assume that the fluid supply and return temperatures are fixed and the
   15399             :     // fluid flow rate is varied to meed the variable load.
   15400             :     // User has been told in IO and Eng ref: for secondary systems/pumps: pump energy is f(viscosity),
   15401             :     //        but since specifying Tcircfluid as steady
   15402             :     //        state in loop, specify power for fluid and system head/resistance at that temp
   15403             :     // ashrae 2006 p4.1 supports 78% eff for pump impellers
   15404             :     //  all power into heat because it would otherwise not be counted in zone
   15405             :     //  if use semihermetic motor, also need to add motor ineff as heat
   15406             : 
   15407             :     // REFERENCES:
   15408             :     // SCE report
   15409             :     //  others
   15410             : 
   15411        4044 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   15412             : 
   15413             :     bool AtPartLoad;          // Whether or not need to iterate on pump power
   15414             :     bool DeRate;              // If true, need to derate aircoils because don't carry over unmet energy
   15415             :     int Iter;                 // loop counter
   15416             :     Real64 CpBrine;           // Specific heat (W/kg)
   15417             :     Real64 DensityBrine;      // Density (kg/m3)
   15418             :     Real64 DiffTemp;          // (C)
   15419             :     Real64 distPipeHeatGain;  // Optional (W)
   15420             :     Real64 Error;             // Used in iterative soln for pumps needed to meet load (that has to include pump energy)
   15421             :     Real64 FlowVolNeeded;     // Flow rate needed to meet load (m3/s)
   15422             :     Real64 PartLdFrac;        // Used to ratio pump power
   15423             :     Real64 PartPumpFrac;      // Used to see if part pumps dispatched meets part pump load
   15424             :     Real64 PrevTotalLoad;     // Used in pump energy convergence test
   15425             :     Real64 RefrigerationLoad; // Load for cases and walk-ins served by loop, does not include pump energy (W)
   15426             :     Real64 StoredEnergyRate;  // Used to meet loads unmet in previous time step (related to defrost cycles
   15427             :     //     on cases/walk-ins served)(W)
   15428             :     Real64 TBrineIn;                  // Brine temperature going to heat exchanger, C
   15429             :     Real64 TotalHotDefrostCondCredit; // Used to credit condenser when heat reclaim used for hot gas/brine defrost (W)
   15430             :     Real64 TotalPumpPower;            // Total Pumping power for loop, W
   15431             :     Real64 TotalLoad;                 // Total Cooling Load on secondary loop, W
   15432        4044 :     Real64 TPipesReceiver(0.0);       // Temperature used for contents of pipes and/or receiver in calculating shell losses (C)
   15433             :     Real64 VarFrac;                   // Pump power fraction for variable speed pump, dimensionless
   15434             :     Real64 VolFlowRate;               // Used in dispatching pumps to meet load (m3/s)
   15435             : 
   15436        4044 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   15437        4044 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   15438        4044 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15439             : 
   15440        4044 :     Real64 LocalTimeStep = state.dataGlobal->TimeStepZone;
   15441        4044 :     if (state.dataRefrigCase->UseSysTimeStep) LocalTimeStep = state.dataHVACGlobal->TimeStepSys;
   15442             : 
   15443        4044 :     switch (this->FluidType) {
   15444        2022 :     case SecFluidType::AlwaysLiquid: {
   15445        2022 :         CpBrine = this->CpBrineRated;
   15446        2022 :         DensityBrine = this->DensityBrineRated;
   15447        2022 :         TBrineIn = this->TBrineInRated;
   15448        2022 :         TPipesReceiver = this->TBrineAverage;
   15449        2022 :     } break;
   15450        2022 :     case SecFluidType::PhaseChange: {
   15451        2022 :         TPipesReceiver = this->TCondense;
   15452        2022 :     } break;
   15453           0 :     default:
   15454           0 :         break;
   15455             :     } // Fluid type
   15456             : 
   15457             :     // Initialize this secondary for this time step
   15458        4044 :     TotalPumpPower = 0.0;
   15459        4044 :     RefrigerationLoad = 0.0;
   15460        4044 :     TotalHotDefrostCondCredit = 0.0;
   15461        4044 :     FlowVolNeeded = 0.0;
   15462        4044 :     DeRate = false;
   15463             : 
   15464             :     // SCE page 28 gives a delta T for pipe heat gains
   15465             :     //         (.25F each for supply and discharge) for use with mdot*cp.
   15466             :     //          However, another author shows this as a major diff between dx and secondary
   15467             :     //          So - allow the user to include this in his total load, even though he has to do
   15468             :     //          most of the calculations before the input (to get to SumUADistPiping)).
   15469        4044 :     distPipeHeatGain = 0.0;
   15470        4044 :     if (this->SumUADistPiping > MySmallNumber) {
   15471        4044 :         int ZoneNodeNum = this->DistPipeZoneNodeNum;
   15472        4044 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15473        4044 :         distPipeHeatGain = DiffTemp * this->SumUADistPiping;
   15474             :         // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   15475             :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   15476        4044 :         this->DistPipeZoneHeatGain = -distPipeHeatGain;
   15477        4044 :         state.dataHeatBal->RefrigCaseCredit(this->DistPipeZoneNum).SenCaseCreditToZone -= distPipeHeatGain;
   15478             :     } // calc distribution piping heat gains
   15479             : 
   15480        4044 :     Real64 receiverHeatGain = 0.0;
   15481        4044 :     if (this->SumUAReceiver > MySmallNumber) {
   15482        2022 :         int ZoneNodeNum = this->ReceiverZoneNodeNum;
   15483        2022 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15484        2022 :         receiverHeatGain = DiffTemp * this->SumUAReceiver;
   15485             :         // receiver heat load is a positive number (ie. heat absorbed by receiver, so needs to be subtracted
   15486             :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   15487        2022 :         this->ReceiverZoneHeatGain = -receiverHeatGain;
   15488        2022 :         state.dataHeatBal->RefrigCaseCredit(this->ReceiverZoneNum).SenCaseCreditToZone -= receiverHeatGain;
   15489             :     } // calc receiver heat gains
   15490             : 
   15491             :     // Sum up all the case and walk-in loads served by the secondary loop
   15492        4044 :     if (this->NumCases > 0) {
   15493       18198 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   15494       14154 :             int CaseID = this->CaseNum(caseNum);
   15495       14154 :             RefrigCase(CaseID).CalculateCase(state);
   15496             :             // increment TotalCoolingLoad Hot gas/brine defrost credits for each secondary loop
   15497       14154 :             RefrigerationLoad += RefrigCase(CaseID).TotalCoolingLoad;
   15498       14154 :             TotalHotDefrostCondCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   15499             :         } // CaseNum
   15500             :     }     // NumCases > 0
   15501        4044 :     if (this->NumWalkIns > 0) {
   15502        4044 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   15503        2022 :             int WalkInID = this->WalkInNum(WalkInIndex);
   15504        2022 :             WalkIn(WalkInID).CalculateWalkIn(state);
   15505             :             // increment TotalCoolingLoad for  each system
   15506        2022 :             RefrigerationLoad += WalkIn(WalkInID).TotalCoolingLoad;
   15507        2022 :             TotalHotDefrostCondCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   15508             :         } // NumWalkIns systems
   15509             :     }     // Secondary(SecondaryNum)%NumWalkIns > 0
   15510             : 
   15511        4044 :     if (this->NumCoils > 0) {
   15512           0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15513           0 :             int CoilID = this->CoilNum(CoilIndex);
   15514             :             // already CALL CalculateCoil(CoilID) for each coil, dispatched in coilset order for each zone
   15515             :             // increment TotalCoolingLoad for each system
   15516             :             //  here will find out if secondary can serve total load, if not will derate coil outout/case credits
   15517           0 :             RefrigerationLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   15518           0 :             TotalHotDefrostCondCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   15519             :         } // NumCoils on secondary system
   15520             :     }     // Secondary(SecondaryNum)%NumCoils > 0
   15521             : 
   15522        4044 :     TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain;
   15523        4044 :     AtPartLoad = true;
   15524             :     // Check to see if load is already >+ maxload without pump heat
   15525        4044 :     if (this->FluidType == SecFluidType::AlwaysLiquid) { //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15526        2022 :         FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   15527             :         // For brine/glycol systems, find flow volume needed to meet load
   15528             :         // Per ashrae 2006, p4.1, eval mass flow rate to pump at brine return (to chiller) temp
   15529             :         //   because pumps located in return piping
   15530        2022 :         if (FlowVolNeeded >= this->MaxVolFlow) {
   15531             :             // Don't need to iterate on pumps, just set to max.  Will have unmet load this time step (unless coils present)
   15532           4 :             VolFlowRate = this->MaxVolFlow;
   15533           4 :             TotalPumpPower = this->PumpTotRatedPower;
   15534           4 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15535           4 :             AtPartLoad = false;
   15536           4 :             if (this->NumCoils > 0) DeRate = true;
   15537             :         }    // flowvolneeded >= maxvolflow
   15538             :     } else { // have SecFluidTypePhaseChange !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15539        2022 :         if (TotalLoad >= this->MaxLoad) {
   15540           5 :             TotalPumpPower = this->PumpTotRatedPower;
   15541           5 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15542           5 :             VolFlowRate = this->MaxVolFlow;
   15543           5 :             AtPartLoad = false;
   15544           5 :             if (this->NumCoils > 0) DeRate = true;
   15545             :         }
   15546             :     } // fluid type check for max load or max flow       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15547             : 
   15548             :     // If totalLoad < maxload, then need to calculate partial pump load
   15549             :     // Need an iterative soln for pump energy needed to meet total load
   15550             :     //  because that total load has to include pump energy
   15551        4044 :     if (AtPartLoad) {
   15552        7287 :         for (Iter = 1; Iter <= 10; ++Iter) {
   15553        7287 :             if (TotalLoad <= 0.0) {
   15554             :                 // Load on secondary loop is zero (or negative).
   15555             :                 // Set volumetric flow rate and pump power to be zero.
   15556           0 :                 VolFlowRate = 0.0;
   15557           0 :                 TotalPumpPower = 0.0;
   15558           0 :                 break;
   15559             :             }
   15560        7287 :             PrevTotalLoad = TotalLoad;
   15561        7287 :             if (this->FluidType == SecFluidType::AlwaysLiquid) {
   15562        4113 :                 FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   15563        4113 :                 PartLdFrac = FlowVolNeeded / this->MaxVolFlow;
   15564             :             } else {
   15565        3174 :                 PartLdFrac = TotalLoad / this->MaxLoad;
   15566             :             }
   15567        7287 :             if (this->PumpControlType == SecPumpCtrl::Constant) {
   15568        4113 :                 VolFlowRate = 0.0;
   15569        4113 :                 TotalPumpPower = 0.0;
   15570       10022 :                 for (int PumpID = 1; PumpID <= this->NumPumps; ++PumpID) { // dispatch pumps to meet needed flow rate
   15571       10022 :                     if (this->FluidType == SecFluidType::AlwaysLiquid) {   //>>>>>>>>>>>>>>>>>>>>>
   15572       10022 :                         VolFlowRate += this->PumpIncrementFlowVol;
   15573       10022 :                         TotalPumpPower += this->PumpIncrementPower;
   15574       10022 :                         if (VolFlowRate >= FlowVolNeeded) break;
   15575             :                     } else { // fluid type phase change >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15576           0 :                         VolFlowRate += this->PumpIncrementFlowVol;
   15577           0 :                         TotalPumpPower += this->PumpIncrementPower;
   15578           0 :                         PartPumpFrac = TotalPumpPower / this->PumpTotRatedPower;
   15579           0 :                         if (PartPumpFrac >= PartLdFrac) break;
   15580             :                     } // fluid type              >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15581             :                 }     // Dispatching pumps until fluid flow need is met
   15582             :             } else {  // pump type variable
   15583        3174 :                 VarFrac = max(0.1, Curve::CurveValue(state, this->VarSpeedCurvePtr, PartLdFrac));
   15584        3174 :                 TotalPumpPower = this->PumpTotRatedPower * VarFrac;
   15585        3174 :                 VolFlowRate = this->MaxVolFlow * PartLdFrac;
   15586             :             } // pump type
   15587             : 
   15588        7287 :             TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain + TotalPumpPower * this->PumpPowerToHeat;
   15589        7287 :             Error = std::abs((TotalLoad - PrevTotalLoad) / PrevTotalLoad);
   15590        7287 :             if (Error < ErrorTol) break;
   15591             :         } // end iteration on pump energy convergence
   15592             : 
   15593             :         //   IF (Iter >=10 .AND. .NOT. WarmupFlag)THEN
   15594             :         //     If( .not. WarmupFlag) Then
   15595             :         //      Write(OutputFileDebug,707)Month, DataGlobals::CurrentTime, Iter, TotalLoad, TotalPumpPower
   15596             :         //     End If
   15597             :         // 707 format(' in iter loop at 707: ',1x,I2,1x,F5.2,1x,I5,7(F10.5,1x))
   15598             :         //    END IF  !didn't converge
   15599             :     } //(AtPartLoad)
   15600             : 
   15601             :     // If only loads are cases and walk-ins, that is, no air coils:
   15602             :     //  Account for difference between load and capacity on secondary loop. Assume system able to provide
   15603             :     //  rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   15604             :     //  Meet current load to the extent possible.  If extra capacity available,
   15605             :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   15606             :     //  (e.g. as it may be following defrost cycles on cases or walk-ins served by secondary loop)
   15607             :     //  save the unmet/stored load to be met in succeeding time steps.
   15608        4044 :     if (this->NumCoils == 0) {
   15609        4044 :         StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::SecInHour));
   15610             :         // Load necessary to meet current and all stored energy needs (W)
   15611        4044 :         Real64 LoadRequested = TotalLoad + StoredEnergyRate;
   15612        4044 :         if (this->MaxLoad > LoadRequested) {
   15613             :             // Have at least as much capacity avail as needed, even counting stored energy
   15614        4030 :             this->TotalCoolingLoad = LoadRequested;
   15615        4030 :             RefrigerationLoad += StoredEnergyRate;
   15616        4030 :             this->UnmetEnergy = 0.0;
   15617             :         } else {
   15618             :             // Don't have as much capacity as needed (likely following defrost periods)
   15619          14 :             this->TotalCoolingLoad = this->MaxLoad;
   15620          14 :             RefrigerationLoad -= (TotalLoad - this->MaxLoad);
   15621          14 :             if (!state.dataGlobal->WarmupFlag) this->UnmetEnergy += ((TotalLoad - this->MaxLoad) * state.dataGlobal->TimeStepZoneSec);
   15622             :         } // load requested greater than MaxLoad
   15623        4044 :         if (this->UnmetEnergy > MyLargeNumber) {
   15624           0 :             this->UnmetEnergy = MyLargeNumber;
   15625           0 :             if (state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum)) {
   15626           0 :                 ShowWarningError(state, format("Secondary Refrigeration Loop: {}", this->Name));
   15627           0 :                 ShowContinueError(state, " This secondary system has insufficient capacity to meet the refrigeration loads.");
   15628           0 :                 state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum) = false;
   15629             :             }
   15630             :         } //>my large number
   15631             : 
   15632             :     } else { // air coils on secondary loop, no "unmet" energy accounting, just reduce amount of cooling provided to zone by coils
   15633           0 :         DeRate = false;
   15634           0 :         if (TotalLoad > this->MaxLoad) DeRate = true;
   15635           0 :         FinalRateCoils(
   15636             :             state, DeRate, SourceType::SecondarySystem, SecondaryNum, TotalLoad, this->MaxLoad); // assign case credits for coils on this loop
   15637             :         // Bug TotalCoolingLoad not set but used below
   15638             :     } // no air coils on secondary loop
   15639        4044 :     this->PumpPowerTotal = TotalPumpPower;
   15640        4044 :     this->PumpElecEnergyTotal = TotalPumpPower * LocalTimeStep * Constant::SecInHour;
   15641        4044 :     this->TotalRefrigLoad = RefrigerationLoad;
   15642        4044 :     this->TotalRefrigEnergy = RefrigerationLoad * LocalTimeStep * Constant::SecInHour;
   15643        4044 :     this->TotalCoolingEnergy = TotalCoolingLoad * LocalTimeStep * Constant::SecInHour;
   15644        4044 :     this->FlowVolActual = VolFlowRate;
   15645        4044 :     this->HotDefrostCondCredit = TotalHotDefrostCondCredit;
   15646        4044 :     this->DistPipeHeatGain = distPipeHeatGain;
   15647        4044 :     this->DistPipeHeatGainEnergy = distPipeHeatGain * LocalTimeStep * Constant::SecInHour;
   15648        4044 :     this->ReceiverHeatGain = receiverHeatGain;
   15649        4044 :     this->ReceiverHeatGainEnergy = receiverHeatGain * LocalTimeStep * Constant::SecInHour;
   15650        4044 : }
   15651             : 
   15652      564713 : void SumZoneImpacts(EnergyPlusData &state)
   15653             : {
   15654             : 
   15655             :     // SUBROUTINE INFORMATION:
   15656             :     //       AUTHOR         Therese Stovall, ORNL
   15657             :     //       DATE WRITTEN   Spring 2010
   15658             :     //       RE-ENGINEERED  na
   15659             : 
   15660             :     // PURPOSE OF THIS SUBROUTINE:
   15661             :     // Find the total impact of all refrigeration systems on each zone.
   15662             : 
   15663             :     // METHODOLOGY EMPLOYED:
   15664             :     // Calculate the energy from refrigerated case credits arising from interaction between the zone and:
   15665             :     //   refrigerated cases and walk-ins
   15666             :     //   heat rejection from zone-located compressor-racks and zone-located air-cooled condensers
   15667             :     //   heat absorbed by suction piping, secondary loop distribution piping, and
   15668             :     //   secondary receiver shells
   15669             : 
   15670      564713 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15671      564713 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   15672             : 
   15673      564713 :     if (state.dataRefrigCase->UseSysTimeStep) { // air chillers
   15674     5343825 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15675     4987570 :             auto &credit = CoilSysCredit(ZoneNum);
   15676     4987570 :             credit.ReportH2ORemovedKgPerS_FromZoneRate = -credit.LatKgPerS_ToZoneRate;
   15677     4987570 :             credit.ReportLatCreditToZoneRate = -credit.LatCreditToZoneRate;
   15678     4987570 :             credit.ReportLatCreditToZoneEnergy = -credit.LatCreditToZoneEnergy;
   15679             :             // Sensible rate can be positive or negative, split into separate output variables and
   15680             :             //   always report positive value
   15681     4987570 :             if (credit.SenCreditToZoneRate <= 0.0) {
   15682     4588702 :                 credit.ReportSenCoolingToZoneRate = -credit.SenCreditToZoneRate;
   15683     4588702 :                 credit.ReportSenCoolingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15684     4588702 :                 credit.ReportHeatingToZoneRate = 0.0;
   15685     4588702 :                 credit.ReportHeatingToZoneEnergy = 0.0;
   15686             :             } else {
   15687      398868 :                 credit.ReportSenCoolingToZoneRate = 0.0;
   15688      398868 :                 credit.ReportSenCoolingToZoneEnergy = 0.0;
   15689      398868 :                 credit.ReportHeatingToZoneRate = credit.SenCreditToZoneRate;
   15690      398868 :                 credit.ReportHeatingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15691             :             }
   15692     4987570 :             credit.ReportTotCoolingToZoneRate = credit.ReportLatCreditToZoneRate + credit.ReportSenCoolingToZoneRate;
   15693     4987570 :             credit.ReportTotCoolingToZoneEnergy = credit.ReportLatCreditToZoneEnergy + credit.ReportSenCoolingToZoneEnergy;
   15694             :         }
   15695             :     } // UseSysTimeStep signals run for air chillers
   15696             : 
   15697             :     // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   15698      773171 :     if ((!state.dataRefrigCase->UseSysTimeStep) &&
   15699      208458 :         ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   15700     5161862 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15701     4953404 :             auto &report = CaseWIZoneReport(ZoneNum);
   15702     4953404 :             report.SenCaseCreditToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15703             :             // Latent always negative
   15704     4953404 :             report.LatCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15705     4953404 :             report.LatCoolingToZoneEnergy = report.LatCoolingToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15706             :             // Sensible rate can be positive or negative, split into separate output variables and
   15707             :             //   always report positive value
   15708     4953404 :             if (state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone <= 0.0) {
   15709     4891730 :                 report.SenCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15710     4891730 :                 report.SenCoolingToZoneEnergy = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15711     4891730 :                 report.HeatingToZoneRate = 0.0;
   15712     4891730 :                 report.HeatingToZoneEnergy = 0.0;
   15713             :             } else {
   15714       61674 :                 report.SenCoolingToZoneRate = 0.0;
   15715       61674 :                 report.SenCoolingToZoneEnergy = 0.0;
   15716       61674 :                 report.HeatingToZoneRate = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15717       61674 :                 report.HeatingToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15718             :             }
   15719     4953404 :             report.TotCoolingToZoneRate = report.SenCoolingToZoneRate + report.LatCoolingToZoneRate;
   15720     4953404 :             report.TotCoolingToZoneEnergy = report.SenCoolingToZoneEnergy + report.LatCoolingToZoneEnergy;
   15721     4953404 :             report.TotHtXferToZoneRate =
   15722     4953404 :                 state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone + state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15723     4953404 :             report.TotHtXferToZoneEnergy = report.TotHtXferToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15724             :         } // over zones for cases and walkins
   15725             :     }
   15726      564713 : }
   15727             : 
   15728     3625828 : void CheckRefrigerationInput(EnergyPlusData &state)
   15729             : {
   15730             : 
   15731             :     // SUBROUTINE INFORMATION:
   15732             :     //       AUTHOR         Linda Lawrie
   15733             :     //       DATE WRITTEN   Sep 2010 - mining function
   15734             :     //       MODIFIED       na
   15735             :     //       RE-ENGINEERED  na
   15736             : 
   15737             :     // PURPOSE OF THIS SUBROUTINE:
   15738             :     // Provides the structure to get Refrigeration input so that
   15739             :     // it can be called from internally or outside the module.
   15740             : 
   15741     3625828 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   15742             : 
   15743         796 :         GetRefrigerationInput(state);
   15744         796 :         SetupReportInput(state);
   15745         796 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   15746             : 
   15747         796 :         if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->HaveChillers)) {
   15748         759 :             state.dataRefrigCase->ManageRefrigeration = false;
   15749         759 :             return;
   15750             :         }
   15751          37 :         if ((!state.dataRefrigCase->HaveDetailedRefrig) && (!state.dataRefrigCase->HaveRefrigRacks) &&
   15752           0 :             (!state.dataRefrigCase->HaveDetailedTransRefrig)) {
   15753           0 :             state.dataRefrigCase->ManageRefrigeration = false;
   15754           0 :             return;
   15755             :         }
   15756             :     } // GetRefrigerationInputFlag
   15757             : }
   15758             : 
   15759      356260 : void SimAirChillerSet(EnergyPlusData &state,
   15760             :                       std::string const &AirChillerSetName,
   15761             :                       int const ZoneNum,
   15762             :                       bool const FirstHVACIteration,
   15763             :                       Real64 &SysOutputProvided,
   15764             :                       Real64 &LatOutputProvided,
   15765             :                       int &AirChillerSetPtr // from ZoneEquipList(CurZoneEqNum)%EquipIndex(EquipPtr)
   15766             : )
   15767             : {
   15768             : 
   15769             :     // SUBROUTINE INFORMATION:
   15770             :     //       AUTHOR         Therese Stovall, ORNL
   15771             :     //       DATE WRITTEN   January 2011
   15772             :     //       MODIFIED       na
   15773             :     //       RE-ENGINEERED  na
   15774             : 
   15775             :     // PURPOSE OF THIS SUBROUTINE:
   15776             :     // Transfers the load requested from the zone to the refrigeration module.
   15777             :     // The load is met, partially met, or not met in the call to the detailed system solution
   15778             :     // METHODOLOGY EMPLOYED:
   15779             :     // Called from Zone Equipment Manager.
   15780             : 
   15781      356260 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   15782      356260 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15783             : 
   15784             :     int ChillerSetID;
   15785             :     Real64 RemainingOutputToCoolingSP; // Remaining requested load in zone
   15786             : 
   15787      356260 :     CheckRefrigerationInput(state);
   15788             : 
   15789             :     // Find the correct Chiller set
   15790      356260 :     if (AirChillerSetPtr == 0) {
   15791          10 :         ChillerSetID = Util::FindItemInList(AirChillerSetName, AirChillerSet);
   15792          10 :         if (ChillerSetID == 0) {
   15793           0 :             ShowFatalError(state, format("SimAirChillerSet: Unit not found={}", AirChillerSetName));
   15794             :         } // chillersetid ==0 because not in list
   15795          10 :         AirChillerSetPtr = ChillerSetID;
   15796             :     } else { // airchllersetpointer passed in call to subroutine not ==0
   15797      356250 :         ChillerSetID = AirChillerSetPtr;
   15798      356250 :         if (ChillerSetID > state.dataRefrigCase->NumRefrigChillerSets || ChillerSetID < 1) {
   15799           0 :             ShowFatalError(state,
   15800           0 :                            format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Number of Units={}, Entered Unit name={}",
   15801             :                                   ChillerSetID,
   15802           0 :                                   state.dataRefrigCase->NumRefrigChillerSets,
   15803             :                                   AirChillerSetName));
   15804             :         } // ChillerSetID makes no sense
   15805      356250 :         if (state.dataRefrigCase->CheckChillerSetName(ChillerSetID)) {
   15806          10 :             if (AirChillerSetName != AirChillerSet(ChillerSetID).Name) {
   15807           0 :                 ShowFatalError(state,
   15808           0 :                                format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Unit name={}, stored Unit Name for that index={}",
   15809             :                                       ChillerSetID,
   15810             :                                       AirChillerSetName,
   15811           0 :                                       AirChillerSet(ChillerSetID).Name));
   15812             :             } // name not equal correct name
   15813          10 :             state.dataRefrigCase->CheckChillerSetName(ChillerSetID) = false;
   15814             :         } // CheckChillerSetName logical test
   15815             :     }     //(AirChillerSetPtr == 0 or else not == 0
   15816             : 
   15817      356260 :     if (FirstHVACIteration) {
   15818     1959760 :         for (ChillerSetID = 1; ChillerSetID <= state.dataRefrigCase->NumRefrigChillerSets;
   15819             :              ++ChillerSetID) { // bbb what point of do loop, only set one (airchillersetptr) to zero
   15820     1781600 :             AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15821             :         }
   15822             :     } // FirstHVACIteration
   15823             : 
   15824      356260 :     RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
   15825             :     // RemainingOutputToCoolingSP in Watts, < 0 for cooling demand
   15826             : 
   15827      356260 :     if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::ThermostatType::SingleHeating) {
   15828      291453 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = RemainingOutputToCoolingSP;
   15829             :     } else {
   15830       64807 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15831             :     }
   15832             : 
   15833      356260 :     state.dataRefrigCase->UseSysTimeStep = true;
   15834             : 
   15835      356260 :     ManageRefrigeratedCaseRacks(state);
   15836             : 
   15837      356260 :     state.dataRefrigCase->UseSysTimeStep = false;
   15838             : 
   15839             :     // Return values to Zone Equipment Manager.
   15840      356260 :     LatOutputProvided = CoilSysCredit(ZoneNum).LatKgPerS_ToZoneRate;
   15841      356260 :     SysOutputProvided = CoilSysCredit(ZoneNum).SenCreditToZoneRate;
   15842      356260 : }
   15843             : 
   15844     3562550 : void AirChillerSetData::CalculateAirChillerSets(EnergyPlusData &state)
   15845             : {
   15846             : 
   15847             :     // SUBROUTINE INFORMATION:
   15848             :     //       AUTHOR         Therese Stovall, ORNL
   15849             :     //       DATE WRITTEN   January 2011
   15850             :     //       MODIFIED       na
   15851             :     //       RE-ENGINEERED  na
   15852             : 
   15853             :     // PURPOSE OF THIS SUBROUTINE:
   15854             :     // Transfers the load requested from the zone to the refrigeration module.
   15855             :     // The load is met, partially met, or not met in the next time step when the refrigerated case
   15856             :     // module is called via case credits. Therefore, by definition, the sensible and latent
   15857             :     // output provided are zero.
   15858             :     // METHODOLOGY EMPLOYED:
   15859             :     // Called from Zone Equipment Manager.
   15860             :     //       have however done the variable definitions for in and out.
   15861             : 
   15862     3562550 :     Real64 AirChillerSetSchedule = 0.0; // Schedule value for air chiller SET
   15863     3562550 :     Real64 QZNReqSens = 0.0;            // Amount of sensible heat needed by the zone, NEGATIVE when cooling needed [W]
   15864     3562550 :     Real64 RemainQZNReqSens = 0.0;      // Remaining amount of sensible heat needed by the zone [W]
   15865             : 
   15866     3562550 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15867             : 
   15868             :     // Note, all coils in a coil set are in the same zone
   15869             :     // the coils may be served by different detailed systems
   15870             :     // The coils are dispatched to meet the load specified in the previous time step in order listed in coilset object
   15871     3562550 :     AirChillerSetSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr);
   15872             : 
   15873     3562550 :     if (AirChillerSetSchedule <= 0.0) return;
   15874     3562550 :     QZNReqSens = this->QZnReqSens;
   15875     3562550 :     RemainQZNReqSens = QZNReqSens;
   15876             : 
   15877    33131715 :     for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15878    29569165 :         int CoilID = this->CoilNum(CoilIndex);
   15879             : 
   15880    29569165 :         WarehouseCoil(CoilID).CalculateCoil(state, RemainQZNReqSens);
   15881    29569165 :         RemainQZNReqSens += WarehouseCoil(CoilID).SensCreditRate;
   15882             :         // should be a negative minus a negative, so a smaller negative, that is, going toward zero, but senscoolingenergyrate expressed as
   15883             :         // 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
   15884             :         // particular time step  IF(RemainQZNReqSens >=0.0d0)EXIT  !shouldn't be > 0 because limited by request in calculatecoil
   15885    29569165 :         if (RemainQZNReqSens > 0.0) RemainQZNReqSens = 0.0;
   15886             :     } // CoilIndex
   15887             : }
   15888             : 
   15889       90934 : void FinalRateCoils(EnergyPlusData &state,
   15890             :                     bool const DeRate,                 // True if compressor rack or secondary ht exchanger unable to provide capacity
   15891             :                     SourceType const SystemSourceType, // Secondarysystem or DetailedSystem
   15892             :                     int const SystemID,                // ID for Secondary loop or detailed system calling for derate
   15893             :                     Real64 const InitialTotalLoad,     // Load on system or secondary loop as initially calculated [W]
   15894             :                     Real64 const AvailableTotalLoad    // Load that system or secondary loop is able to serve [W]
   15895             : )
   15896             : {
   15897             : 
   15898             :     // SUBROUTINE INFORMATION:
   15899             :     //       AUTHOR         Therese Stovall, ORNL
   15900             :     //       DATE WRITTEN   January 2011
   15901             :     //       MODIFIED       na
   15902             :     //       RE-ENGINEERED  na
   15903             : 
   15904             :     // PURPOSE OF THIS SUBROUTINE:
   15905             :     // When compressor system, or secondary loop capacity is insufficient to meet coil loads
   15906             :     //   Come back here and derate the coil case credits to show unmet load impact
   15907             :     //   Note that the coil fan, heater, and defrost would be unaffected because they
   15908             :     //   would still be running at level calculated previously
   15909             : 
   15910       90934 :     auto &System = state.dataRefrigCase->System;
   15911       90934 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15912             : 
   15913       90934 :     int NumCoils = 0;
   15914       90934 :     Real64 DeRateFactor = 0.0;        // Ratio of energy available from system or secondary loop
   15915       90934 :     Real64 InitLatCreditEnergy = 0.0; // Latent credit energy before derate [W]
   15916       90934 :     Real64 FrostReduction = 0.0;      // Change in frost on coils based on derated latent load [kg]
   15917             : 
   15918             :     {
   15919       90934 :         switch (SystemSourceType) {
   15920       90934 :         case SourceType::DetailedSystem:
   15921       90934 :             NumCoils = System(SystemID).NumCoils;
   15922       90934 :             break;
   15923           0 :         case SourceType::SecondarySystem:
   15924           0 :             NumCoils = state.dataRefrigCase->Secondary(SystemID).NumCoils;
   15925           0 :             break;
   15926           0 :         default:
   15927           0 :             assert(false);
   15928             :         }
   15929             :     } // DeRateCoils
   15930             : 
   15931       90934 :     if (DeRate) {
   15932      272802 :         ShowRecurringWarningErrorAtEnd(
   15933             :             state,
   15934      181868 :             "Refrigeration:System chilling WarehouseCoils " + System(SystemID).Name +
   15935             :                 " - Refrigeration system unable to meet load of warehouse coils chilled by system ... continues by derating coil load",
   15936       90934 :             System(SystemID).InsuffCapWarn);
   15937             : 
   15938       90934 :         DeRateFactor = AvailableTotalLoad / InitialTotalLoad;
   15939       90934 :         Real64 const time_step_sec(state.dataHVACGlobal->TimeStepSysSec);
   15940     1127963 :         for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
   15941     1037029 :             int CoilID = System(SystemID).CoilNum(CoilIndex);
   15942     1037029 :             auto &warehouse_coil = WarehouseCoil(CoilID);
   15943             : 
   15944             :             // need to adjust ice on coil due to reduction in latent load met by coil
   15945     1037029 :             InitLatCreditEnergy = warehouse_coil.LatCreditEnergy;
   15946             : 
   15947     1037029 :             warehouse_coil.TotalCoolingLoad *= DeRateFactor;
   15948     1037029 :             warehouse_coil.TotalCoolingEnergy *= DeRateFactor;
   15949     1037029 :             warehouse_coil.SensCoolingEnergyRate *= DeRateFactor;
   15950     1037029 :             warehouse_coil.SensCoolingEnergy *= DeRateFactor;
   15951     1037029 :             warehouse_coil.LatCreditRate *= DeRateFactor;
   15952     1037029 :             warehouse_coil.LatCreditEnergy *= DeRateFactor;
   15953     1037029 :             warehouse_coil.LatKgPerS_ToZone *= DeRateFactor;
   15954     1037029 :             warehouse_coil.SensCreditRate = warehouse_coil.SensCoolingEnergyRate - warehouse_coil.ElecFanPower - warehouse_coil.ElecHeaterPower -
   15955     1037029 :                                             warehouse_coil.ThermalDefrostPower;
   15956     1037029 :             warehouse_coil.SensCreditEnergy = warehouse_coil.SensCreditRate * time_step_sec;
   15957             : 
   15958     1037029 :             FrostReduction = (InitLatCreditEnergy - warehouse_coil.LatCreditEnergy) / IcetoVaporEnthalpy;
   15959     1037029 :             warehouse_coil.KgFrost = max(0.0, warehouse_coil.KgFrost - FrostReduction);
   15960             : 
   15961     1037029 :             if (warehouse_coil.SensCreditRate >= 0.0) {
   15962      825527 :                 warehouse_coil.ReportSensCoolCreditRate = warehouse_coil.SensCreditRate;
   15963      825527 :                 warehouse_coil.ReportHeatingCreditRate = 0.0;
   15964             :             } else {
   15965      211502 :                 warehouse_coil.ReportSensCoolCreditRate = 0.0;
   15966      211502 :                 warehouse_coil.ReportHeatingCreditRate = -warehouse_coil.SensCreditRate;
   15967             :             }
   15968     1037029 :             warehouse_coil.ReportSensCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditRate * time_step_sec;
   15969     1037029 :             warehouse_coil.ReportHeatingCreditEnergy = warehouse_coil.ReportHeatingCreditRate * time_step_sec;
   15970     1037029 :             warehouse_coil.ReportTotalCoolCreditRate = warehouse_coil.ReportSensCoolCreditRate + warehouse_coil.LatCreditRate;
   15971     1037029 :             warehouse_coil.ReportTotalCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditEnergy + warehouse_coil.LatCreditEnergy;
   15972             :         }
   15973             :     } // DeRate == true
   15974       90934 : }
   15975             : 
   15976    29569165 : void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq)
   15977             : {
   15978             : 
   15979             :     // SUBROUTINE INFORMATION:
   15980             :     //       AUTHOR         Therese Stovall, ORNL
   15981             :     //       DATE WRITTEN   January 2011
   15982             :     //       MODIFIED       na
   15983             :     //       RE-ENGINEERED  na
   15984             : 
   15985             :     // PURPOSE OF THIS SUBROUTINE:
   15986             :     // Simulates the refrigerated warehouse coil object.
   15987             :     // Note QZnReq < 0 corresponds to cooling needed
   15988             : 
   15989             :     // METHODOLOGY EMPLOYED:
   15990             :     // Called from Calculate Air Chiller Set.
   15991             :     // Air chillers are used to model the type of equipment typically used in
   15992             :     // refrigerated warehouses. For that reason, there is a major difference
   15993             :     // between the air chiller model and those for refrigerated cases or walk-ins.
   15994             :     // For cases and walk-ins, a portion of the model is directed toward
   15995             :     // calculating the amount of refrigeration needed to maintain the refrigerated
   15996             :     // volume at the desired temperature due to heat exchange with the surrounding
   15997             :     // zone, and that zone is conditioned to a nearly constant temperature.
   15998             :     // In a refrigerated warehouse, the refrigeration load is caused by heat exchange
   15999             :     // with a variable external environment.  For that reason, the loads for these
   16000             :     // zones are calculated by the usual EnergyPlus zone heat balance.
   16001             :     // The amount of refrigeration needed to maintain the specified temperature
   16002             :     // setpoints is then passed to the air chiller model, in a similar fashion
   16003             :     // to the load passed to a window air conditioner model. The air chillers
   16004             :     // are therefore solved using the system time step, not the zone time step
   16005             :     // used for cases and walk-ins.
   16006             :     // The air chiller performance is based on three types of manufacturers ratings,
   16007             :     // Unit Load Factor, Total Capacity Map, or a set of European standards.
   16008             :     // Correction factors for material and refrigerant are applied to all of these ratings.
   16009             : 
   16010             :     static constexpr std::string_view TrackMessage("from RefrigeratedCase:CalculateCoil");
   16011             : 
   16012    29569165 :     Real64 CoilSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr); // Current value of Coil operating (availability) schedule
   16013    29569165 :     if (CoilSchedule <= 0.0) return;
   16014             : 
   16015    21677709 :     Real64 DefrostSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->DefrostSchedPtr); // Coil defrost schedule, between 0 and 1
   16016    21677709 :     Real64 DefrostDripDownSchedule = ScheduleManager::GetCurrentScheduleValue(
   16017             :         state, this->DefrostDripDownSchedPtr); // Coil drip-down schedule (allows coil to drain after defrost)
   16018             :     // next statement In case user doesn't understand concept of drip down schedule
   16019    21677709 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   16020             :     // next value optional, so set to default before checking for schedule
   16021    21677709 :     Real64 HeaterSchedule = 1.0; // zero to one
   16022    21677709 :     if (this->HeaterSchedPtr > 0) HeaterSchedule = ScheduleManager::GetCurrentScheduleValue(state, this->HeaterSchedPtr);
   16023             : 
   16024             :     // Set local subroutine variables for convenience
   16025    21677709 :     FanSpeedCtrlType FanSpeedControlType = this->FanType;
   16026    21677709 :     Real64 AirVolumeFlowRated = this->RatedAirVolumeFlow;   // Coil rated air flow (m3/s)
   16027    21677709 :     Real64 FanPowerRated = this->RatedFanPower;             // (W)
   16028    21677709 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   16029    21677709 :     Real64 DefrostCap = this->DefrostCapacity;              // Design defrost capacity of Coil (W)
   16030    21677709 :     Real64 TEvap = this->TEvapDesign;                       // Evaporating temperature in the coil (C)
   16031             : 
   16032    21677709 :     Real64 CoilCapTotEstimate(0.0); // Part of loop to solve for total coil capacity as a function of inlet air conditions (W)
   16033    21677709 :     Real64 AirVolumeFlowMax(0.0);   // Coil air flow limited by drip down schedule (m3/s)
   16034    21677709 :     Real64 CoilCapTotal(0.0);       // Sensible plus latent load (W)
   16035    21677709 :     Real64 CoilInletDensity(0.0);   // Coil air inlet density (kg/m3)
   16036    21677709 :     Real64 CoilInletDryAirCp(0.0);  // Dry air specific heat at coil inlet temperature (J/kg-C)
   16037    21677709 :     Real64 CoilInletHumRatio(0.0);  // Coil air inlet humidity ratio (kg water/kg air)
   16038    21677709 :     Real64 CoilInletTemp(0.0);      // Inlet temperature of air to coil, not mixed zone temperature unless "middle" location selected (C)
   16039    21677709 :     Real64 CoilInletEnthalpy(0.0);  // Coil inlet air enthalpy (J/kg)
   16040    21677709 :     Real64 CoilInletRHFrac(0.0);    // Coil inlet air relative humidity expressed as a fraction (0 to 1)
   16041    21677709 :     Real64 DefrostLoad(0.0);
   16042    21677709 :     Real64 DryAirMassFlowMax(0.0);      // Rated volume flow rate times dry air density adjusted for schedules (kg/s)
   16043    21677709 :     Real64 FanPowerActual(0.0);         // (W)
   16044    21677709 :     Real64 FrostChangekg(0.0);          // Amount of frost added or melted  (kg)
   16045    21677709 :     Real64 latLoadServed(0.0);          // Energy rate used to remove water from zone air (W)
   16046    21677709 :     Real64 SensLoadRequestedGross(0.0); // Gross sensible load removed by coil
   16047    21677709 :     Real64 SensLoadGross(0.0);          // Sensible load met by coil (W)
   16048    21677709 :     Real64 SHR(0.0);                    // Sensible heat ratio, sensible load/total load
   16049    21677709 :     Real64 SHRCorrection(0.0);          // Actual total/sensible load, NOT = Inverse SHR (unless coil efficiency = 1.0)
   16050    21677709 :     Real64 WaterRemovRate(0.0);         // Walk in cooler removes water at this rate in this zone (kg/s)
   16051             : 
   16052    21677709 :     if (DefrostDripDownSchedule == 1.0) {
   16053     2261960 :         AirVolumeFlowMax = 0.0;
   16054     2261960 :         DryAirMassFlowMax = 0.0;
   16055             :     } else { // DefrostDripDownSchedule < 1.0d0, cooling will occur at least part of the time step
   16056             :         // Sensible load requested by zone balance (W)
   16057    19415749 :         Real64 SensLoadRequested = -QZnReq; // here let cooling demand be positive within subroutine
   16058    19415749 :         if (SensLoadRequested <= 0.0) {     // No load so assume control keeps off, except that scheduled defrost still occurs
   16059     9889889 :             AirVolumeFlowMax = 0.0;
   16060     9889889 :             DryAirMassFlowMax = 0.0;
   16061             :         } else {
   16062     9525860 :             SensLoadRequestedGross = SensLoadRequested + HeaterLoad + FanPowerRated;
   16063     9525860 :             Real64 ZoneMixedAirDryBulb = state.dataLoopNodes->Node(this->ZoneNodeNum).Temp;    // (C)
   16064     9525860 :             Real64 ZoneMixedAirHumRatio = state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat; // kg water/kg air in the zone mixed air
   16065             :             Real64 ZoneMixedAirRHFrac =
   16066     9525860 :                 Psychrometrics::PsyRhFnTdbWPb(state, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, state.dataEnvrn->OutBaroPress, TrackMessage);
   16067             :             Real64 ZoneMixedAirEnthalpy =
   16068     9525860 :                 Psychrometrics::PsyHFnTdbRhPb(state, ZoneMixedAirDryBulb, ZoneMixedAirRHFrac, state.dataEnvrn->OutBaroPress, TrackMessage);
   16069             :             Real64 ZoneMixedAirDensity =
   16070     9525860 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, TrackMessage);
   16071             :             Real64 ZoneDryAirDensity =
   16072     9525860 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, 0.0, TrackMessage);
   16073     9525860 :             Real64 DryAirMassFlowRated = AirVolumeFlowRated * ZoneDryAirDensity;
   16074             :             // calc t inlet to coil assuming at middle/mixed point in room  bbb -
   16075             :             //    later need to do for hottest/coolest in room where Tin /= Tzonemixed
   16076             :             // calc RH inlet to coil assuming at middle/mixed point in room
   16077             :             // calc coilcap, sens and latent, available as f(inlet T,RH)
   16078     9525860 :             switch (this->VerticalLocation) {
   16079     9525860 :             case VerticalLoc::Floor:
   16080             :                 // purposely fall through
   16081             :             case VerticalLoc::Ceiling:
   16082             :                 // purposely fall through
   16083             :             case VerticalLoc::Middle:
   16084     9525860 :                 CoilInletTemp = ZoneMixedAirDryBulb;
   16085     9525860 :                 CoilInletEnthalpy = ZoneMixedAirEnthalpy;
   16086     9525860 :                 CoilInletRHFrac = ZoneMixedAirRHFrac;
   16087     9525860 :                 CoilInletDensity = ZoneMixedAirDensity;
   16088     9525860 :                 CoilInletHumRatio = ZoneMixedAirHumRatio;
   16089     9525860 :                 CoilInletDryAirCp = Psychrometrics::PsyCpAirFnW(0.0);
   16090     9525860 :                 break;
   16091           0 :             default:
   16092           0 :                 assert(false);
   16093             :             }
   16094     9525860 :             AirVolumeFlowMax = AirVolumeFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   16095     9525860 :             DryAirMassFlowMax = DryAirMassFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   16096             : 
   16097             :         } // Sens load requested is non-zero
   16098             :     }     // DefrostDripDownSchedule == 1.0d0
   16099             : 
   16100    21677709 :     if (AirVolumeFlowMax > 0.0) {
   16101             : 
   16102             :         Real64 TemperatureDif =
   16103     9525860 :             min(this->MaxTemperatureDif, (CoilInletTemp - TEvap)); // difference between inlet air and evaporating temperature (deltaC)
   16104             : 
   16105     9525860 :         if (this->ratingType == RatingType::RatedCapacityTotal) {
   16106             :             // RatingType = CapacityTotalSpecificConditions, will be doing a table lookup
   16107             :             //    based upon RHInlet, DT1, CoilInletTemperature - see excel files from B. Nelson, CoilCom
   16108             :             //    In the table, X1== inlet air dry bulb temperature
   16109             :             //                  X2== Difference between inlet T and evap T
   16110             :             //                  X3== RH expressed as decimal
   16111      344255 :             CoilCapTotEstimate = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, CoilInletTemp, TemperatureDif, CoilInletRHFrac) *
   16112      344255 :                                  this->RatedCapTotal * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   16113             : 
   16114             :         } else { // work with unit load factor (sensible only), function of DT1 (Tair in drybulb-Tevap)
   16115     9181605 :             Real64 SensibleCapacityMax = this->UnitLoadFactorSens * TemperatureDif * (1.0 - DefrostDripDownSchedule) *
   16116             :                                          CoilSchedule; // Sensible capacity adjusted for any time in dripdown state (W)
   16117             : 
   16118     9181605 :             if (SensibleCapacityMax > 0.0) {
   16119     9155685 :                 Real64 ExitTemperatureEstimate =
   16120     9155685 :                     CoilInletTemp - (SensibleCapacityMax / (DryAirMassFlowMax * CoilInletDryAirCp)); // Estimated Air temperature leaving the coil (C)
   16121     9155685 :                 if (ExitTemperatureEstimate <= TEvap) {
   16122           0 :                     ShowWarningError(state, format("{}Refrigeration:AirCoil: {}", TrackMessage, this->Name));
   16123           0 :                     ShowContinueError(state, " The estimated air outlet temperature is less than the evaporating temperature.");
   16124             :                 }
   16125     9155685 :                 Real64 ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbRhPb(state,
   16126             :                                                                             ExitTemperatureEstimate,
   16127             :                                                                             1.0,
   16128     9155685 :                                                                             state.dataEnvrn->OutBaroPress,
   16129             :                                                                             TrackMessage); // Estimated Air enthalpy leaving the coil (J/kg)
   16130     9155685 :                 if (ExitEnthalpyEstimate <= CoilInletEnthalpy) {
   16131     6290134 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16132             :                 } else {
   16133             :                     // Assume no water is extracted from flow
   16134     2865551 :                     ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbW(ExitTemperatureEstimate, CoilInletHumRatio);
   16135     2865551 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16136             :                 }
   16137     9155685 :                 if (SensibleCapacityMax > CoilCapTotEstimate) SensibleCapacityMax = CoilCapTotEstimate;
   16138     9155685 :                 if (std::abs(CoilCapTotEstimate) > 0.0) {
   16139     9155445 :                     SHR = SensibleCapacityMax / (CoilCapTotEstimate);
   16140             :                 } else {
   16141             :                     // will occur whenever defrost or dripdown
   16142         240 :                     SHR = 0.0;
   16143             :                 }
   16144             : 
   16145     9155685 :                 switch (this->SHRCorrType) {
   16146     8978370 :                 case SHRCorrectionType::SHR60: {
   16147             :                     // line from y = SHRCorrection60 value to 1. as x(SHR) goes from .6 to 1, from B. Nelson, ASHRAE August 2010
   16148     8978370 :                     Real64 Slope = (this->SHRCorrection60 - 1.0) / (0.6 - 1.0); // Part of linear SHR60 correction factor, dimensionless
   16149     8978370 :                     Real64 Yint = this->SHRCorrection60 - (Slope * 0.6);        // Part of linear SHR60 correction factor, dimensionless
   16150     8978370 :                     SHRCorrection = Slope * SHR + Yint;
   16151     8978370 :                 } break;
   16152           0 :                 case SHRCorrectionType::QuadraticSHR: {
   16153           0 :                     SHRCorrection = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, SHR);
   16154           0 :                 } break;
   16155      177315 :                 case SHRCorrectionType::European: {
   16156             :                     // With European ratings, either start with rated total sensible capacity or rated total capacity
   16157             :                     //    If rated total capacity is used, 'get input'
   16158             :                     //    translated it to rated total sensible capacity using
   16159             :                     //    PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   16160             :                     //    That sensible capacity rating was then turned to a rated UnitLoadFactor using
   16161             :                     //    the rated temperature difference. That sensible rating was also corrected
   16162             :                     //    for refrigerant and fin material in 'get input' and is given as UnitLoadFactor
   16163             :                     //  The total (sens + latent) capacity is equal to that * DT1 * WetCoilFactor(TcoilIn)
   16164             :                     //    Sensible capacity max already has DT1, just need WetCoilFactor(TcoilIn)
   16165             :                     // PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   16166             :                     // PARAMETER ::EuropeanAirInletTemp  = (/10.0D0,  0.0D0, -18.0D0, -25.0D0, -34.0D0/)
   16167             :                     // PARAMETER ::EuropeanEvapTemp      = (/ 0.0D0, -8.0D0, -25.0D0, -31.0D0, -40.0D0/)
   16168             :                     // PARAMETER ::EuropeanDT1           = (/10.0D0,  8.0D0,   7.0D0,   7.0D0,   6.0D0/)
   16169      177315 :                     if (CoilInletTemp <= -25.0) {
   16170           0 :                         SHRCorrection = 1.0;
   16171      177315 :                     } else if (CoilInletTemp > -25.0 && CoilInletTemp <= 0.0) {
   16172      133720 :                         SHRCorrection = (EuropeanWetCoilFactor[1] - EuropeanWetCoilFactor[3]) / (EuropeanAirInletTemp[1] - EuropeanAirInletTemp[3]) *
   16173      267440 :                                             (EuropeanAirInletTemp[1] - CoilInletTemp) +
   16174      133720 :                                         EuropeanWetCoilFactor[3];
   16175       43595 :                     } else if (CoilInletTemp > 0.0 && CoilInletTemp <= 5.0) {
   16176       10040 :                         SHRCorrection = (EuropeanWetCoilFactor[0] - EuropeanWetCoilFactor[1]) / (EuropeanAirInletTemp[0] - EuropeanAirInletTemp[1]) *
   16177       20080 :                                             (EuropeanAirInletTemp[0] - CoilInletTemp) +
   16178       10040 :                                         EuropeanWetCoilFactor[1];
   16179       33555 :                     } else if (CoilInletTemp > 5.0) {
   16180       33555 :                         SHRCorrection = EuropeanWetCoilFactor[0];
   16181             :                     } // calc correction as a function of coil inlet temperature
   16182      177315 :                 } break;
   16183           0 :                 default:
   16184           0 :                     break;
   16185             :                 }
   16186     9155685 :                 CoilCapTotEstimate = SHRCorrection * SensibleCapacityMax;
   16187             :             } else { // NOT (SensibleCapacityMax > 0.0d0)
   16188       25920 :                 CoilCapTotEstimate = 0.0;
   16189             :             } //  (SensibleCapacityMax > 0.0d0)
   16190             :         }     // Rating type : CapacityTotalSpecificConditions or Sensible Unit Load Factor
   16191             : 
   16192     9525860 :         if (CoilCapTotEstimate > 0.0) {
   16193     9499460 :             Real64 ExitEnthalpy =
   16194     9499460 :                 CoilInletEnthalpy - (CoilCapTotEstimate / (AirVolumeFlowMax * CoilInletDensity)); // Air enthalpy leaving the coil (J/kg)
   16195     9499460 :             Real64 ExitTemperature = Psychrometrics::PsyTsatFnHPb(
   16196     9499460 :                 state, ExitEnthalpy, state.dataEnvrn->OutBaroPress, TrackMessage); // RH =1.0 at Tsat // Air temperature leaving the coil (C)
   16197     9499460 :             Real64 ExitHumRatio = Psychrometrics::PsyWFnTdbH(state, ExitTemperature, ExitEnthalpy, TrackMessage); // kg water/kg air
   16198     9499460 :             if (ExitHumRatio > CoilInletHumRatio) ExitHumRatio = CoilInletHumRatio;
   16199     9499460 :             WaterRemovRate = DryAirMassFlowMax * (CoilInletHumRatio - ExitHumRatio);
   16200     9499460 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16201     9499460 :             SensLoadGross = CoilCapTotEstimate - latLoadServed;
   16202     9499460 :             FanPowerActual = FanPowerRated;
   16203     9499460 :             if (SensLoadGross < 0.0) {
   16204             :                 // Could rarely happen during initial cooldown of a warm environment
   16205          58 :                 SensLoadGross = 0.0;
   16206          58 :                 latLoadServed = CoilCapTotEstimate;
   16207          58 :                 WaterRemovRate = latLoadServed / IcetoVaporEnthalpy;
   16208             :             }    // SensLoadGross < 0
   16209             :         } else { // NOT (SensibleCapacityMax > 0.0d0)
   16210       26400 :             WaterRemovRate = 0.0;
   16211       26400 :             latLoadServed = 0.0;
   16212       26400 :             SensLoadGross = 0.0;
   16213       26400 :             FanPowerActual = 0.0;
   16214             :         } //(CoilCapTotEstimate > 0.0d0)
   16215             : 
   16216     9525860 :         Real64 FanPowerMax = FanPowerRated * (1.0 - DefrostDripDownSchedule); // Total fan energy rate, limited by dripdown period (W)
   16217     9525860 :         if (SensLoadGross > SensLoadRequestedGross) {                         // part load operation
   16218             :             // don't need full chiller power, reduce fan speed to reduce air flow
   16219             :             // move fan to part power if need to
   16220     3709785 :             Real64 CapFac = SensLoadRequestedGross / SensLoadGross; // used to reduce fan power when don't need full coil capacity
   16221     3709785 :             Real64 AirVolRatio = max(this->FanMinAirFlowRatio, std::pow(CapFac, EvaporatorAirVolExponent)); // used when operating at part load
   16222             :             // Fans limited by minimum air flow ratio
   16223             : 
   16224     3709785 :             switch (FanSpeedControlType) {
   16225           0 :             case FanSpeedCtrlType::VariableSpeed: {                // fan power law, adjusted for reality, applies
   16226           0 :                 Real64 FanPowerRatio = std::pow(AirVolRatio, 2.5); // Used for variable speed fans, dimensionless
   16227           0 :                 FanPowerActual = FanPowerRatio * FanPowerMax;
   16228           0 :             } break;
   16229     3709785 :             case FanSpeedCtrlType::ConstantSpeed: {
   16230     3709785 :                 FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16231     3709785 :             } break;
   16232           0 :             case FanSpeedCtrlType::ConstantSpeedLinear: { // e.g., on-off control
   16233           0 :                 FanPowerActual = AirVolRatio * FanPowerMax;
   16234           0 :             } break;
   16235           0 :             case FanSpeedCtrlType::TwoSpeed: {
   16236             :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   16237             :                 // 1/2 speed corresonds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   16238             :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   16239           0 :                 if (CapFac < CapFac60Percent) {
   16240           0 :                     FanPowerActual = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16241             :                 } else {
   16242           0 :                     FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16243             :                 } // capfac60percent
   16244           0 :             } break;
   16245           0 :             default:
   16246           0 :                 break;
   16247             :             } // fan speed control type
   16248             : 
   16249             :             // reduce latent capacity according to value called for for sensible  - recalc latent.
   16250             :             //   recalc coilcaptotal
   16251     3709785 :             WaterRemovRate *= AirVolRatio;
   16252     3709785 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16253     3709785 :             SensLoadGross = SensLoadRequestedGross;
   16254             :         } else { // at full load
   16255     5816075 :             FanPowerActual = FanPowerMax;
   16256             :         } // part load and sensload served > 0.
   16257             : 
   16258     9525860 :         CoilCapTotal = SensLoadGross + latLoadServed;
   16259     9525860 :         if (CoilCapTotal > 0.0) {
   16260     9499460 :             SHR = SensLoadGross / CoilCapTotal;
   16261             :         } else {
   16262       26400 :             SHR = 0.0;
   16263             :         } //(CoilCapTotal > 0.0d0)
   16264             : 
   16265             :         // now handle ice on coil and defrost because defrost energy not into melting ice goes into sensible load
   16266             :         // FROST:  keep track of frost build up on evaporator coil
   16267             :         //         avoid accumulation during warm-up to avoid reverse dd test problem
   16268     9525860 :         if (!state.dataGlobal->WarmupFlag) {
   16269      466527 :             FrostChangekg = (WaterRemovRate * state.dataHVACGlobal->TimeStepSysSec);
   16270      466527 :             this->KgFrost += FrostChangekg;
   16271             :         }
   16272             : 
   16273             :     } else { // NOT (AirVolumeFlowMax > 0.0d0)
   16274    12151849 :         WaterRemovRate = 0.0;
   16275    12151849 :         latLoadServed = 0.0;
   16276    12151849 :         SensLoadGross = 0.0;
   16277    12151849 :         FanPowerActual = 0.0;
   16278             :     } //(AirVolumeFlowMax > 0.0d0)
   16279             : 
   16280             :     // DEFROST CALCULATIONS   ***** need to reduce sensible heat to zone from
   16281             :     //                     defrost by amount used to melt ice. Last two elements
   16282             :     //                     in starting IF are there to mimic temperature override
   16283             :     //                     on the coils that stops defrost if the coils get above
   16284             :     //                     a certain temperature (such as when there's no load and no ice)
   16285    21677709 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   16286     2694120 :         DefrostLoad = DefrostCap * DefrostSchedule;                                // Part of the defrost that is a heat load on the zone (W)
   16287     2694120 :         Real64 DefrostEnergy = DefrostLoad * state.dataHVACGlobal->TimeStepSysSec; // Joules
   16288     2694120 :         Real64 StartFrostKg = this->KgFrost;                                       // frost load at start of time step (kg of ice)
   16289             : 
   16290     2694120 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   16291             :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   16292             :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   16293             :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   16294             :             //  others and xfer heat to environment)
   16295             :             //  Assume full ice melting satisfies temperature control.
   16296             :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   16297       19940 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // available to melt ice with temp term control (J)
   16298       19940 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   16299       19940 :             if (StartFrostKg > 0.0) {
   16300         180 :                 if (this->IceTemp < 0.0) {
   16301         160 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   16302         160 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   16303         160 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   16304         160 :                         this->IceTemp = 0.0;
   16305         160 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   16306             :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   16307           0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   16308           0 :                         AvailDefrostEnergy = 0.0;
   16309             :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   16310             :                 }     // IceTemp < 0,  need to raise temperature of ice
   16311             :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   16312         180 :                 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   16313         180 :                 if (FrostChangekg < StartFrostKg) {
   16314          20 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::SecInHour;
   16315          20 :                     if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   16316             :                     // DefrostSchedule not changed because ice not all melted, temp term not triggered
   16317             :                 } else { // all frost melted during time step, so need to terminate defrost
   16318             :                     //  see Aug 8 2010 page 3 notes
   16319         160 :                     this->KgFrost = 0.0;
   16320         160 :                     Real64 DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   16321         160 :                                                  this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   16322         160 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (DefrostCap * state.dataHVACGlobal->TimeStepSysSec)));
   16323             :                     // reduce heat load on warehouse by energy put into ice melting
   16324             :                     // Defrost load that actually goes to melting ice (W)
   16325         160 :                     Real64 DefrostRateNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / (state.dataHVACGlobal->TimeStepSysSec);
   16326         160 :                     DefrostLoad = max(0.0, (DefrostSchedule * DefrostCap - DefrostRateNeeded));
   16327         160 :                     this->IceTemp = this->TEvapDesign;
   16328             :                 } // frost melted during time step less than amount of ice at start
   16329             :             } else {
   16330             :                 // no frost present so terminate defrost and reset ice temperature for start of next defrost
   16331             :                 // However, dripdown schedule still prevents/limits cooling capacity during time step
   16332       19760 :                 DefrostLoad = 0.0;
   16333       19760 :                 DefrostSchedule = 0.0;
   16334       19760 :                 this->IceTemp = this->TEvapDesign;
   16335             :             } // have frost present
   16336             : 
   16337             :         } else {
   16338             :             // Not temperature control type, controlled only by schedule
   16339             :             // Reduce defrost heat load on the zone by amount of ice melted during time step
   16340             :             // But DefrostSchedule not changed
   16341     2674180 :             FrostChangekg = max(0.0, min((DefrostEnergy / IceMeltEnthalpy), StartFrostKg));
   16342     2674180 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::SecInHour;
   16343     2674180 :             if (!state.dataGlobal->WarmupFlag) this->KgFrost = StartFrostKg - FrostChangekg;
   16344             :         } // Temperature termination vs. time-clock control type
   16345             : 
   16346     2694120 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   16347    18983589 :         DefrostLoad = 0.0;
   16348             :     } // Defrost calculations
   16349             : 
   16350    21677709 :     Real64 SensLoadFromZone = SensLoadGross - HeaterLoad - DefrostLoad -
   16351             :                               FanPowerActual; // Net sensible load removed from zone after accounting for heaters, fans, defrost [W]
   16352             : 
   16353             :     // ReportWarehouseCoil(CoilID)
   16354    21677709 :     this->ThermalDefrostPower = DefrostLoad;
   16355    21677709 :     if (this->defrostType == DefrostType::Elec) {
   16356    21321454 :         this->ElecDefrostConsumption = DefrostCap * DefrostSchedule * state.dataHVACGlobal->TimeStepSysSec;
   16357    21321454 :         this->ElecDefrostPower = DefrostCap * DefrostSchedule;
   16358             :     } else {
   16359      356255 :         this->ElecDefrostConsumption = 0.0;
   16360      356255 :         this->ElecDefrostPower = 0.0;
   16361             :     }
   16362             : 
   16363             :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   16364    21677709 :     if (this->defrostType == DefrostType::Fluid) this->HotDefrostCondCredit = DefrostCap * DefrostSchedule;
   16365             :     // LatentLoadServed is positive for latent heat removed from zone
   16366             :     // SensLoadFromZone positive for heat REMOVED from zone, switch when do credit to zone
   16367    21677709 :     this->SensCreditRate = SensLoadFromZone;
   16368    21677709 :     this->SensCreditEnergy = SensLoadFromZone * state.dataHVACGlobal->TimeStepSysSec;
   16369    21677709 :     this->LatCreditRate = latLoadServed;
   16370    21677709 :     this->LatCreditEnergy = latLoadServed * state.dataHVACGlobal->TimeStepSysSec;
   16371    21677709 :     this->LatKgPerS_ToZone = WaterRemovRate;
   16372    21677709 :     this->TotalCoolingLoad = CoilCapTotal;
   16373    21677709 :     this->TotalCoolingEnergy = CoilCapTotal * state.dataHVACGlobal->TimeStepSysSec;
   16374    21677709 :     this->SensCoolingEnergyRate = SensLoadGross;
   16375    21677709 :     this->SensCoolingEnergy = SensLoadGross * state.dataHVACGlobal->TimeStepSysSec;
   16376    21677709 :     this->SensHeatRatio = SHR;
   16377    21677709 :     this->ElecFanPower = FanPowerActual;
   16378    21677709 :     this->ElecFanConsumption = FanPowerActual * state.dataHVACGlobal->TimeStepSysSec;
   16379    21677709 :     this->ElecHeaterPower = HeaterLoad;
   16380    21677709 :     this->ElecHeaterConsumption = HeaterLoad * state.dataHVACGlobal->TimeStepSysSec;
   16381             : 
   16382    21677709 :     this->TotalElecPower = FanPowerActual + HeaterLoad + this->ElecDefrostPower;
   16383    21677709 :     this->TotalElecConsumption = this->TotalElecPower * state.dataHVACGlobal->TimeStepSysSec;
   16384             : 
   16385    21677709 :     if (this->SensCreditRate >= 0.0) {
   16386    18016343 :         this->ReportSensCoolCreditRate = this->SensCreditRate;
   16387    18016343 :         this->ReportHeatingCreditRate = 0.0;
   16388             :     } else {
   16389     3661366 :         this->ReportSensCoolCreditRate = 0.0;
   16390     3661366 :         this->ReportHeatingCreditRate = -this->SensCreditRate;
   16391             :     }
   16392    21677709 :     this->ReportSensCoolCreditEnergy = this->ReportSensCoolCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16393    21677709 :     this->ReportHeatingCreditEnergy = this->ReportHeatingCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16394    21677709 :     this->ReportTotalCoolCreditRate = this->ReportSensCoolCreditRate + this->LatCreditRate;
   16395    21677709 :     this->ReportTotalCoolCreditEnergy = this->ReportSensCoolCreditEnergy + this->LatCreditEnergy;
   16396             : 
   16397             :     //**************************************************************************************************
   16398             :     // Cap Kg Frost to avoid floating overflow errors
   16399             :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   16400             : 
   16401    21677709 :     if (this->KgFrost > MyLargeNumber) {
   16402           0 :         this->KgFrost = MyLargeNumber;
   16403           0 :         if (this->ShowCoilFrostWarning) {
   16404           0 :             ShowWarningError(state, format("Refrigeration:AirCoil: {}", this->Name));
   16405           0 :             ShowContinueError(state, " This refrigerated air coil has insufficient defrost capacity to remove the excess frost accumulation.");
   16406           0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   16407           0 :             ShowContinueErrorTimeStamp(state, "... Occurrence info");
   16408           0 :             this->ShowCoilFrostWarning = false;
   16409             :         }
   16410             :     }
   16411             : }
   16412             : 
   16413     2804678 : void FigureRefrigerationZoneGains(EnergyPlusData &state)
   16414             : {
   16415             : 
   16416             :     // SUBROUTINE INFORMATION:
   16417             :     //       AUTHOR         B. Griffith
   16418             :     //       DATE WRITTEN   Dec 2011
   16419             :     //       MODIFIED       na
   16420             :     //       RE-ENGINEERED  na
   16421             : 
   16422             :     // PURPOSE OF THIS SUBROUTINE:
   16423             :     // initialize zone gain terms at begin environment
   16424             : 
   16425     2804678 :     auto &System = state.dataRefrigCase->System;
   16426     2804678 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   16427     2804678 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16428     2804678 :     auto &Secondary = state.dataRefrigCase->Secondary;
   16429     2804678 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   16430     2804678 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   16431             : 
   16432     2804678 :     CheckRefrigerationInput(state);
   16433             : 
   16434     2804678 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag) {
   16435             : 
   16436        6443 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   16437         360 :             for (auto &e : System) {
   16438         262 :                 e.PipeHeatLoad = 0.0;
   16439         262 :                 e.NetHeatRejectLoad = 0.0;
   16440             :             }
   16441             :         }
   16442             : 
   16443        6443 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   16444          12 :             for (auto &e : TransSystem) {
   16445           6 :                 e.PipeHeatLoadMT = 0.0;
   16446           6 :                 e.PipeHeatLoadLT = 0.0;
   16447           6 :                 e.NetHeatRejectLoad = 0.0;
   16448             :             }
   16449             :         }
   16450             : 
   16451        6443 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   16452         772 :             for (auto &e : RefrigRack) {
   16453         514 :                 e.SensZoneCreditHeatRate = 0.0;
   16454         514 :                 e.SensHVACCreditHeatRate = 0.0;
   16455             :             }
   16456             :         }
   16457             : 
   16458        6443 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   16459          18 :             for (auto &e : Secondary) {
   16460          12 :                 e.DistPipeZoneHeatGain = 0.0;
   16461          12 :                 e.ReceiverZoneHeatGain = 0.0;
   16462             :             }
   16463             :         }
   16464             : 
   16465        6443 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   16466         210 :             for (int loop = 1; loop <= state.dataRefrigCase->NumSimulationWalkIns; ++loop) {
   16467         118 :                 WalkIn(loop).SensZoneCreditRate = 0.0;
   16468         118 :                 WalkIn(loop).LatZoneCreditRate = 0.0;
   16469             :             }
   16470             :         }
   16471        6443 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   16472        1635 :             for (auto &e : RefrigCase) {
   16473        1333 :                 e.SensZoneCreditRate = 0.0;
   16474        1333 :                 e.SensHVACCreditRate = 0.0;
   16475        1333 :                 e.LatZoneCreditRate = 0.0;
   16476        1333 :                 e.LatHVACCreditRate = 0.0;
   16477             :             }
   16478             :         }
   16479        6443 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = false;
   16480             :     }
   16481     2804678 :     if (!state.dataGlobal->BeginEnvrnFlag) state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = true;
   16482     2804678 : }
   16483             : 
   16484        2891 : void ZeroHVACValues(EnergyPlusData &state)
   16485             : {
   16486             : 
   16487             :     // SUBROUTINE INFORMATION:
   16488             :     //       AUTHOR         T. Stovall
   16489             :     //       DATE WRITTEN   Aug 2012
   16490             :     //       MODIFIED       na
   16491             :     //       RE-ENGINEERED  na
   16492             : 
   16493             :     // PURPOSE OF THIS SUBROUTINE:
   16494             :     // Reset all values that communicate outside module for HVAC steps
   16495             :     // to zero when called on zone timestep. Otherwise, values may be held over when
   16496             :     // no HVAC load calls module during that zone time step.
   16497             : 
   16498        2891 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16499        2891 :     auto &Condenser = state.dataRefrigCase->Condenser;
   16500             : 
   16501        2891 :     int DemandARRID = 0; // Index to water tank Demand used for evap condenser
   16502             : 
   16503        2891 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   16504             :         // HaveRefrigRacks is TRUE when NumRefrigeratedRAcks > 0
   16505             :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   16506           0 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   16507           0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   16508           0 :                 Real64 MassFlowRate = 0.0;
   16509           0 :                 PlantUtilities::SetComponentFlowRate(
   16510           0 :                     state, MassFlowRate, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).OutletNode, RefrigRack(RackNum).plantLoc);
   16511             :             }
   16512           0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   16513           0 :                 if (RefrigRack(RackNum).EvapWaterSupplyMode == WaterSupply::FromTank) {
   16514           0 :                     DemandARRID = RefrigRack(RackNum).EvapWaterTankDemandARRID;
   16515           0 :                     int TankID = RefrigRack(RackNum).EvapWaterSupTankID;
   16516           0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   16517             :                 }
   16518             :             }
   16519             :         } // RackNum
   16520             :     }     // HaveRefrigRacks
   16521             : 
   16522        2891 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   16523             :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   16524       28910 :         for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
   16525       26019 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   16526           0 :                 Real64 MassFlowRate = 0.0;
   16527           0 :                 PlantUtilities::SetComponentFlowRate(
   16528           0 :                     state, MassFlowRate, Condenser(CondID).InletNode, Condenser(CondID).OutletNode, Condenser(CondID).plantLoc);
   16529             :             }
   16530       26019 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   16531           0 :                 if (Condenser(CondID).EvapWaterSupplyMode == WaterSupply::FromTank) {
   16532           0 :                     DemandARRID = Condenser(CondID).EvapWaterTankDemandARRID;
   16533           0 :                     int TankID = Condenser(CondID).EvapWaterSupTankID;
   16534           0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   16535             :                 }
   16536             :             }
   16537             :         } // ICond
   16538             :     }     // DataHeatBalance::NumRefrigCondensers>0
   16539        2891 : }
   16540             : 
   16541             : } // namespace EnergyPlus::RefrigeratedCase

Generated by: LCOV version 1.14