LCOV - code coverage report
Current view: top level - EnergyPlus - HVACVariableRefrigerantFlow.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 99.0 % 103 102
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 7 7

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : #ifndef HVACVariableRefrigerantFlow_hh_INCLUDED
      49              : #define HVACVariableRefrigerantFlow_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : #include <ObjexxFCL/Optional.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/Data/BaseData.hh>
      57              : #include <EnergyPlus/DataGlobalConstants.hh>
      58              : #include <EnergyPlus/DataGlobals.hh>
      59              : #include <EnergyPlus/DataHeatBalance.hh>
      60              : #include <EnergyPlus/EnergyPlus.hh>
      61              : #include <EnergyPlus/FluidProperties.hh>
      62              : #include <EnergyPlus/Plant/PlantLocation.hh>
      63              : #include <EnergyPlus/PlantComponent.hh>
      64              : #include <EnergyPlus/SingleDuct.hh>
      65              : #include <EnergyPlus/StandardRatings.hh>
      66              : #include <EnergyPlus/UnitarySystem.hh>
      67              : #include <EnergyPlus/UtilityRoutines.hh>
      68              : 
      69              : namespace EnergyPlus {
      70              : 
      71              : // Forward declarations
      72              : struct EnergyPlusData;
      73              : 
      74              : namespace HVACVariableRefrigerantFlow {
      75              : 
      76              :     // Parameters describing variable refrigerant flow terminal unit types
      77              :     enum class TUType
      78              :     {
      79              :         Invalid = -1,
      80              :         ConstantVolume,
      81              :         Num
      82              :     };
      83              : 
      84              :     // Thermostat Priority Control Type
      85              :     enum class ThermostatCtrlType
      86              :     {
      87              :         Invalid = -1,
      88              :         LoadPriority,             // total of zone loads dictate operation in cooling or heating
      89              :         ZonePriority,             // # of zones requiring cooling or heating dictate operation in cooling or heating
      90              :         ThermostatOffsetPriority, // zone with largest deviation from setpoint dictates operation
      91              :         ScheduledPriority,        // cooling and heating modes are scheduled
      92              :         MasterThermostatPriority, // Master zone thermostat dictates operation
      93              :         FirstOnPriority,          // first unit to respond dictates operation (not used at this time)
      94              :         Num
      95              :     };
      96              : 
      97              :     static constexpr std::array<std::string_view, static_cast<int>(ThermostatCtrlType::Num)> ThermostatCtrlTypeUC = {
      98              :         "LOADPRIORITY", "ZONEPRIORITY", "THERMOSTATOFFSETPRIORITY", "SCHEDULEDPRIORITY", "MASTERTHERMOSTATPRIORITY",
      99              :         // "FIRSTONPRIORITY",
     100              :     };
     101              : 
     102              :     enum class EvapWaterSupply
     103              :     {
     104              :         Invalid = -1,
     105              :         FromMains, // mains water line used as water source
     106              :         FromTank,  // storage tank used as water source
     107              :         Num
     108              :     };
     109              : 
     110              :     // VRF Algorithm Type
     111              :     enum class AlgorithmType
     112              :     {
     113              :         Invalid = -1,
     114              :         SysCurve,   // VRF model based on system curve
     115              :         FluidTCtrl, // VRF model based on physics, appreciable for Fluid Temperature Control
     116              :         Num
     117              :     };
     118              : 
     119              :     // VRF System Types (strings used in integer conversions)
     120              :     constexpr int VRF_HeatPump(1);
     121              : 
     122           53 :     constexpr auto cVRFTypes(int i)
     123              :     {
     124           53 :         if (i == 1) {
     125           53 :             return "AirConditioner:VariableRefrigerantFlow";
     126              :         } else {
     127            0 :             assert(false);
     128              :             return "";
     129              :         }
     130              :     }
     131              : 
     132              :     // Flag for hex operation
     133              :     enum class HXOpMode
     134              :     {
     135              :         Invalid = -1,
     136              :         CondMode, // Flag for the hex running as condenser [-]
     137              :         EvapMode, // Flag for the hex running as evaporator [-]
     138              :         Num
     139              :     };
     140              : 
     141              :     // Flag for VRF operational mode
     142              :     constexpr int ModeCoolingOnly = 1;       // Flag for Cooling Only Mode [-]
     143              :     constexpr int ModeHeatingOnly = 2;       // Flag for Heating Only Mode [-]
     144              :     constexpr int ModeCoolingAndHeating = 3; // Flag for Simultaneous Cooling and Heating Only Mode [-]
     145              : 
     146              :     // Subroutine Specifications for the Module
     147              :     struct VRFCondenserEquipment : PlantComponent
     148              :     {
     149              :         // Members
     150              :         std::string Name;                      // Name of the VRF Terminal Unit
     151              :         int VRFSystemTypeNum;                  // integer equivalent of system type
     152              :         AlgorithmType VRFAlgorithmType;        // Algorithm type: 1_system curve based model; 2_physics based model (FluidTCtrl)
     153              :         DataPlant::PlantEquipmentType VRFType; // integer equivalent of index to DataPlant type
     154              :         PlantLocation SourcePlantLoc;          // plant data for water-cooled only
     155              :         Real64 WaterCondenserDesignMassFlow;   // plant data for water-cooled only
     156              :         Real64 WaterCondenserMassFlow;         // Water condenser flow rate (kg/s)
     157              :         Real64 QCondenser;                     // Water condenser heat rejection/absorption (W)
     158              :         Real64 QCondEnergy;                    // Water condenser heat rejection/aborption energy (J)
     159              :         Real64 CondenserSideOutletTemp;        // Water condenser outlet temp (C)
     160              :         Sched::Schedule *availSched = nullptr; // Pointer to the correct schedule // LOL
     161              :         Real64 CoolingCapacity;                // Nominal VRF heat pump cooling capacity (W)
     162              :         Real64 TotalCoolingCapacity;           // Nominal VRF heat pump cooling capacity (W)
     163              :         Real64 CoolingCombinationRatio;        // Ratio or terminal unit cooling capacity to VRF condenser capacity
     164              :         Real64 VRFCondPLR;                     // Condenser part-load ratio wrt total capacity
     165              :         Real64 VRFCondRTF;                     // Condenser runtime fraction
     166              :         Real64 VRFCondCyclingRatio;            // Condenser cycling ratio below MinPLR
     167              :         Real64 CondenserInletTemp;             // Condenser entering air temperature (C)
     168              :         Real64 CoolingCOP;                     // Nominal VRF heat pump cooling COP (W/W)
     169              :         Real64 OperatingCoolingCOP;            // Operating VRF heat pump cooling COP (W/W)
     170              :         Real64 RatedCoolingPower;              // Rated cooling power = Rated Cooling Capacity / Rated COP (W)
     171              :         Real64 HeatingCapacity;                // Nominal VRF heat pump heating capacity (W)
     172              :         Real64 HeatingCapacitySizeRatio;       // Ratio of heating to cooling when autosizing
     173              :         bool LockHeatingCapacity;              // used in sizing to size VRF heat cap to VRF cool cap
     174              :         Real64 TotalHeatingCapacity;           // Nominal VRF heat pump heating capacity (W)
     175              :         Real64 HeatingCombinationRatio;        // Ratio or terminal unit heating capacity to VRF condenser capacity
     176              :         Real64 HeatingCOP;                     // Nominal VRF heat pump heating COP
     177              :         Real64 OperatingHeatingCOP;            // Operating VRF heat pump heating COP
     178              :         Real64 RatedHeatingPower;              // Rated heating power = Rated Heating Capacity / Rated COP (W)
     179              :         Real64 MinOATCooling;                  // Minimum outdoor air dry-bulb temp in cooling mode (C)
     180              :         Real64 MaxOATCooling;                  // Maximum outdoor air dry-bulb temp in cooling mode (C)
     181              :         Real64 MinOATHeating;                  // Minimum outdoor air dry-bulb temp in heating mode (C)
     182              :         Real64 MaxOATHeating;                  // Maximum outdoor air dry-bulb temp in heating mode (C)
     183              :         int CoolCapFT;                         // index to cooling capacity function of temperature curve
     184              :         int CoolEIRFT;                         // index to cooling EIR function of temperature curve
     185              :         int HeatCapFT;                         // index to heating capacity function of temperature curve
     186              :         int HeatEIRFT;                         // index to heating EIR function of temperature curve
     187              :         int CoolBoundaryCurvePtr;              // index to cooling capacity boundary curve
     188              :         int HeatBoundaryCurvePtr;              // index to cooling capacity boundary curve
     189              :         int EIRCoolBoundaryCurvePtr;           // index to cooling EIR boundary curve
     190              :         int CoolEIRFPLR1;                      // index to cooling EIR function of PLR curve < 1
     191              :         int CoolEIRFPLR2;                      // index to cooling EIR function of PLR curve >= 1
     192              :         int CoolCapFTHi;                       // index to cooling capacity function of temperature curve
     193              :         int CoolEIRFTHi;                       // index to cooling EIR function of temperature curve
     194              :         int HeatCapFTHi;                       // index to heating capacity function of temperature curve
     195              :         int HeatEIRFTHi;                       // index to heating EIR function of temperature curve
     196              :         int EIRHeatBoundaryCurvePtr;           // index to heating EIR boundary curve
     197              :         int HeatEIRFPLR1;                      // index to heating EIR function of PLR curve < 1
     198              :         int HeatEIRFPLR2;                      // index to heating EIR function of PLR curve >= 1
     199              :         int CoolPLFFPLR;                       // index to cooling PLF function of PLR curve
     200              :         int HeatPLFFPLR;                       // index to heating PLF function of PLR curve
     201              :         HVAC::OATType HeatingPerformanceOATType = HVAC::OATType::Invalid; // Temperature type for heating performance curves
     202              :         Real64 MinPLR;                                                    // minimum PLR before cycling occurs
     203              :         int MasterZonePtr;                                                // index to master thermostat zone
     204              :         int MasterZoneTUIndex;                                            // index to TU in master thermostat zone
     205              :         ThermostatCtrlType ThermostatPriority;                            // VRF priority control (1=LoadPriority, 2=ZonePriority, etc)
     206              :         Sched::Schedule *prioritySched = nullptr;                         // VRF priority control schedule
     207              :         int ZoneTUListPtr;                                                // index to zone terminal unit list
     208              :         bool HeatRecoveryUsed;                                            // .TRUE. = heat recovery used
     209              :         Real64 VertPipeLngth;                                             // vertical piping length (m)
     210              :         int PCFLengthCoolPtr;                                             // piping correction factor for length in cooling mode curve index
     211              :         Real64 PCFHeightCool;                                             // piping correction factor for height in cooling mode
     212              :         Real64 EquivPipeLngthCool;                                        // equivalent piping length for cooling
     213              :         Real64 PipingCorrectionCooling;                                   // piping correction factor for cooling
     214              :         int PCFLengthHeatPtr;                                             // piping correction factor for length in heating mode curve index
     215              :         Real64 PCFHeightHeat;                                             // piping correction factor for height in heating mode
     216              :         Real64 EquivPipeLngthHeat;                                        // equivalent piping length for heating
     217              :         Real64 PipingCorrectionHeating;                                   // piping correction factor for heating
     218              :         Real64 CCHeaterPower;                                             // crankcase heater power per compressor (W)
     219              :         Real64 CompressorSizeRatio;                                       // ratio of min compressor size to total capacity
     220              :         int NumCompressors;                                               // number of compressors in VRF condenser
     221              :         Real64 MaxOATCCHeater;                                            // maximum outdoor air dry-bulb temp for crankcase heater operation (C)
     222              :         // begin variables used for Defrost
     223              :         int DefrostEIRPtr;                                // index to defrost EIR curve
     224              :         Real64 DefrostFraction;                           // defrost time period fraction (hr)
     225              :         StandardRatings::DefrostStrat DefrostStrategy;    // Type of defrost (reversecycle or resistive)
     226              :         StandardRatings::HPdefrostControl DefrostControl; // type of defrost control (timed or ondemand)
     227              :         Real64 DefrostCapacity;                           // capacity of resistive defrost heating element (W)
     228              :         Real64 DefrostPower;                              // power used during defrost (W)
     229              :         Real64 DefrostConsumption;                        // energy used during defrost (J)
     230              :         Real64 MaxOATDefrost;                             // maximum outdoor air dry-bulb temp for defrost operation (C)
     231              :         // end variables used for Defrost
     232              :         DataHeatBalance::RefrigCondenserType CondenserType; // condenser type, evap- or air-cooled
     233              :         int CondenserNodeNum;                               // condenser inlet node number
     234              :         bool SkipCondenserNodeNumCheck;                     // used to check for duplicate node names
     235              :         int CondenserOutletNodeNum;                         // condenser outlet node number
     236              :         Real64 WaterCondVolFlowRate;                        // water condenser volume flow rate (m3/s)
     237              :         Real64 EvapCondEffectiveness;                       // evaporative condenser effectiveness
     238              :         Real64 EvapCondAirVolFlowRate;                      // air volume flow rate through condenser (m3/s)
     239              :         Real64 EvapCondPumpPower;                           // evaporative condenser water pump power (W)
     240              :         int CoolCombRatioPTR;                               // index to cooling combination ratio curve pointer
     241              :         int HeatCombRatioPTR;                               // index to heating combination ratio curve pointer
     242              :         int OperatingMode;                                  // VRF Condenser operating mode, 0=off, 1=cooling, 2=heating, 3=HR
     243              :         Real64 ElecPower;                                   // VRF Condenser power (W)
     244              :         Real64 ElecCoolingPower;                            // VRF Condenser power in cooling mode (W)
     245              :         Real64 ElecHeatingPower;                            // VRF Condenser power in heating mode (W)
     246              :         Real64 CoolElecConsumption;                         // VRF Condenser cooling energy (J)
     247              :         Real64 HeatElecConsumption;                         // VRF Condenser heating energy (J)
     248              :         Real64 CrankCaseHeaterPower;                        // VRF Condenser crankcase heater power (W)
     249              :         Real64 CrankCaseHeaterElecConsumption;              // VRF Condenser crankcase heater energy (J)
     250              :         Real64 EvapCondPumpElecPower;                       // VRF Condenser evaporatively cooled condenser pump power (W)
     251              :         Real64 EvapCondPumpElecConsumption;                 // VRF Condenser evaporatively cooled condenser pump elec consumption (J)
     252              :         Real64 EvapWaterConsumpRate;                        // VRF Condenser evaporatively cooled condenser water consumption (m3/s)
     253              :         int HRMaxTempLimitIndex = 0;                        // Warning message recurring error index
     254              :         int CoolingMaxTempLimitIndex = 0;                   // Warning message recurring error index
     255              :         int HeatingMaxTempLimitIndex = 0;                   // Warning message recurring error index
     256              :         Constant::eFuel fuel = Constant::eFuel::Invalid;    // Fuel type number
     257              :         Real64 SUMultiplier;                                // exponential timer for mode changes
     258              :         Real64 TUCoolingLoad;                               // total TU cooling load for each VRF system
     259              :         Real64 TUHeatingLoad;                               // total TU heating load for each VRF system
     260              :         bool SwitchedMode;                                  // used to derate capacity/power when system changes operating mode
     261              :         // begin variables used for heat recovery mode
     262              :         Real64 OperatingCOP;            // Operating VRF heat pump COP (total TU capacity/total power)
     263              :         Real64 MinOATHeatRecovery;      // Minimum outdoor air temperature for heat recovery operation (C)
     264              :         Real64 MaxOATHeatRecovery;      // Maximum outdoor air temperature for heat recovery operation (C)
     265              :         int HRCAPFTCool;                // Index to cool capacity as a function of temperature curve for heat recovery
     266              :         Real64 HRCAPFTCoolConst;        // constant used if curve is blank
     267              :         Real64 HRInitialCoolCapFrac;    // Fractional cooling degradation at the start of heat recovery from cooling mode
     268              :         Real64 HRCoolCapTC;             // Time constant used to recover from intial degratation in cooling heat recovery
     269              :         int HREIRFTCool;                // Index to cool EIR as a function of temperature curve for heat recovery
     270              :         Real64 HREIRFTCoolConst;        // constant used if curve is blank
     271              :         Real64 HRInitialCoolEIRFrac;    // Fractional EIR degradation at the start of heat recovery from cooling mode
     272              :         Real64 HRCoolEIRTC;             // Time constant used to recover from intial degratation in cooling heat recovery
     273              :         int HRCAPFTHeat;                // Index to heat capacity as a function of temperature curve for heat recovery
     274              :         Real64 HRCAPFTHeatConst;        // constant used if curve is blank
     275              :         Real64 HRInitialHeatCapFrac;    // Fractional heating degradation at the start of heat recovery from heating mode
     276              :         Real64 HRHeatCapTC;             // Time constant used to recover from intial degratation in heating heat recovery
     277              :         int HREIRFTHeat;                // Index to heat EIR as a function of temperature curve for heat recovery
     278              :         Real64 HREIRFTHeatConst;        // constant used if curve is blank
     279              :         Real64 HRInitialHeatEIRFrac;    // Fractional EIR degradation at the start of heat recovery from heating mode
     280              :         Real64 HRHeatEIRTC;             // Time constant used to recover from intial degratation in heating heat recovery
     281              :         bool HRCoolingActive;           // heat recovery mode active in cooling mode
     282              :         bool HRHeatingActive;           // heat recovery mode active in heating mode
     283              :         bool ModeChange;                // tracks changes in operating mode
     284              :         bool HRModeChange;              // tracks changes in heat recovery operating mode
     285              :         Real64 HRTimer;                 // timer used to model changes in system performance as mode changes
     286              :         Real64 HRTime;                  // length of time system has been in same mode (hr)
     287              :         int EIRFTempCoolErrorIndex = 0; // warning message index for recurring warnings
     288              :         int EIRFTempHeatErrorIndex = 0; // warning message index for recurring warnings
     289              :         int DefrostHeatErrorIndex = 0;  // warning message index for recurring warnings
     290              :         // end variables used for heat recovery mode
     291              :         // begin variables for Water System interactions
     292              :         EvapWaterSupply EvapWaterSupplyMode; // where does water come from
     293              :         std::string EvapWaterSupplyName;     // name of water source e.g. water storage tank
     294              :         int EvapWaterSupTankID;
     295              :         int EvapWaterTankDemandARRID;
     296              :         std::string CondensateCollectName; // name of water source e.g. water storage tank
     297              :         int CondensateTankID;
     298              :         int CondensateTankSupplyARRID;
     299              :         Real64 CondensateVdot; // rate of water condensation from air stream [m3/s]
     300              :         Real64 CondensateVol;  // amount of water condensed from air stream [m3]
     301              :         // end variables for water system interactions
     302              :         // begin variables for Basin Heater interactions
     303              :         Real64 BasinHeaterPowerFTempDiff;            // Basin heater capacity per degree C below setpoint (W/C)
     304              :         Real64 BasinHeaterSetPointTemp;              // setpoint temperature for basin heater operation (C)
     305              :         Real64 BasinHeaterPower;                     // Basin heater power (W)
     306              :         Real64 BasinHeaterConsumption;               // Basin heater energy consumption (J)
     307              :         Sched::Schedule *basinHeaterSched = nullptr; // Pointer to basin heater schedule
     308              :         // end variables for Basin Heater interactions
     309              :         bool EMSOverrideHPOperatingMode;
     310              :         Real64 EMSValueForHPOperatingMode;
     311              :         int HPOperatingModeErrorIndex;
     312              :         Real64 VRFHeatRec;             // Heat Recovery heat reclaim power (W)
     313              :         Real64 VRFHeatEnergyRec;       // Heat Recovery heat reclain energy (J)
     314              :         int HeatCapFTErrorIndex = 0;   // warning message index
     315              :         int CoolCapFTErrorIndex = 0;   // warning message index
     316              :         int HeatEIRFPLRErrorIndex = 0; // warning message index
     317              :         int CoolEIRFPLRErrorIndex = 0; // warning message index
     318              :         int LowLoadTeError = 0;
     319              :         int LowLoadTeErrorIndex = 0; // warning message index
     320              :         // The following are for the Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
     321              :         int AlgorithmIUCtrl;             // VRF indoor unit contrl algorithm, 1-High sensible, 2-Te/Tc constant
     322              :         Array1D<Real64> CompressorSpeed; // compressor speed array [rps]
     323              :         Real64 CondensingTemp;           // VRV system outdoor unit condensing temperature [C]
     324              :         Real64 CondTempFixed;            // Inddor unit condensing temperature, fixed, for AlgorithmIUCtrl is 2-Te/Tc constant [C]
     325              :         Real64 CoffEvapCap;              // Evaporative Capacity Correction Factor
     326              :         Real64 CompActSpeed;             // Compressor speed [rps]
     327              :         Real64 CompMaxDeltaP;            // maximum compressor pressure rise [Pa]
     328              :         Real64 C1Te;                     // VRF Outdoor Unit Coefficient 1 to calculate Te,req [--]
     329              :         Real64 C2Te;                     // VRF Outdoor Unit Coefficient 2 to calculate Te,req [--]
     330              :         Real64 C3Te;                     // VRF Outdoor Unit Coefficient 3 to calculate Te,req [--]
     331              :         Real64 C1Tc;                     // VRF Outdoor Unit Coefficient 1 to calculate Tc,req [--]
     332              :         Real64 C2Tc;                     // VRF Outdoor Unit Coefficient 2 to calculate Tc,req [--]
     333              :         Real64 C3Tc;                     // VRF Outdoor Unit Coefficient 3 to calculate Tc,req [--]
     334              :         Real64 DiffOUTeTo;               // Difference between Outdoor Unit Te and OAT during Simultaneous Heating and Cooling operations
     335              :         Real64 EffCompInverter;          // Compressor Inverter Efficiency
     336              :         Real64 EvaporatingTemp;          // VRV system outdoor unit evaporating temperature [C]
     337              :         Real64 EvapTempFixed;            // Indoor unit evaporating temperature, fixed, for AlgorithmIUCtrl is 2-Te/Tc constant [C]
     338              :         Real64 HROUHexRatio;             // HR OU Heat Exchanger Capacity Ratio [--]
     339              :         Real64 IUEvaporatingTemp;        // VRV system indoor unit evaporating temperature, min among all indoor units [C]
     340              :         Real64 IUCondensingTemp;         // VRV system indoor unit condensing temperature, max among all indoor units [C]
     341              :         Real64 IUEvapTempLow;            // VRV system indoor unit evaporating temperature, lower bound[C]
     342              :         Real64 IUEvapTempHigh;           // VRV system indoor unit evaporating temperature, higher bound [C]
     343              :         Real64 IUCondTempLow;            // VRV system indoor unit condensing temperature, lower bound [C]
     344              :         Real64 IUCondTempHigh;           // VRV system indoor unit condensing temperature, higher bound [C]
     345              :         Real64 IUCondHeatRate;           // Indoor Unit Condensers Total Heat Release Rate, excluding piping loss  [W]
     346              :         Real64 IUEvapHeatRate;           // Outdoor Unit Evaporators Total Heat Extract Rate, excluding piping loss  [W]
     347              :         Real64 Ncomp;                    // compressor electric power [W]
     348              :         Real64 NcompCooling;             // compressor electric power at cooling mode [W]
     349              :         Real64 NcompHeating;             // compressor electric power at heating mode [W]
     350              :         Array1D_int OUCoolingCAPFT;      // index to outdoor unit cooling capacity function of temperature at different compressor speed
     351              :         Array1D_int OUCoolingPWRFT;      // index to outdoor unit cooling power function of temperature at different compressor speed
     352              :         Real64 OUEvapTempLow;            // VRV system outdoor unit evaporating temperature, lower bound[C]
     353              :         Real64 OUEvapTempHigh;           // VRV system outdoor unit evaporating temperature, higher bound [C]
     354              :         Real64 OUCondTempLow;            // VRV system outdoor unit condensing temperature, lower bound [C]
     355              :         Real64 OUCondTempHigh;           // VRV system outdoor unit condensing temperature, higher bound [C]
     356              :         Real64 OUAirFlowRate;            // Max condenser air flow rate [m3/s]
     357              :         Real64 OUAirFlowRatePerCapcity;  // Max condenser air flow rate per Evaporative Capacity [m3/s]
     358              :         Real64 OUCondHeatRate;           // Outdoor Unit Condenser Heat Release Rate, excluding piping loss [W]
     359              :         Real64 OUEvapHeatRate;           // Outdoor Unit Evaporator Heat Extract Rate, excluding piping loss  [W]
     360              :         Real64 OUFanPower;               // Outdoor unit fan power at real conditions[W]
     361              :         std::string refrigName;          // Name of refrigerant, must match name in FluidName (see fluidpropertiesrefdata.idf)
     362              :         Fluid::RefrigProps *refrig;
     363              :         Real64 RatedEvapCapacity;         // Rated Evaporative Capacity [W]
     364              :         Real64 RatedHeatCapacity;         // Rated Heating Capacity [W]
     365              :         Real64 RatedCompPower;            // Rated Compressor Power [W]
     366              :         Real64 RatedCompPowerPerCapcity;  // Rated Compressor Power per Evaporative Capacity [W]
     367              :         Real64 RatedOUFanPower;           // Outdoor unit fan power at rated conditions [W]
     368              :         Real64 RatedOUFanPowerPerCapcity; // Rated outdoor unit fan power per Evaporative Capacity [W]
     369              :         Real64 RateBFOUEvap;              // Outdoor Unit Evaporator Rated Bypass Factor
     370              :         Real64 RateBFOUCond;              // Outdoor Unit Condenser Rated Bypass Factor
     371              :         Real64 RefPipDiaSuc;              // diameter of refrigerant pipe (suction gas) that links the outdoor unit to the indoor units [m]
     372              :         Real64 RefPipDiaDis;              // diameter of refrigerant pipe (discharge gas) that links the outdoor unit to the indoor units [m]
     373              :         Real64 RefPipLen;                 // length of refrigerant pipe that links the outdoor unit to the indoor units [m]
     374              :         Real64 RefPipEquLen;              // Equivalent length of refrigerant pipe for pressure drop calculations [m]
     375              :         Real64 RefPipHei;                 // height of refrigerant pipe that links the outdoor unit to the indoor units [m]
     376              :         Real64 RefPipInsThi;              // thickness of refrigerant pipe insulation [m]
     377              :         Real64 RefPipInsCon;              // thermal conductivity of refrigerant pipe insulation [W/mk]
     378              :         Real64 SH;                        // VRF outdoor unit superheating degrees [C]
     379              :         Real64 SC;                        // VRF outdoor unit subcooling degrees [C]
     380              :         Real64 SCHE;                      // Simultaneous Cooling and Heating Efficiency [Btu/h/W]
     381              :         Real64 SHLow;                     // VRF outdoor unit superheating degrees lower limit [C]
     382              :         Real64 SCLow;                     // VRF outdoor unit subcooling degrees lower limit [C]
     383              :         Real64 SHHigh;                    // VRF outdoor unit superheating degrees uppler limit [C]
     384              :         Real64 SCHigh;                    // VRF outdoor unit subcooling degrees uppler limit [C]
     385              :         Real64 VRFOperationSimPath;       // simulation path indicating the VRF operation mode [--]
     386              :         bool checkPlantCondTypeOneTime;
     387              :         int CondenserCapErrIdx; // recurring condenser capacity error index
     388              :         bool adjustedTe;
     389              : 
     390              :         // Default Constructor
     391           64 :         VRFCondenserEquipment()
     392           64 :             : VRFSystemTypeNum(0), VRFAlgorithmType(AlgorithmType::Invalid), VRFType(DataPlant::PlantEquipmentType::Invalid), SourcePlantLoc{},
     393           64 :               WaterCondenserDesignMassFlow(0.0), WaterCondenserMassFlow(0.0), QCondenser(0.0), QCondEnergy(0.0), CondenserSideOutletTemp(0.0),
     394           64 :               CoolingCapacity(0.0), TotalCoolingCapacity(0.0), CoolingCombinationRatio(1.0), VRFCondPLR(0.0), VRFCondRTF(0.0),
     395           64 :               VRFCondCyclingRatio(0.0), CondenserInletTemp(0.0), CoolingCOP(0.0), OperatingCoolingCOP(0.0), RatedCoolingPower(0.0),
     396           64 :               HeatingCapacity(0.0), HeatingCapacitySizeRatio(1.0), LockHeatingCapacity(false), TotalHeatingCapacity(0.0),
     397           64 :               HeatingCombinationRatio(1.0), HeatingCOP(0.0), OperatingHeatingCOP(0.0), RatedHeatingPower(0.0), MinOATCooling(0.0), MaxOATCooling(0.0),
     398           64 :               MinOATHeating(0.0), MaxOATHeating(0.0), CoolCapFT(0), CoolEIRFT(0), HeatCapFT(0), HeatEIRFT(0), CoolBoundaryCurvePtr(0),
     399           64 :               HeatBoundaryCurvePtr(0), EIRCoolBoundaryCurvePtr(0), CoolEIRFPLR1(0), CoolEIRFPLR2(0), CoolCapFTHi(0), CoolEIRFTHi(0), HeatCapFTHi(0),
     400           64 :               HeatEIRFTHi(0), EIRHeatBoundaryCurvePtr(0), HeatEIRFPLR1(0), HeatEIRFPLR2(0), CoolPLFFPLR(0), HeatPLFFPLR(0), MinPLR(0.0),
     401           64 :               MasterZonePtr(0), MasterZoneTUIndex(0), ThermostatPriority(ThermostatCtrlType::Invalid), ZoneTUListPtr(0), HeatRecoveryUsed(false),
     402           64 :               VertPipeLngth(0.0), PCFLengthCoolPtr(0), PCFHeightCool(0.0), EquivPipeLngthCool(0.0), PipingCorrectionCooling(1.0), PCFLengthHeatPtr(0),
     403           64 :               PCFHeightHeat(0.0), EquivPipeLngthHeat(0.0), PipingCorrectionHeating(1.0), CCHeaterPower(0.0), CompressorSizeRatio(0.0),
     404           64 :               NumCompressors(0), MaxOATCCHeater(0.0), DefrostEIRPtr(0), DefrostFraction(0.0), DefrostStrategy(StandardRatings::DefrostStrat::Invalid),
     405           64 :               DefrostControl(StandardRatings::HPdefrostControl::Invalid), DefrostCapacity(0.0), DefrostPower(0.0), DefrostConsumption(0.0),
     406           64 :               MaxOATDefrost(0.0), CondenserType(DataHeatBalance::RefrigCondenserType::Invalid), CondenserNodeNum(0), SkipCondenserNodeNumCheck(false),
     407           64 :               CondenserOutletNodeNum(0), WaterCondVolFlowRate(0.0), EvapCondEffectiveness(0.0), EvapCondAirVolFlowRate(0.0), EvapCondPumpPower(0.0),
     408           64 :               CoolCombRatioPTR(0), HeatCombRatioPTR(0), OperatingMode(0), ElecPower(0.0), ElecCoolingPower(0.0), ElecHeatingPower(0.0),
     409           64 :               CoolElecConsumption(0.0), HeatElecConsumption(0.0), CrankCaseHeaterPower(0.0), CrankCaseHeaterElecConsumption(0.0),
     410           64 :               EvapCondPumpElecPower(0.0), EvapCondPumpElecConsumption(0.0), EvapWaterConsumpRate(0.0), SUMultiplier(0.0), TUCoolingLoad(0.0),
     411           64 :               TUHeatingLoad(0.0), SwitchedMode(false), OperatingCOP(0.0), MinOATHeatRecovery(0.0), MaxOATHeatRecovery(0.0), HRCAPFTCool(0),
     412           64 :               HRCAPFTCoolConst(0.9), HRInitialCoolCapFrac(0.5), HRCoolCapTC(0.15), HREIRFTCool(0), HREIRFTCoolConst(1.1), HRInitialCoolEIRFrac(1.0),
     413           64 :               HRCoolEIRTC(0.0), HRCAPFTHeat(0), HRCAPFTHeatConst(1.1), HRInitialHeatCapFrac(1.0), HRHeatCapTC(0.0), HREIRFTHeat(0),
     414           64 :               HREIRFTHeatConst(1.1), HRInitialHeatEIRFrac(1.0), HRHeatEIRTC(0.0), HRCoolingActive(false), HRHeatingActive(false), ModeChange(false),
     415          128 :               HRModeChange(false), HRTimer(0.0), HRTime(0.0), EvapWaterSupplyMode(EvapWaterSupply::FromMains), EvapWaterSupTankID(0),
     416          128 :               EvapWaterTankDemandARRID(0), CondensateTankID(0), CondensateTankSupplyARRID(0), CondensateVdot(0.0), CondensateVol(0.0),
     417           64 :               BasinHeaterPowerFTempDiff(0.0), BasinHeaterSetPointTemp(0.0), BasinHeaterPower(0.0), BasinHeaterConsumption(0.0),
     418           64 :               EMSOverrideHPOperatingMode(false), EMSValueForHPOperatingMode(0.0), HPOperatingModeErrorIndex(0), VRFHeatRec(0.0),
     419          128 :               VRFHeatEnergyRec(0.0), AlgorithmIUCtrl(1), CondensingTemp(44.0), CondTempFixed(0.0), CoffEvapCap(1.0), CompActSpeed(0.0),
     420           64 :               CompMaxDeltaP(0.0), C1Te(0.0), C2Te(0.0), C3Te(0.0), C1Tc(0.0), C2Tc(0.0), C3Tc(0.0), DiffOUTeTo(5), EffCompInverter(0.95),
     421           64 :               EvaporatingTemp(6.0), EvapTempFixed(0.0), HROUHexRatio(0.0), IUEvaporatingTemp(6.0), IUCondensingTemp(44.0), IUEvapTempLow(4.0),
     422           64 :               IUEvapTempHigh(15.0), IUCondTempLow(42.0), IUCondTempHigh(46.0), IUCondHeatRate(0.0), IUEvapHeatRate(0.0), Ncomp(0.0),
     423          128 :               NcompCooling(0.0), NcompHeating(0.0), OUEvapTempLow(-30.0), OUEvapTempHigh(20.0), OUCondTempLow(30.0), OUCondTempHigh(96.0),
     424          128 :               OUAirFlowRate(0.0), OUAirFlowRatePerCapcity(0.0), OUCondHeatRate(0.0), OUEvapHeatRate(0.0), OUFanPower(0.0), RatedEvapCapacity(40000.0),
     425           64 :               RatedHeatCapacity(0.0), RatedCompPower(14000.0), RatedCompPowerPerCapcity(0.35), RatedOUFanPower(0.0), RatedOUFanPowerPerCapcity(0.0),
     426           64 :               RateBFOUEvap(0.45581), RateBFOUCond(0.21900), RefPipDiaSuc(0.0), RefPipDiaDis(0.0), RefPipLen(0.0), RefPipEquLen(0.0), RefPipHei(0.0),
     427           64 :               RefPipInsThi(0.0), RefPipInsCon(0.0), SH(0.0), SC(0.0), SCHE(0.0), SHLow(0.0), SCLow(0.0), SHHigh(0.0), SCHigh(0.0),
     428          128 :               VRFOperationSimPath(0.0), checkPlantCondTypeOneTime(true), CondenserCapErrIdx(0), adjustedTe(false)
     429              :         {
     430           64 :         }
     431              : 
     432              :         // Begin of Methods for New VRF Model: Fluid Temperature Control
     433              :         //******************************************************************************
     434              : 
     435              :         void onInitLoopEquip([[maybe_unused]] EnergyPlusData &state, const PlantLocation &calledFromLocation) override;
     436              : 
     437              :         void getDesignCapacities(
     438              :             EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad) override;
     439              : 
     440              :         void simulate([[maybe_unused]] EnergyPlusData &state,
     441              :                       const PlantLocation &calledFromLocation,
     442              :                       bool FirstHVACIteration,
     443              :                       Real64 &CurLoad,
     444              :                       bool RunFlag) override;
     445              : 
     446              :         static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
     447              : 
     448              :         void SizeVRFCondenser(EnergyPlusData &state);
     449              : 
     450              :         void CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state, const bool FirstHVACIteration);
     451              : 
     452              :         void CalcVRFIUTeTc_FluidTCtrl(EnergyPlusData &state);
     453              : 
     454              :         void VRFOU_TeTc(EnergyPlusData &state,
     455              :                         HXOpMode OperationMode, // Flag for hex operation
     456              :                         Real64 Q_coil,          // // OU coil heat release at cooling mode or heat extract at heating mode [W]
     457              :                         Real64 SHSC,            // SH at cooling or SC at heating [C]
     458              :                         Real64 m_air,           // OU coil air mass flow rate [kg/s]
     459              :                         Real64 T_coil_in,       // Temperature of air at OU coil inlet [C]
     460              :                         Real64 W_coil_in,       // Humidity ratio of air at OU coil inlet [kg/kg]
     461              :                         Real64 OutdoorPressure, // Outdoor air pressure (Pa)
     462              :                         Real64 &T_coil_surf,    // Air temperature at coil surface [C]
     463              :                         Real64 &TeTc            // VRF Tc at cooling mode, or Te at heating mode [C]
     464              :         );
     465              : 
     466              :         Real64 VRFOU_FlowRate(EnergyPlusData &state,
     467              :                               HXOpMode OperationMode, // Flag for hex operation
     468              :                               Real64 TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
     469              :                               Real64 SHSC,            // SC for OU condenser or SH for OU evaporator [C]
     470              :                               Real64 Q_coil,          // absolute value of OU coil heat release or heat extract [W]
     471              :                               Real64 T_coil_in,       // Temperature of air at OU coil inlet [C]
     472              :                               Real64 W_coil_in        // Humidity ratio of air at OU coil inlet [kg/kg]
     473              :         ) const;
     474              : 
     475              :         Real64 VRFOU_Cap(EnergyPlusData &state,
     476              :                          HXOpMode OperationMode, // Flag for hex operation
     477              :                          Real64 TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
     478              :                          Real64 SHSC,            // SC for OU condenser or SH for OU evaporator [C]
     479              :                          Real64 m_air,           // OU coil air mass flow rate [kg/s]
     480              :                          Real64 T_coil_in,       // Temperature of air at OU coil inlet [C]
     481              :                          Real64 W_coil_in        // Humidity ratio of air at OU coil inlet [kg/kg]
     482              :         );
     483              : 
     484              :         Real64 VRFOU_SCSH(EnergyPlusData &state,
     485              :                           HXOpMode OperationMode, // Mode 0 for running as evaporator, 1 for condenser
     486              :                           Real64 Q_coil,          // // OU coil heat release at cooling mode or heat extract at heating mode [W]
     487              :                           Real64 TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
     488              :                           Real64 m_air,           // OU coil air mass flow rate [kg/s]
     489              :                           Real64 T_coil_in,       // Temperature of air at OU coil inlet [C]
     490              :                           Real64 W_coil_in,       // Humidity ratio of air at OU coil inlet [kg/kg]
     491              :                           Real64 OutdoorPressure  // Outdoor air pressure [Pa]
     492              :         ) const;
     493              : 
     494              :         Real64 VRFOU_CapModFactor(EnergyPlusData &state,
     495              :                                   Real64 h_comp_in_real, // Enthalpy of refrigerant at the compressor inlet at real conditions [kJ/kg]
     496              :                                   Real64 h_evap_in_real, // Enthalpy of refrigerant at the evaporator inlet at real conditions [kJ/kg]
     497              :                                   Real64 P_evap_real,    // Evaporative pressure at real conditions [Pa]
     498              :                                   Real64 T_comp_in_real, // Temperature of the refrigerant at the compressor inlet at real conditions [C]
     499              :                                   Real64 T_comp_in_rate, // Temperature of the refrigerant at the compressor inlet at rated conditions [C]
     500              :                                   Real64 T_cond_out_rate // Temperature of the refrigerant at the condenser outlet at rated conditions [C]
     501              :         );
     502              : 
     503              :         void VRFOU_TeModification(EnergyPlusData &state,
     504              :                                   Real64 Te_up,          // Upper bound of Te during iteration, i.e., Te before reduction [C]
     505              :                                   Real64 Te_low,         // Lower bound of Te during iteration, i.e., the given suction temperature Te' [C]
     506              :                                   Real64 Pipe_h_IU_in,   // Piping Loss Algorithm Parameter: enthalpy of IU at inlet [kJ/kg]
     507              :                                   Real64 OutdoorDryBulb, // outdoor dry-bulb temperature [C]
     508              :                                   Real64 &Te_update,     // Updated Te that can generate the required Tsuction [C]
     509              :                                   Real64 &Pe_update,     // Piping Loss Algorithm Parameter: evaporating pressure assumed for iterations [Pa]
     510              :                                   Real64 &Pipe_m_ref,    // Piping Loss Algorithm Parameter: Refrigerant mass flow rate [kg/s]
     511              :                                   Real64 &Pipe_h_IU_out, // Piping Loss Algorithm Parameter: enthalpy of IU at outlet [kJ/kg]
     512              :                                   Real64 &Pipe_SH_merged // Piping Loss Algorithm Parameter: Average SH after the indoor units [C]
     513              :         );
     514              : 
     515              :         void VRFOU_CalcCompC(EnergyPlusData &state,
     516              :                              Real64 TU_load,            // Indoor unit cooling load [W]
     517              :                              Real64 T_suction,          // Compressor suction temperature Te' [C]
     518              :                              Real64 T_discharge,        // Compressor discharge temperature Tc' [C]
     519              :                              Real64 P_suction,          // Compressor suction pressure Pe' [Pa]
     520              :                              Real64 Pipe_T_comp_in,     // Refrigerant temperature at compressor inlet (after piping loss) [C]
     521              :                              Real64 Pipe_h_comp_in,     // Enthalpy after piping loss (compressor inlet) [kJ/kg]
     522              :                              Real64 Pipe_h_IU_in,       // Enthalpy of IU at inlet [kJ/kg]
     523              :                              Real64 Pipe_Q,             // Piping Loss Algorithm Parameter: Heat loss [W]
     524              :                              Real64 MaxOutdoorUnitTc,   // The maximum temperature that Tc can be at heating mode [C]
     525              :                              Real64 &OUCondHeatRelease, // Condenser heat release (cooling mode) [W]
     526              :                              Real64 &CompSpdActual,     // Actual compressor running speed [rps]
     527              :                              Real64 &Ncomp,             // Compressor power [W]
     528              :                              Real64 &CyclingRatio       // Cycling Ratio [W]
     529              :         );
     530              : 
     531              :         void
     532              :         VRFOU_CalcCompH(EnergyPlusData &state,
     533              :                         Real64 TU_load,            // Indoor unit cooling load [W]
     534              :                         Real64 T_suction,          // Compressor suction temperature Te' [C]
     535              :                         Real64 T_discharge,        // Compressor discharge temperature Tc' [C]
     536              :                         Real64 Pipe_h_out_ave,     // Average Enthalpy of the refrigerant leaving IUs [kJ/kg]
     537              :                         Real64 IUMaxCondTemp,      // VRV IU condensing temperature, max among all indoor units [C]
     538              :                         Real64 MinOutdoorUnitTe,   // The minimum temperature that Te can be at cooling mode (only used for calculating Min capacity)
     539              :                         Real64 Tfs,                // Temperature of the air at the coil surface [C]]
     540              :                         Real64 Pipe_Q,             // Piping Loss Algorithm Parameter: Heat loss [W]
     541              :                         Real64 &OUEvapHeatExtract, // Condenser heat release (cooling mode) [W]
     542              :                         Real64 &CompSpdActual,     // Actual compressor running speed [rps]
     543              :                         Real64 &Ncomp,             // Compressor power [W]
     544              :                         Real64 &CyclingRatio       // Compressor cycling ratio
     545              :         );
     546              : 
     547              :         void VRFHR_OU_HR_Mode(EnergyPlusData &state,
     548              :                               Real64 h_IU_evap_in,   // enthalpy of IU evaporator at inlet [kJ/kg]
     549              :                               Real64 h_comp_out,     // enthalpy of refrigerant at compressor outlet [kJ/kg]
     550              :                               Real64 Q_c_TU_PL,      // IU evaporator load, including piping loss [W]
     551              :                               Real64 Q_h_TU_PL,      // IU condenser load, including piping loss [W]
     552              :                               Real64 Tdischarge,     // VRF Compressor discharge refrigerant temperature [C]
     553              :                               Real64 &Tsuction,      // VRF compressor suction refrigerant temperature [C]
     554              :                               Real64 &Te_update,     // updated evaporating temperature, only updated when Tsuction is updated [C]
     555              :                               Real64 &h_comp_in,     // enthalpy of refrigerant at compressor inlet [kJ/kg]
     556              :                               Real64 &h_IU_PLc_out,  // enthalpy of refrigerant at the outlet of IU evaporator side main pipe [kJ/kg]
     557              :                               Real64 &Pipe_Q_c,      // IU evaporator side piping loss [W]
     558              :                               Real64 &Q_c_OU,        // OU evaporator load [W]
     559              :                               Real64 &Q_h_OU,        // OU condenser load [W]
     560              :                               Real64 &m_ref_IU_evap, // mass flow rate of Refrigerant through IU evaporators [kg/s]
     561              :                               Real64 &m_ref_OU_evap, // mass flow rate of Refrigerant through OU evaporator [kg/s]
     562              :                               Real64 &m_ref_OU_cond, // mass flow rate of Refrigerant through OU condenser [kg/s]
     563              :                               Real64 &N_fan_OU,      // outdoor unit fan power [W]
     564              :                               Real64 &CompSpdActual, // Actual compressor running speed [rps]
     565              :                               Real64 &Ncomp          // compressor power [W]
     566              :         );
     567              : 
     568              :         void VRFOU_CompSpd(EnergyPlusData &state,
     569              :                            Real64 Q_req,         // Required capacity [W]
     570              :                            HXOpMode Q_type,      // Required capacity type: 0 for evaporator, 1 for condenser
     571              :                            Real64 T_suction,     // Compressor suction temperature Te' [C]
     572              :                            Real64 T_discharge,   // Compressor discharge temperature Tc' [C]
     573              :                            Real64 h_IU_evap_in,  // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg]
     574              :                            Real64 h_comp_in,     // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg]
     575              :                            Real64 &CompSpdActual // Actual compressor running speed [rps]
     576              :         );
     577              : 
     578              :         void VRFOU_CompCap(EnergyPlusData &state,
     579              :                            Real64 CompSpdActual, // Given compressor speed
     580              :                            Real64 T_suction,     // Compressor suction temperature Te' [C]
     581              :                            Real64 T_discharge,   // Compressor discharge temperature Tc' [C]
     582              :                            Real64 h_IU_evap_in,  // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg]
     583              :                            Real64 h_comp_in,     // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg]
     584              :                            Real64 &Q_c_tot,      // Compressor evaporative capacity [W]
     585              :                            Real64 &Ncomp         // Compressor power [W]
     586              :         );
     587              : 
     588              :         void VRFOU_PipeLossC(EnergyPlusData &state,
     589              :                              Real64 Pipe_m_ref,     // Refrigerant mass flow rate [kg/s]
     590              :                              Real64 Pevap,          // VRF evaporating pressure [Pa]
     591              :                              Real64 Pipe_h_IU_out,  // Enthalpy of IU at outlet [kJ/kg]
     592              :                              Real64 Pipe_SH_merged, // Average super heating degrees after the indoor units [C]
     593              :                              Real64 OutdoorDryBulb, // outdoor dry-bulb temperature (C)
     594              :                              Real64 &Pipe_Q,        // unit part load ratio
     595              :                              Real64 &Pipe_DeltP,    // ratio of compressor ON airflow to AVERAGE airflow over timestep
     596              :                              Real64 &Pipe_h_comp_in // Piping Loss Algorithm Parameter: Enthalpy after piping loss (compressor inlet) [kJ/kg]
     597              :         );
     598              : 
     599              :         void VRFOU_PipeLossH(EnergyPlusData &state,
     600              :                              Real64 Pipe_m_ref,      // Refrigerant mass flow rate [kg/s]
     601              :                              Real64 Pcond,           // VRF condensing pressure [Pa]
     602              :                              Real64 Pipe_h_IU_in,    // Enthalpy of IU at outlet [kJ/kg]
     603              :                              Real64 OutdoorDryBulb,  // outdoor dry-bulb temperature (C)
     604              :                              Real64 &Pipe_Q,         // unit part load ratio
     605              :                              Real64 &Pipe_DeltP,     // ratio of compressor ON airflow to AVERAGE airflow over timestep
     606              :                              Real64 &Pipe_h_comp_out // Piping Loss Algorithm Parameter: Enthalpy before piping loss (compressor outlet) [kJ/kg]
     607              :         ) const;
     608              : 
     609              :         void oneTimeInit(EnergyPlusData &state) override;
     610              : 
     611              :         void oneTimeInit_new(EnergyPlusData &state) override;
     612              :     };
     613              : 
     614              :     struct TerminalUnitListData
     615              :     {
     616              :         // Members
     617              :         std::string Name;                                  // Name of the VRF Terminal Unit List
     618              :         int NumTUInList;                                   // Number of VRF Terminal Units in List
     619              :         bool reset_isSimulatedFlags;                       // used to align simulate flags with order of each TU in simulation
     620              :         Array1D_int ZoneTUPtr;                             // index to VRF Terminal Unit
     621              :         Array1D_string ZoneTUName;                         // Name of the VRF Terminal Unit
     622              :         Array1D_bool IsSimulated;                          // TRUE if TU has been simulated
     623              :         Array1D<Real64> TotalCoolLoad;                     // Total zone cooling coil load met by TU
     624              :         Array1D<Real64> TotalHeatLoad;                     // Total zone heating coil load met by TU
     625              :         Array1D_bool CoolingCoilPresent;                   // FALSE if coil not present
     626              :         Array1D_bool HeatingCoilPresent;                   // FALSE if coil not present
     627              :         Array1D_bool SuppHeatingCoilPresent;               // FALSE if supplemental heating coil not present
     628              :         Array1D_bool TerminalUnitNotSizedYet;              // TRUE if terminal unit not sized
     629              :         Array1D_bool HRHeatRequest;                        // defines a heating load on VRFTerminalUnits when QZnReq < 0
     630              :         Array1D_bool HRCoolRequest;                        // defines a cooling load on VRFTerminalUnits when QZnReq > 0
     631              :         Array1D_bool CoolingCoilAvailable;                 // cooling coil availability scheduled on
     632              :         Array1D_bool HeatingCoilAvailable;                 // cooling coil availability scheduled on
     633              :         Array1D<Sched::Schedule *> coolingCoilAvailScheds; // cooling coil availability schedule index
     634              :         Array1D<Sched::Schedule *> heatingCoilAvailScheds; // heating coil availability schedule index
     635              : 
     636              :         // Default Constructor
     637           62 :         TerminalUnitListData() : NumTUInList(0), reset_isSimulatedFlags(true)
     638              :         {
     639           62 :         }
     640              :     };
     641              : 
     642              :     struct VRFTerminalUnitEquipment
     643              :     {
     644              :         // Members
     645              :         std::string Name;                                  // Name of the VRF Terminal Unit
     646              :         TUType type = TUType::Invalid;                     // DataHVACGlobals VRF Terminal Unit type
     647              :         Sched::Schedule *availSched = nullptr;             // Pointer to the correct schedule // LOL // avail?
     648              :         int VRFSysNum = 0;                                 // index to VRF Condenser
     649              :         int TUListIndex = 0;                               // index to VRF Terminal Unit List
     650              :         int IndexToTUInTUList = 0;                         // index to TU in VRF Terminal Unit List
     651              :         int ZoneNum = 0;                                   // index to zone where VRF Terminal Unit resides
     652              :         int ZoneAirNode = 0;                               // zone air node number
     653              :         int VRFTUInletNodeNum = 0;                         // VRF Terminal Unit inlet node number
     654              :         int VRFTUOutletNodeNum = 0;                        // VRF Terminal Unit outlet node number
     655              :         int VRFTUOAMixerOANodeNum = 0;                     // OA node number for this TU's OA mixer
     656              :         int VRFTUOAMixerRelNodeNum = 0;                    // Relief node number for this TU's OA mixer
     657              :         int VRFTUOAMixerRetNodeNum = 0;                    // Return node number for this TU's OA mixer
     658              :         int VRFTUOAMixerMixedNodeNum = 0;                  // Mixed node number for this TU's OA mixer
     659              :         Real64 MaxCoolAirVolFlow = 0.0;                    // supply air volumetric flow rate during cooling operation [m3/s]
     660              :         Real64 MaxHeatAirVolFlow = 0.0;                    // supply air volumetric flow rate during heating operation [m3/s]
     661              :         Real64 MaxNoCoolAirVolFlow = 0.0;                  // supply air volumetric flow rate when no cooling [m3/s]
     662              :         Real64 MaxNoHeatAirVolFlow = 0.0;                  // supply air volumetric flow rate when no heating [m3/s]
     663              :         Real64 MaxCoolAirMassFlow = 0.0;                   // supply air mass flow rate during cooling operation [kg/s]
     664              :         Real64 MaxHeatAirMassFlow = 0.0;                   // supply air mass flow rate during heating operation [kg/s]
     665              :         Real64 MaxNoCoolAirMassFlow = 0.0;                 // supply air mass flow rate when no cooling [kg/s]
     666              :         Real64 MaxNoHeatAirMassFlow = 0.0;                 // supply air mass flow rate when no heating [kg/s]
     667              :         Real64 CoolOutAirVolFlow = 0.0;                    // OA volumetric flow rate during cooling operation [m3/s]
     668              :         Real64 HeatOutAirVolFlow = 0.0;                    // OA volumetric flow rate during heating operation [m3/s]
     669              :         Real64 NoCoolHeatOutAirVolFlow = 0.0;              // OA volumetric flow rate when no cooling or heating [m3/s]
     670              :         Real64 CoolOutAirMassFlow = 0.0;                   // OA mass flow rate during cooling operation [kg/s]
     671              :         Real64 HeatOutAirMassFlow = 0.0;                   // OA mass flow rate during heating operation [kg/s]
     672              :         Real64 NoCoolHeatOutAirMassFlow = 0.0;             // OA mass flow rate when no cooling or heating [kg/s]
     673              :         Real64 MinOperatingPLR = 1.0E-20;                  // minimum part-load ratio for operating of fan/coil
     674              :         Real64 SuppHeatCoilFluidMaxFlow = 0.0;             // supplemental heating coil fluid (hot water or steam) maximum flow rate [kg/s]
     675              :         Real64 DesignSuppHeatingCapacity = 0.0;            // supplemental heating coil design capacity  [W]
     676              :         Real64 MaxSATFromSuppHeatCoil = 0.0;               // maximum supply air temperature from supplemental heating coil [C]
     677              :         Real64 MaxOATSuppHeatingCoil = 0.0;                // maximum outdoor dry-bulb temperature for supplemental heating coil [C]
     678              :         Real64 SuppHeatPartLoadRatio = 0.0;                // supplemental heating coil part load ratio
     679              :         Real64 SuppHeatingCoilLoad = 0.0;                  // supplemental heating coil heating load
     680              :         HVAC::FanType fanType = HVAC::FanType::Invalid;    // index to fan type
     681              :         Sched::Schedule *fanOpModeSched = nullptr;         // Pointer to the correct fan operating mode schedule
     682              :         Sched::Schedule *fanAvailSched = nullptr;          // Pointer to the correct fan availability schedule
     683              :         int FanIndex = 0;                                  // Index to fan object
     684              :         Real64 FanPower = 0.0;                             // power reported by fan component
     685              :         HVAC::FanOp fanOp = HVAC::FanOp::Invalid;          // operation mode: 1 = cycling fan, cycling coil 2 = constant fan, cycling coil
     686              :         HVAC::FanPlace fanPlace = HVAC::FanPlace::Invalid; // fan placement; 1=blow through, 2=draw through
     687              :         Real64 ActualFanVolFlowRate = 0.0;                 // volumetric flow rate from fan object
     688              :         std::string SuppHeatCoilType;                      // type of supplemental heating coil
     689              :         std::string SuppHeatCoilName;                      // name of supplemental heating coil
     690              :         std::string OAMixerName;                           // name of outside air mixer
     691              :         int OAMixerIndex = 0;                              // index to outside air mixer
     692              :         bool OAMixerUsed = false;                          // true if OA Mixer object is used
     693              :         int CoolCoilIndex = 0;                             // index to terminal unit cooling coil
     694              :         int HeatCoilIndex = 0;                             // index to terminal unit heating coil
     695              :         int SuppHeatCoilIndex = 0;                         // index to terminal unit supplemental heating coil
     696              :         int DXCoolCoilType_Num = 0;                        // type of VRF cooling coil
     697              :         int DXHeatCoilType_Num = 0;                        // type of VRF heating coil
     698              :         int SuppHeatCoilType_Num = 0;                      // type of VRF supplemental heating coil
     699              :         Real64 ParasiticElec = 0.0;                        // parasitic electric for VRF terminal unit
     700              :         Real64 ParasiticOffElec = 0.0;                     // parasitic electric for VRF terminal unit when off
     701              :         Real64 HeatingSpeedRatio = 1.0;                    // Fan speed ratio in heating mode
     702              :         Real64 NoHeatingSpeedRatio = 0.0;                  // Fan speed ratio when no heating
     703              :         Real64 HeatingCapacitySizeRatio = 1.0;             // Ratio of heating to cooling when autosizing
     704              :         Real64 CoolingSpeedRatio = 1.0;                    // Fan speed ratio in cooling mode
     705              :         Real64 NoCoolingSpeedRatio = 1.0;                  // Fan speed ratio when no cooling
     706              :         Real64 ParasiticCoolElecPower = 0.0;               // Terminal unit cooling parasitic electric power [W]
     707              :         Real64 ParasiticHeatElecPower = 0.0;               // Terminal unit heating parasitic electric power [W]
     708              :         Real64 ParasiticElecCoolConsumption = 0.0;         // Terminal unit parasitic electric consumption in cooling [J]
     709              :         Real64 ParasiticElecHeatConsumption = 0.0;         // Terminal unit parasitic electric consumption in heating [J]
     710              :         bool CoolingCoilPresent = true;                    // FALSE if coil not present
     711              :         bool HeatingCoilPresent = true;                    // FALSE if coil not present
     712              :         bool SuppHeatingCoilPresent = false;               // FALSE if coil not present
     713              :         std::string AvailManagerListName;                  // Name of an availability manager list object
     714              :         Avail::Status availStatus = Avail::Status::NoAction;
     715              :         Real64 TerminalUnitSensibleRate = 0.0;                  // sensible cooling/heating rate of VRF terminal unit (W)
     716              :         Real64 TerminalUnitLatentRate = 0.0;                    // latent dehumidification/humidification rate of VRF terminal unit (W)
     717              :         Real64 TotalCoolingRate = 0.0;                          // report variable for total cooling rate (W)
     718              :         Real64 TotalHeatingRate = 0.0;                          // report variable for total heating rate (W)
     719              :         Real64 SensibleCoolingRate = 0.0;                       // report variable for sensible cooling rate (W)
     720              :         Real64 SensibleHeatingRate = 0.0;                       // report variable for sensible heating rate (W)
     721              :         Real64 LatentCoolingRate = 0.0;                         // report variable for latent cooling rate (W)
     722              :         Real64 LatentHeatingRate = 0.0;                         // report variable for latent heating rate (W)
     723              :         Real64 TotalCoolingEnergy = 0.0;                        // report variable for total cooling energy (J)
     724              :         Real64 TotalHeatingEnergy = 0.0;                        // report variable for total heating energy (J)
     725              :         Real64 SensibleCoolingEnergy = 0.0;                     // report variable for sensible cooling energy (J)
     726              :         Real64 SensibleHeatingEnergy = 0.0;                     // report variable for sensible heating energy (J)
     727              :         Real64 LatentCoolingEnergy = 0.0;                       // report variable for latent cooling energy (J)
     728              :         Real64 LatentHeatingEnergy = 0.0;                       // report variable for latent heating energy (J)
     729              :         bool EMSOverridePartLoadFrac = false;                   // User defined EMS function
     730              :         Real64 EMSValueForPartLoadFrac = 0.0;                   // user defined value for EMS function
     731              :         int IterLimitExceeded = 0;                              // index used for warning messages
     732              :         int FirstIterfailed = 0;                                // index used for warning messages
     733              :         int HVACSizingIndex = 0;                                // index of a HVACSizing object for a VRF terminal
     734              :         bool ATMixerExists = false;                             // True if there is an ATMixer
     735              :         std::string ATMixerName;                                // name of air terminal mixer
     736              :         int ATMixerIndex = 0;                                   // index to the air terminal mixer
     737              :         HVAC::MixerType ATMixerType = HVAC::MixerType::Invalid; // 1 = inlet side mixer, 2 = supply side mixer
     738              :         int ATMixerPriNode = 0;                                 // primary inlet air node number for the air terminal mixer
     739              :         int ATMixerSecNode = 0;                                 // secondary air inlet node number for the air terminal mixer
     740              :         int ATMixerOutNode = 0;                                 // outlet air node number for the air terminal mixer
     741              :         int SuppHeatCoilAirInletNode = 0;                       // supplemental heating coil air inlet node
     742              :         int SuppHeatCoilAirOutletNode = 0;                      // supplemental heating coil air outlet node
     743              :         int SuppHeatCoilFluidInletNode = 0;                     // supplemental heating coil fluid inlet node
     744              :         int SuppHeatCoilFluidOutletNode = 0;                    // supplemental heating coil fluid outlet node
     745              :         bool firstPass = true;                                  // used to reset global sizing data
     746              :         PlantLocation SuppHeatCoilPlantLoc{};                   // supplemental heating coil plant component index
     747              :         Real64 coilInNodeT = 0.0;                               // coil inlet node temp at full flow (C)
     748              :         Real64 coilInNodeW = 0.0;                               // coil inlet node humidity ratio at full flow (kg/kg)
     749              :         int fanInletNode = 0;                                   // fan inlet node index
     750              :         int fanOutletNode = 0;                                  // fan outlet node index
     751              :         bool MySuppCoilPlantScanFlag = true;                    // flag used to initialize plant comp for water and steam heating coils
     752              :         int airLoopNum = 0;                                     // index to air loop
     753              :         bool isInOASys = false;                                 // true if TU is configured in outside air system
     754              :         bool isInAirLoop = false;                               // true if TU is configured in an air loop
     755              :         bool isInZone = false;                                  // true if TU is configured as zone equipment
     756              :         bool isSetPointControlled = false;                      // TU is controlled via setpoint instead of the standard load control
     757              :         bool coolSPActive = false;                              // set point controlled cooling coil active (needs to operate)
     758              :         bool heatSPActive = false;                              // set point controlled heating coil active (needs to operate)
     759              :         Real64 coolLoadToSP = 0.0;                              // load to set point in cooling mode
     760              :         Real64 heatLoadToSP = 0.0;                              // load to set point in heating mode
     761              :         Real64 coilTempSetPoint = 0.0;                          // coil control temperature
     762              :         Real64 suppTempSetPoint = 0.0;                          // supplemental heating coil control temperature
     763              :         Real64 controlZoneMassFlowFrac = 1.0;                   // ratio of control zone air mass flow rate to total zone air mass flow rate
     764              :         int zoneSequenceCoolingNum = 0;                         // zone equipment cooling sequence
     765              :         int zoneSequenceHeatingNum = 0;                         // zone equipment heating sequence
     766              :         int coolCoilAirInNode = 0;                              // cooling coil air inlet node number
     767              :         int coolCoilAirOutNode = 0;                             // cooling coil air outlet node number
     768              :         int heatCoilAirInNode = 0;                              // heating coil air inlet node number
     769              :         int heatCoilAirOutNode = 0;                             // heating coil air outlet node number
     770              :         std::string DesignSpecMultispeedHPType;                 // Multiuple performance object type
     771              :         std::string DesignSpecMultispeedHPName;                 // Multiuple performance object name
     772              :         int DesignSpecMSHPIndex = -1;                           //  Multiuple performance index
     773              :         int NumOfSpeedHeating = 0;                              // Number of heating speed
     774              :         int NumOfSpeedCooling = 0;                              // Number of cooling speed
     775              :         int HeatSpeedNum = 0;                                   // Heating speed number
     776              :         int CoolSpeedNum = 0;                                   // Cooling speed number
     777              :         std::vector<Real64> CoolVolumeFlowRate;
     778              :         std::vector<Real64> CoolMassFlowRate;
     779              :         std::vector<Real64> HeatVolumeFlowRate;
     780              :         std::vector<Real64> HeatMassFlowRate;
     781              :         int SpeedNum = 0;
     782              :         Real64 SpeedRatio = 0.0;
     783              :         Real64 CycRatio = 0.0;
     784              : 
     785              :         // Methods for New VRF Model: Fluid Temperature Control
     786              :         //******************************************************************************
     787              :         // Note: the argument VRFTUNum should be removed later in the deeper OO re-factor. Now this argument may be used by other functions that are
     788              :         // not member functions of this class.
     789              : 
     790              :         void CalcVRFIUVariableTeTc(EnergyPlusData &state,
     791              :                                    Real64 &EvapTemp, // evaporating temperature
     792              :                                    Real64 &CondTemp  // condensing temperature
     793              :         );
     794              : 
     795              :         void ControlVRF_FluidTCtrl(EnergyPlusData &state,
     796              :                                    int VRFTUNum,              // Index to VRF terminal unit
     797              :                                    Real64 QZnReq,             // Index to zone number
     798              :                                    bool FirstHVACIteration,   // flag for 1st HVAC iteration in the time step
     799              :                                    Real64 &PartLoadRatio,     // unit part load ratio
     800              :                                    Real64 &OnOffAirFlowRatio, // ratio of compressor ON airflow to AVERAGE airflow over timestep
     801              :                                    Real64 &SuppHeatCoilLoad   // supplemental heating coil load (W)
     802              :         );
     803              : 
     804              :         void CalcVRF_FluidTCtrl(EnergyPlusData &state,
     805              :                                 int VRFTUNum,                                     // Index to VRF terminal unit
     806              :                                 bool FirstHVACIteration,                          // flag for 1st HVAC iteration in the time step
     807              :                                 Real64 PartLoadRatio,                             // compressor part load fraction
     808              :                                 Real64 &LoadMet,                                  // load met by unit (W)
     809              :                                 Real64 &OnOffAirFlowRatio,                        // ratio of ON air flow to average air flow
     810              :                                 Real64 &SuppHeatCoilLoad,                         // supplemental heating coil load (W)
     811              :                                 ObjexxFCL::Optional<Real64> LatOutputProvided = _ // delivered latent capacity (W)
     812              :         );
     813              : 
     814              :         Real64 CalVRFTUAirFlowRate_FluidTCtrl(EnergyPlusData &state,
     815              :                                               int VRFTUNum,                            // Index to VRF terminal unit
     816              :                                               Real64 PartLoadRatio,                    // part load ratio of the coil
     817              :                                               bool FirstHVACIteration,                 // FirstHVACIteration flag
     818              :                                               ObjexxFCL::Optional<Real64 const> MaxCap // maximum allowed heating capacity
     819              :         );
     820              : 
     821              :         // Methods for cruve based VRF Model
     822              :         //******************************************************************************
     823              :         void ControlVRF(EnergyPlusData &state,
     824              :                         int VRFTUNum,              // Index to VRF terminal unit
     825              :                         Real64 QZnReq,             // Index to zone number
     826              :                         bool FirstHVACIteration,   // flag for 1st HVAC iteration in the time step
     827              :                         Real64 &PartLoadRatio,     // unit part load ratio
     828              :                         Real64 &OnOffAirFlowRatio, // ratio of compressor ON airflow to AVERAGE airflow over timestep
     829              :                         Real64 &SuppHeatCoilLoad   // supplemental heating coil load (W)
     830              :         );
     831              : 
     832              :         void ControlVRFToLoad(EnergyPlusData &state,
     833              :                               int const VRFTUNum,            // Index to VRF terminal unit
     834              :                               Real64 const QZnReq,           // Index to zone number
     835              :                               bool const FirstHVACIteration, // flag for 1st HVAC iteration in the time step
     836              :                               Real64 &PartLoadRatio,         // unit part load ratio
     837              :                               Real64 &OnOffAirFlowRatio,     // ratio of compressor ON airflow to AVERAGE airflow over timestep
     838              :                               Real64 &SuppHeatCoilLoad       // supplemental heating coil load (W)
     839              :         );
     840              : 
     841              :         void CalcVRF(EnergyPlusData &state,
     842              :                      int const VRFTUNum,                               // Unit index in VRF terminal unit array
     843              :                      bool const FirstHVACIteration,                    // flag for 1st HVAC iteration in the time step
     844              :                      Real64 const PartLoadRatio,                       // compressor part load fraction
     845              :                      Real64 &LoadMet,                                  // load met by unit (W)
     846              :                      Real64 &OnOffAirFlowRatio,                        // ratio of ON air flow to average air flow
     847              :                      Real64 &SuppHeatCoilLoad,                         // supplemental heating coil load (W)
     848              :                      ObjexxFCL::Optional<Real64> LatOutputProvided = _ // delivered latent capacity (W)
     849              :         );
     850              : 
     851              :         // Methods for curve based and refrigerant flow control based models
     852              :         //******************************************************************************
     853              :         void CalcVRFSuppHeatingCoil(EnergyPlusData &state,
     854              :                                     int VRFTUNum,            // index of vrf terminal unit
     855              :                                     bool FirstHVACIteration, // True when first HVAC iteration
     856              :                                     Real64 PartLoadRatio,    // coil operating part-load ratio
     857              :                                     Real64 &SuppCoilLoad     // adjusted supp coil load when outlet temp exceeds max (W)
     858              :         );
     859              : 
     860              :         static Real64 HotWaterHeatingCoilResidual(EnergyPlusData &state,
     861              :                                                   Real64 PartLoadFrac,           // water heating coil part-load ratio
     862              :                                                   std::vector<Real64> const &Par // par(1) = VRF TU Numberindex to current VRF terminal unit
     863              :         );
     864              : 
     865              :         static Real64
     866              :         HeatingCoilCapacityLimit(EnergyPlusData &state,
     867              :                                  Real64 const HeatCoilAirInletNode, // supplemental heating coil air inlet node
     868              :                                  Real64 const HeatCoilMaxSATAllowed // supplemental heating coil maximum supply air temperature allowed [C]
     869              :         );
     870              :     };
     871              : 
     872              :     struct VRFTUNumericFieldData
     873              :     {
     874              :         // Members
     875              :         Array1D_string FieldNames;
     876              : 
     877              :         // Default Constructor
     878           35 :         VRFTUNumericFieldData() = default;
     879              :     };
     880              : 
     881              :     // Functions
     882              : 
     883              :     void SimulateVRF(EnergyPlusData &state,
     884              :                      std::string_view CompName,
     885              :                      bool const FirstHVACIteration,
     886              :                      int const ZoneNum,
     887              :                      int &CompIndex,
     888              :                      bool &HeatingActive,
     889              :                      bool &CoolingActive,
     890              :                      int const OAUnitNum,         // If the system is an equipment of OutdoorAirUnit
     891              :                      Real64 const OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit
     892              :                      bool const ZoneEquipment,    // TRUE if called as zone equipment
     893              :                      Real64 &SysOutputProvided,
     894              :                      Real64 &LatOutputProvided);
     895              : 
     896              :     void CalcVRFCondenser(EnergyPlusData &state, int VRFCond);
     897              : 
     898              :     void GetVRFInput(EnergyPlusData &state);
     899              : 
     900              :     void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound // flag for errors in GetInput
     901              :     );
     902              : 
     903              :     void CheckVRFTUNodeConnections(EnergyPlusData &state, int const VRFTUNum, bool &ErrorsFound);
     904              : 
     905              :     void InitVRF(EnergyPlusData &state, int VRFTUNum, int ZoneNum, bool FirstHVACIteration, Real64 &OnOffAirFlowRatio, Real64 &QZnReq);
     906              : 
     907              :     void SetCompFlowRate(EnergyPlusData &state, int VRFTUNum, int VRFCond, bool const UseCurrentMode = false);
     908              : 
     909              :     void SizeVRF(EnergyPlusData &state, int const VRFTUNum);
     910              : 
     911              :     void initCapSizingVars(EnergyPlusData &state,
     912              :                            int sizingMethod,
     913              :                            int capSizingMethod,
     914              :                            int &eqSizingMethod,
     915              :                            Real64 scaledCapacity,
     916              :                            bool &modeCapacity,
     917              :                            Real64 &designLoad,
     918              :                            bool &scalableCapSizingOn,
     919              :                            Real64 &fracOfAutosizedCapacity);
     920              : 
     921              :     void SimVRF(EnergyPlusData &state,
     922              :                 int VRFTUNum,
     923              :                 bool FirstHVACIteration,
     924              :                 Real64 &OnOffAirFlowRatio,
     925              :                 Real64 &SysOutputProvided,
     926              :                 Real64 &LatOutputProvided,
     927              :                 Real64 QZnReq);
     928              : 
     929              :     int GetVRFTUOutAirNode(EnergyPlusData &state, int VRFTUNum);
     930              : 
     931              :     int GetVRFTUZoneInletAirNode(EnergyPlusData &state, int VRFTUNum);
     932              : 
     933              :     int GetVRFTUMixedAirNode(EnergyPlusData &state, int VRFTUNum);
     934              : 
     935              :     int GetVRFTUOutAirNodeFromName(EnergyPlusData &state, std::string const &VRFTUName, bool &errorsFound);
     936              : 
     937              :     int GetVRFTUInAirNodeFromName(EnergyPlusData &state, std::string const &VRFTUName, bool &errorsFound);
     938              : 
     939              :     int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum);
     940              : 
     941              :     void getVRFTUZoneLoad(
     942              :         EnergyPlusData &state, int const VRFTUNum, Real64 &zoneLoad, Real64 &LoadToHeatingSP, Real64 &LoadToCoolingSP, bool const InitFlag);
     943              : 
     944              :     bool getVRFTUNodeNumber(EnergyPlusData &state, int const nodeNumber);
     945              : 
     946              :     void ReportVRFTerminalUnit(EnergyPlusData &state, int VRFTUNum); // index to VRF terminal unit
     947              : 
     948              :     void ReportVRFCondenser(EnergyPlusData &state, int VRFCond); // index to VRF condensing unit
     949              : 
     950              :     void UpdateVRFCondenser(EnergyPlusData &state, int VRFCond); // index to VRF condensing unit
     951              : 
     952              :     void isVRFCoilPresent(EnergyPlusData &state, std::string_view VRFTUName, bool &CoolCoilPresent, bool &HeatCoilPresent);
     953              : 
     954              :     void SetAverageAirFlow(EnergyPlusData &state,
     955              :                            int VRFTUNum,             // Unit index
     956              :                            Real64 PartLoadRatio,     // unit part load ratio
     957              :                            Real64 &OnOffAirFlowRatio // ratio of compressor ON airflow to average airflow over timestep
     958              :     );
     959              : 
     960              :     void InitializeOperatingMode(EnergyPlusData &state,
     961              :                                  bool FirstHVACIteration,  // flag for first time through HVAC systems
     962              :                                  int VRFCond,              // Condenser Unit index
     963              :                                  int TUListNum,            // Condenser Unit terminal unit list
     964              :                                  Real64 &OnOffAirFlowRatio // ratio of on to off flow rate
     965              :     );
     966              : 
     967              :     void LimitTUCapacity(EnergyPlusData &state,
     968              :                          int VRFCond,                     // Condenser Unit index
     969              :                          int NumTUInList,                 // Number of terminal units in list
     970              :                          Real64 StartingCapacity,         // temporary variable holding condenser capacity [W]
     971              :                          const Array1D<Real64> &CapArray, // Array of coil capacities in either cooling or heating mode [W]
     972              :                          Real64 &MaxLimit,                // Maximum terminal unit capacity for coils in same operating mode [W]
     973              :                          Real64 AltCapacity,              // temporary variable holding heat recovery capacity [W]
     974              :                          const Array1D<Real64> &AltArray, // Array of coil capacities of heat recovery [W]
     975              :                          Real64 &AltLimit                 // Maximum terminal unit capacity of heat recovery coils [W]
     976              :     );
     977              : 
     978              :     void LimitCoilCapacity(int NumTUInList,                 // Number of terminal units in list
     979              :                            Real64 TotalCapacity,            // temporary variable holding condenser capacity [W]
     980              :                            const Array1D<Real64> &CapArray, // Array of coil capacities in either cooling or heating mode [W]
     981              :                            Real64 &MaxLimit                 // Maximum terminal unit capacity for coils in same operating mode [W]
     982              :     );
     983              : 
     984              :     Real64 CompResidual_FluidTCtrl(EnergyPlusData &state,
     985              :                                    Real64 T_dis,
     986              :                                    Real64 CondHeat,
     987              :                                    int CAPFT,
     988              :                                    Real64 const T_suc // Compressor suction temperature Te' [C]
     989              :     );
     990              : 
     991              :     int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName);
     992              : 
     993              : } // namespace HVACVariableRefrigerantFlow
     994              : 
     995              : struct HVACVarRefFlowData : BaseGlobalStruct
     996              : {
     997              : 
     998              :     bool GetVRFInputFlag = true;             // Flag set to make sure you get input once
     999              :     bool MyOneTimeFlag = true;               // One time flag used to allocate MyEnvrnFlag and MySizeFlag
    1000              :     bool MyOneTimeSizeFlag = true;           // One time flag used to allocate MyEnvrnFlag and MySizeFlag
    1001              :     bool ZoneEquipmentListNotChecked = true; // False after the Zone Equipment List has been checked for items
    1002              :     int NumVRFCond = 0;                      // total number of VRF condensers (All VRF Algorithm Types)
    1003              :     int NumVRFCond_SysCurve = 0;             // total number of VRF condensers with VRF Algorithm Type 1
    1004              :     int NumVRFCond_FluidTCtrl_HP = 0;        // total number of VRF condensers with VRF Algorithm Type 2 (HP)
    1005              :     int NumVRFCond_FluidTCtrl_HR = 0;        // total number of VRF condensers with VRF Algorithm Type 2 (HR)
    1006              :     int NumVRFTU = 0;                        // total number of VRF terminal units
    1007              :     int NumVRFTULists = 0;                   // The number of VRF TU lists
    1008              :     Real64 CompOnMassFlow = 0.0;             // Supply air mass flow rate w/ compressor ON
    1009              :     Real64 OACompOnMassFlow = 0.0;           // OA mass flow rate w/ compressor ON
    1010              :     Real64 CompOffMassFlow = 0.0;            // Supply air mass flow rate w/ compressor OFF
    1011              :     Real64 OACompOffMassFlow = 0.0;          // OA mass flow rate w/ compressor OFF
    1012              :     Real64 CompOnFlowRatio = 0.0;            // fan flow ratio when coil on
    1013              :     Real64 CompOffFlowRatio = 0.0;           // fan flow ratio when coil off
    1014              :     Real64 FanSpeedRatio = 0.0;              // ratio of air flow ratio passed to fan object
    1015              :     Real64 LoopDXCoolCoilRTF = 0.0;          // holds value of DX cooling coil RTF
    1016              :     Real64 LoopDXHeatCoilRTF = 0.0;          // holds value of DX heating coil RTF
    1017              :     Real64 CondenserWaterMassFlowRate = 0.0; // VRF water-cooled condenser mass flow rate (kg/s)
    1018              :     Real64 CurrentEndTimeLast = 0.0;         // end time of last time step
    1019              :     Array1D_bool HeatingLoad;                // defines a heating load on VRFTerminalUnits
    1020              :     Array1D_bool CoolingLoad;                // defines a cooling load on VRFTerminalUnits
    1021              :     Array1D_bool LastModeHeating;            // defines last mode was heating mode
    1022              :     Array1D_bool LastModeCooling;            // defines last mode was cooling mode
    1023              :     Array1D_bool CheckEquipName;             // Flag set to check equipment connections once
    1024              :     Array1D_bool MyEnvrnFlag;                // Flag for initializing at beginning of each new environment
    1025              :     Array1D_bool MySizeFlag;                 // False after TU has been sized
    1026              :     Array1D_bool MyBeginTimeStepFlag;        // Flag to sense beginning of time step
    1027              :     Array1D_bool MyVRFFlag;                  // used for sizing VRF inputs one time
    1028              :     Array1D_bool MyVRFCondFlag;              // used to reset timer counter
    1029              :     Array1D_bool MyZoneEqFlag;               // used to set up zone equipment availability managers
    1030              :     Array1D_int NumCoolingLoads;             // number of TU's requesting cooling
    1031              :     Array1D_int NumHeatingLoads;             // number of TU's requesting heating
    1032              :     Array1D<Real64> MaxCoolingCapacity;      // maximum capacity of any terminal unit
    1033              :     Array1D<Real64> MaxHeatingCapacity;      // maximum capacity of any terminal unit
    1034              :     Array1D<Real64> CoolCombinationRatio;    // ratio of terminal unit capacity to VRF condenser capacity
    1035              :     Array1D<Real64> HeatCombinationRatio;    // ratio of terminal unit capacity to VRF condenser capacity
    1036              :     Array1D<Real64> MaxDeltaT;               // maximum zone temperature difference from setpoint
    1037              :     Array1D<Real64> MinDeltaT;               // minimum zone temperature difference from setpoint
    1038              :     Array1D<Real64> SumCoolingLoads;         // sum of cooling loads
    1039              :     Array1D<Real64> SumHeatingLoads;         // sum of heating loads
    1040              :     Array1D_bool CheckVRFCombinationRatio;
    1041              :     bool MyOneTimeEIOFlag = true; // eio header flag reporting
    1042              :     int ATMixOutNode = 0;         // terminal unit mixer outlet node
    1043              :     int ATMixOutNode2 = 0;        // terminal unit mixer outlet node
    1044              : 
    1045              :     // Object Data
    1046              :     EPVector<HVACVariableRefrigerantFlow::VRFCondenserEquipment> VRF; // AirConditioner:VariableRefrigerantFlow object
    1047              :     std::unordered_map<std::string, std::string> VrfUniqueNames;
    1048              :     EPVector<HVACVariableRefrigerantFlow::VRFTerminalUnitEquipment> VRFTU;           // ZoneHVAC:TerminalUnit:VariableRefrigerantFlow object
    1049              :     EPVector<HVACVariableRefrigerantFlow::TerminalUnitListData> TerminalUnitList;    // zoneTerminalUnitList object
    1050              :     EPVector<HVACVariableRefrigerantFlow::VRFTUNumericFieldData> VRFTUNumericFields; // holds VRF TU numeric input fields character field name
    1051              : 
    1052         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
    1053              :     {
    1054         2126 :     }
    1055              : 
    1056         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
    1057              :     {
    1058         1152 :     }
    1059              : 
    1060         2100 :     void clear_state() override
    1061              :     {
    1062         2100 :         this->GetVRFInputFlag = true;
    1063         2100 :         this->MyOneTimeFlag = true;
    1064         2100 :         this->MyOneTimeSizeFlag = true;
    1065         2100 :         this->ZoneEquipmentListNotChecked = true;
    1066         2100 :         this->NumVRFCond = 0;
    1067         2100 :         this->NumVRFCond_SysCurve = 0;
    1068         2100 :         this->NumVRFCond_FluidTCtrl_HP = 0;
    1069         2100 :         this->NumVRFCond_FluidTCtrl_HR = 0;
    1070         2100 :         this->NumVRFTU = 0;
    1071         2100 :         this->NumVRFTULists = 0;
    1072         2100 :         this->CompOnMassFlow = 0.0;
    1073         2100 :         this->OACompOnMassFlow = 0.0;
    1074         2100 :         this->CompOffMassFlow = 0.0;
    1075         2100 :         this->OACompOffMassFlow = 0.0;
    1076         2100 :         this->CompOnFlowRatio = 0.0;
    1077         2100 :         this->CompOffFlowRatio = 0.0;
    1078         2100 :         this->FanSpeedRatio = 0.0;
    1079         2100 :         this->LoopDXCoolCoilRTF = 0.0;
    1080         2100 :         this->LoopDXHeatCoilRTF = 0.0;
    1081         2100 :         this->CondenserWaterMassFlowRate = 0.0;
    1082         2100 :         this->CurrentEndTimeLast = 0.0;
    1083         2100 :         this->HeatingLoad.deallocate();
    1084         2100 :         this->CoolingLoad.deallocate();
    1085         2100 :         this->LastModeHeating.deallocate();
    1086         2100 :         this->LastModeCooling.deallocate();
    1087         2100 :         this->CheckEquipName.deallocate();
    1088         2100 :         this->MyEnvrnFlag.deallocate();
    1089         2100 :         this->MySizeFlag.deallocate();
    1090         2100 :         this->MyBeginTimeStepFlag.deallocate();
    1091         2100 :         this->MyVRFFlag.deallocate();
    1092         2100 :         this->MyVRFCondFlag.deallocate();
    1093         2100 :         this->MyZoneEqFlag.deallocate();
    1094         2100 :         this->NumCoolingLoads.deallocate();
    1095         2100 :         this->NumHeatingLoads.deallocate();
    1096         2100 :         this->MaxCoolingCapacity.deallocate();
    1097         2100 :         this->MaxHeatingCapacity.deallocate();
    1098         2100 :         this->CoolCombinationRatio.deallocate();
    1099         2100 :         this->HeatCombinationRatio.deallocate();
    1100         2100 :         this->MaxDeltaT.deallocate();
    1101         2100 :         this->MinDeltaT.deallocate();
    1102         2100 :         this->SumCoolingLoads.deallocate();
    1103         2100 :         this->SumHeatingLoads.deallocate();
    1104         2100 :         this->VRF.deallocate();
    1105         2100 :         this->VrfUniqueNames.clear();
    1106         2100 :         this->VRFTU.deallocate();
    1107         2100 :         this->TerminalUnitList.deallocate();
    1108         2100 :         this->VRFTUNumericFields.deallocate();
    1109         2100 :         this->CheckVRFCombinationRatio.clear();
    1110         2100 :         this->MyOneTimeEIOFlag = true;
    1111         2100 :         this->ATMixOutNode = 0;
    1112         2100 :         this->ATMixOutNode2 = 0;
    1113         2100 :     }
    1114              : };
    1115              : 
    1116              : } // namespace EnergyPlus
    1117              : 
    1118              : #endif
        

Generated by: LCOV version 2.0-1