LCOV - code coverage report
Current view: top level - EnergyPlus - HVACVariableRefrigerantFlow.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 4949 8170 60.6 %
Date: 2023-01-17 19:17:23 Functions: 53 66 80.3 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <cassert>
      50             : #include <cmath>
      51             : #include <string>
      52             : 
      53             : // ObjexxFCL Headers
      54             : #include <ObjexxFCL/Array.functions.hh>
      55             : #include <ObjexxFCL/Fmath.hh>
      56             : 
      57             : // EnergyPlus Headers
      58             : #include <EnergyPlus/Autosizing/All_Simple_Sizing.hh>
      59             : #include <EnergyPlus/Autosizing/CoolingAirFlowSizing.hh>
      60             : #include <EnergyPlus/Autosizing/CoolingCapacitySizing.hh>
      61             : #include <EnergyPlus/Autosizing/HeatingAirFlowSizing.hh>
      62             : #include <EnergyPlus/Autosizing/HeatingCapacitySizing.hh>
      63             : #include <EnergyPlus/Autosizing/SystemAirFlowSizing.hh>
      64             : #include <EnergyPlus/Autosizing/WaterHeatingCapacitySizing.hh>
      65             : #include <EnergyPlus/BranchNodeConnections.hh>
      66             : #include <EnergyPlus/CurveManager.hh>
      67             : #include <EnergyPlus/DXCoils.hh>
      68             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      69             : #include <EnergyPlus/DataAirSystems.hh>
      70             : #include <EnergyPlus/DataDefineEquip.hh>
      71             : #include <EnergyPlus/DataGlobalConstants.hh>
      72             : #include <EnergyPlus/DataHVACGlobals.hh>
      73             : #include <EnergyPlus/DataHeatBalFanSys.hh>
      74             : #include <EnergyPlus/DataHeatBalance.hh>
      75             : #include <EnergyPlus/DataIPShortCuts.hh>
      76             : #include <EnergyPlus/DataLoopNode.hh>
      77             : #include <EnergyPlus/DataSizing.hh>
      78             : #include <EnergyPlus/DataZoneControls.hh>
      79             : #include <EnergyPlus/DataZoneEnergyDemands.hh>
      80             : #include <EnergyPlus/DataZoneEquipment.hh>
      81             : #include <EnergyPlus/EMSManager.hh>
      82             : #include <EnergyPlus/Fans.hh>
      83             : #include <EnergyPlus/FluidProperties.hh>
      84             : #include <EnergyPlus/General.hh>
      85             : #include <EnergyPlus/GeneralRoutines.hh>
      86             : #include <EnergyPlus/GlobalNames.hh>
      87             : #include <EnergyPlus/HVACFan.hh>
      88             : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
      89             : #include <EnergyPlus/HeatingCoils.hh>
      90             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      91             : #include <EnergyPlus/MixedAir.hh>
      92             : #include <EnergyPlus/NodeInputManager.hh>
      93             : #include <EnergyPlus/OutAirNodeManager.hh>
      94             : #include <EnergyPlus/OutputProcessor.hh>
      95             : #include <EnergyPlus/Plant/DataPlant.hh>
      96             : #include <EnergyPlus/Plant/PlantLocation.hh>
      97             : #include <EnergyPlus/PlantUtilities.hh>
      98             : #include <EnergyPlus/Psychrometrics.hh>
      99             : #include <EnergyPlus/ScheduleManager.hh>
     100             : #include <EnergyPlus/SteamCoils.hh>
     101             : #include <EnergyPlus/UtilityRoutines.hh>
     102             : #include <EnergyPlus/WaterCoils.hh>
     103             : #include <EnergyPlus/WaterManager.hh>
     104             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     105             : 
     106             : namespace EnergyPlus::HVACVariableRefrigerantFlow {
     107             : // Module containing the Variable Refrigerant Flow (VRF or VRV) simulation routines
     108             : 
     109             : // MODULE INFORMATION:
     110             : //       AUTHOR         Richard Raustad, FSEC
     111             : //       DATE WRITTEN   August 2010
     112             : //       MODIFIED       Apr 2012, R. Raustad, FSEC, Added Heat Recovery Operating Mode
     113             : //                      Jul 2015, RP Zhang, XF Pang, LBNL, Added a new physics based VRF model applicable for Fluid Temperature Control
     114             : //       RE-ENGINEERED  na
     115             : 
     116             : // PURPOSE OF THIS MODULE:
     117             : // To encapsulate the data and algorithms required to
     118             : // manage the VRF System Component
     119             : 
     120             : using namespace DataZoneEnergyDemands;
     121             : using namespace Psychrometrics;
     122             : using namespace DataPlant;
     123             : 
     124      231306 : void SimulateVRF(EnergyPlusData &state,
     125             :                  std::string_view CompName,
     126             :                  bool const FirstHVACIteration,
     127             :                  int const ZoneNum,
     128             :                  int &CompIndex,
     129             :                  bool &HeatingActive,
     130             :                  bool &CoolingActive,
     131             :                  int const OAUnitNum,         // If the system is an equipment of OutdoorAirUnit
     132             :                  Real64 const OAUCoilOutTemp, // the coil inlet temperature of OutdoorAirUnit
     133             :                  bool const ZoneEquipment,    // TRUE if called as zone equipment
     134             :                  Real64 &SysOutputProvided,
     135             :                  Real64 &LatOutputProvided)
     136             : {
     137             : 
     138             :     // SUBROUTINE INFORMATION:
     139             :     // AUTHOR         Richard Raustad, FSEC
     140             :     // DATE WRITTEN   August 2010
     141             :     // MODIFIED       Jul 2015, RP Zhang (LBNL), XF Pang (LBNL), Y Yura (Daikin Inc). Add a physics-based VRF model applicable for Fluid
     142             :     // Temperature Control RE-ENGINEERED  na
     143             : 
     144             :     // PURPOSE OF THIS SUBROUTINE:
     145             :     // This subroutine manages VRF terminal unit simulation.
     146             : 
     147             :     // METHODOLOGY EMPLOYED:
     148             :     // Simulate all terminal units
     149             :     // Once all terminal units have been simulated, simulate VRF condenser
     150             : 
     151             :     int VRFTUNum;             // current VRF system terminal unit index
     152             :     int VRFCondenser;         // index to VRF AC system object - AirConditioner:VariableRefrigerantFlow
     153             :     int TUListNum;            // index to VRF AC system terminal unit list
     154             :     int IndexToTUInTUList;    // index to pointer in VRF AC system terminal unit list
     155             :     Real64 OnOffAirFlowRatio; // ratio of compressor ON airflow to average airflow over timestep
     156             :     int DXCoolingCoilIndex;   // index to this terminal units DX cooling coil
     157             :     int DXHeatingCoilIndex;   // index to this terminal units DX heating coil
     158             :     Real64 QZnReq;
     159             : 
     160             :     // Obtains and Allocates VRF system related parameters from input file
     161      231306 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) { // First time subroutine has been entered
     162          10 :         GetVRFInput(state);
     163          10 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
     164             :     }
     165             : 
     166             :     // CompIndex accounting
     167      231306 :     if (CompIndex == 0) {
     168          56 :         VRFTUNum = UtilityRoutines::FindItemInList(CompName, state.dataHVACVarRefFlow->VRFTU);
     169          56 :         if (VRFTUNum == 0) {
     170           0 :             ShowFatalError(state, "SimulateVRF: VRF Terminal Unit not found=" + std::string{CompName});
     171             :         }
     172          56 :         CompIndex = VRFTUNum;
     173             : 
     174             :         // suppress unused warnings temporarily until VRF inherits HVACSystemData
     175          56 :         if (OAUnitNum > 0) {
     176           0 :             bool tmpFlag = false;
     177           0 :             if (OAUCoilOutTemp > 0.0) tmpFlag = true;
     178           0 :             if (ZoneEquipment) tmpFlag = true;
     179             :         }
     180             : 
     181             :     } else {
     182      231250 :         VRFTUNum = CompIndex;
     183      231250 :         if (VRFTUNum > state.dataHVACVarRefFlow->NumVRFTU || VRFTUNum < 1) {
     184           0 :             ShowFatalError(state,
     185           0 :                            format("SimulateVRF: Invalid CompIndex passed={}, Number of VRF Terminal Units = {}, VRF Terminal Unit name = {}",
     186             :                                   VRFTUNum,
     187           0 :                                   state.dataHVACVarRefFlow->NumVRFTU,
     188           0 :                                   CompName));
     189             :         }
     190      231250 :         if (state.dataHVACVarRefFlow->CheckEquipName(VRFTUNum)) {
     191          56 :             if (!CompName.empty() && CompName != state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name) {
     192           0 :                 ShowFatalError(state,
     193           0 :                                format("SimulateVRF: Invalid CompIndex passed={}, VRF Terminal Unit name={}, stored VRF TU Name for that index={}",
     194             :                                       VRFTUNum,
     195             :                                       CompName,
     196           0 :                                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name));
     197             :             }
     198          56 :             state.dataHVACVarRefFlow->CheckEquipName(VRFTUNum) = false;
     199             :         }
     200             :     }
     201             : 
     202             :     // the VRF condenser index
     203      231306 :     VRFCondenser = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
     204             : 
     205      246390 :     if ((state.dataHVACVarRefFlow->VRF(VRFCondenser).CondenserType == DataHeatBalance::RefrigCondenserType::Water) &&
     206       15084 :         (state.dataHVACVarRefFlow->VRF(VRFCondenser).checkPlantCondTypeOneTime)) {
     207             :         // scan for loop connection data
     208           1 :         bool errFlag = false;
     209           5 :         PlantUtilities::ScanPlantLoopsForObject(state,
     210           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFCondenser).Name,
     211           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFCondenser).VRFType,
     212           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFCondenser).SourcePlantLoc,
     213             :                                                 errFlag,
     214             :                                                 _,
     215             :                                                 _,
     216             :                                                 _,
     217           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFCondenser).CondenserNodeNum,
     218             :                                                 _);
     219             : 
     220           1 :         if (errFlag) {
     221           0 :             ShowSevereError(state, "GetVRFInput: Error scanning for plant loop data");
     222             :         }
     223             : 
     224           1 :         state.dataHVACVarRefFlow->VRF(VRFCondenser).checkPlantCondTypeOneTime = false;
     225             :     }
     226             : 
     227             :     // the terminal unit list object index
     228      231306 :     TUListNum = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex;
     229             :     // the entry number in the terminal unit list (which item in the terminal unit list, e.g. second in list)
     230      231306 :     IndexToTUInTUList = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList;
     231             :     // index to cooling coil (coil is optional but at least one must be present)
     232      231306 :     DXCoolingCoilIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex;
     233             :     // index to heating coil (coil is optional but at least one must be present)
     234      231306 :     DXHeatingCoilIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex;
     235      231306 :     QZnReq = 0.0;
     236             : 
     237             :     // Initialize terminal unit
     238      231306 :     InitVRF(state, VRFTUNum, ZoneNum, FirstHVACIteration, OnOffAirFlowRatio, QZnReq); // Initialize all VRFTU related parameters
     239             : 
     240             :     // Simulate terminal unit
     241      231306 :     SimVRF(state, VRFTUNum, FirstHVACIteration, OnOffAirFlowRatio, SysOutputProvided, LatOutputProvided, QZnReq);
     242             : 
     243             :     // mark this terminal unit as simulated
     244      231306 :     state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).IsSimulated(IndexToTUInTUList) = true;
     245             : 
     246             :     // keep track of individual coil loads
     247      231306 :     if (DXCoolingCoilIndex > 0) {
     248      231306 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(IndexToTUInTUList) =
     249      231306 :             state.dataDXCoils->DXCoilTotalCooling(DXCoolingCoilIndex);
     250             :     } else {
     251           0 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(IndexToTUInTUList) = 0.0;
     252             :     }
     253      231306 :     if (DXHeatingCoilIndex > 0) {
     254      231306 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(IndexToTUInTUList) =
     255      231306 :             state.dataDXCoils->DXCoilTotalHeating(DXHeatingCoilIndex);
     256             :     } else {
     257           0 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(IndexToTUInTUList) = 0.0;
     258             :     }
     259             : 
     260             :     // Report the current VRF terminal unit
     261      231306 :     ReportVRFTerminalUnit(state, VRFTUNum);
     262             : 
     263      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalCoolingRate > 0.0) CoolingActive = true;
     264      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalHeatingRate > 0.0) HeatingActive = true;
     265             : 
     266             :     // make sure all TU in a list are able to get simulated, otherwise condenser is never simulated **
     267             :     // either fatal on GetInput, or keep track of unused TU's and set their respective flag to TRUE **
     268             :     // after all VRF terminal units have been simulated, call the VRF condenser model
     269      231306 :     if (all(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).IsSimulated)) {
     270             : 
     271       49389 :         if (state.dataHVACVarRefFlow->VRF(VRFCondenser).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
     272             :             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
     273       11709 :             state.dataHVACVarRefFlow->VRF(VRFCondenser).CalcVRFCondenser_FluidTCtrl(state);
     274             :         } else {
     275             :             // Algorithm Type: VRF model based on system curve
     276       37680 :             CalcVRFCondenser(state, VRFCondenser);
     277             :         }
     278             : 
     279       49389 :         ReportVRFCondenser(state, VRFCondenser);
     280             : 
     281       49389 :         if (state.dataHVACVarRefFlow->VRF(VRFCondenser).CondenserType == DataHeatBalance::RefrigCondenserType::Water)
     282        3771 :             UpdateVRFCondenser(state, VRFCondenser);
     283             :     }
     284      231306 : }
     285             : 
     286           1 : PlantComponent *VRFCondenserEquipment::factory(EnergyPlusData &state, std::string const &objectName)
     287             : {
     288             :     // Process the input data if it hasn't been done already
     289           1 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
     290           1 :         GetVRFInput(state);
     291           1 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
     292             :     }
     293             :     // Now look for this object in the list
     294           1 :     for (auto &obj : state.dataHVACVarRefFlow->VRF) {
     295           1 :         if (obj.Name == objectName) {
     296           1 :             return &obj;
     297             :         }
     298             :     }
     299             :     // If we didn't find it, fatal
     300             :     ShowFatalError(state, "LocalVRFCondenserFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE
     301             :     // Shut up the compiler
     302             :     return nullptr; // LCOV_EXCL_LINE
     303             : }
     304             : 
     305           5 : void VRFCondenserEquipment::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
     306             : {
     307           5 :     this->SizeVRFCondenser(state);
     308           5 : }
     309             : 
     310           5 : void VRFCondenserEquipment::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     311             :                                                 [[maybe_unused]] const PlantLocation &calledFromLocation,
     312             :                                                 Real64 &MaxLoad,
     313             :                                                 Real64 &MinLoad,
     314             :                                                 Real64 &OptLoad)
     315             : {
     316           5 :     MinLoad = 0.0;
     317           5 :     MaxLoad = max(this->CoolingCapacity, this->HeatingCapacity); // greater of cooling and heating capacity
     318           5 :     OptLoad = max(this->CoolingCapacity,
     319             :                   this->HeatingCapacity); // connects to single loop, need to switch between cooling/heating capacity?
     320           5 : }
     321             : 
     322       15061 : void VRFCondenserEquipment::simulate(EnergyPlusData &state,
     323             :                                      const PlantLocation &calledFromLocation,
     324             :                                      bool FirstHVACIteration,
     325             :                                      [[maybe_unused]] Real64 &CurLoad,
     326             :                                      [[maybe_unused]] bool RunFlag)
     327             : {
     328       15061 :     if (calledFromLocation.loopNum == this->SourcePlantLoc.loopNum) { // condenser loop
     329       15061 :         PlantUtilities::UpdateChillerComponentCondenserSide(state,
     330             :                                                             this->SourcePlantLoc.loopNum,
     331             :                                                             this->SourcePlantLoc.loopSideNum,
     332             :                                                             PlantEquipmentType::HeatPumpVRF,
     333             :                                                             this->CondenserNodeNum,
     334             :                                                             this->CondenserOutletNodeNum,
     335             :                                                             this->QCondenser,
     336             :                                                             this->CondenserInletTemp,
     337             :                                                             this->CondenserSideOutletTemp,
     338             :                                                             this->WaterCondenserMassFlow,
     339             :                                                             FirstHVACIteration);
     340             :     } else {
     341           0 :         ShowFatalError(state, "SimVRFCondenserPlant:: Invalid loop connection " + std::string(cVRFTypes(VRF_HeatPump)));
     342             :     }
     343       15061 : }
     344             : 
     345       37680 : void CalcVRFCondenser(EnergyPlusData &state, int const VRFCond)
     346             : {
     347             : 
     348             :     // SUBROUTINE INFORMATION:
     349             :     //       AUTHOR         R. Raustad, FSEC
     350             :     //       DATE WRITTEN   September 2010
     351             : 
     352             :     // PURPOSE OF THIS SUBROUTINE:
     353             :     // Model the interactions of VRF terminal units with a single variable-speed condenser.
     354             :     // The terminal units are simulated first, and then the condenser is simulated.
     355             :     // If terminal units require more capacity than can be delivered by condenser, a limit is set.
     356             : 
     357             :     using Curve::CurveValue;
     358             :     using FluidProperties::GetSpecificHeatGlycol;
     359             :     using PlantUtilities::SetComponentFlowRate;
     360             :     using Psychrometrics::RhoH2O;
     361             : 
     362             :     static constexpr std::string_view RoutineName("VRFCondenser");
     363             : 
     364             :     int NumTU;         // loop counter
     365             :     int TUIndex;       // Index to terminal unit
     366             :     int CoolCoilIndex; // index to cooling coil in terminal unit
     367             :     int HeatCoilIndex; // index to heating coil in terminal unit
     368             : 
     369             :     Real64 TotCoolCapTempModFac;      // cooling CAPFT curve output
     370             :     Real64 TotHeatCapTempModFac;      // heating CAPFT curve output
     371             :     Real64 TotCoolEIRTempModFac;      // cooling EIRFT curve output
     372             :     Real64 TotHeatEIRTempModFac;      // heating EIRFT curve output
     373             :     Real64 InletAirWetBulbC;          // coil inlet air wet-bulb temperature (C)
     374             :     Real64 InletAirDryBulbC;          // coil inlet air dry-bulb temperature (C)
     375       37680 :     Real64 CondInletTemp(0.0);        // condenser inlet air temperature (C)
     376             :     Real64 CondInletHumRat;           // condenser inlet air humidity ratio (kg/kg)
     377             :     Real64 OutdoorDryBulb;            // outdoor dry-bulb temperature (C)
     378             :     Real64 OutdoorHumRat;             // outdoor humidity ratio (kg/kg)
     379             :     Real64 OutdoorPressure;           // outdoor pressure (Pa)
     380             :     Real64 OutdoorWetBulb;            // outdoor wet-bulb temperature (C)
     381             :     Real64 CoolOABoundary;            // output of cooling boundary curve (outdoor temperature, C)
     382             :     Real64 HeatOABoundary;            // output of heating boundary curve (outdoor temperature, C)
     383             :     Real64 EIRFPLRModFac;             // EIRFPLR curve output
     384             :     int Stage;                        // used for crankcase heater power calculation
     385             :     Real64 UpperStageCompressorRatio; // used for crankcase heater power calculation
     386             :     Real64 RhoAir;                    // Density of air [kg/m3]
     387             :     Real64 RhoWater;                  // Density of water [kg/m3]
     388             :     Real64 CpCond;                    // Specific Heat of water [J/kg-k]
     389             :     Real64 CondAirMassFlow;           // Condenser air mass flow rate [kg/s]
     390             :     Real64 CondWaterMassFlow;         // Condenser water mass flow rate [kg/s]
     391             :     Real64 PartLoadFraction;          // Part load fraction from PLFFPLR curve
     392             :     Real64 VRFRTF;                    // VRF runtime fraction when cycling below MINPLR
     393             :     Real64 OutdoorCoilT;              // Outdoor coil temperature (C)
     394             :     Real64 OutdoorCoildw;             // Outdoor coil delta w assuming coil temp of OutdoorCoilT (kg/kg)
     395             :     Real64 FractionalDefrostTime;     // Fraction of time step system is in defrost
     396             :     Real64 HeatingCapacityMultiplier; // Multiplier for heating capacity when system is in defrost
     397             :     Real64 InputPowerMultiplier;      // Multiplier for power when system is in defrost
     398             :     Real64 LoadDueToDefrost;          // Additional load due to defrost
     399             :     Real64 DefrostEIRTempModFac;      // EIR modifier for defrost (function of entering drybulb, outside wetbulb)
     400             :     int HRCAPFT;                      // index to heat recovery CAPFTCool curve
     401             :     Real64 HRCAPFTConst;              // stead-state capacity fraction
     402             :     Real64 HRInitialCapFrac;          // Fractional cooling degradation at the start of heat recovery from cooling mode
     403             :     Real64 HRCapTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
     404             :     int HREIRFT;                      // Index to cool EIR as a function of temperature curve for heat recovery
     405             :     Real64 HREIRFTConst;              // stead-state EIR fraction
     406             :     Real64 HRInitialEIRFrac;          // Fractional cooling degradation at the start of heat recovery from cooling mode
     407             :     Real64 HREIRTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
     408             :     Real64 CurrentEndTime;            // end time of current time step
     409             :     Real64 SUMultiplier;              // multiplier for simulating mode changes
     410             :     Real64 CondPower;                 // condenser power [W]
     411             :     Real64 CondCapacity;              // condenser heat rejection [W]
     412             :     Real64 CondOutletTemp;            // Outlet temperature from VRF condenser [C]
     413             :     Real64 TotPower;                  // total condenser power use [W]
     414             :     bool HRHeatRequestFlag;           // flag indicating VRF TU could operate in heating mode
     415             :     bool HRCoolRequestFlag;           // flag indicating VRF TU could operate in cooling mode
     416             : 
     417       37680 :     auto &vrf = state.dataHVACVarRefFlow->VRF(VRFCond);
     418             : 
     419             :     // variable initializations
     420       37680 :     int TUListNum = vrf.ZoneTUListPtr;
     421       37680 :     int NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
     422       37680 :     int NumTUInCoolingMode = 0;            // number of terminal units actually cooling
     423       37680 :     int NumTUInHeatingMode = 0;            // number of terminal units actually heating
     424       37680 :     Real64 TUCoolingLoad = 0.0;            // sum of TU's cooling coil load {W}
     425       37680 :     Real64 TUHeatingLoad = 0.0;            // sum of TU's heating coil load (W)
     426       37680 :     Real64 TUParasiticPower = 0.0;         // total terminal unit parasitic power (W)
     427       37680 :     Real64 TUFanPower = 0.0;               // total terminal unit fan power (W)
     428       37680 :     Real64 CoolingPLR = 0.0;               // condenser cooling PLR
     429       37680 :     Real64 HeatingPLR = 0.0;               // condenser heating PLR
     430       37680 :     Real64 CyclingRatio = 1.0;             // cycling ratio of condenser's compressors
     431       37680 :     Real64 SumCoolInletWB = 0.0;           // sum of active TU's DX cooling coil inlet air wet-bulb temperature
     432       37680 :     Real64 SumHeatInletDB = 0.0;           // sum of active TU's DX heating coil inlet air dry-bulb temperature
     433       37680 :     Real64 SumHeatInletWB = 0.0;           // sum of active TU's DX heating coil inlet air wet-bulb temperature
     434       37680 :     Real64 TotalCondCoolingCapacity = 0.0; // total available condenser cooling capacity (W)
     435       37680 :     Real64 TotalCondHeatingCapacity = 0.0; // total available condenser heating capacity (W)
     436       37680 :     Real64 TotalTUCoolingCapacity = 0.0;   // sum of TU's cooling capacity including piping losses (W)
     437       37680 :     Real64 TotalTUHeatingCapacity = 0.0;   // sum of TU's heating capacity including piping losses (W)
     438             : 
     439       37680 :     vrf.ElecCoolingPower = 0.0;
     440       37680 :     vrf.ElecHeatingPower = 0.0;
     441       37680 :     vrf.CrankCaseHeaterPower = 0.0;
     442       37680 :     vrf.EvapCondPumpElecPower = 0.0;
     443       37680 :     vrf.EvapWaterConsumpRate = 0.0;
     444       37680 :     vrf.DefrostPower = 0.0;
     445       37680 :     vrf.OperatingCoolingCOP = 0.0;
     446       37680 :     vrf.OperatingHeatingCOP = 0.0;
     447       37680 :     vrf.OperatingCOP = 0.0;
     448       37680 :     vrf.SCHE = 0.0;
     449       37680 :     vrf.BasinHeaterPower = 0.0;
     450       37680 :     vrf.VRFHeatRec = 0.0;
     451             : 
     452             :     // set condenser entering air conditions
     453       37680 :     if (vrf.CondenserNodeNum != 0) {
     454       37680 :         OutdoorDryBulb = state.dataLoopNodes->Node(vrf.CondenserNodeNum).Temp;
     455       37680 :         if (vrf.CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
     456       33909 :             OutdoorHumRat = state.dataLoopNodes->Node(vrf.CondenserNodeNum).HumRat;
     457       33909 :             OutdoorPressure = state.dataLoopNodes->Node(vrf.CondenserNodeNum).Press;
     458       33909 :             OutdoorWetBulb = state.dataLoopNodes->Node(vrf.CondenserNodeNum).OutAirWetBulb;
     459             :         } else {
     460        3771 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
     461        3771 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
     462        3771 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
     463             :         }
     464             :     } else {
     465           0 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
     466           0 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
     467           0 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
     468           0 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
     469             :     }
     470             : 
     471       37680 :     if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
     472       33909 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp
     473        3771 :     } else if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
     474           0 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
     475           0 :         CondAirMassFlow = RhoAir * vrf.EvapCondAirVolFlowRate;
     476             :         // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
     477           0 :         CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - vrf.EvapCondEffectiveness);
     478           0 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
     479        3771 :     } else if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
     480        3771 :         CondInletTemp = OutdoorDryBulb; // node inlet temp from above
     481        3771 :         OutdoorWetBulb = CondInletTemp; // for watercooled
     482        3771 :         CondWaterMassFlow = vrf.WaterCondenserDesignMassFlow;
     483             :     } else {
     484           0 :         assert(false);
     485             :     }
     486       37680 :     vrf.CondenserInletTemp = CondInletTemp;
     487             : 
     488             :     // sum loads on TU coils
     489      210409 :     for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
     490      172729 :         TUCoolingLoad += state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU);
     491      172729 :         TUHeatingLoad += state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU);
     492             :     }
     493             : 
     494       37680 :     vrf.TUCoolingLoad = TUCoolingLoad;
     495       37680 :     vrf.TUHeatingLoad = TUHeatingLoad;
     496             : 
     497             :     // no need to do anything else if the terminal units are off
     498       37680 :     if (TUCoolingLoad == 0.0 && TUHeatingLoad == 0.0) {
     499        6664 :         vrf.SUMultiplier = 0.0;
     500        6664 :         vrf.VRFCondPLR = 0.0;
     501        6664 :         vrf.VRFCondRTF = 0.0;
     502        6664 :         vrf.VRFCondCyclingRatio = 0.0;
     503        6664 :         vrf.QCondenser = 0.0;
     504        6664 :         vrf.TotalCoolingCapacity = 0.0;
     505        6664 :         vrf.TotalHeatingCapacity = 0.0;
     506        6664 :         vrf.OperatingMode = 0.0;
     507        6664 :         vrf.HRHeatingActive = false;
     508        6664 :         vrf.HRCoolingActive = false;
     509       19992 :         state.dataHVACVarRefFlow->CurrentEndTimeLast = double((state.dataGlobal->DayOfSim - 1) * 24) + state.dataGlobal->CurrentTime -
     510       13328 :                                                        state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed;
     511        6664 :         if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
     512         487 :             state.dataHVACVarRefFlow->CondenserWaterMassFlowRate = 0.0;
     513         974 :             SetComponentFlowRate(
     514         487 :                 state, state.dataHVACVarRefFlow->CondenserWaterMassFlowRate, vrf.CondenserNodeNum, vrf.CondenserOutletNodeNum, vrf.SourcePlantLoc);
     515         487 :             vrf.WaterCondenserMassFlow = state.dataHVACVarRefFlow->CondenserWaterMassFlowRate;
     516         487 :             vrf.CondenserSideOutletTemp = CondInletTemp;
     517             :         }
     518        6664 :         return;
     519             :     }
     520             : 
     521             :     // switch modes if summed coil capacity shows opposite operating mode
     522             :     // if total TU heating exceeds total TU cooling * ( 1 + 1/COP) then system is in heating mode
     523       31016 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && TUHeatingLoad > (TUCoolingLoad * (1.0 + 1.0 / vrf.CoolingCOP))) {
     524           0 :         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
     525           0 :         state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
     526           0 :         vrf.ModeChange = true;
     527           0 :         if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
     528           0 :             state.dataHVACVarRefFlow->LastModeHeating(VRFCond) = true;
     529             :             // reset heat recovery startup timer
     530           0 :             vrf.HRTimer = 0.0;
     531           0 :             vrf.HRHeatingActive = false;
     532           0 :             vrf.HRCoolingActive = false;
     533             :         }
     534       31016 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && (TUCoolingLoad * (1.0 + 1.0 / vrf.CoolingCOP)) > TUHeatingLoad) {
     535           0 :         state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
     536           0 :         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
     537           0 :         vrf.ModeChange = true;
     538           0 :         if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
     539           0 :             state.dataHVACVarRefFlow->LastModeCooling(VRFCond) = true;
     540             :             // reset heat recovery startup timer
     541           0 :             vrf.HRTimer = 0.0;
     542           0 :             vrf.HRHeatingActive = false;
     543           0 :             vrf.HRCoolingActive = false;
     544             :         }
     545       31016 :     } else if (TUCoolingLoad > 0.0 && TUHeatingLoad > 0.0 &&
     546           0 :                ((state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) ||
     547           0 :                 (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && state.dataHVACVarRefFlow->LastModeCooling(VRFCond)))) {
     548           0 :         vrf.ModeChange = true;
     549             :         // reset heat recovery startup timer
     550           0 :         vrf.HRTimer = 0.0;
     551           0 :         vrf.HRHeatingActive = false;
     552           0 :         vrf.HRCoolingActive = false;
     553             :     }
     554             : 
     555             :     // loop through TU's and calculate average inlet conditions for active coils
     556      173464 :     for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
     557      142448 :         TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
     558      142448 :         CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
     559      142448 :         HeatCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex;
     560      142448 :         TUParasiticPower +=
     561      142448 :             state.dataHVACVarRefFlow->VRFTU(TUIndex).ParasiticCoolElecPower + state.dataHVACVarRefFlow->VRFTU(TUIndex).ParasiticHeatElecPower;
     562      142448 :         TUFanPower += state.dataHVACVarRefFlow->VRFTU(TUIndex).FanPower;
     563             : 
     564      142448 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0.0) {
     565      218388 :             SumCoolInletWB += state.dataDXCoils->DXCoilCoolInletAirWBTemp(CoolCoilIndex) *
     566      145592 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) / TUCoolingLoad;
     567       72796 :             ++NumTUInCoolingMode;
     568             :         }
     569      142448 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) > 0.0) {
     570      184164 :             SumHeatInletDB += state.dataDXCoils->DXCoilHeatInletAirDBTemp(HeatCoilIndex) *
     571      122776 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / TUHeatingLoad;
     572      184164 :             SumHeatInletWB += state.dataDXCoils->DXCoilHeatInletAirWBTemp(HeatCoilIndex) *
     573      122776 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / TUHeatingLoad;
     574       61388 :             ++NumTUInHeatingMode;
     575             :         }
     576             :     }
     577             : 
     578       31016 :     bool CoolingCoilAvailableFlag = any(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailable);
     579       31016 :     bool HeatingCoilAvailableFlag = any(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailable);
     580             : 
     581             :     // calculate capacities and energy use
     582       31016 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && CoolingCoilAvailableFlag) {
     583       17211 :         InletAirWetBulbC = SumCoolInletWB;
     584       17211 :         TotCoolCapTempModFac = CurveValue(state, vrf.CoolCapFT, InletAirWetBulbC, CondInletTemp);
     585       17211 :         TotCoolEIRTempModFac = CurveValue(state, vrf.CoolEIRFT, InletAirWetBulbC, CondInletTemp);
     586             : 
     587             :         // recalculate cooling Cap and EIR curve output if using boundary curve along with dual Cap and EIR curves.
     588       17211 :         if (vrf.CoolBoundaryCurvePtr > 0) {
     589       17211 :             CoolOABoundary = CurveValue(state, vrf.CoolBoundaryCurvePtr, InletAirWetBulbC);
     590       17211 :             if (OutdoorDryBulb > CoolOABoundary) {
     591       17211 :                 if (vrf.CoolCapFTHi > 0) TotCoolCapTempModFac = CurveValue(state, vrf.CoolCapFTHi, InletAirWetBulbC, CondInletTemp);
     592             :             }
     593             :         }
     594       17211 :         if (vrf.EIRCoolBoundaryCurvePtr > 0) {
     595       17211 :             CoolOABoundary = CurveValue(state, vrf.EIRCoolBoundaryCurvePtr, InletAirWetBulbC);
     596       17211 :             if (OutdoorDryBulb > CoolOABoundary) {
     597       17211 :                 if (vrf.CoolEIRFTHi > 0) TotCoolEIRTempModFac = CurveValue(state, vrf.CoolEIRFTHi, InletAirWetBulbC, CondInletTemp);
     598             :             }
     599             :         }
     600             : 
     601             :         //   Warn user if curve output goes negative
     602       17211 :         if (TotCoolCapTempModFac < 0.0) {
     603           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInCoolingMode > 0) {
     604           0 :                 if (vrf.CoolCapFTErrorIndex == 0) {
     605           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     606           0 :                     ShowContinueError(
     607             :                         state,
     608           0 :                         format(" Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotCoolCapTempModFac));
     609           0 :                     ShowContinueError(state,
     610           0 :                                       format(" Negative value occurs using an outdoor air temperature of {:.1T} C and an average indoor air "
     611             :                                              "wet-bulb temperature of {:.1T} C.",
     612             :                                              CondInletTemp,
     613           0 :                                              InletAirWetBulbC));
     614           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     615             :                 }
     616           0 :                 ShowRecurringWarningErrorAtEnd(
     617             :                     state,
     618           0 :                     format("{} \"{}\": Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
     619           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     620           0 :                            vrf.Name),
     621             :                     vrf.CoolCapFTErrorIndex,
     622             :                     TotCoolCapTempModFac,
     623             :                     TotCoolCapTempModFac);
     624           0 :                 TotCoolCapTempModFac = 0.0;
     625             :             }
     626             :         }
     627             : 
     628             :         //   Warn user if curve output goes negative
     629       17211 :         if (TotCoolEIRTempModFac < 0.0) {
     630           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInCoolingMode > 0) {
     631           0 :                 if (vrf.EIRFTempCoolErrorIndex == 0) {
     632           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     633           0 :                     ShowContinueError(state,
     634           0 :                                       format(" Cooling Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).",
     635           0 :                                              TotCoolEIRTempModFac));
     636           0 :                     ShowContinueError(state,
     637           0 :                                       format(" Negative value occurs using an outdoor air temperature of {:.1T} C and an average indoor air "
     638             :                                              "wet-bulb temperature of {:.1T} C.",
     639             :                                              CondInletTemp,
     640           0 :                                              InletAirWetBulbC));
     641           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     642             :                 }
     643           0 :                 ShowRecurringWarningErrorAtEnd(
     644             :                     state,
     645           0 :                     format("{} \"{}\": Cooling Energy Input Ratio Modifier curve (function of temperature) output is negative warning continues...",
     646           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     647           0 :                            vrf.Name),
     648             :                     vrf.EIRFTempCoolErrorIndex,
     649             :                     TotCoolEIRTempModFac,
     650             :                     TotCoolEIRTempModFac);
     651           0 :                 TotCoolEIRTempModFac = 0.0;
     652             :             }
     653             :         }
     654             : 
     655       17211 :         TotalCondCoolingCapacity = vrf.CoolingCapacity * state.dataHVACVarRefFlow->CoolCombinationRatio(VRFCond) * TotCoolCapTempModFac;
     656       17211 :         TotalTUCoolingCapacity = TotalCondCoolingCapacity * vrf.PipingCorrectionCooling;
     657             : 
     658       17211 :         if (TotalCondCoolingCapacity > 0.0) {
     659       17211 :             CoolingPLR = (TUCoolingLoad / vrf.PipingCorrectionCooling) / TotalCondCoolingCapacity;
     660             :         } else {
     661           0 :             CoolingPLR = 0.0;
     662             :         }
     663             : 
     664             :         //   Warn user if curve output goes negative
     665       17211 :         if (TotCoolCapTempModFac < 0.0) {
     666           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInCoolingMode > 0) {
     667           0 :                 if (vrf.CoolCapFTErrorIndex == 0) {
     668           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     669           0 :                     ShowContinueError(
     670             :                         state,
     671           0 :                         format(" Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotCoolCapTempModFac));
     672           0 :                     ShowContinueError(state,
     673           0 :                                       format(" Negative value occurs using an outdoor air temperature of {:.1T} C and an average indoor air "
     674             :                                              "wet-bulb temperature of {:.1T} C.",
     675             :                                              CondInletTemp,
     676           0 :                                              InletAirWetBulbC));
     677           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     678             :                 }
     679           0 :                 ShowRecurringWarningErrorAtEnd(
     680             :                     state,
     681           0 :                     format("{} \"{}\": Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
     682           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     683           0 :                            vrf.Name),
     684             :                     vrf.CoolCapFTErrorIndex,
     685             :                     TotCoolCapTempModFac,
     686             :                     TotCoolCapTempModFac);
     687           0 :                 TotCoolCapTempModFac = 0.0;
     688             :             }
     689             :         }
     690             :         //   Warn user if curve output goes negative
     691       17211 :         if (TotCoolEIRTempModFac < 0.0) {
     692           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInCoolingMode > 0) {
     693           0 :                 if (vrf.EIRFTempCoolErrorIndex == 0) {
     694           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     695           0 :                     ShowContinueError(state,
     696           0 :                                       format(" Cooling Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).",
     697           0 :                                              TotCoolEIRTempModFac));
     698           0 :                     ShowContinueError(state,
     699           0 :                                       format(" Negative value occurs using an outdoor air temperature of {:.1T} C and an average indoor air "
     700             :                                              "wet-bulb temperature of {:.1T} C.",
     701             :                                              CondInletTemp,
     702           0 :                                              InletAirWetBulbC));
     703           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     704             :                 }
     705           0 :                 ShowRecurringWarningErrorAtEnd(
     706             :                     state,
     707           0 :                     format("{} \"{}\": Cooling Energy Input Ratio Modifier curve (function of temperature) output is negative warning continues...",
     708           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     709           0 :                            vrf.Name),
     710             :                     vrf.EIRFTempCoolErrorIndex,
     711             :                     TotCoolEIRTempModFac,
     712             :                     TotCoolEIRTempModFac);
     713           0 :                 TotCoolEIRTempModFac = 0.0;
     714             :             }
     715             :         }
     716             : 
     717       13805 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && HeatingCoilAvailableFlag) {
     718       13801 :         InletAirDryBulbC = SumHeatInletDB;
     719       13801 :         InletAirWetBulbC = SumHeatInletWB;
     720       13801 :         switch (vrf.HeatingPerformanceOATType) {
     721        1455 :         case DataHVACGlobals::DryBulbIndicator: {
     722        1455 :             TotHeatCapTempModFac = CurveValue(state, vrf.HeatCapFT, InletAirDryBulbC, CondInletTemp);
     723        1455 :             TotHeatEIRTempModFac = CurveValue(state, vrf.HeatEIRFT, InletAirDryBulbC, CondInletTemp);
     724        1455 :         } break;
     725       12346 :         case DataHVACGlobals::WetBulbIndicator: {
     726       12346 :             TotHeatCapTempModFac = CurveValue(state, vrf.HeatCapFT, InletAirDryBulbC, OutdoorWetBulb);
     727       12346 :             TotHeatEIRTempModFac = CurveValue(state, vrf.HeatEIRFT, InletAirDryBulbC, OutdoorWetBulb);
     728       12346 :         } break;
     729           0 :         default: {
     730           0 :             TotHeatCapTempModFac = 1.0;
     731           0 :             TotHeatEIRTempModFac = 1.0;
     732           0 :         } break;
     733             :         }
     734             :         // recalculate heating Cap and EIR curve output if using boundary curve along with dual Cap and EIR curves.
     735       13801 :         if (vrf.HeatBoundaryCurvePtr > 0) {
     736       13801 :             HeatOABoundary = CurveValue(state, vrf.HeatBoundaryCurvePtr, InletAirDryBulbC);
     737       13801 :             switch (vrf.HeatingPerformanceOATType) {
     738        1455 :             case DataHVACGlobals::DryBulbIndicator: {
     739        1455 :                 if (OutdoorDryBulb > HeatOABoundary) {
     740        1455 :                     if (vrf.HeatCapFTHi > 0) TotHeatCapTempModFac = CurveValue(state, vrf.HeatCapFTHi, InletAirDryBulbC, CondInletTemp);
     741             :                 }
     742        1455 :             } break;
     743       12346 :             case DataHVACGlobals::WetBulbIndicator: {
     744       12346 :                 if (OutdoorWetBulb > HeatOABoundary) {
     745        1330 :                     if (vrf.HeatCapFTHi > 0) TotHeatCapTempModFac = CurveValue(state, vrf.HeatCapFTHi, InletAirDryBulbC, OutdoorWetBulb);
     746             :                 }
     747       12346 :             } break;
     748           0 :             default: {
     749           0 :                 TotHeatCapTempModFac = 1.0;
     750           0 :             } break;
     751             :             }
     752             :         }
     753       13801 :         if (vrf.EIRHeatBoundaryCurvePtr > 0) {
     754       13801 :             HeatOABoundary = CurveValue(state, vrf.EIRHeatBoundaryCurvePtr, InletAirDryBulbC);
     755       13801 :             switch (vrf.HeatingPerformanceOATType) {
     756        1455 :             case DataHVACGlobals::DryBulbIndicator: {
     757        1455 :                 if (OutdoorDryBulb > HeatOABoundary) {
     758        1455 :                     if (vrf.HeatEIRFTHi > 0) TotHeatEIRTempModFac = CurveValue(state, vrf.HeatEIRFTHi, InletAirDryBulbC, CondInletTemp);
     759             :                 }
     760        1455 :             } break;
     761       12346 :             case DataHVACGlobals::WetBulbIndicator: {
     762       12346 :                 if (OutdoorWetBulb > HeatOABoundary) {
     763        1330 :                     if (vrf.HeatEIRFTHi > 0) TotHeatEIRTempModFac = CurveValue(state, vrf.HeatEIRFTHi, InletAirDryBulbC, OutdoorWetBulb);
     764             :                 }
     765       12346 :             } break;
     766           0 :             default: {
     767           0 :                 TotHeatEIRTempModFac = 1.0;
     768           0 :             } break;
     769             :             }
     770             :         }
     771             : 
     772             :         //   Warn user if curve output goes negative
     773       13801 :         if (TotHeatCapTempModFac < 0.0) {
     774           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInHeatingMode > 0) {
     775           0 :                 if (vrf.HeatCapFTErrorIndex == 0) {
     776           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     777           0 :                     ShowContinueError(
     778             :                         state,
     779           0 :                         format(" Heating Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotHeatCapTempModFac));
     780             : 
     781           0 :                     switch (vrf.HeatingPerformanceOATType) {
     782           0 :                     case DataHVACGlobals::DryBulbIndicator: {
     783           0 :                         ShowContinueError(state,
     784           0 :                                           format(" Negative value occurs using an outdoor air temperature of {:.1T} C and an average indoor air "
     785             :                                                  "dry-bulb temperature of {:.1T} C.",
     786             :                                                  CondInletTemp,
     787           0 :                                                  InletAirDryBulbC));
     788           0 :                     } break;
     789           0 :                     case DataHVACGlobals::WetBulbIndicator: {
     790           0 :                         ShowContinueError(state,
     791           0 :                                           format(" Negative value occurs using an outdoor air wet-bulb temperature of {:.1T} C and an average "
     792             :                                                  "indoor air wet-bulb temperature of {:.1T} C.",
     793             :                                                  OutdoorWetBulb,
     794           0 :                                                  InletAirWetBulbC));
     795           0 :                     } break;
     796           0 :                     default:
     797             :                         // should never get here
     798           0 :                         break;
     799             :                     }
     800             : 
     801           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     802             :                 }
     803           0 :                 ShowRecurringWarningErrorAtEnd(
     804             :                     state,
     805           0 :                     format("{} \"{}\": Heating Capacity Ratio Modifier curve (function of temperature) output is negative warning continues...",
     806           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     807           0 :                            vrf.Name),
     808             :                     vrf.HeatCapFTErrorIndex,
     809             :                     TotHeatCapTempModFac,
     810             :                     TotHeatCapTempModFac);
     811           0 :                 TotHeatCapTempModFac = 0.0;
     812             :             }
     813             :         }
     814             :         //   Warn user if curve output goes negative
     815       13801 :         if (TotHeatEIRTempModFac < 0.0) {
     816           0 :             if (!state.dataGlobal->WarmupFlag && NumTUInHeatingMode > 0) {
     817           0 :                 if (vrf.EIRFTempHeatErrorIndex == 0) {
     818           0 :                     ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     819           0 :                     ShowContinueError(state,
     820           0 :                                       format(" Heating Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).",
     821           0 :                                              TotHeatEIRTempModFac));
     822           0 :                     switch (vrf.HeatingPerformanceOATType) {
     823           0 :                     case DataHVACGlobals::DryBulbIndicator: {
     824           0 :                         ShowContinueError(state,
     825           0 :                                           format(" Negative value occurs using an outdoor air dry-bulb temperature of {:.1T} C and an "
     826             :                                                  "average indoor air dry-bulb temperature of {:.1T} C.",
     827             :                                                  CondInletTemp,
     828           0 :                                                  InletAirDryBulbC));
     829           0 :                     } break;
     830           0 :                     case DataHVACGlobals::WetBulbIndicator: {
     831           0 :                         ShowContinueError(state,
     832           0 :                                           format(" Negative value occurs using an outdoor air wet-bulb temperature of {:.1T} C and an "
     833             :                                                  "average indoor air wet-bulb temperature of {:.1T} C.",
     834             :                                                  OutdoorWetBulb,
     835           0 :                                                  InletAirWetBulbC));
     836           0 :                     } break;
     837           0 :                     default:
     838           0 :                         break;
     839             :                     }
     840           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     841             :                 }
     842           0 :                 ShowRecurringWarningErrorAtEnd(
     843             :                     state,
     844           0 :                     format("{} \"{}\": Heating Energy Input Ratio Modifier curve (function of temperature) output is negative warning continues...",
     845           0 :                            PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     846           0 :                            vrf.Name),
     847             :                     vrf.EIRFTempHeatErrorIndex,
     848             :                     TotHeatEIRTempModFac,
     849             :                     TotHeatEIRTempModFac);
     850           0 :                 TotHeatEIRTempModFac = 0.0;
     851             :             }
     852             :         }
     853             : 
     854             :         // Initializing defrost adjustment factors
     855       13801 :         LoadDueToDefrost = 0.0;
     856       13801 :         HeatingCapacityMultiplier = 1.0;
     857       13801 :         FractionalDefrostTime = 0.0;
     858       13801 :         InputPowerMultiplier = 1.0;
     859             : 
     860             :         // Check outdoor temperature to determine of defrost is active
     861       13801 :         if (OutdoorDryBulb <= vrf.MaxOATDefrost && vrf.CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
     862             : 
     863             :             // Calculating adjustment factors for defrost
     864             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
     865        2891 :             OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
     866        2891 :             OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure)));
     867             : 
     868             :             // Calculate defrost adjustment factors depending on defrost control type
     869        2891 :             if (vrf.DefrostControl == StandardRatings::HPdefrostControl::Timed) {
     870        2891 :                 FractionalDefrostTime = vrf.DefrostFraction;
     871        2891 :                 if (FractionalDefrostTime > 0.0) {
     872        2891 :                     HeatingCapacityMultiplier = 0.909 - 107.33 * OutdoorCoildw;
     873        2891 :                     InputPowerMultiplier = 0.90 - 36.45 * OutdoorCoildw;
     874             :                 }
     875             :             } else { // else defrost control is on-demand
     876           0 :                 FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / OutdoorCoildw);
     877           0 :                 HeatingCapacityMultiplier = 0.875 * (1.0 - FractionalDefrostTime);
     878           0 :                 InputPowerMultiplier = 0.954 * (1.0 - FractionalDefrostTime);
     879             :             }
     880             : 
     881        2891 :             if (FractionalDefrostTime > 0.0) {
     882             :                 // Calculate defrost adjustment factors depending on defrost control strategy
     883        2891 :                 if (vrf.DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
     884           0 :                     LoadDueToDefrost = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) * (vrf.HeatingCapacity / 1.01667);
     885           0 :                     DefrostEIRTempModFac = CurveValue(state, vrf.DefrostEIRPtr, max(15.555, InletAirWetBulbC), max(15.555, OutdoorDryBulb));
     886             : 
     887             :                     //         Warn user if curve output goes negative
     888           0 :                     if (DefrostEIRTempModFac < 0.0) {
     889           0 :                         if (!state.dataGlobal->WarmupFlag) {
     890           0 :                             if (vrf.DefrostHeatErrorIndex == 0) {
     891           0 :                                 ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + vrf.Name + "\":");
     892           0 :                                 ShowContinueError(
     893             :                                     state,
     894           0 :                                     format(" Defrost Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).",
     895           0 :                                            DefrostEIRTempModFac));
     896           0 :                                 ShowContinueError(state,
     897           0 :                                                   format(" Negative value occurs using an outdoor air dry-bulb temperature of {:.1T} C and an "
     898             :                                                          "average indoor air wet-bulb temperature of {:.1T} C.",
     899             :                                                          OutdoorDryBulb,
     900           0 :                                                          InletAirWetBulbC));
     901           0 :                                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
     902             :                             }
     903           0 :                             ShowRecurringWarningErrorAtEnd(state,
     904           0 :                                                            format("{} \"{}\": Defrost Energy Input Ratio Modifier curve (function of temperature) "
     905             :                                                                   "output is negative warning continues...",
     906           0 :                                                                   PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
     907           0 :                                                                   vrf.Name),
     908             :                                                            vrf.DefrostHeatErrorIndex,
     909             :                                                            DefrostEIRTempModFac,
     910             :                                                            DefrostEIRTempModFac);
     911           0 :                             DefrostEIRTempModFac = 0.0;
     912             :                         }
     913             :                     }
     914             : 
     915           0 :                     vrf.DefrostPower = DefrostEIRTempModFac * (vrf.HeatingCapacity / 1.01667) * FractionalDefrostTime;
     916             : 
     917             :                 } else { // Defrost strategy is resistive
     918        2891 :                     vrf.DefrostPower = vrf.DefrostCapacity * FractionalDefrostTime;
     919             :                 }
     920             :             }
     921             :         }
     922             : 
     923       13801 :         TotalCondHeatingCapacity =
     924       13801 :             vrf.HeatingCapacity * state.dataHVACVarRefFlow->HeatCombinationRatio(VRFCond) * TotHeatCapTempModFac * HeatingCapacityMultiplier;
     925       13801 :         TotalTUHeatingCapacity = TotalCondHeatingCapacity * vrf.PipingCorrectionHeating;
     926       13801 :         if (TotalCondHeatingCapacity > 0.0) {
     927       13801 :             HeatingPLR = (TUHeatingLoad / vrf.PipingCorrectionHeating) / TotalCondHeatingCapacity;
     928       13801 :             HeatingPLR += (LoadDueToDefrost * HeatingPLR) / TotalCondHeatingCapacity;
     929             :         } else {
     930           0 :             HeatingPLR = 0.0;
     931             :         }
     932             :     }
     933             : 
     934       31016 :     vrf.VRFCondPLR = max(CoolingPLR, HeatingPLR);
     935       31016 :     Real64 tmpVRFCondPLR = 0.0;
     936       31016 :     if (CoolingPLR > 0.0 || HeatingPLR > 0.0) tmpVRFCondPLR = max(vrf.MinPLR, vrf.VRFCondPLR);
     937             : 
     938       31016 :     HRHeatRequestFlag = any(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HRHeatRequest);
     939       31016 :     HRCoolRequestFlag = any(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HRCoolRequest);
     940       31016 :     HREIRFTConst = 1.0;
     941       31016 :     Real64 HREIRAdjustment = 1.0;
     942             : 
     943       31016 :     if (!state.dataGlobal->DoingSizing && !state.dataGlobal->WarmupFlag) {
     944        4367 :         if (HRHeatRequestFlag && HRCoolRequestFlag) {
     945             :             // determine operating mode change
     946           0 :             if (!vrf.HRCoolingActive && !vrf.HRHeatingActive) {
     947           0 :                 vrf.ModeChange = true;
     948           0 :                 vrf.HRTimer = 0.0;
     949             :             }
     950           0 :             if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
     951           0 :                 if (vrf.HRHeatingActive && !vrf.HRCoolingActive) {
     952           0 :                     vrf.HRModeChange = true;
     953             :                 }
     954           0 :                 vrf.HRCoolingActive = true;
     955           0 :                 vrf.HRHeatingActive = false;
     956           0 :                 HRCAPFT = vrf.HRCAPFTCool; // Index to cool capacity as a function of temperature\PLR curve for heat recovery
     957           0 :                 if (HRCAPFT > 0) {
     958             :                     //         VRF(VRFCond)%HRCAPFTCoolConst = 0.9d0 ! initialized to 0.9
     959           0 :                     if (state.dataCurveManager->PerfCurve(vrf.HRCAPFTCool).numDims == 2) { // Curve type for HRCAPFTCool
     960           0 :                         vrf.HRCAPFTCoolConst = CurveValue(state, HRCAPFT, InletAirWetBulbC, CondInletTemp);
     961             :                     } else {
     962           0 :                         vrf.HRCAPFTCoolConst = CurveValue(state, HRCAPFT, tmpVRFCondPLR);
     963             :                     }
     964             :                 }
     965           0 :                 HRCAPFTConst = vrf.HRCAPFTCoolConst;
     966           0 :                 HRInitialCapFrac = vrf.HRInitialCoolCapFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode
     967           0 :                 HRCapTC = vrf.HRCoolCapTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
     968             : 
     969           0 :                 HREIRFT = vrf.HREIRFTCool; // Index to cool EIR as a function of temperature curve for heat recovery
     970           0 :                 if (HREIRFT > 0) {
     971             :                     //         VRF(VRFCond)%HREIRFTCoolConst = 1.1d0 ! initialized to 1.1
     972           0 :                     if (state.dataCurveManager->PerfCurve(vrf.HREIRFTCool).numDims == 2) { // Curve type for HREIRFTCool
     973           0 :                         vrf.HREIRFTCoolConst = CurveValue(state, HREIRFT, InletAirWetBulbC, CondInletTemp);
     974             :                     } else {
     975           0 :                         vrf.HREIRFTCoolConst = CurveValue(state, HREIRFT, tmpVRFCondPLR);
     976             :                     }
     977             :                 }
     978           0 :                 HREIRFTConst = vrf.HREIRFTCoolConst;
     979           0 :                 HRInitialEIRFrac = vrf.HRInitialCoolEIRFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode
     980           0 :                 HREIRTC = vrf.HRCoolEIRTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
     981           0 :             } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
     982           0 :                 if (!vrf.HRHeatingActive && vrf.HRCoolingActive) {
     983           0 :                     vrf.HRModeChange = true;
     984             :                 }
     985           0 :                 vrf.HRCoolingActive = false;
     986           0 :                 vrf.HRHeatingActive = true;
     987           0 :                 HRCAPFT = vrf.HRCAPFTHeat; // Index to heat capacity as a function of temperature\PLR curve for heat recovery
     988           0 :                 if (HRCAPFT > 0) {
     989             :                     //         VRF(VRFCond)%HRCAPFTHeatConst = 1.1d0 ! initialized to 1.1
     990           0 :                     if (state.dataCurveManager->PerfCurve(vrf.HRCAPFTHeat).numDims == 2) { // Curve type for HRCAPFTCool
     991           0 :                         switch (vrf.HeatingPerformanceOATType) {
     992           0 :                         case DataHVACGlobals::DryBulbIndicator: {
     993           0 :                             vrf.HRCAPFTHeatConst = CurveValue(state, HRCAPFT, InletAirDryBulbC, CondInletTemp);
     994           0 :                         } break;
     995           0 :                         case DataHVACGlobals::WetBulbIndicator: {
     996           0 :                             vrf.HRCAPFTHeatConst = CurveValue(state, HRCAPFT, InletAirDryBulbC, OutdoorWetBulb);
     997           0 :                         } break;
     998           0 :                         default: {
     999           0 :                             vrf.HRCAPFTHeatConst = 1.0;
    1000           0 :                         } break;
    1001             :                         }
    1002             :                     } else {
    1003           0 :                         vrf.HRCAPFTHeatConst = CurveValue(state, HRCAPFT, tmpVRFCondPLR);
    1004             :                     }
    1005             :                 }
    1006           0 :                 HRCAPFTConst = vrf.HRCAPFTHeatConst;
    1007           0 :                 HRInitialCapFrac = vrf.HRInitialHeatCapFrac; // Fractional heating degradation at the start of heat recovery from cooling mode
    1008           0 :                 HRCapTC = vrf.HRHeatCapTC;                   // Time constant used to recover from initial degradation in heating heat recovery
    1009             : 
    1010           0 :                 HREIRFT = vrf.HREIRFTHeat; // Index to cool EIR as a function of temperature curve for heat recovery
    1011           0 :                 if (HREIRFT > 0) {
    1012             :                     //         VRF(VRFCond)%HREIRFTCoolConst = 1.1d0 ! initialized to 1.1
    1013           0 :                     if (state.dataCurveManager->PerfCurve(vrf.HREIRFTHeat).numDims == 2) { // Curve type for HREIRFTHeat
    1014           0 :                         switch (vrf.HeatingPerformanceOATType) {
    1015           0 :                         case DataHVACGlobals::DryBulbIndicator: {
    1016           0 :                             vrf.HREIRFTHeatConst = CurveValue(state, HREIRFT, InletAirDryBulbC, CondInletTemp);
    1017           0 :                         } break;
    1018           0 :                         case DataHVACGlobals::WetBulbIndicator: {
    1019           0 :                             vrf.HREIRFTHeatConst = CurveValue(state, HREIRFT, InletAirDryBulbC, OutdoorWetBulb);
    1020           0 :                         } break;
    1021           0 :                         default: {
    1022           0 :                             vrf.HREIRFTHeatConst = 1.0;
    1023           0 :                         } break;
    1024             :                         }
    1025             :                     } else {
    1026           0 :                         vrf.HREIRFTHeatConst = CurveValue(state, HREIRFT, tmpVRFCondPLR);
    1027             :                     }
    1028             :                 }
    1029           0 :                 HREIRFTConst = vrf.HREIRFTHeatConst;
    1030           0 :                 HRInitialEIRFrac = vrf.HRInitialHeatEIRFrac; // Fractional heating degradation at the start of heat recovery from heating mode
    1031           0 :                 HREIRTC = vrf.HRHeatEIRTC;                   // Time constant used to recover from initial degradation in heating heat recovery
    1032             :             } else {
    1033             :                 //   zone thermostats satisfied, condenser is off. Set values anyway
    1034           0 :                 HRCAPFTConst = 1.0;
    1035           0 :                 HRInitialCapFrac = 1.0;
    1036           0 :                 HRCapTC = 1.0;
    1037           0 :                 HREIRFTConst = 1.0;
    1038           0 :                 HRInitialEIRFrac = 1.0;
    1039           0 :                 HREIRTC = 1.0;
    1040           0 :                 if (vrf.HRHeatingActive || vrf.HRCoolingActive) {
    1041           0 :                     vrf.HRModeChange = true;
    1042             :                 }
    1043           0 :                 vrf.HRCoolingActive = false;
    1044           0 :                 vrf.HRHeatingActive = false;
    1045             :             }
    1046             : 
    1047             :         } else { // IF(HRHeatRequestFlag .AND. HRCoolRequestFlag)THEN -- Heat recovery turned off
    1048        4367 :             HRCAPFTConst = 1.0;
    1049        4367 :             HRInitialCapFrac = 1.0;
    1050        4367 :             HRCapTC = 0.0;
    1051        4367 :             HREIRFTConst = 1.0;
    1052        4367 :             HRInitialEIRFrac = 1.0;
    1053        4367 :             HREIRTC = 0.0;
    1054        4367 :             vrf.HRModeChange = false;
    1055        4367 :             vrf.HRCoolingActive = false;
    1056        4367 :             vrf.HRHeatingActive = false;
    1057        4367 :             vrf.HRTimer = 0.0;
    1058             :         }
    1059             : 
    1060             :         // Calculate the capacity modification factor (SUMultiplier) for the HR mode transition period
    1061        8734 :         CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone +
    1062        4367 :                          state.dataHVACGlobal->SysTimeElapsed;
    1063             : 
    1064        4367 :         if (vrf.ModeChange || vrf.HRModeChange) {
    1065           0 :             if (vrf.HRCoolingActive && vrf.HRTimer == 0.0) {
    1066           0 :                 vrf.HRTimer = state.dataHVACVarRefFlow->CurrentEndTimeLast;
    1067           0 :             } else if (vrf.HRHeatingActive && vrf.HRTimer == 0.0) {
    1068           0 :                 vrf.HRTimer = state.dataHVACVarRefFlow->CurrentEndTimeLast;
    1069           0 :             } else if (!vrf.HRCoolingActive && !vrf.HRHeatingActive) {
    1070           0 :                 vrf.HRTimer = 0.0;
    1071             :             }
    1072             :         }
    1073             : 
    1074        4367 :         vrf.HRTime = max(0.0, CurrentEndTime - vrf.HRTimer);
    1075        4367 :         if (vrf.HRTime < (HRCapTC * 5.0)) {
    1076           0 :             if (HRCapTC > 0.0) {
    1077           0 :                 SUMultiplier = min(1.0, 1.0 - std::exp(-vrf.HRTime / HRCapTC));
    1078             :             } else {
    1079           0 :                 SUMultiplier = 1.0;
    1080             :             }
    1081             :         } else {
    1082        4367 :             SUMultiplier = 1.0;
    1083        4367 :             vrf.ModeChange = false;
    1084        4367 :             vrf.HRModeChange = false;
    1085             :         }
    1086        4367 :         vrf.SUMultiplier = SUMultiplier;
    1087             : 
    1088        4367 :         state.dataHVACVarRefFlow->CurrentEndTimeLast = CurrentEndTime;
    1089             : 
    1090        4367 :         if (vrf.HeatRecoveryUsed && vrf.HRCoolingActive) {
    1091           0 :             TotalCondCoolingCapacity *= HRCAPFTConst;
    1092           0 :             TotalCondCoolingCapacity =
    1093           0 :                 HRInitialCapFrac * TotalCondCoolingCapacity + (1.0 - HRInitialCapFrac) * TotalCondCoolingCapacity * SUMultiplier;
    1094           0 :             TotalTUCoolingCapacity = TotalCondCoolingCapacity * vrf.PipingCorrectionCooling;
    1095           0 :             if (TotalCondCoolingCapacity > 0.0) {
    1096           0 :                 CoolingPLR = min(1.0, (TUCoolingLoad / vrf.PipingCorrectionCooling) / TotalCondCoolingCapacity);
    1097             :             } else {
    1098           0 :                 CoolingPLR = 0.0;
    1099             :             }
    1100           0 :             HREIRAdjustment = HRInitialEIRFrac + (HREIRFTConst - HRInitialEIRFrac) * SUMultiplier;
    1101           0 :             vrf.VRFHeatRec = TUHeatingLoad;
    1102        4367 :         } else if (vrf.HeatRecoveryUsed && vrf.HRHeatingActive) {
    1103           0 :             TotalCondHeatingCapacity *= HRCAPFTConst;
    1104           0 :             TotalCondHeatingCapacity =
    1105           0 :                 HRInitialCapFrac * TotalCondHeatingCapacity + (1.0 - HRInitialCapFrac) * TotalCondHeatingCapacity * SUMultiplier;
    1106           0 :             TotalTUHeatingCapacity = TotalCondHeatingCapacity * vrf.PipingCorrectionHeating;
    1107           0 :             if (TotalCondHeatingCapacity > 0.0) {
    1108           0 :                 HeatingPLR = min(1.0, (TUHeatingLoad / vrf.PipingCorrectionHeating) / TotalCondHeatingCapacity);
    1109             :             } else {
    1110           0 :                 HeatingPLR = 0.0;
    1111             :             }
    1112           0 :             HREIRAdjustment = HRInitialEIRFrac + (HREIRFTConst - HRInitialEIRFrac) * SUMultiplier;
    1113           0 :             vrf.VRFHeatRec = TUCoolingLoad;
    1114             :         }
    1115        4367 :         vrf.VRFCondPLR = max(CoolingPLR, HeatingPLR);
    1116             :     }
    1117             : 
    1118       31016 :     if (vrf.MinPLR > 0.0) {
    1119       31016 :         CyclingRatio = min(1.0, vrf.VRFCondPLR / vrf.MinPLR);
    1120       31016 :         if (vrf.VRFCondPLR < vrf.MinPLR && vrf.VRFCondPLR > 0.0) {
    1121       15476 :             vrf.VRFCondPLR = vrf.MinPLR;
    1122       15476 :             if (CoolingPLR > 0.0) CoolingPLR = vrf.MinPLR; // also adjust local PLR variables
    1123       15476 :             if (HeatingPLR > 0.0) HeatingPLR = vrf.MinPLR; // also adjust local PLR variables
    1124             :         }
    1125             :     }
    1126       31016 :     vrf.VRFCondCyclingRatio = CyclingRatio; // report variable for cycling rate
    1127       31016 :     vrf.TotalCoolingCapacity = TotalCondCoolingCapacity * CoolingPLR * CyclingRatio;
    1128       31016 :     vrf.TotalHeatingCapacity = TotalCondHeatingCapacity * HeatingPLR * CyclingRatio;
    1129             : 
    1130       31016 :     vrf.OperatingMode = 0; // report variable for heating or cooling mode
    1131       31016 :     EIRFPLRModFac = 1.0;
    1132       31016 :     VRFRTF = 0.0;
    1133             :     // cooling and heating is optional (only one may exist), if so then performance curve for missing coil are not required
    1134       31016 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && CoolingPLR > 0.0) {
    1135       17211 :         vrf.OperatingMode = ModeCoolingOnly;
    1136       17211 :         if (CoolingPLR > 1.0) {
    1137         434 :             if (vrf.CoolEIRFPLR2 > 0) EIRFPLRModFac = CurveValue(state, vrf.CoolEIRFPLR2, max(vrf.MinPLR, CoolingPLR));
    1138             :         } else {
    1139       16777 :             if (vrf.CoolEIRFPLR1 > 0) EIRFPLRModFac = CurveValue(state, vrf.CoolEIRFPLR1, max(vrf.MinPLR, CoolingPLR));
    1140             :         }
    1141             : 
    1142       17211 :         if (EIRFPLRModFac < 0.0) {
    1143           0 :             if (vrf.CoolEIRFPLRErrorIndex == 0) {
    1144           0 :                 ShowSevereMessage(state, fmt::format("{} \"{}\":", std::string(cVRFTypes(VRF_HeatPump)), vrf.Name));
    1145           0 :                 ShowContinueError(state, format(" Cooling EIR Modifier curve (function of PLR) output is negative ({:.3T}).", EIRFPLRModFac));
    1146           0 :                 ShowContinueError(state, format(" Negative value occurs using a cooling Part Load Ratio (PLR) of {:.2T}.", CoolingPLR));
    1147           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    1148             :             }
    1149           0 :             ShowRecurringWarningErrorAtEnd(
    1150             :                 state,
    1151           0 :                 fmt::format("{} \"{}\": Cooling EIR Modifier curve (function of PLR) output is negative warning continues...",
    1152           0 :                             PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
    1153             :                             vrf.Name),
    1154             :                 vrf.CoolEIRFPLRErrorIndex,
    1155             :                 EIRFPLRModFac,
    1156             :                 EIRFPLRModFac);
    1157           0 :             EIRFPLRModFac = 0.0;
    1158             :         }
    1159             : 
    1160             :         // find part load fraction to calculate RTF
    1161       17211 :         if (vrf.CoolPLFFPLR > 0) {
    1162       17211 :             PartLoadFraction = max(0.7, CurveValue(state, vrf.CoolPLFFPLR, CyclingRatio));
    1163             :         } else {
    1164           0 :             PartLoadFraction = 1.0;
    1165             :         }
    1166       17211 :         VRFRTF = min(1.0, (CyclingRatio / PartLoadFraction));
    1167             : 
    1168       17211 :         vrf.ElecCoolingPower = (vrf.RatedCoolingPower * TotCoolCapTempModFac) * TotCoolEIRTempModFac * EIRFPLRModFac * HREIRAdjustment * VRFRTF;
    1169             :     }
    1170       31016 :     if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && HeatingPLR > 0.0) {
    1171       13801 :         vrf.OperatingMode = ModeHeatingOnly;
    1172       13801 :         if (HeatingPLR > 1.0) {
    1173        1000 :             if (vrf.HeatEIRFPLR2 > 0) EIRFPLRModFac = CurveValue(state, vrf.HeatEIRFPLR2, max(vrf.MinPLR, HeatingPLR));
    1174             :         } else {
    1175       12801 :             if (vrf.HeatEIRFPLR1 > 0) EIRFPLRModFac = CurveValue(state, vrf.HeatEIRFPLR1, max(vrf.MinPLR, HeatingPLR));
    1176             :         }
    1177             : 
    1178       13801 :         if (EIRFPLRModFac < 0.0) {
    1179           0 :             if (vrf.HeatEIRFPLRErrorIndex == 0) {
    1180           0 :                 ShowSevereMessage(state, fmt::format("{} \"{}\":", std::string(cVRFTypes(VRF_HeatPump)), vrf.Name));
    1181           0 :                 ShowContinueError(state, format(" Heating EIR Modifier curve (function of PLR) output is negative ({:.3T}).", EIRFPLRModFac));
    1182           0 :                 ShowContinueError(state, format(" Negative value occurs using a heating Part Load Ratio (PLR) of {:.2T}.", HeatingPLR));
    1183           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    1184             :             }
    1185           0 :             ShowRecurringWarningErrorAtEnd(
    1186             :                 state,
    1187           0 :                 fmt::format("{} \"{}\": Heating EIR Modifier curve (function of PLR) output is negative warning continues...",
    1188           0 :                             PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
    1189             :                             vrf.Name),
    1190             :                 vrf.HeatEIRFPLRErrorIndex,
    1191             :                 EIRFPLRModFac,
    1192             :                 EIRFPLRModFac);
    1193           0 :             EIRFPLRModFac = 0.0;
    1194             :         }
    1195             : 
    1196             :         // find part load fraction to calculate RTF
    1197       13801 :         if (vrf.HeatPLFFPLR > 0) {
    1198       13801 :             PartLoadFraction = max(0.7, CurveValue(state, vrf.HeatPLFFPLR, CyclingRatio));
    1199             :         } else {
    1200           0 :             PartLoadFraction = 1.0;
    1201             :         }
    1202       13801 :         VRFRTF = min(1.0, (CyclingRatio / PartLoadFraction));
    1203             : 
    1204       13801 :         vrf.ElecHeatingPower =
    1205       13801 :             (vrf.RatedHeatingPower * TotHeatCapTempModFac) * TotHeatEIRTempModFac * EIRFPLRModFac * HREIRAdjustment * VRFRTF * InputPowerMultiplier;
    1206             : 
    1207             :         // adjust defrost power based on heating RTF
    1208       13801 :         vrf.DefrostPower *= VRFRTF;
    1209             :     }
    1210       31016 :     vrf.VRFCondRTF = VRFRTF;
    1211             : 
    1212             :     // calculate crankcase heater power
    1213       31016 :     if (vrf.MaxOATCCHeater > OutdoorDryBulb) {
    1214             :         // calculate crankcase heater power
    1215        2891 :         vrf.CrankCaseHeaterPower = vrf.CCHeaterPower * (1.0 - VRFRTF);
    1216        2891 :         if (vrf.NumCompressors > 1) {
    1217        2891 :             UpperStageCompressorRatio = (1.0 - vrf.CompressorSizeRatio) / (vrf.NumCompressors - 1);
    1218        4327 :             for (Stage = 1; Stage <= vrf.NumCompressors - 2; ++Stage) {
    1219        1436 :                 if (vrf.VRFCondPLR < (vrf.CompressorSizeRatio + Stage * UpperStageCompressorRatio)) {
    1220           3 :                     vrf.CrankCaseHeaterPower += vrf.CCHeaterPower;
    1221             :                 }
    1222             :             }
    1223             :         }
    1224             :     } else {
    1225       28125 :         vrf.CrankCaseHeaterPower = 0.0;
    1226             :     }
    1227             : 
    1228       31016 :     CondCapacity = max(vrf.TotalCoolingCapacity, vrf.TotalHeatingCapacity);
    1229       31016 :     CondPower = max(vrf.ElecCoolingPower, vrf.ElecHeatingPower);
    1230       31016 :     if (vrf.ElecCoolingPower > 0.0) {
    1231       17211 :         vrf.QCondenser = CondCapacity + CondPower - vrf.TUHeatingLoad / vrf.PipingCorrectionHeating;
    1232       13805 :     } else if (vrf.ElecHeatingPower > 0.0) {
    1233       13801 :         vrf.QCondenser = -CondCapacity + CondPower + vrf.TUCoolingLoad / vrf.PipingCorrectionCooling;
    1234             :     } else {
    1235           4 :         vrf.QCondenser = 0.0;
    1236             :     }
    1237             : 
    1238       31016 :     if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    1239             :         // Calculate basin heater power
    1240           0 :         CalcBasinHeaterPower(state, vrf.BasinHeaterPowerFTempDiff, vrf.BasinHeaterSchedulePtr, vrf.BasinHeaterSetPointTemp, vrf.BasinHeaterPower);
    1241           0 :         vrf.BasinHeaterPower *= (1.0 - VRFRTF);
    1242             : 
    1243             :         // calculate evaporative condenser pump power and water consumption
    1244           0 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && CoolingPLR > 0.0) {
    1245             :             //******************
    1246             :             // WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
    1247             :             // H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
    1248             :             //                    /RhoWater [kgWater/m3]
    1249             :             //******************
    1250           0 :             RhoWater = RhoH2O(OutdoorDryBulb);
    1251           0 :             vrf.EvapWaterConsumpRate = (CondInletHumRat - OutdoorHumRat) * CondAirMassFlow / RhoWater * vrf.VRFCondPLR;
    1252           0 :             vrf.EvapCondPumpElecPower = vrf.EvapCondPumpPower * VRFRTF;
    1253             :         }
    1254       31016 :     } else if (vrf.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    1255             : 
    1256        3284 :         if (CondCapacity > 0.0) {
    1257        3283 :             state.dataHVACVarRefFlow->CondenserWaterMassFlowRate = CondWaterMassFlow;
    1258             :         } else {
    1259           1 :             state.dataHVACVarRefFlow->CondenserWaterMassFlowRate = 0.0;
    1260             :         }
    1261        6568 :         SetComponentFlowRate(
    1262        3284 :             state, state.dataHVACVarRefFlow->CondenserWaterMassFlowRate, vrf.CondenserNodeNum, vrf.CondenserOutletNodeNum, vrf.SourcePlantLoc);
    1263             : 
    1264             :         // should be the same as above just entering this function
    1265             :         //            VRF( VRFCond ).CondenserInletTemp = state.dataLoopNodes->Node(VRF(VRFCond).CondenserNodeNum).Temp;
    1266        3284 :         vrf.WaterCondenserMassFlow = state.dataLoopNodes->Node(vrf.CondenserNodeNum).MassFlowRate;
    1267             : 
    1268        6568 :         CpCond = GetSpecificHeatGlycol(state,
    1269        3284 :                                        state.dataPlnt->PlantLoop(vrf.SourcePlantLoc.loopNum).FluidName,
    1270             :                                        vrf.CondenserInletTemp,
    1271        3284 :                                        state.dataPlnt->PlantLoop(vrf.SourcePlantLoc.loopNum).FluidIndex,
    1272             :                                        RoutineName);
    1273        3284 :         if (CondWaterMassFlow > 0.0) {
    1274        3283 :             CondOutletTemp = vrf.QCondenser / (CondWaterMassFlow * CpCond) + CondInletTemp;
    1275             :         } else {
    1276           1 :             CondOutletTemp = CondInletTemp;
    1277             :         }
    1278        3284 :         vrf.CondenserSideOutletTemp = CondOutletTemp;
    1279             :     }
    1280             : 
    1281             :     // calculate operating COP
    1282       31016 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && CoolingPLR > 0.0) {
    1283       17211 :         if (vrf.ElecCoolingPower != 0.0) {
    1284             :             // this calc should use delivered capacity, not condenser capacity, use VRF(VRFCond)%TUCoolingLoad
    1285       17211 :             vrf.OperatingCoolingCOP =
    1286       17211 :                 (vrf.TotalCoolingCapacity) / (vrf.ElecCoolingPower + vrf.CrankCaseHeaterPower + vrf.EvapCondPumpElecPower + vrf.DefrostPower);
    1287             :         } else {
    1288           0 :             vrf.OperatingCoolingCOP = 0.0;
    1289             :         }
    1290             :     }
    1291       31016 :     if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && HeatingPLR > 0.0) {
    1292       13801 :         if (vrf.ElecHeatingPower != 0.0) {
    1293             :             // this calc should use delivered capacity, not condenser capacity, use VRF(VRFCond)%TUHeatingLoad
    1294       13801 :             vrf.OperatingHeatingCOP =
    1295       13801 :                 (vrf.TotalHeatingCapacity) / (vrf.ElecHeatingPower + vrf.CrankCaseHeaterPower + vrf.EvapCondPumpElecPower + vrf.DefrostPower);
    1296             :         } else {
    1297           0 :             vrf.OperatingHeatingCOP = 0.0;
    1298             :         }
    1299             :     }
    1300             : 
    1301       62032 :     TotPower = TUParasiticPower + TUFanPower + vrf.ElecHeatingPower + vrf.ElecCoolingPower + vrf.CrankCaseHeaterPower + vrf.EvapCondPumpElecPower +
    1302       31016 :                vrf.DefrostPower;
    1303       31016 :     if (TotPower > 0.0) {
    1304       31016 :         vrf.OperatingCOP = (vrf.TUCoolingLoad + vrf.TUHeatingLoad) / TotPower;
    1305       31016 :         vrf.SCHE = vrf.OperatingCOP * 3.412141633; // see StandardRatings::ConvFromSIToIP
    1306             :     }
    1307             : 
    1308             :     // limit the TU capacity when the condenser is maxed out on capacity
    1309             :     // I think this next line will make the max cap report variable match the coil objects, will probably change the answer though
    1310             :     //  IF(CoolingLoad(VRFCond) .AND. NumTUInCoolingMode .GT. 0 .AND. MaxCoolingCapacity(VRFCond) == MaxCap)THEN
    1311       31016 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && NumTUInCoolingMode > 0) {
    1312             : 
    1313             :         //   IF TU capacity is greater than condenser capacity find maximum allowed TU capacity (i.e., conserve energy)
    1314       17212 :         if (TUCoolingLoad > TotalTUCoolingCapacity) {
    1315         870 :             LimitTUCapacity(state,
    1316             :                             VRFCond,
    1317             :                             NumTUInList,
    1318             :                             TotalTUCoolingCapacity,
    1319         435 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad,
    1320         435 :                             state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond),
    1321             :                             TotalTUHeatingCapacity,
    1322         435 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad,
    1323         435 :                             state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond));
    1324             :         }
    1325       13804 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && NumTUInHeatingMode > 0) {
    1326             :         //   IF TU capacity is greater than condenser capacity
    1327       13804 :         if (TUHeatingLoad > TotalTUHeatingCapacity) {
    1328        2006 :             LimitTUCapacity(state,
    1329             :                             VRFCond,
    1330             :                             NumTUInList,
    1331             :                             TotalTUHeatingCapacity,
    1332        1003 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad,
    1333        1003 :                             state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond),
    1334             :                             TotalTUCoolingCapacity,
    1335        1003 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad,
    1336        1003 :                             state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond));
    1337             :         }
    1338             :     } else {
    1339             :     }
    1340             : }
    1341             : 
    1342          11 : void GetVRFInput(EnergyPlusData &state)
    1343             : {
    1344             : 
    1345             :     // SUBROUTINE INFORMATION:
    1346             :     //       AUTHOR         Richard Raustad, FSEC
    1347             :     //       DATE WRITTEN   August 2015
    1348             :     //       MODIFIED       na
    1349             :     //       RE-ENGINEERED  na
    1350             : 
    1351             :     // PURPOSE OF THIS SUBROUTINE:
    1352             :     // Manages GetInput processing and program termination
    1353             : 
    1354             :     // METHODOLOGY EMPLOYED:
    1355             :     // Calls "Get" routines to read in data.
    1356             : 
    1357             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1358             :     static constexpr std::string_view RoutineName("GetVRFInput: "); // include trailing blank space
    1359             : 
    1360             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1361          11 :     bool ErrorsFound(false); // If errors detected in input
    1362             : 
    1363          11 :     GetVRFInputData(state, ErrorsFound);
    1364             : 
    1365          11 :     if (ErrorsFound) {
    1366           0 :         ShowFatalError(state,
    1367           0 :                        std::string{RoutineName} +
    1368             :                            "Errors found in getting AirConditioner:VariableRefrigerantFlow system input. Preceding condition(s) causes termination.");
    1369             :     }
    1370          11 : }
    1371             : 
    1372          11 : void GetVRFInputData(EnergyPlusData &state, bool &ErrorsFound)
    1373             : {
    1374             : 
    1375             :     // SUBROUTINE INFORMATION:
    1376             :     //       AUTHOR         Richard Raustad, FSEC
    1377             :     //       DATE WRITTEN   August 2010
    1378             :     //       MODIFIED       July 2012, Chandan Sharma - FSEC: Added zone sys avail managers
    1379             :     //       RE-ENGINEERED  na
    1380             : 
    1381             :     // PURPOSE OF THIS SUBROUTINE:
    1382             :     // Obtains input data for VRF systems and stores it in data structures
    1383             : 
    1384             :     using namespace DataLoopNode;
    1385             :     using BranchNodeConnections::SetUpCompSets;
    1386             :     using BranchNodeConnections::TestCompSet;
    1387             :     using Curve::checkCurveIsNormalizedToOne;
    1388             :     using Curve::CurveValue;
    1389             :     using Curve::GetCurveIndex;
    1390             :     using Curve::SetCurveOutputMinMaxValues;
    1391             :     using DXCoils::GetDXCoilIndex;
    1392             :     using Fans::GetFanAvailSchPtr;
    1393             :     using Fans::GetFanDesignVolumeFlowRate;
    1394             :     using Fans::GetFanIndex;
    1395             :     using Fans::GetFanInletNode;
    1396             :     using Fans::GetFanOutletNode;
    1397             :     using Fans::GetFanType;
    1398             : 
    1399             :     using MixedAir::GetOAMixerNodeNumbers;
    1400             :     using NodeInputManager::GetOnlySingleNode;
    1401             :     using ScheduleManager::CheckScheduleValueMinMax;
    1402             :     using ScheduleManager::GetScheduleIndex;
    1403          11 :     auto &GetDXCoilInletNode(DXCoils::GetCoilInletNode);
    1404          11 :     auto &GetDXCoilOutletNode(DXCoils::GetCoilOutletNode);
    1405             :     using DataSizing::AutoSize;
    1406             :     using DXCoils::GetCoilCondenserInletNode;
    1407             :     using DXCoils::GetCoilTypeNum;
    1408             :     using DXCoils::GetDXCoilAvailSchPtr;
    1409             :     using DXCoils::GetDXCoilCapFTCurveIndex;
    1410             :     using DXCoils::GetDXCoilName;
    1411             :     using DXCoils::RatedInletAirTempHeat;
    1412             :     using DXCoils::RatedInletWetBulbTemp;
    1413             :     using DXCoils::RatedOutdoorAirTemp;
    1414             :     using DXCoils::RatedOutdoorAirTempHeat;
    1415             :     using DXCoils::RatedOutdoorWetBulbTempHeat;
    1416             :     using DXCoils::SetDXCoolingCoilData;
    1417             :     using OutAirNodeManager::CheckOutAirNodeNumber;
    1418             :     using SingleDuct::GetATMixer;
    1419             :     using WaterManager::SetupTankDemandComponent;
    1420             :     using WaterManager::SetupTankSupplyComponent;
    1421             : 
    1422             :     static constexpr std::string_view RoutineName("GetVRFInput: "); // include trailing blank space
    1423             : 
    1424             :     int NumVRFCTU; // The number of VRF constant volume TUs (anticipating different types of TU's)
    1425             :     int VRFTUNum;  // Loop index to the total number of VRF terminal units
    1426             :     int VRFNum;    // Loop index to the total number of VRF terminal units
    1427             :     int TUListNum; // Loop index to the total number of VRF terminal unit lists
    1428             :     int NumAlphas; // Number of alpha arguments
    1429             :     int NumNums;   // Number of real arguments
    1430             :     //    INTEGER :: checkNum
    1431             :     int IOStat;   // Status
    1432             :     bool errFlag; // error flag for mining functions
    1433             :     bool IsNotOK; // Flag to verify name
    1434          22 :     Array1D_string cAlphaFieldNames;
    1435          22 :     Array1D_string cNumericFieldNames;
    1436          22 :     Array1D_bool lNumericFieldBlanks;
    1437          22 :     Array1D_bool lAlphaFieldBlanks;
    1438          22 :     Array1D_string cAlphaArgs;
    1439          22 :     Array1D<Real64> rNumericArgs;
    1440          22 :     std::string cCurrentModuleObject;
    1441             :     int NumParams;
    1442             :     int MaxAlphas;
    1443             :     int MaxNumbers;
    1444          22 :     std::string FanType;             // Type of supply air fan
    1445          22 :     std::string FanName;             // Supply air fan name
    1446          22 :     std::string OAMixerType;         // Type of OA mixer
    1447          22 :     std::string DXCoolingCoilType;   // Type of VRF DX cooling coil
    1448          22 :     std::string DXHeatingCoilType;   // Type of VRF DX heating coil
    1449          22 :     std::string SuppHeatingCoilType; // Type of VRF supplemental heating coil
    1450          22 :     std::string SuppHeatingCoilName; // Name of VRF supplemental heating coil
    1451             :     Real64 FanVolFlowRate;           // Fan Max Flow Rate from Fan object (for comparisons to validity)
    1452             :     int FanInletNodeNum;             // Used in TU configuration setup
    1453             :     int FanOutletNodeNum;            // Used in TU configuration setup
    1454          22 :     Array1D_int OANodeNums(4);       // Node numbers of OA mixer (OA, EA, RA, MA)
    1455             :     int CCoilInletNodeNum;           // Used in TU configuration setup
    1456             :     int CCoilOutletNodeNum;          // Used in TU configuration setup
    1457             :     int HCoilInletNodeNum;           // Used in TU configuration setup
    1458             :     int HCoilOutletNodeNum;          // Used in TU configuration setup
    1459             :     int SuppHeatCoilAirInletNode;    // supplemental heating coil air inlet node
    1460             :     int SuppHeatCoilAirOutletNode;   // supplemental heating coil air outlet node
    1461             :     int ZoneTerminalUnitListNum;     // Used to find connection between VRFTU, TUList and VRF condenser
    1462             :     int NumCond;                     // loop counter
    1463             :     int NumList;                     // loop counter
    1464             :     int CtrlZone;                    // index to loop counter
    1465             :     int NodeNum;                     // index to loop counter
    1466             :     // Followings for VRF FluidTCtrl Only
    1467             :     int NumCompSpd;     // XP_loop counter
    1468             :     int NumOfCompSpd;   // XP_ number of compressor speed inputs
    1469             :     Real64 CurveVal;    // Used to verify modifier curves equal 1 at rated conditions
    1470             :     Real64 MinCurveVal; // used for testing PLF curve output
    1471             :     Real64 MinCurvePLR; // used for testing PLF curve output
    1472             :     Real64 MaxCurveVal; // used for testing PLF curve output
    1473             :     Real64 MaxCurvePLR; // used for testing PLF curve output
    1474             :     Real64 CurveInput;  // index used for testing PLF curve output
    1475             : 
    1476          11 :     MaxAlphas = 0;
    1477          11 :     MaxNumbers = 0;
    1478             : 
    1479          11 :     NumVRFCTU = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow");
    1480          11 :     if (NumVRFCTU > 0) {
    1481          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
    1482          11 :             state, "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow", NumParams, NumAlphas, NumNums);
    1483          11 :         MaxAlphas = max(MaxAlphas, NumAlphas);
    1484          11 :         MaxNumbers = max(MaxNumbers, NumNums);
    1485             :     }
    1486             : 
    1487          11 :     state.dataHVACVarRefFlow->NumVRFCond_SysCurve =
    1488          22 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "AirConditioner:VariableRefrigerantFlow");
    1489          11 :     if (state.dataHVACVarRefFlow->NumVRFCond_SysCurve > 0) {
    1490          16 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
    1491           8 :             state, "AirConditioner:VariableRefrigerantFlow", NumParams, NumAlphas, NumNums);
    1492           8 :         MaxAlphas = max(MaxAlphas, NumAlphas);
    1493           8 :         MaxNumbers = max(MaxNumbers, NumNums);
    1494             :     }
    1495             : 
    1496          11 :     state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP =
    1497          22 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl");
    1498          11 :     if (state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP > 0) {
    1499           4 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
    1500           2 :             state, "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl", NumParams, NumAlphas, NumNums);
    1501           2 :         MaxAlphas = max(MaxAlphas, NumAlphas);
    1502           2 :         MaxNumbers = max(MaxNumbers, NumNums);
    1503             :     }
    1504             : 
    1505          11 :     state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HR =
    1506          22 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl:HR");
    1507          11 :     if (state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HR > 0) {
    1508           2 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
    1509           1 :             state, "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl:HR", NumParams, NumAlphas, NumNums);
    1510           1 :         MaxAlphas = max(MaxAlphas, NumAlphas);
    1511           1 :         MaxNumbers = max(MaxNumbers, NumNums);
    1512             :     }
    1513             : 
    1514          22 :     state.dataHVACVarRefFlow->NumVRFCond = state.dataHVACVarRefFlow->NumVRFCond_SysCurve + state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP +
    1515          11 :                                            state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HR;
    1516             : 
    1517          11 :     state.dataHVACVarRefFlow->NumVRFTULists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneTerminalUnitList");
    1518          11 :     if (state.dataHVACVarRefFlow->NumVRFTULists > 0) {
    1519          11 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "ZoneTerminalUnitList", NumParams, NumAlphas, NumNums);
    1520          11 :         MaxAlphas = max(MaxAlphas, NumAlphas);
    1521          11 :         MaxNumbers = max(MaxNumbers, NumNums);
    1522             :     }
    1523             : 
    1524          11 :     cAlphaArgs.allocate(MaxAlphas);
    1525          11 :     cAlphaFieldNames.allocate(MaxAlphas);
    1526          11 :     lAlphaFieldBlanks.dimension(MaxAlphas, false);
    1527          11 :     cNumericFieldNames.allocate(MaxNumbers);
    1528          11 :     lNumericFieldBlanks.dimension(MaxNumbers, false);
    1529          11 :     rNumericArgs.dimension(MaxNumbers, 0.0);
    1530             : 
    1531          11 :     state.dataHVACVarRefFlow->NumVRFTU = NumVRFCTU;
    1532          11 :     if (state.dataHVACVarRefFlow->NumVRFTU > 0) {
    1533          11 :         state.dataHVACVarRefFlow->VRFTU.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    1534          11 :         state.dataHVACVarRefFlow->CheckEquipName.dimension(state.dataHVACVarRefFlow->NumVRFTU, true);
    1535          11 :         state.dataHVACVarRefFlow->VRFTUNumericFields.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    1536             :     }
    1537             : 
    1538          11 :     if (state.dataHVACVarRefFlow->NumVRFCond > 0) {
    1539          11 :         state.dataHVACVarRefFlow->VRF.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    1540          11 :         state.dataHVACVarRefFlow->VrfUniqueNames.reserve(static_cast<unsigned>(state.dataHVACVarRefFlow->NumVRFCond));
    1541          11 :         state.dataHVACVarRefFlow->MaxCoolingCapacity.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    1542          11 :         state.dataHVACVarRefFlow->MaxHeatingCapacity.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    1543          11 :         state.dataHVACVarRefFlow->CoolCombinationRatio.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    1544          11 :         state.dataHVACVarRefFlow->HeatCombinationRatio.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    1545          11 :         state.dataHVACVarRefFlow->MaxCoolingCapacity = MaxCap;
    1546          11 :         state.dataHVACVarRefFlow->MaxHeatingCapacity = MaxCap;
    1547          11 :         state.dataHVACVarRefFlow->CoolCombinationRatio = 1.0;
    1548          11 :         state.dataHVACVarRefFlow->HeatCombinationRatio = 1.0;
    1549             :     }
    1550             : 
    1551          11 :     if (state.dataHVACVarRefFlow->NumVRFTULists > 0) {
    1552          11 :         state.dataHVACVarRefFlow->TerminalUnitList.allocate(state.dataHVACVarRefFlow->NumVRFTULists);
    1553             :     }
    1554             : 
    1555             :     // read all terminal unit list objects
    1556          11 :     cCurrentModuleObject = "ZoneTerminalUnitList";
    1557          23 :     for (VRFNum = 1; VRFNum <= state.dataHVACVarRefFlow->NumVRFTULists; ++VRFNum) {
    1558          12 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1559             :                                                                  cCurrentModuleObject,
    1560             :                                                                  VRFNum,
    1561             :                                                                  cAlphaArgs,
    1562             :                                                                  NumAlphas,
    1563             :                                                                  rNumericArgs,
    1564             :                                                                  NumNums,
    1565             :                                                                  IOStat,
    1566             :                                                                  lNumericFieldBlanks,
    1567             :                                                                  lAlphaFieldBlanks,
    1568             :                                                                  cAlphaFieldNames,
    1569             :                                                                  cNumericFieldNames);
    1570          12 :         UtilityRoutines::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
    1571             : 
    1572          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).Name = cAlphaArgs(1);
    1573          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList = NumAlphas - 1;
    1574          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).ZoneTUPtr.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1575          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).ZoneTUName.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1576          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).IsSimulated.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1577          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TotalCoolLoad.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1578          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TotalHeatLoad.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1579          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilPresent.allocate(
    1580          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1581          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilPresent.allocate(
    1582          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1583          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TerminalUnitNotSizedYet.allocate(
    1584          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1585          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HRHeatRequest.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1586          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HRCoolRequest.allocate(state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1587          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilAvailable.allocate(
    1588          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1589          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilAvailable.allocate(
    1590          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1591          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilAvailSchPtr.allocate(
    1592          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1593          24 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilAvailSchPtr.allocate(
    1594          24 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList);
    1595          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).ZoneTUPtr = 0;
    1596          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).IsSimulated = false;
    1597          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TotalCoolLoad = 0.0;
    1598          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TotalHeatLoad = 0.0;
    1599          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilPresent = true;
    1600          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilPresent = true;
    1601          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).TerminalUnitNotSizedYet = true;
    1602          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HRHeatRequest = false;
    1603          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HRCoolRequest = false;
    1604          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilAvailable = false;
    1605          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilAvailable = false;
    1606          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).CoolingCoilAvailSchPtr = -1;
    1607          12 :         state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).HeatingCoilAvailSchPtr = -1;
    1608             : 
    1609          68 :         for (TUListNum = 1; TUListNum <= state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).NumTUInList; ++TUListNum) {
    1610          56 :             state.dataHVACVarRefFlow->TerminalUnitList(VRFNum).ZoneTUName(TUListNum) = cAlphaArgs(TUListNum + 1);
    1611             :         }
    1612             :     }
    1613             : 
    1614             :     // read all VRF condenser objects: Algorithm Type 1_system curve based model
    1615          11 :     cCurrentModuleObject = "AirConditioner:VariableRefrigerantFlow";
    1616          20 :     for (VRFNum = 1; VRFNum <= state.dataHVACVarRefFlow->NumVRFCond_SysCurve; ++VRFNum) {
    1617           9 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1618             :                                                                  cCurrentModuleObject,
    1619             :                                                                  VRFNum,
    1620             :                                                                  cAlphaArgs,
    1621             :                                                                  NumAlphas,
    1622             :                                                                  rNumericArgs,
    1623             :                                                                  NumNums,
    1624             :                                                                  IOStat,
    1625             :                                                                  lNumericFieldBlanks,
    1626             :                                                                  lAlphaFieldBlanks,
    1627             :                                                                  cAlphaFieldNames,
    1628             :                                                                  cNumericFieldNames);
    1629          18 :         GlobalNames::VerifyUniqueInterObjectName(
    1630          18 :             state, state.dataHVACVarRefFlow->VrfUniqueNames, cAlphaArgs(1), cCurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    1631             : 
    1632           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).Name = cAlphaArgs(1);
    1633           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFSystemTypeNum = VRF_HeatPump;
    1634           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFAlgorithmTypeNum = AlgorithmType::SysCurve;
    1635           9 :         if (lAlphaFieldBlanks(2)) {
    1636           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    1637             :         } else {
    1638           7 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2));
    1639           7 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr == 0) {
    1640           0 :                 ShowSevereError(state, cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" invalid data");
    1641           0 :                 ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\".");
    1642           0 :                 ErrorsFound = true;
    1643             :             }
    1644             :         }
    1645             : 
    1646           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCapacity = rNumericArgs(1);
    1647           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCOP = rNumericArgs(2);
    1648           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling = rNumericArgs(3);
    1649           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling = rNumericArgs(4);
    1650             : 
    1651           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFT = GetCurveIndex(state, cAlphaArgs(3));
    1652           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFT > 0) {
    1653             :             // Verify Curve Object, only legal type is biquadratic
    1654          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1655           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFT, // Curve index
    1656             :                                                  {2},                                             // Valid dimensions
    1657             :                                                  RoutineName,                                     // Routine name
    1658             :                                                  cCurrentModuleObject,                            // Object Type
    1659           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    1660           9 :                                                  cAlphaFieldNames(3));                            // Field Name
    1661             : 
    1662           9 :             if (!ErrorsFound) {
    1663          45 :                 checkCurveIsNormalizedToOne(state,
    1664          18 :                                             std::string{RoutineName} + cCurrentModuleObject,
    1665           9 :                                             state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    1666           9 :                                             state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFT,
    1667           9 :                                             cAlphaFieldNames(3),
    1668           9 :                                             cAlphaArgs(3),
    1669             :                                             RatedInletWetBulbTemp,
    1670             :                                             RatedOutdoorAirTemp);
    1671             :             }
    1672             :         }
    1673             : 
    1674           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolBoundaryCurvePtr = GetCurveIndex(state, cAlphaArgs(4));
    1675           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolBoundaryCurvePtr > 0) {
    1676             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1677          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1678           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolBoundaryCurvePtr, // Curve index
    1679             :                                                  {1},                                                        // Valid dimensions
    1680             :                                                  RoutineName,                                                // Routine name
    1681             :                                                  cCurrentModuleObject,                                       // Object Type
    1682           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,                 // Object Name
    1683           9 :                                                  cAlphaFieldNames(4));                                       // Field Name
    1684             :         }
    1685             : 
    1686           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFTHi = GetCurveIndex(state, cAlphaArgs(5));
    1687           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFTHi > 0) {
    1688             :             // Verify Curve Object, only legal type is biquadratic
    1689          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1690           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolCapFTHi, // Curve index
    1691             :                                                  {2},                                               // Valid dimensions
    1692             :                                                  RoutineName,                                       // Routine name
    1693             :                                                  cCurrentModuleObject,                              // Object Type
    1694           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1695           9 :                                                  cAlphaFieldNames(5));                              // Field Name
    1696             :         }
    1697             : 
    1698           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFT = GetCurveIndex(state, cAlphaArgs(6));
    1699           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFT > 0) {
    1700             :             // Verify Curve Object, only legal type is biquadratic
    1701          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1702           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFT, // Curve index
    1703             :                                                  {2},                                             // Valid dimensions
    1704             :                                                  RoutineName,                                     // Routine name
    1705             :                                                  cCurrentModuleObject,                            // Object Type
    1706           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    1707           9 :                                                  cAlphaFieldNames(6));                            // Field Name
    1708             :         }
    1709             : 
    1710           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EIRCoolBoundaryCurvePtr = GetCurveIndex(state, cAlphaArgs(7));
    1711           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).EIRCoolBoundaryCurvePtr > 0) {
    1712             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1713          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1714           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).EIRCoolBoundaryCurvePtr, // Curve index
    1715             :                                                  {1},                                                           // Valid dimensions
    1716             :                                                  RoutineName,                                                   // Routine name
    1717             :                                                  cCurrentModuleObject,                                          // Object Type
    1718           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,                    // Object Name
    1719           9 :                                                  cAlphaFieldNames(7));                                          // Field Name
    1720             :         }
    1721             : 
    1722           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFTHi = GetCurveIndex(state, cAlphaArgs(8));
    1723           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFTHi > 0) {
    1724             :             // Verify Curve Object, only legal type is biquadratic
    1725          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1726           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFTHi, // Curve index
    1727             :                                                  {2},                                               // Valid dimensions
    1728             :                                                  RoutineName,                                       // Routine name
    1729             :                                                  cCurrentModuleObject,                              // Object Type
    1730           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1731           9 :                                                  cAlphaFieldNames(8));                              // Field Name
    1732             :         }
    1733             : 
    1734           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR1 = GetCurveIndex(state, cAlphaArgs(9));
    1735           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR1 > 0) {
    1736             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1737          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1738           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR1, // Curve index
    1739             :                                                  {1},                                                // Valid dimensions
    1740             :                                                  RoutineName,                                        // Routine name
    1741             :                                                  cCurrentModuleObject,                               // Object Type
    1742           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,         // Object Name
    1743           9 :                                                  cAlphaFieldNames(9));                               // Field Name
    1744             :         }
    1745             : 
    1746           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR2 = GetCurveIndex(state, cAlphaArgs(10));
    1747           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR2 > 0) {
    1748             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1749          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1750           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR2, // Curve index
    1751             :                                                  {1},                                                // Valid dimensions
    1752             :                                                  RoutineName,                                        // Routine name
    1753             :                                                  cCurrentModuleObject,                               // Object Type
    1754           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,         // Object Name
    1755           9 :                                                  cAlphaFieldNames(10));                              // Field Name
    1756             :         }
    1757             : 
    1758           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolCombRatioPTR = GetCurveIndex(state, cAlphaArgs(11));
    1759           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolCombRatioPTR > 0) {
    1760             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1761          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1762           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolCombRatioPTR, // Curve index
    1763             :                                                  {1},                                                    // Valid dimensions
    1764             :                                                  RoutineName,                                            // Routine name
    1765             :                                                  cCurrentModuleObject,                                   // Object Type
    1766           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,             // Object Name
    1767           9 :                                                  cAlphaFieldNames(11));                                  // Field Name
    1768             :         }
    1769             : 
    1770           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR = GetCurveIndex(state, cAlphaArgs(12));
    1771           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR > 0) {
    1772             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1773          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1774           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR, // Curve index
    1775             :                                                  {1},                                               // Valid dimensions
    1776             :                                                  RoutineName,                                       // Routine name
    1777             :                                                  cCurrentModuleObject,                              // Object Type
    1778           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1779           9 :                                                  cAlphaFieldNames(12));                             // Field Name
    1780           9 :             if (!ErrorsFound) {
    1781             :                 //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    1782           9 :                 MinCurveVal = 999.0;
    1783           9 :                 MaxCurveVal = -999.0;
    1784           9 :                 CurveInput = 0.0;
    1785        1809 :                 while (CurveInput <= 1.0) {
    1786         900 :                     CurveVal = CurveValue(state, state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR, CurveInput);
    1787         900 :                     if (CurveVal < MinCurveVal) {
    1788           9 :                         MinCurveVal = CurveVal;
    1789           9 :                         MinCurvePLR = CurveInput;
    1790             :                     }
    1791         900 :                     if (CurveVal > MaxCurveVal) {
    1792         900 :                         MaxCurveVal = CurveVal;
    1793         900 :                         MaxCurvePLR = CurveInput;
    1794             :                     }
    1795         900 :                     CurveInput += 0.01;
    1796             :                 }
    1797           9 :                 if (MinCurveVal < 0.7) {
    1798           0 :                     ShowWarningError(
    1799           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    1800           0 :                     ShowContinueError(state, "..." + cAlphaFieldNames(12) + "=\"" + cAlphaArgs(12) + "\" has out of range values.");
    1801           0 :                     ShowContinueError(state,
    1802           0 :                                       format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    1803           0 :                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    1804           0 :                     SetCurveOutputMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR, ErrorsFound, 0.7, _);
    1805             :                 }
    1806             : 
    1807           9 :                 if (MaxCurveVal > 1.0) {
    1808           0 :                     ShowWarningError(
    1809           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    1810           0 :                     ShowContinueError(state, "..." + cAlphaFieldNames(12) + " = " + cAlphaArgs(12) + " has out of range value.");
    1811           0 :                     ShowContinueError(state,
    1812           0 :                                       format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    1813           0 :                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    1814           0 :                     SetCurveOutputMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).CoolPLFFPLR, ErrorsFound, _, 1.0);
    1815             :                 }
    1816             :             }
    1817             :         }
    1818             : 
    1819           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCapacity = rNumericArgs(5);
    1820           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCapacitySizeRatio = rNumericArgs(6);
    1821           9 :         if (!lNumericFieldBlanks(6) && state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCapacity == AutoSize) {
    1822           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).LockHeatingCapacity = true;
    1823             :         }
    1824           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCOP = rNumericArgs(7);
    1825           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating = rNumericArgs(8);
    1826           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating = rNumericArgs(9);
    1827           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating) {
    1828           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    1829           0 :             ShowContinueError(state,
    1830           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    1831             :                                      cNumericFieldNames(8),
    1832           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating,
    1833           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    1834           0 :             ErrorsFound = true;
    1835             :         }
    1836             : 
    1837           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFT = GetCurveIndex(state, cAlphaArgs(13));
    1838           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFT > 0) {
    1839             :             // Verify Curve Object, only legal type is biquadratic
    1840          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1841           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFT, // Curve index
    1842             :                                                  {2},                                             // Valid dimensions
    1843             :                                                  RoutineName,                                     // Routine name
    1844             :                                                  cCurrentModuleObject,                            // Object Type
    1845           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    1846           9 :                                                  cAlphaFieldNames(13));                           // Field Name
    1847             : 
    1848           9 :             if (!ErrorsFound) {
    1849           9 :                 if (UtilityRoutines::SameString(cAlphaArgs(19), "WETBULBTEMPERATURE")) {
    1850          40 :                     checkCurveIsNormalizedToOne(state,
    1851          16 :                                                 std::string{RoutineName} + cCurrentModuleObject,
    1852           8 :                                                 state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    1853           8 :                                                 state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFT,
    1854           8 :                                                 cAlphaFieldNames(13),
    1855           8 :                                                 cAlphaArgs(13),
    1856             :                                                 RatedInletAirTempHeat,
    1857             :                                                 RatedOutdoorWetBulbTempHeat);
    1858           1 :                 } else if (UtilityRoutines::SameString(cAlphaArgs(19), "DRYBULBTEMPERATURE")) {
    1859           5 :                     checkCurveIsNormalizedToOne(state,
    1860           2 :                                                 std::string{RoutineName} + cCurrentModuleObject,
    1861           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    1862           1 :                                                 state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFT,
    1863           1 :                                                 cAlphaFieldNames(13),
    1864           1 :                                                 cAlphaArgs(13),
    1865             :                                                 RatedInletAirTempHeat,
    1866             :                                                 RatedOutdoorAirTempHeat);
    1867             :                 }
    1868             :             }
    1869             :         }
    1870             : 
    1871           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatBoundaryCurvePtr = GetCurveIndex(state, cAlphaArgs(14));
    1872           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatBoundaryCurvePtr > 0) {
    1873             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1874          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1875           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatBoundaryCurvePtr, // Curve index
    1876             :                                                  {1},                                                        // Valid dimensions
    1877             :                                                  RoutineName,                                                // Routine name
    1878             :                                                  cCurrentModuleObject,                                       // Object Type
    1879           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,                 // Object Name
    1880           9 :                                                  cAlphaFieldNames(14));                                      // Field Name
    1881             :         }
    1882             : 
    1883           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFTHi = GetCurveIndex(state, cAlphaArgs(15));
    1884           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFTHi > 0) {
    1885             :             // Verify Curve Object, only legal type is biquadratic
    1886          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1887           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatCapFTHi, // Curve index
    1888             :                                                  {2},                                               // Valid dimensions
    1889             :                                                  RoutineName,                                       // Routine name
    1890             :                                                  cCurrentModuleObject,                              // Object Type
    1891           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1892           9 :                                                  cAlphaFieldNames(15));                             // Field Name
    1893             :         }
    1894             : 
    1895           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFT = GetCurveIndex(state, cAlphaArgs(16));
    1896           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFT > 0) {
    1897             :             // Verify Curve Object, only legal type is biquadratic
    1898          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1899           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFT, // Curve index
    1900             :                                                  {2},                                             // Valid dimensions
    1901             :                                                  RoutineName,                                     // Routine name
    1902             :                                                  cCurrentModuleObject,                            // Object Type
    1903           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    1904           9 :                                                  cAlphaFieldNames(16));                           // Field Name
    1905             :         }
    1906             : 
    1907           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EIRHeatBoundaryCurvePtr = GetCurveIndex(state, cAlphaArgs(17));
    1908           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).EIRHeatBoundaryCurvePtr > 0) {
    1909             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1910          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1911           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).EIRHeatBoundaryCurvePtr, // Curve index
    1912             :                                                  {1},                                                           // Valid dimensions
    1913             :                                                  RoutineName,                                                   // Routine name
    1914             :                                                  cCurrentModuleObject,                                          // Object Type
    1915           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,                    // Object Name
    1916           9 :                                                  cAlphaFieldNames(17));                                         // Field Name
    1917             :         }
    1918             : 
    1919           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFTHi = GetCurveIndex(state, cAlphaArgs(18));
    1920           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFTHi > 0) {
    1921             :             // Verify Curve Object, only legal type is biquadratic
    1922          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1923           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFTHi, // Curve index
    1924             :                                                  {2},                                               // Valid dimensions
    1925             :                                                  RoutineName,                                       // Routine name
    1926             :                                                  cCurrentModuleObject,                              // Object Type
    1927           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1928           9 :                                                  cAlphaFieldNames(18));                             // Field Name
    1929             :         }
    1930             : 
    1931           9 :         if (UtilityRoutines::SameString(cAlphaArgs(19), "WETBULBTEMPERATURE")) {
    1932           8 :             state.dataHVACVarRefFlow->VRF(VRFNum).HeatingPerformanceOATType = DataHVACGlobals::WetBulbIndicator;
    1933           1 :         } else if (UtilityRoutines::SameString(cAlphaArgs(19), "DRYBULBTEMPERATURE")) {
    1934           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HeatingPerformanceOATType = DataHVACGlobals::DryBulbIndicator;
    1935             :         } else {
    1936           0 :             ShowSevereError(state,
    1937           0 :                             cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" illegal " + cAlphaFieldNames(19) +
    1938           0 :                                 " input for this object = " + cAlphaArgs(19));
    1939           0 :             ShowContinueError(state, "... input must be WETBULBTEMPERATURE or DRYBULBTEMPERATURE.");
    1940           0 :             ErrorsFound = true;
    1941             :         }
    1942             : 
    1943           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR1 = GetCurveIndex(state, cAlphaArgs(20));
    1944           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR1 > 0) {
    1945             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1946          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1947           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR1, // Curve index
    1948             :                                                  {1},                                                // Valid dimensions
    1949             :                                                  RoutineName,                                        // Routine name
    1950             :                                                  cCurrentModuleObject,                               // Object Type
    1951           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,         // Object Name
    1952           9 :                                                  cAlphaFieldNames(20));                              // Field Name
    1953             :         }
    1954             : 
    1955           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR2 = GetCurveIndex(state, cAlphaArgs(21));
    1956           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR2 > 0) {
    1957             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1958          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1959           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR2, // Curve index
    1960             :                                                  {1},                                                // Valid dimensions
    1961             :                                                  RoutineName,                                        // Routine name
    1962             :                                                  cCurrentModuleObject,                               // Object Type
    1963           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,         // Object Name
    1964           9 :                                                  cAlphaFieldNames(21));                              // Field Name
    1965             :         }
    1966             : 
    1967           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatCombRatioPTR = GetCurveIndex(state, cAlphaArgs(22));
    1968           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatCombRatioPTR > 0) {
    1969             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1970          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1971           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatCombRatioPTR, // Curve index
    1972             :                                                  {1},                                                    // Valid dimensions
    1973             :                                                  RoutineName,                                            // Routine name
    1974             :                                                  cCurrentModuleObject,                                   // Object Type
    1975           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,             // Object Name
    1976           9 :                                                  cAlphaFieldNames(22));                                  // Field Name
    1977             :         }
    1978           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR = GetCurveIndex(state, cAlphaArgs(23));
    1979           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR > 0) {
    1980             :             // Verify Curve Object, only legal type is linear, quadratic, or cubic
    1981          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1982           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR, // Curve index
    1983             :                                                  {1},                                               // Valid dimensions
    1984             :                                                  RoutineName,                                       // Routine name
    1985             :                                                  cCurrentModuleObject,                              // Object Type
    1986           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    1987           9 :                                                  cAlphaFieldNames(23));                             // Field Name
    1988             : 
    1989           9 :             if (!ErrorsFound) {
    1990           9 :                 MinCurveVal = 999.0;
    1991           9 :                 MaxCurveVal = -999.0;
    1992           9 :                 CurveInput = 0.0;
    1993        1809 :                 while (CurveInput <= 1.0) {
    1994         900 :                     CurveVal = CurveValue(state, state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR, CurveInput);
    1995         900 :                     if (CurveVal < MinCurveVal) {
    1996           9 :                         MinCurveVal = CurveVal;
    1997           9 :                         MinCurvePLR = CurveInput;
    1998             :                     }
    1999         900 :                     if (CurveVal > MaxCurveVal) {
    2000         900 :                         MaxCurveVal = CurveVal;
    2001         900 :                         MaxCurvePLR = CurveInput;
    2002             :                     }
    2003         900 :                     CurveInput += 0.01;
    2004             :                 }
    2005           9 :                 if (MinCurveVal < 0.7) {
    2006           0 :                     ShowWarningError(
    2007           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2008           0 :                     ShowContinueError(state, "..." + cAlphaFieldNames(23) + "=\"" + cAlphaArgs(23) + "\" has out of range values.");
    2009           0 :                     ShowContinueError(state,
    2010           0 :                                       format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    2011           0 :                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    2012           0 :                     SetCurveOutputMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR, ErrorsFound, 0.7, _);
    2013             :                 }
    2014             : 
    2015           9 :                 if (MaxCurveVal > 1.0) {
    2016           0 :                     ShowWarningError(
    2017           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2018           0 :                     ShowContinueError(state, "..." + cAlphaFieldNames(23) + " = " + cAlphaArgs(23) + " has out of range value.");
    2019           0 :                     ShowContinueError(state,
    2020           0 :                                       format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    2021           0 :                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    2022           0 :                     SetCurveOutputMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).HeatPLFFPLR, ErrorsFound, _, 1.0);
    2023             :                 }
    2024             :             }
    2025             :         }
    2026             : 
    2027           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinPLR = rNumericArgs(10);
    2028           9 :         Real64 minEIRfLowPLRXInput = 0.0;
    2029           9 :         Real64 maxEIRfLowPLRXInput = 0.0;
    2030             : 
    2031           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR1 > 0) {
    2032           9 :             Curve::GetCurveMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).CoolEIRFPLR1, minEIRfLowPLRXInput, maxEIRfLowPLRXInput);
    2033           9 :             if (minEIRfLowPLRXInput > state.dataHVACVarRefFlow->VRF(VRFNum).MinPLR) {
    2034           0 :                 ShowWarningError(
    2035           0 :                     state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2036           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(9) + " = " + cAlphaArgs(9) + " has out of range value.");
    2037           0 :                 ShowContinueError(state,
    2038           0 :                                   format("...Curve minimum value of X = {:.3T} must be <= Minimum Heat Pump Part-Load Ratio = {:.3T}.",
    2039             :                                          minEIRfLowPLRXInput,
    2040           0 :                                          state.dataHVACVarRefFlow->VRF(VRFNum).MinPLR));
    2041           0 :                 ErrorsFound = true;
    2042             :             }
    2043           9 :             if (maxEIRfLowPLRXInput < 1.0) {
    2044           0 :                 ShowWarningError(
    2045           0 :                     state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", suspicious");
    2046           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(9) + " = " + cAlphaArgs(9) + " has unexpected value.");
    2047           0 :                 ShowContinueError(state,
    2048           0 :                                   format("...Curve maximum value of X = {:.3T} should be 1 and will result in lower energy use than expected.",
    2049           0 :                                          maxEIRfLowPLRXInput));
    2050             :             }
    2051           9 :             minEIRfLowPLRXInput = 0.0;
    2052           9 :             maxEIRfLowPLRXInput = 0.0;
    2053             :         }
    2054           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR1 > 0) {
    2055           9 :             Curve::GetCurveMinMaxValues(state, state.dataHVACVarRefFlow->VRF(VRFNum).HeatEIRFPLR1, minEIRfLowPLRXInput, maxEIRfLowPLRXInput);
    2056           9 :             if (minEIRfLowPLRXInput > state.dataHVACVarRefFlow->VRF(VRFNum).MinPLR) {
    2057           0 :                 ShowWarningError(
    2058           0 :                     state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2059           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(20) + " = " + cAlphaArgs(20) + " has out of range value.");
    2060           0 :                 ShowContinueError(state,
    2061           0 :                                   format("...Curve minimum value of X = {:.3T} must be <= Minimum Heat Pump Part-Load Ratio = {:.3T}.",
    2062             :                                          minEIRfLowPLRXInput,
    2063           0 :                                          state.dataHVACVarRefFlow->VRF(VRFNum).MinPLR));
    2064           0 :                 ErrorsFound = true;
    2065             :             }
    2066           9 :             if (maxEIRfLowPLRXInput < 1.0) {
    2067           0 :                 ShowWarningError(
    2068           0 :                     state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", suspicious");
    2069           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(20) + " = " + cAlphaArgs(20) + " has unexpected value.");
    2070           0 :                 ShowContinueError(state,
    2071           0 :                                   format("...Curve maximum value of X = {:.3T} should be 1 and will result in lower energy use than expected.",
    2072           0 :                                          maxEIRfLowPLRXInput));
    2073             :             }
    2074             :         }
    2075             : 
    2076           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MasterZonePtr = UtilityRoutines::FindItemInList(cAlphaArgs(24), state.dataHeatBal->Zone);
    2077             : 
    2078           9 :         if (UtilityRoutines::SameString(cAlphaArgs(25), "LoadPriority")) {
    2079           8 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::LoadPriority;
    2080           1 :         } else if (UtilityRoutines::SameString(cAlphaArgs(25), "ZonePriority")) {
    2081           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ZonePriority;
    2082           1 :         } else if (UtilityRoutines::SameString(cAlphaArgs(25), "ThermostatOffsetPriority")) {
    2083           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ThermostatOffsetPriority;
    2084           1 :         } else if (UtilityRoutines::SameString(cAlphaArgs(25), "Scheduled")) {
    2085           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ScheduledPriority;
    2086           1 :         } else if (UtilityRoutines::SameString(cAlphaArgs(25), "MasterThermostatPriority")) {
    2087           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::MasterThermostatPriority;
    2088           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).MasterZonePtr == 0) {
    2089           0 :                 ShowSevereError(state, cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2090           0 :                 ShowContinueError(state, cAlphaFieldNames(24) + " must be entered when " + cAlphaFieldNames(25) + " = " + cAlphaArgs(25));
    2091           0 :                 ErrorsFound = true;
    2092             :             }
    2093             :         } else {
    2094           0 :             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2095           0 :             ShowContinueError(state, "Illegal " + cAlphaFieldNames(25) + " = " + cAlphaArgs(25));
    2096           0 :             ErrorsFound = true;
    2097             :         }
    2098             : 
    2099           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority == ThermostatCtrlType::ScheduledPriority) {
    2100           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPriorityPtr = GetScheduleIndex(state, cAlphaArgs(26));
    2101           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).SchedPriorityPtr == 0) {
    2102           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2103           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(26) + " = " + cAlphaArgs(26) + " not found.");
    2104           0 :                 ShowContinueError(state, "A schedule name is required when " + cAlphaFieldNames(25) + " = " + cAlphaArgs(25));
    2105           0 :                 ErrorsFound = true;
    2106             :             }
    2107             :         }
    2108             : 
    2109           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr =
    2110           9 :             UtilityRoutines::FindItemInList(cAlphaArgs(27), state.dataHVACVarRefFlow->TerminalUnitList);
    2111           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr == 0) {
    2112           0 :             ShowSevereError(state, cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2113           0 :             ShowContinueError(state, cAlphaFieldNames(27) + " = " + cAlphaArgs(27) + " not found.");
    2114           0 :             ErrorsFound = true;
    2115             :         }
    2116             : 
    2117           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed = false;
    2118           9 :         if (!lAlphaFieldBlanks(28)) {
    2119           9 :             if (UtilityRoutines::SameString(cAlphaArgs(28), "No")) {
    2120           8 :                 state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed = false;
    2121           1 :             } else if (UtilityRoutines::SameString(cAlphaArgs(28), "Yes")) {
    2122           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed = true;
    2123             :             } else {
    2124           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2125           0 :                 ShowContinueError(state, "Illegal " + cAlphaFieldNames(28) + " = " + cAlphaArgs(28));
    2126           0 :                 ErrorsFound = true;
    2127             :             }
    2128             :         }
    2129             : 
    2130           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EquivPipeLngthCool = rNumericArgs(11);
    2131           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).VertPipeLngth = rNumericArgs(12);
    2132           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthCoolPtr = GetCurveIndex(state, cAlphaArgs(29));
    2133           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthCoolPtr > 0) {
    2134             :             // Verify Curve Object, only legal type is linear, quadratic, cubic, or biquadratic
    2135          27 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2136           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthCoolPtr, // Curve index
    2137             :                                                  {1, 2},                                                 // Valid dimensions
    2138             :                                                  RoutineName,                                            // Routine name
    2139             :                                                  cCurrentModuleObject,                                   // Object Type
    2140           9 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,             // Object Name
    2141           9 :                                                  cAlphaFieldNames(29));                                  // Field Name
    2142             :         }
    2143           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).PCFHeightCool = rNumericArgs(13);
    2144             : 
    2145           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EquivPipeLngthHeat = rNumericArgs(14);
    2146           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthHeatPtr = GetCurveIndex(state, cAlphaArgs(30));
    2147           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthHeatPtr > 0) {
    2148             :             // Verify Curve Object, only legal type is linear, quadratic, cubic, or biquadratic
    2149           0 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2150           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).PCFLengthHeatPtr, // Curve index
    2151             :                                                  {1, 2},                                                 // Valid dimensions
    2152             :                                                  RoutineName,                                            // Routine name
    2153             :                                                  cCurrentModuleObject,                                   // Object Type
    2154           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFNum).Name,             // Object Name
    2155           0 :                                                  cAlphaFieldNames(30));                                  // Field Name
    2156             :         }
    2157             : 
    2158           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).PCFHeightHeat = rNumericArgs(15);
    2159             : 
    2160           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CCHeaterPower = rNumericArgs(16);
    2161           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).NumCompressors = rNumericArgs(17);
    2162           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSizeRatio = rNumericArgs(18);
    2163           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCCHeater = rNumericArgs(19);
    2164             : 
    2165           9 :         if (!lAlphaFieldBlanks(31)) {
    2166           9 :             if (UtilityRoutines::SameString(cAlphaArgs(31), "ReverseCycle"))
    2167           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    2168           9 :             if (UtilityRoutines::SameString(cAlphaArgs(31), "Resistive"))
    2169           9 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::Resistive;
    2170           9 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Invalid) {
    2171           0 :                 ShowSevereError(state,
    2172           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(31) +
    2173           0 :                                     " not found: " + cAlphaArgs(31));
    2174           0 :                 ErrorsFound = true;
    2175             :             }
    2176             :         } else {
    2177           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    2178             :         }
    2179             : 
    2180           9 :         if (!lAlphaFieldBlanks(32)) {
    2181           9 :             if (UtilityRoutines::SameString(cAlphaArgs(32), "Timed"))
    2182           9 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    2183           9 :             if (UtilityRoutines::SameString(cAlphaArgs(32), "OnDemand"))
    2184           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    2185           9 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::Invalid) {
    2186           0 :                 ShowSevereError(state,
    2187           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(32) +
    2188           0 :                                     " not found: " + cAlphaArgs(32));
    2189           0 :                 ErrorsFound = true;
    2190             :             }
    2191             :         } else {
    2192           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    2193             :         }
    2194             : 
    2195           9 :         if (!lAlphaFieldBlanks(33)) {
    2196           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr = GetCurveIndex(state, cAlphaArgs(33));
    2197           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr > 0) {
    2198             :                 // Verify Curve Object, expected type is BiQuadratic
    2199           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2200           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr, // Curve index
    2201             :                                                      {2},                                                 // Valid dimensions
    2202             :                                                      RoutineName,                                         // Routine name
    2203             :                                                      cCurrentModuleObject,                                // Object Type
    2204           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,          // Object Name
    2205           0 :                                                      cAlphaFieldNames(33));                               // Field Name
    2206             :             } else {
    2207           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
    2208           0 :                     ShowSevereError(state,
    2209           0 :                                     cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(33) +
    2210           0 :                                         " not found:" + cAlphaArgs(33));
    2211           0 :                     ErrorsFound = true;
    2212             :                 }
    2213             :             }
    2214             :         } else {
    2215           9 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
    2216           0 :                 ShowSevereError(state,
    2217           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(33) +
    2218           0 :                                     " not found:" + cAlphaArgs(33));
    2219           0 :                 ErrorsFound = true;
    2220             :             }
    2221             :         }
    2222             : 
    2223           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostFraction = rNumericArgs(20);
    2224           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity = rNumericArgs(21);
    2225           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity == 0.0 &&
    2226           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    2227           0 :             ShowWarningError(state,
    2228           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cNumericFieldNames(21) +
    2229             :                                  " = 0.0 for defrost strategy = RESISTIVE.");
    2230             :         }
    2231             : 
    2232           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATDefrost = rNumericArgs(22);
    2233             : 
    2234           9 :         if (!lAlphaFieldBlanks(35)) {
    2235           9 :             if (UtilityRoutines::SameString(cAlphaArgs(34), "AirCooled"))
    2236           8 :                 state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2237           9 :             if (UtilityRoutines::SameString(cAlphaArgs(34), "EvaporativelyCooled"))
    2238           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    2239           9 :             if (UtilityRoutines::SameString(cAlphaArgs(34), "WaterCooled")) {
    2240           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    2241           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).VRFType = PlantEquipmentType::HeatPumpVRF;
    2242           1 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatingPerformanceOATType == DataHVACGlobals::WetBulbIndicator) {
    2243           0 :                     ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2244           0 :                     ShowContinueError(state, cAlphaFieldNames(34) + " = " + cAlphaArgs(34));
    2245           0 :                     ShowContinueError(state, "Illegal " + cAlphaFieldNames(19) + " input for this object = " + cAlphaArgs(19));
    2246           0 :                     ShowContinueError(state, "... input must be DRYBULBTEMPERATURE when Condenser Type is WaterCooled.");
    2247           0 :                     ShowContinueError(state, "... " + cAlphaFieldNames(19) + " will be reset to DRYBULBTEMPERATURE and simulation continues.");
    2248             :                 }
    2249             :             }
    2250           9 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType == DataHeatBalance::RefrigCondenserType::Invalid) {
    2251           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2252           0 :                 ShowContinueError(state, "Illegal " + cAlphaFieldNames(34) + " = " + cAlphaArgs(34));
    2253           0 :                 ErrorsFound = true;
    2254             :             }
    2255             :         } else {
    2256           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2257             :         }
    2258             : 
    2259             :         // outdoor condenser node
    2260           9 :         if (lAlphaFieldBlanks(35)) {
    2261           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum = 0;
    2262             :         } else {
    2263           9 :             switch (state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType) {
    2264           8 :             case DataHeatBalance::RefrigCondenserType::Air:
    2265             :             case DataHeatBalance::RefrigCondenserType::Evap: {
    2266           8 :                 state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum =
    2267          24 :                     GetOnlySingleNode(state,
    2268           8 :                                       cAlphaArgs(35),
    2269             :                                       ErrorsFound,
    2270             :                                       DataLoopNode::ConnectionObjectType::AirConditionerVariableRefrigerantFlow,
    2271           8 :                                       state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    2272             :                                       DataLoopNode::NodeFluidType::Air,
    2273             :                                       DataLoopNode::ConnectionType::OutsideAirReference,
    2274             :                                       NodeInputManager::CompFluidStream::Primary,
    2275           8 :                                       ObjectIsNotParent);
    2276           8 :                 if (!CheckOutAirNodeNumber(state, state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum)) {
    2277           0 :                     ShowSevereError(state,
    2278           0 :                                     cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(35) +
    2279           0 :                                         " not a valid Outdoor Air Node = " + cAlphaArgs(35));
    2280           0 :                     ShowContinueError(state, "...node name does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    2281           0 :                     ErrorsFound = true;
    2282             :                 }
    2283           8 :             } break;
    2284           1 :             case DataHeatBalance::RefrigCondenserType::Water: {
    2285           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum =
    2286           3 :                     GetOnlySingleNode(state,
    2287           1 :                                       cAlphaArgs(35),
    2288             :                                       ErrorsFound,
    2289             :                                       DataLoopNode::ConnectionObjectType::AirConditionerVariableRefrigerantFlow,
    2290           1 :                                       state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    2291             :                                       DataLoopNode::NodeFluidType::Water,
    2292             :                                       DataLoopNode::ConnectionType::Inlet,
    2293             :                                       NodeInputManager::CompFluidStream::Secondary,
    2294           1 :                                       ObjectIsNotParent);
    2295           1 :             } break;
    2296           0 :             default:
    2297           0 :                 break;
    2298             :             }
    2299             :         }
    2300             : 
    2301           9 :         if (!lAlphaFieldBlanks(36) && state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2302           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).CondenserOutletNodeNum =
    2303           3 :                 GetOnlySingleNode(state,
    2304           1 :                                   cAlphaArgs(36),
    2305             :                                   ErrorsFound,
    2306             :                                   DataLoopNode::ConnectionObjectType::AirConditionerVariableRefrigerantFlow,
    2307           1 :                                   state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    2308             :                                   DataLoopNode::NodeFluidType::Water,
    2309             :                                   DataLoopNode::ConnectionType::Outlet,
    2310             :                                   NodeInputManager::CompFluidStream::Secondary,
    2311           1 :                                   ObjectIsNotParent);
    2312           2 :             TestCompSet(
    2313           1 :                 state, cCurrentModuleObject, state.dataHVACVarRefFlow->VRF(VRFNum).Name, cAlphaArgs(35), cAlphaArgs(36), "Condenser Water Nodes");
    2314           8 :         } else if (lAlphaFieldBlanks(36) && state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2315           0 :             ShowSevereError(state,
    2316           0 :                             cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(36) + " is blank.");
    2317           0 :             ShowContinueError(state, "...node name must be entered when Condenser Type = WaterCooled.");
    2318           0 :             ErrorsFound = true;
    2319             :         }
    2320             : 
    2321           9 :         if (lAlphaFieldBlanks(23)) {
    2322           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2323           0 :                 ShowSevereError(state,
    2324           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cNumericFieldNames(23) +
    2325             :                                     " is blank.");
    2326           0 :                 ShowContinueError(state, "...input is required when " + cAlphaFieldNames(34) + " = " + cAlphaArgs(34));
    2327           0 :                 ErrorsFound = true;
    2328             :             }
    2329             :         } else {
    2330           9 :             state.dataHVACVarRefFlow->VRF(VRFNum).WaterCondVolFlowRate = rNumericArgs(23);
    2331             :         }
    2332           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapCondEffectiveness = rNumericArgs(24);
    2333           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapCondAirVolFlowRate = rNumericArgs(25);
    2334           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapCondPumpPower = rNumericArgs(26);
    2335             : 
    2336             :         // Get Water System tank connections
    2337             :         // A37, \field Supply Water Storage Tank Name
    2338           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterSupplyName = cAlphaArgs(37);
    2339           9 :         if (lAlphaFieldBlanks(37)) {
    2340           9 :             state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterSupplyMode = EvapWaterSupply::FromMains;
    2341             :         } else {
    2342           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterSupplyMode = EvapWaterSupply::FromTank;
    2343           0 :             SetupTankDemandComponent(state,
    2344           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,
    2345             :                                      cCurrentModuleObject,
    2346           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterSupplyName,
    2347             :                                      ErrorsFound,
    2348           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterSupTankID,
    2349           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).EvapWaterTankDemandARRID);
    2350             :         }
    2351             : 
    2352             :         //   Basin heater power as a function of temperature must be greater than or equal to 0
    2353           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterPowerFTempDiff = rNumericArgs(27);
    2354           9 :         if (rNumericArgs(27) < 0.0) {
    2355           0 :             ShowSevereError(state,
    2356           0 :                             cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(27) +
    2357             :                                 " must be >= 0");
    2358           0 :             ErrorsFound = true;
    2359             :         }
    2360             : 
    2361           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterSetPointTemp = rNumericArgs(28);
    2362           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterPowerFTempDiff > 0.0) {
    2363           0 :             if (NumNums < 27) {
    2364           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterSetPointTemp = 2.0;
    2365             :             }
    2366           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterSetPointTemp < 2.0) {
    2367           0 :                 ShowWarningError(state,
    2368           0 :                                  cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(28) +
    2369             :                                      " is less than 2 deg C. Freezing could occur.");
    2370             :             }
    2371             :         }
    2372             : 
    2373           9 :         if (!lAlphaFieldBlanks(38)) {
    2374           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, cAlphaArgs(38));
    2375           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).BasinHeaterSchedulePtr == 0) {
    2376           0 :                 ShowWarningError(state,
    2377           0 :                                  cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cAlphaFieldNames(38) +
    2378           0 :                                      " = \"" + cAlphaArgs(38) + "\" was not found.");
    2379           0 :                 ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    2380             :             }
    2381             :         }
    2382             : 
    2383           9 :         state.dataHVACVarRefFlow->VRF(VRFNum).FuelType = "Electricity";
    2384           9 :         if (!lAlphaFieldBlanks(39)) {
    2385             :             // A39; \field Fuel type, Validate fuel type input
    2386           9 :             bool FuelTypeError(false);
    2387          27 :             UtilityRoutines::ValidateFuelTypeWithAssignResourceTypeNum(
    2388          27 :                 cAlphaArgs(39), state.dataHVACVarRefFlow->VRF(VRFNum).FuelType, state.dataHVACVarRefFlow->VRF(VRFNum).FuelTypeNum, FuelTypeError);
    2389           9 :             if (FuelTypeError) {
    2390           0 :                 ShowSevereError(state,
    2391           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cAlphaFieldNames(39) +
    2392           0 :                                     " not found = " + cAlphaArgs(39));
    2393           0 :                 ShowContinueError(
    2394             :                     state, "Valid choices are Electricity, NaturalGas, Propane, Diesel, Gasoline, FuelOilNo1, FuelOilNo2, OtherFuel1 or OtherFuel2");
    2395           0 :                 ErrorsFound = true;
    2396           0 :                 FuelTypeError = false;
    2397             :             }
    2398             :         }
    2399             : 
    2400           9 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed) {
    2401           1 :             if (lAlphaFieldBlanks(29)) {
    2402           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery =
    2403           0 :                     max(state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating);
    2404             :             } else {
    2405           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery = rNumericArgs(29);
    2406           2 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery < state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling ||
    2407           1 :                     state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery < state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating) {
    2408           0 :                     ShowWarningError(state,
    2409           0 :                                      cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(29) +
    2410             :                                          " is less than the minimum temperature in heat pump mode.");
    2411           0 :                     ShowContinueError(state,
    2412           0 :                                       format("...{} = {:.2T} C", cNumericFieldNames(29), state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery));
    2413           0 :                     ShowContinueError(
    2414             :                         state,
    2415           0 :                         format("...Minimum Outdoor Temperature in Cooling Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling));
    2416           0 :                     ShowContinueError(
    2417             :                         state,
    2418           0 :                         format("...Minimum Outdoor Temperature in Heating Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating));
    2419           0 :                     ShowContinueError(state,
    2420             :                                       "...Minimum Outdoor Temperature in Heat Recovery Mode reset to greater of cooling or heating minimum "
    2421             :                                       "temperature and simulation continues.");
    2422           0 :                     state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery =
    2423           0 :                         max(state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating);
    2424           0 :                     ShowContinueError(
    2425             :                         state,
    2426           0 :                         format("... adjusted {} = {:.2T} C", cNumericFieldNames(29), state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery));
    2427             :                 }
    2428             :             }
    2429           1 :             if (lAlphaFieldBlanks(30)) {
    2430           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery =
    2431           1 :                     min(state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating);
    2432             :             } else {
    2433           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery = rNumericArgs(30);
    2434           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery > state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling ||
    2435           0 :                     state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery > state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating) {
    2436           0 :                     ShowWarningError(state,
    2437           0 :                                      cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(30) +
    2438             :                                          " is greater than the maximum temperature in heat pump mode.");
    2439           0 :                     ShowContinueError(state,
    2440           0 :                                       format("...{} = {:.2T} C", cNumericFieldNames(30), state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery));
    2441           0 :                     ShowContinueError(
    2442             :                         state,
    2443           0 :                         format("...Maximum Outdoor Temperature in Cooling Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling));
    2444           0 :                     ShowContinueError(
    2445             :                         state,
    2446           0 :                         format("...Maximum Outdoor Temperature in Heating Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    2447           0 :                     ShowContinueError(state,
    2448             :                                       "...Maximum Outdoor Temperature in Heat Recovery Mode reset to lesser of cooling or heating minimum "
    2449             :                                       "temperature and simulation continues.");
    2450           0 :                     state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery =
    2451           0 :                         min(state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating);
    2452           0 :                     ShowContinueError(
    2453             :                         state,
    2454           0 :                         format("... adjusted {} = {:.2T} C", cNumericFieldNames(30), state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery));
    2455             :                 }
    2456             :             }
    2457             : 
    2458           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTCool = GetCurveIndex(state, cAlphaArgs(40));
    2459           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTCool > 0) {
    2460             :                 // Verify Curve Object, only legal type is bi-quadratic or linear, quadratic, or cubic
    2461           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2462           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTCool, // Curve index
    2463             :                                                      {1, 2},                                            // Valid dimensions
    2464             :                                                      RoutineName,                                       // Routine name
    2465             :                                                      cCurrentModuleObject,                              // Object Type
    2466           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    2467           0 :                                                      cAlphaFieldNames(40));                             // Field Name
    2468             :             }
    2469           1 :             if (!lNumericFieldBlanks(31)) {
    2470           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialCoolCapFrac = rNumericArgs(31);
    2471             :             }
    2472           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRCoolCapTC = rNumericArgs(32);
    2473           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTCool = GetCurveIndex(state, cAlphaArgs(41));
    2474           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTCool > 0) {
    2475             :                 // Verify Curve Object, only legal type is bi-quadratic or linear, quadratic, or cubic
    2476           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2477           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTCool, // Curve index
    2478             :                                                      {1, 2},                                            // Valid dimensions
    2479             :                                                      RoutineName,                                       // Routine name
    2480             :                                                      cCurrentModuleObject,                              // Object Type
    2481           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    2482           0 :                                                      cAlphaFieldNames(41));                             // Field Name
    2483             :             }
    2484           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialCoolEIRFrac = rNumericArgs(33);
    2485           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRCoolEIRTC = rNumericArgs(34);
    2486             : 
    2487             :             //  INTEGER      :: HRCAPFTHeat                =0   ! Index to heat capacity as a function of temperature curve for heat recovery
    2488             :             //  REAL(r64)    :: HRInitialHeatCapFrac       =0.0d0 ! Fractional heating degradation at the start of heat recovery from heating mode
    2489             :             //  REAL(r64)    :: HRHeatCapTC                =0.0d0 ! Time constant used to recover from initial degradation in heating heat
    2490             :             //  recovery
    2491           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTHeat = GetCurveIndex(state, cAlphaArgs(42));
    2492           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTHeat > 0) {
    2493             :                 // Verify Curve Object, only legal type is bi-quadratic or linear, quadratic, or cubic
    2494           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2495           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).HRCAPFTHeat, // Curve index
    2496             :                                                      {1, 2},                                            // Valid dimensions
    2497             :                                                      RoutineName,                                       // Routine name
    2498             :                                                      cCurrentModuleObject,                              // Object Type
    2499           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    2500           0 :                                                      cAlphaFieldNames(42));                             // Field Name
    2501             :             }
    2502           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialHeatCapFrac = rNumericArgs(35);
    2503           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRHeatCapTC = rNumericArgs(36);
    2504             : 
    2505             :             //  INTEGER      :: HREIRFTHeat                =0   ! Index to heat EIR as a function of temperature curve for heat recovery
    2506             :             //  REAL(r64)    :: HRInitialHeatEIRFrac       =0.0d0 ! Fractional EIR degradation at the start of heat recovery from heating mode
    2507             :             //  REAL(r64)    :: HRHeatEIRTC                =0.0d0 ! Time constant used to recover from initial degradation in heating heat
    2508             :             //  recovery
    2509           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTHeat = GetCurveIndex(state, cAlphaArgs(43));
    2510           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTHeat > 0) {
    2511             :                 // Verify Curve Object, only legal type is bi-quadratic or linear, quadratic, or cubic
    2512           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2513           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).HREIRFTHeat, // Curve index
    2514             :                                                      {1, 2},                                            // Valid dimensions
    2515             :                                                      RoutineName,                                       // Routine name
    2516             :                                                      cCurrentModuleObject,                              // Object Type
    2517           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,        // Object Name
    2518           0 :                                                      cAlphaFieldNames(43));                             // Field Name
    2519             :             }
    2520           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialHeatEIRFrac = rNumericArgs(37);
    2521           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).HRHeatEIRTC = rNumericArgs(38);
    2522             :         }
    2523             :     }
    2524             : 
    2525             :     // Read all VRF condenser objects: Algorithm Type 2_physics based model (VRF-FluidTCtrl-HP)
    2526          11 :     cCurrentModuleObject = "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl";
    2527          13 :     for (VRFNum = state.dataHVACVarRefFlow->NumVRFCond_SysCurve + 1;
    2528          13 :          VRFNum <= state.dataHVACVarRefFlow->NumVRFCond_SysCurve + state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP;
    2529             :          ++VRFNum) {
    2530           2 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2531             :                                                                  cCurrentModuleObject,
    2532             :                                                                  VRFNum,
    2533             :                                                                  cAlphaArgs,
    2534             :                                                                  NumAlphas,
    2535             :                                                                  rNumericArgs,
    2536             :                                                                  NumNums,
    2537             :                                                                  IOStat,
    2538             :                                                                  lNumericFieldBlanks,
    2539             :                                                                  lAlphaFieldBlanks,
    2540             :                                                                  cAlphaFieldNames,
    2541             :                                                                  cNumericFieldNames);
    2542           4 :         GlobalNames::VerifyUniqueInterObjectName(
    2543           4 :             state, state.dataHVACVarRefFlow->VrfUniqueNames, cAlphaArgs(1), cCurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    2544             : 
    2545           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).Name = cAlphaArgs(1);
    2546           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFSystemTypeNum = VRF_HeatPump;
    2547           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFAlgorithmTypeNum = AlgorithmType::FluidTCtrl;
    2548           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).FuelType = "Electricity";
    2549           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).FuelTypeNum = DataGlobalConstants::ResourceType::Electricity;
    2550             : 
    2551           2 :         if (lAlphaFieldBlanks(2)) {
    2552           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    2553             :         } else {
    2554           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2));
    2555           2 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr == 0) {
    2556           0 :                 ShowSevereError(state, cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" invalid data");
    2557           0 :                 ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\".");
    2558           0 :                 ErrorsFound = true;
    2559             :             }
    2560             :         }
    2561             : 
    2562           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr =
    2563           2 :             UtilityRoutines::FindItemInList(cAlphaArgs(3), state.dataHVACVarRefFlow->TerminalUnitList, state.dataHVACVarRefFlow->NumVRFTULists);
    2564           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr == 0) {
    2565           0 :             ShowSevereError(state, cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2566           0 :             ShowContinueError(state, cAlphaFieldNames(3) + " = " + cAlphaArgs(3) + " not found.");
    2567           0 :             ErrorsFound = true;
    2568             :         }
    2569             : 
    2570             :         // Refrigerant type
    2571           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefrigerantName = cAlphaArgs(4);
    2572           2 :         if (state.dataFluidProps->GetInput) {
    2573           1 :             EnergyPlus::FluidProperties::GetFluidPropertiesData(state);
    2574           1 :             state.dataFluidProps->GetInput = false;
    2575             :         }
    2576           6 :         if (UtilityRoutines::FindItemInList(state.dataHVACVarRefFlow->VRF(VRFNum).RefrigerantName,
    2577           2 :                                             state.dataFluidProps->RefrigData,
    2578           4 :                                             state.dataFluidProps->NumOfRefrigerants) == 0) {
    2579           0 :             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2580           0 :             ShowContinueError(state, "Illegal " + cAlphaFieldNames(4) + " = " + cAlphaArgs(4));
    2581           0 :             ErrorsFound = true;
    2582             :         }
    2583             : 
    2584           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity = rNumericArgs(1);
    2585           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity = rNumericArgs(2);
    2586           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPower =
    2587           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    2588           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCapacity = state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    2589           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedHeatCapacity =
    2590           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity * (1 + state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity);
    2591           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCapacity = state.dataHVACVarRefFlow->VRF(VRFNum).RatedHeatCapacity;
    2592             : 
    2593             :         // Reference system COP
    2594           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCOP = 1 / state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity;
    2595           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCOP = 1 / state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity + 1;
    2596             : 
    2597             :         // OA temperature range for VRF-HP operations
    2598           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling = rNumericArgs(3);
    2599           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling = rNumericArgs(4);
    2600           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating = rNumericArgs(5);
    2601           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating = rNumericArgs(6);
    2602           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling) {
    2603           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2604           0 :             ShowContinueError(state,
    2605           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    2606             :                                      cNumericFieldNames(3),
    2607           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling,
    2608           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling));
    2609           0 :             ErrorsFound = true;
    2610             :         }
    2611           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating) {
    2612           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2613           0 :             ShowContinueError(state,
    2614           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    2615             :                                      cNumericFieldNames(5),
    2616           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating,
    2617           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    2618           0 :             ErrorsFound = true;
    2619             :         }
    2620             : 
    2621             :         // Reference OU SH/SC
    2622           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).SH = rNumericArgs(7);
    2623           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).SC = rNumericArgs(8);
    2624             : 
    2625           2 :         if (UtilityRoutines::SameString(cAlphaArgs(5), "VariableTemp")) {
    2626           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 1;
    2627           2 :         } else if (UtilityRoutines::SameString(cAlphaArgs(5), "ConstantTemp")) {
    2628           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 2;
    2629             :         } else {
    2630           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 1;
    2631             :         }
    2632             : 
    2633             :         // Reference IU Te/Tc for IU Control Algorithm: ConstantTemp
    2634           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapTempFixed = rNumericArgs(9);
    2635           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondTempFixed = rNumericArgs(10);
    2636             : 
    2637             :         // Bounds of Te/Tc for IU Control Algorithm: VariableTemp
    2638           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow = rNumericArgs(11);
    2639           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh = rNumericArgs(12);
    2640           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow = rNumericArgs(13);
    2641           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh = rNumericArgs(14);
    2642           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow >= state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh) {
    2643           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2644           0 :             ShowContinueError(state,
    2645           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    2646             :                                      cNumericFieldNames(11),
    2647           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow,
    2648           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh));
    2649           0 :             ErrorsFound = true;
    2650             :         }
    2651           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow >= state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh) {
    2652           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2653           0 :             ShowContinueError(state,
    2654           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    2655             :                                      cNumericFieldNames(13),
    2656           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow,
    2657           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh));
    2658           0 :             ErrorsFound = true;
    2659             :         }
    2660             : 
    2661             :         // Get OU fan data
    2662           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPowerPerCapcity = rNumericArgs(15);
    2663           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRatePerCapcity = rNumericArgs(16);
    2664           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPower =
    2665           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    2666           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRate =
    2667           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRatePerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    2668             : 
    2669             :         // OUEvapTempCurve
    2670           2 :         int indexOUEvapTempCurve = GetCurveIndex(state, cAlphaArgs(6)); // convert curve name to index number
    2671             :         // Verify curve name and type
    2672           2 :         if (indexOUEvapTempCurve == 0) {
    2673           0 :             if (lAlphaFieldBlanks(6)) {
    2674           0 :                 ShowSevereError(state,
    2675           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", missing");
    2676           0 :                 ShowContinueError(state, "...required " + cAlphaFieldNames(6) + " is blank.");
    2677             :             } else {
    2678           0 :                 ShowSevereError(state,
    2679           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2680           0 :                 ShowContinueError(state, "...not found " + cAlphaFieldNames(6) + "=\"" + cAlphaArgs(6) + "\".");
    2681             :             }
    2682           0 :             ErrorsFound = true;
    2683             :         } else {
    2684             :             {
    2685           2 :                 if (state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).curveType == Curve::CurveType::Quadratic) {
    2686           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C1Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[0];
    2687           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C2Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[1];
    2688           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C3Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[2];
    2689             : 
    2690             :                 } else {
    2691           0 :                     ShowSevereError(
    2692           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2693           0 :                     ShowContinueError(
    2694             :                         state,
    2695           0 :                         format("...illegal {} type for this object = {}",
    2696             :                                cAlphaFieldNames(6),
    2697           0 :                                Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).curveType)]));
    2698           0 :                     ShowContinueError(state, "... Curve type must be Quadratic.");
    2699           0 :                     ErrorsFound = true;
    2700             :                 }
    2701             :             }
    2702             :         }
    2703             : 
    2704             :         // OUCondTempCurve
    2705           2 :         int indexOUCondTempCurve = GetCurveIndex(state, cAlphaArgs(7)); // convert curve name to index number
    2706             :         // Verify curve name and type
    2707           2 :         if (indexOUCondTempCurve == 0) {
    2708           0 :             if (lAlphaFieldBlanks(7)) {
    2709           0 :                 ShowSevereError(state,
    2710           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", missing");
    2711           0 :                 ShowContinueError(state, "...required " + cAlphaFieldNames(7) + " is blank.");
    2712             :             } else {
    2713           0 :                 ShowSevereError(state,
    2714           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2715           0 :                 ShowContinueError(state, "...not found " + cAlphaFieldNames(7) + "=\"" + cAlphaArgs(7) + "\".");
    2716             :             }
    2717           0 :             ErrorsFound = true;
    2718             :         } else {
    2719             :             {
    2720           2 :                 if (state.dataCurveManager->PerfCurve(indexOUCondTempCurve).curveType == Curve::CurveType::Quadratic) {
    2721           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C1Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[0];
    2722           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C2Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[1];
    2723           2 :                     state.dataHVACVarRefFlow->VRF(VRFNum).C3Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[2];
    2724             : 
    2725             :                 } else {
    2726           0 :                     ShowSevereError(
    2727           0 :                         state, std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    2728           0 :                     ShowContinueError(
    2729             :                         state,
    2730           0 :                         format("...illegal {} type for this object = {}",
    2731             :                                cAlphaFieldNames(7),
    2732           0 :                                Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexOUCondTempCurve).curveType)]));
    2733           0 :                     ShowContinueError(state, "... Curve type must be Quadratic.");
    2734           0 :                     ErrorsFound = true;
    2735             :                 }
    2736             :             }
    2737             :         }
    2738             : 
    2739             :         // Pipe parameters
    2740           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipDiaSuc = rNumericArgs(17);
    2741           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipDiaDis = rNumericArgs(17);
    2742           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen = rNumericArgs(18);
    2743           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = rNumericArgs(19);
    2744           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipHei = rNumericArgs(20);
    2745           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipInsThi = rNumericArgs(21);
    2746           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipInsCon = rNumericArgs(22);
    2747             : 
    2748             :         // Check the RefPipEquLen
    2749           2 :         if (lNumericFieldBlanks(19) && !lNumericFieldBlanks(18)) {
    2750           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = 1.2 * state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen;
    2751           0 :             ShowWarningError(state,
    2752           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", \" " + cNumericFieldNames(19) +
    2753             :                                  "\" is calculated based on");
    2754           0 :             ShowContinueError(state, "...the provided \"" + cNumericFieldNames(18) + "\" value.");
    2755             :         }
    2756           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen < state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen) {
    2757           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = 1.2 * state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen;
    2758           0 :             ShowWarningError(state,
    2759           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid \" " + cNumericFieldNames(19) +
    2760             :                                  "\" value.");
    2761           0 :             ShowContinueError(state, "...Equivalent length of main pipe should be greater than or equal to the actual length.");
    2762           0 :             ShowContinueError(state, "...The value is recalculated based on the provided \"" + cNumericFieldNames(18) + "\" value.");
    2763             :         }
    2764             : 
    2765             :         // Crank case
    2766           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CCHeaterPower = rNumericArgs(23);
    2767           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).NumCompressors = rNumericArgs(24);
    2768           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSizeRatio = rNumericArgs(25);
    2769           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCCHeater = rNumericArgs(26);
    2770             : 
    2771             :         // Defrost
    2772           2 :         if (!lAlphaFieldBlanks(8)) {
    2773           0 :             if (UtilityRoutines::SameString(cAlphaArgs(8), "ReverseCycle"))
    2774           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    2775           0 :             if (UtilityRoutines::SameString(cAlphaArgs(8), "Resistive"))
    2776           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::Resistive;
    2777           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Invalid) {
    2778           0 :                 ShowSevereError(state,
    2779           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(8) +
    2780           0 :                                     " not found: " + cAlphaArgs(8));
    2781           0 :                 ErrorsFound = true;
    2782             :             }
    2783             :         } else {
    2784           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    2785             :         }
    2786             : 
    2787           2 :         if (!lAlphaFieldBlanks(9)) {
    2788           0 :             if (UtilityRoutines::SameString(cAlphaArgs(9), "Timed"))
    2789           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    2790           0 :             if (UtilityRoutines::SameString(cAlphaArgs(9), "OnDemand"))
    2791           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    2792           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::Invalid) {
    2793           0 :                 ShowSevereError(state,
    2794           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(9) +
    2795           0 :                                     " not found: " + cAlphaArgs(9));
    2796           0 :                 ErrorsFound = true;
    2797             :             }
    2798             :         } else {
    2799           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    2800             :         }
    2801             : 
    2802           2 :         if (!lAlphaFieldBlanks(10)) {
    2803           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr = GetCurveIndex(state, cAlphaArgs(10));
    2804           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr > 0) {
    2805             :                 // Verify Curve Object, expected type is BiQuadratic
    2806           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2807           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr, // Curve index
    2808             :                                                      {2},                                                 // Valid dimensions
    2809             :                                                      RoutineName,                                         // Routine name
    2810             :                                                      cCurrentModuleObject,                                // Object Type
    2811           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,          // Object Name
    2812           0 :                                                      cAlphaFieldNames(10));                               // Field Name
    2813             :             } else {
    2814           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
    2815           0 :                     state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
    2816           0 :                     ShowSevereError(state,
    2817           0 :                                     cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(10) +
    2818           0 :                                         " not found:" + cAlphaArgs(10));
    2819           0 :                     ErrorsFound = true;
    2820             :                 }
    2821             :             }
    2822             :         } else {
    2823           4 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
    2824           2 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
    2825           0 :                 ShowSevereError(state,
    2826           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(10) +
    2827           0 :                                     " not found:" + cAlphaArgs(10));
    2828           0 :                 ErrorsFound = true;
    2829             :             }
    2830             :         }
    2831             : 
    2832           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostFraction = rNumericArgs(27);
    2833           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity = rNumericArgs(28);
    2834           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATDefrost = rNumericArgs(29);
    2835           4 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity == 0.0 &&
    2836           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    2837           0 :             ShowWarningError(state,
    2838           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cNumericFieldNames(28) +
    2839             :                                  " = 0.0 for defrost strategy = RESISTIVE.");
    2840             :         }
    2841             : 
    2842           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompMaxDeltaP = rNumericArgs(30);
    2843             : 
    2844             :         //@@ The control type
    2845           4 :         std::string ThermostatPriorityType = "LoadPriority"; // cAlphaArgs( 25 )
    2846           2 :         if (UtilityRoutines::SameString(ThermostatPriorityType, "LoadPriority")) {
    2847           2 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::LoadPriority;
    2848           0 :         } else if (UtilityRoutines::SameString(ThermostatPriorityType, "ZonePriority")) {
    2849           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ZonePriority;
    2850           0 :         } else if (UtilityRoutines::SameString(ThermostatPriorityType, "ThermostatOffsetPriority")) {
    2851           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ThermostatOffsetPriority;
    2852           0 :         } else if (UtilityRoutines::SameString(ThermostatPriorityType, "Scheduled")) {
    2853           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::ScheduledPriority;
    2854           0 :         } else if (UtilityRoutines::SameString(ThermostatPriorityType, "MasterThermostatPriority")) {
    2855           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::MasterThermostatPriority;
    2856           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).MasterZonePtr == 0) {
    2857           0 :                 ShowSevereError(state, cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2858             :                 //** ShowContinueError(state,  cAlphaFieldNames( 24 ) + " must be entered when " + cAlphaFieldNames( 25 ) + " = " + cAlphaArgs( 25 )
    2859             :                 //);
    2860           0 :                 ErrorsFound = true;
    2861             :             }
    2862             :         } else {
    2863           0 :             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    2864             :             // ShowContinueError(state,  "Illegal " + cAlphaFieldNames( 25 ) + " = " + cAlphaArgs( 25 ) );
    2865           0 :             ErrorsFound = true;
    2866             :         }
    2867             : 
    2868             :         // The new VRF model is Air cooled
    2869           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2870           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum = 0;
    2871             : 
    2872             :         // Evaporative Capacity & Compressor Power Curves corresponding to each Loading Index / compressor speed
    2873           2 :         NumOfCompSpd = rNumericArgs(31);
    2874           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSpeed.dimension(NumOfCompSpd);
    2875           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingCAPFT.dimension(NumOfCompSpd);
    2876           2 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingPWRFT.dimension(NumOfCompSpd);
    2877           2 :         int Count1Index = 31; // the index of the last numeric field before compressor speed entries
    2878           2 :         int Count2Index = 9;  // the index of the last alpha field before capacity/power curves
    2879           8 :         for (NumCompSpd = 1; NumCompSpd <= NumOfCompSpd; NumCompSpd++) {
    2880           6 :             state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSpeed(NumCompSpd) = rNumericArgs(Count1Index + NumCompSpd);
    2881             : 
    2882             :             // Evaporating Capacity Curve
    2883           6 :             if (!lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd)) {
    2884           6 :                 int indexOUEvapCapCurve = GetCurveIndex(state, cAlphaArgs(Count2Index + 2 * NumCompSpd)); // convert curve name to index number
    2885           6 :                 if (indexOUEvapCapCurve == 0) {                                                           // Verify curve name and type
    2886           0 :                     if (lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd)) {
    2887           0 :                         ShowSevereError(state,
    2888           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    2889             :                                             "\", missing");
    2890           0 :                         ShowContinueError(state, "...required " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd) + " is blank.");
    2891             :                     } else {
    2892           0 :                         ShowSevereError(state,
    2893           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    2894             :                                             "\", invalid");
    2895           0 :                         ShowContinueError(state,
    2896           0 :                                           "...not found " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd) + "=\"" +
    2897           0 :                                               cAlphaArgs(Count2Index + 2 * NumCompSpd) + "\".");
    2898             :                     }
    2899           0 :                     ErrorsFound = true;
    2900             :                 } else {
    2901          12 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2902             :                                                          indexOUEvapCapCurve,                             // Curve index
    2903             :                                                          {2},                                             // Valid dimensions
    2904             :                                                          RoutineName,                                     // Routine name
    2905             :                                                          cCurrentModuleObject,                            // Object Type
    2906           6 :                                                          state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    2907           6 :                                                          cAlphaFieldNames(Count2Index + 2 * NumCompSpd)); // Field Name
    2908             : 
    2909           6 :                     if (!ErrorsFound) {
    2910           6 :                         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingCAPFT(NumCompSpd) = indexOUEvapCapCurve;
    2911             :                     }
    2912             :                 }
    2913             :             }
    2914             : 
    2915             :             // Compressor Power Curve
    2916           6 :             if (!lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd + 1)) {
    2917           6 :                 int indexOUCompPwrCurve = GetCurveIndex(state, cAlphaArgs(Count2Index + 2 * NumCompSpd + 1)); // convert curve name to index number
    2918           6 :                 if (indexOUCompPwrCurve == 0) {                                                               // Verify curve name and type
    2919           0 :                     if (lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd + 1)) {
    2920           0 :                         ShowSevereError(state,
    2921           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    2922             :                                             "\", missing");
    2923           0 :                         ShowContinueError(state, "...required " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1) + " is blank.");
    2924             :                     } else {
    2925           0 :                         ShowSevereError(state,
    2926           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    2927             :                                             "\", invalid");
    2928           0 :                         ShowContinueError(state,
    2929           0 :                                           "...not found " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1) + "=\"" +
    2930           0 :                                               cAlphaArgs(Count2Index + 2 * NumCompSpd + 1) + "\".");
    2931             :                     }
    2932           0 :                     ErrorsFound = true;
    2933             :                 } else {
    2934          12 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2935             :                                                          indexOUCompPwrCurve,                                 // Curve index
    2936             :                                                          {2},                                                 // Valid dimensions
    2937             :                                                          RoutineName,                                         // Routine name
    2938             :                                                          cCurrentModuleObject,                                // Object Type
    2939           6 :                                                          state.dataHVACVarRefFlow->VRF(VRFNum).Name,          // Object Name
    2940           6 :                                                          cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1)); // Field Name
    2941             : 
    2942           6 :                     if (!ErrorsFound) {
    2943           6 :                         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingPWRFT(NumCompSpd) = indexOUCompPwrCurve;
    2944             :                     }
    2945             :                 }
    2946             :             }
    2947             :         }
    2948             :     }
    2949             : 
    2950             :     // Read all VRF condenser objects: Algorithm Type 2_physics based model (VRF-FluidTCtrl-HR)
    2951          11 :     cCurrentModuleObject = "AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl:HR";
    2952          12 :     for (VRFNum = state.dataHVACVarRefFlow->NumVRFCond_SysCurve + state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP + 1;
    2953          24 :          VRFNum <= state.dataHVACVarRefFlow->NumVRFCond_SysCurve + state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HP +
    2954          12 :                        state.dataHVACVarRefFlow->NumVRFCond_FluidTCtrl_HR;
    2955             :          ++VRFNum) {
    2956           1 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2957             :                                                                  cCurrentModuleObject,
    2958             :                                                                  VRFNum,
    2959             :                                                                  cAlphaArgs,
    2960             :                                                                  NumAlphas,
    2961             :                                                                  rNumericArgs,
    2962             :                                                                  NumNums,
    2963             :                                                                  IOStat,
    2964             :                                                                  lNumericFieldBlanks,
    2965             :                                                                  lAlphaFieldBlanks,
    2966             :                                                                  cAlphaFieldNames,
    2967             :                                                                  cNumericFieldNames);
    2968           2 :         GlobalNames::VerifyUniqueInterObjectName(
    2969           2 :             state, state.dataHVACVarRefFlow->VrfUniqueNames, cAlphaArgs(1), cCurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    2970             : 
    2971           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).Name = cAlphaArgs(1);
    2972             : 
    2973           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).ThermostatPriority = ThermostatCtrlType::LoadPriority;
    2974           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed = true;
    2975           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFSystemTypeNum = VRF_HeatPump;
    2976           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).VRFAlgorithmTypeNum = AlgorithmType::FluidTCtrl;
    2977           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).FuelType = "Electricity";
    2978           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).FuelTypeNum = DataGlobalConstants::ResourceType::Electricity;
    2979             : 
    2980           1 :         if (lAlphaFieldBlanks(2)) {
    2981           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    2982             :         } else {
    2983           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2));
    2984           1 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).SchedPtr == 0) {
    2985           0 :                 ShowSevereError(state, cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" invalid data");
    2986           0 :                 ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\".");
    2987           0 :                 ErrorsFound = true;
    2988             :             }
    2989             :         }
    2990             : 
    2991           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr =
    2992           1 :             UtilityRoutines::FindItemInList(cAlphaArgs(3), state.dataHVACVarRefFlow->TerminalUnitList, state.dataHVACVarRefFlow->NumVRFTULists);
    2993           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr == 0) {
    2994           0 :             ShowSevereError(state, cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    2995           0 :             ShowContinueError(state, cAlphaFieldNames(3) + " = " + cAlphaArgs(3) + " not found.");
    2996           0 :             ErrorsFound = true;
    2997             :         }
    2998             : 
    2999             :         // Refrigerant type
    3000           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefrigerantName = cAlphaArgs(4);
    3001           1 :         if (state.dataFluidProps->GetInput) {
    3002           1 :             EnergyPlus::FluidProperties::GetFluidPropertiesData(state);
    3003           1 :             state.dataFluidProps->GetInput = false;
    3004             :         }
    3005           3 :         if (UtilityRoutines::FindItemInList(state.dataHVACVarRefFlow->VRF(VRFNum).RefrigerantName,
    3006           1 :                                             state.dataFluidProps->RefrigData,
    3007           2 :                                             state.dataFluidProps->NumOfRefrigerants) == 0) {
    3008           0 :             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRF(VRFNum).Name);
    3009           0 :             ShowContinueError(state, "Illegal " + cAlphaFieldNames(4) + " = " + cAlphaArgs(4));
    3010           0 :             ErrorsFound = true;
    3011             :         }
    3012             : 
    3013           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity = rNumericArgs(1);
    3014           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity = rNumericArgs(2);
    3015           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPower =
    3016           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    3017           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCapacity = state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    3018           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCapacity =
    3019           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity * (1 + state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity);
    3020             : 
    3021             :         // Reference system COP
    3022           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoolingCOP = 1 / state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity;
    3023           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HeatingCOP = 1 / state.dataHVACVarRefFlow->VRF(VRFNum).RatedCompPowerPerCapcity + 1;
    3024             : 
    3025             :         // OA temperature range for VRF-HP operations
    3026           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling = rNumericArgs(3);
    3027           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling = rNumericArgs(4);
    3028           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating = rNumericArgs(5);
    3029           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating = rNumericArgs(6);
    3030           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery = rNumericArgs(7);
    3031           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery = rNumericArgs(8);
    3032           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling) {
    3033           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    3034           0 :             ShowContinueError(state,
    3035           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    3036             :                                      cNumericFieldNames(3),
    3037           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling,
    3038           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling));
    3039           0 :             ErrorsFound = true;
    3040             :         }
    3041           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating) {
    3042           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    3043           0 :             ShowContinueError(state,
    3044           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    3045             :                                      cNumericFieldNames(5),
    3046           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating,
    3047           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    3048           0 :             ErrorsFound = true;
    3049             :         }
    3050           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery >= state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery) {
    3051           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    3052           0 :             ShowContinueError(state,
    3053           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    3054             :                                      cNumericFieldNames(7),
    3055           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating,
    3056           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    3057           0 :             ErrorsFound = true;
    3058             :         }
    3059           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery < state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling &&
    3060           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery < state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating) {
    3061           0 :             ShowWarningError(state,
    3062           0 :                              cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(7) +
    3063             :                                  " is less than the minimum temperature in heat pump mode.");
    3064           0 :             ShowContinueError(state, format("...{} = {:.2T} C", cNumericFieldNames(7), state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery));
    3065           0 :             ShowContinueError(
    3066           0 :                 state, format("...Minimum Outdoor Temperature in Cooling Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling));
    3067           0 :             ShowContinueError(
    3068           0 :                 state, format("...Minimum Outdoor Temperature in Heating Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating));
    3069           0 :             ShowContinueError(state,
    3070             :                               "...Minimum Outdoor Temperature in Heat Recovery Mode reset to lesser of cooling or heating minimum temperature "
    3071             :                               "and simulation continues.");
    3072           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery =
    3073           0 :                 min(state.dataHVACVarRefFlow->VRF(VRFNum).MinOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeating);
    3074           0 :             ShowContinueError(state,
    3075           0 :                               format("... adjusted {} = {:.2T} C", cNumericFieldNames(7), state.dataHVACVarRefFlow->VRF(VRFNum).MinOATHeatRecovery));
    3076             :         }
    3077           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery > state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling &&
    3078           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery > state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating) {
    3079           0 :             ShowWarningError(state,
    3080           0 :                              cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", " + cNumericFieldNames(8) +
    3081             :                                  " is greater than the maximum temperature in heat pump mode.");
    3082           0 :             ShowContinueError(state, format("...{} = {:.2T} C", cNumericFieldNames(8), state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery));
    3083           0 :             ShowContinueError(
    3084           0 :                 state, format("...Maximum Outdoor Temperature in Cooling Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling));
    3085           0 :             ShowContinueError(
    3086           0 :                 state, format("...Maximum Outdoor Temperature in Heating Mode = {:.2T} C", state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating));
    3087           0 :             ShowContinueError(state,
    3088             :                               "...Maximum Outdoor Temperature in Heat Recovery Mode reset to greater of cooling or heating maximum temperature "
    3089             :                               "and simulation continues.");
    3090           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery =
    3091           0 :                 max(state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCooling, state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeating);
    3092           0 :             ShowContinueError(state,
    3093           0 :                               format("... adjusted {} = {:.2T} C", cNumericFieldNames(8), state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATHeatRecovery));
    3094             :         }
    3095             : 
    3096             :         // IU Control Type
    3097           1 :         if (UtilityRoutines::SameString(cAlphaArgs(5), "VariableTemp")) {
    3098           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 1;
    3099           0 :         } else if (UtilityRoutines::SameString(cAlphaArgs(5), "ConstantTemp")) {
    3100           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 2;
    3101             :         } else {
    3102           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).AlgorithmIUCtrl = 1;
    3103             :         }
    3104             : 
    3105             :         // Reference IU Te/Tc for IU Control Algorithm: ConstantTemp
    3106           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).EvapTempFixed = rNumericArgs(9);
    3107           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondTempFixed = rNumericArgs(10);
    3108             : 
    3109             :         // Bounds of Te/Tc for IU Control Algorithm: VariableTemp
    3110           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow = rNumericArgs(11);
    3111           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh = rNumericArgs(12);
    3112           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow = rNumericArgs(13);
    3113           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh = rNumericArgs(14);
    3114           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow >= state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh) {
    3115           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    3116           0 :             ShowContinueError(state,
    3117           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    3118             :                                      cNumericFieldNames(11),
    3119           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow,
    3120           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh));
    3121           0 :             ErrorsFound = true;
    3122             :         }
    3123           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow >= state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh) {
    3124           0 :             ShowSevereError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\"");
    3125           0 :             ShowContinueError(state,
    3126           0 :                               format("... {} ({:.3T}) must be less than maximum ({:.3T}).",
    3127             :                                      cNumericFieldNames(13),
    3128           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow,
    3129           0 :                                      state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh));
    3130           0 :             ErrorsFound = true;
    3131             :         }
    3132             : 
    3133             :         // Reference OU SH/SC
    3134           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).SH = rNumericArgs(15);
    3135           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).SC = rNumericArgs(16);
    3136           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).SH > 20) {
    3137           0 :             ShowWarningError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", \" " + cNumericFieldNames(15));
    3138           0 :             ShowContinueError(state, "...is higher than 20C, which is usually the maximum of normal range.");
    3139             :         }
    3140           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).SC > 20) {
    3141           0 :             ShowWarningError(state, cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", \" " + cNumericFieldNames(15));
    3142           0 :             ShowContinueError(state, "...is higher than 20C, which is usually the maximum of normal range.");
    3143             :         }
    3144             : 
    3145             :         // OU Heat Exchanger Rated Bypass Factor
    3146           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RateBFOUEvap = rNumericArgs(17);
    3147           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RateBFOUCond = rNumericArgs(18);
    3148             : 
    3149             :         // Difference between Outdoor Unit Te and OAT during Simultaneous Heating and Cooling operations
    3150           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).DiffOUTeTo = rNumericArgs(19);
    3151             : 
    3152             :         // HR OU Heat Exchanger Capacity Ratio
    3153           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HROUHexRatio = rNumericArgs(20);
    3154             : 
    3155             :         // Get OU fan data
    3156           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPowerPerCapcity = rNumericArgs(21);
    3157           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRatePerCapcity = rNumericArgs(22);
    3158           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPower =
    3159           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).RatedOUFanPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    3160           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRate =
    3161           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).OUAirFlowRatePerCapcity * state.dataHVACVarRefFlow->VRF(VRFNum).RatedEvapCapacity;
    3162             : 
    3163             :         // OUEvapTempCurve
    3164           1 :         int indexOUEvapTempCurve = GetCurveIndex(state, cAlphaArgs(6)); // convert curve name to index number
    3165             :         // Verify curve name and type
    3166           1 :         if (indexOUEvapTempCurve == 0) {
    3167           0 :             if (lAlphaFieldBlanks(6)) {
    3168           0 :                 ShowSevereError(state,
    3169           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", missing");
    3170           0 :                 ShowContinueError(state, "...required " + cAlphaFieldNames(6) + " is blank.");
    3171             :             } else {
    3172           0 :                 ShowSevereError(state,
    3173           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    3174           0 :                 ShowContinueError(state, "...not found " + cAlphaFieldNames(6) + "=\"" + cAlphaArgs(6) + "\".");
    3175             :             }
    3176           0 :             ErrorsFound = true;
    3177             :         } else {
    3178           1 :             if (state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).curveType == Curve::CurveType::Quadratic) {
    3179           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C1Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[0];
    3180           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C2Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[1];
    3181           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C3Te = state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).coeff[2];
    3182             :             } else {
    3183           0 :                 ShowSevereError(state,
    3184           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    3185           0 :                 ShowContinueError(state,
    3186           0 :                                   format("...illegal {} type for this object = {}",
    3187             :                                          cAlphaFieldNames(6),
    3188           0 :                                          Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexOUEvapTempCurve).curveType)]));
    3189           0 :                 ShowContinueError(state, "... Curve type must be Quadratic.");
    3190           0 :                 ErrorsFound = true;
    3191             :             }
    3192             :         }
    3193             : 
    3194             :         // OUCondTempCurve
    3195           1 :         int indexOUCondTempCurve = GetCurveIndex(state, cAlphaArgs(7)); // convert curve name to index number
    3196             :         // Verify curve name and type
    3197           1 :         if (indexOUCondTempCurve == 0) {
    3198           0 :             if (lAlphaFieldBlanks(7)) {
    3199           0 :                 ShowSevereError(state,
    3200           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", missing");
    3201           0 :                 ShowContinueError(state, "...required " + cAlphaFieldNames(7) + " is blank.");
    3202             :             } else {
    3203           0 :                 ShowSevereError(state,
    3204           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    3205           0 :                 ShowContinueError(state, "...not found " + cAlphaFieldNames(7) + "=\"" + cAlphaArgs(7) + "\".");
    3206             :             }
    3207           0 :             ErrorsFound = true;
    3208             :         } else {
    3209           1 :             if (state.dataCurveManager->PerfCurve(indexOUCondTempCurve).curveType == Curve::CurveType::Quadratic) {
    3210           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C1Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[0];
    3211           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C2Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[1];
    3212           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).C3Tc = state.dataCurveManager->PerfCurve(indexOUCondTempCurve).coeff[2];
    3213             :             } else {
    3214           0 :                 ShowSevereError(state,
    3215           0 :                                 std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid");
    3216           0 :                 ShowContinueError(state,
    3217           0 :                                   format("...illegal {} type for this object = {}",
    3218             :                                          cAlphaFieldNames(7),
    3219           0 :                                          Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexOUCondTempCurve).curveType)]));
    3220           0 :                 ShowContinueError(state, "... Curve type must be Quadratic.");
    3221           0 :                 ErrorsFound = true;
    3222             :             }
    3223             :         }
    3224             : 
    3225             :         // Pipe parameters
    3226           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipDiaSuc = rNumericArgs(23);
    3227           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipDiaDis = rNumericArgs(24);
    3228           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen = rNumericArgs(25);
    3229           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = rNumericArgs(26);
    3230           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipHei = rNumericArgs(27);
    3231           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipInsThi = rNumericArgs(28);
    3232           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).RefPipInsCon = rNumericArgs(29);
    3233             : 
    3234             :         // Check the RefPipEquLen
    3235           1 :         if (lNumericFieldBlanks(26) && !lNumericFieldBlanks(25)) {
    3236           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = 1.2 * state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen;
    3237           0 :             ShowWarningError(state,
    3238           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", \" " + cNumericFieldNames(26) +
    3239             :                                  "\" is calculated based on");
    3240           0 :             ShowContinueError(state, "...the provided \"" + cNumericFieldNames(25) + "\" value.");
    3241             :         }
    3242           1 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen < state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen) {
    3243           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).RefPipEquLen = 1.2 * state.dataHVACVarRefFlow->VRF(VRFNum).RefPipLen;
    3244           0 :             ShowWarningError(state,
    3245           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\", invalid \" " + cNumericFieldNames(26) +
    3246             :                                  "\" value.");
    3247           0 :             ShowContinueError(state, "...Equivalent length of main pipe should be greater than or equal to the actual length.");
    3248           0 :             ShowContinueError(state, "...The value is recalculated based on the provided \"" + cNumericFieldNames(25) + "\" value.");
    3249             :         }
    3250             : 
    3251             :         // Crank case
    3252           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CCHeaterPower = rNumericArgs(30);
    3253           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).NumCompressors = rNumericArgs(31);
    3254           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSizeRatio = rNumericArgs(32);
    3255           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATCCHeater = rNumericArgs(33);
    3256             : 
    3257             :         // Defrost
    3258           1 :         if (!lAlphaFieldBlanks(8)) {
    3259           0 :             if (UtilityRoutines::SameString(cAlphaArgs(8), "ReverseCycle"))
    3260           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    3261           0 :             if (UtilityRoutines::SameString(cAlphaArgs(8), "Resistive"))
    3262           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::Resistive;
    3263           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Invalid) {
    3264           0 :                 ShowSevereError(state,
    3265           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(8) +
    3266           0 :                                     " not found: " + cAlphaArgs(8));
    3267           0 :                 ErrorsFound = true;
    3268             :             }
    3269             :         } else {
    3270           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    3271             :         }
    3272             : 
    3273           1 :         if (!lAlphaFieldBlanks(9)) {
    3274           0 :             if (UtilityRoutines::SameString(cAlphaArgs(9), "Timed"))
    3275           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    3276           0 :             if (UtilityRoutines::SameString(cAlphaArgs(9), "OnDemand"))
    3277           0 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    3278           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::Invalid) {
    3279           0 :                 ShowSevereError(state,
    3280           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(9) +
    3281           0 :                                     " not found: " + cAlphaArgs(9));
    3282           0 :                 ErrorsFound = true;
    3283             :             }
    3284             :         } else {
    3285           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    3286             :         }
    3287             : 
    3288           1 :         if (!lAlphaFieldBlanks(10)) {
    3289           0 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr = GetCurveIndex(state, cAlphaArgs(10));
    3290           0 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr > 0) {
    3291             :                 // Verify Curve Object, expected type is BiQuadratic
    3292           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3293           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).DefrostEIRPtr, // Curve index
    3294             :                                                      {2},                                                 // Valid dimensions
    3295             :                                                      RoutineName,                                         // Routine name
    3296             :                                                      cCurrentModuleObject,                                // Object Type
    3297           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFNum).Name,          // Object Name
    3298           0 :                                                      cAlphaFieldNames(10));                               // Field Name
    3299             :             } else {
    3300           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
    3301           0 :                     state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
    3302           0 :                     ShowSevereError(state,
    3303           0 :                                     cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(10) +
    3304           0 :                                         " not found:" + cAlphaArgs(10));
    3305           0 :                     ErrorsFound = true;
    3306             :                 }
    3307             :             }
    3308             :         } else {
    3309           2 :             if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
    3310           1 :                 state.dataHVACVarRefFlow->VRF(VRFNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
    3311           0 :                 ShowSevereError(state,
    3312           0 :                                 cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cAlphaFieldNames(10) +
    3313           0 :                                     " not found:" + cAlphaArgs(10));
    3314           0 :                 ErrorsFound = true;
    3315             :             }
    3316             :         }
    3317             : 
    3318           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostFraction = rNumericArgs(34);
    3319           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity = rNumericArgs(35);
    3320           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).MaxOATDefrost = rNumericArgs(36);
    3321           2 :         if (state.dataHVACVarRefFlow->VRF(VRFNum).DefrostCapacity == 0.0 &&
    3322           1 :             state.dataHVACVarRefFlow->VRF(VRFNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    3323           0 :             ShowWarningError(state,
    3324           0 :                              cCurrentModuleObject + ", \"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name + "\" " + cNumericFieldNames(35) +
    3325             :                                  " = 0.0 for defrost strategy = RESISTIVE.");
    3326             :         }
    3327             : 
    3328             :         // HR mode transition
    3329           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialCoolCapFrac = rNumericArgs(37);
    3330           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRCoolCapTC = rNumericArgs(38);
    3331           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialCoolEIRFrac = rNumericArgs(39);
    3332           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRCoolEIRTC = rNumericArgs(40);
    3333           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialHeatCapFrac = rNumericArgs(41);
    3334           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRHeatCapTC = rNumericArgs(42);
    3335           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRInitialHeatEIRFrac = rNumericArgs(43);
    3336           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).HRHeatEIRTC = rNumericArgs(44);
    3337             : 
    3338             :         // Compressor configuration
    3339           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompMaxDeltaP = rNumericArgs(45);
    3340           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).EffCompInverter = rNumericArgs(46);
    3341           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CoffEvapCap = rNumericArgs(47);
    3342             : 
    3343             :         // The new VRF model is Air cooled
    3344           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3345           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CondenserNodeNum = 0;
    3346             : 
    3347             :         // Evaporative Capacity & Compressor Power Curves corresponding to each Loading Index / compressor speed
    3348           1 :         NumOfCompSpd = rNumericArgs(48);
    3349           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSpeed.dimension(NumOfCompSpd);
    3350           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingCAPFT.dimension(NumOfCompSpd);
    3351           1 :         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingPWRFT.dimension(NumOfCompSpd);
    3352           1 :         int Count1Index = 48; // the index of the last numeric field before compressor speed entries
    3353           1 :         int Count2Index = 9;  // the index of the last alpha field before capacity/power curves
    3354           4 :         for (NumCompSpd = 1; NumCompSpd <= NumOfCompSpd; NumCompSpd++) {
    3355           3 :             state.dataHVACVarRefFlow->VRF(VRFNum).CompressorSpeed(NumCompSpd) = rNumericArgs(Count1Index + NumCompSpd);
    3356             : 
    3357             :             // Evaporating Capacity Curve
    3358           3 :             if (!lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd)) {
    3359           3 :                 int indexOUEvapCapCurve = GetCurveIndex(state, cAlphaArgs(Count2Index + 2 * NumCompSpd)); // convert curve name to index number
    3360           3 :                 if (indexOUEvapCapCurve == 0) {                                                           // Verify curve name and type
    3361           0 :                     if (lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd)) {
    3362           0 :                         ShowSevereError(state,
    3363           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    3364             :                                             "\", missing");
    3365           0 :                         ShowContinueError(state, "...required " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd) + " is blank.");
    3366             :                     } else {
    3367           0 :                         ShowSevereError(state,
    3368           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    3369             :                                             "\", invalid");
    3370           0 :                         ShowContinueError(state,
    3371           0 :                                           "...not found " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd) + "=\"" +
    3372           0 :                                               cAlphaArgs(Count2Index + 2 * NumCompSpd) + "\".");
    3373             :                     }
    3374           0 :                     ErrorsFound = true;
    3375             :                 } else {
    3376           6 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    3377             :                                                          indexOUEvapCapCurve,                             // Curve index
    3378             :                                                          {2},                                             // Valid dimensions
    3379             :                                                          RoutineName,                                     // Routine name
    3380             :                                                          cCurrentModuleObject,                            // Object Type
    3381           3 :                                                          state.dataHVACVarRefFlow->VRF(VRFNum).Name,      // Object Name
    3382           3 :                                                          cAlphaFieldNames(Count2Index + 2 * NumCompSpd)); // Field Name
    3383             : 
    3384           3 :                     if (!ErrorsFound) {
    3385           3 :                         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingCAPFT(NumCompSpd) = indexOUEvapCapCurve;
    3386             :                     }
    3387             :                 }
    3388             :             }
    3389             : 
    3390             :             // Compressor Power Curve
    3391           3 :             if (!lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd + 1)) {
    3392           3 :                 int indexOUCompPwrCurve = GetCurveIndex(state, cAlphaArgs(Count2Index + 2 * NumCompSpd + 1)); // convert curve name to index number
    3393           3 :                 if (indexOUCompPwrCurve == 0) {                                                               // Verify curve name and type
    3394           0 :                     if (lAlphaFieldBlanks(Count2Index + 2 * NumCompSpd + 1)) {
    3395           0 :                         ShowSevereError(state,
    3396           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    3397             :                                             "\", missing");
    3398           0 :                         ShowContinueError(state, "...required " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1) + " is blank.");
    3399             :                     } else {
    3400           0 :                         ShowSevereError(state,
    3401           0 :                                         std::string{RoutineName} + cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRF(VRFNum).Name +
    3402             :                                             "\", invalid");
    3403           0 :                         ShowContinueError(state,
    3404           0 :                                           "...not found " + cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1) + "=\"" +
    3405           0 :                                               cAlphaArgs(Count2Index + 2 * NumCompSpd + 1) + "\".");
    3406             :                     }
    3407           0 :                     ErrorsFound = true;
    3408             :                 } else {
    3409           6 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    3410             :                                                          indexOUCompPwrCurve,                                 // Curve index
    3411             :                                                          {2},                                                 // Valid dimensions
    3412             :                                                          RoutineName,                                         // Routine name
    3413             :                                                          cCurrentModuleObject,                                // Object Type
    3414           3 :                                                          state.dataHVACVarRefFlow->VRF(VRFNum).Name,          // Object Name
    3415           3 :                                                          cAlphaFieldNames(Count2Index + 2 * NumCompSpd + 1)); // Field Name
    3416             : 
    3417           3 :                     if (!ErrorsFound) {
    3418           3 :                         state.dataHVACVarRefFlow->VRF(VRFNum).OUCoolingPWRFT(NumCompSpd) = indexOUCompPwrCurve;
    3419             :                     }
    3420             :                 }
    3421             :             }
    3422             :         }
    3423             :     }
    3424             : 
    3425          11 :     cCurrentModuleObject = "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow";
    3426          67 :     for (VRFNum = 1; VRFNum <= state.dataHVACVarRefFlow->NumVRFTU; ++VRFNum) {
    3427          56 :         VRFTUNum = VRFNum;
    3428             : 
    3429             :         //     initialize local node number variables
    3430          56 :         FanInletNodeNum = 0;
    3431          56 :         FanOutletNodeNum = 0;
    3432          56 :         CCoilInletNodeNum = 0;
    3433          56 :         CCoilOutletNodeNum = 0;
    3434          56 :         HCoilInletNodeNum = 0;
    3435          56 :         HCoilOutletNodeNum = 0;
    3436          56 :         OANodeNums = 0;
    3437             : 
    3438          56 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3439             :                                                                  cCurrentModuleObject,
    3440             :                                                                  VRFTUNum,
    3441             :                                                                  cAlphaArgs,
    3442             :                                                                  NumAlphas,
    3443             :                                                                  rNumericArgs,
    3444             :                                                                  NumNums,
    3445             :                                                                  IOStat,
    3446             :                                                                  lNumericFieldBlanks,
    3447             :                                                                  lAlphaFieldBlanks,
    3448             :                                                                  cAlphaFieldNames,
    3449             :                                                                  cNumericFieldNames);
    3450             : 
    3451          56 :         state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames.allocate(NumNums);
    3452          56 :         state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames = cNumericFieldNames;
    3453          56 :         UtilityRoutines::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
    3454             : 
    3455          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name = cAlphaArgs(1);
    3456          56 :         ZoneTerminalUnitListNum = 0;
    3457          57 :         for (NumList = 1; NumList <= state.dataHVACVarRefFlow->NumVRFTULists; ++NumList) {
    3458         114 :             ZoneTerminalUnitListNum = UtilityRoutines::FindItemInList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    3459          57 :                                                                       state.dataHVACVarRefFlow->TerminalUnitList(NumList).ZoneTUName,
    3460          57 :                                                                       state.dataHVACVarRefFlow->TerminalUnitList(NumList).NumTUInList);
    3461          57 :             if (ZoneTerminalUnitListNum > 0) {
    3462          56 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList = ZoneTerminalUnitListNum;
    3463          56 :                 state.dataHVACVarRefFlow->TerminalUnitList(NumList).ZoneTUPtr(ZoneTerminalUnitListNum) = VRFTUNum;
    3464          56 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex = NumList;
    3465          56 :                 break;
    3466             :             }
    3467             :         }
    3468          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex == 0) {
    3469           0 :             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3470           0 :             ShowContinueError(state, "Terminal unit not found on any ZoneTerminalUnitList.");
    3471           0 :             ErrorsFound = true;
    3472             :         }
    3473             : 
    3474          57 :         for (NumCond = 1; NumCond <= state.dataHVACVarRefFlow->NumVRFCond; ++NumCond) {
    3475          57 :             if (state.dataHVACVarRefFlow->VRF(NumCond).ZoneTUListPtr != state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex) continue;
    3476          56 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum = NumCond;
    3477          56 :             break;
    3478             :         }
    3479          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num = DataHVACGlobals::VRFTUType_ConstVolume;
    3480          56 :         if (lAlphaFieldBlanks(2)) {
    3481           5 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    3482             :         } else {
    3483          51 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr = GetScheduleIndex(state, cAlphaArgs(2));
    3484          51 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr == 0) {
    3485           0 :                 ShowSevereError(state, cCurrentModuleObject + "=\"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\" invalid data");
    3486           0 :                 ShowContinueError(state, "Invalid-not found " + cAlphaFieldNames(2) + "=\"" + cAlphaArgs(2) + "\".");
    3487           0 :                 ErrorsFound = true;
    3488             :             }
    3489             :         }
    3490             : 
    3491          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum =
    3492         168 :             GetOnlySingleNode(state,
    3493          56 :                               cAlphaArgs(3),
    3494             :                               ErrorsFound,
    3495             :                               DataLoopNode::ConnectionObjectType::ZoneHVACTerminalUnitVariableRefrigerantFlow,
    3496          56 :                               state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    3497             :                               DataLoopNode::NodeFluidType::Air,
    3498             :                               DataLoopNode::ConnectionType::Inlet,
    3499             :                               NodeInputManager::CompFluidStream::Primary,
    3500          56 :                               ObjectIsParent);
    3501             : 
    3502          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum =
    3503         168 :             GetOnlySingleNode(state,
    3504          56 :                               cAlphaArgs(4),
    3505             :                               ErrorsFound,
    3506             :                               DataLoopNode::ConnectionObjectType::ZoneHVACTerminalUnitVariableRefrigerantFlow,
    3507          56 :                               state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    3508             :                               DataLoopNode::NodeFluidType::Air,
    3509             :                               DataLoopNode::ConnectionType::Outlet,
    3510             :                               NodeInputManager::CompFluidStream::Primary,
    3511          56 :                               ObjectIsParent);
    3512             : 
    3513          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow = rNumericArgs(1);
    3514          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow = rNumericArgs(2);
    3515          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow = rNumericArgs(3);
    3516          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow = rNumericArgs(4);
    3517          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow = rNumericArgs(5);
    3518          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow = rNumericArgs(6);
    3519          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow = rNumericArgs(7);
    3520             : 
    3521          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr = GetScheduleIndex(state, cAlphaArgs(5));
    3522             :         // default to constant fan operating mode
    3523          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr == 0) {
    3524           1 :             if (!lAlphaFieldBlanks(5)) {
    3525           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3526           0 :                 ShowContinueError(state, "..." + cAlphaFieldNames(5) + " = " + cAlphaArgs(5) + " not found.");
    3527           0 :                 ShowContinueError(state, "...Defaulting to constant fan operating mode and simulation continues.");
    3528             :             }
    3529           1 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode = DataHVACGlobals::ContFanCycCoil;
    3530             :         }
    3531             : 
    3532          56 :         if (UtilityRoutines::SameString(cAlphaArgs(6), "BlowThrough")) state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace = DataHVACGlobals::BlowThru;
    3533          56 :         if (UtilityRoutines::SameString(cAlphaArgs(6), "DrawThrough")) state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace = DataHVACGlobals::DrawThru;
    3534             : 
    3535          56 :         if (!lAlphaFieldBlanks(7) && !lAlphaFieldBlanks(8)) {
    3536             :             // Get fan data
    3537          55 :             FanType = cAlphaArgs(7);
    3538          55 :             FanName = cAlphaArgs(8);
    3539          55 :             if (UtilityRoutines::SameString(FanType, "Fan:SystemModel")) {
    3540          15 :                 if (!HVACFan::checkIfFanNameIsAFanSystem(state, FanName)) {
    3541           0 :                     ErrorsFound = true;
    3542             :                 } else {
    3543          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num = DataHVACGlobals::FanType_SystemModelObject;
    3544             :                 }
    3545             :             } else {
    3546          40 :                 errFlag = false;
    3547          40 :                 GetFanType(state, FanName, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num, errFlag, cCurrentModuleObject);
    3548          40 :                 if (errFlag) {
    3549           0 :                     ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3550           0 :                     ErrorsFound = true;
    3551             :                 }
    3552             :             }
    3553             : 
    3554             :             // Check the type of the fan is correct
    3555          55 :             if (!UtilityRoutines::SameString(DataHVACGlobals::cFanTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num), FanType)) {
    3556           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3557           0 :                 ShowContinueError(state, "Fan type specified = " + cAlphaArgs(7));
    3558           0 :                 ShowContinueError(state,
    3559           0 :                                   "Based on the fan name the type of fan actually used = " +
    3560           0 :                                       DataHVACGlobals::cFanTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num));
    3561           0 :                 ErrorsFound = true;
    3562             :             }
    3563             : 
    3564          55 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    3565             :                 // VRFTU Supply Air Fan Object Type must be Fan:VariableVolume if VRF Algorithm Type is AlgorithmTypeFluidTCtrl
    3566         110 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum ==
    3567          70 :                         AlgorithmType::FluidTCtrl &&
    3568          15 :                     !(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleVAV ||
    3569           0 :                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject)) {
    3570           0 :                     ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3571           0 :                     ShowContinueError(state, "Fan type specified = " + cAlphaArgs(7));
    3572           0 :                     ShowContinueError(
    3573             :                         state, "Fan Object Type must be Fan:VariableVolume if VRF AirConditioner:VariableRefrigerantFlow:FluidTemperatureControl");
    3574           0 :                     ShowContinueError(state, "is used to model VRF outdoor unit.");
    3575           0 :                     ErrorsFound = true;
    3576             :                 }
    3577             :                 // VRFTU Supply Air Fan Object Type must be Fan:OnOff or Fan:ConstantVolume if VRF Algorithm Type is AlgorithmTypeSysCurve
    3578         110 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum ==
    3579          95 :                         AlgorithmType::SysCurve &&
    3580          75 :                     !(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleOnOff ||
    3581          20 :                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleConstVolume ||
    3582          15 :                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject)) {
    3583           0 :                     ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3584           0 :                     ShowContinueError(state, "Fan type specified = " + cAlphaArgs(7));
    3585           0 :                     ShowContinueError(state,
    3586             :                                       "Fan Object Type must be Fan:SystemModel, Fan:OnOff, or Fan:ConstantVolume if VRF "
    3587             :                                       "AirConditioner:VariableRefrigerantFlow");
    3588           0 :                     ShowContinueError(state, "is used to model VRF outdoor unit.");
    3589           0 :                     ErrorsFound = true;
    3590             :                 }
    3591             :             }
    3592             : 
    3593         145 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleOnOff ||
    3594          85 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleConstVolume ||
    3595          30 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleVAV) {
    3596             : 
    3597          40 :                 ValidateComponent(
    3598          40 :                     state, DataHVACGlobals::cFanTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num), FanName, IsNotOK, cCurrentModuleObject);
    3599          40 :                 if (IsNotOK) {
    3600           0 :                     ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3601           0 :                     ErrorsFound = true;
    3602             : 
    3603             :                 } else { // mine data from fan object
    3604             : 
    3605             :                     // Get the fan index
    3606          40 :                     errFlag = false;
    3607          40 :                     GetFanIndex(state, FanName, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex, errFlag);
    3608          40 :                     if (errFlag) {
    3609           0 :                         ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3610           0 :                         ErrorsFound = true;
    3611             :                     } else {
    3612          40 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanInletNode =
    3613          40 :                             state.dataFans->Fan(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex).InletNodeNum;
    3614          40 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOutletNode =
    3615          40 :                             state.dataFans->Fan(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex).OutletNodeNum;
    3616             :                     }
    3617             : 
    3618             :                     // Set the Design Fan Volume Flow Rate
    3619          40 :                     errFlag = false;
    3620          40 :                     FanVolFlowRate = GetFanDesignVolumeFlowRate(state, FanType, FanName, errFlag);
    3621          40 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate = FanVolFlowRate;
    3622             : 
    3623          40 :                     if (errFlag) {
    3624           0 :                         ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " =" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3625           0 :                         ErrorsFound = true;
    3626             :                     }
    3627             : 
    3628             :                     // Get the Fan Inlet node
    3629          40 :                     errFlag = false;
    3630          40 :                     FanInletNodeNum = GetFanInletNode(state, FanType, FanName, errFlag);
    3631          40 :                     if (errFlag) {
    3632           0 :                         ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3633           0 :                         ErrorsFound = true;
    3634             :                     }
    3635             : 
    3636             :                     // Get the Fan Outlet node
    3637          40 :                     errFlag = false;
    3638          40 :                     FanOutletNodeNum = GetFanOutletNode(state, FanType, FanName, errFlag);
    3639          40 :                     if (errFlag) {
    3640           0 :                         ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3641           0 :                         ErrorsFound = true;
    3642             :                     }
    3643             : 
    3644             :                     // Get the fan's availability schedule
    3645          40 :                     errFlag = false;
    3646          40 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr = GetFanAvailSchPtr(state, FanType, FanName, errFlag);
    3647          40 :                     if (errFlag) {
    3648           0 :                         ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3649           0 :                         ErrorsFound = true;
    3650             :                     }
    3651             : 
    3652             :                     // Check fan's schedule for cycling fan operation if constant volume fan is used
    3653          80 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr > 0 &&
    3654          40 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SimpleConstVolume) {
    3655           5 :                         if (!CheckScheduleValueMinMax(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr, ">", 0.0, "<=", 1.0)) {
    3656           0 :                             ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3657           0 :                             ShowContinueError(state, "For fan type = " + DataHVACGlobals::cFanTypes(DataHVACGlobals::FanType_SimpleConstVolume));
    3658           0 :                             ShowContinueError(state, "Fan operating mode must be continuous (fan operating mode schedule values > 0).");
    3659           0 :                             ShowContinueError(state, "Error found in " + cAlphaFieldNames(5) + " = " + cAlphaArgs(5));
    3660           0 :                             ShowContinueError(state, "...schedule values must be (>0., <=1.)");
    3661           0 :                             ErrorsFound = true;
    3662             :                         }
    3663             :                     }
    3664             :                 } // IF (IsNotOK) THEN
    3665             : 
    3666          15 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    3667             : 
    3668          15 :                 ValidateComponent(
    3669          15 :                     state, DataHVACGlobals::cFanTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num), FanName, IsNotOK, cCurrentModuleObject);
    3670          15 :                 if (IsNotOK) {
    3671           0 :                     ShowContinueError(state, "...occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3672           0 :                     ErrorsFound = true;
    3673             : 
    3674             :                 } else {                                                                             // mine data from fan object
    3675          15 :                     state.dataHVACFan->fanObjs.emplace_back(new HVACFan::FanSystem(state, FanName)); // call constructor
    3676          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex = HVACFan::getFanObjectVectorIndex(state, FanName);
    3677          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate =
    3678          15 :                         state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->designAirVolFlowRate;
    3679          15 :                     FanInletNodeNum = state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->inletNodeNum;
    3680          15 :                     FanOutletNodeNum = state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->outletNodeNum;
    3681          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr =
    3682          15 :                         state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->availSchedIndex;
    3683          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanInletNode = FanInletNodeNum;
    3684          15 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOutletNode = FanOutletNodeNum;
    3685             :                 }
    3686             :             } else { // IF (FanType_Num == DataHVACGlobals::FanType_SimpleOnOff .OR. FanType_Num ==
    3687             :                      // DataHVACGlobals::FanType_SimpleConstVolume)THEN
    3688           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3689           0 :                 ShowContinueError(state, "Illegal " + cAlphaFieldNames(7) + " = " + cAlphaArgs(7));
    3690           0 :                 ErrorsFound = true;
    3691             :             } // IF (FanType_Num == DataHVACGlobals::FanType_SimpleOnOff .OR. FanType_Num == DataHVACGlobals::FanType_SimpleConstVolume)THEN
    3692             : 
    3693             :             // Add TU to component sets array
    3694         220 :             SetUpCompSets(state,
    3695             :                           cCurrentModuleObject,
    3696          55 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    3697          55 :                           DataHVACGlobals::cFanTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num),
    3698             :                           FanName,
    3699          55 :                           state.dataLoopNodes->NodeID(FanInletNodeNum),
    3700          55 :                           state.dataLoopNodes->NodeID(FanOutletNodeNum));
    3701             : 
    3702           1 :         } else if (lAlphaFieldBlanks(7) || lAlphaFieldBlanks(8)) {
    3703           1 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace = 0; // reset fan placement when fan is not used so as not to call the fan
    3704             :         } else {
    3705           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace = 0;
    3706             :         }
    3707             : 
    3708             :         // Get OA mixer data
    3709          56 :         OAMixerType = cAlphaArgs(9);
    3710             : 
    3711          56 :         if (!lAlphaFieldBlanks(10)) {
    3712          50 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName = cAlphaArgs(10);
    3713          50 :             errFlag = false;
    3714          50 :             OANodeNums = GetOAMixerNodeNumbers(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName, errFlag);
    3715             : 
    3716             :             //       OANodeNums(1) = OAMixer(OAMixerNum)%InletNode
    3717             :             //       OANodeNums(2) = OAMixer(OAMixerNum)%RelNode
    3718             :             //       OANodeNums(3) = OAMixer(OAMixerNum)%RetNode
    3719             :             //       OANodeNums(4) = OAMixer(OAMixerNum)%MixNode
    3720             : 
    3721          50 :             if (errFlag) {
    3722           0 :                 ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    3723           0 :                 ErrorsFound = true;
    3724             :             } else {
    3725          50 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed = true;
    3726             :             }
    3727          50 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum = OANodeNums(1);
    3728          50 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRelNodeNum = OANodeNums(2);
    3729          50 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum = OANodeNums(3);
    3730          50 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerMixedNodeNum = OANodeNums(4);
    3731             :         }
    3732             : 
    3733             :         // Get DX cooling coil data
    3734          56 :         DXCoolingCoilType = cAlphaArgs(11);
    3735             : 
    3736          56 :         errFlag = false;
    3737          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num = GetCoilTypeNum(state, DXCoolingCoilType, cAlphaArgs(12), errFlag, false);
    3738          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num == 0) {
    3739           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent = false;
    3740           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    3741           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    3742           0 :                     .CoolingCoilPresent(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) = false;
    3743             :             }
    3744             :         } else {
    3745          56 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    3746          56 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum ==
    3747             :                     AlgorithmType::FluidTCtrl) {
    3748             :                     // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    3749             : 
    3750          15 :                     if (UtilityRoutines::SameString(DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num),
    3751          15 :                                                     DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling))) {
    3752          15 :                         errFlag = false;
    3753          30 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 &&
    3754          15 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    3755          15 :                             state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    3756          15 :                                 .CoolingCoilAvailSchPtr(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) =
    3757          30 :                                 GetDXCoilAvailSchPtr(state, DXCoolingCoilType, cAlphaArgs(12), errFlag);
    3758             :                         }
    3759          45 :                         GetDXCoilIndex(state,
    3760          15 :                                        cAlphaArgs(12),
    3761          15 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3762             :                                        errFlag,
    3763          15 :                                        DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling));
    3764          15 :                         CCoilInletNodeNum = GetDXCoilInletNode(
    3765          15 :                             state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling), cAlphaArgs(12), errFlag);
    3766          15 :                         CCoilOutletNodeNum = GetDXCoilOutletNode(
    3767          15 :                             state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling), cAlphaArgs(12), errFlag);
    3768          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolCoilAirInNode = CCoilInletNodeNum;
    3769          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolCoilAirOutNode = CCoilOutletNodeNum;
    3770             : 
    3771          15 :                         if (errFlag)
    3772           0 :                             ShowContinueError(state,
    3773           0 :                                               "...occurs in " + cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3774             : 
    3775          15 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    3776          45 :                             SetDXCoolingCoilData(state,
    3777          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3778             :                                                  ErrorsFound,
    3779             :                                                  _,
    3780          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserType);
    3781          45 :                             SetDXCoolingCoilData(state,
    3782          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3783             :                                                  ErrorsFound,
    3784             :                                                  _,
    3785             :                                                  _,
    3786          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserNodeNum);
    3787          45 :                             SetDXCoolingCoilData(state,
    3788          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3789             :                                                  ErrorsFound,
    3790             :                                                  _,
    3791             :                                                  _,
    3792             :                                                  _,
    3793          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCCHeater);
    3794          45 :                             SetDXCoolingCoilData(state,
    3795          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3796             :                                                  ErrorsFound,
    3797             :                                                  _,
    3798             :                                                  _,
    3799             :                                                  _,
    3800             :                                                  _,
    3801          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MinOATCooling);
    3802          45 :                             SetDXCoolingCoilData(state,
    3803          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3804             :                                                  ErrorsFound,
    3805             :                                                  _,
    3806             :                                                  _,
    3807             :                                                  _,
    3808             :                                                  _,
    3809             :                                                  _,
    3810          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCooling);
    3811             : 
    3812          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).VRFIUPtr = VRFTUNum;
    3813          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).VRFOUPtr =
    3814          15 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
    3815          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).SupplyFanIndex =
    3816          15 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    3817          15 :                             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    3818           0 :                                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex > -1) {
    3819           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).RatedAirVolFlowRate(1) =
    3820           0 :                                         state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->designAirVolFlowRate;
    3821             :                                 } else {
    3822           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).RatedAirVolFlowRate(1) =
    3823             :                                         AutoSize;
    3824             :                                 }
    3825             :                             } else {
    3826          15 :                                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex > 0) {
    3827          15 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).RatedAirVolFlowRate(1) =
    3828          15 :                                         state.dataFans->Fan(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex).MaxAirFlowRate;
    3829             :                                 } else {
    3830           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).RatedAirVolFlowRate(1) =
    3831             :                                         AutoSize;
    3832             :                                 }
    3833             :                             }
    3834             : 
    3835             :                         } else {
    3836           0 :                             ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3837           0 :                             ShowContinueError(state,
    3838           0 :                                               "... when checking " +
    3839           0 :                                                   DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num) +
    3840           0 :                                                   " \"" + cAlphaArgs(12) + "\"");
    3841           0 :                             ShowContinueError(state, "... terminal unit not connected to condenser.");
    3842           0 :                             ShowContinueError(state, "... check that terminal unit is specified in a terminal unit list object.");
    3843           0 :                             ShowContinueError(state,
    3844             :                                               "... also check that the terminal unit list name is specified in an "
    3845             :                                               "AirConditioner:VariableRefrigerantFlow object.");
    3846           0 :                             ErrorsFound = true;
    3847             :                         }
    3848             :                     } else {
    3849           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3850           0 :                         ShowContinueError(state, "... illegal " + cAlphaFieldNames(12) + " = " + cAlphaArgs(12));
    3851           0 :                         ErrorsFound = true;
    3852             :                     }
    3853             : 
    3854             :                 } else {
    3855             :                     // Algorithm Type: VRF model based on system curve
    3856             : 
    3857          41 :                     if (UtilityRoutines::SameString(DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num),
    3858          41 :                                                     DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Cooling))) {
    3859          82 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 &&
    3860          41 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    3861          41 :                             state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    3862          41 :                                 .CoolingCoilAvailSchPtr(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) =
    3863          82 :                                 GetDXCoilAvailSchPtr(state, DXCoolingCoilType, cAlphaArgs(12), errFlag);
    3864             :                         } else {
    3865           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent = false;
    3866             :                         }
    3867          41 :                         errFlag = false;
    3868         123 :                         GetDXCoilIndex(state,
    3869          41 :                                        cAlphaArgs(12),
    3870          41 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3871             :                                        errFlag,
    3872          41 :                                        DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Cooling));
    3873          41 :                         CCoilInletNodeNum =
    3874          41 :                             GetDXCoilInletNode(state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Cooling), cAlphaArgs(12), errFlag);
    3875          41 :                         CCoilOutletNodeNum =
    3876          41 :                             GetDXCoilOutletNode(state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Cooling), cAlphaArgs(12), errFlag);
    3877          41 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolCoilAirInNode = CCoilInletNodeNum;
    3878          41 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolCoilAirOutNode = CCoilOutletNodeNum;
    3879             : 
    3880          41 :                         if (errFlag)
    3881           0 :                             ShowContinueError(state,
    3882           0 :                                               "...occurs in " + cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3883             : 
    3884         123 :                         SetDXCoolingCoilData(state,
    3885          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3886             :                                              ErrorsFound,
    3887             :                                              _,
    3888          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserType);
    3889         123 :                         SetDXCoolingCoilData(state,
    3890          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3891             :                                              ErrorsFound,
    3892             :                                              _,
    3893             :                                              _,
    3894          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserNodeNum);
    3895         123 :                         SetDXCoolingCoilData(state,
    3896          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3897             :                                              ErrorsFound,
    3898             :                                              _,
    3899             :                                              _,
    3900             :                                              _,
    3901          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCCHeater);
    3902         123 :                         SetDXCoolingCoilData(state,
    3903          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3904             :                                              ErrorsFound,
    3905             :                                              _,
    3906             :                                              _,
    3907             :                                              _,
    3908             :                                              _,
    3909          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MinOATCooling);
    3910         123 :                         SetDXCoolingCoilData(state,
    3911          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    3912             :                                              ErrorsFound,
    3913             :                                              _,
    3914             :                                              _,
    3915             :                                              _,
    3916             :                                              _,
    3917             :                                              _,
    3918          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCooling);
    3919             : 
    3920             :                     } else {
    3921           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3922           0 :                         ShowContinueError(state, "... illegal " + cAlphaFieldNames(12) + " = " + cAlphaArgs(12));
    3923           0 :                         ErrorsFound = true;
    3924             :                     }
    3925             :                 }
    3926             :             } else {
    3927           0 :                 ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3928           0 :                 ShowContinueError(state,
    3929           0 :                                   "... when checking " +
    3930           0 :                                       DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num) + " \"" +
    3931           0 :                                       cAlphaArgs(12) + "\"");
    3932           0 :                 ShowContinueError(state, "... terminal unit not connected to condenser.");
    3933           0 :                 ShowContinueError(state, "... check that terminal unit is specified in a terminal unit list object.");
    3934           0 :                 ShowContinueError(
    3935             :                     state, "... also check that the terminal unit list name is specified in an AirConditioner:VariableRefrigerantFlow object.");
    3936           0 :                 ErrorsFound = true;
    3937             :             }
    3938             :         }
    3939             : 
    3940             :         // Get DX heating coil data
    3941          56 :         DXHeatingCoilType = cAlphaArgs(13);
    3942             : 
    3943             :         // Get the heating to cooling sizing ratio input before writing to DX heating coil data
    3944          56 :         if (!lNumericFieldBlanks(10)) {
    3945           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCapacitySizeRatio = rNumericArgs(10);
    3946             :         }
    3947             : 
    3948          56 :         errFlag = false;
    3949          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num = GetCoilTypeNum(state, DXHeatingCoilType, cAlphaArgs(14), errFlag, false);
    3950          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num == 0) {
    3951           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent = false;
    3952           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    3953           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    3954           0 :                     .HeatingCoilPresent(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) = false;
    3955             :             }
    3956             :         } else {
    3957          56 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    3958          56 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum ==
    3959             :                     AlgorithmType::FluidTCtrl) {
    3960             :                     // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    3961             : 
    3962          15 :                     if (UtilityRoutines::SameString(DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num),
    3963          15 :                                                     DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Heating))) {
    3964          15 :                         errFlag = false;
    3965          30 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 &&
    3966          15 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    3967          15 :                             state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    3968          15 :                                 .HeatingCoilAvailSchPtr(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) =
    3969          30 :                                 GetDXCoilAvailSchPtr(state, DXHeatingCoilType, cAlphaArgs(14), errFlag);
    3970             :                         }
    3971          45 :                         GetDXCoilIndex(state,
    3972          15 :                                        cAlphaArgs(14),
    3973          15 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    3974             :                                        errFlag,
    3975          15 :                                        DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Heating));
    3976          15 :                         HCoilInletNodeNum = GetDXCoilInletNode(
    3977          15 :                             state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Heating), cAlphaArgs(14), errFlag);
    3978          15 :                         HCoilOutletNodeNum = GetDXCoilOutletNode(
    3979          15 :                             state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_FluidTCtrl_Heating), cAlphaArgs(14), errFlag);
    3980          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatCoilAirInNode = HCoilInletNodeNum;
    3981          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatCoilAirOutNode = HCoilOutletNodeNum;
    3982             : 
    3983          15 :                         if (errFlag)
    3984           0 :                             ShowContinueError(state,
    3985           0 :                                               "...occurs in " + cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    3986             : 
    3987          15 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    3988          45 :                             SetDXCoolingCoilData(state,
    3989          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    3990             :                                                  ErrorsFound,
    3991             :                                                  _,
    3992          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserType);
    3993          45 :                             SetDXCoolingCoilData(state,
    3994          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    3995             :                                                  ErrorsFound,
    3996             :                                                  _,
    3997             :                                                  _,
    3998          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserNodeNum);
    3999          45 :                             SetDXCoolingCoilData(state,
    4000          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4001             :                                                  ErrorsFound,
    4002             :                                                  _,
    4003             :                                                  _,
    4004             :                                                  _,
    4005          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCCHeater);
    4006          45 :                             SetDXCoolingCoilData(state,
    4007          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4008             :                                                  ErrorsFound,
    4009             :                                                  _,
    4010             :                                                  _,
    4011             :                                                  _,
    4012             :                                                  _,
    4013             :                                                  _,
    4014             :                                                  _,
    4015          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MinOATHeating);
    4016          45 :                             SetDXCoolingCoilData(state,
    4017          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4018             :                                                  ErrorsFound,
    4019             :                                                  _,
    4020             :                                                  _,
    4021             :                                                  _,
    4022             :                                                  _,
    4023             :                                                  _,
    4024             :                                                  _,
    4025             :                                                  _,
    4026          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATHeating);
    4027          45 :                             SetDXCoolingCoilData(
    4028             :                                 state,
    4029          15 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4030             :                                 ErrorsFound,
    4031             :                                 _,
    4032             :                                 _,
    4033             :                                 _,
    4034             :                                 _,
    4035             :                                 _,
    4036             :                                 _,
    4037             :                                 _,
    4038             :                                 _,
    4039          15 :                                 state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingPerformanceOATType);
    4040             :                             // Set defrost controls in child object to trip child object defrost calculations
    4041          45 :                             SetDXCoolingCoilData(state,
    4042          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4043             :                                                  ErrorsFound,
    4044             :                                                  _,
    4045             :                                                  _,
    4046             :                                                  _,
    4047             :                                                  _,
    4048             :                                                  _,
    4049             :                                                  _,
    4050             :                                                  _,
    4051             :                                                  _,
    4052             :                                                  _,
    4053          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostStrategy);
    4054          45 :                             SetDXCoolingCoilData(state,
    4055          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4056             :                                                  ErrorsFound,
    4057             :                                                  _,
    4058             :                                                  _,
    4059             :                                                  _,
    4060             :                                                  _,
    4061             :                                                  _,
    4062             :                                                  _,
    4063             :                                                  _,
    4064             :                                                  _,
    4065             :                                                  _,
    4066             :                                                  _,
    4067          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostControl);
    4068          45 :                             SetDXCoolingCoilData(state,
    4069          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4070             :                                                  ErrorsFound,
    4071             :                                                  _,
    4072             :                                                  _,
    4073             :                                                  _,
    4074             :                                                  _,
    4075             :                                                  _,
    4076             :                                                  _,
    4077             :                                                  _,
    4078             :                                                  _,
    4079             :                                                  _,
    4080             :                                                  _,
    4081             :                                                  _,
    4082          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostEIRPtr);
    4083          45 :                             SetDXCoolingCoilData(state,
    4084          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4085             :                                                  ErrorsFound,
    4086             :                                                  _,
    4087             :                                                  _,
    4088             :                                                  _,
    4089             :                                                  _,
    4090             :                                                  _,
    4091             :                                                  _,
    4092             :                                                  _,
    4093             :                                                  _,
    4094             :                                                  _,
    4095             :                                                  _,
    4096             :                                                  _,
    4097             :                                                  _,
    4098          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostFraction);
    4099          45 :                             SetDXCoolingCoilData(state,
    4100          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4101             :                                                  ErrorsFound,
    4102             :                                                  _,
    4103             :                                                  _,
    4104             :                                                  _,
    4105             :                                                  _,
    4106             :                                                  _,
    4107             :                                                  _,
    4108             :                                                  _,
    4109             :                                                  _,
    4110             :                                                  _,
    4111             :                                                  _,
    4112             :                                                  _,
    4113             :                                                  _,
    4114             :                                                  _,
    4115             :                                                  _,
    4116          15 :                                                  state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATDefrost);
    4117             :                             // If defrost is disabled in the VRF condenser, it must be disabled in the DX coil
    4118             :                             // Defrost primarily handled in parent object, set defrost capacity to 1 to avoid autosizing.
    4119             :                             // Defrost capacity is used for nothing more than setting defrost power/consumption report
    4120             :                             // variables which are not reported. The coil's defrost algorythm IS used to derate the coil
    4121          30 :                             SetDXCoolingCoilData(state,
    4122          15 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4123             :                                                  ErrorsFound,
    4124             :                                                  _,
    4125             :                                                  _,
    4126             :                                                  _,
    4127             :                                                  _,
    4128             :                                                  _,
    4129             :                                                  _,
    4130             :                                                  _,
    4131             :                                                  _,
    4132             :                                                  _,
    4133             :                                                  _,
    4134             :                                                  _,
    4135             :                                                  _,
    4136             :                                                  _,
    4137             :                                                  1.0); // DefrostCapacity=1.0
    4138             : 
    4139          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).VRFIUPtr = VRFTUNum;
    4140          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).VRFOUPtr =
    4141          15 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
    4142          15 :                             state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).SupplyFanIndex =
    4143          15 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    4144          15 :                             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    4145           0 :                                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex > -1) {
    4146           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).RatedAirVolFlowRate(1) =
    4147           0 :                                         state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->designAirVolFlowRate;
    4148             :                                 } else {
    4149           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).RatedAirVolFlowRate(1) =
    4150             :                                         AutoSize;
    4151             :                                 }
    4152             :                             } else {
    4153          15 :                                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex > 0) {
    4154          15 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).RatedAirVolFlowRate(1) =
    4155          15 :                                         state.dataFans->Fan(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex).MaxAirFlowRate;
    4156             :                                 } else {
    4157           0 :                                     state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).RatedAirVolFlowRate(1) =
    4158             :                                         AutoSize;
    4159             :                                 }
    4160             :                             }
    4161             : 
    4162             :                             // Terminal unit heating to cooling sizing ratio has precedence over VRF system sizing ratio
    4163          15 :                             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCapacitySizeRatio > 1.0) {
    4164           0 :                                 SetDXCoolingCoilData(state,
    4165           0 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4166             :                                                      ErrorsFound,
    4167             :                                                      _,
    4168             :                                                      _,
    4169             :                                                      _,
    4170             :                                                      _,
    4171             :                                                      _,
    4172             :                                                      _,
    4173             :                                                      _,
    4174             :                                                      _,
    4175             :                                                      _,
    4176             :                                                      _,
    4177             :                                                      _,
    4178             :                                                      _,
    4179             :                                                      _,
    4180             :                                                      _,
    4181             :                                                      _,
    4182             :                                                      _,
    4183             :                                                      _,
    4184           0 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCapacitySizeRatio);
    4185          15 :                             } else if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacitySizeRatio >
    4186             :                                        1.0) {
    4187           0 :                                 SetDXCoolingCoilData(
    4188             :                                     state,
    4189           0 :                                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4190             :                                     ErrorsFound,
    4191             :                                     _,
    4192             :                                     _,
    4193             :                                     _,
    4194             :                                     _,
    4195             :                                     _,
    4196             :                                     _,
    4197             :                                     _,
    4198             :                                     _,
    4199             :                                     _,
    4200             :                                     _,
    4201             :                                     _,
    4202             :                                     _,
    4203             :                                     _,
    4204             :                                     _,
    4205             :                                     _,
    4206             :                                     _,
    4207             :                                     _,
    4208           0 :                                     state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacitySizeRatio);
    4209             :                             }
    4210             :                         } else {
    4211           0 :                             ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4212           0 :                             ShowContinueError(state,
    4213           0 :                                               "... when checking " +
    4214           0 :                                                   DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num) +
    4215           0 :                                                   " \"" + cAlphaArgs(14) + "\"");
    4216           0 :                             ShowContinueError(state, "... terminal unit not connected to condenser.");
    4217           0 :                             ShowContinueError(state, "... check that terminal unit is specified in a terminal unit list object.");
    4218           0 :                             ShowContinueError(state,
    4219             :                                               "... also check that the terminal unit list name is specified in an "
    4220             :                                               "AirConditioner:VariableRefrigerantFlow object.");
    4221           0 :                             ErrorsFound = true;
    4222             :                         }
    4223             :                     } else {
    4224           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4225           0 :                         ShowContinueError(state, "... illegal " + cAlphaFieldNames(14) + " = " + cAlphaArgs(14));
    4226           0 :                         ErrorsFound = true;
    4227             :                     }
    4228             : 
    4229             :                 } else {
    4230             :                     // Algorithm Type: VRF model based on system curve
    4231          41 :                     if (UtilityRoutines::SameString(DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num),
    4232          41 :                                                     DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Heating))) {
    4233          82 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex > 0 &&
    4234          41 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList > 0) {
    4235          41 :                             state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex)
    4236          41 :                                 .HeatingCoilAvailSchPtr(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList) =
    4237          82 :                                 GetDXCoilAvailSchPtr(state, DXHeatingCoilType, cAlphaArgs(14), errFlag);
    4238             :                         } else {
    4239           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent = false;
    4240             :                         }
    4241          41 :                         errFlag = false;
    4242         123 :                         GetDXCoilIndex(state,
    4243          41 :                                        cAlphaArgs(14),
    4244          41 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4245             :                                        errFlag,
    4246          41 :                                        DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Heating));
    4247          41 :                         HCoilInletNodeNum =
    4248          41 :                             GetDXCoilInletNode(state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Heating), cAlphaArgs(14), errFlag);
    4249          41 :                         HCoilOutletNodeNum =
    4250          41 :                             GetDXCoilOutletNode(state, DataHVACGlobals::cAllCoilTypes(DataHVACGlobals::CoilVRF_Heating), cAlphaArgs(14), errFlag);
    4251          41 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatCoilAirInNode = HCoilInletNodeNum;
    4252          41 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatCoilAirOutNode = HCoilOutletNodeNum;
    4253             : 
    4254          41 :                         if (errFlag)
    4255           0 :                             ShowContinueError(state,
    4256           0 :                                               "...occurs in " + cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4257             : 
    4258         123 :                         SetDXCoolingCoilData(state,
    4259          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4260             :                                              ErrorsFound,
    4261             :                                              _,
    4262          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserType);
    4263         123 :                         SetDXCoolingCoilData(state,
    4264          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4265             :                                              ErrorsFound,
    4266             :                                              _,
    4267             :                                              _,
    4268          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CondenserNodeNum);
    4269         123 :                         SetDXCoolingCoilData(state,
    4270          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4271             :                                              ErrorsFound,
    4272             :                                              _,
    4273             :                                              _,
    4274             :                                              _,
    4275          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATCCHeater);
    4276         123 :                         SetDXCoolingCoilData(state,
    4277          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4278             :                                              ErrorsFound,
    4279             :                                              _,
    4280             :                                              _,
    4281             :                                              _,
    4282             :                                              _,
    4283             :                                              _,
    4284             :                                              _,
    4285          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MinOATHeating);
    4286         123 :                         SetDXCoolingCoilData(
    4287             :                             state,
    4288          41 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4289             :                             ErrorsFound,
    4290             :                             _,
    4291             :                             _,
    4292             :                             _,
    4293             :                             _,
    4294             :                             _,
    4295             :                             _,
    4296             :                             _,
    4297             :                             _,
    4298          41 :                             state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingPerformanceOATType);
    4299             :                         // Set defrost controls in child object to trip child object defrost calculations
    4300         123 :                         SetDXCoolingCoilData(state,
    4301          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4302             :                                              ErrorsFound,
    4303             :                                              _,
    4304             :                                              _,
    4305             :                                              _,
    4306             :                                              _,
    4307             :                                              _,
    4308             :                                              _,
    4309             :                                              _,
    4310             :                                              _,
    4311             :                                              _,
    4312          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostStrategy);
    4313         123 :                         SetDXCoolingCoilData(state,
    4314          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4315             :                                              ErrorsFound,
    4316             :                                              _,
    4317             :                                              _,
    4318             :                                              _,
    4319             :                                              _,
    4320             :                                              _,
    4321             :                                              _,
    4322             :                                              _,
    4323             :                                              _,
    4324             :                                              _,
    4325             :                                              _,
    4326          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostControl);
    4327         123 :                         SetDXCoolingCoilData(state,
    4328          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4329             :                                              ErrorsFound,
    4330             :                                              _,
    4331             :                                              _,
    4332             :                                              _,
    4333             :                                              _,
    4334             :                                              _,
    4335             :                                              _,
    4336             :                                              _,
    4337             :                                              _,
    4338             :                                              _,
    4339             :                                              _,
    4340             :                                              _,
    4341          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostEIRPtr);
    4342         123 :                         SetDXCoolingCoilData(state,
    4343          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4344             :                                              ErrorsFound,
    4345             :                                              _,
    4346             :                                              _,
    4347             :                                              _,
    4348             :                                              _,
    4349             :                                              _,
    4350             :                                              _,
    4351             :                                              _,
    4352             :                                              _,
    4353             :                                              _,
    4354             :                                              _,
    4355             :                                              _,
    4356             :                                              _,
    4357          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).DefrostFraction);
    4358         123 :                         SetDXCoolingCoilData(state,
    4359          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4360             :                                              ErrorsFound,
    4361             :                                              _,
    4362             :                                              _,
    4363             :                                              _,
    4364             :                                              _,
    4365             :                                              _,
    4366             :                                              _,
    4367             :                                              _,
    4368             :                                              _,
    4369             :                                              _,
    4370             :                                              _,
    4371             :                                              _,
    4372             :                                              _,
    4373             :                                              _,
    4374             :                                              _,
    4375          41 :                                              state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).MaxOATDefrost);
    4376             :                         // If defrost is disabled in the VRF condenser, it must be disabled in the DX coil
    4377             :                         // Defrost primarily handled in parent object, set defrost capacity to 1 to avoid autosizing.
    4378             :                         // Defrost capacity is used for nothing more than setting defrost power/consumption report
    4379             :                         // variables which are not reported. The coil's defrost algorythm IS used to derate the coil
    4380          82 :                         SetDXCoolingCoilData(state,
    4381          41 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4382             :                                              ErrorsFound,
    4383             :                                              _,
    4384             :                                              _,
    4385             :                                              _,
    4386             :                                              _,
    4387             :                                              _,
    4388             :                                              _,
    4389             :                                              _,
    4390             :                                              _,
    4391             :                                              _,
    4392             :                                              _,
    4393             :                                              _,
    4394             :                                              _,
    4395             :                                              _,
    4396             :                                              1.0); // DefrostCapacity=1.0
    4397             :                         // Terminal unit heating to cooling sizing ratio has precedence over VRF system sizing ratio
    4398          41 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCapacitySizeRatio > 1.0) {
    4399           0 :                             SetDXCoolingCoilData(state,
    4400           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4401             :                                                  ErrorsFound,
    4402             :                                                  _,
    4403             :                                                  _,
    4404             :                                                  _,
    4405             :                                                  _,
    4406             :                                                  _,
    4407             :                                                  _,
    4408             :                                                  _,
    4409             :                                                  _,
    4410             :                                                  _,
    4411             :                                                  _,
    4412             :                                                  _,
    4413             :                                                  _,
    4414             :                                                  _,
    4415             :                                                  _,
    4416             :                                                  _,
    4417             :                                                  _,
    4418             :                                                  _,
    4419           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCapacitySizeRatio);
    4420          41 :                         } else if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacitySizeRatio >
    4421             :                                    1.0) {
    4422           0 :                             SetDXCoolingCoilData(
    4423             :                                 state,
    4424           0 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4425             :                                 ErrorsFound,
    4426             :                                 _,
    4427             :                                 _,
    4428             :                                 _,
    4429             :                                 _,
    4430             :                                 _,
    4431             :                                 _,
    4432             :                                 _,
    4433             :                                 _,
    4434             :                                 _,
    4435             :                                 _,
    4436             :                                 _,
    4437             :                                 _,
    4438             :                                 _,
    4439             :                                 _,
    4440             :                                 _,
    4441             :                                 _,
    4442             :                                 _,
    4443           0 :                                 state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacitySizeRatio);
    4444             :                         }
    4445             :                         // Check VRF DX heating coil heating capacity as a fuction of temperature performance curve. Only report here for
    4446             :                         // biquadratic curve type.
    4447          82 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0 && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex > 0 &&
    4448             :                             state.dataCurveManager
    4449          41 :                                     ->PerfCurve(GetDXCoilCapFTCurveIndex(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex, ErrorsFound))
    4450          41 :                                     .numDims == 2) {
    4451          15 :                             if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingPerformanceOATType ==
    4452             :                                 DataHVACGlobals::WetBulbIndicator) {
    4453          90 :                                 checkCurveIsNormalizedToOne(
    4454             :                                     state,
    4455          30 :                                     "GetDXCoils: " + DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num),
    4456          45 :                                     DXCoils::GetDXCoilName(
    4457             :                                         state,
    4458          15 :                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4459             :                                         ErrorsFound,
    4460          15 :                                         DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num)),
    4461          15 :                                     GetDXCoilCapFTCurveIndex(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex, ErrorsFound),
    4462             :                                     "Heating Capacity Ratio Modifier Function of Temperature Curve Name",
    4463          30 :                                     Curve::GetCurveName(
    4464          15 :                                         state, GetDXCoilCapFTCurveIndex(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex, ErrorsFound)),
    4465             :                                     RatedInletAirTempHeat,
    4466             :                                     RatedOutdoorWetBulbTempHeat);
    4467           0 :                             } else if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingPerformanceOATType ==
    4468             :                                        DataHVACGlobals::DryBulbIndicator) {
    4469           0 :                                 checkCurveIsNormalizedToOne(
    4470             :                                     state,
    4471           0 :                                     "GetDXCoils: " + DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num),
    4472           0 :                                     DXCoils::GetDXCoilName(
    4473             :                                         state,
    4474           0 :                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4475             :                                         ErrorsFound,
    4476           0 :                                         DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num)),
    4477           0 :                                     GetDXCoilCapFTCurveIndex(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex, ErrorsFound),
    4478             :                                     "Heating Capacity Ratio Modifier Function of Temperature Curve Name",
    4479           0 :                                     Curve::GetCurveName(
    4480           0 :                                         state, GetDXCoilCapFTCurveIndex(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex, ErrorsFound)),
    4481             :                                     RatedInletAirTempHeat,
    4482             :                                     RatedOutdoorAirTempHeat);
    4483             :                             }
    4484             :                         }
    4485             : 
    4486             :                     } else {
    4487           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4488           0 :                         ShowContinueError(state, "... illegal " + cAlphaFieldNames(14) + " = " + cAlphaArgs(14));
    4489           0 :                         ErrorsFound = true;
    4490             :                     }
    4491             :                 }
    4492             :             } else {
    4493           0 :                 ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4494           0 :                 ShowContinueError(state,
    4495           0 :                                   "... when checking " +
    4496           0 :                                       DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num) + " \"" +
    4497           0 :                                       cAlphaArgs(14) + "\"");
    4498           0 :                 ShowContinueError(state, "... terminal unit not connected to condenser.");
    4499           0 :                 ShowContinueError(state, "... check that terminal unit is specified in a terminal unit list object.");
    4500           0 :                 ShowContinueError(
    4501             :                     state, "... also check that the terminal unit list name is specified in an AirConditioner:VariableRefrigerantFlow object.");
    4502           0 :                 ErrorsFound = true;
    4503             :             }
    4504             :         }
    4505             : 
    4506         112 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num == 0 &&
    4507          56 :             !state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num == 0) {
    4508           0 :             ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4509           0 :             ShowContinueError(state, "... no valid coils entered for this terminal unit. Simulation will not proceed.");
    4510           0 :             ErrorsFound = true;
    4511             :         }
    4512             : 
    4513          56 :         if (!lAlphaFieldBlanks(15)) {
    4514           1 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).AvailManagerListName = cAlphaArgs(15);
    4515             :         }
    4516          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElec = rNumericArgs(8);
    4517          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec = rNumericArgs(9);
    4518             : 
    4519          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HVACSizingIndex = 0;
    4520          56 :         if (!lAlphaFieldBlanks(16)) {
    4521           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HVACSizingIndex =
    4522           0 :                 UtilityRoutines::FindItemInList(cAlphaArgs(16), state.dataSize->ZoneHVACSizing);
    4523           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HVACSizingIndex == 0) {
    4524           0 :                 ShowSevereError(state, cAlphaFieldNames(16) + " = " + cAlphaArgs(16) + " not found.");
    4525           0 :                 ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4526           0 :                 ErrorsFound = true;
    4527             :             }
    4528             :         }
    4529             : 
    4530             :         // supplemental heating coil
    4531          56 :         if (!lAlphaFieldBlanks(17) && !lAlphaFieldBlanks(18)) {
    4532             : 
    4533          10 :             SuppHeatingCoilType = cAlphaArgs(17);
    4534          10 :             SuppHeatingCoilName = cAlphaArgs(18);
    4535             : 
    4536          10 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName = SuppHeatingCoilName;
    4537             : 
    4538          10 :             errFlag = false;
    4539          10 :             if (UtilityRoutines::SameString(SuppHeatingCoilType, "Coil:Heating:Water")) {
    4540           2 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num = DataHVACGlobals::Coil_HeatingWater;
    4541           8 :             } else if (UtilityRoutines::SameString(SuppHeatingCoilType, "Coil:Heating:Steam")) {
    4542           2 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num = DataHVACGlobals::Coil_HeatingSteam;
    4543          14 :             } else if (UtilityRoutines::SameString(SuppHeatingCoilType, "Coil:Heating:Fuel") ||
    4544           8 :                        UtilityRoutines::SameString(SuppHeatingCoilType, "Coil:Heating:Electric")) {
    4545           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num =
    4546           6 :                     HeatingCoils::GetHeatingCoilTypeNum(state, SuppHeatingCoilType, SuppHeatingCoilName, errFlag);
    4547             :             }
    4548             : 
    4549          10 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType = SuppHeatingCoilType;
    4550          10 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatingCoilPresent = true;
    4551             : 
    4552          16 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingGasOrOtherFuel ||
    4553           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingElectric) {
    4554           6 :                 errFlag = false;
    4555           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num =
    4556           6 :                     HeatingCoils::GetHeatingCoilTypeNum(state, SuppHeatingCoilType, SuppHeatingCoilName, errFlag);
    4557           6 :                 if (errFlag) {
    4558           0 :                     ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4559           0 :                     ErrorsFound = true;
    4560             :                 } else {
    4561           6 :                     ValidateComponent(state, SuppHeatingCoilType, SuppHeatingCoilName, IsNotOK, cCurrentModuleObject);
    4562           6 :                     if (IsNotOK) {
    4563           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4564           0 :                         ErrorsFound = true;
    4565             :                     } else { // mine data from supplemental heating coil
    4566             :                         // Get the supplemental heating coil index
    4567           6 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex =
    4568           6 :                             HeatingCoils::GetHeatingCoilIndex(state, SuppHeatingCoilType, SuppHeatingCoilName, IsNotOK);
    4569           6 :                         if (IsNotOK) {
    4570           0 :                             ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4571           0 :                             ErrorsFound = true;
    4572             :                         }
    4573             :                         // Get the design supplemental heating capacity
    4574           6 :                         errFlag = false;
    4575           6 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity =
    4576           6 :                             HeatingCoils::GetCoilCapacity(state, SuppHeatingCoilType, SuppHeatingCoilName, errFlag);
    4577           6 :                         if (errFlag) {
    4578           0 :                             ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4579           0 :                             ErrorsFound = true;
    4580             :                         }
    4581             :                         // Get the supplemental heating Coil air inlet node
    4582           6 :                         errFlag = false;
    4583           6 :                         SuppHeatCoilAirInletNode = HeatingCoils::GetCoilInletNode(state, SuppHeatingCoilType, SuppHeatingCoilName, errFlag);
    4584           6 :                         if (errFlag) {
    4585           0 :                             ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4586           0 :                             ErrorsFound = true;
    4587             :                         }
    4588             :                         // Get the supplemental heating Coil air outlet node
    4589           6 :                         errFlag = false;
    4590           6 :                         SuppHeatCoilAirOutletNode = HeatingCoils::GetCoilOutletNode(state, SuppHeatingCoilType, SuppHeatingCoilName, errFlag);
    4591           6 :                         if (errFlag) {
    4592           0 :                             ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4593           0 :                             ErrorsFound = true;
    4594             :                         }
    4595             :                     } // IF (IsNotOK) THEN
    4596             :                 }
    4597             : 
    4598           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirInletNode = SuppHeatCoilAirInletNode;
    4599           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirOutletNode = SuppHeatCoilAirOutletNode;
    4600             : 
    4601           4 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    4602             : 
    4603           2 :                 ValidateComponent(state, SuppHeatingCoilType, SuppHeatingCoilName, IsNotOK, cCurrentModuleObject);
    4604           2 :                 if (IsNotOK) {
    4605           0 :                     ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4606           0 :                     ErrorsFound = true;
    4607             :                 } else { // mine data from heating coil object
    4608             : 
    4609             :                     // Get the supplemental heating coil water Inlet or control node number
    4610           2 :                     errFlag = false;
    4611           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode =
    4612           4 :                         WaterCoils::GetCoilWaterInletNode(state, "Coil:Heating:Water", SuppHeatingCoilName, errFlag);
    4613           2 :                     if (errFlag) {
    4614           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4615           0 :                         ErrorsFound = true;
    4616             :                     }
    4617             :                     // Get the supplemental heating coil hot water max volume flow rate
    4618           2 :                     errFlag = false;
    4619           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    4620           4 :                         WaterCoils::GetCoilMaxWaterFlowRate(state, "Coil:Heating:Water", SuppHeatingCoilName, errFlag);
    4621           2 :                     if (errFlag) {
    4622           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4623           0 :                         ErrorsFound = true;
    4624             :                     }
    4625             :                     // Get the supplemental heating Coil air inlet node
    4626           2 :                     errFlag = false;
    4627           2 :                     SuppHeatCoilAirInletNode = WaterCoils::GetCoilInletNode(state, "Coil:Heating:Water", SuppHeatingCoilName, errFlag);
    4628           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirInletNode = SuppHeatCoilAirInletNode;
    4629           2 :                     if (errFlag) {
    4630           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4631           0 :                         ErrorsFound = true;
    4632             :                     }
    4633             :                     // Get the supplemental heating coil air outlet node
    4634           2 :                     errFlag = false;
    4635           2 :                     SuppHeatCoilAirOutletNode = WaterCoils::GetCoilOutletNode(state, "Coil:Heating:Water", SuppHeatingCoilName, errFlag);
    4636           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirOutletNode = SuppHeatCoilAirOutletNode;
    4637           2 :                     if (errFlag) {
    4638           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4639           0 :                         ErrorsFound = true;
    4640             :                     }
    4641             :                 }
    4642             : 
    4643           2 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) {
    4644             : 
    4645           2 :                 ValidateComponent(state, SuppHeatingCoilType, SuppHeatingCoilName, IsNotOK, cCurrentModuleObject);
    4646           2 :                 if (IsNotOK) {
    4647           0 :                     ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4648           0 :                     ErrorsFound = true;
    4649             :                 } else { // mine data from supplemental heating coil object
    4650           2 :                     errFlag = false;
    4651           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex =
    4652           4 :                         SteamCoils::GetSteamCoilIndex(state, "COIL:HEATING:STEAM", SuppHeatingCoilName, errFlag);
    4653           2 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex == 0) {
    4654           0 :                         ShowSevereError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4655           0 :                         ErrorsFound = true;
    4656             :                     }
    4657             :                     // Get the supplemental heating Coil steam inlet node number
    4658           2 :                     errFlag = false;
    4659           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode =
    4660           4 :                         SteamCoils::GetCoilSteamInletNode(state, "Coil:Heating:Steam", SuppHeatingCoilName, errFlag);
    4661           2 :                     if (errFlag) {
    4662           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4663           0 :                         ErrorsFound = true;
    4664             :                     }
    4665             :                     // Get the supplemental heating coil steam max volume flow rate
    4666           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    4667           2 :                         SteamCoils::GetCoilMaxSteamFlowRate(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, errFlag);
    4668           2 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow > 0.0) {
    4669           0 :                         int SteamIndex = 0; // fluid type index of 0 is passed if steam
    4670           0 :                         Real64 TempSteamIn = 100.0;
    4671           0 :                         Real64 SteamDensity = FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName);
    4672           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    4673           0 :                             SteamCoils::GetCoilMaxSteamFlowRate(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, errFlag) *
    4674             :                             SteamDensity;
    4675             :                     }
    4676             :                     // Get the supplemental heating coil air inlet node
    4677           2 :                     errFlag = false;
    4678           2 :                     SuppHeatCoilAirInletNode = SteamCoils::GetCoilAirInletNode(
    4679           2 :                         state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, SuppHeatingCoilName, errFlag);
    4680           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirInletNode = SuppHeatCoilAirInletNode;
    4681           2 :                     if (errFlag) {
    4682           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4683           0 :                         ErrorsFound = true;
    4684             :                     }
    4685             :                     // Get the supplemental heating coil air outlet node
    4686           2 :                     errFlag = false;
    4687           2 :                     SuppHeatCoilAirOutletNode = SteamCoils::GetCoilAirOutletNode(
    4688           2 :                         state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, SuppHeatingCoilName, errFlag);
    4689           2 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilAirOutletNode = SuppHeatCoilAirOutletNode;
    4690           2 :                     if (errFlag) {
    4691           0 :                         ShowContinueError(state, "Occurs in " + cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    4692           0 :                         ErrorsFound = true;
    4693             :                     }
    4694             :                 }
    4695             :             }
    4696             :         } else { // if (!lAlphaFieldBlanks(17) && !lAlphaFieldBlanks(18)) {
    4697          46 :             if (!lAlphaFieldBlanks(17) && lAlphaFieldBlanks(18)) {
    4698           0 :                 ShowWarningError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4699           0 :                 ShowContinueError(state, "...Supplemental heating coil type = " + cAlphaArgs(17));
    4700           0 :                 ShowContinueError(state, "...But missing the associated supplemental heating coil name. ");
    4701           0 :                 ShowContinueError(state, "...The supplemental heating coil will not be simulated. ");
    4702             :             }
    4703          46 :             if (lAlphaFieldBlanks(17) && !lAlphaFieldBlanks(18)) {
    4704           0 :                 ShowWarningError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4705           0 :                 ShowContinueError(state, "...Supplemental heating coil name = " + cAlphaArgs(18));
    4706           0 :                 ShowContinueError(state, "...But missing the associated supplemental heating coil type. ");
    4707           0 :                 ShowContinueError(state, "...The supplemental heating coil will not be simulated. ");
    4708             :             }
    4709             :         }
    4710             : 
    4711          56 :         if (!lAlphaFieldBlanks(19)) {
    4712           1 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum = UtilityRoutines::FindItemInList(cAlphaArgs(19), state.dataHeatBal->Zone);
    4713           1 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum == 0) {
    4714           0 :                 ShowSevereError(state, cCurrentModuleObject + " = " + cAlphaArgs(1));
    4715           0 :                 ShowContinueError(state, "Illegal " + cAlphaFieldNames(19) + " = " + cAlphaArgs(19));
    4716           0 :                 ErrorsFound = true;
    4717             :             }
    4718             :         }
    4719             : 
    4720             :         // set supplemental heating coil operation temperature limits
    4721          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatingCoilPresent) {
    4722             :             // Set maximum supply air temperature for supplemental heating coil
    4723          10 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxSATFromSuppHeatCoil = rNumericArgs(11);
    4724             :             // set maximum outdoor dry-bulb temperature for supplemental heating coil operation
    4725          10 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxOATSuppHeatingCoil = rNumericArgs(12);
    4726             :         }
    4727             : 
    4728             :         // Add cooling coil to component sets array
    4729          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    4730             : 
    4731         280 :             SetUpCompSets(state,
    4732             :                           cCurrentModuleObject,
    4733          56 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    4734          56 :                           DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXCoolCoilType_Num),
    4735          56 :                           cAlphaArgs(12),
    4736          56 :                           state.dataLoopNodes->NodeID(CCoilInletNodeNum),
    4737          56 :                           state.dataLoopNodes->NodeID(CCoilOutletNodeNum));
    4738             :             //     set heating coil present flag
    4739         168 :             SetDXCoolingCoilData(state,
    4740          56 :                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex,
    4741             :                                  ErrorsFound,
    4742             :                                  _,
    4743             :                                  _,
    4744             :                                  _,
    4745             :                                  _,
    4746             :                                  _,
    4747             :                                  _,
    4748             :                                  _,
    4749             :                                  _,
    4750             :                                  _,
    4751             :                                  _,
    4752             :                                  _,
    4753             :                                  _,
    4754             :                                  _,
    4755             :                                  _,
    4756             :                                  _,
    4757             :                                  _,
    4758          56 :                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent);
    4759             : 
    4760             :             //   check that curve types are present in VRF Condenser if cooling coil is present in terminal unit (can be blank)
    4761             :             //   all curves are checked for correct type if a curve name is entered in the VRF condenser object. Check that the
    4762             :             //   curve is present if the corresponding coil is entered in the terminal unit.
    4763          56 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    4764             : 
    4765          56 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum !=
    4766             :                     AlgorithmType::FluidTCtrl) {
    4767             : 
    4768          82 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CoolingCapacity <= 0 &&
    4769          41 :                         state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).CoolingCapacity != AutoSize) {
    4770           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4771           0 :                         ShowContinueError(state,
    4772             :                                           "...This terminal unit contains a cooling coil and rated cooling capacity is also required in the "
    4773             :                                           "associated condenser object.");
    4774           0 :                         ShowContinueError(
    4775             :                             state,
    4776           0 :                             "...Rated Cooling Capacity must also be specified for condenser = " +
    4777           0 :                                 std::string(
    4778           0 :                                     cVRFTypes(state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFSystemTypeNum)) +
    4779           0 :                                 " \"" + state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).Name + "\".");
    4780           0 :                         ErrorsFound = true;
    4781             :                     }
    4782             :                 }
    4783             :             }
    4784             :         }
    4785             : 
    4786             :         // Add heating coil to component sets array
    4787          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent) {
    4788             : 
    4789         280 :             SetUpCompSets(state,
    4790             :                           cCurrentModuleObject,
    4791          56 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    4792          56 :                           DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DXHeatCoilType_Num),
    4793          56 :                           cAlphaArgs(14),
    4794          56 :                           state.dataLoopNodes->NodeID(HCoilInletNodeNum),
    4795          56 :                           state.dataLoopNodes->NodeID(HCoilOutletNodeNum));
    4796             :             //     set cooling coil present flag
    4797         168 :             SetDXCoolingCoilData(state,
    4798          56 :                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex,
    4799             :                                  ErrorsFound,
    4800             :                                  _,
    4801             :                                  _,
    4802             :                                  _,
    4803             :                                  _,
    4804             :                                  _,
    4805             :                                  _,
    4806             :                                  _,
    4807             :                                  _,
    4808             :                                  _,
    4809             :                                  _,
    4810             :                                  _,
    4811             :                                  _,
    4812             :                                  _,
    4813             :                                  _,
    4814             :                                  _,
    4815          56 :                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent);
    4816             : 
    4817          56 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum > 0) {
    4818             : 
    4819          56 :                 if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum !=
    4820             :                     AlgorithmType::FluidTCtrl) {
    4821             : 
    4822          82 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacity <= 0 &&
    4823          41 :                         state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatingCapacity != AutoSize) {
    4824           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4825           0 :                         ShowContinueError(state,
    4826             :                                           "...This terminal unit contains a heating coil and rated heating capacity is also required in the "
    4827             :                                           "associated condenser object.");
    4828           0 :                         ShowContinueError(
    4829             :                             state,
    4830           0 :                             "...Rated Heating Capacity must also be specified for condenser = " +
    4831           0 :                                 std::string(
    4832           0 :                                     cVRFTypes(state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFSystemTypeNum)) +
    4833           0 :                                 " \"" + state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).Name + "\".");
    4834           0 :                         ErrorsFound = true;
    4835             :                     }
    4836             : 
    4837          41 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatCapFT == 0) {
    4838           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4839           0 :                         ShowContinueError(state,
    4840             :                                           "...This terminal unit contains a heating coil and heating performance curves are also required in the "
    4841             :                                           "associated condenser object.");
    4842           0 :                         ShowContinueError(
    4843             :                             state,
    4844           0 :                             "...Heating Capacity Ratio Modifier Function of Low Temperature Curve must also be specified for condenser = " +
    4845           0 :                                 std::string(
    4846           0 :                                     cVRFTypes(state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFSystemTypeNum)) +
    4847           0 :                                 " \"" + state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).Name + "\".");
    4848           0 :                         ErrorsFound = true;
    4849             :                     }
    4850             : 
    4851          41 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatEIRFT == 0) {
    4852           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4853           0 :                         ShowContinueError(state,
    4854             :                                           "...This terminal unit contains a heating coil and heating performance curves are also required in the "
    4855             :                                           "associated condenser object.");
    4856           0 :                         ShowContinueError(
    4857             :                             state,
    4858           0 :                             "...Heating Energy Input Ratio Modifier Function of Low Temperature Curve must also be specified for condenser = " +
    4859           0 :                                 std::string(
    4860           0 :                                     cVRFTypes(state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFSystemTypeNum)) +
    4861           0 :                                 " \"" + state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).Name + "\".");
    4862           0 :                         ErrorsFound = true;
    4863             :                     }
    4864             : 
    4865          41 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).HeatEIRFPLR1 == 0) {
    4866           0 :                         ShowSevereError(state, cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"");
    4867           0 :                         ShowContinueError(state,
    4868             :                                           "...This terminal unit contains a heating coil and heating performance curves are also required in the "
    4869             :                                           "associated condenser object.");
    4870           0 :                         ShowContinueError(
    4871             :                             state,
    4872             :                             "...Heating Energy Input Ratio Modifier Function of Low Part-Load Ratio Curve must also be specified "
    4873           0 :                             "for condenser = " +
    4874           0 :                                 std::string(
    4875           0 :                                     cVRFTypes(state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFSystemTypeNum)) +
    4876           0 :                                 " \"" + state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).Name + "\".");
    4877             :                     }
    4878             :                 }
    4879             :             }
    4880             :         }
    4881             : 
    4882             :         // Add supplemental heating coil to component sets array
    4883          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatingCoilPresent) {
    4884          40 :             SetUpCompSets(state,
    4885             :                           cCurrentModuleObject,
    4886          10 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    4887          10 :                           DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num),
    4888             :                           SuppHeatingCoilName,
    4889          10 :                           state.dataLoopNodes->NodeID(SuppHeatCoilAirInletNode),
    4890          10 :                           state.dataLoopNodes->NodeID(SuppHeatCoilAirOutletNode));
    4891             :         }
    4892             :         // Set up component set for OA mixer - use OA node and Mixed air node
    4893          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed)
    4894         200 :             SetUpCompSets(state,
    4895             :                           cCurrentModuleObject,
    4896          50 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    4897             :                           "UNDEFINED",
    4898          50 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    4899          50 :                           state.dataLoopNodes->NodeID(OANodeNums(1)),
    4900         100 :                           state.dataLoopNodes->NodeID(OANodeNums(4)));
    4901             : 
    4902             :         // Get AirTerminal mixer data
    4903         448 :         GetATMixer(state,
    4904          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    4905          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerName,
    4906          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerIndex,
    4907          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType,
    4908          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerPriNode,
    4909          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerSecNode,
    4910          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerOutNode,
    4911          56 :                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum);
    4912         109 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_InletSide ||
    4913          53 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_SupplySide) {
    4914           5 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists = true;
    4915             :         }
    4916             :         // check that the VRF TU have local outside air and DOA
    4917          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists && OANodeNums(4) > 0) {
    4918           0 :             ShowSevereError(state,
    4919           0 :                             cCurrentModuleObject + " = \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name +
    4920             :                                 "\". VRF terminal unit has local as well as central outdoor air specified");
    4921           0 :             ErrorsFound = true;
    4922             :         }
    4923             : 
    4924             :         // for ZoneHVAC check that TU inlet node is a zone exhaust node otherwise ZoneAirNode and ZoneNum = 0
    4925          61 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists ||
    4926           5 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_SupplySide) {
    4927         371 :             for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
    4928         318 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue;
    4929         473 :                 for (NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumExhaustNodes; ++NodeNum) {
    4930         518 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum ==
    4931         259 :                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ExhaustNode(NodeNum)) {
    4932          51 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    4933          51 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum = CtrlZone;
    4934          51 :                         break;
    4935             :                     }
    4936             :                 }
    4937             :             }
    4938           3 :         } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_InletSide) {
    4939          21 :             for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
    4940          18 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue;
    4941          27 :                 for (NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++NodeNum) {
    4942          30 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum ==
    4943          15 :                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(NodeNum)) {
    4944           3 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    4945           3 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum = CtrlZone;
    4946           3 :                         break;
    4947             :                     }
    4948             :                 }
    4949             :             }
    4950             :         }
    4951          56 :         CheckVRFTUNodeConnections(state, VRFTUNum, ErrorsFound);
    4952             :     } // end Number of VRF Terminal Unit Loop
    4953             : 
    4954             :     //   perform additional error checking
    4955          23 :     for (NumList = 1; NumList <= state.dataHVACVarRefFlow->NumVRFTULists; ++NumList) {
    4956          68 :         for (VRFNum = 1; VRFNum <= state.dataHVACVarRefFlow->TerminalUnitList(NumList).NumTUInList; ++VRFNum) {
    4957          56 :             if (state.dataHVACVarRefFlow->TerminalUnitList(NumList).ZoneTUPtr(VRFNum) == 0) {
    4958             :                 // TU name in zone terminal unit list not found
    4959           0 :                 ShowSevereError(state, "ZoneTerminalUnitList \"" + state.dataHVACVarRefFlow->TerminalUnitList(NumList).Name + "\"");
    4960           0 :                 ShowContinueError(state,
    4961           0 :                                   "...Zone Terminal Unit = " + state.dataHVACVarRefFlow->TerminalUnitList(NumList).ZoneTUName(VRFNum) +
    4962             :                                       " improperly connected to system.");
    4963           0 :                 ShowContinueError(state, "...either the ZoneHVAC:TerminalUnit:VariableRefrigerantFlow object does not exist,");
    4964           0 :                 ShowContinueError(state, "...the ZoneHVAC:TerminalUnit:VariableRefrigerantFlow object name is misspelled,");
    4965           0 :                 ShowContinueError(state, "...or the ZoneTerminalUnitList object is not named in an AirConditioner:VariableRefrigerantFlow object.");
    4966           0 :                 ErrorsFound = true;
    4967             :             }
    4968          56 :             if (state.dataHVACVarRefFlow->VRFTU(VRFNum).VRFSysNum > 0) {
    4969          57 :                 if (state.dataHVACVarRefFlow->TerminalUnitList(NumList).NumTUInList == 1 &&
    4970           1 :                     state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFNum).VRFSysNum).VRFAlgorithmTypeNum == AlgorithmType::SysCurve) {
    4971           1 :                     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFNum).VRFSysNum).HeatRecoveryUsed) {
    4972           0 :                         ShowWarningError(state, "ZoneTerminalUnitList \"" + state.dataHVACVarRefFlow->TerminalUnitList(NumList).Name + "\"");
    4973           0 :                         ShowWarningError(state, "...Only 1 Terminal Unit connected to system and heat recovery is selected.");
    4974           0 :                         ShowContinueError(state, "...Heat recovery will be disabled.");
    4975           0 :                         state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed = false;
    4976             :                     }
    4977             :                 }
    4978             :             }
    4979             :         }
    4980             :     }
    4981             : 
    4982             :     //   warn when number of ZoneTerminalUnitList different from number of AirConditioner:VariableRefrigerantFlow
    4983          11 :     if (state.dataHVACVarRefFlow->NumVRFTULists != state.dataHVACVarRefFlow->NumVRFCond) {
    4984           0 :         ShowSevereError(state,
    4985           0 :                         format("The number of AirConditioner:VariableRefrigerantFlow objects ({}) does not match the number of "
    4986             :                                "ZoneTerminalUnitList objects ({}).",
    4987           0 :                                state.dataHVACVarRefFlow->NumVRFCond,
    4988           0 :                                state.dataHVACVarRefFlow->NumVRFTULists));
    4989           0 :         for (NumCond = 1; NumCond <= state.dataHVACVarRefFlow->NumVRFCond; ++NumCond) {
    4990           0 :             if (state.dataHVACVarRefFlow->VRF(NumCond).ZoneTUListPtr > 0) {
    4991           0 :                 ShowContinueError(state,
    4992           0 :                                   "...AirConditioner:VariableRefrigerantFlow = " + state.dataHVACVarRefFlow->VRF(NumCond).Name +
    4993           0 :                                       " specifies Zone Terminal Unit List Name = " +
    4994           0 :                                       state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRF(NumCond).ZoneTUListPtr).Name);
    4995             :             } else {
    4996           0 :                 ShowContinueError(state,
    4997           0 :                                   "...AirConditioner:VariableRefrigerantFlow = " + state.dataHVACVarRefFlow->VRF(NumCond).Name +
    4998             :                                       " Zone Terminal Unit List Name not found.");
    4999             :             }
    5000             :         }
    5001           0 :         ShowContinueError(state, "...listing ZoneTerminalUnitList objects.");
    5002           0 :         for (NumList = 1; NumList <= state.dataHVACVarRefFlow->NumVRFTULists; ++NumList) {
    5003           0 :             ShowContinueError(state, "...ZoneTerminalUnitList = " + state.dataHVACVarRefFlow->TerminalUnitList(NumList).Name);
    5004             :         }
    5005           0 :         ErrorsFound = true;
    5006             :     }
    5007             : 
    5008             :     // Set up output variables
    5009          67 :     for (VRFNum = 1; VRFNum <= state.dataHVACVarRefFlow->NumVRFTU; ++VRFNum) {
    5010          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFNum).CoolingCoilPresent) {
    5011         224 :             SetupOutputVariable(state,
    5012             :                                 "Zone VRF Air Terminal Cooling Electricity Rate",
    5013             :                                 OutputProcessor::Unit::W,
    5014          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).ParasiticCoolElecPower,
    5015             :                                 OutputProcessor::SOVTimeStepType::System,
    5016             :                                 OutputProcessor::SOVStoreType::Average,
    5017         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5018         224 :             SetupOutputVariable(state,
    5019             :                                 "Zone VRF Air Terminal Cooling Electricity Energy",
    5020             :                                 OutputProcessor::Unit::J,
    5021          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).ParasiticElecCoolConsumption,
    5022             :                                 OutputProcessor::SOVTimeStepType::System,
    5023             :                                 OutputProcessor::SOVStoreType::Summed,
    5024          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name,
    5025             :                                 _,
    5026             :                                 "Electricity",
    5027             :                                 "COOLING",
    5028             :                                 _,
    5029          56 :                                 "System");
    5030         224 :             SetupOutputVariable(state,
    5031             :                                 "Zone VRF Air Terminal Total Cooling Rate",
    5032             :                                 OutputProcessor::Unit::W,
    5033          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).TotalCoolingRate,
    5034             :                                 OutputProcessor::SOVTimeStepType::System,
    5035             :                                 OutputProcessor::SOVStoreType::Average,
    5036         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5037         224 :             SetupOutputVariable(state,
    5038             :                                 "Zone VRF Air Terminal Sensible Cooling Rate",
    5039             :                                 OutputProcessor::Unit::W,
    5040          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).SensibleCoolingRate,
    5041             :                                 OutputProcessor::SOVTimeStepType::System,
    5042             :                                 OutputProcessor::SOVStoreType::Average,
    5043         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5044         224 :             SetupOutputVariable(state,
    5045             :                                 "Zone VRF Air Terminal Latent Cooling Rate",
    5046             :                                 OutputProcessor::Unit::W,
    5047          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).LatentCoolingRate,
    5048             :                                 OutputProcessor::SOVTimeStepType::System,
    5049             :                                 OutputProcessor::SOVStoreType::Average,
    5050         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5051         224 :             SetupOutputVariable(state,
    5052             :                                 "Zone VRF Air Terminal Total Cooling Energy",
    5053             :                                 OutputProcessor::Unit::J,
    5054          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).TotalCoolingEnergy,
    5055             :                                 OutputProcessor::SOVTimeStepType::System,
    5056             :                                 OutputProcessor::SOVStoreType::Summed,
    5057         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5058         224 :             SetupOutputVariable(state,
    5059             :                                 "Zone VRF Air Terminal Sensible Cooling Energy",
    5060             :                                 OutputProcessor::Unit::J,
    5061          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).SensibleCoolingEnergy,
    5062             :                                 OutputProcessor::SOVTimeStepType::System,
    5063             :                                 OutputProcessor::SOVStoreType::Summed,
    5064         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5065         224 :             SetupOutputVariable(state,
    5066             :                                 "Zone VRF Air Terminal Latent Cooling Energy",
    5067             :                                 OutputProcessor::Unit::J,
    5068          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).LatentCoolingEnergy,
    5069             :                                 OutputProcessor::SOVTimeStepType::System,
    5070             :                                 OutputProcessor::SOVStoreType::Summed,
    5071         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5072             :         }
    5073          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFNum).HeatingCoilPresent) {
    5074         224 :             SetupOutputVariable(state,
    5075             :                                 "Zone VRF Air Terminal Heating Electricity Rate",
    5076             :                                 OutputProcessor::Unit::W,
    5077          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).ParasiticHeatElecPower,
    5078             :                                 OutputProcessor::SOVTimeStepType::System,
    5079             :                                 OutputProcessor::SOVStoreType::Average,
    5080         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5081         224 :             SetupOutputVariable(state,
    5082             :                                 "Zone VRF Air Terminal Heating Electricity Energy",
    5083             :                                 OutputProcessor::Unit::J,
    5084          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).ParasiticElecHeatConsumption,
    5085             :                                 OutputProcessor::SOVTimeStepType::System,
    5086             :                                 OutputProcessor::SOVStoreType::Summed,
    5087          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name,
    5088             :                                 _,
    5089             :                                 "Electricity",
    5090             :                                 "HEATING",
    5091             :                                 _,
    5092          56 :                                 "System");
    5093         224 :             SetupOutputVariable(state,
    5094             :                                 "Zone VRF Air Terminal Total Heating Rate",
    5095             :                                 OutputProcessor::Unit::W,
    5096          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).TotalHeatingRate,
    5097             :                                 OutputProcessor::SOVTimeStepType::System,
    5098             :                                 OutputProcessor::SOVStoreType::Average,
    5099         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5100         224 :             SetupOutputVariable(state,
    5101             :                                 "Zone VRF Air Terminal Sensible Heating Rate",
    5102             :                                 OutputProcessor::Unit::W,
    5103          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).SensibleHeatingRate,
    5104             :                                 OutputProcessor::SOVTimeStepType::System,
    5105             :                                 OutputProcessor::SOVStoreType::Average,
    5106         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5107         224 :             SetupOutputVariable(state,
    5108             :                                 "Zone VRF Air Terminal Latent Heating Rate",
    5109             :                                 OutputProcessor::Unit::W,
    5110          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).LatentHeatingRate,
    5111             :                                 OutputProcessor::SOVTimeStepType::System,
    5112             :                                 OutputProcessor::SOVStoreType::Average,
    5113         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5114         224 :             SetupOutputVariable(state,
    5115             :                                 "Zone VRF Air Terminal Total Heating Energy",
    5116             :                                 OutputProcessor::Unit::J,
    5117          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).TotalHeatingEnergy,
    5118             :                                 OutputProcessor::SOVTimeStepType::System,
    5119             :                                 OutputProcessor::SOVStoreType::Summed,
    5120         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5121         224 :             SetupOutputVariable(state,
    5122             :                                 "Zone VRF Air Terminal Sensible Heating Energy",
    5123             :                                 OutputProcessor::Unit::J,
    5124          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).SensibleHeatingEnergy,
    5125             :                                 OutputProcessor::SOVTimeStepType::System,
    5126             :                                 OutputProcessor::SOVStoreType::Summed,
    5127         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5128         224 :             SetupOutputVariable(state,
    5129             :                                 "Zone VRF Air Terminal Latent Heating Energy",
    5130             :                                 OutputProcessor::Unit::J,
    5131          56 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).LatentHeatingEnergy,
    5132             :                                 OutputProcessor::SOVTimeStepType::System,
    5133             :                                 OutputProcessor::SOVStoreType::Summed,
    5134         112 :                                 state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5135             :         }
    5136         224 :         SetupOutputVariable(state,
    5137             :                             "Zone VRF Air Terminal Fan Availability Status",
    5138             :                             OutputProcessor::Unit::None,
    5139          56 :                             state.dataHVACVarRefFlow->VRFTU(VRFNum).AvailStatus,
    5140             :                             OutputProcessor::SOVTimeStepType::System,
    5141             :                             OutputProcessor::SOVStoreType::Average,
    5142         112 :                             state.dataHVACVarRefFlow->VRFTU(VRFNum).Name);
    5143          56 :         if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5144           0 :             SetupEMSActuator(state,
    5145             :                              "Variable Refrigerant Flow Terminal Unit",
    5146           0 :                              state.dataHVACVarRefFlow->VRFTU(VRFNum).Name,
    5147             :                              "Part Load Ratio",
    5148             :                              "[fraction]",
    5149           0 :                              state.dataHVACVarRefFlow->VRFTU(VRFNum).EMSOverridePartLoadFrac,
    5150           0 :                              state.dataHVACVarRefFlow->VRFTU(VRFNum).EMSValueForPartLoadFrac);
    5151             :         }
    5152             :     }
    5153             : 
    5154          23 :     for (NumCond = 1; NumCond <= state.dataHVACVarRefFlow->NumVRFCond; ++NumCond) {
    5155          48 :         SetupOutputVariable(state,
    5156             :                             "VRF Heat Pump Total Cooling Rate",
    5157             :                             OutputProcessor::Unit::W,
    5158          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).TotalCoolingCapacity,
    5159             :                             OutputProcessor::SOVTimeStepType::System,
    5160             :                             OutputProcessor::SOVStoreType::Average,
    5161          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5162          48 :         SetupOutputVariable(state,
    5163             :                             "VRF Heat Pump Total Heating Rate",
    5164             :                             OutputProcessor::Unit::W,
    5165          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).TotalHeatingCapacity,
    5166             :                             OutputProcessor::SOVTimeStepType::System,
    5167             :                             OutputProcessor::SOVStoreType::Average,
    5168          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5169          60 :         SetupOutputVariable(state,
    5170          24 :                             "VRF Heat Pump Cooling " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Rate",
    5171             :                             OutputProcessor::Unit::W,
    5172          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).ElecCoolingPower,
    5173             :                             OutputProcessor::SOVTimeStepType::System,
    5174             :                             OutputProcessor::SOVStoreType::Average,
    5175          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5176          72 :         SetupOutputVariable(state,
    5177          24 :                             "VRF Heat Pump Cooling " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Energy",
    5178             :                             OutputProcessor::Unit::J,
    5179          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).CoolElecConsumption,
    5180             :                             OutputProcessor::SOVTimeStepType::System,
    5181             :                             OutputProcessor::SOVStoreType::Summed,
    5182          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5183             :                             _,
    5184          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).FuelType,
    5185             :                             "COOLING",
    5186             :                             _,
    5187             :                             "System");
    5188          60 :         SetupOutputVariable(state,
    5189          24 :                             "VRF Heat Pump Heating " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Rate",
    5190             :                             OutputProcessor::Unit::W,
    5191          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).ElecHeatingPower,
    5192             :                             OutputProcessor::SOVTimeStepType::System,
    5193             :                             OutputProcessor::SOVStoreType::Average,
    5194          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5195          72 :         SetupOutputVariable(state,
    5196          24 :                             "VRF Heat Pump Heating " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Energy",
    5197             :                             OutputProcessor::Unit::J,
    5198          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).HeatElecConsumption,
    5199             :                             OutputProcessor::SOVTimeStepType::System,
    5200             :                             OutputProcessor::SOVStoreType::Summed,
    5201          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5202             :                             _,
    5203          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).FuelType,
    5204             :                             "HEATING",
    5205             :                             _,
    5206             :                             "System");
    5207             : 
    5208          48 :         SetupOutputVariable(state,
    5209             :                             "VRF Heat Pump Cooling COP",
    5210             :                             OutputProcessor::Unit::None,
    5211          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).OperatingCoolingCOP,
    5212             :                             OutputProcessor::SOVTimeStepType::System,
    5213             :                             OutputProcessor::SOVStoreType::Average,
    5214          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5215          48 :         SetupOutputVariable(state,
    5216             :                             "VRF Heat Pump Heating COP",
    5217             :                             OutputProcessor::Unit::None,
    5218          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).OperatingHeatingCOP,
    5219             :                             OutputProcessor::SOVTimeStepType::System,
    5220             :                             OutputProcessor::SOVStoreType::Average,
    5221          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5222          48 :         SetupOutputVariable(state,
    5223             :                             "VRF Heat Pump COP",
    5224             :                             OutputProcessor::Unit::None,
    5225          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).OperatingCOP,
    5226             :                             OutputProcessor::SOVTimeStepType::System,
    5227             :                             OutputProcessor::SOVStoreType::Average,
    5228          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5229             : 
    5230          12 :         if (state.dataHVACVarRefFlow->VRF(NumCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    5231             :             // For VRF_FluidTCtrl Model
    5232          12 :             SetupOutputVariable(state,
    5233             :                                 "VRF Heat Pump Compressor Electricity Rate",
    5234             :                                 OutputProcessor::Unit::W,
    5235           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Ncomp,
    5236             :                                 OutputProcessor::SOVTimeStepType::System,
    5237             :                                 OutputProcessor::SOVStoreType::Average,
    5238           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5239          12 :             SetupOutputVariable(state,
    5240             :                                 "VRF Heat Pump Outdoor Unit Fan Power",
    5241             :                                 OutputProcessor::Unit::W,
    5242           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).OUFanPower,
    5243             :                                 OutputProcessor::SOVTimeStepType::System,
    5244             :                                 OutputProcessor::SOVStoreType::Average,
    5245           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5246          12 :             SetupOutputVariable(state,
    5247             :                                 "VRF Heat Pump Compressor Rotating Speed",
    5248             :                                 OutputProcessor::Unit::rev_min,
    5249           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).CompActSpeed,
    5250             :                                 OutputProcessor::SOVTimeStepType::System,
    5251             :                                 OutputProcessor::SOVStoreType::Average,
    5252           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5253          12 :             SetupOutputVariable(state,
    5254             :                                 "VRF Heat Pump Indoor Unit Evaporating Temperature",
    5255             :                                 OutputProcessor::Unit::C,
    5256           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).IUEvaporatingTemp,
    5257             :                                 OutputProcessor::SOVTimeStepType::System,
    5258             :                                 OutputProcessor::SOVStoreType::Average,
    5259           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5260          12 :             SetupOutputVariable(state,
    5261             :                                 "VRF Heat Pump Outdoor Unit Condensing Temperature",
    5262             :                                 OutputProcessor::Unit::C,
    5263           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).CondensingTemp,
    5264             :                                 OutputProcessor::SOVTimeStepType::System,
    5265             :                                 OutputProcessor::SOVStoreType::Average,
    5266           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5267          12 :             SetupOutputVariable(state,
    5268             :                                 "VRF Heat Pump Indoor Unit Condensing Temperature",
    5269             :                                 OutputProcessor::Unit::C,
    5270           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).IUCondensingTemp,
    5271             :                                 OutputProcessor::SOVTimeStepType::System,
    5272             :                                 OutputProcessor::SOVStoreType::Average,
    5273           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5274          12 :             SetupOutputVariable(state,
    5275             :                                 "VRF Heat Pump Outdoor Unit Evaporating Temperature",
    5276             :                                 OutputProcessor::Unit::C,
    5277           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).EvaporatingTemp,
    5278             :                                 OutputProcessor::SOVTimeStepType::System,
    5279             :                                 OutputProcessor::SOVStoreType::Average,
    5280           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5281          12 :             SetupOutputVariable(state,
    5282             :                                 "VRF Heat Pump Cooling Capacity at Max Compressor Speed",
    5283             :                                 OutputProcessor::Unit::W,
    5284           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).CoolingCapacity,
    5285             :                                 OutputProcessor::SOVTimeStepType::System,
    5286             :                                 OutputProcessor::SOVStoreType::Average,
    5287           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5288          12 :             SetupOutputVariable(state,
    5289             :                                 "VRF Heat Pump Heating Capacity at Max Compressor Speed",
    5290             :                                 OutputProcessor::Unit::W,
    5291           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).HeatingCapacity,
    5292             :                                 OutputProcessor::SOVTimeStepType::System,
    5293             :                                 OutputProcessor::SOVStoreType::Average,
    5294           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5295          12 :             SetupOutputVariable(state,
    5296             :                                 "VRF Heat Pump Indoor Unit Piping Correction for Cooling",
    5297             :                                 OutputProcessor::Unit::None,
    5298           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).PipingCorrectionCooling,
    5299             :                                 OutputProcessor::SOVTimeStepType::System,
    5300             :                                 OutputProcessor::SOVStoreType::Average,
    5301           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5302          12 :             SetupOutputVariable(state,
    5303             :                                 "VRF Heat Pump Indoor Unit Piping Correction for Heating",
    5304             :                                 OutputProcessor::Unit::None,
    5305           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).PipingCorrectionHeating,
    5306             :                                 OutputProcessor::SOVTimeStepType::System,
    5307             :                                 OutputProcessor::SOVStoreType::Average,
    5308           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5309          12 :             SetupOutputVariable(state,
    5310             :                                 "VRF Heat Pump Outdoor Unit Evaporator Heat Extract Rate",
    5311             :                                 OutputProcessor::Unit::W,
    5312           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).OUEvapHeatRate,
    5313             :                                 OutputProcessor::SOVTimeStepType::System,
    5314             :                                 OutputProcessor::SOVStoreType::Average,
    5315           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5316          12 :             SetupOutputVariable(state,
    5317             :                                 "VRF Heat Pump Outdoor Unit Condenser Heat Release Rate",
    5318             :                                 OutputProcessor::Unit::W,
    5319           3 :                                 state.dataHVACVarRefFlow->VRF(NumCond).OUCondHeatRate,
    5320             :                                 OutputProcessor::SOVTimeStepType::System,
    5321             :                                 OutputProcessor::SOVStoreType::Average,
    5322           6 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5323             : 
    5324             :         } else {
    5325             :             // For VRF_SysCurve Model
    5326          27 :             SetupOutputVariable(state,
    5327             :                                 "VRF Heat Pump Maximum Capacity Cooling Rate",
    5328             :                                 OutputProcessor::Unit::W,
    5329           9 :                                 state.dataHVACVarRefFlow->MaxCoolingCapacity(NumCond),
    5330             :                                 OutputProcessor::SOVTimeStepType::System,
    5331             :                                 OutputProcessor::SOVStoreType::Average,
    5332          18 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5333          27 :             SetupOutputVariable(state,
    5334             :                                 "VRF Heat Pump Maximum Capacity Heating Rate",
    5335             :                                 OutputProcessor::Unit::W,
    5336           9 :                                 state.dataHVACVarRefFlow->MaxHeatingCapacity(NumCond),
    5337             :                                 OutputProcessor::SOVTimeStepType::System,
    5338             :                                 OutputProcessor::SOVStoreType::Average,
    5339          18 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5340             :         }
    5341             : 
    5342          27 :         if (state.dataHVACVarRefFlow->VRF(NumCond).DefrostStrategy == StandardRatings::DefrostStrat::Resistive ||
    5343           6 :             (state.dataHVACVarRefFlow->VRF(NumCond).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
    5344           3 :              state.dataHVACVarRefFlow->VRF(NumCond).FuelTypeNum == DataGlobalConstants::ResourceType::Electricity)) {
    5345          48 :             SetupOutputVariable(state,
    5346             :                                 "VRF Heat Pump Defrost Electricity Rate",
    5347             :                                 OutputProcessor::Unit::W,
    5348          12 :                                 state.dataHVACVarRefFlow->VRF(NumCond).DefrostPower,
    5349             :                                 OutputProcessor::SOVTimeStepType::System,
    5350             :                                 OutputProcessor::SOVStoreType::Average,
    5351          24 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5352          48 :             SetupOutputVariable(state,
    5353             :                                 "VRF Heat Pump Defrost Electricity Energy",
    5354             :                                 OutputProcessor::Unit::J,
    5355          12 :                                 state.dataHVACVarRefFlow->VRF(NumCond).DefrostConsumption,
    5356             :                                 OutputProcessor::SOVTimeStepType::System,
    5357             :                                 OutputProcessor::SOVStoreType::Summed,
    5358          12 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5359             :                                 _,
    5360             :                                 "Electricity",
    5361             :                                 "HEATING",
    5362             :                                 _,
    5363          12 :                                 "System");
    5364             :         } else { // defrost energy applied to fuel type
    5365           0 :             SetupOutputVariable(state,
    5366           0 :                                 "VRF Heat Pump Defrost " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Rate",
    5367             :                                 OutputProcessor::Unit::W,
    5368           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).DefrostPower,
    5369             :                                 OutputProcessor::SOVTimeStepType::System,
    5370             :                                 OutputProcessor::SOVStoreType::Average,
    5371           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5372           0 :             SetupOutputVariable(state,
    5373           0 :                                 "VRF Heat Pump Defrost " + state.dataHVACVarRefFlow->VRF(NumCond).FuelType + " Energy",
    5374             :                                 OutputProcessor::Unit::J,
    5375           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).DefrostConsumption,
    5376             :                                 OutputProcessor::SOVTimeStepType::System,
    5377             :                                 OutputProcessor::SOVStoreType::Summed,
    5378           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5379             :                                 _,
    5380           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).FuelType,
    5381             :                                 "HEATING",
    5382             :                                 _,
    5383             :                                 "System");
    5384             :         }
    5385             : 
    5386          48 :         SetupOutputVariable(state,
    5387             :                             "VRF Heat Pump Part Load Ratio",
    5388             :                             OutputProcessor::Unit::None,
    5389          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).VRFCondPLR,
    5390             :                             OutputProcessor::SOVTimeStepType::System,
    5391             :                             OutputProcessor::SOVStoreType::Average,
    5392          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5393          48 :         SetupOutputVariable(state,
    5394             :                             "VRF Heat Pump Runtime Fraction",
    5395             :                             OutputProcessor::Unit::None,
    5396          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).VRFCondRTF,
    5397             :                             OutputProcessor::SOVTimeStepType::System,
    5398             :                             OutputProcessor::SOVStoreType::Average,
    5399          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5400          48 :         SetupOutputVariable(state,
    5401             :                             "VRF Heat Pump Cycling Ratio",
    5402             :                             OutputProcessor::Unit::None,
    5403          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).VRFCondCyclingRatio,
    5404             :                             OutputProcessor::SOVTimeStepType::System,
    5405             :                             OutputProcessor::SOVStoreType::Average,
    5406          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5407             : 
    5408          48 :         SetupOutputVariable(state,
    5409             :                             "VRF Heat Pump Operating Mode",
    5410             :                             OutputProcessor::Unit::None,
    5411          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).OperatingMode,
    5412             :                             OutputProcessor::SOVTimeStepType::System,
    5413             :                             OutputProcessor::SOVStoreType::Average,
    5414          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5415          48 :         SetupOutputVariable(state,
    5416             :                             "VRF Heat Pump Condenser Inlet Temperature",
    5417             :                             OutputProcessor::Unit::C,
    5418          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).CondenserInletTemp,
    5419             :                             OutputProcessor::SOVTimeStepType::System,
    5420             :                             OutputProcessor::SOVStoreType::Average,
    5421          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5422             : 
    5423          48 :         SetupOutputVariable(state,
    5424             :                             "VRF Heat Pump Crankcase Heater Electricity Rate",
    5425             :                             OutputProcessor::Unit::W,
    5426          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).CrankCaseHeaterPower,
    5427             :                             OutputProcessor::SOVTimeStepType::System,
    5428             :                             OutputProcessor::SOVStoreType::Average,
    5429          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5430          48 :         SetupOutputVariable(state,
    5431             :                             "VRF Heat Pump Crankcase Heater Electricity Energy",
    5432             :                             OutputProcessor::Unit::J,
    5433          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).CrankCaseHeaterElecConsumption,
    5434             :                             OutputProcessor::SOVTimeStepType::System,
    5435             :                             OutputProcessor::SOVStoreType::Summed,
    5436          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5437             :                             _,
    5438             :                             "Electricity",
    5439             :                             "COOLING",
    5440             :                             _,
    5441          12 :                             "System");
    5442          48 :         SetupOutputVariable(state,
    5443             :                             "VRF Heat Pump Terminal Unit Cooling Load Rate",
    5444             :                             OutputProcessor::Unit::W,
    5445          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).TUCoolingLoad,
    5446             :                             OutputProcessor::SOVTimeStepType::System,
    5447             :                             OutputProcessor::SOVStoreType::Average,
    5448          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5449          48 :         SetupOutputVariable(state,
    5450             :                             "VRF Heat Pump Terminal Unit Heating Load Rate",
    5451             :                             OutputProcessor::Unit::W,
    5452          12 :                             state.dataHVACVarRefFlow->VRF(NumCond).TUHeatingLoad,
    5453             :                             OutputProcessor::SOVTimeStepType::System,
    5454             :                             OutputProcessor::SOVStoreType::Average,
    5455          24 :                             state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5456          12 :         if (state.dataHVACVarRefFlow->VRF(NumCond).HeatRecoveryUsed) {
    5457           8 :             SetupOutputVariable(state,
    5458             :                                 "VRF Heat Pump Heat Recovery Status Change Multiplier",
    5459             :                                 OutputProcessor::Unit::None,
    5460           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).SUMultiplier,
    5461             :                                 OutputProcessor::SOVTimeStepType::System,
    5462             :                                 OutputProcessor::SOVStoreType::Average,
    5463           4 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5464           8 :             SetupOutputVariable(state,
    5465             :                                 "VRF Heat Pump Simultaneous Cooling and Heating Efficiency",
    5466             :                                 OutputProcessor::Unit::Btu_h_W,
    5467           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).SCHE,
    5468             :                                 OutputProcessor::SOVTimeStepType::System,
    5469             :                                 OutputProcessor::SOVStoreType::Average,
    5470           4 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5471           8 :             SetupOutputVariable(state,
    5472             :                                 "VRF Heat Pump Heat Recovery Rate",
    5473             :                                 OutputProcessor::Unit::W,
    5474           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).VRFHeatRec,
    5475             :                                 OutputProcessor::SOVTimeStepType::System,
    5476             :                                 OutputProcessor::SOVStoreType::Average,
    5477           4 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5478           8 :             SetupOutputVariable(state,
    5479             :                                 "VRF Heat Pump Heat Recovery Energy",
    5480             :                                 OutputProcessor::Unit::J,
    5481           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).VRFHeatEnergyRec,
    5482             :                                 OutputProcessor::SOVTimeStepType::System,
    5483             :                                 OutputProcessor::SOVStoreType::Summed,
    5484           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5485             :                                 _,
    5486             :                                 "ENERGYTRANSFER",
    5487             :                                 "HEATRECOVERY",
    5488             :                                 _,
    5489           2 :                                 "Plant");
    5490             :         }
    5491             : 
    5492          12 :         if (state.dataHVACVarRefFlow->VRF(NumCond).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5493           0 :             SetupOutputVariable(state,
    5494             :                                 "VRF Heat Pump Evaporative Condenser Water Use Volume",
    5495             :                                 OutputProcessor::Unit::m3,
    5496           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).EvapWaterConsumpRate,
    5497             :                                 OutputProcessor::SOVTimeStepType::System,
    5498             :                                 OutputProcessor::SOVStoreType::Summed,
    5499           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5500             :                                 _,
    5501             :                                 "Water",
    5502             :                                 "Cooling",
    5503             :                                 _,
    5504           0 :                                 "System");
    5505           0 :             SetupOutputVariable(state,
    5506             :                                 "VRF Heat Pump Evaporative Condenser Pump Electricity Rate",
    5507             :                                 OutputProcessor::Unit::W,
    5508           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).EvapCondPumpElecPower,
    5509             :                                 OutputProcessor::SOVTimeStepType::System,
    5510             :                                 OutputProcessor::SOVStoreType::Average,
    5511           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5512           0 :             SetupOutputVariable(state,
    5513             :                                 "VRF Heat Pump Evaporative Condenser Pump Electricity Energy",
    5514             :                                 OutputProcessor::Unit::J,
    5515           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).EvapCondPumpElecConsumption,
    5516             :                                 OutputProcessor::SOVTimeStepType::System,
    5517             :                                 OutputProcessor::SOVStoreType::Summed,
    5518           0 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5519             :                                 _,
    5520             :                                 "Electricity",
    5521             :                                 "COOLING",
    5522             :                                 _,
    5523           0 :                                 "System");
    5524             : 
    5525           0 :             if (state.dataHVACVarRefFlow->VRF(NumCond).BasinHeaterPowerFTempDiff > 0.0) {
    5526           0 :                 SetupOutputVariable(state,
    5527             :                                     "VRF Heat Pump Basin Heater Electricity Rate",
    5528             :                                     OutputProcessor::Unit::W,
    5529           0 :                                     state.dataHVACVarRefFlow->VRF(NumCond).BasinHeaterPower,
    5530             :                                     OutputProcessor::SOVTimeStepType::System,
    5531             :                                     OutputProcessor::SOVStoreType::Average,
    5532           0 :                                     state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5533           0 :                 SetupOutputVariable(state,
    5534             :                                     "VRF Heat Pump Basin Heater Electricity Energy",
    5535             :                                     OutputProcessor::Unit::J,
    5536           0 :                                     state.dataHVACVarRefFlow->VRF(NumCond).BasinHeaterConsumption,
    5537             :                                     OutputProcessor::SOVTimeStepType::System,
    5538             :                                     OutputProcessor::SOVStoreType::Summed,
    5539           0 :                                     state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5540             :                                     _,
    5541             :                                     "Electricity",
    5542             :                                     "COOLING",
    5543             :                                     _,
    5544           0 :                                     "System");
    5545             :             }
    5546             : 
    5547          12 :         } else if (state.dataHVACVarRefFlow->VRF(NumCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    5548           4 :             SetupOutputVariable(state,
    5549             :                                 "VRF Heat Pump Condenser Outlet Temperature",
    5550             :                                 OutputProcessor::Unit::C,
    5551           1 :                                 state.dataHVACVarRefFlow->VRF(NumCond).CondenserSideOutletTemp,
    5552             :                                 OutputProcessor::SOVTimeStepType::System,
    5553             :                                 OutputProcessor::SOVStoreType::Average,
    5554           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5555           4 :             SetupOutputVariable(state,
    5556             :                                 "VRF Heat Pump Condenser Mass Flow Rate",
    5557             :                                 OutputProcessor::Unit::kg_s,
    5558           1 :                                 state.dataHVACVarRefFlow->VRF(NumCond).WaterCondenserMassFlow,
    5559             :                                 OutputProcessor::SOVTimeStepType::System,
    5560             :                                 OutputProcessor::SOVStoreType::Average,
    5561           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5562           4 :             SetupOutputVariable(state,
    5563             :                                 "VRF Heat Pump Condenser Heat Transfer Rate",
    5564             :                                 OutputProcessor::Unit::W,
    5565           1 :                                 state.dataHVACVarRefFlow->VRF(NumCond).QCondenser,
    5566             :                                 OutputProcessor::SOVTimeStepType::System,
    5567             :                                 OutputProcessor::SOVStoreType::Average,
    5568           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5569           4 :             SetupOutputVariable(state,
    5570             :                                 "VRF Heat Pump Condenser Heat Transfer Energy",
    5571             :                                 OutputProcessor::Unit::J,
    5572           1 :                                 state.dataHVACVarRefFlow->VRF(NumCond).QCondEnergy,
    5573             :                                 OutputProcessor::SOVTimeStepType::System,
    5574             :                                 OutputProcessor::SOVStoreType::Summed,
    5575           2 :                                 state.dataHVACVarRefFlow->VRF(NumCond).Name);
    5576             :         }
    5577             : 
    5578          12 :         if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5579           0 :             SetupEMSActuator(state,
    5580             :                              "Variable Refrigerant Flow Heat Pump",
    5581           0 :                              state.dataHVACVarRefFlow->VRF(NumCond).Name,
    5582             :                              "Operating Mode",
    5583             :                              "[integer]",
    5584           0 :                              state.dataHVACVarRefFlow->VRF(NumCond).EMSOverrideHPOperatingMode,
    5585           0 :                              state.dataHVACVarRefFlow->VRF(NumCond).EMSValueForHPOperatingMode);
    5586             :         }
    5587             :     }
    5588          11 : }
    5589             : 
    5590          56 : void CheckVRFTUNodeConnections(EnergyPlusData &state, int const VRFTUNum, bool &ErrorsFound)
    5591             : {
    5592             : 
    5593             :     constexpr static std::string_view cTerminalUnitType("ZoneHVAC:TerminalUnit:VariableRefrigerantFlow");
    5594          56 :     auto &nodeID = state.dataLoopNodes->NodeID;
    5595          56 :     auto &vrfTU = state.dataHVACVarRefFlow->VRFTU(VRFTUNum);
    5596         112 :     std::string const cTUName(vrfTU.Name);
    5597          56 :     bool const CoolingCoilPresent = vrfTU.CoolingCoilPresent;
    5598          56 :     bool const HeatingCoilPresent = vrfTU.HeatingCoilPresent;
    5599          56 :     bool const SuppHeatingCoilPresent = vrfTU.SuppHeatingCoilPresent;
    5600          56 :     int const FanPlace = vrfTU.FanPlace;
    5601          56 :     bool const FanPresent = FanPlace;
    5602          56 :     bool const OAMixerUsed = vrfTU.OAMixerUsed;
    5603          56 :     int const VRFTUInletNodeNum = vrfTU.VRFTUInletNodeNum;
    5604          56 :     int const VRFTUOutletNodeNum = vrfTU.VRFTUOutletNodeNum;
    5605          56 :     int const coolCoilAirInNode = vrfTU.coolCoilAirInNode;
    5606          56 :     int const coolCoilAirOutNode = vrfTU.coolCoilAirOutNode;
    5607          56 :     int const heatCoilAirInNode = vrfTU.heatCoilAirInNode;
    5608          56 :     int const heatCoilAirOutNode = vrfTU.heatCoilAirOutNode;
    5609          56 :     int const fanInletNode = vrfTU.fanInletNode;
    5610          56 :     int const fanOutletNode = vrfTU.fanOutletNode;
    5611          56 :     int const SuppHeatCoilAirInletNode = vrfTU.SuppHeatCoilAirInletNode;
    5612          56 :     int const SuppHeatCoilAirOutletNode = vrfTU.SuppHeatCoilAirOutletNode;
    5613          56 :     int const VRFTUOAMixerRetNodeNum = vrfTU.VRFTUOAMixerRetNodeNum;
    5614          56 :     int const VRFTUOAMixerMixedNodeNum = vrfTU.VRFTUOAMixerMixedNodeNum;
    5615             : 
    5616             :     // check that TU object internal nodes (TU inlet to TU outlet) are correctly connected
    5617             :     // the following is checked regardless of fan placement
    5618          56 :     if (CoolingCoilPresent && HeatingCoilPresent) {
    5619          56 :         if (coolCoilAirOutNode != heatCoilAirInNode) {
    5620           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5621           0 :             ShowContinueError(state, "The cooling coil air outlet node name must match the heating coil air inlet node name.");
    5622           0 :             if (coolCoilAirOutNode > 0 && heatCoilAirInNode > 0) {
    5623           0 :                 ShowContinueError(state, "... Cooling coil air outlet node = " + nodeID(coolCoilAirOutNode));
    5624           0 :                 ShowContinueError(state, "... Heating coil air inlet node  = " + nodeID(heatCoilAirInNode));
    5625             :             }
    5626           0 :             ErrorsFound = true;
    5627             :         }
    5628             :     }
    5629             : 
    5630             :     // check the TU inlet node name with the first component
    5631          56 :     if (FanPlace == DataHVACGlobals::DrawThru || !FanPresent) {
    5632          51 :         if (OAMixerUsed) {
    5633          45 :             if (VRFTUInletNodeNum != VRFTUOAMixerRetNodeNum) {
    5634           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5635           0 :                 ShowContinueError(state,
    5636             :                                   "... For draw thru or no fan when an OA mixer is specified the terminal unit "
    5637             :                                   "inlet node name must match the OA mixer return air stream node name.");
    5638           0 :                 if (VRFTUInletNodeNum > 0 && VRFTUOAMixerRetNodeNum > 0) {
    5639           0 :                     ShowContinueError(state, "... Terminal unit inlet node name = " + nodeID(VRFTUInletNodeNum) + ".");
    5640           0 :                     ShowContinueError(state, "... OA mixer return air stream node name = " + nodeID(VRFTUOAMixerRetNodeNum) + ".");
    5641             :                 }
    5642           0 :                 ErrorsFound = true;
    5643             :             }
    5644             :             // check mixer outlet with next component
    5645          45 :             if (CoolingCoilPresent) {
    5646          45 :                 if (VRFTUOAMixerMixedNodeNum != coolCoilAirInNode) {
    5647           0 :                     ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5648           0 :                     ShowContinueError(state,
    5649             :                                       "... For draw thru or no fan when an OA mixer is specified and a cooling coil is present "
    5650             :                                       "the OA mixer mixed air node name must match the cooling coil inlet node name.");
    5651           0 :                     if (VRFTUOAMixerMixedNodeNum > 0 && coolCoilAirInNode > 0) {
    5652           0 :                         ShowContinueError(state, "... OA mixer mixed air node name = " + nodeID(VRFTUOAMixerMixedNodeNum) + ".");
    5653           0 :                         ShowContinueError(state, "... Cooling coil inlet node name = " + nodeID(coolCoilAirInNode) + ".");
    5654             :                     }
    5655           0 :                     ErrorsFound = true;
    5656             :                 }
    5657           0 :             } else if (HeatingCoilPresent) {
    5658           0 :                 if (VRFTUOAMixerMixedNodeNum != heatCoilAirInNode) {
    5659           0 :                     ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5660           0 :                     ShowContinueError(state,
    5661             :                                       "... For draw thru or no fan when an OA mixer is specified and a cooling coil is not present "
    5662             :                                       "the OA mixer mixed air node name must match the heating coil inlet node name.");
    5663           0 :                     if (VRFTUOAMixerMixedNodeNum > 0 && heatCoilAirInNode > 0) {
    5664           0 :                         ShowContinueError(state, "... OA mixer mixed air node name = " + nodeID(VRFTUOAMixerMixedNodeNum) + ".");
    5665           0 :                         ShowContinueError(state, "... Heating coil inlet node name = " + nodeID(heatCoilAirInNode) + ".");
    5666             :                     }
    5667           0 :                     ErrorsFound = true;
    5668             :                 }
    5669             :             }
    5670             :         } else { // OAMixer not used
    5671           6 :             if (CoolingCoilPresent) {
    5672           6 :                 if (VRFTUInletNodeNum != coolCoilAirInNode) {
    5673           0 :                     ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5674           0 :                     ShowContinueError(
    5675             :                         state,
    5676             :                         "... For draw thru or no fan when no OA mixer is specified and a cooling coil is present the terminal unit inlet "
    5677             :                         "node name must match the cooling coil inlet node name.");
    5678           0 :                     if (VRFTUInletNodeNum > 0 && coolCoilAirInNode > 0) {
    5679           0 :                         ShowContinueError(state, "... Terminal unit inlet node name = " + nodeID(VRFTUInletNodeNum) + ".");
    5680           0 :                         ShowContinueError(state, "... Cooling coil inlet node name = " + nodeID(coolCoilAirInNode) + ".");
    5681             :                     }
    5682           0 :                     ErrorsFound = true;
    5683             :                 }
    5684           0 :             } else if (HeatingCoilPresent) {
    5685           0 :                 if (VRFTUInletNodeNum != heatCoilAirInNode) {
    5686           0 :                     ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5687           0 :                     ShowContinueError(state,
    5688             :                                       "... For draw thru or no fan when no cooling coil or OA mixer is specified the terminal unit inlet "
    5689             :                                       "node name must match the heating coil inlet node name.");
    5690           0 :                     if (VRFTUInletNodeNum > 0 && heatCoilAirInNode > 0) {
    5691           0 :                         ShowContinueError(state, "... Terminal unit inlet node name = " + nodeID(VRFTUInletNodeNum) + ".");
    5692           0 :                         ShowContinueError(state, "... Heating coil inlet node name = " + nodeID(heatCoilAirInNode) + ".");
    5693             :                     }
    5694           0 :                     ErrorsFound = true;
    5695             :                 }
    5696             :             }
    5697             :         }
    5698             :     }
    5699          56 :     if (FanPlace == DataHVACGlobals::BlowThru && !OAMixerUsed) {
    5700           0 :         if (VRFTUInletNodeNum != fanInletNode) {
    5701           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5702           0 :             ShowContinueError(state,
    5703             :                               "... For blow thru fan when no OA mixer is specified the terminal unit inlet "
    5704             :                               "node name must match the fan inlet node name.");
    5705           0 :             if (VRFTUInletNodeNum > 0 && fanInletNode > 0) {
    5706           0 :                 ShowContinueError(state, "... Terminal unit inlet node name = " + nodeID(VRFTUInletNodeNum) + ".");
    5707           0 :                 ShowContinueError(state, "... Fan inlet node name = " + nodeID(fanInletNode) + ".");
    5708             :             }
    5709           0 :             ErrorsFound = true;
    5710             :         }
    5711          56 :     } else if (OAMixerUsed) { // when OA mixer is used TU inlet = OAMixer return node regardless of fan placement
    5712          50 :         if (VRFTUInletNodeNum != VRFTUOAMixerRetNodeNum) {
    5713           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5714           0 :             ShowContinueError(state,
    5715             :                               "... When an OA mixer is specified the terminal unit inlet "
    5716             :                               "node name must match the OA mixer return node name.");
    5717           0 :             if (VRFTUInletNodeNum > 0 && VRFTUOAMixerRetNodeNum > 0) {
    5718           0 :                 ShowContinueError(state, "... Terminal unit inlet node name = " + nodeID(VRFTUInletNodeNum) + ".");
    5719           0 :                 ShowContinueError(state, "... Fan inlet node name = " + nodeID(VRFTUOAMixerRetNodeNum) + ".");
    5720             :             }
    5721           0 :             ErrorsFound = true;
    5722             :         }
    5723             :     }
    5724             :     // check the next component
    5725          56 :     if (CoolingCoilPresent) {
    5726          56 :         if (FanPlace == DataHVACGlobals::BlowThru) {
    5727           5 :             if (fanOutletNode != coolCoilAirInNode) {
    5728           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5729           0 :                 ShowContinueError(state,
    5730             :                                   "... For blow thru fan when a cooling coil is present "
    5731             :                                   "fan outlet node name must match the cooling coil inlet node name.");
    5732           0 :                 if (fanOutletNode > 0 && coolCoilAirInNode > 0) {
    5733           0 :                     ShowContinueError(state, "... The fan outlet node name = " + nodeID(fanOutletNode) + ".");
    5734           0 :                     ShowContinueError(state, "... Cooling coil inlet node name = " + nodeID(coolCoilAirInNode) + ".");
    5735             :                 }
    5736           0 :                 ErrorsFound = true;
    5737             :             }
    5738             :         }
    5739          56 :         if (!HeatingCoilPresent && FanPlace == DataHVACGlobals::DrawThru) {
    5740           0 :             if (coolCoilAirOutNode != fanInletNode) {
    5741           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5742           0 :                 ShowContinueError(state,
    5743             :                                   "... For draw thru fan when a heating coil is not present "
    5744             :                                   "the cooling coil outlet node name must match the fan inlet node name.");
    5745           0 :                 if (coolCoilAirOutNode > 0 && fanInletNode > 0) {
    5746           0 :                     ShowContinueError(state, "... Cooling coil outlet node name = " + nodeID(coolCoilAirOutNode) + ".");
    5747           0 :                     ShowContinueError(state, "... The fan inlet node name = " + nodeID(fanInletNode) + ".");
    5748             :                 }
    5749           0 :                 ErrorsFound = true;
    5750             :             }
    5751             :         }
    5752             :     }
    5753          56 :     if (HeatingCoilPresent) {
    5754          56 :         if (FanPlace == DataHVACGlobals::DrawThru) {
    5755          50 :             if (heatCoilAirOutNode != fanInletNode) {
    5756           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5757           0 :                 ShowContinueError(state,
    5758             :                                   "... For draw thru fan when a heating coil is present "
    5759             :                                   "the heating coil outlet node name must match the fan inlet node name.");
    5760           0 :                 if (heatCoilAirOutNode > 0 && fanInletNode > 0) {
    5761           0 :                     ShowContinueError(state, "... Heating coil outlet node name = " + nodeID(heatCoilAirOutNode) + ".");
    5762           0 :                     ShowContinueError(state, "... The fan inlet node name = " + nodeID(fanInletNode) + ".");
    5763             :                 }
    5764           0 :                 ErrorsFound = true;
    5765             :             }
    5766             :         }
    5767             :     }
    5768          56 :     if (SuppHeatingCoilPresent) {
    5769          10 :         if (SuppHeatCoilAirOutletNode != VRFTUOutletNodeNum) {
    5770           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5771           0 :             ShowContinueError(state, "... The supplemental heating coil outlet node name must match the terminal unit outlet node name.");
    5772           0 :             if (SuppHeatCoilAirOutletNode > 0 && VRFTUOutletNodeNum > 0) {
    5773           0 :                 ShowContinueError(state, "... Supplemental heating coil outlet node name = " + nodeID(SuppHeatCoilAirOutletNode) + ".");
    5774           0 :                 ShowContinueError(state, "... Terminal unit outlet node name = " + nodeID(VRFTUOutletNodeNum) + ".");
    5775             :             }
    5776           0 :             ErrorsFound = true;
    5777             :         }
    5778          10 :         if (FanPlace == DataHVACGlobals::DrawThru) {
    5779          10 :             if (fanOutletNode != SuppHeatCoilAirInletNode) {
    5780           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5781           0 :                 ShowContinueError(state,
    5782             :                                   "... For draw thru fan when a supplemental heating coil is present "
    5783             :                                   "the fan outlet node name must match the supplemental heating coil inlet node name.");
    5784           0 :                 if (fanOutletNode > 0 && SuppHeatCoilAirInletNode > 0) {
    5785           0 :                     ShowContinueError(state, "... Fan outlet node name = " + nodeID(fanOutletNode) + ".");
    5786           0 :                     ShowContinueError(state, "... Supplemental heating coil inlet node name = " + nodeID(SuppHeatCoilAirInletNode) + ".");
    5787             :                 }
    5788           0 :                 ErrorsFound = true;
    5789             :             }
    5790             :         } else {
    5791           0 :             if (heatCoilAirOutNode != SuppHeatCoilAirInletNode) {
    5792           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5793           0 :                 ShowContinueError(state,
    5794             :                                   "... For blow thru or no fan when a supplemental heating coil is present the heating "
    5795             :                                   "coil outlet node name must match the supplemental heating coil inlet node name.");
    5796           0 :                 if (heatCoilAirOutNode > 0 && SuppHeatCoilAirInletNode > 0) {
    5797           0 :                     ShowContinueError(state, "... Heating coil outlet node name = " + nodeID(heatCoilAirOutNode) + ".");
    5798           0 :                     ShowContinueError(state, "... Supplemental heating coil inlet node name = " + nodeID(SuppHeatCoilAirInletNode) + ".");
    5799             :                 }
    5800           0 :                 ErrorsFound = true;
    5801             :             }
    5802             :         }
    5803          46 :     } else if (CoolingCoilPresent && !HeatingCoilPresent && (FanPlace == DataHVACGlobals::BlowThru || !FanPresent)) {
    5804           0 :         if (coolCoilAirOutNode != VRFTUOutletNodeNum) {
    5805           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5806           0 :             ShowContinueError(state,
    5807             :                               "... For blow through or no fan and no heating or supplemental heating coil the cooling coil outlet node name must "
    5808             :                               "match the terminal unit outlet node name.");
    5809           0 :             if (coolCoilAirOutNode > 0 && VRFTUOutletNodeNum > 0) {
    5810           0 :                 ShowContinueError(state, "... Cooling coil outlet node name = " + nodeID(coolCoilAirOutNode) + ".");
    5811           0 :                 ShowContinueError(state, "... Terminal unit outlet node name = " + nodeID(VRFTUOutletNodeNum) + ".");
    5812             :             }
    5813           0 :             ErrorsFound = true;
    5814             :         }
    5815           0 :         if (FanPlace == DataHVACGlobals::DrawThru) {
    5816           0 :             if (fanOutletNode != VRFTUOutletNodeNum) {
    5817           0 :                 ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5818           0 :                 ShowContinueError(state,
    5819             :                                   "... For draw through fan and no supplemental heating coil the fan outlet node name must "
    5820             :                                   "match the terminal unit outlet node name.");
    5821           0 :                 if (fanOutletNode > 0 && VRFTUOutletNodeNum > 0) {
    5822           0 :                     ShowContinueError(state, "... Fan outlet node name = " + nodeID(fanOutletNode) + ".");
    5823           0 :                     ShowContinueError(state, "... Terminal unit outlet node name = " + nodeID(VRFTUOutletNodeNum) + ".");
    5824             :                 }
    5825           0 :                 ErrorsFound = true;
    5826             :             }
    5827             :         }
    5828          46 :     } else if (FanPlace == DataHVACGlobals::DrawThru) {
    5829          40 :         if (fanOutletNode != VRFTUOutletNodeNum) {
    5830           0 :             ShowSevereError(state, fmt::format("{}=\"{}\",", cTerminalUnitType, cTUName));
    5831           0 :             ShowContinueError(state,
    5832             :                               "... For blow through fan and no supplemental heating coil the fan outlet node name must "
    5833             :                               "match the terminal unit outlet node name.");
    5834           0 :             if (fanOutletNode > 0 && VRFTUOutletNodeNum > 0) {
    5835           0 :                 ShowContinueError(state, "... Fan outlet node name = " + nodeID(fanOutletNode) + ".");
    5836           0 :                 ShowContinueError(state, "... Terminal unit outlet node name = " + nodeID(VRFTUOutletNodeNum) + ".");
    5837             :             }
    5838           0 :             ErrorsFound = true;
    5839             :         }
    5840             :     }
    5841          56 : }
    5842             : 
    5843      231306 : void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool const FirstHVACIteration, Real64 &OnOffAirFlowRatio, Real64 &QZnReq)
    5844             : {
    5845             : 
    5846             :     // SUBROUTINE INFORMATION:
    5847             :     //       AUTHOR         Richard Raustad, FSEC
    5848             :     //       DATE WRITTEN   August 2010
    5849             :     //       MODIFIED       July 2012, Chandan Sharma - FSEC: Added zone sys avail managers
    5850             :     //       RE-ENGINEERED  na
    5851             : 
    5852             :     // PURPOSE OF THIS SUBROUTINE:
    5853             :     // This subroutine is for initializations of the VRF Components.
    5854             : 
    5855             :     // METHODOLOGY EMPLOYED:
    5856             :     // Uses the status flags to trigger initializations.
    5857             : 
    5858             :     using DataSizing::AutoSize;
    5859             :     using DataZoneEquipment::CheckZoneEquipmentList;
    5860             :     using Fans::GetFanVolFlow;
    5861             :     using FluidProperties::GetDensityGlycol;
    5862             : 
    5863             :     using MixedAir::SimOAMixer;
    5864             :     using PlantUtilities::InitComponentNodes;
    5865             :     using ScheduleManager::GetCurrentScheduleValue;
    5866             :     using SingleDuct::SimATMixer;
    5867             : 
    5868             :     static constexpr std::string_view RoutineName("InitVRF");
    5869             : 
    5870             :     int InNode;                  // TU inlet node
    5871             :     int OutNode;                 // TU outlet node
    5872             :     int OutsideAirNode;          // TU mixer outside air inlet node
    5873             :     int NumTULoop;               // loop counter, number of TU's in list
    5874             :     int ELLoop;                  // loop counter, number of zone equipment lists
    5875             :     int ListLoop;                // loop counter, number of equipment is each list
    5876             :     int VRFCond;                 // index to VRF condenser
    5877             :     int TUIndex;                 // index to TU
    5878             :     int TUListNum;               // index to VRF AC system terminal unit list
    5879             :     int TUListIndex;             // pointer to TU list for this VRF system
    5880             :     int IndexToTUInTUList;       // index to TU in TerminalUnilList
    5881             :     Real64 RhoAir;               // air density at InNode
    5882             :     Real64 CurrentEndTime;       // end time of current time step
    5883      231306 :     Real64 TimeStepSysLast(0.0); // system time step on last time step
    5884             :     Real64 TempOutput;           // Sensible output of TU
    5885             :     Real64 LoadToCoolingSP;      // thermostat load to cooling setpoint (W)
    5886             :     Real64 LoadToHeatingSP;      // thermostat load to heating setpoint (W)
    5887             :     bool EnableSystem;           // use to turn on secondary operating mode if OA temp limits exceeded
    5888             :     bool ErrorsFound;            // flag returned from mining call
    5889             :     Real64 rho;                  // density of water (kg/m3)
    5890             :     Real64 OutsideDryBulbTemp;   // Outdoor air temperature at external node height
    5891             :     bool errFlag;                // local error flag
    5892             :     Real64 SuppHeatCoilLoad;     // additional heating required by supplemental heater (W)
    5893             :     Real64 SuppHeatCoilCapacity; // supplemental heating coil size (W)
    5894             : 
    5895             :     // ALLOCATE and Initialize subroutine variables
    5896      231306 :     if (state.dataHVACVarRefFlow->MyOneTimeFlag) {
    5897             : 
    5898          11 :         state.dataHVACVarRefFlow->MyEnvrnFlag.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    5899          11 :         state.dataHVACVarRefFlow->MySizeFlag.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    5900          11 :         state.dataHVACVarRefFlow->MyVRFFlag.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    5901          11 :         state.dataHVACVarRefFlow->MyZoneEqFlag.allocate(state.dataHVACVarRefFlow->NumVRFTU);
    5902          11 :         state.dataHVACVarRefFlow->MyBeginTimeStepFlag.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5903          11 :         state.dataHVACVarRefFlow->MaxDeltaT.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5904          11 :         state.dataHVACVarRefFlow->MinDeltaT.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5905          11 :         state.dataHVACVarRefFlow->LastModeCooling.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5906          11 :         state.dataHVACVarRefFlow->LastModeHeating.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5907          11 :         state.dataHVACVarRefFlow->HeatingLoad.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5908          11 :         state.dataHVACVarRefFlow->CoolingLoad.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5909          11 :         state.dataHVACVarRefFlow->NumCoolingLoads.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5910          11 :         state.dataHVACVarRefFlow->SumCoolingLoads.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5911          11 :         state.dataHVACVarRefFlow->NumHeatingLoads.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5912          11 :         state.dataHVACVarRefFlow->SumHeatingLoads.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5913          11 :         state.dataHVACVarRefFlow->MyVRFCondFlag.allocate(state.dataHVACVarRefFlow->NumVRFCond);
    5914          11 :         state.dataHVACVarRefFlow->MyEnvrnFlag = true;
    5915          11 :         state.dataHVACVarRefFlow->MySizeFlag = true;
    5916          11 :         state.dataHVACVarRefFlow->MyVRFFlag = true;
    5917          11 :         state.dataHVACVarRefFlow->MyZoneEqFlag = true;
    5918          11 :         state.dataHVACVarRefFlow->MyBeginTimeStepFlag = true;
    5919          11 :         state.dataHVACVarRefFlow->MaxDeltaT = 0.0;
    5920          11 :         state.dataHVACVarRefFlow->MinDeltaT = 0.0;
    5921          11 :         state.dataHVACVarRefFlow->LastModeCooling = false;
    5922          11 :         state.dataHVACVarRefFlow->LastModeHeating = true;
    5923          11 :         state.dataHVACVarRefFlow->NumCoolingLoads = 0;
    5924          11 :         state.dataHVACVarRefFlow->SumCoolingLoads = 0.0;
    5925          11 :         state.dataHVACVarRefFlow->NumHeatingLoads = 0;
    5926          11 :         state.dataHVACVarRefFlow->SumHeatingLoads = 0.0;
    5927             : 
    5928          11 :         state.dataHVACVarRefFlow->MyOneTimeFlag = false;
    5929          11 :         state.dataHVACVarRefFlow->MyVRFCondFlag = true;
    5930             : 
    5931             :     } // IF (MyOneTimeFlag) THEN
    5932             : 
    5933             :     // identify VRF condenser connected to this TU
    5934      231306 :     VRFCond = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
    5935      231306 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
    5936      231306 :     InNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum;
    5937      231306 :     OutNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum;
    5938      231306 :     OutsideAirNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum;
    5939      231306 :     IndexToTUInTUList = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList;
    5940             : 
    5941      231306 :     SuppHeatCoilCapacity = 0.0;
    5942      231306 :     SuppHeatCoilLoad = 0.0;
    5943      231306 :     LoadToCoolingSP = 0.0;
    5944      231306 :     LoadToHeatingSP = 0.0;
    5945      231306 :     ErrorsFound = false;
    5946      231306 :     bool SetPointErrorFlag = false;
    5947             : 
    5948             :     // set condenser inlet temp, used as surrogate for OAT (used to check limits of operation)
    5949      231306 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    5950       15084 :         OutsideDryBulbTemp = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRF(VRFCond).CondenserNodeNum).Temp;
    5951             :     } else {
    5952      216222 :         if (OutsideAirNode == 0) {
    5953       18764 :             OutsideDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    5954             :         } else {
    5955      197458 :             OutsideDryBulbTemp = state.dataLoopNodes->Node(OutsideAirNode).Temp;
    5956             :         }
    5957             :     }
    5958             : 
    5959      231306 :     if (allocated(state.dataHVACGlobal->ZoneComp)) {
    5960      231267 :         if (state.dataHVACVarRefFlow->MyZoneEqFlag(VRFTUNum)) { // initialize the name of each availability manager list and zone number
    5961         112 :             state.dataHVACGlobal->ZoneComp(DataZoneEquipment::ZoneEquip::VRFTerminalUnit).ZoneCompAvailMgrs(VRFTUNum).AvailManagerListName =
    5962         112 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).AvailManagerListName;
    5963          56 :             state.dataHVACGlobal->ZoneComp(DataZoneEquipment::ZoneEquip::VRFTerminalUnit).ZoneCompAvailMgrs(VRFTUNum).ZoneNum = ZoneNum;
    5964          56 :             state.dataHVACVarRefFlow->MyZoneEqFlag(VRFTUNum) = false;
    5965             :         }
    5966      231267 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).AvailStatus =
    5967      231267 :             state.dataHVACGlobal->ZoneComp(DataZoneEquipment::ZoneEquip::VRFTerminalUnit).ZoneCompAvailMgrs(VRFTUNum).AvailStatus;
    5968             :     }
    5969             : 
    5970      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag && allocated(state.dataPlnt->PlantLoop)) {
    5971          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    5972             :             // hot water supplemental heating coil
    5973           2 :             errFlag = false;
    5974           6 :             PlantUtilities::ScanPlantLoopsForObject(state,
    5975           2 :                                                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    5976             :                                                     PlantEquipmentType::CoilWaterSimpleHeating,
    5977           2 :                                                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc,
    5978             :                                                     errFlag,
    5979             :                                                     _,
    5980             :                                                     _,
    5981             :                                                     _,
    5982             :                                                     _,
    5983             :                                                     _);
    5984             : 
    5985           6 :             WaterCoils::SetCoilDesFlow(state,
    5986           2 :                                        DataHVACGlobals::cAllCoilTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num),
    5987           2 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    5988           2 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow,
    5989             :                                        errFlag);
    5990             : 
    5991           2 :             if (errFlag) {
    5992           0 :                 ShowFatalError(state, std::string{RoutineName} + ": Program terminated for previous conditions.");
    5993             :             }
    5994           4 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow = WaterCoils::GetCoilMaxWaterFlowRate(
    5995           4 :                 state, "Coil:Heating:Water", state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName, ErrorsFound);
    5996             : 
    5997           2 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow > 0.0) {
    5998           0 :                 rho = GetDensityGlycol(state,
    5999           0 :                                        state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc.loopNum).FluidName,
    6000             :                                        DataGlobalConstants::HWInitConvTemp,
    6001           0 :                                        state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc.loopNum).FluidIndex,
    6002             :                                        RoutineName);
    6003           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    6004           0 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow * rho;
    6005             :             }
    6006             : 
    6007             :             // fill fluid outlet node for hot water coil SuppHeatCoilFluidOutletNode
    6008           2 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode =
    6009           2 :                 DataPlant::CompData::getPlantComponent(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc).NodeNumOut;
    6010           2 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag = false;
    6011             : 
    6012          54 :         } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) {
    6013             :             // steam supplemental heating coil
    6014           2 :             errFlag = false;
    6015           6 :             PlantUtilities::ScanPlantLoopsForObject(state,
    6016           2 :                                                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    6017             :                                                     PlantEquipmentType::CoilSteamAirHeating,
    6018           2 :                                                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc,
    6019             :                                                     errFlag,
    6020             :                                                     _,
    6021             :                                                     _,
    6022             :                                                     _,
    6023             :                                                     _,
    6024             :                                                     _);
    6025           2 :             if (errFlag) {
    6026           0 :                 ShowFatalError(state, std::string{RoutineName} + ": Program terminated for previous conditions.");
    6027             :             }
    6028           2 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    6029           2 :                 SteamCoils::GetCoilMaxSteamFlowRate(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, ErrorsFound);
    6030           2 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow > 0.0) {
    6031           0 :                 int SteamIndex = 0; // fluid type index of 0 is passed if steam
    6032           0 :                 Real64 TempSteamIn = 100.0;
    6033           0 :                 Real64 SteamDensity = FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName);
    6034           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow =
    6035           0 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow * SteamDensity;
    6036             :             }
    6037             : 
    6038             :             // fill fluid outlet node for steam coil SuppHeatCoilFluidOutletNode
    6039           2 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode =
    6040           2 :                 DataPlant::CompData::getPlantComponent(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc).NodeNumOut;
    6041           2 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag = false;
    6042             : 
    6043             :         } else { // VRF terminal unit not connected to plant
    6044          52 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag = false;
    6045             :         }
    6046      231250 :     } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag && !state.dataGlobal->AnyPlantInModel) {
    6047           0 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MySuppCoilPlantScanFlag = false;
    6048             :     }
    6049             : 
    6050             :     // one-time check to see if VRF TU's are on ZoneHVAC:EquipmentList or AirloopHVAC or issue warning
    6051      231306 :     if (state.dataHVACVarRefFlow->ZoneEquipmentListNotChecked) {
    6052         145 :         if (state.dataAirLoop->AirLoopInputsFilled) state.dataHVACVarRefFlow->ZoneEquipmentListNotChecked = false;
    6053         145 :         bool AirLoopFound = false;
    6054         145 :         bool errorsFound = false;
    6055         145 :         bool AirNodeFound = false;
    6056         145 :         int ctrlZoneNum = 0;
    6057         290 :         std::string const cCurrentModuleObject = "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow";
    6058         301 :         for (TUListNum = 1; TUListNum <= state.dataHVACVarRefFlow->NumVRFTULists; ++TUListNum) {
    6059         896 :             for (NumTULoop = 1; NumTULoop <= state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList; ++NumTULoop) {
    6060         740 :                 AirLoopFound = false; // reset for next TU
    6061         740 :                 ctrlZoneNum = 0;      // reset for next TU
    6062         740 :                 TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTULoop);
    6063         740 :                 std::string const thisObjectName = state.dataHVACVarRefFlow->VRFTU(TUIndex).Name;
    6064         740 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isInZone) goto EquipList_exit; // already found previously
    6065         424 :                 for (ELLoop = 1; ELLoop <= state.dataGlobal->NumOfZones; ++ELLoop) {        // NumOfZoneEquipLists
    6066         394 :                     if (state.dataZoneEquip->ZoneEquipList(ELLoop).Name == "") continue;    // dimensioned by NumOfZones.  Only valid ones have names.
    6067         756 :                     for (ListLoop = 1; ListLoop <= state.dataZoneEquip->ZoneEquipList(ELLoop).NumOfEquipTypes; ++ListLoop) {
    6068         500 :                         if (!UtilityRoutines::SameString(state.dataZoneEquip->ZoneEquipList(ELLoop).EquipType(ListLoop),
    6069         500 :                                                          DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num)))
    6070         220 :                             continue;
    6071         280 :                         if (!UtilityRoutines::SameString(state.dataZoneEquip->ZoneEquipList(ELLoop).EquipName(ListLoop),
    6072         280 :                                                          state.dataHVACVarRefFlow->VRFTU(TUIndex).Name))
    6073         226 :                             continue;
    6074          54 :                         state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum = ELLoop;
    6075          54 :                         state.dataHVACVarRefFlow->VRFTU(TUIndex).isInZone = true;
    6076          54 :                         if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFSysNum).MasterZonePtr == ELLoop) {
    6077           8 :                             state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFSysNum).MasterZoneTUIndex = TUIndex;
    6078             :                         }
    6079          54 :                         if (state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode == 0) {
    6080           0 :                             bool ZoneNodeNotFound = true;
    6081           0 :                             for (int CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
    6082           0 :                                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue;
    6083           0 :                                 for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumExhaustNodes; ++NodeNum) {
    6084           0 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum ==
    6085           0 :                                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ExhaustNode(NodeNum)) {
    6086           0 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode =
    6087           0 :                                             state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    6088           0 :                                         ZoneNodeNotFound = false;
    6089           0 :                                         break;
    6090             :                                     }
    6091             :                                 }
    6092           0 :                                 for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++NodeNum) {
    6093           0 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum ==
    6094           0 :                                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(NodeNum)) {
    6095           0 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode =
    6096           0 :                                             state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    6097           0 :                                         ZoneNodeNotFound = false;
    6098           0 :                                         break;
    6099             :                                     }
    6100             :                                 }
    6101           0 :                                 if (!ZoneNodeNotFound) break;
    6102             :                             }
    6103           0 :                             if (ZoneNodeNotFound) {
    6104           0 :                                 ShowSevereError(
    6105             :                                     state,
    6106           0 :                                     "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow \"" + state.dataHVACVarRefFlow->VRFTU(TUIndex).Name +
    6107             :                                         "\" Zone terminal unit air inlet node name must be the same as a zone inlet or exhaust node name.");
    6108           0 :                                 ShowContinueError(state,
    6109             :                                                   "... Zone inlet and exhaust node name is specified in ZoneHVAC:EquipmentConnections object.");
    6110           0 :                                 ShowContinueError(state,
    6111           0 :                                                   "... Zone terminal unit inlet node name  = " +
    6112           0 :                                                       state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum));
    6113           0 :                                 ShowContinueError(state,
    6114           0 :                                                   "... Zone terminal unit outlet node name = " +
    6115           0 :                                                       state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum));
    6116             :                             }
    6117             :                         }
    6118          54 :                         goto EquipList_exit;
    6119             :                     }
    6120             :                 }
    6121             :                 // check if the TU is connected to an air loop
    6122          30 :                 if (!state.dataHVACVarRefFlow->VRFTU(TUIndex).isInAirLoop) {
    6123          31 :                     for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
    6124          23 :                         for (int BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches; ++BranchNum) {
    6125          35 :                             for (int CompNum = 1;
    6126          35 :                                  CompNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents;
    6127             :                                  ++CompNum) {
    6128          72 :                                 if (UtilityRoutines::SameString(
    6129          24 :                                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).Name,
    6130          25 :                                         thisObjectName) &&
    6131           2 :                                     UtilityRoutines::SameString(
    6132           1 :                                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).TypeOf,
    6133             :                                         cCurrentModuleObject)) {
    6134           1 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum = AirLoopNum;
    6135           1 :                                     AirLoopFound = true;
    6136           1 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).isInAirLoop = true;
    6137           2 :                                     BranchNodeConnections::TestCompSet(
    6138             :                                         state,
    6139             :                                         cCurrentModuleObject,
    6140             :                                         thisObjectName,
    6141           1 :                                         state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum),
    6142           1 :                                         state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum),
    6143             :                                         "Air Nodes");
    6144           1 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum > 0) {
    6145           1 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode =
    6146           1 :                                             state.dataZoneEquip->ZoneEquipConfig(state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum).ZoneNode;
    6147           1 :                                         int ControlledZoneNum = state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum;
    6148           5 :                                         for (int TstatZoneNum = 1; TstatZoneNum <= state.dataZoneCtrls->NumTempControlledZones; ++TstatZoneNum) {
    6149          10 :                                             if (state.dataZoneCtrls->TempControlledZone(TstatZoneNum).ActualZoneNum !=
    6150           5 :                                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum)
    6151           4 :                                                 continue;
    6152           1 :                                             state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFSysNum).MasterZoneTUIndex =
    6153             :                                                 TUIndex;
    6154           1 :                                             AirNodeFound = true;
    6155           1 :                                             ctrlZoneNum = ControlledZoneNum;
    6156           1 :                                             goto EquipList_exit;
    6157             :                                         }
    6158           0 :                                         for (int TstatZoneNum = 1; TstatZoneNum <= state.dataZoneCtrls->NumComfortControlledZones; ++TstatZoneNum) {
    6159           0 :                                             if (state.dataZoneCtrls->ComfortControlledZone(TstatZoneNum).ActualZoneNum !=
    6160           0 :                                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum)
    6161           0 :                                                 continue;
    6162           0 :                                             state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFSysNum).MasterZoneTUIndex =
    6163             :                                                 TUIndex;
    6164           0 :                                             AirNodeFound = true;
    6165           0 :                                             ctrlZoneNum = ControlledZoneNum;
    6166           0 :                                             goto EquipList_exit;
    6167             :                                         }
    6168           0 :                                         if (!AirNodeFound && state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum > 0) {
    6169           0 :                                             ShowSevereError(state, "Input errors for " + cCurrentModuleObject + ":" + thisObjectName);
    6170           0 :                                             ShowContinueError(state, "Did not find Air node (Zone with Thermostat or Thermal Comfort Thermostat).");
    6171             :                                             // ShowContinueError(state, "specified Controlling Zone or Thermostat Location name = " +
    6172             :                                             // loc_controlZoneName);
    6173           0 :                                             errorsFound = true;
    6174             :                                         }
    6175           0 :                                     } else if (AirLoopFound) { // control zone name not entered in TU object input
    6176           0 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = true;
    6177             :                                     }
    6178             :                                 }
    6179          23 :                                 if (AirLoopFound) break;
    6180             :                             }
    6181          11 :                             if (AirLoopFound) break;
    6182             :                         }
    6183          11 :                         if (AirLoopFound) break;
    6184             :                     }
    6185             :                 }
    6186             : 
    6187             :                 // check if the TU is connected to an outside air system
    6188          29 :                 if (!AirLoopFound && !state.dataHVACVarRefFlow->VRFTU(TUIndex).isInOASys) {
    6189          29 :                     for (int OASysNum = 1; OASysNum <= state.dataAirLoop->NumOASystems; ++OASysNum) {
    6190          31 :                         for (int OACompNum = 1; OACompNum <= state.dataAirLoop->OutsideAirSys(OASysNum).NumComponents; ++OACompNum) {
    6191          42 :                             if (!UtilityRoutines::SameString(state.dataAirLoop->OutsideAirSys(OASysNum).ComponentName(OACompNum),
    6192          43 :                                                              state.dataHVACVarRefFlow->VRFTU(TUIndex).Name) ||
    6193           1 :                                 !UtilityRoutines::SameString(state.dataAirLoop->OutsideAirSys(OASysNum).ComponentType(OACompNum),
    6194             :                                                              cCurrentModuleObject))
    6195          20 :                                 continue;
    6196           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum = 0; // need air loop number here?
    6197           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).isInOASys = true;
    6198           1 :                             AirLoopFound = true;
    6199           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = true;
    6200             :                             // user may have inadvertently entered a zone name in the OA system TU object
    6201           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum = 0;
    6202           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode = 0;
    6203           2 :                             BranchNodeConnections::TestCompSet(
    6204             :                                 state,
    6205             :                                 cCurrentModuleObject,
    6206             :                                 thisObjectName,
    6207           1 :                                 state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum),
    6208           1 :                                 state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum),
    6209             :                                 "Air Nodes");
    6210           1 :                             goto EquipList_exit;
    6211             :                         }
    6212             :                     }
    6213             :                 }
    6214         750 :             EquipList_exit:;
    6215         740 :                 if (ctrlZoneNum > 0) {
    6216           1 :                     int inletNodeADUNum = 0;
    6217           1 :                     DataZoneEquipment::ZoneEquip sysType_Num = DataZoneEquipment::ZoneEquip::Invalid;
    6218           2 :                     std::string sysName = "";
    6219           1 :                     for (int inletNode = 1; inletNode <= state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).NumInletNodes; inletNode++) {
    6220           2 :                         if (state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).InletNodeAirLoopNum(inletNode) !=
    6221           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6222           0 :                             continue;
    6223           1 :                         inletNodeADUNum = state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).InletNodeADUNum(inletNode);
    6224           1 :                         if (inletNodeADUNum > 0 && inletNodeADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size()) {
    6225           1 :                             sysType_Num = DataZoneEquipment::ZoneEquip::AirDistUnit;
    6226           1 :                             sysName = state.dataDefineEquipment->AirDistUnit(inletNodeADUNum).Name;
    6227           1 :                             break;
    6228             :                         }
    6229             :                     }
    6230           1 :                     if (inletNodeADUNum > 0) {
    6231           1 :                         if (state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex > 0) {
    6232           1 :                             for (int EquipNum = 1;
    6233           1 :                                  EquipNum <=
    6234           1 :                                  state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex).NumOfEquipTypes;
    6235             :                                  ++EquipNum) {
    6236           2 :                                 if ((state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex)
    6237           2 :                                          .EquipTypeEnum(EquipNum) != sysType_Num) ||
    6238           1 :                                     state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex)
    6239           1 :                                             .EquipName(EquipNum) != sysName)
    6240           0 :                                     continue;
    6241           1 :                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).zoneSequenceCoolingNum =
    6242           1 :                                     state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex)
    6243           1 :                                         .CoolingPriority(EquipNum);
    6244           1 :                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).zoneSequenceHeatingNum =
    6245           1 :                                     state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).EquipListIndex)
    6246           1 :                                         .HeatingPriority(EquipNum);
    6247           1 :                                 break;
    6248             :                             }
    6249             :                         }
    6250             :                     } else {
    6251           0 :                         ShowSevereError(state, "Input errors for " + cCurrentModuleObject + ":" + thisObjectName);
    6252           0 :                         ShowContinueError(state, "Did not find ZoneHVAC:EquipmentList connected to this VRF terminal unit.");
    6253           0 :                         errorsFound = true;
    6254             :                     }
    6255             :                 }
    6256             : 
    6257             :                 // Find the number of zones (zone Inlet nodes) attached to an air loop from the air loop number
    6258         740 :                 if (AirLoopFound || state.dataHVACVarRefFlow->VRFTU(TUIndex).isInAirLoop) {
    6259          12 :                     int NumAirLoopZones = 0;
    6260          12 :                     bool initLoadBasedControlFlowFracFlagReady = false;
    6261          12 :                     Real64 initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax = 0.0;
    6262          12 :                     if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum > 0)
    6263          22 :                         NumAirLoopZones = state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum).NumZonesCooled +
    6264          11 :                                           state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum).NumZonesHeated;
    6265          12 :                     if (allocated(state.dataAirLoop->AirToZoneNodeInfo)) {
    6266          12 :                         initLoadBasedControlFlowFracFlagReady = true;
    6267          67 :                         for (int ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) {
    6268             :                             // zone inlet nodes for cooling
    6269          55 :                             if (state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum).NumZonesCooled > 0) {
    6270         110 :                                 if (state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6271          55 :                                         .TermUnitCoolInletNodes(ZoneInSysIndex) == -999) {
    6272             :                                     // the data structure for the zones inlet nodes has not been filled
    6273           0 :                                     initLoadBasedControlFlowFracFlagReady = false;
    6274             :                                 } else {
    6275          55 :                                     int ZoneInletNodeNum = state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6276          55 :                                                                .TermUnitCoolInletNodes(ZoneInSysIndex);
    6277          55 :                                     if (state.dataLoopNodes->Node(ZoneInletNodeNum).MassFlowRateMax == -999.0) {
    6278             :                                         // the node mass flow rate has not been set
    6279          10 :                                         initLoadBasedControlFlowFracFlagReady = false;
    6280             :                                     }
    6281             :                                 }
    6282             :                             }
    6283             :                             // zone inlet nodes for heating
    6284          55 :                             if (state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum).NumZonesHeated > 0) {
    6285           0 :                                 if (state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6286           0 :                                         .TermUnitHeatInletNodes(ZoneInSysIndex) == -999) {
    6287             :                                     // the data structure for the zones inlet nodes has not been filled
    6288           0 :                                     initLoadBasedControlFlowFracFlagReady = false;
    6289             :                                 } else {
    6290           0 :                                     int ZoneInletNodeNum = state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6291           0 :                                                                .TermUnitHeatInletNodes(ZoneInSysIndex);
    6292           0 :                                     if (state.dataLoopNodes->Node(ZoneInletNodeNum).MassFlowRateMax == -999.0) {
    6293             :                                         // the node mass flow rate has not been set
    6294           0 :                                         initLoadBasedControlFlowFracFlagReady = false;
    6295             :                                     }
    6296             :                                 }
    6297             :                             }
    6298             :                         }
    6299             :                     }
    6300          12 :                     if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && initLoadBasedControlFlowFracFlagReady) {
    6301           8 :                         Real64 SumOfMassFlowRateMax = 0.0; // initialize the sum of the maximum flows
    6302          43 :                         for (int ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) {
    6303          35 :                             int ZoneInletNodeNum = state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6304          35 :                                                        .TermUnitCoolInletNodes(ZoneInSysIndex);
    6305          35 :                             SumOfMassFlowRateMax += state.dataLoopNodes->Node(ZoneInletNodeNum).MassFlowRateMax;
    6306          70 :                             if (state.dataAirLoop->AirToZoneNodeInfo(state.dataHVACVarRefFlow->VRFTU(TUIndex).airLoopNum)
    6307          35 :                                     .CoolCtrlZoneNums(ZoneInSysIndex) == state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum) {
    6308           7 :                                 initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax =
    6309           7 :                                     state.dataLoopNodes->Node(ZoneInletNodeNum).MassFlowRateMax;
    6310             :                             }
    6311             :                         }
    6312           8 :                         if (SumOfMassFlowRateMax != 0.0 && state.dataAirLoop->AirLoopInputsFilled) {
    6313           1 :                             if (initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax >= DataHVACGlobals::SmallAirVolFlow) {
    6314           1 :                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).controlZoneMassFlowFrac =
    6315           1 :                                     initLoadBasedControlCntrlZoneTerminalUnitMassFlowRateMax / SumOfMassFlowRateMax;
    6316           4 :                                 BaseSizer::reportSizerOutput(state,
    6317           1 :                                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num),
    6318           1 :                                                              state.dataHVACVarRefFlow->VRFTU(TUIndex).Name,
    6319             :                                                              "Fraction of Supply Air Flow That Goes Through the Controlling Zone",
    6320           2 :                                                              state.dataHVACVarRefFlow->VRFTU(TUIndex).controlZoneMassFlowFrac);
    6321           1 :                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = false; // redundant
    6322             :                             } else {
    6323           0 :                                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isInAirLoop && state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum == 0 &&
    6324           0 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneAirNode == 0) {
    6325             :                                     // TU must be set point controlled and use constant fan mode (or coil out T won't change with PLR/air flow)
    6326           0 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = true;
    6327           0 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr > 0) {
    6328           0 :                                         if (ScheduleManager::GetScheduleMinValue(state, state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr) ==
    6329             :                                             0.0) {
    6330           0 :                                             ShowSevereError(state,
    6331           0 :                                                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num) +
    6332           0 :                                                                 " = " + state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6333           0 :                                             ShowContinueError(state,
    6334             :                                                               "When using set point control, fan operating mode must be continuous (fan "
    6335             :                                                               "operating mode schedule values > 0).");
    6336           0 :                                             ShowContinueError(
    6337             :                                                 state,
    6338           0 :                                                 "Error found in Supply Air Fan Operating Mode Schedule Name = " +
    6339           0 :                                                     state.dataScheduleMgr->Schedule(state.dataHVACVarRefFlow->VRFTU(TUIndex).FanOpModeSchedPtr).Name);
    6340           0 :                                             ShowContinueError(state, "...schedule values must be (>0., <=1.)");
    6341           0 :                                             ErrorsFound = true;
    6342             :                                         }
    6343             :                                     }
    6344             :                                 } else {
    6345           0 :                                     ShowSevereError(state,
    6346           0 :                                                     DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num) + " = " +
    6347           0 :                                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6348           0 :                                     ShowContinueError(state, " The Fraction of Supply Air Flow That Goes Through the Controlling Zone is set to 1.");
    6349           0 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).controlZoneMassFlowFrac = 1.0;
    6350           0 :                                     BaseSizer::reportSizerOutput(state,
    6351           0 :                                                                  DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num),
    6352           0 :                                                                  state.dataHVACVarRefFlow->VRFTU(TUIndex).Name,
    6353             :                                                                  "Fraction of Supply Air Flow That Goes Through the Controlling Zone",
    6354           0 :                                                                  state.dataHVACVarRefFlow->VRFTU(TUIndex).controlZoneMassFlowFrac);
    6355             :                                 }
    6356             :                             }
    6357           7 :                         } else if (state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum == 0) {
    6358             :                             // TU must be set point controlled and use constant fan mode (or coil outlet T won't change with PLR/air flow rate)
    6359             :                             // TU inlet air flow rate is also determined by OA system, not TU
    6360           1 :                             state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled = true;
    6361             :                         }
    6362             :                     }
    6363             :                 }
    6364             : 
    6365         740 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isInZone && state.dataAirLoop->AirLoopInputsFilled) {
    6366          54 :                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanPlace == 0) {
    6367           0 :                         ShowSevereError(state, "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow = " + state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6368           0 :                         ShowContinueError(state, "Illegal Supply Air Fan Placement.");
    6369           0 :                         ErrorsFound = true;
    6370             :                     }
    6371          54 :                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    6372          14 :                         if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanIndex == -1) {
    6373           0 :                             ShowSevereError(state,
    6374           0 :                                             "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow = " + state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6375           0 :                             ShowContinueError(state, "VRF Terminal Unit fan is required when used as zone equipment.");
    6376           0 :                             ErrorsFound = true;
    6377             :                         }
    6378             :                     } else {
    6379          40 :                         if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanIndex == 0) {
    6380           0 :                             ShowSevereError(state,
    6381           0 :                                             "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow = " + state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6382           0 :                             ShowContinueError(state, "VRF Terminal Unit fan is required when used as zone equipment.");
    6383           0 :                             ErrorsFound = true;
    6384             :                         }
    6385             :                     }
    6386             :                 }
    6387             : 
    6388         740 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled && state.dataAirLoop->AirLoopInputsFilled) {
    6389           1 :                     bool missingSetPoint = false;
    6390           1 :                     Real64 TUOutNodeSP = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum).TempSetPoint;
    6391           1 :                     Real64 coolCoilOutNodeSP = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirOutNode).TempSetPoint;
    6392           1 :                     Real64 heatCoilOutNodeSP = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirOutNode).TempSetPoint;
    6393             :                     // SP can be at outlet of TU or at outlet of coils
    6394             :                     // if supp heat coil is present, a SP must be at the outlet of the TU
    6395           1 :                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).SuppHeatingCoilPresent) {
    6396           0 :                         if (TUOutNodeSP == DataLoopNode::SensedNodeFlagValue) missingSetPoint = true;
    6397             :                     } else {
    6398           1 :                         if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanPlace == DataHVACGlobals::DrawThru) {
    6399             :                             // then SP must be at TU outlet
    6400           0 :                             if (TUOutNodeSP == DataLoopNode::SensedNodeFlagValue) missingSetPoint = true;
    6401             :                             // or at coil outlet nodes
    6402           0 :                             if (missingSetPoint) {
    6403           0 :                                 if (coolCoilOutNodeSP != DataLoopNode::SensedNodeFlagValue && heatCoilOutNodeSP != DataLoopNode::SensedNodeFlagValue)
    6404           0 :                                     missingSetPoint = false;
    6405             :                             }
    6406             :                         } else {
    6407             :                             // else fan is blow thru or missing
    6408           1 :                             if (TUOutNodeSP == DataLoopNode::SensedNodeFlagValue) missingSetPoint = true;
    6409             :                         }
    6410             :                     }
    6411           1 :                     if (missingSetPoint) {
    6412           0 :                         if (!state.dataGlobal->AnyEnergyManagementSystemInModel) {
    6413           0 :                             ShowSevereError(state,
    6414           0 :                                             "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow: Missing temperature setpoint for " +
    6415           0 :                                                 state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6416           0 :                             ShowContinueError(state, "...use a Setpoint Manager to establish a setpoint at the TU or coil(s) outlet node.");
    6417           0 :                             ErrorsFound = true;
    6418           0 :                         } else if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    6419           0 :                             bool SPNotFound = false;
    6420           0 :                             EMSManager::CheckIfNodeSetPointManagedByEMS(state,
    6421           0 :                                                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum,
    6422             :                                                                         EMSManager::SPControlType::TemperatureSetPoint,
    6423             :                                                                         SetPointErrorFlag);
    6424           0 :                             SPNotFound = SPNotFound || SetPointErrorFlag;
    6425           0 :                             EMSManager::CheckIfNodeSetPointManagedByEMS(state,
    6426           0 :                                                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirOutNode,
    6427             :                                                                         EMSManager::SPControlType::TemperatureSetPoint,
    6428             :                                                                         SetPointErrorFlag);
    6429           0 :                             SPNotFound = SPNotFound || SetPointErrorFlag;
    6430           0 :                             EMSManager::CheckIfNodeSetPointManagedByEMS(state,
    6431           0 :                                                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirOutNode,
    6432             :                                                                         EMSManager::SPControlType::TemperatureSetPoint,
    6433             :                                                                         SetPointErrorFlag);
    6434           0 :                             SPNotFound = SPNotFound || SetPointErrorFlag;
    6435             : 
    6436             :                             // We disable the check at end (if API), because one of the nodes is enough, so there's an almost certainty
    6437             :                             // that it will throw as you're unlikely going to actuate all three nodes
    6438             :                             // It's not ideal, but it's better to let slide a bad condition rather than throw false positives...
    6439           0 :                             state.dataLoopNodes->NodeSetpointCheck(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum)
    6440           0 :                                 .needsSetpointChecking = false;
    6441           0 :                             state.dataLoopNodes->NodeSetpointCheck(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirOutNode)
    6442           0 :                                 .needsSetpointChecking = false;
    6443           0 :                             state.dataLoopNodes->NodeSetpointCheck(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirOutNode)
    6444           0 :                                 .needsSetpointChecking = false;
    6445             : 
    6446           0 :                             if (SPNotFound && state.dataAirLoop->AirLoopInputsFilled) {
    6447           0 :                                 ShowSevereError(state,
    6448           0 :                                                 "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow: Missing temperature setpoint for unitary system = " +
    6449           0 :                                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).Name);
    6450           0 :                                 ShowContinueError(state, "...use a Setpoint Manager to establish a setpoint at the TU or coil(s) outlet node.");
    6451           0 :                                 ShowContinueError(state, "...or use an EMS actuator to establish a temperature setpoint at the coil control node.");
    6452           0 :                                 ErrorsFound = true;
    6453             :                             }
    6454             :                         }
    6455             :                     }
    6456             :                 }
    6457             : 
    6458        1458 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isInAirLoop || state.dataHVACVarRefFlow->VRFTU(TUIndex).isInOASys ||
    6459         718 :                     state.dataHVACVarRefFlow->VRFTU(TUIndex).isInZone)
    6460         732 :                     continue;
    6461           8 :                 if (!state.dataAirLoop->AirLoopInputsFilled) continue;
    6462           0 :                 ShowSevereError(state,
    6463           0 :                                 "InitVRF: VRF Terminal Unit = [" +
    6464           0 :                                     DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUType_Num) + ',' +
    6465           0 :                                     state.dataHVACVarRefFlow->VRFTU(TUIndex).Name +
    6466             :                                     "] is not on any ZoneHVAC:EquipmentList, AirloopHVAC or AirLoopHVAC:OutdoorAirSystem:EquipmentList.  It will not "
    6467             :                                     "be simulated.");
    6468           0 :                 ShowContinueError(state, "...The VRF AC System associated with this terminal unit may also not be simulated.");
    6469             :             }
    6470             :         }
    6471             : 
    6472             :         // TU inlet node must be the same as a zone exhaust node and the OA Mixer return node
    6473             :         // check that TU inlet node is a zone exhaust node.
    6474         421 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone &&
    6475         159 :             (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists ||
    6476          16 :              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_SupplySide)) {
    6477         133 :             bool ZoneNodeNotFound = true;
    6478         515 :             for (int CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
    6479         515 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue;
    6480         631 :                 for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumExhaustNodes; ++NodeNum) {
    6481         764 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum ==
    6482         382 :                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ExhaustNode(NodeNum)) {
    6483         133 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    6484         133 :                         ZoneNodeNotFound = false;
    6485         133 :                         break;
    6486             :                     }
    6487             :                 }
    6488         382 :                 if (!ZoneNodeNotFound) break;
    6489             :             }
    6490         133 :             if (ZoneNodeNotFound && !state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInAirLoop) {
    6491           0 :                 ShowSevereError(state,
    6492           0 :                                 cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name +
    6493             :                                     "\" Zone terminal unit air inlet node name must be the same as a zone exhaust node name.");
    6494           0 :                 ShowContinueError(state, "... Zone exhaust node name is specified in ZoneHVAC:EquipmentConnections object.");
    6495           0 :                 ShowContinueError(state,
    6496           0 :                                   "... Zone terminal unit inlet node name = " +
    6497           0 :                                       state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum));
    6498           0 :                 ErrorsFound = true;
    6499             :             }
    6500             :         }
    6501             :         // check OA Mixer return node
    6502         272 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone && !state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists &&
    6503         127 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    6504         254 :             Array1D_int OANodeNums = MixedAir::GetOAMixerNodeNumbers(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName, errFlag);
    6505         127 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum != OANodeNums(3)) {
    6506           0 :                 ShowSevereError(state,
    6507           0 :                                 cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name +
    6508             :                                     "\" Zone terminal unit air inlet node name must be the same as the OutdoorAir:Mixer return air node name.");
    6509           0 :                 ShowContinueError(state,
    6510           0 :                                   "... Zone terminal unit air inlet node name = " +
    6511           0 :                                       state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum));
    6512           0 :                 ShowContinueError(state, "... OutdoorAir:Mixer return air node name = " + state.dataLoopNodes->NodeID(OANodeNums(3)));
    6513           0 :                 ErrorsFound = true;
    6514             :             }
    6515             :         }
    6516             :         // check that TU outlet node is a zone inlet node.
    6517         425 :         if ((state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone &&
    6518         159 :              (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists ||
    6519          16 :               state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_InletSide))) {
    6520         137 :             bool ZoneNodeNotFound = true;
    6521         511 :             for (int CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
    6522         511 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) continue;
    6523         719 :                 for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++NodeNum) {
    6524         964 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum ==
    6525         482 :                         state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(NodeNum)) {
    6526         137 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).ZoneNode;
    6527         137 :                         ZoneNodeNotFound = false;
    6528         137 :                         break;
    6529             :                     }
    6530             :                 }
    6531         374 :                 if (!ZoneNodeNotFound) break;
    6532             :             }
    6533         137 :             if (ZoneNodeNotFound) {
    6534           0 :                 ShowSevereError(state,
    6535           0 :                                 cCurrentModuleObject + " \"" + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name +
    6536             :                                     "\" Zone terminal unit air outlet node name must be the same as a zone inlet node name.");
    6537           0 :                 ShowContinueError(state, "... Zone inlet node name is specified in ZoneHVAC:EquipmentConnections object.");
    6538           0 :                 ShowContinueError(state,
    6539           0 :                                   "... Zone terminal unit outlet node name = " +
    6540           0 :                                       state.dataLoopNodes->NodeID(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum));
    6541           0 :                 ErrorsFound = true;
    6542             :             }
    6543             :         }
    6544             : 
    6545         145 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists) {
    6546             :             //   check that OA flow in cooling must be set to zero when connected to DOAS
    6547          16 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow != 0) {
    6548           0 :                 ShowWarningError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    6549           0 :                 ShowContinueError(state, ".. Cooling Outdoor Air Flow Rate must be zero when " + cCurrentModuleObject);
    6550           0 :                 ShowContinueError(state, "..object is connected to central dedicated outdoor air system via AirTerminal:SingleDuct:Mixer");
    6551           0 :                 ShowContinueError(state, ".. Cooling Outdoor Air Flow Rate is set to 0 and simulation continues.");
    6552           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow = 0;
    6553             :             }
    6554             :             //   check that OA flow in heating must be set to zero when connected to DOAS
    6555          16 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow != 0) {
    6556           0 :                 ShowWarningError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    6557           0 :                 ShowContinueError(state, ".. Heating Outdoor Air Flow Rate must be zero when " + cCurrentModuleObject);
    6558           0 :                 ShowContinueError(state, "..object is connected to central dedicated outdoor air system via AirTerminal:SingleDuct:Mixer");
    6559           0 :                 ShowContinueError(state, ".. Heating Outdoor Air Flow Rate is set to 0 and simulation continues.");
    6560           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow = 0;
    6561             :             }
    6562             :             //   check that OA flow in no cooling and no heating must be set to zero when connected to DOAS
    6563          16 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow != 0) {
    6564           0 :                 ShowWarningError(state, cCurrentModuleObject + " = " + state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    6565           0 :                 ShowContinueError(state, ".. No Load Outdoor Air Flow Rate must be zero when " + cCurrentModuleObject);
    6566           0 :                 ShowContinueError(state, "..object is connected to central dedicated outdoor air system via AirTerminal:SingleDuct:Mixer");
    6567           0 :                 ShowContinueError(state, ".. No Load Outdoor Air Flow Rate is set to 0 and simulation continues.");
    6568           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow = 0;
    6569             :             }
    6570             :         }
    6571             :     } // IF(ZoneEquipmentListNotChecked)THEN
    6572             : 
    6573             :     // Size TU
    6574      231306 :     if (state.dataHVACVarRefFlow->MySizeFlag(VRFTUNum)) {
    6575         110 :         if (!state.dataGlobal->ZoneSizingCalc && !state.dataGlobal->SysSizingCalc) {
    6576          56 :             SizeVRF(state, VRFTUNum);
    6577          56 :             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).TerminalUnitNotSizedYet(IndexToTUInTUList) = false;
    6578          56 :             state.dataHVACVarRefFlow->MySizeFlag(VRFTUNum) = false;
    6579             :         } // IF ( .NOT. ZoneSizingCalc) THEN
    6580             :     }     // IF (MySizeFlag(VRFTUNum)) THEN
    6581             : 
    6582             :     // Do the Begin Environment initializations
    6583      231306 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataHVACVarRefFlow->MyEnvrnFlag(VRFTUNum)) {
    6584             : 
    6585             :         // Change the Volume Flow Rates to Mass Flow Rates
    6586             : 
    6587         336 :         RhoAir = state.dataEnvrn->StdRhoAir;
    6588             :         // set the mass flow rates from the input volume flow rates
    6589         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow;
    6590         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow;
    6591         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow;
    6592         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow;
    6593         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow;
    6594         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow = RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow;
    6595         336 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow =
    6596         336 :             RhoAir * state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow;
    6597             :         // set the node max and min mass flow rates
    6598             :         // outside air mixer is optional, check that node num > 0
    6599         336 :         if (OutsideAirNode > 0) {
    6600         300 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRateMax =
    6601         300 :                 max(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow);
    6602         300 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRateMin = 0.0;
    6603         300 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRateMinAvail = 0.0;
    6604             :         }
    6605         336 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMax =
    6606         336 :             max(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow);
    6607         336 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMin = 0.0;
    6608         336 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMinAvail = 0.0;
    6609         336 :         state.dataLoopNodes->Node(InNode).MassFlowRateMax =
    6610         336 :             max(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow);
    6611         336 :         state.dataLoopNodes->Node(InNode).MassFlowRateMin = 0.0;
    6612         336 :         state.dataLoopNodes->Node(InNode).MassFlowRateMinAvail = 0.0;
    6613         336 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRelNodeNum > 0) {
    6614         300 :             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRelNodeNum).MassFlowRateMinAvail = 0.0;
    6615             :         }
    6616             : 
    6617         336 :         state.dataHVACVarRefFlow->MyEnvrnFlag(VRFTUNum) = false;
    6618             : 
    6619         336 :         if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    6620          48 :             rho = GetDensityGlycol(state,
    6621          24 :                                    state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRF(VRFCond).SourcePlantLoc.loopNum).FluidName,
    6622             :                                    DataGlobalConstants::CWInitConvTemp,
    6623          24 :                                    state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRF(VRFCond).SourcePlantLoc.loopNum).FluidIndex,
    6624             :                                    RoutineName);
    6625          24 :             state.dataHVACVarRefFlow->VRF(VRFCond).WaterCondenserDesignMassFlow = state.dataHVACVarRefFlow->VRF(VRFCond).WaterCondVolFlowRate * rho;
    6626             : 
    6627          72 :             InitComponentNodes(state,
    6628             :                                0.0,
    6629          24 :                                state.dataHVACVarRefFlow->VRF(VRFCond).WaterCondenserDesignMassFlow,
    6630          24 :                                state.dataHVACVarRefFlow->VRF(VRFCond).CondenserNodeNum,
    6631          24 :                                state.dataHVACVarRefFlow->VRF(VRFCond).CondenserOutletNodeNum);
    6632             :         }
    6633             :         //    IF(MyVRFCondFlag(VRFCond))THEN
    6634         336 :         state.dataHVACVarRefFlow->VRF(VRFCond).HRTimer = 0.0;
    6635         336 :         state.dataHVACVarRefFlow->VRF(VRFCond).ModeChange = false;
    6636         336 :         state.dataHVACVarRefFlow->VRF(VRFCond).HRModeChange = false;
    6637         336 :         state.dataHVACVarRefFlow->MyVRFCondFlag(VRFCond) = false;
    6638             :         //    END IF
    6639             : 
    6640         336 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode > 0) {
    6641          24 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    6642          12 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow == DataSizing::AutoSize) {
    6643           6 :                     WaterCoils::SimulateWaterCoilComponents(state,
    6644           2 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    6645             :                                                             FirstHVACIteration,
    6646           2 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex);
    6647             :                     // design hot water volume flow rate
    6648           4 :                     Real64 CoilMaxVolFlowRate = WaterCoils::GetCoilMaxWaterFlowRate(
    6649           4 :                         state, "Coil:Heating:Water", state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName, ErrorsFound);
    6650           2 :                     if (CoilMaxVolFlowRate != DataSizing::AutoSize) {
    6651           4 :                         rho = GetDensityGlycol(
    6652             :                             state,
    6653           2 :                             state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc.loopNum).FluidName,
    6654             :                             DataGlobalConstants::HWInitConvTemp,
    6655           2 :                             state.dataPlnt->PlantLoop(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc.loopNum).FluidIndex,
    6656             :                             RoutineName);
    6657           2 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow = CoilMaxVolFlowRate * rho;
    6658             :                     }
    6659             :                 }
    6660             :             }
    6661             : 
    6662          24 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) {
    6663          12 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow == DataSizing::AutoSize) {
    6664           6 :                     SteamCoils::SimulateSteamCoilComponents(state,
    6665           2 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    6666             :                                                             FirstHVACIteration,
    6667           2 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex,
    6668             :                                                             1.0);
    6669             :                     // design steam volume flow rate
    6670             :                     Real64 CoilMaxVolFlowRate =
    6671           2 :                         SteamCoils::GetCoilMaxSteamFlowRate(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex, ErrorsFound);
    6672           2 :                     if (CoilMaxVolFlowRate != DataSizing::AutoSize) {
    6673           2 :                         int SteamIndex = 0; // fluid type index of 0 is passed if steam
    6674           2 :                         Real64 TempSteamIn = 100.0;
    6675           2 :                         Real64 SteamDensity = FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName);
    6676           2 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow = CoilMaxVolFlowRate * SteamDensity;
    6677             :                     }
    6678             :                 }
    6679             :             }
    6680             :             // init water/steam coils min and max flow rates
    6681          72 :             InitComponentNodes(state,
    6682             :                                0.0,
    6683          24 :                                state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow,
    6684          24 :                                state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode,
    6685          24 :                                state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode);
    6686             :         }
    6687             : 
    6688             :         // the first time an air loop VRF TU is simulated set isSimulated = true so that the TU initialization
    6689             :         // will occur with the first TU simulated this time step. Zone VRF TUs are called during sizing which, if air
    6690             :         // loop TUs are included, alters when all TUs appear to have been simulated. Also, BeginEnvrnFlag is true multiple
    6691             :         // times during the simulation, reset each time to avoid a different order during sizing and simulation
    6692         336 :         if (state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex).reset_isSimulatedFlags) {
    6693             :             // if no TUs are in the air loop or outdoor air system they will all be simulated during ManageZoneEquipment
    6694             :             // and there is no need to adjust the order of simulation (i.e., when isSimulated are all true for a given system)
    6695         330 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInAirLoop || state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys) {
    6696           6 :                 state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex).IsSimulated = true;
    6697           6 :                 state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex).reset_isSimulatedFlags = false;
    6698             :             }
    6699             :         }
    6700             : 
    6701             :     } // IF (BeginEnvrnFlag .and. MyEnvrnFlag(VRFTUNum)) THEN
    6702             : 
    6703             :     // reset environment flag for next environment
    6704      231306 :     if (!state.dataGlobal->BeginEnvrnFlag) {
    6705      229218 :         state.dataHVACVarRefFlow->MyEnvrnFlag(VRFTUNum) = true;
    6706      229218 :         state.dataHVACVarRefFlow->MyVRFCondFlag(VRFCond) = true;
    6707      229218 :         state.dataHVACVarRefFlow->TerminalUnitList(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex).reset_isSimulatedFlags = true;
    6708             :     }
    6709             : 
    6710             :     // If all VRF Terminal Units on this VRF AC System have been simulated, reset the IsSimulated flag
    6711             :     // The condenser will be simulated after all terminal units have been simulated (see Sub SimulateVRF)
    6712      231306 :     if (all(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).IsSimulated)) {
    6713             :         //   this should be the first time through on the next iteration. All TU's and condenser have been simulated.
    6714             :         //   reset simulation flag for each terminal unit
    6715       49383 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).IsSimulated = false;
    6716             :         //     after all TU's have been simulated, reset operating mode flag if necessary
    6717       49383 :         if (state.dataHVACVarRefFlow->LastModeHeating(VRFCond) && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
    6718          80 :             state.dataHVACVarRefFlow->LastModeCooling(VRFCond) = true;
    6719          80 :             state.dataHVACVarRefFlow->LastModeHeating(VRFCond) = false;
    6720             :             //        SwitchedMode(VRFCond)    = .TRUE.
    6721             :         }
    6722       49383 :         if (state.dataHVACVarRefFlow->LastModeCooling(VRFCond) && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
    6723          68 :             state.dataHVACVarRefFlow->LastModeHeating(VRFCond) = true;
    6724          68 :             state.dataHVACVarRefFlow->LastModeCooling(VRFCond) = false;
    6725             :             //        SwitchedMode(VRFCond)    = .TRUE.
    6726             :         }
    6727             :     } // IF(ALL(TerminalUnitList(VRFTU(VRFTUNum)%TUListIndex)%IsSimulated))THEN
    6728             : 
    6729             :     // get operating capacity of water and steam coil
    6730      231306 :     if (FirstHVACIteration) {
    6731      115844 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode > 0) {
    6732        7328 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    6733             :                 //     set hot water full flow rate for sizing
    6734        3664 :                 Real64 mdot = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow;
    6735       10992 :                 PlantUtilities::SetComponentFlowRate(state,
    6736             :                                                      mdot,
    6737        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode,
    6738        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode,
    6739        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc);
    6740             : 
    6741             :                 //     simulate water coil to find operating capacity
    6742       10992 :                 WaterCoils::SimulateWaterCoilComponents(state,
    6743        3664 :                                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    6744             :                                                         FirstHVACIteration,
    6745        3664 :                                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex,
    6746             :                                                         SuppHeatCoilCapacity);
    6747        3664 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity = SuppHeatCoilCapacity;
    6748             :             } // from iF VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater
    6749        7328 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) {
    6750             :                 //     set hot water full flow rate for sizing
    6751        3664 :                 Real64 mdot = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow;
    6752       10992 :                 PlantUtilities::SetComponentFlowRate(state,
    6753             :                                                      mdot,
    6754        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode,
    6755        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode,
    6756        3664 :                                                      state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc);
    6757             : 
    6758             :                 //     simulate steam coil to find operating capacity
    6759       10992 :                 SteamCoils::SimulateSteamCoilComponents(state,
    6760        3664 :                                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    6761             :                                                         FirstHVACIteration,
    6762        3664 :                                                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex,
    6763             :                                                         1.0,
    6764             :                                                         ErrorsFound); // QCoilReq, simulate any load > 0 to get max capacity of steam coil
    6765        3664 :                 SuppHeatCoilCapacity =
    6766        7328 :                     SteamCoils::GetCoilCapacity(state, "Coil:Heating:Steam", state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName, ErrorsFound);
    6767             : 
    6768        3664 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity = SuppHeatCoilCapacity;
    6769             :             } // from if VRFTU( VRFTUNum ).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam
    6770             :         }
    6771             :     }
    6772             :     // initialize water/steam coil inlet flow rate to zero
    6773      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode > 0) {
    6774       14628 :         Real64 mdot = 0.0;
    6775       43884 :         PlantUtilities::SetComponentFlowRate(state,
    6776             :                                              mdot,
    6777       14628 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode,
    6778       14628 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode,
    6779       14628 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilPlantLoc);
    6780             :     }
    6781             : 
    6782             :     // one-time checks of flow rate vs fan flow rate
    6783      231306 :     if (state.dataHVACVarRefFlow->MyVRFFlag(VRFTUNum)) {
    6784         165 :         if (!state.dataGlobal->ZoneSizingCalc && !state.dataGlobal->SysSizingCalc) {
    6785         111 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace > 0) {
    6786         110 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate != AutoSize) {
    6787             : 
    6788         110 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow >
    6789          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) {
    6790           0 :                         ShowWarningError(state,
    6791           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6792           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6793           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6794           0 :                         ShowContinueError(state, "... has Supply Air Flow Rate During Cooling Operation > Max Fan Volume Flow Rate, should be <=");
    6795           0 :                         ShowContinueError(state,
    6796           0 :                                           format("... Supply Air Flow Rate During Cooling Operation = {:.4R} m3/s",
    6797           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow));
    6798           0 :                         ShowContinueError(state,
    6799           0 :                                           format("... Max Fan Volume Flow Rate                      = {:.4R} m3/s",
    6800           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate));
    6801           0 :                         ShowContinueError(
    6802             :                             state, "...the supply air flow rate during cooling operation will be reduced to match and the simulation continues.");
    6803           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6804             :                     }
    6805             : 
    6806         110 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow >
    6807          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) {
    6808           0 :                         ShowWarningError(state,
    6809           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6810           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6811           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6812           0 :                         ShowContinueError(state, "... has Supply Air Flow Rate When No Cooling is Needed > Max Fan Volume Flow Rate, should be <=");
    6813           0 :                         ShowContinueError(state,
    6814           0 :                                           format("... Supply Air Flow Rate When No Cooling is Needed = {:.4R} m3/s",
    6815           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow));
    6816           0 :                         ShowContinueError(state,
    6817           0 :                                           format("... Max Fan Volume Flow Rate                       = {:.4R} m3/s",
    6818           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate));
    6819           0 :                         ShowContinueError(
    6820             :                             state, "...the supply air flow rate when no cooling is needed will be reduced to match and the simulation continues.");
    6821           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow =
    6822           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6823             :                     }
    6824             : 
    6825          55 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow > state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow) {
    6826           0 :                         ShowWarningError(state,
    6827           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6828           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6829           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6830           0 :                         ShowContinueError(
    6831             :                             state,
    6832             :                             "...The Outdoor Air Flow Rate During Cooling Operation exceeds the Supply Air Flow Rate During Cooling Operation.");
    6833           0 :                         ShowContinueError(state,
    6834           0 :                                           format("...Outdoor Air Flow Rate During Cooling Operation = {:.4R} m3/s",
    6835           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow));
    6836           0 :                         ShowContinueError(state,
    6837           0 :                                           format("... Supply Air Flow Rate During Cooling Operation = {:.4R} m3/s",
    6838           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow));
    6839           0 :                         ShowContinueError(state, "...the outdoor air flow rate will be reduced to match and the simulation continues.");
    6840           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow;
    6841             :                     }
    6842             : 
    6843         110 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow >
    6844          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) {
    6845           0 :                         ShowWarningError(state,
    6846           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6847           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6848           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6849           0 :                         ShowContinueError(state, "... has Supply Air Flow Rate During Heating Operation > Max Fan Volume Flow Rate, should be <=");
    6850           0 :                         ShowContinueError(state,
    6851           0 :                                           format("... Supply Air Flow Rate During Heating Operation = {:.4R} m3/s",
    6852           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow));
    6853           0 :                         ShowContinueError(state,
    6854           0 :                                           format("... Max Fan Volume Flow Rate                      = {:.4R} m3/s",
    6855           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate));
    6856           0 :                         ShowContinueError(
    6857             :                             state, "...the supply air flow rate during cooling operation will be reduced to match and the simulation continues.");
    6858           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6859             :                     }
    6860             : 
    6861         110 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow >
    6862          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) {
    6863           0 :                         ShowWarningError(state,
    6864           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6865           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6866           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6867           0 :                         ShowContinueError(state, "... has Supply Air Flow Rate When No Heating is Needed > Max Fan Volume Flow Rate, should be <=");
    6868           0 :                         ShowContinueError(state,
    6869           0 :                                           format("... Supply Air Flow Rate When No Heating is Needed = {:.4R} m3/s",
    6870           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow));
    6871           0 :                         ShowContinueError(state,
    6872           0 :                                           format("... Max Fan Volume Flow Rate                       = {:.4R} m3/s",
    6873           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate));
    6874           0 :                         ShowContinueError(
    6875             :                             state, "...the supply air flow rate when no cooling is needed will be reduced to match and the simulation continues.");
    6876           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow =
    6877           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6878             :                     }
    6879             : 
    6880          55 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow > state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow) {
    6881           0 :                         ShowWarningError(state,
    6882           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6883           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6884           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6885           0 :                         ShowContinueError(
    6886             :                             state,
    6887             :                             "...The Outdoor Air Flow Rate During Heating Operation exceeds the Supply Air Flow Rate During Heating Operation.");
    6888           0 :                         ShowContinueError(state,
    6889           0 :                                           format("...Outdoor Air Flow Rate During Heating Operation = {:.4R} m3/s",
    6890           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow));
    6891           0 :                         ShowContinueError(state,
    6892           0 :                                           format("... Supply Air Flow Rate During Heating Operation = {:.4R} m3/s",
    6893           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow));
    6894           0 :                         ShowContinueError(state, "...the outdoor air flow rate will be reduced to match and the simulation continues.");
    6895           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow;
    6896             :                     }
    6897             : 
    6898         110 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow >
    6899          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate) {
    6900           0 :                         ShowWarningError(state,
    6901           0 :                                          "InitVRF: VRF Terminal Unit = [" +
    6902           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ", \"" +
    6903           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name + "\"]");
    6904           0 :                         ShowContinueError(
    6905             :                             state, "... has a Outdoor Air Flow Rate When No Cooling or Heating is Needed > Max Fan Volume Flow Rate, should be <=");
    6906           0 :                         ShowContinueError(state,
    6907           0 :                                           format("... Outdoor Air Flow Rate When No Cooling or Heating is Needed = {:.4R} m3/s",
    6908           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow));
    6909           0 :                         ShowContinueError(state,
    6910           0 :                                           format("... Max Fan Volume Flow Rate                                   = {:.4R} m3/s",
    6911           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate));
    6912           0 :                         ShowContinueError(state,
    6913             :                                           "...the outdoor air flow rate when no cooling or heating is needed will be reduced to match and the "
    6914             :                                           "simulation continues.");
    6915           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow =
    6916           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6917             :                     }
    6918             : 
    6919          55 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate > 0.0) {
    6920         110 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow /
    6921          55 :                                                                                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6922         110 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow /
    6923          55 :                                                                                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6924          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio =
    6925         110 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow /
    6926          55 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6927          55 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio =
    6928         110 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow /
    6929          55 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate;
    6930             :                     }
    6931             : 
    6932          55 :                     state.dataHVACVarRefFlow->MyVRFFlag(VRFTUNum) = false;
    6933             :                 } else {
    6934          55 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    6935          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate =
    6936          15 :                             state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->designAirVolFlowRate;
    6937             :                     } else {
    6938          80 :                         GetFanVolFlow(state,
    6939          40 :                                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex,
    6940          40 :                                       state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ActualFanVolFlowRate);
    6941             :                     }
    6942             :                 }
    6943             :             } else {
    6944           1 :                 state.dataHVACVarRefFlow->MyVRFFlag(VRFTUNum) = false;
    6945             :             }
    6946             :         }
    6947             :     } // IF(MyVRFFlag(VRFTUNum))THEN
    6948             : 
    6949             :     // calculate end time of current time step to determine if max capacity reset is required
    6950      462612 :     CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone +
    6951      231306 :                      state.dataHVACGlobal->SysTimeElapsed;
    6952             : 
    6953             :     // Initialize the maximum allowed terminal unit capacity. Total terminal unit capacity must not
    6954             :     // exceed the available condenser capacity. This variable is used to limit the terminal units
    6955             :     // providing more capacity than allowed. Example: TU loads are 1-ton, 2-ton, 3-ton, and 4-ton connected
    6956             :     // to a condenser having only 9-tons available. This variable will be set to 3-tons and the 4-ton
    6957             :     // terminal unit will be limited to 3-tons (see SimVRFCondenser where this variable is calculated).
    6958      255958 :     if (CurrentEndTime > state.dataHVACVarRefFlow->CurrentEndTimeLast || TimeStepSysLast > state.dataHVACGlobal->TimeStepSys ||
    6959       95975 :         (FirstHVACIteration && state.dataHVACVarRefFlow->MyBeginTimeStepFlag(VRFCond))) {
    6960       24652 :         state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = MaxCap;
    6961       24652 :         state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = MaxCap;
    6962       24652 :         state.dataHVACVarRefFlow->MyBeginTimeStepFlag(VRFCond) = false;
    6963             :     }
    6964             : 
    6965      231306 :     if (!FirstHVACIteration) state.dataHVACVarRefFlow->MyBeginTimeStepFlag(VRFCond) = true;
    6966             : 
    6967             :     // Do the following initializations (every time step).
    6968             : 
    6969      231306 :     TimeStepSysLast = state.dataHVACGlobal->TimeStepSys;
    6970      231306 :     state.dataHVACVarRefFlow->CurrentEndTimeLast = CurrentEndTime;
    6971             : 
    6972      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr > 0) {
    6973      228122 :         if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanOpModeSchedPtr) == 0.0) {
    6974       62200 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode = DataHVACGlobals::CycFanCycCoil;
    6975             :         } else {
    6976      165922 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode = DataHVACGlobals::ContFanCycCoil;
    6977             :         }
    6978             :     }
    6979             : 
    6980             :     // if condenser is off, all terminal unit coils are off
    6981      231306 :     if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPtr) == 0.0) {
    6982       20400 :         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
    6983       20400 :         state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
    6984             :     } else {
    6985             : 
    6986             :         //*** Operating Mode Initialization done at beginning of each iteration ***!
    6987             :         //*** assumes all TU's and Condenser were simulated last iteration ***!
    6988             :         //*** this code is done ONCE each iteration when all TU's IsSimulated flag is FALSE ***!
    6989             :         // Determine operating mode prior to simulating any terminal units connected to a VRF condenser
    6990             :         // this should happen at the beginning of a time step where all TU's are polled to see what
    6991             :         // mode the heat pump condenser will operate in
    6992      210906 :         if (!any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).IsSimulated)) {
    6993       45315 :             InitializeOperatingMode(state, FirstHVACIteration, VRFCond, TUListIndex, OnOffAirFlowRatio);
    6994             :         }
    6995             :         //*** End of Operating Mode Initialization done at beginning of each iteration ***!
    6996             : 
    6997             :         // disable VRF system when outside limits of operation based on OAT
    6998      210906 :         EnableSystem = false; // flag used to switch operating modes when OAT is outside operating limits
    6999      210906 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
    7000      353469 :             if ((OutsideDryBulbTemp < state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling ||
    7001      117823 :                  OutsideDryBulbTemp > state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling) &&
    7002           0 :                 any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).CoolingCoilPresent)) {
    7003           0 :                 state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
    7004             :                 // test if heating load exists, account for thermostat control type
    7005           0 :                 switch (state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority) {
    7006           0 :                 case ThermostatCtrlType::LoadPriority:
    7007             :                 case ThermostatCtrlType::ZonePriority: {
    7008           0 :                     if (state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) > 0.0) EnableSystem = true;
    7009           0 :                 } break;
    7010           0 :                 case ThermostatCtrlType::ThermostatOffsetPriority: {
    7011           0 :                     if (state.dataHVACVarRefFlow->MinDeltaT(VRFCond) < 0.0) EnableSystem = true;
    7012           0 :                 } break;
    7013           0 :                 case ThermostatCtrlType::ScheduledPriority:
    7014             :                 case ThermostatCtrlType::MasterThermostatPriority: {
    7015             :                     // can't switch modes if scheduled (i.e., would be switching to unscheduled mode)
    7016             :                     // or master TSTAT used (i.e., master zone only has a specific load - can't switch)
    7017           0 :                 } break;
    7018           0 :                 default:
    7019           0 :                     break;
    7020             :                 }
    7021           0 :                 if (EnableSystem) {
    7022           0 :                     if ((OutsideDryBulbTemp >= state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating &&
    7023           0 :                          OutsideDryBulbTemp <= state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating) &&
    7024           0 :                         any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HeatingCoilPresent)) {
    7025           0 :                         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
    7026             :                     } else {
    7027           0 :                         if (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).CoolingCoilAvailable)) {
    7028           0 :                             if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolingMaxTempLimitIndex == 0) {
    7029           0 :                                 ShowWarningMessage(state,
    7030           0 :                                                    std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7031           0 :                                                        state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7032           0 :                                 ShowContinueError(state,
    7033             :                                                   "...InitVRF: VRF Heat Pump Min/Max Operating Temperature in Cooling Mode Limits have been "
    7034             :                                                   "exceeded and VRF system is disabled.");
    7035           0 :                                 if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    7036           0 :                                     ShowContinueError(state,
    7037           0 :                                                       format("... Outdoor Unit Inlet Water Temperature           = {:.3T}", OutsideDryBulbTemp));
    7038             :                                 } else {
    7039           0 :                                     ShowContinueError(state,
    7040           0 :                                                       format("... Outdoor Unit Inlet Air Temperature                 = {:.3T}", OutsideDryBulbTemp));
    7041             :                                 }
    7042           0 :                                 ShowContinueError(state,
    7043           0 :                                                   format("... Cooling Minimum Outdoor Unit Inlet Temperature = {:.3T}",
    7044           0 :                                                          state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling));
    7045           0 :                                 ShowContinueError(state,
    7046           0 :                                                   format("... Cooling Maximum Outdoor Unit Inlet Temperature = {:.3T}",
    7047           0 :                                                          state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling));
    7048           0 :                                 ShowContinueErrorTimeStamp(state, "... Check VRF Heat Pump Min/Max Outdoor Temperature in Cooling Mode limits.");
    7049             :                             }
    7050           0 :                             ShowRecurringWarningErrorAtEnd(state,
    7051           0 :                                                            std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7052           0 :                                                                state.dataHVACVarRefFlow->VRF(VRFCond).Name +
    7053             :                                                                "\" -- Exceeded VRF Heat Pump min/max cooling temperature limit error continues...",
    7054           0 :                                                            state.dataHVACVarRefFlow->VRF(VRFCond).CoolingMaxTempLimitIndex,
    7055             :                                                            OutsideDryBulbTemp,
    7056             :                                                            OutsideDryBulbTemp);
    7057             :                         }
    7058             :                     }
    7059             :                 } else {
    7060           0 :                     if (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).CoolingCoilAvailable)) {
    7061           0 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolingMaxTempLimitIndex == 0) {
    7062           0 :                             ShowWarningMessage(state,
    7063           0 :                                                std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7064           0 :                                                    state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7065           0 :                             ShowContinueError(state,
    7066             :                                               "...InitVRF: VRF Heat Pump Min/Max Operating Temperature in Cooling Mode Limits have been exceeded "
    7067             :                                               "and VRF system is disabled.");
    7068           0 :                             if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    7069           0 :                                 ShowContinueError(state, format("... Outdoor Unit Inlet Water Temperature           = {:.3T}", OutsideDryBulbTemp));
    7070             :                             } else {
    7071           0 :                                 ShowContinueError(state,
    7072           0 :                                                   format("... Outdoor Unit Inlet Air Temperature                 = {:.3T}", OutsideDryBulbTemp));
    7073             :                             }
    7074           0 :                             ShowContinueError(state,
    7075           0 :                                               format("... Cooling Minimum Outdoor Unit Inlet Temperature = {:.3T}",
    7076           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling));
    7077           0 :                             ShowContinueError(state,
    7078           0 :                                               format("... Cooling Maximum Outdoor Unit Inlet Temperature = {:.3T}",
    7079           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling));
    7080           0 :                             ShowContinueErrorTimeStamp(state, "... Check VRF Heat Pump Min/Max Outdoor Temperature in Cooling Mode limits.");
    7081             :                         }
    7082           0 :                         ShowRecurringWarningErrorAtEnd(state,
    7083           0 :                                                        std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7084           0 :                                                            state.dataHVACVarRefFlow->VRF(VRFCond).Name +
    7085             :                                                            "\" -- Exceeded VRF Heat Pump min/max cooling temperature limit error continues...",
    7086           0 :                                                        state.dataHVACVarRefFlow->VRF(VRFCond).CoolingMaxTempLimitIndex,
    7087             :                                                        OutsideDryBulbTemp,
    7088             :                                                        OutsideDryBulbTemp);
    7089             :                     }
    7090             :                 }
    7091             :             }
    7092       93083 :         } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
    7093      256527 :             if ((OutsideDryBulbTemp < state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating ||
    7094       85509 :                  OutsideDryBulbTemp > state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating) &&
    7095           0 :                 any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HeatingCoilPresent)) {
    7096           0 :                 state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
    7097             :                 // test if cooling load exists, account for thermostat control type
    7098           0 :                 switch (state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority) {
    7099           0 :                 case ThermostatCtrlType::LoadPriority:
    7100             :                 case ThermostatCtrlType::ZonePriority: {
    7101           0 :                     if (state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) < 0.0) EnableSystem = true;
    7102           0 :                 } break;
    7103           0 :                 case ThermostatCtrlType::ThermostatOffsetPriority: {
    7104           0 :                     if (state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) > 0.0) EnableSystem = true;
    7105           0 :                 } break;
    7106           0 :                 case ThermostatCtrlType::ScheduledPriority:
    7107             :                 case ThermostatCtrlType::MasterThermostatPriority: {
    7108           0 :                 } break;
    7109           0 :                 default:
    7110           0 :                     break;
    7111             :                 }
    7112           0 :                 if (EnableSystem) {
    7113           0 :                     if ((OutsideDryBulbTemp >= state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling &&
    7114           0 :                          OutsideDryBulbTemp <= state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling) &&
    7115           0 :                         any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).CoolingCoilPresent)) {
    7116           0 :                         state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
    7117             :                     } else {
    7118           0 :                         if (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HeatingCoilAvailable)) {
    7119           0 :                             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatingMaxTempLimitIndex == 0) {
    7120           0 :                                 ShowWarningMessage(state,
    7121           0 :                                                    std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7122           0 :                                                        state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7123           0 :                                 ShowContinueError(state,
    7124             :                                                   "...InitVRF: VRF Heat Pump Min/Max Operating Temperature in Heating Mode Limits have been "
    7125             :                                                   "exceeded and VRF system is disabled.");
    7126           0 :                                 if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    7127           0 :                                     ShowContinueError(state,
    7128           0 :                                                       format("... Outdoor Unit Inlet Water Temperature           = {:.3T}", OutsideDryBulbTemp));
    7129             :                                 } else {
    7130           0 :                                     ShowContinueError(state,
    7131           0 :                                                       format("... Outdoor Unit Inlet Air Temperature             = {:.3T}", OutsideDryBulbTemp));
    7132             :                                 }
    7133           0 :                                 ShowContinueError(state,
    7134           0 :                                                   format("... Heating Minimum Outdoor Unit Inlet Temperature = {:.3T}",
    7135           0 :                                                          state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating));
    7136           0 :                                 ShowContinueError(state,
    7137           0 :                                                   format("... Heating Maximum Outdoor Unit Inlet Temperature = {:.3T}",
    7138           0 :                                                          state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating));
    7139           0 :                                 ShowContinueErrorTimeStamp(state, "... Check VRF Heat Pump Min/Max Outdoor Temperature in Heating Mode limits.");
    7140             :                             }
    7141           0 :                             ShowRecurringWarningErrorAtEnd(state,
    7142           0 :                                                            std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7143           0 :                                                                state.dataHVACVarRefFlow->VRF(VRFCond).Name +
    7144             :                                                                "\" -- Exceeded VRF Heat Pump min/max heating temperature limit error continues...",
    7145           0 :                                                            state.dataHVACVarRefFlow->VRF(VRFCond).HeatingMaxTempLimitIndex,
    7146             :                                                            OutsideDryBulbTemp,
    7147             :                                                            OutsideDryBulbTemp);
    7148             :                         }
    7149             :                     }
    7150             :                 } else {
    7151           0 :                     if (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HeatingCoilAvailable)) {
    7152           0 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatingMaxTempLimitIndex == 0) {
    7153           0 :                             ShowWarningMessage(state,
    7154           0 :                                                std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7155           0 :                                                    state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7156           0 :                             ShowContinueError(state,
    7157             :                                               "...InitVRF: VRF Heat Pump Min/Max Operating Temperature in Heating Mode Limits have been exceeded "
    7158             :                                               "and VRF system is disabled.");
    7159           0 :                             if (state.dataHVACVarRefFlow->VRF(VRFCond).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    7160           0 :                                 ShowContinueError(state, format("... Outdoor Unit Inlet Water Temperature           = {:.3T}", OutsideDryBulbTemp));
    7161             :                             } else {
    7162           0 :                                 ShowContinueError(state, format("... Outdoor Unit Inlet Air Temperature             = {:.3T}", OutsideDryBulbTemp));
    7163             :                             }
    7164           0 :                             ShowContinueError(state,
    7165           0 :                                               format("... Heating Minimum Outdoor Unit Inlet Temperature = {:.3T}",
    7166           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating));
    7167           0 :                             ShowContinueError(state,
    7168           0 :                                               format("... Heating Maximum Outdoor Unit Inlet Temperature = {:.3T}",
    7169           0 :                                                      state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating));
    7170           0 :                             ShowContinueErrorTimeStamp(state, "... Check VRF Heat Pump Min/Max Outdoor Temperature in Heating Mode limits.");
    7171             :                         }
    7172           0 :                         ShowRecurringWarningErrorAtEnd(state,
    7173           0 :                                                        std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7174           0 :                                                            state.dataHVACVarRefFlow->VRF(VRFCond).Name +
    7175             :                                                            "\" -- Exceeded VRF Heat Pump min/max heating temperature limit error continues...",
    7176           0 :                                                        state.dataHVACVarRefFlow->VRF(VRFCond).HeatingMaxTempLimitIndex,
    7177             :                                                        OutsideDryBulbTemp,
    7178             :                                                        OutsideDryBulbTemp);
    7179             :                     }
    7180             :                 }
    7181             :             }
    7182             :         }
    7183             : 
    7184             :     } // IF (GetCurrentScheduleValue(state, VRF(VRFCond)%SchedPtr) .EQ. 0.0) THEN
    7185             : 
    7186             :     // initialize terminal unit flow rate
    7187      462628 :     if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) ||
    7188      169321 :         (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
    7189       23524 :          state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList))) {
    7190       85525 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7191       77508 :             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7192       77508 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7193       77508 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7194             :         } else {
    7195        8017 :             if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys)
    7196        6650 :                 state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7197             :         }
    7198      291578 :     } else if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) ||
    7199       28209 :                (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
    7200         237 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList))) {
    7201      117825 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7202      107440 :             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7203      107440 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7204      107440 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7205             :         } else {
    7206       10385 :             if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys)
    7207        8579 :                 state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7208             :         }
    7209             :     } else {
    7210       27956 :         if (state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
    7211       12848 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7212       12497 :                 state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7213       12497 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7214       12497 :                 state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7215             :             } else {
    7216         351 :                 if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys)
    7217         340 :                     state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7218             :             }
    7219       15108 :         } else if (state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7220       15108 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7221       15097 :                 state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7222       15097 :                     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7223       15097 :                 state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7224             :             } else {
    7225          11 :                 if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys)
    7226          11 :                     state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7227             :             }
    7228             :         }
    7229             :     }
    7230             : 
    7231      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists) {
    7232             :         // There is an air terminal mixer
    7233       15580 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType ==
    7234             :             DataHVACGlobals::ATMixer_InletSide) { // if there is an inlet side air terminal mixer
    7235             :             // set the primary air inlet mass flow rate
    7236        9348 :             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerPriNode).MassFlowRate =
    7237        9348 :                 min(state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerPriNode).MassFlowRateMaxAvail,
    7238        9348 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum).MassFlowRate);
    7239             :             // now calculate the the mixer outlet air conditions (and the secondary air inlet flow rate). The mixer outlet flow rate has already
    7240             :             // been set above (it is the "inlet" node flow rate)
    7241       18696 :             SimATMixer(state,
    7242        9348 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerName,
    7243             :                        FirstHVACIteration,
    7244        9348 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerIndex);
    7245             :         }
    7246             :     } else {
    7247      215726 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed)
    7248      425084 :             SimOAMixer(state,
    7249      212542 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7250             :                        FirstHVACIteration,
    7251      212542 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7252             :     }
    7253      231306 :     OnOffAirFlowRatio = 1.0;
    7254             : 
    7255             :     // these flags are used in Subroutine CalcVRF to turn on the correct coil (heating or cooling)
    7256             :     // valid operating modes
    7257             :     // Heat Pump (heat recovery flags are set to FALSE):
    7258             :     // CoolingLoad(VRFCond) - TU can only operate in this mode if heat recovery is not used and there is a cooling load
    7259             :     // HeatingLoad(VRFCond) - TU can only operate in this mode if heat recovery is not used and there is a heating load
    7260             :     // Heat Recovery (heat pump flags are set same as for Heat Pump operation):
    7261             :     // TerminalUnitList(TUListIndex)%HRCoolRequest(IndexToTUInTUList) - TU will operate in this mode if heat recovery is used
    7262             :     // TerminalUnitList(TUListIndex)%HRHeatRequest(IndexToTUInTUList) - TU will operate in this mode if heat recovery is used
    7263             : 
    7264      231306 :     getVRFTUZoneLoad(state, VRFTUNum, QZnReq, LoadToHeatingSP, LoadToCoolingSP, false);
    7265             : 
    7266      231306 :     if (std::abs(QZnReq) < DataHVACGlobals::SmallLoad) QZnReq = 0.0;
    7267             :     // set initial terminal unit operating mode for heat recovery
    7268             :     // operating mode for non-heat recovery set above using CoolingLoad(VRFCond) or HeatingLoad(VRFCond) variables
    7269             :     // first turn off terminal unit
    7270      231306 :     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7271      231306 :     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7272             :     // then set according to LoadToXXXXingSP variables
    7273      231306 :     if (LoadToCoolingSP < -1.0 * DataHVACGlobals::SmallLoad) {
    7274      101687 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) ||
    7275         202 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) { // don't allow heat recovery if control logic dictates unit is off
    7276      101314 :             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7277             :         }
    7278             :     }
    7279      231306 :     if (LoadToHeatingSP > DataHVACGlobals::SmallLoad) {
    7280      190070 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) ||
    7281       94819 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) { // don't allow heat recovery if control logic dictates unit is off
    7282       82764 :             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7283             :         }
    7284             :     }
    7285      231306 :     if (LoadToCoolingSP > 0.0 && LoadToHeatingSP < 0.0) QZnReq = 0.0;
    7286             : 
    7287             :     // next check for overshoot when constant fan mode is used
    7288             :     // check operating load to see if OA will overshoot setpoint temperature when constant fan mode is used
    7289      524812 :     if ((state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode == DataHVACGlobals::ContFanCycCoil ||
    7290      400412 :          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists) &&
    7291      169106 :         !state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isSetPointControlled) {
    7292      165922 :         SetCompFlowRate(state, VRFTUNum, VRFCond, true);
    7293             : 
    7294      165922 :         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7295             :             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7296       58545 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7297             :                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7298             :         } else {
    7299             :             // Algorithm Type: VRF model based on system curve
    7300      107377 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7301             :                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7302             :         }
    7303             : 
    7304             :         // If the Terminal Unit has a net cooling capacity (TempOutput < 0) and
    7305             :         // the zone temp is above the Tstat heating setpoint (QToHeatSetPt < 0)
    7306             :         // see if the terminal unit operation will exceed the setpoint
    7307             :         // 4 tests here to cover all possibilities:
    7308             :         // IF(TempOutput < 0.0d0 .AND. LoadToHeatingSP .LT. 0.0d0)THEN
    7309             :         // ELSE IF(TempOutput .GT. 0.0d0 .AND. LoadToCoolingSP .GT. 0.0d0)THEN
    7310             :         // ELSE IF(TempOutput .GT. 0.0d0 .AND. LoadToCoolingSP .LT. 0.0d0)THEN
    7311             :         // ELSE IF(TempOutput < 0.0d0 .AND. LoadToHeatingSP .GT. 0.0d0)THEN
    7312             :         // END IF
    7313             :         // could compress these to 2 complex IF's but logic inside each would get more complex
    7314      165922 :         if (TempOutput < 0.0 && LoadToHeatingSP < 0.0) {
    7315             :             // If the net cooling capacity overshoots the heating setpoint count as heating load
    7316       18296 :             if (TempOutput < LoadToHeatingSP) {
    7317             :                 // Don't count as heating load unless mode is allowed. Also check for floating zone.
    7318        3244 :                 if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7319        3244 :                         DataHVACGlobals::ThermostatType::SingleCooling &&
    7320        1622 :                     state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7321             :                         DataHVACGlobals::ThermostatType::Uncontrolled) {
    7322        1622 :                     if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7323             :                         // system last operated in cooling mode, change air flows and repeat coil off capacity test
    7324           7 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7325           7 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7326           7 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7327           7 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum).MassFlowRate =
    7328           7 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7329          14 :                             SimOAMixer(state,
    7330           7 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7331             :                                        FirstHVACIteration,
    7332           7 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7333             :                         } else {
    7334           0 :                             state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7335             :                         }
    7336             : 
    7337           7 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7338             :                             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7339           2 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7340             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7341             :                         } else {
    7342             :                             // Algorithm Type: VRF model based on system curve
    7343           5 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7344             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7345             :                         }
    7346             : 
    7347             :                         // if zone temp will overshoot, pass the LoadToHeatingSP as the load to meet
    7348           7 :                         if (TempOutput < LoadToHeatingSP) {
    7349           7 :                             QZnReq = LoadToHeatingSP;
    7350           7 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7351           7 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7352             :                         }
    7353             :                     } else {
    7354             :                         // last mode was heating, zone temp will overshoot heating setpoint, reset QznReq to LoadtoHeatingSP
    7355        1615 :                         QZnReq = LoadToHeatingSP;
    7356        1615 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7357        1615 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7358             :                     }
    7359             :                 }
    7360        7526 :             } else if (TempOutput > LoadToCoolingSP && LoadToCoolingSP < 0.0) {
    7361             :                 //       If the net cooling capacity does not meet the zone cooling load enable cooling
    7362         814 :                 QZnReq = LoadToCoolingSP;
    7363         814 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7364         814 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7365        6712 :             } else if (TempOutput < LoadToCoolingSP && LoadToCoolingSP < 0.0) {
    7366             :                 //       If the net cooling capacity meets the zone cooling load but does not overshoot heating setpoint
    7367         132 :                 QZnReq = 0.0;
    7368         132 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7369         132 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7370             :             }
    7371             :             //     If the terminal unit has a net heating capacity and the zone temp is below the Tstat cooling setpoint
    7372             :             //     see if the terminal unit operation will exceed the setpoint
    7373      156774 :         } else if (TempOutput > 0.0 && LoadToCoolingSP > 0.0) {
    7374             :             //       If the net heating capacity overshoots the cooling setpoint count as cooling load
    7375       38848 :             if (TempOutput > LoadToCoolingSP) {
    7376             :                 //         Don't count as cooling load unless mode is allowed. Also check for floating zone.
    7377       14486 :                 if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7378       14486 :                         DataHVACGlobals::ThermostatType::SingleHeating &&
    7379        7243 :                     state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7380             :                         DataHVACGlobals::ThermostatType::Uncontrolled) {
    7381        7243 :                     if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
    7382          24 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7383          23 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7384          23 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7385          23 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum).MassFlowRate =
    7386          23 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7387          46 :                             SimOAMixer(state,
    7388          23 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7389             :                                        FirstHVACIteration,
    7390          23 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7391             :                         } else {
    7392           1 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum).MassFlowRate =
    7393           1 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7394             :                         }
    7395             : 
    7396          24 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7397             :                             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7398           6 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7399             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7400             :                         } else {
    7401             :                             // Algorithm Type: VRF model based on system curve
    7402          18 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7403             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7404             :                         }
    7405             : 
    7406             :                         // if zone temp will overshoot, pass the LoadToCoolingSP as the load to meet
    7407          24 :                         if (TempOutput > LoadToCoolingSP) {
    7408          24 :                             QZnReq = LoadToCoolingSP;
    7409          24 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7410          24 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7411             :                         }
    7412             :                     } else {
    7413        7219 :                         QZnReq = LoadToCoolingSP;
    7414        7219 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7415        7219 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7416             :                     }
    7417             :                 }
    7418       12181 :             } else if (TempOutput < LoadToHeatingSP) {
    7419             :                 //         Don't count as heating load unless mode is allowed. Also check for floating zone.
    7420       15660 :                 if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7421       15660 :                         DataHVACGlobals::ThermostatType::SingleCooling &&
    7422        7830 :                     state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7423             :                         DataHVACGlobals::ThermostatType::Uncontrolled) {
    7424        7830 :                     if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7425           1 :                         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7426           0 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7427           0 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7428           0 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum).MassFlowRate =
    7429           0 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7430           0 :                             SimOAMixer(state,
    7431           0 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7432             :                                        FirstHVACIteration,
    7433           0 :                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7434             :                         } else {
    7435           1 :                             state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum).MassFlowRate =
    7436           1 :                                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7437             :                         }
    7438             : 
    7439           1 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7440             :                             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7441           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7442             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7443             :                         } else {
    7444             :                             // Algorithm Type: VRF model based on system curve
    7445           1 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7446             :                                 state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7447             :                         }
    7448             : 
    7449             :                         // if zone temp will overshoot, pass the LoadToHeatingSP as the load to meet
    7450           1 :                         if (TempOutput < LoadToHeatingSP) {
    7451           1 :                             QZnReq = LoadToHeatingSP;
    7452           1 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7453           1 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7454             :                         }
    7455             :                     } else {
    7456        7829 :                         QZnReq = LoadToHeatingSP;
    7457        7829 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7458        7829 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7459             :                     }
    7460             :                 }
    7461        4351 :             } else if (TempOutput > LoadToHeatingSP && TempOutput < LoadToCoolingSP) {
    7462             :                 //         If the net capacity does not overshoot either setpoint
    7463        4351 :                 QZnReq = 0.0;
    7464        4351 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7465        4351 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7466             :             } else {
    7467             :                 //         If the net heating capacity meets the zone heating load but does not overshoot cooling setpoint
    7468           0 :                 QZnReq = 0.0;
    7469           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7470           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7471             :             }
    7472             :             //     If the terminal unit has a net heating capacity and the zone temp is above the Tstat cooling setpoint
    7473             :             //     see if the terminal unit operation will exceed the setpoint
    7474      137350 :         } else if (TempOutput > 0.0 && LoadToCoolingSP < 0.0) {
    7475             :             //       If the net heating capacity overshoots the cooling setpoint count as cooling load
    7476             :             //       Don't count as cooling load unless mode is allowed. Also check for floating zone.
    7477      227133 :             if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7478      151422 :                     DataHVACGlobals::ThermostatType::SingleHeating &&
    7479       75711 :                 state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7480             :                     DataHVACGlobals::ThermostatType::Uncontrolled) {
    7481       75711 :                 if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
    7482          15 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7483          10 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7484          10 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7485          10 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum).MassFlowRate =
    7486          10 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7487          20 :                         SimOAMixer(state,
    7488          10 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7489             :                                    FirstHVACIteration,
    7490          10 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7491             :                     } else {
    7492           5 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum).MassFlowRate =
    7493           5 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7494             :                     }
    7495             : 
    7496          15 :                     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7497             :                         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7498           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7499             :                             state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7500             :                     } else {
    7501             :                         // Algorithm Type: VRF model based on system curve
    7502          15 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7503             :                             state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7504             :                     }
    7505             : 
    7506             :                     // if zone temp will overshoot, pass the LoadToCoolingSP as the load to meet
    7507          15 :                     if (TempOutput > LoadToCoolingSP) {
    7508          15 :                         QZnReq = LoadToCoolingSP;
    7509          15 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7510          15 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7511             :                     }
    7512             :                     // last mode was cooling, zone temp will overshoot cooling setpoint, reset QznReq to LoadtoCoolingSP
    7513             :                 } else {
    7514       75696 :                     QZnReq = LoadToCoolingSP;
    7515       75696 :                     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7516       75696 :                     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7517             :                 }
    7518             :             }
    7519             :             // If the Terminal Unit has a net cooling capacity (TempOutput < 0) and
    7520             :             // the zone temp is below the Tstat heating setpoint (QToHeatSetPt > 0)
    7521             :             // see if the terminal unit operation will exceed the setpoint
    7522       61639 :         } else if (TempOutput < 0.0 && LoadToHeatingSP > 0.0) {
    7523             :             // Don't count as heating load unless mode is allowed. Also check for floating zone.
    7524      119104 :             if (state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7525      119104 :                     DataHVACGlobals::ThermostatType::SingleCooling &&
    7526       59552 :                 state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
    7527             :                     DataHVACGlobals::ThermostatType::Uncontrolled) {
    7528       59552 :                 if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7529             :                     // system last operated in cooling mode, change air flows and repeat coil off capacity test
    7530           0 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
    7531           0 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum).MassFlowRate =
    7532           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7533           0 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum).MassFlowRate =
    7534           0 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7535           0 :                         SimOAMixer(state,
    7536           0 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
    7537             :                                    FirstHVACIteration,
    7538           0 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
    7539             :                     } else {
    7540           0 :                         state.dataLoopNodes->Node(InNode).MassFlowRate = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7541             :                     }
    7542             : 
    7543           0 :                     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    7544             :                         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    7545           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    7546             :                             state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7547             :                     } else {
    7548             :                         // Algorithm Type: VRF model based on system curve
    7549           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    7550             :                             state, VRFTUNum, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    7551             :                     }
    7552             : 
    7553             :                     // if zone temp will overshoot, pass the LoadToHeatingSP as the load to meet
    7554           0 :                     if (TempOutput < LoadToHeatingSP) {
    7555           0 :                         QZnReq = LoadToHeatingSP;
    7556           0 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7557           0 :                         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7558             :                     }
    7559             :                 } else {
    7560             :                     // last mode was heating, zone temp will overshoot heating setpoint, reset QznReq to LoadtoHeatingSP
    7561       59552 :                     QZnReq = LoadToHeatingSP;
    7562       59552 :                     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7563       59552 :                     state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7564             :                 }
    7565             :             }
    7566             :         }
    7567             :         // test that the system is active if constant fan logic enables system when thermostat control logic did not
    7568      165922 :         if (!state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && !state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
    7569       14765 :             if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) &&
    7570        7407 :                 OutsideDryBulbTemp >= state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling &&
    7571          49 :                 OutsideDryBulbTemp <= state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling) {
    7572          49 :                 state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
    7573       14622 :             } else if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) &&
    7574        7313 :                        OutsideDryBulbTemp >= state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating &&
    7575           4 :                        OutsideDryBulbTemp <= state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating) {
    7576           4 :                 state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
    7577             :             }
    7578             :         }
    7579             :     } // IF(VRFTU(VRFTUNum)%OpMode == DataHVACGlobals::ContFanCycCoil)THEN
    7580             : 
    7581      231306 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) {
    7582       77022 :         if (OutsideDryBulbTemp < state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeatRecovery ||
    7583       38511 :             OutsideDryBulbTemp > state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeatRecovery) {
    7584       40681 :             if ((any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest) && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) ||
    7585       20344 :                 (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest) && state.dataHVACVarRefFlow->CoolingLoad(VRFCond))) {
    7586           7 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).HRMaxTempLimitIndex == 0) {
    7587           3 :                     ShowWarningMessage(state,
    7588           2 :                                        std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7589           3 :                                            state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7590           1 :                     ShowContinueError(state,
    7591             :                                       "...InitVRF: VRF Heat Pump Min/Max Outdoor Temperature in Heat Recovery Mode Limits have been exceeded and "
    7592             :                                       "VRF heat recovery is disabled.");
    7593           1 :                     ShowContinueError(state, format("... Outdoor Dry-Bulb Temperature                       = {:.3T}", OutsideDryBulbTemp));
    7594           3 :                     ShowContinueError(state,
    7595           3 :                                       format("... Heat Recovery Minimum Outdoor Dry-Bulb Temperature = {:.3T}",
    7596           2 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeatRecovery));
    7597           3 :                     ShowContinueError(state,
    7598           3 :                                       format("... Heat Recovery Maximum Outdoor Dry-Bulb Temperature = {:.3T}",
    7599           2 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeatRecovery));
    7600           1 :                     ShowContinueErrorTimeStamp(state, "... Check VRF Heat Pump Min/Max Outdoor Temperature in Heat Recovery Mode limits.");
    7601           1 :                     ShowContinueError(state, "...the system will operate in heat pump mode when applicable.");
    7602             :                 }
    7603          28 :                 ShowRecurringWarningErrorAtEnd(state,
    7604          14 :                                                std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7605          21 :                                                    state.dataHVACVarRefFlow->VRF(VRFCond).Name +
    7606             :                                                    "\" -- Exceeded VRF Heat Recovery min/max outdoor temperature limit error continues...",
    7607           7 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).HRMaxTempLimitIndex,
    7608             :                                                OutsideDryBulbTemp,
    7609             :                                                OutsideDryBulbTemp);
    7610             :             }
    7611             :             // Allow heat pump mode to operate if within limits
    7612       40674 :             if (OutsideDryBulbTemp < state.dataHVACVarRefFlow->VRF(VRFCond).MinOATCooling ||
    7613       20337 :                 OutsideDryBulbTemp > state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATCooling) {
    7614             :                 // Disable cooling mode only, heating model will still be allowed
    7615           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7616             :             }
    7617       40674 :             if (OutsideDryBulbTemp < state.dataHVACVarRefFlow->VRF(VRFCond).MinOATHeating ||
    7618       20337 :                 OutsideDryBulbTemp > state.dataHVACVarRefFlow->VRF(VRFCond).MaxOATHeating) {
    7619             :                 // Disable heating mode only, cooling model will still be allowed
    7620       20337 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7621             :             }
    7622             :         }
    7623             :     } else {
    7624      192795 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest = false;
    7625      192795 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest = false;
    7626             :     }
    7627             : 
    7628             :     // Override operating mode when using EMS
    7629             :     // this logic seems suspect, uses a "just run it on" mentality. Nee to test using EMS.
    7630      231306 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).EMSOverrideHPOperatingMode) {
    7631           0 :         if (state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode == 0.0) { // Off
    7632           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
    7633           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
    7634           0 :             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7635           0 :             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7636           0 :         } else if (state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode == 1.0) { // Cooling
    7637           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
    7638           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
    7639           0 :             QZnReq = LoadToCoolingSP;
    7640           0 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) {
    7641           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = false;
    7642           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = true;
    7643             :             }
    7644           0 :         } else if (state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode == 2.0) { // Heating
    7645           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
    7646           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
    7647           0 :             QZnReq = LoadToHeatingSP;
    7648           0 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) {
    7649           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList) = true;
    7650           0 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList) = false;
    7651             :             }
    7652             :         } else {
    7653           0 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HPOperatingModeErrorIndex == 0) {
    7654           0 :                 ShowWarningMessage(state,
    7655           0 :                                    std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7656           0 :                                        state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\".");
    7657           0 :                 ShowContinueError(
    7658             :                     state,
    7659           0 :                     format("...InitVRF: Illegal HP operating mode = {:.0T}", state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode));
    7660           0 :                 ShowContinueError(state, "...InitVRF: VRF HP operating mode will not be controlled by EMS.");
    7661             :             }
    7662           0 :             ShowRecurringWarningErrorAtEnd(state,
    7663           0 :                                            std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + " \"" +
    7664           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).Name + "\" -- Illegal HP operating mode error continues...",
    7665           0 :                                            state.dataHVACVarRefFlow->VRF(VRFCond).HPOperatingModeErrorIndex,
    7666           0 :                                            state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode,
    7667           0 :                                            state.dataHVACVarRefFlow->VRF(VRFCond).EMSValueForHPOperatingMode);
    7668             :         }
    7669             :     }
    7670             : 
    7671             :     // set the TU flow rate. Check for heat recovery operation first, these will be FALSE if HR is not used.
    7672      231306 :     if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList)) {
    7673       22247 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7674       22247 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7675       22247 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7676       22247 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7677       22247 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7678       22247 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7679      209059 :     } else if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList)) {
    7680       14449 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7681       14449 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7682       14449 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7683       14449 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7684       14449 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7685       14449 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7686      194610 :     } else if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && QZnReq != 0.0) {
    7687       86329 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7688       86329 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7689       86329 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7690       86329 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7691       86329 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7692       86329 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7693      108281 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && QZnReq != 0.0) {
    7694       69448 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7695       69448 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7696       69448 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7697       69448 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7698       69448 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7699       69448 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7700             :     } else {
    7701       38833 :         if (state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
    7702       22087 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7703       22087 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7704       22087 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7705       22087 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7706       22087 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7707             :         }
    7708       38833 :         if (state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7709       16746 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7710       16746 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7711       16746 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7712       16746 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7713       16746 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7714             :         }
    7715       38833 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7716             :     }
    7717             : 
    7718      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode == DataHVACGlobals::CycFanCycCoil) {
    7719       62200 :         state.dataHVACVarRefFlow->CompOffMassFlow = 0.0;
    7720       62200 :         state.dataHVACVarRefFlow->OACompOffMassFlow = 0.0;
    7721       62200 :         state.dataHVACVarRefFlow->CompOffFlowRatio = 0.0;
    7722             :     }
    7723             : 
    7724      231306 :     SetAverageAirFlow(state, VRFTUNum, 0.0, OnOffAirFlowRatio);
    7725             : 
    7726      231306 :     if (ErrorsFound) {
    7727           0 :         ShowFatalError(
    7728             :             state,
    7729           0 :             std::string{RoutineName} +
    7730             :                 ": Errors found in getting ZoneHVAC:TerminalUnit:VariableRefrigerantFlow system input. Preceding condition(s) causes termination.");
    7731             :     }
    7732      231306 : }
    7733             : 
    7734      331764 : void SetCompFlowRate(EnergyPlusData &state, int const VRFTUNum, int const VRFCond, Optional_bool_const UseCurrentMode)
    7735             : {
    7736             : 
    7737             :     // SUBROUTINE INFORMATION:
    7738             :     //       AUTHOR         Richard Raustad, FSEC
    7739             :     //       DATE WRITTEN   June 2011
    7740             :     //       MODIFIED       na
    7741             :     //       RE-ENGINEERED  na
    7742             : 
    7743             :     // PURPOSE OF THIS SUBROUTINE:
    7744             :     // This subroutine is for calling VRF terminal units during Init to initialize flow rate
    7745             :     // while looping through all terminal units connected to a specific condenser.
    7746             :     // This allows polling of capacities for all terminal units.
    7747             :     // Since the heat pump can only heat or cool, a single operating mode is chosen for each condenser.
    7748             : 
    7749             :     // METHODOLOGY EMPLOYED:
    7750             :     // Initializes flow rates for a specific terminal unit.
    7751             : 
    7752             :     bool CurrentMode;      // - specifies whether current or previous operating mode is used
    7753             :     int IndexToTUInTUList; // - index to TU in specific list for this VRF system
    7754             :     int TUListIndex;       // index to TU list for this VRF system
    7755             : 
    7756      331764 :     IndexToTUInTUList = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList;
    7757      331764 :     TUListIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex;
    7758      331764 :     if (present(UseCurrentMode)) {
    7759      165922 :         CurrentMode = UseCurrentMode;
    7760             :     } else {
    7761      165842 :         CurrentMode = false;
    7762             :     }
    7763             : 
    7764             :     // uses current operating mode to set flow rate (after mode is set)
    7765      331764 :     if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList)) {
    7766       97573 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7767       97573 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7768       97573 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7769       97573 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7770       97573 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7771       97573 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7772      234191 :     } else if (state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList)) {
    7773       82136 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7774       82136 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7775       82136 :         state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7776       82136 :         state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7777       82136 :         state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7778       82136 :         state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7779      152055 :     } else if (CurrentMode) { // uses current operating mode to set flow rate (after mode is set)
    7780       19725 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
    7781       10089 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7782       10089 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7783       10089 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7784       10089 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7785       10089 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7786       10089 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7787        9636 :         } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
    7788        2278 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7789        2278 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7790        2278 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7791        2278 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7792        2278 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7793        2278 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7794        7358 :         } else if (state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) { // if NOT cooling or heating then use last mode
    7795        5923 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7796        5923 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7797        5923 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7798        5923 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7799        5923 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7800        5923 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7801        1435 :         } else if (state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) { // if NOT cooling or heating then use last mode
    7802        1435 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7803        1435 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7804        1435 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7805        1435 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7806        1435 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7807        1435 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7808             :         } else { // should not happen so just set to cooling flow rate
    7809           0 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7810           0 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7811           0 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7812           0 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7813           0 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7814           0 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7815             :         }
    7816             :     } else { // uses previous operating mode to set flow rate (used for looping through each TU in Init before mode is set)
    7817      132330 :         if (state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
    7818       73112 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7819       73112 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7820       73112 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7821       73112 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7822       73112 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7823       73112 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7824       59218 :         } else if (state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
    7825       59218 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirMassFlow;
    7826       59218 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirMassFlow;
    7827       59218 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirMassFlow;
    7828       59218 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7829       59218 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingSpeedRatio;
    7830       59218 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoHeatingSpeedRatio;
    7831             :         } else { // should not happen so just set to cooling flow rate
    7832           0 :             state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirMassFlow;
    7833           0 :             state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirMassFlow;
    7834           0 :             state.dataHVACVarRefFlow->OACompOnMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirMassFlow;
    7835           0 :             state.dataHVACVarRefFlow->OACompOffMassFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirMassFlow;
    7836           0 :             state.dataHVACVarRefFlow->CompOnFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingSpeedRatio;
    7837           0 :             state.dataHVACVarRefFlow->CompOffFlowRatio = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolingSpeedRatio;
    7838             :         }
    7839             :     }
    7840             : 
    7841      331764 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode == DataHVACGlobals::CycFanCycCoil) {
    7842           0 :         state.dataHVACVarRefFlow->CompOffMassFlow = 0.0;
    7843           0 :         state.dataHVACVarRefFlow->OACompOffMassFlow = 0.0;
    7844           0 :         state.dataHVACVarRefFlow->CompOffFlowRatio = 0.0;
    7845             :     }
    7846      331764 : }
    7847             : 
    7848          56 : void SizeVRF(EnergyPlusData &state, int const VRFTUNum)
    7849             : {
    7850             : 
    7851             :     // SUBROUTINE INFORMATION:
    7852             :     //       AUTHOR         Richard Raustad, FSEC
    7853             :     //       DATE WRITTEN   August 2010
    7854             :     //       MODIFIED       August 2013 Daeho Kang, add component sizing table entries
    7855             :     //                      B Nigusse, FSEC, added scalable sizing
    7856             :     //       RE-ENGINEERED  na
    7857             : 
    7858             :     // PURPOSE OF THIS SUBROUTINE:
    7859             :     // This subroutine is for sizing VRF Components for which inputs have not been
    7860             :     // specified in the input.
    7861             : 
    7862             :     // METHODOLOGY EMPLOYED:
    7863             :     // Obtains flow rates from the zone or system sizing arrays.
    7864             : 
    7865             :     using namespace DataSizing;
    7866             :     using Curve::CurveValue;
    7867          56 :     auto &GetDXCoilCap(DXCoils::GetCoilCapacityByIndexType);
    7868             :     using DataHVACGlobals::CoolingAirflowSizing;
    7869             :     using DataHVACGlobals::CoolingCapacitySizing;
    7870             :     using DataHVACGlobals::HeatingAirflowSizing;
    7871             :     using DataHVACGlobals::HeatingCapacitySizing;
    7872             : 
    7873             :     using PlantUtilities::RegisterPlantCompDesignFlow;
    7874             : 
    7875             :     static constexpr std::string_view RoutineName("SizeVRF: "); // include trailing blank space
    7876             : 
    7877          56 :     auto &CheckVRFCombinationRatio = state.dataHVACVarRefFlow->CheckVRFCombinationRatio;
    7878             :     bool FoundAll;                                                       // temporary variable used to check all terminal units
    7879             :     bool errFlag;                                                        // temporary variable used for error checking
    7880             :     Real64 TUCoolingCapacity;                                            // total terminal unit cooling capacity
    7881             :     Real64 TUHeatingCapacity;                                            // total terminal unit heating capacity
    7882             :     int VRFCond;                                                         // index to VRF condenser
    7883             :     int TUListNum;                                                       // index to terminal unit list
    7884             :     int TUIndex;                                                         // index to terminal unit
    7885             :     int NumTU;                                                           // DO Loop index counter
    7886          56 :     auto &MyOneTimeEIOFlag = state.dataHVACVarRefFlow->MyOneTimeEIOFlag; // eio header flag reporting
    7887             :     Real64 OnOffAirFlowRat;                                              // temporary variable used when sizing coils
    7888             :     Real64 DXCoilCap;                                                    // capacity of DX cooling coil (W)
    7889             :     bool IsAutoSize;                                                     // Indicator to autosize
    7890             :     Real64 MaxCoolAirVolFlowDes;                                         // Autosized supply air during cooling for reporting
    7891             :     Real64 MaxCoolAirVolFlowUser;                                        // Hardsized supply air during cooling for reporting
    7892             :     Real64 MaxHeatAirVolFlowDes;                                         // Autosized supply air during heating for reporting
    7893             :     Real64 MaxHeatAirVolFlowUser;                                        // Hardsized supply air during heating for reporting
    7894             :     Real64 MaxNoCoolAirVolFlowDes;                                       // Autosized supply air flow when no cooling is needed for reporting
    7895             :     Real64 MaxNoCoolAirVolFlowUser;                                      // Hardsized supply air flow when no cooling is needed for reporting
    7896             :     Real64 MaxNoHeatAirVolFlowDes;                                       // Autosized supply air flow when no heating is needed for reporting
    7897             :     Real64 MaxNoHeatAirVolFlowUser;                                      // Hardsized supply air flow when no heating is needed for reporting
    7898             :     Real64 CoolOutAirVolFlowDes;                                         // Autosized outdoor air flow during cooling for reporting
    7899             :     Real64 CoolOutAirVolFlowUser;                                        // Hardsized outdoor air flow during cooling for reporting
    7900             :     Real64 HeatOutAirVolFlowDes;                                         // Autosized outdoor air flow during heating for reporting
    7901             :     Real64 HeatOutAirVolFlowUser;                                        // Hardsized outdoor air flow during heating for reporting
    7902             :     Real64 NoCoolHeatOutAirVolFlowDes;                                   // Autosized outdoor air when unconditioned for reporting
    7903             :     Real64 NoCoolHeatOutAirVolFlowUser;                                  // Hardsized outdoor air when unconditioned for reporting
    7904             :     Real64 CoolingCapacityDes;                                           // Autosized cooling capacity for reporting
    7905             :     Real64 CoolingCapacityUser;                                          // Hardsized cooling capacity for reporting
    7906             :     Real64 HeatingCapacityDes;                                           // Autosized heating capacity for reporting
    7907             :     Real64 HeatingCapacityUser;                                          // Hardsized heating capacity for reporting
    7908             :     Real64 DefrostCapacityDes;                                           // Autosized defrost heater capacity for reporting
    7909             :     Real64 DefrostCapacityUser;                                          // Hardsized defrost heater capacity for reporting
    7910             :     Real64 EvapCondAirVolFlowRateDes;                                    // Autosized evaporative condenser flow for reporting
    7911             :     Real64 EvapCondAirVolFlowRateUser;                                   // Hardsized evaporative condenser flow for reporting
    7912             :     Real64 EvapCondPumpPowerDes;                                         // Autosized evaporative condenser pump power for reporting
    7913             :     Real64 EvapCondPumpPowerUser;                                        // Hardsized evaporative condenser pump power for reporting
    7914             : 
    7915         112 :     std::string CompName;     // component name
    7916         112 :     std::string CompType;     // component type
    7917         112 :     std::string SizingString; // input field sizing description (e.g., Nominal Capacity)
    7918             :     Real64 TempSize;          // autosized value of coil input field
    7919          56 :     int FieldNum = 2;         // IDD numeric field number where input field description is found
    7920             :     int SizingMethod;       // Integer representation of sizing method name (e.g., CoolingAirflowSizing, HeatingAirflowSizing, CoolingCapacitySizing,
    7921             :                             // HeatingCapacitySizing, etc.)
    7922          56 :     bool PrintFlag = true;  // TRUE when sizing information is reported in the eio file
    7923             :     int zoneHVACIndex;      // index of zoneHVAC equipment sizing specification
    7924          56 :     int SAFMethod(0);       // supply air flow rate sizing method (SupplyAirFlowRate, FlowPerFloorArea, FractionOfAutosizedCoolingAirflow,
    7925             :                             // FractionOfAutosizedHeatingAirflow ...)
    7926          56 :     int CapSizingMethod(0); // capacity sizing methods (HeatingDesignCapacity, CapacityPerFloorArea, FractionOfAutosizedCoolingCapacity, and
    7927             :                             // FractionOfAutosizedHeatingCapacity )
    7928             : 
    7929          56 :     auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    7930             : 
    7931          56 :     DataSizing::ZoneEqSizingData *select_EqSizing(nullptr);
    7932             : 
    7933             :     // sweep specific data into one pointer to avoid if statements throughout this subroutine
    7934          56 :     if (state.dataSize->CurOASysNum > 0) {
    7935           1 :         select_EqSizing = &state.dataSize->OASysEqSizing(state.dataSize->CurOASysNum);
    7936          55 :     } else if (state.dataSize->CurSysNum > 0) {
    7937           1 :         select_EqSizing = &state.dataSize->UnitarySysEqSizing(state.dataSize->CurSysNum);
    7938          54 :     } else if (state.dataSize->CurZoneEqNum > 0) {
    7939          54 :         select_EqSizing = &ZoneEqSizing(state.dataSize->CurZoneEqNum);
    7940          54 :         state.dataSize->ZoneEqUnitarySys = true;
    7941             :     } else {
    7942           0 :         assert(false);
    7943             :     }
    7944             :     // Object Data, points to specific array
    7945          56 :     DataSizing::ZoneEqSizingData &EqSizing(*select_EqSizing);
    7946             : 
    7947             :     // can't hurt to initialize these going in, probably redundant
    7948          56 :     EqSizing.AirFlow = false;
    7949          56 :     EqSizing.CoolingAirFlow = false;
    7950          56 :     EqSizing.HeatingAirFlow = false;
    7951          56 :     EqSizing.AirVolFlow = 0.0;
    7952          56 :     EqSizing.CoolingAirVolFlow = 0.0;
    7953          56 :     EqSizing.HeatingAirVolFlow = 0.0;
    7954          56 :     EqSizing.Capacity = false;
    7955          56 :     EqSizing.CoolingCapacity = false;
    7956          56 :     EqSizing.HeatingCapacity = false;
    7957          56 :     EqSizing.DesCoolingLoad = 0.0;
    7958          56 :     EqSizing.DesHeatingLoad = 0.0;
    7959          56 :     EqSizing.OAVolFlow = 0.0;
    7960             : 
    7961          56 :     VRFCond = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
    7962          56 :     IsAutoSize = false;
    7963          56 :     MaxCoolAirVolFlowDes = 0.0;
    7964          56 :     MaxCoolAirVolFlowUser = 0.0;
    7965          56 :     MaxHeatAirVolFlowDes = 0.0;
    7966          56 :     MaxHeatAirVolFlowUser = 0.0;
    7967          56 :     MaxNoCoolAirVolFlowDes = 0.0;
    7968          56 :     MaxNoCoolAirVolFlowUser = 0.0;
    7969          56 :     MaxNoHeatAirVolFlowDes = 0.0;
    7970          56 :     MaxNoHeatAirVolFlowUser = 0.0;
    7971          56 :     CoolOutAirVolFlowDes = 0.0;
    7972          56 :     CoolOutAirVolFlowUser = 0.0;
    7973          56 :     HeatOutAirVolFlowDes = 0.0;
    7974          56 :     HeatOutAirVolFlowUser = 0.0;
    7975          56 :     NoCoolHeatOutAirVolFlowDes = 0.0;
    7976          56 :     NoCoolHeatOutAirVolFlowUser = 0.0;
    7977          56 :     CoolingCapacityDes = 0.0;
    7978          56 :     CoolingCapacityUser = 0.0;
    7979          56 :     HeatingCapacityDes = 0.0;
    7980          56 :     HeatingCapacityUser = 0.0;
    7981          56 :     DefrostCapacityDes = 0.0;
    7982          56 :     DefrostCapacityUser = 0.0;
    7983          56 :     EvapCondAirVolFlowRateDes = 0.0;
    7984          56 :     EvapCondAirVolFlowRateUser = 0.0;
    7985          56 :     EvapCondPumpPowerDes = 0.0;
    7986          56 :     EvapCondPumpPowerUser = 0.0;
    7987             : 
    7988          56 :     state.dataSize->DataScalableSizingON = false;
    7989          56 :     state.dataSize->DataScalableCapSizingON = false;
    7990          56 :     state.dataSize->DataFracOfAutosizedCoolingAirflow = 1.0;
    7991          56 :     state.dataSize->DataFracOfAutosizedHeatingAirflow = 1.0;
    7992          56 :     state.dataSize->DataFracOfAutosizedCoolingCapacity = 1.0;
    7993          56 :     state.dataSize->DataFracOfAutosizedHeatingCapacity = 1.0;
    7994          56 :     state.dataSize->SuppHeatCap = 0.0;
    7995             : 
    7996          56 :     if (state.dataHVACVarRefFlow->MyOneTimeSizeFlag) {
    7997             :         // initialize the environment and sizing flags
    7998          11 :         CheckVRFCombinationRatio.dimension(state.dataHVACVarRefFlow->NumVRFCond, true);
    7999          11 :         state.dataHVACVarRefFlow->MyOneTimeSizeFlag = false;
    8000             :     }
    8001             : 
    8002          56 :     CompType = DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num);
    8003          56 :     CompName = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name;
    8004          56 :     state.dataSize->DataZoneNumber = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum;
    8005             : 
    8006          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    8007          15 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone) {
    8008          14 :             state.dataSize->DataFanEnumType = DataAirSystems::ObjectVectorOOFanSystemModel;
    8009          14 :             state.dataSize->DataFanIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    8010          14 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::BlowThru) {
    8011           0 :                 state.dataSize->DataFanPlacement = DataSizing::ZoneFanPlacement::BlowThru;
    8012          14 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::DrawThru) {
    8013          14 :                 state.dataSize->DataFanPlacement = DataSizing::ZoneFanPlacement::DrawThru;
    8014             :             }
    8015           1 :         } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInAirLoop) {
    8016           1 :             state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanModelType =
    8017             :                 DataAirSystems::ObjectVectorOOFanSystemModel;
    8018           1 :             state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanVecIndex =
    8019           1 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    8020           1 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::BlowThru) {
    8021           0 :                 state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanLocation =
    8022             :                     DataAirSystems::FanPlacement::BlowThru;
    8023           1 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::DrawThru) {
    8024           1 :                 state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanLocation =
    8025             :                     DataAirSystems::FanPlacement::DrawThru;
    8026             :             }
    8027             :         }
    8028          41 :     } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex > 0) {
    8029          40 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone) {
    8030          40 :             state.dataSize->DataFanEnumType = DataAirSystems::StructArrayLegacyFanModels;
    8031          40 :             state.dataSize->DataFanIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    8032          40 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::BlowThru) {
    8033           5 :                 state.dataSize->DataFanPlacement = DataSizing::ZoneFanPlacement::BlowThru;
    8034          35 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::DrawThru) {
    8035          35 :                 state.dataSize->DataFanPlacement = DataSizing::ZoneFanPlacement::DrawThru;
    8036             :             }
    8037           0 :         } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInAirLoop) {
    8038           0 :             state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanModelType =
    8039             :                 DataAirSystems::StructArrayLegacyFanModels;
    8040           0 :             state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanVecIndex =
    8041           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex;
    8042           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::BlowThru) {
    8043           0 :                 state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanLocation =
    8044             :                     DataAirSystems::FanPlacement::BlowThru;
    8045           0 :             } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::DrawThru) {
    8046           0 :                 state.dataAirSystemsData->PrimaryAirSystems(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).airLoopNum).supFanLocation =
    8047             :                     DataAirSystems::FanPlacement::DrawThru;
    8048             :             }
    8049             :         }
    8050             :     }
    8051             : 
    8052          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HVACSizingIndex > 0) {
    8053             :         // initialize OA flow for sizing other inputs (e.g., capacity)
    8054           0 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow == AutoSize) {
    8055           0 :             EqSizing.OAVolFlow = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA;
    8056             :         } else {
    8057           0 :             EqSizing.OAVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow;
    8058             :         }
    8059           0 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow != AutoSize) {
    8060           0 :             EqSizing.OAVolFlow = max(EqSizing.OAVolFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow);
    8061             :         }
    8062           0 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists &&
    8063           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone) { // set up ATMixer conditions for scalable capacity sizing
    8064           0 :             EqSizing.OAVolFlow = 0.0;                             // Equipment OA flow should always be 0 when ATMixer is used
    8065           0 :             SingleDuct::setATMixerSizingProperties(state,
    8066           0 :                                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerIndex,
    8067           0 :                                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum,
    8068           0 :                                                    state.dataSize->CurZoneEqNum);
    8069             :         }
    8070             : 
    8071           0 :         zoneHVACIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HVACSizingIndex;
    8072             : 
    8073           0 :         SizingMethod = CoolingAirflowSizing;
    8074           0 :         PrintFlag = true;
    8075           0 :         bool errorsFound = false;
    8076           0 :         SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingSAFMethod;
    8077           0 :         EqSizing.SizingMethod(SizingMethod) = SAFMethod;
    8078           0 :         if (SAFMethod == SupplyAirFlowRate || SAFMethod == FlowPerFloorArea || SAFMethod == FractionOfAutosizedCoolingAirflow) {
    8079           0 :             if (SAFMethod == SupplyAirFlowRate) {
    8080           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow > 0.0) {
    8081           0 :                     EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow;
    8082           0 :                     EqSizing.SystemAirFlow = true;
    8083             :                 }
    8084           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow;
    8085           0 :             } else if (SAFMethod == FlowPerFloorArea) {
    8086           0 :                 EqSizing.SystemAirFlow = true;
    8087           0 :                 EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow *
    8088           0 :                                       state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8089           0 :                 TempSize = ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow;
    8090           0 :                 state.dataSize->DataScalableSizingON = true;
    8091           0 :             } else if (SAFMethod == FractionOfAutosizedCoolingAirflow) {
    8092           0 :                 state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow;
    8093           0 :                 TempSize = AutoSize;
    8094           0 :                 state.dataSize->DataScalableSizingON = true;
    8095             :             } else {
    8096           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow;
    8097             :             }
    8098             : 
    8099           0 :             CoolingAirFlowSizer sizingCoolingAirFlow;
    8100           0 :             std::string stringOverride = "Cooling Supply Air Flow Rate [m3/s]";
    8101           0 :             if (state.dataGlobal->isEpJSON) stringOverride = "cooling_supply_air_flow_rate [m3/s]";
    8102           0 :             sizingCoolingAirFlow.overrideSizingString(stringOverride);
    8103             :             // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8104           0 :             sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8105           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8106             : 
    8107           0 :         } else if (SAFMethod == FlowPerCoolingCapacity) {
    8108           0 :             SizingMethod = CoolingCapacitySizing;
    8109           0 :             TempSize = AutoSize;
    8110           0 :             PrintFlag = false;
    8111           0 :             state.dataSize->DataScalableSizingON = true;
    8112           0 :             state.dataSize->DataFlowUsedForSizing = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow;
    8113           0 :             if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod == FractionOfAutosizedCoolingCapacity) {
    8114           0 :                 state.dataSize->DataFracOfAutosizedCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity;
    8115             :             }
    8116           0 :             CoolingCapacitySizer sizerCoolingCapacity;
    8117           0 :             sizerCoolingCapacity.overrideSizingString(SizingString);
    8118           0 :             sizerCoolingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8119           0 :             state.dataSize->DataAutosizedCoolingCapacity = sizerCoolingCapacity.size(state, TempSize, errorsFound);
    8120           0 :             state.dataSize->DataFlowPerCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow;
    8121           0 :             PrintFlag = true;
    8122           0 :             TempSize = AutoSize;
    8123           0 :             CoolingAirFlowSizer sizingCoolingAirFlow;
    8124           0 :             std::string stringOverride = "Cooling Supply Air Flow Rate [m3/s]";
    8125           0 :             if (state.dataGlobal->isEpJSON) stringOverride = "cooling_supply_air_flow_rate [m3/s]";
    8126           0 :             sizingCoolingAirFlow.overrideSizingString(stringOverride);
    8127             :             // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8128           0 :             sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8129           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8130             :         }
    8131             : 
    8132           0 :         SizingMethod = HeatingAirflowSizing;
    8133           0 :         FieldNum = 3; // N3, \field Supply Air Flow Rate During Heating Operation
    8134           0 :         PrintFlag = true;
    8135           0 :         SizingString = state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames(FieldNum) + " [m3/s]";
    8136           0 :         SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).HeatingSAFMethod;
    8137           0 :         EqSizing.SizingMethod(SizingMethod) = SAFMethod;
    8138           0 :         if (SAFMethod == SupplyAirFlowRate || SAFMethod == FlowPerFloorArea || SAFMethod == FractionOfAutosizedHeatingAirflow) {
    8139           0 :             if (SAFMethod == SupplyAirFlowRate) {
    8140           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow > 0.0) {
    8141           0 :                     EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow;
    8142           0 :                     EqSizing.SystemAirFlow = true;
    8143             :                 }
    8144           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow;
    8145           0 :             } else if (SAFMethod == FlowPerFloorArea) {
    8146           0 :                 EqSizing.SystemAirFlow = true;
    8147           0 :                 EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow *
    8148           0 :                                       state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8149           0 :                 TempSize = ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow;
    8150           0 :                 state.dataSize->DataScalableSizingON = true;
    8151           0 :             } else if (SAFMethod == FractionOfAutosizedHeatingAirflow) {
    8152           0 :                 state.dataSize->DataFracOfAutosizedHeatingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow;
    8153           0 :                 TempSize = AutoSize;
    8154           0 :                 state.dataSize->DataScalableSizingON = true;
    8155             :             } else {
    8156           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow;
    8157             :             }
    8158           0 :             bool errorsFound = false;
    8159           0 :             HeatingAirFlowSizer sizingHeatingAirFlow;
    8160           0 :             sizingHeatingAirFlow.overrideSizingString(SizingString);
    8161             :             // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8162           0 :             sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8163           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    8164           0 :         } else if (SAFMethod == FlowPerHeatingCapacity) {
    8165           0 :             SizingMethod = HeatingCapacitySizing;
    8166           0 :             TempSize = AutoSize;
    8167           0 :             PrintFlag = false;
    8168           0 :             state.dataSize->DataScalableSizingON = true;
    8169           0 :             state.dataSize->DataFlowUsedForSizing = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatVolFlow;
    8170           0 :             if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).HeatingCapMethod == FractionOfAutosizedHeatingCapacity) {
    8171           0 :                 state.dataSize->DataFracOfAutosizedHeatingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity;
    8172             :             }
    8173           0 :             bool errorsFound = false;
    8174           0 :             HeatingCapacitySizer sizerHeatingCapacity;
    8175           0 :             sizerHeatingCapacity.overrideSizingString(SizingString);
    8176           0 :             sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8177           0 :             state.dataSize->DataAutosizedHeatingCapacity = sizerHeatingCapacity.size(state, TempSize, errorsFound);
    8178           0 :             state.dataSize->DataFlowPerHeatingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxHeatAirVolFlow;
    8179           0 :             SizingMethod = HeatingAirflowSizing;
    8180           0 :             PrintFlag = true;
    8181           0 :             TempSize = AutoSize;
    8182           0 :             errorsFound = false;
    8183           0 :             HeatingAirFlowSizer sizingHeatingAirFlow;
    8184           0 :             sizingHeatingAirFlow.overrideSizingString(SizingString);
    8185             :             // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8186           0 :             sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8187           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    8188             :         }
    8189             : 
    8190           0 :         PrintFlag = true;
    8191           0 :         SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).NoCoolHeatSAFMethod;
    8192           0 :         EqSizing.SizingMethod(SizingMethod) = SAFMethod;
    8193           0 :         if ((SAFMethod == SupplyAirFlowRate) || (SAFMethod == FlowPerFloorArea) || (SAFMethod == FractionOfAutosizedHeatingAirflow) ||
    8194             :             (SAFMethod == FractionOfAutosizedCoolingAirflow)) {
    8195           0 :             if (SAFMethod == SupplyAirFlowRate) {
    8196           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow > 0.0) {
    8197           0 :                     EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8198           0 :                     EqSizing.SystemAirFlow = true;
    8199             :                 }
    8200           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8201           0 :             } else if (SAFMethod == FlowPerFloorArea) {
    8202           0 :                 EqSizing.SystemAirFlow = true;
    8203           0 :                 EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow *
    8204           0 :                                       state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8205           0 :                 TempSize = ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow;
    8206           0 :                 state.dataSize->DataScalableSizingON = true;
    8207           0 :             } else if (SAFMethod == FractionOfAutosizedCoolingAirflow) {
    8208           0 :                 state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8209           0 :                 state.dataSize->DataFracOfAutosizedHeatingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8210           0 :                 TempSize = AutoSize;
    8211           0 :                 state.dataSize->DataScalableSizingON = true;
    8212           0 :             } else if (SAFMethod == FractionOfAutosizedHeatingAirflow) {
    8213           0 :                 state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8214           0 :                 state.dataSize->DataFracOfAutosizedHeatingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8215           0 :                 TempSize = AutoSize;
    8216           0 :                 state.dataSize->DataScalableSizingON = true;
    8217             :             } else {
    8218           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8219             :             }
    8220           0 :             CoolingAirFlowSizer sizingCoolingAirFlow;
    8221           0 :             std::string stringOverride = "No Cooling Supply Air Flow Rate [m3/s]";
    8222           0 :             if (state.dataGlobal->isEpJSON) stringOverride = "no_cooling_supply_air_flow_rate [m3/s]";
    8223           0 :             sizingCoolingAirFlow.overrideSizingString(stringOverride);
    8224             :             // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8225           0 :             sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8226           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8227             :         }
    8228             : 
    8229           0 :         SizingMethod = HeatingAirflowSizing;
    8230           0 :         FieldNum = 4; // N4, \field Supply Air Flow Rate When No Heating is Needed
    8231           0 :         PrintFlag = true;
    8232           0 :         SizingString = state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames(FieldNum) + " [m3/s]";
    8233           0 :         SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).NoCoolHeatSAFMethod;
    8234           0 :         EqSizing.SizingMethod(SizingMethod) = SAFMethod;
    8235           0 :         if ((SAFMethod == SupplyAirFlowRate) || (SAFMethod == FlowPerFloorArea) || (SAFMethod == FractionOfAutosizedHeatingAirflow) ||
    8236             :             (SAFMethod == FractionOfAutosizedCoolingAirflow)) {
    8237           0 :             if (SAFMethod == SupplyAirFlowRate) {
    8238           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow > 0.0) {
    8239           0 :                     EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8240           0 :                     EqSizing.SystemAirFlow = true;
    8241             :                 }
    8242           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8243           0 :             } else if (SAFMethod == FlowPerFloorArea) {
    8244           0 :                 EqSizing.SystemAirFlow = true;
    8245           0 :                 EqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow *
    8246           0 :                                       state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8247           0 :                 TempSize = ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow;
    8248           0 :                 state.dataSize->DataScalableSizingON = true;
    8249           0 :             } else if (SAFMethod == FractionOfAutosizedHeatingAirflow) {
    8250           0 :                 state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8251           0 :                 state.dataSize->DataFracOfAutosizedHeatingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8252           0 :                 TempSize = AutoSize;
    8253           0 :                 state.dataSize->DataScalableSizingON = true;
    8254           0 :             } else if (SAFMethod == FractionOfAutosizedCoolingAirflow) {
    8255           0 :                 state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8256           0 :                 state.dataSize->DataFracOfAutosizedHeatingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8257           0 :                 TempSize = AutoSize;
    8258           0 :                 state.dataSize->DataScalableSizingON = true;
    8259             :             } else {
    8260           0 :                 TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxNoCoolHeatAirVolFlow;
    8261             :             }
    8262           0 :             bool errorsFound = false;
    8263           0 :             HeatingAirFlowSizer sizingNoHeatingAirFlow;
    8264           0 :             sizingNoHeatingAirFlow.overrideSizingString(SizingString);
    8265             :             // sizingNoHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8266           0 :             sizingNoHeatingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8267           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow = sizingNoHeatingAirFlow.size(state, TempSize, errorsFound);
    8268             :         }
    8269             : 
    8270             :         // initialize capacity sizing variables: cooling
    8271           0 :         SizingMethod = CoolingCapacitySizing;
    8272           0 :         CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod;
    8273           0 :         EqSizing.SizingMethod(SizingMethod) = CapSizingMethod;
    8274           0 :         if (CapSizingMethod == CoolingDesignCapacity || CapSizingMethod == CapacityPerFloorArea ||
    8275             :             CapSizingMethod == FractionOfAutosizedCoolingCapacity) {
    8276           0 :             if (CapSizingMethod == HeatingDesignCapacity) {
    8277           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity > 0.0) {
    8278           0 :                     EqSizing.CoolingCapacity = true;
    8279           0 :                     EqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity;
    8280             :                 }
    8281           0 :             } else if (CapSizingMethod == CapacityPerFloorArea) {
    8282           0 :                 EqSizing.CoolingCapacity = true;
    8283           0 :                 EqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity *
    8284           0 :                                           state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8285           0 :                 state.dataSize->DataScalableCapSizingON = true;
    8286           0 :             } else if (CapSizingMethod == FractionOfAutosizedCoolingCapacity) {
    8287           0 :                 state.dataSize->DataFracOfAutosizedCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity;
    8288           0 :                 state.dataSize->DataScalableCapSizingON = true;
    8289             :             }
    8290             :         }
    8291             : 
    8292             :         // initialize capacity sizing variables: heating
    8293           0 :         SizingMethod = HeatingCapacitySizing;
    8294           0 :         CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).HeatingCapMethod;
    8295           0 :         EqSizing.SizingMethod(SizingMethod) = CapSizingMethod;
    8296           0 :         if (CapSizingMethod == HeatingDesignCapacity || CapSizingMethod == CapacityPerFloorArea ||
    8297             :             CapSizingMethod == FractionOfAutosizedHeatingCapacity) {
    8298           0 :             if (CapSizingMethod == HeatingDesignCapacity) {
    8299           0 :                 if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity > 0.0) {
    8300           0 :                     EqSizing.HeatingCapacity = true;
    8301           0 :                     EqSizing.DesHeatingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity;
    8302             :                 }
    8303           0 :             } else if (CapSizingMethod == CapacityPerFloorArea) {
    8304           0 :                 EqSizing.HeatingCapacity = true;
    8305           0 :                 EqSizing.DesHeatingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity *
    8306           0 :                                           state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea;
    8307           0 :                 state.dataSize->DataScalableCapSizingON = true;
    8308           0 :             } else if (CapSizingMethod == FractionOfAutosizedHeatingCapacity) {
    8309           0 :                 state.dataSize->DataFracOfAutosizedHeatingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity;
    8310           0 :                 state.dataSize->DataScalableCapSizingON = true;
    8311             :             }
    8312             :         }
    8313             :     } else {
    8314             :         // no scalable sizing method has been specified. Sizing proceeds using the method
    8315             :         // specified in the zoneHVAC object
    8316             : 
    8317          56 :         PrintFlag = true;
    8318             : 
    8319          56 :         TempSize = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow;
    8320          56 :         bool errorsFound = false;
    8321         112 :         CoolingAirFlowSizer sizingCoolingAirFlow;
    8322         112 :         std::string stringOverride = "Cooling Supply Air Flow Rate [m3/s]";
    8323          56 :         if (state.dataGlobal->isEpJSON) stringOverride = "cooling_supply_air_flow_rate [m3/s]";
    8324          56 :         sizingCoolingAirFlow.overrideSizingString(stringOverride);
    8325             :         // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8326          56 :         sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8327          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8328             : 
    8329          56 :         FieldNum = 3; // N3, \field Supply Air Flow Rate During Heating Operation
    8330          56 :         SizingString = state.dataHVACVarRefFlow->VRFTUNumericFields(VRFTUNum).FieldNames(FieldNum) + " [m3/s]";
    8331          56 :         SizingMethod = HeatingAirflowSizing;
    8332          56 :         TempSize = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow;
    8333          56 :         errorsFound = false;
    8334         112 :         HeatingAirFlowSizer sizingHeatingAirFlow;
    8335          56 :         sizingHeatingAirFlow.overrideSizingString(SizingString);
    8336             :         // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8337          56 :         sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8338          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    8339             : 
    8340          56 :         errorsFound = false;
    8341         112 :         SystemAirFlowSizer sizerSystemAirFlow;
    8342         112 :         std::string sizingString = "No Cooling Supply Air Flow Rate [m3/s]";
    8343          56 :         sizerSystemAirFlow.overrideSizingString(sizingString);
    8344          56 :         sizerSystemAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8345          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow =
    8346          56 :             sizerSystemAirFlow.size(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoCoolAirVolFlow, errorsFound);
    8347             : 
    8348         112 :         SystemAirFlowSizer sizerSystemAirFlow2;
    8349          56 :         sizingString = "No Heating Supply Air Flow Rate [m3/s]";
    8350          56 :         sizerSystemAirFlow2.overrideSizingString(sizingString);
    8351          56 :         sizerSystemAirFlow2.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8352          56 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow =
    8353          56 :             sizerSystemAirFlow2.size(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxNoHeatAirVolFlow, errorsFound);
    8354             :     }
    8355          56 :     IsAutoSize = false;
    8356          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow == AutoSize) {
    8357          36 :         IsAutoSize = true;
    8358             :     }
    8359          56 :     if (state.dataSize->CurZoneEqNum > 0) {
    8360          54 :         if (!IsAutoSize && !state.dataSize->ZoneSizingRunDone) { // Simulation continue
    8361           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow > 0.0) {
    8362           0 :                 BaseSizer::reportSizerOutput(state,
    8363           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8364           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8365             :                                              "User-Specified Outdoor Air Flow Rate During Cooling Operation [m3/s]",
    8366           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow);
    8367             :             }
    8368             :         } else {
    8369         108 :             CheckZoneSizing(state,
    8370          54 :                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8371          54 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8372          54 :             CoolOutAirVolFlowDes =
    8373          54 :                 min(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow);
    8374          54 :             if (CoolOutAirVolFlowDes < DataHVACGlobals::SmallAirVolFlow) {
    8375           0 :                 CoolOutAirVolFlowDes = 0.0;
    8376             :             }
    8377             : 
    8378          54 :             if (IsAutoSize) {
    8379          34 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow = CoolOutAirVolFlowDes;
    8380         102 :                 BaseSizer::reportSizerOutput(state,
    8381          34 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8382          34 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8383             :                                              "Design Size Outdoor Air Flow Rate During Cooling Operation [m3/s]",
    8384          34 :                                              CoolOutAirVolFlowDes);
    8385             :             } else {
    8386          20 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow > 0.0 && CoolOutAirVolFlowDes > 0.0) {
    8387           0 :                     CoolOutAirVolFlowUser = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow;
    8388           0 :                     BaseSizer::reportSizerOutput(state,
    8389           0 :                                                  DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8390           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8391             :                                                  "Design Size Outdoor Air Flow Rate During Cooling Operation [m3/s]",
    8392             :                                                  CoolOutAirVolFlowDes,
    8393             :                                                  "User-Specified Outdoor Air Flow Rate During Cooling Operation [m3/s]",
    8394           0 :                                                  CoolOutAirVolFlowUser);
    8395           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8396           0 :                         if ((std::abs(CoolOutAirVolFlowDes - CoolOutAirVolFlowUser) / CoolOutAirVolFlowUser) >
    8397           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    8398           0 :                             ShowMessage(state,
    8399           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    8400           0 :                                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ' ' +
    8401           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8402           0 :                             ShowContinueError(
    8403             :                                 state,
    8404           0 :                                 format("User-Specified Outdoor Air Flow Rate During Cooling Operation of {:.5R} [m3/s]", CoolOutAirVolFlowUser));
    8405           0 :                             ShowContinueError(state,
    8406           0 :                                               format("differs from Design Size Outdoor Air Flow Rate During Cooling Operation of {:.5R} [m3/s]",
    8407           0 :                                                      CoolOutAirVolFlowDes));
    8408           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8409           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8410             :                         }
    8411             :                     }
    8412             :                 }
    8413             :             }
    8414             :         }
    8415             :     } else {
    8416           2 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow == DataSizing::AutoSize) {
    8417           2 :             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).OASysExists) {
    8418           2 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow = 0.0;
    8419             :             } else {
    8420           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow =
    8421           0 :                     min(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesOutAirVolFlow,
    8422           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow);
    8423             :             }
    8424           8 :             BaseSizer::reportSizerOutput(state,
    8425           2 :                                          DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8426           2 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8427             :                                          "Design Size Outdoor Air Flow Rate During Cooling Operation [m3/s]",
    8428           4 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow);
    8429             :         }
    8430             :     }
    8431             : 
    8432          56 :     IsAutoSize = false;
    8433          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow == AutoSize) {
    8434          36 :         IsAutoSize = true;
    8435             :     }
    8436          56 :     if (state.dataSize->CurZoneEqNum > 0) {
    8437          54 :         if (!IsAutoSize && !state.dataSize->ZoneSizingRunDone) { // Simulation continue
    8438           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow > 0.0) {
    8439           0 :                 BaseSizer::reportSizerOutput(state,
    8440           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8441           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8442             :                                              "Outdoor Air Flow Rate During Heating Operation [m3/s]",
    8443           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow);
    8444             :             }
    8445             :         } else {
    8446         108 :             CheckZoneSizing(state,
    8447          54 :                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8448          54 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8449          54 :             HeatOutAirVolFlowDes =
    8450          54 :                 min(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow);
    8451          54 :             if (HeatOutAirVolFlowDes < DataHVACGlobals::SmallAirVolFlow) {
    8452           0 :                 HeatOutAirVolFlowDes = 0.0;
    8453             :             }
    8454             : 
    8455          54 :             if (IsAutoSize) {
    8456          34 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow = HeatOutAirVolFlowDes;
    8457         102 :                 BaseSizer::reportSizerOutput(state,
    8458          34 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8459          34 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8460             :                                              "Design Size Outdoor Air Flow Rate During Heating Operation [m3/s]",
    8461          34 :                                              HeatOutAirVolFlowDes);
    8462             :             } else {
    8463          20 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow > 0.0 && HeatOutAirVolFlowDes > 0.0) {
    8464           0 :                     HeatOutAirVolFlowUser = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow;
    8465           0 :                     BaseSizer::reportSizerOutput(state,
    8466           0 :                                                  DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8467           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8468             :                                                  "Design Size Outdoor Air Flow Rate During Heating Operation [m3/s]",
    8469             :                                                  HeatOutAirVolFlowDes,
    8470             :                                                  "User-Specified Outdoor Air Flow Rate During Heating Operation [m3/s]",
    8471           0 :                                                  HeatOutAirVolFlowUser);
    8472           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8473           0 :                         if ((std::abs(HeatOutAirVolFlowDes - HeatOutAirVolFlowUser) / HeatOutAirVolFlowUser) >
    8474           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    8475           0 :                             ShowMessage(state,
    8476           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    8477           0 :                                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ' ' +
    8478           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8479           0 :                             ShowContinueError(
    8480             :                                 state,
    8481           0 :                                 format("User-Specified Outdoor Air Flow Rate During Heating Operation of {:.5R} [m3/s]", HeatOutAirVolFlowUser));
    8482           0 :                             ShowContinueError(state,
    8483           0 :                                               format("differs from Design Size Outdoor Air Flow Rate During Heating Operation of {:.5R} [m3/s]",
    8484           0 :                                                      HeatOutAirVolFlowDes));
    8485           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8486           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8487             :                         }
    8488             :                     }
    8489             :                 }
    8490             :             }
    8491             :         }
    8492             :     } else {
    8493           2 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow == DataSizing::AutoSize) {
    8494           2 :             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).OASysExists) {
    8495           2 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow = 0.0;
    8496             :             } else {
    8497           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow =
    8498           0 :                     min(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesOutAirVolFlow,
    8499           0 :                         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow);
    8500             :             }
    8501           8 :             BaseSizer::reportSizerOutput(state,
    8502           2 :                                          DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8503           2 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8504             :                                          "Design Size Outdoor Air Flow Rate During Heating Operation [m3/s]",
    8505           4 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow);
    8506             :         }
    8507             :     }
    8508          56 :     EqSizing.OAVolFlow =
    8509          56 :         max(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow);
    8510             : 
    8511          61 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists &&
    8512           5 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone) { // set up ATMixer conditions for use in component sizing
    8513           5 :         EqSizing.OAVolFlow = 0.0;                             // Equipment OA flow should always be 0 when ATMixer is used
    8514          15 :         SingleDuct::setATMixerSizingProperties(state,
    8515           5 :                                                state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerIndex,
    8516           5 :                                                state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum,
    8517           5 :                                                state.dataSize->CurZoneEqNum);
    8518             :     }
    8519             : 
    8520          56 :     IsAutoSize = false;
    8521          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow == AutoSize) {
    8522          36 :         IsAutoSize = true;
    8523             :     }
    8524          56 :     if (state.dataSize->CurZoneEqNum > 0) {
    8525          54 :         if (!IsAutoSize && !state.dataSize->ZoneSizingRunDone) { // Simulation continue
    8526           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow > 0.0) {
    8527           0 :                 BaseSizer::reportSizerOutput(state,
    8528           0 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8529           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8530             :                                              "User-Specified Outdoor Air Flow Rate When No Cooling or Heating is Needed [m3/s]",
    8531           0 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow);
    8532             :             }
    8533             :         } else {
    8534         108 :             CheckZoneSizing(state,
    8535          54 :                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8536          54 :                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8537         108 :             NoCoolHeatOutAirVolFlowDes = min(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA,
    8538          54 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow,
    8539          54 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow);
    8540          54 :             if (NoCoolHeatOutAirVolFlowDes < DataHVACGlobals::SmallAirVolFlow) {
    8541          20 :                 NoCoolHeatOutAirVolFlowDes = 0.0;
    8542             :             }
    8543             : 
    8544          54 :             if (IsAutoSize) {
    8545          34 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow = NoCoolHeatOutAirVolFlowDes;
    8546         102 :                 BaseSizer::reportSizerOutput(state,
    8547          34 :                                              DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8548          34 :                                              state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8549             :                                              "Design Size Outdoor Air Flow Rate When No Cooling or Heating is Needed [m3/s]",
    8550          34 :                                              NoCoolHeatOutAirVolFlowDes);
    8551             :             } else {
    8552          20 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow > 0.0 && NoCoolHeatOutAirVolFlowDes > 0.0) {
    8553           0 :                     NoCoolHeatOutAirVolFlowUser = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow;
    8554           0 :                     BaseSizer::reportSizerOutput(state,
    8555           0 :                                                  DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8556           0 :                                                  state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8557             :                                                  "Design Size Outdoor Air Flow Rate When No Cooling or Heating is Needed [m3/s]",
    8558             :                                                  NoCoolHeatOutAirVolFlowDes,
    8559             :                                                  "User-Specified Outdoor Air Flow Rate When No Cooling or Heating is Needed [m3/s]",
    8560           0 :                                                  NoCoolHeatOutAirVolFlowUser);
    8561           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8562           0 :                         if ((std::abs(NoCoolHeatOutAirVolFlowDes - NoCoolHeatOutAirVolFlowUser) / NoCoolHeatOutAirVolFlowUser) >
    8563           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    8564           0 :                             ShowMessage(state,
    8565           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    8566           0 :                                             DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num) + ' ' +
    8567           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name);
    8568           0 :                             ShowContinueError(state,
    8569           0 :                                               format("User-Specified Outdoor Air Flow Rate When No Cooling or Heating is Needed of {:.5R} [m3/s]",
    8570           0 :                                                      NoCoolHeatOutAirVolFlowUser));
    8571           0 :                             ShowContinueError(
    8572             :                                 state,
    8573           0 :                                 format("differs from Design Size Outdoor Air Flow Rate When No Cooling or Heating is Needed of {:.5R} [m3/s]",
    8574           0 :                                        NoCoolHeatOutAirVolFlowDes));
    8575           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8576           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8577             :                         }
    8578             :                     }
    8579             :                 }
    8580             :             }
    8581             :         }
    8582             :     } else {
    8583           2 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow == DataSizing::AutoSize) {
    8584           2 :             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).OASysExists) {
    8585           2 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow = 0.0;
    8586             :             } else {
    8587           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow =
    8588           0 :                     min(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow);
    8589             :             }
    8590           8 :             BaseSizer::reportSizerOutput(state,
    8591           2 :                                          DataHVACGlobals::cVRFTUTypes(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUType_Num),
    8592           2 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name,
    8593             :                                          "Design Size Outdoor Air Flow Rate When No Cooling or Heating Heating is Needed [m3/s]",
    8594           4 :                                          state.dataHVACVarRefFlow->VRFTU(VRFTUNum).NoCoolHeatOutAirVolFlow);
    8595             :         }
    8596             :     }
    8597             : 
    8598          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatingCoilPresent) {
    8599          10 :         bool ErrorsFound = false;
    8600          10 :         TempSize = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxSATFromSuppHeatCoil;
    8601          20 :         MaxHeaterOutletTempSizer sizerMaxHeaterOutTemp;
    8602          20 :         std::string stringOverride = "Maximum Supply Air Temperature from Supplemental Heater [C]";
    8603          10 :         if (state.dataGlobal->isEpJSON) stringOverride = "maximum_supply_air_temperature_from_supplemental_heater [C]";
    8604          10 :         sizerMaxHeaterOutTemp.overrideSizingString(stringOverride);
    8605          10 :         sizerMaxHeaterOutTemp.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8606          10 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxSATFromSuppHeatCoil = sizerMaxHeaterOutTemp.size(state, TempSize, ErrorsFound);
    8607             :     }
    8608             : 
    8609          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    8610           2 :         bool ErrorsFound = false;
    8611           6 :         WaterCoils::SetCoilDesFlow(state,
    8612           2 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType,
    8613           2 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
    8614           2 :                                    state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow,
    8615             :                                    ErrorsFound);
    8616             :     }
    8617             : 
    8618          56 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatingCoilPresent) {
    8619          10 :         CompType = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType;
    8620          10 :         CompName = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName;
    8621          10 :         PrintFlag = false; // why isn't this being reported?
    8622          10 :         TempSize = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity;
    8623          10 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilType_Num == DataHVACGlobals::Coil_HeatingWater) {
    8624             :             // sizing result should always be reported
    8625           2 :             if (TempSize == DataSizing::AutoSize) {
    8626           0 :                 WaterHeatingCapacitySizer sizerWaterHeatingCapacity;
    8627           0 :                 bool ErrorsFound = false;
    8628           0 :                 std::string stringOverride = "Supplemental Heating Coil Nominal Capacity [W]";
    8629           0 :                 if (state.dataGlobal->isEpJSON) stringOverride = "supplemental_heating_coil_nominal_capacity [W]";
    8630           0 :                 sizerWaterHeatingCapacity.overrideSizingString(stringOverride);
    8631           0 :                 sizerWaterHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8632           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity = sizerWaterHeatingCapacity.size(state, TempSize, ErrorsFound);
    8633             :             }
    8634             :         } else {
    8635           8 :             SizingMethod = DataHVACGlobals::HeatingCapacitySizing;
    8636           8 :             SizingString = "Supplemental Heating Coil Nominal Capacity [W]";
    8637           8 :             if (TempSize == DataSizing::AutoSize) {
    8638           6 :                 IsAutoSize = true;
    8639           6 :                 bool errorsFound = false;
    8640          12 :                 HeatingCapacitySizer sizerHeatingCapacity;
    8641           6 :                 sizerHeatingCapacity.overrideSizingString(SizingString);
    8642           6 :                 sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8643           6 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).DesignSuppHeatingCapacity = sizerHeatingCapacity.size(state, TempSize, errorsFound);
    8644             :             }
    8645             :         }
    8646             :     }
    8647             : 
    8648          56 :     EqSizing.CoolingAirFlow = true;
    8649          56 :     EqSizing.CoolingAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxCoolAirVolFlow;
    8650          56 :     EqSizing.HeatingAirFlow = true;
    8651          56 :     EqSizing.HeatingAirVolFlow = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).MaxHeatAirVolFlow;
    8652             : 
    8653          56 :     if (CheckVRFCombinationRatio(VRFCond)) {
    8654          56 :         OnOffAirFlowRat = 1.0;
    8655             :         // set up the outside air data for sizing the DX coils
    8656          56 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInZone) state.dataSize->ZoneEqDXCoil = true;
    8657          56 :         if (state.dataSize->CurZoneEqNum > 0) {
    8658          74 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow > 0.0 ||
    8659          20 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow > 0.0) {
    8660          34 :                 EqSizing.OAVolFlow =
    8661          34 :                     max(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolOutAirVolFlow, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatOutAirVolFlow);
    8662             :             } else {
    8663          20 :                 EqSizing.OAVolFlow = 0.0;
    8664             :             }
    8665             :         } else {
    8666           2 :             EqSizing.OAVolFlow = 0.0;
    8667             :         }
    8668             : 
    8669          56 :         Real64 SuppHeatCoilLoad = 0.0;
    8670             :         // simulate the TU to size the coils
    8671          56 :         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    8672             :             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    8673          15 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    8674             :                 state, VRFTUNum, true, 0.0, TUCoolingCapacity, OnOffAirFlowRat, SuppHeatCoilLoad);
    8675             :         } else {
    8676             :             // Algorithm Type: VRF model based on system curve
    8677          41 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(state, VRFTUNum, true, 0.0, TUCoolingCapacity, OnOffAirFlowRat, SuppHeatCoilLoad);
    8678             :         }
    8679             : 
    8680             :         //    ZoneEqDXCoil = .FALSE.
    8681          56 :         TUCoolingCapacity = 0.0;
    8682          56 :         TUHeatingCapacity = 0.0;
    8683          56 :         FoundAll = true;
    8684          56 :         TUListNum = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TUListIndex;
    8685         187 :         for (NumTU = 1; NumTU <= state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList; ++NumTU) {
    8686         175 :             TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
    8687         175 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex > 0) {
    8688         350 :                 DXCoilCap = GetDXCoilCap(state,
    8689         175 :                                          state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex,
    8690         175 :                                          state.dataHVACVarRefFlow->VRFTU(TUIndex).DXCoolCoilType_Num,
    8691             :                                          errFlag);
    8692         175 :                 TUCoolingCapacity += DXCoilCap;
    8693         175 :                 if (DXCoilCap == AutoSize) {
    8694          44 :                     FoundAll = false;
    8695          44 :                     break;
    8696             :                 }
    8697             :             }
    8698         131 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex > 0) {
    8699         262 :                 DXCoilCap = GetDXCoilCap(state,
    8700         131 :                                          state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex,
    8701         131 :                                          state.dataHVACVarRefFlow->VRFTU(TUIndex).DXHeatCoilType_Num,
    8702             :                                          errFlag);
    8703         131 :                 TUHeatingCapacity += DXCoilCap;
    8704         131 :                 if (DXCoilCap == AutoSize) {
    8705           0 :                     FoundAll = false;
    8706           0 :                     break;
    8707             :                 }
    8708             :             }
    8709             :         }
    8710             : 
    8711          56 :         if (FoundAll && (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::SysCurve)) {
    8712             :             // Size VRF rated cooling/heating capacity (VRF-SysCurve Model)
    8713             : 
    8714             :             // Size VRF( VRFCond ).CoolingCapacity
    8715           9 :             IsAutoSize = false;
    8716           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity == AutoSize) {
    8717           9 :                 IsAutoSize = true;
    8718             :             }
    8719           9 :             CoolingCapacityDes = TUCoolingCapacity;
    8720           9 :             if (IsAutoSize) {
    8721           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity = CoolingCapacityDes;
    8722          36 :                 BaseSizer::reportSizerOutput(state,
    8723          18 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8724           9 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8725             :                                              "Design Size Rated Total Cooling Capacity (gross) [W]",
    8726           9 :                                              CoolingCapacityDes);
    8727             :             } else {
    8728           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity > 0.0 && CoolingCapacityDes > 0.0) {
    8729           0 :                     CoolingCapacityUser = state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity;
    8730           0 :                     BaseSizer::reportSizerOutput(state,
    8731           0 :                                                  std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8732           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8733             :                                                  "Design Size Rated Total Cooling Capacity (gross) [W]",
    8734             :                                                  CoolingCapacityDes,
    8735             :                                                  "User-Specified Rated Total Cooling Capacity (gross) [W]",
    8736           0 :                                                  CoolingCapacityUser);
    8737           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8738           0 :                         if ((std::abs(CoolingCapacityDes - CoolingCapacityUser) / CoolingCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8739           0 :                             ShowMessage(state,
    8740           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    8741           0 :                                             std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    8742           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    8743           0 :                             ShowContinueError(state,
    8744           0 :                                               format("User-Specified Rated Total Cooling Capacity (gross) of {:.2R} [W]", CoolingCapacityUser));
    8745           0 :                             ShowContinueError(
    8746           0 :                                 state, format("differs from Design Size Rated Total Cooling Capacity (gross) of {:.2R} [W]", CoolingCapacityDes));
    8747           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8748           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8749             :                         }
    8750             :                     }
    8751             :                 }
    8752             :             }
    8753             : 
    8754           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity > 0.0) {
    8755           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCombinationRatio =
    8756           9 :                     TUCoolingCapacity / state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity;
    8757             :             }
    8758             : 
    8759             :             // Size VRF( VRFCond ).HeatingCapacity
    8760           9 :             IsAutoSize = false;
    8761           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity == AutoSize) {
    8762           9 :                 IsAutoSize = true;
    8763             :             }
    8764           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).LockHeatingCapacity) {
    8765           2 :                 HeatingCapacityDes =
    8766           2 :                     state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity * state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacitySizeRatio;
    8767             :             } else {
    8768           7 :                 HeatingCapacityDes = TUHeatingCapacity;
    8769             :             }
    8770           9 :             if (IsAutoSize) {
    8771           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity = HeatingCapacityDes;
    8772          36 :                 BaseSizer::reportSizerOutput(state,
    8773          18 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8774           9 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8775             :                                              "Design Size Rated Total Heating Capacity [W]",
    8776           9 :                                              HeatingCapacityDes);
    8777             :             } else {
    8778           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity > 0.0 && HeatingCapacityDes > 0.0) {
    8779           0 :                     HeatingCapacityUser = state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity;
    8780           0 :                     BaseSizer::reportSizerOutput(state,
    8781           0 :                                                  std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8782           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8783             :                                                  "Design Size Rated Total Heating Capacity [W]",
    8784             :                                                  HeatingCapacityDes,
    8785             :                                                  "User-Specified Rated Total Heating Capacity [W]",
    8786           0 :                                                  HeatingCapacityUser);
    8787           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8788           0 :                         if ((std::abs(HeatingCapacityDes - HeatingCapacityUser) / HeatingCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8789           0 :                             ShowMessage(state,
    8790           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    8791           0 :                                             std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    8792           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    8793           0 :                             ShowContinueError(state, format("User-Specified Rated Total Heating Capacity of {:.2R} [W]", HeatingCapacityUser));
    8794           0 :                             ShowContinueError(state,
    8795           0 :                                               format("differs from Design Size Rated Total Heating Capacity of {:.2R} [W]", HeatingCapacityDes));
    8796           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8797           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8798             :                         }
    8799             :                     }
    8800             :                 }
    8801             :             }
    8802             : 
    8803           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity > 0.0) {
    8804           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCombinationRatio =
    8805           9 :                     TUHeatingCapacity / state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity;
    8806             :             }
    8807             : 
    8808             :             // calculate the piping correction factors only once
    8809           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthCoolPtr > 0) {
    8810             :                 {
    8811           9 :                     if (state.dataCurveManager->PerfCurve(state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthCoolPtr).numDims == 2) {
    8812           9 :                         state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionCooling =
    8813           9 :                             min(1.0,
    8814             :                                 max(0.5,
    8815          45 :                                     CurveValue(state,
    8816           9 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthCoolPtr,
    8817           9 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).EquivPipeLngthCool,
    8818           9 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCombinationRatio) +
    8819           9 :                                         state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightCool));
    8820             :                     } else {
    8821           0 :                         state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionCooling =
    8822           0 :                             min(1.0,
    8823             :                                 max(0.5,
    8824           0 :                                     CurveValue(state,
    8825           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthCoolPtr,
    8826           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).EquivPipeLngthCool) +
    8827           0 :                                         state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightCool));
    8828             :                     }
    8829             :                 }
    8830             :             } else {
    8831           0 :                 state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionCooling = min(
    8832             :                     1.0,
    8833           0 :                     max(0.5, (1.0 + state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightCool)));
    8834             :             }
    8835             : 
    8836           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthHeatPtr > 0) {
    8837             :                 {
    8838           0 :                     if (state.dataCurveManager->PerfCurve(state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthHeatPtr).numDims == 2) {
    8839           0 :                         state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionHeating =
    8840           0 :                             min(1.0,
    8841             :                                 max(0.5,
    8842           0 :                                     CurveValue(state,
    8843           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthHeatPtr,
    8844           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).EquivPipeLngthHeat,
    8845           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCombinationRatio) +
    8846           0 :                                         state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightHeat));
    8847             :                     } else {
    8848           0 :                         state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionHeating =
    8849           0 :                             min(1.0,
    8850             :                                 max(0.5,
    8851           0 :                                     CurveValue(state,
    8852           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).PCFLengthHeatPtr,
    8853           0 :                                                state.dataHVACVarRefFlow->VRF(VRFCond).EquivPipeLngthHeat) +
    8854           0 :                                         state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightHeat));
    8855             :                     }
    8856             :                 }
    8857             :             } else {
    8858           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionHeating = min(
    8859             :                     1.0,
    8860           9 :                     max(0.5, (1.0 + state.dataHVACVarRefFlow->VRF(VRFCond).VertPipeLngth * state.dataHVACVarRefFlow->VRF(VRFCond).PCFHeightHeat)));
    8861             :             }
    8862             : 
    8863           9 :             state.dataHVACVarRefFlow->VRF(VRFCond).RatedCoolingPower =
    8864           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity / state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCOP;
    8865           9 :             state.dataHVACVarRefFlow->VRF(VRFCond).RatedHeatingPower =
    8866           9 :                 state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity / state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCOP;
    8867             : 
    8868           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).CoolCombRatioPTR > 0) {
    8869          27 :                 state.dataHVACVarRefFlow->CoolCombinationRatio(VRFCond) = CurveValue(
    8870          18 :                     state, state.dataHVACVarRefFlow->VRF(VRFCond).CoolCombRatioPTR, state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCombinationRatio);
    8871             :             } else {
    8872           0 :                 state.dataHVACVarRefFlow->CoolCombinationRatio(VRFCond) = 1.0;
    8873             :             }
    8874             : 
    8875           9 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatCombRatioPTR > 0) {
    8876          27 :                 state.dataHVACVarRefFlow->HeatCombinationRatio(VRFCond) = CurveValue(
    8877          18 :                     state, state.dataHVACVarRefFlow->VRF(VRFCond).HeatCombRatioPTR, state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCombinationRatio);
    8878             :             } else {
    8879           0 :                 state.dataHVACVarRefFlow->HeatCombinationRatio(VRFCond) = 1.0;
    8880             :             }
    8881             :         }
    8882             : 
    8883          56 :         if (FoundAll && (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl)) {
    8884             :             // Size VRF rated evaporative capacity (VRF-FluidTCtrl Model)
    8885             :             // Set piping correction factors to 1.0 here for reporting to eio output - recalculated every time step in
    8886             :             // VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl
    8887           3 :             state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionCooling = 1.0;
    8888           3 :             state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionHeating = 1.0;
    8889             : 
    8890             :             // Size VRF( VRFCond ).RatedEvapCapacity
    8891           3 :             IsAutoSize = false;
    8892           3 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity == AutoSize) {
    8893           2 :                 IsAutoSize = true;
    8894             :             }
    8895             : 
    8896           3 :             CoolingCapacityDes = TUCoolingCapacity;
    8897           3 :             HeatingCapacityDes = TUHeatingCapacity;
    8898             : 
    8899           3 :             if (IsAutoSize) {
    8900             :                 // RatedEvapCapacity
    8901           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity =
    8902           2 :                     max(CoolingCapacityDes, HeatingCapacityDes / (1 + state.dataHVACVarRefFlow->VRF(VRFCond).RatedCompPowerPerCapcity));
    8903             : 
    8904             :                 // Other parameters dependent on RatedEvapCapacity
    8905           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).RatedCompPower =
    8906           2 :                     state.dataHVACVarRefFlow->VRF(VRFCond).RatedCompPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity;
    8907           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).RatedOUFanPower =
    8908           2 :                     state.dataHVACVarRefFlow->VRF(VRFCond).RatedOUFanPowerPerCapcity * state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity;
    8909           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).OUAirFlowRate =
    8910           2 :                     state.dataHVACVarRefFlow->VRF(VRFCond).OUAirFlowRatePerCapcity * state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity;
    8911             : 
    8912           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity = state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity;
    8913           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity =
    8914           2 :                     state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity * (1 + state.dataHVACVarRefFlow->VRF(VRFCond).RatedCompPowerPerCapcity);
    8915             : 
    8916          10 :                 BaseSizer::reportSizerOutput(state,
    8917           4 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8918           2 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8919             :                                              "Design Size Rated Total Heating Capacity [W]",
    8920           4 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCapacity);
    8921          10 :                 BaseSizer::reportSizerOutput(state,
    8922           4 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8923           2 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8924             :                                              "Design Size Rated Total Cooling Capacity (gross) [W]",
    8925           4 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity);
    8926             :             } else {
    8927           1 :                 CoolingCapacityUser = state.dataHVACVarRefFlow->VRF(VRFCond).RatedEvapCapacity;
    8928           1 :                 HeatingCapacityUser = state.dataHVACVarRefFlow->VRF(VRFCond).RatedHeatCapacity;
    8929             : 
    8930           4 :                 BaseSizer::reportSizerOutput(state,
    8931           2 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8932           1 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8933             :                                              "Design Size Rated Total Cooling Capacity (gross) [W]",
    8934             :                                              CoolingCapacityDes,
    8935             :                                              "User-Specified Rated Total Cooling Capacity (gross) [W]",
    8936           1 :                                              CoolingCapacityUser);
    8937           4 :                 BaseSizer::reportSizerOutput(state,
    8938           2 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8939           1 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8940             :                                              "Design Size Rated Total Heating Capacity [W]",
    8941             :                                              HeatingCapacityDes,
    8942             :                                              "User-Specified Rated Total Heating Capacity [W]",
    8943           1 :                                              HeatingCapacityUser);
    8944             : 
    8945           1 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    8946           1 :                     if ((std::abs(CoolingCapacityDes - CoolingCapacityUser) / CoolingCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8947           3 :                         ShowMessage(state,
    8948           2 :                                     "SizeVRF: Potential issue with equipment sizing for " +
    8949           4 :                                         std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    8950           1 :                                         state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    8951           1 :                         ShowContinueError(state, format("User-Specified Rated Total Cooling Capacity (gross) of {:.2R} [W]", CoolingCapacityUser));
    8952           3 :                         ShowContinueError(state,
    8953           2 :                                           format("differs from Design Size Rated Total Cooling Capacity (gross) of {:.2R} [W]", CoolingCapacityDes));
    8954           1 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8955           1 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8956             :                     }
    8957             : 
    8958           1 :                     if ((std::abs(HeatingCapacityDes - HeatingCapacityUser) / HeatingCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8959           3 :                         ShowMessage(state,
    8960           2 :                                     "SizeVRF: Potential issue with equipment sizing for " +
    8961           4 :                                         std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    8962           1 :                                         state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    8963           1 :                         ShowContinueError(state, format("User-Specified Rated Total Heating Capacity of {:.2R} [W]", HeatingCapacityUser));
    8964           1 :                         ShowContinueError(state, format("differs from Design Size Rated Total Heating Capacity of {:.2R} [W]", HeatingCapacityDes));
    8965           1 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8966           1 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8967             :                     }
    8968             :                 }
    8969             :             }
    8970             :         }
    8971             : 
    8972          56 :         if (FoundAll) {
    8973             :             // autosize resistive defrost heater capacity
    8974          12 :             IsAutoSize = false;
    8975          12 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).DefrostCapacity == AutoSize) {
    8976           7 :                 IsAutoSize = true;
    8977             :             }
    8978          12 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    8979           9 :                 DefrostCapacityDes = state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity;
    8980             :             } else {
    8981           3 :                 DefrostCapacityDes = 0.0;
    8982             :             }
    8983          12 :             if (IsAutoSize) {
    8984           7 :                 state.dataHVACVarRefFlow->VRF(VRFCond).DefrostCapacity = DefrostCapacityDes;
    8985          28 :                 BaseSizer::reportSizerOutput(state,
    8986          14 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8987           7 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8988             :                                              "Design Size Resistive Defrost Heater Capacity",
    8989           7 :                                              DefrostCapacityDes);
    8990             :             } else {
    8991           5 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).DefrostCapacity > 0.0 && DefrostCapacityDes > 0.0) {
    8992           2 :                     DefrostCapacityUser = state.dataHVACVarRefFlow->VRF(VRFCond).DefrostCapacity;
    8993           8 :                     BaseSizer::reportSizerOutput(state,
    8994           4 :                                                  std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    8995           2 :                                                  state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    8996             :                                                  "Design Size Resistive Defrost Heater Capacity",
    8997             :                                                  DefrostCapacityDes,
    8998             :                                                  "User-Specified Resistive Defrost Heater Capacity",
    8999           2 :                                                  DefrostCapacityUser);
    9000           2 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    9001           0 :                         if ((std::abs(DefrostCapacityDes - DefrostCapacityUser) / DefrostCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    9002           0 :                             ShowMessage(state,
    9003           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    9004           0 :                                             std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    9005           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    9006           0 :                             ShowContinueError(state, format("User-Specified Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityUser));
    9007           0 :                             ShowContinueError(state,
    9008           0 :                                               format("differs from Design Size Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityDes));
    9009           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    9010           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    9011             :                         }
    9012             :                     }
    9013             :                 }
    9014             :             }
    9015             : 
    9016          12 :             IsAutoSize = false;
    9017          12 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondAirVolFlowRate == AutoSize) {
    9018           2 :                 IsAutoSize = true;
    9019             :             }
    9020             :             // Auto size condenser air flow to Total Capacity * 0.000114 m3/s/w (850 cfm/ton)
    9021          12 :             EvapCondAirVolFlowRateDes = state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity * 0.000114;
    9022          12 :             if (IsAutoSize) {
    9023           2 :                 state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondAirVolFlowRate = EvapCondAirVolFlowRateDes;
    9024           8 :                 BaseSizer::reportSizerOutput(state,
    9025           4 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    9026           2 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    9027             :                                              "Design Size Evaporative Condenser Air Flow Rate [m3/s]",
    9028           2 :                                              EvapCondAirVolFlowRateDes);
    9029             :             } else {
    9030          10 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondAirVolFlowRate > 0.0 && EvapCondAirVolFlowRateDes > 0.0) {
    9031           0 :                     EvapCondAirVolFlowRateUser = state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondAirVolFlowRate;
    9032           0 :                     BaseSizer::reportSizerOutput(state,
    9033           0 :                                                  std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    9034           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    9035             :                                                  "Design Size Evaporative Condenser Air Flow Rate [m3/s]",
    9036             :                                                  EvapCondAirVolFlowRateDes,
    9037             :                                                  "User-Specified Evaporative Condenser Air Flow Rate [m3/s]",
    9038           0 :                                                  EvapCondAirVolFlowRateUser);
    9039           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    9040           0 :                         if ((std::abs(EvapCondAirVolFlowRateDes - EvapCondAirVolFlowRateUser) / EvapCondAirVolFlowRateUser) >
    9041           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    9042           0 :                             ShowMessage(state,
    9043           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    9044           0 :                                             std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    9045           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    9046           0 :                             ShowContinueError(
    9047           0 :                                 state, format("User-Specified Evaporative Condenser Air Flow Rate of {:.5R} [m3/s]", EvapCondAirVolFlowRateUser));
    9048           0 :                             ShowContinueError(
    9049             :                                 state,
    9050           0 :                                 format("differs from Design Size Evaporative Condenser Air Flow Rate of {:.5R} [m3/s]", EvapCondAirVolFlowRateDes));
    9051           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    9052           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    9053             :                         }
    9054             :                     }
    9055             :                 }
    9056             :             }
    9057             : 
    9058          12 :             IsAutoSize = false;
    9059          12 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpPower == AutoSize) {
    9060           0 :                 IsAutoSize = true;
    9061             :             }
    9062             :             // Auto size evap condenser pump power to Total Capacity * 0.004266 w/w (15 w/ton)
    9063          12 :             EvapCondPumpPowerDes = state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCapacity * 0.004266;
    9064          12 :             if (IsAutoSize) {
    9065           0 :                 state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpPower = EvapCondPumpPowerDes;
    9066           0 :                 BaseSizer::reportSizerOutput(state,
    9067           0 :                                              std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    9068           0 :                                              state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    9069             :                                              "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    9070           0 :                                              EvapCondPumpPowerDes);
    9071             : 
    9072             :             } else {
    9073          12 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpPower > 0.0 && EvapCondPumpPowerDes > 0.0) {
    9074           0 :                     EvapCondPumpPowerUser = state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpPower;
    9075           0 :                     BaseSizer::reportSizerOutput(state,
    9076           0 :                                                  std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)),
    9077           0 :                                                  state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    9078             :                                                  "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    9079             :                                                  EvapCondPumpPowerDes,
    9080             :                                                  "User-Specified Evaporative Condenser Pump Rated Power Consumption [W]",
    9081           0 :                                                  EvapCondPumpPowerUser);
    9082           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    9083           0 :                         if ((std::abs(EvapCondPumpPowerDes - EvapCondPumpPowerUser) / EvapCondPumpPowerUser) >
    9084           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    9085           0 :                             ShowMessage(state,
    9086           0 :                                         "SizeVRF: Potential issue with equipment sizing for " +
    9087           0 :                                             std::string(cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum)) + ' ' +
    9088           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFCond).Name);
    9089           0 :                             ShowContinueError(
    9090             :                                 state,
    9091           0 :                                 format("User-Specified Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]", EvapCondPumpPowerUser));
    9092           0 :                             ShowContinueError(state,
    9093           0 :                                               format("differs from Design Size Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    9094           0 :                                                      EvapCondPumpPowerDes));
    9095           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    9096           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    9097             :                         }
    9098             :                     }
    9099             :                 }
    9100             :             }
    9101             : 
    9102             :             // Report to eio other information not related to autosizing
    9103          12 :             if (MyOneTimeEIOFlag) {
    9104             :                 static constexpr std::string_view Format_990(
    9105             :                     "! <VRF System Information>, VRF System Type, VRF System Name, VRF System Cooling Combination Ratio, VRF "
    9106             :                     "System Heating Combination Ratio, VRF System Cooling Piping Correction Factor, VRF System Heating Piping "
    9107             :                     "Correction Factor\n");
    9108          11 :                 print(state.files.eio, Format_990);
    9109          11 :                 MyOneTimeEIOFlag = false;
    9110             :             }
    9111             :             static constexpr std::string_view Format_991(" VRF System Information, {}, {}, {:.5R}, {:.5R}, {:.5R}, {:.5R}\n");
    9112          72 :             print(state.files.eio,
    9113             :                   Format_991,
    9114          24 :                   cVRFTypes(state.dataHVACVarRefFlow->VRF(VRFCond).VRFSystemTypeNum),
    9115          12 :                   state.dataHVACVarRefFlow->VRF(VRFCond).Name,
    9116          12 :                   state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCombinationRatio,
    9117          12 :                   state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCombinationRatio,
    9118          12 :                   state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionCooling,
    9119          12 :                   state.dataHVACVarRefFlow->VRF(VRFCond).PipingCorrectionHeating);
    9120             : 
    9121          12 :             CheckVRFCombinationRatio(VRFCond) = false;
    9122             :         }
    9123             :     }
    9124             : 
    9125          56 :     state.dataSize->DataScalableCapSizingON = false;
    9126          56 : }
    9127             : 
    9128           5 : void VRFCondenserEquipment::SizeVRFCondenser(EnergyPlusData &state)
    9129             : {
    9130             : 
    9131             :     // SUBROUTINE INFORMATION:
    9132             :     //       AUTHOR         Richard Raustad, FSEC
    9133             :     //       DATE WRITTEN   August 2012
    9134             :     //       MODIFIED       na
    9135             :     //       RE-ENGINEERED  na
    9136             : 
    9137             :     // PURPOSE OF THIS SUBROUTINE:
    9138             :     // This subroutine is for sizing VRF Condenser.
    9139             : 
    9140             :     // METHODOLOGY EMPLOYED:
    9141             :     // Set water-cooled plant flow rates.
    9142             : 
    9143             :     static constexpr std::string_view RoutineName("SizeVRFCondenser");
    9144             : 
    9145             :     int PltSizCondNum;         // Plant Sizing index for condenser loop
    9146             :     Real64 rho;                // local fluid density [kg/m3]
    9147             :     Real64 Cp;                 // local fluid specific heat [J/kg-k]
    9148             :     Real64 tmpCondVolFlowRate; // local condenser design volume flow rate [m3/s]
    9149             :     bool ErrorsFound;          // indicates problem with sizing
    9150             : 
    9151             :     // save the design water flow rate for use by the water loop sizing algorithms
    9152           5 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9153             : 
    9154           5 :         ErrorsFound = false;
    9155           5 :         PltSizCondNum = 0;
    9156             : 
    9157           5 :         if (this->WaterCondVolFlowRate == DataSizing::AutoSize) {
    9158           1 :             if (this->SourcePlantLoc.loopNum > 0) PltSizCondNum = state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).PlantSizNum;
    9159           1 :             if (PltSizCondNum > 0) {
    9160           3 :                 rho = FluidProperties::GetDensityGlycol(state,
    9161           1 :                                                         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
    9162           1 :                                                         state.dataSize->PlantSizData(PltSizCondNum).ExitTemp,
    9163           1 :                                                         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
    9164             :                                                         RoutineName);
    9165             : 
    9166           3 :                 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    9167           1 :                                                             state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
    9168           1 :                                                             state.dataSize->PlantSizData(PltSizCondNum).ExitTemp,
    9169           1 :                                                             state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
    9170             :                                                             RoutineName);
    9171           1 :                 tmpCondVolFlowRate =
    9172           1 :                     max(this->CoolingCapacity, this->HeatingCapacity) / (state.dataSize->PlantSizData(PltSizCondNum).DeltaT * Cp * rho);
    9173           1 :                 if (this->HeatingCapacity != DataSizing::AutoSize && this->CoolingCapacity != DataSizing::AutoSize) {
    9174           1 :                     this->WaterCondVolFlowRate = tmpCondVolFlowRate;
    9175           3 :                     BaseSizer::reportSizerOutput(state,
    9176             :                                                  "AirConditioner:VariableRefrigerantFlow",
    9177             :                                                  this->Name,
    9178             :                                                  "Design Condenser Water Flow Rate [m3/s]",
    9179           2 :                                                  this->WaterCondVolFlowRate);
    9180             :                 }
    9181             : 
    9182           2 :                 rho = FluidProperties::GetDensityGlycol(state,
    9183           1 :                                                         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
    9184             :                                                         DataGlobalConstants::CWInitConvTemp,
    9185           1 :                                                         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
    9186             :                                                         RoutineName);
    9187           1 :                 this->WaterCondenserDesignMassFlow = this->WaterCondVolFlowRate * rho;
    9188           1 :                 PlantUtilities::InitComponentNodes(
    9189             :                     state, 0.0, this->WaterCondenserDesignMassFlow, this->CondenserNodeNum, this->CondenserOutletNodeNum);
    9190             : 
    9191             :             } else {
    9192           0 :                 ShowSevereError(state, "Autosizing of condenser water flow rate requires a condenser loop Sizing:Plant object");
    9193           0 :                 ShowContinueError(state, "... occurs in AirConditioner:VariableRefrigerantFlow object=" + this->Name);
    9194           0 :                 ShowContinueError(state, "... plant loop name must be referenced in Sizing:Plant object");
    9195           0 :                 ErrorsFound = true;
    9196             :             }
    9197             :         }
    9198             : 
    9199           5 :         if (ErrorsFound) {
    9200           0 :             ShowFatalError(state, "Preceding sizing errors cause program termination");
    9201             :         }
    9202             : 
    9203           5 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->CondenserNodeNum, this->WaterCondVolFlowRate);
    9204             :     }
    9205           5 : }
    9206             : 
    9207      231306 : void SimVRF(EnergyPlusData &state,
    9208             :             int const VRFTUNum,
    9209             :             bool const FirstHVACIteration,
    9210             :             Real64 &OnOffAirFlowRatio,
    9211             :             Real64 &SysOutputProvided,
    9212             :             Real64 &LatOutputProvided,
    9213             :             Real64 const QZnReq)
    9214             : {
    9215             : 
    9216             :     // SUBROUTINE INFORMATION:
    9217             :     //       AUTHOR         Richard Raustad, FSEC
    9218             :     //       DATE WRITTEN   August 2010
    9219             :     //       MODIFIED       na
    9220             :     //       RE-ENGINEERED  na
    9221             : 
    9222             :     // PURPOSE OF THIS SUBROUTINE:
    9223             :     // This subroutine simulates the VRF TU's.
    9224             : 
    9225             :     // METHODOLOGY EMPLOYED:
    9226             :     // Simulate terminal unit to meet zone load.
    9227             : 
    9228      231306 :     Real64 PartLoadRatio(1.0);
    9229      231306 :     Real64 SuppHeatCoilLoad(0.0); // supplemental heating coil load (W)
    9230             : 
    9231      231306 :     if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9232             :         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9233       58545 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ControlVRF_FluidTCtrl(
    9234             :             state, VRFTUNum, QZnReq, FirstHVACIteration, PartLoadRatio, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9235       58545 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    9236             :             state, VRFTUNum, FirstHVACIteration, PartLoadRatio, SysOutputProvided, OnOffAirFlowRatio, SuppHeatCoilLoad, LatOutputProvided);
    9237       58545 :         if (PartLoadRatio ==
    9238             :             0.0) { // set coil inlet conditions when coil does not operate. Inlet conditions are set in ControlVRF_FluidTCtrl when PLR=1
    9239        3777 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    9240        3777 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilInNodeT =
    9241        3777 :                     state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).AirInNode).Temp;
    9242        3777 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilInNodeW =
    9243        3777 :                     state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex).AirInNode).HumRat;
    9244             :             } else {
    9245           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilInNodeT =
    9246           0 :                     state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).AirInNode).Temp;
    9247           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilInNodeW =
    9248           0 :                     state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex).AirInNode).HumRat;
    9249             :             }
    9250             :         }
    9251             :         // CalcVRF( VRFTUNum, FirstHVACIteration, PartLoadRatio, SysOutputProvided, OnOffAirFlowRatio, LatOutputProvided );
    9252             :     } else {
    9253             :         // Algorithm Type: VRF model based on system curve
    9254      172761 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ControlVRF(
    9255             :             state, VRFTUNum, QZnReq, FirstHVACIteration, PartLoadRatio, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9256      172761 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    9257             :             state, VRFTUNum, FirstHVACIteration, PartLoadRatio, SysOutputProvided, OnOffAirFlowRatio, SuppHeatCoilLoad, LatOutputProvided);
    9258             :     }
    9259             : 
    9260      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TerminalUnitSensibleRate = SysOutputProvided;
    9261      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TerminalUnitLatentRate = LatOutputProvided;
    9262      231306 : }
    9263             : 
    9264      172761 : void VRFTerminalUnitEquipment::ControlVRF(EnergyPlusData &state,
    9265             :                                           int const VRFTUNum,            // Index to VRF terminal unit
    9266             :                                           Real64 const QZnReq,           // Index to zone number
    9267             :                                           bool const FirstHVACIteration, // flag for 1st HVAC iteration in the time step
    9268             :                                           Real64 &PartLoadRatio,         // unit part load ratio
    9269             :                                           Real64 &OnOffAirFlowRatio,     // ratio of compressor ON airflow to AVERAGE airflow over timestep
    9270             :                                           Real64 &SuppHeatCoilLoad       // supplemental heating coil load (W)
    9271             : )
    9272             : {
    9273             : 
    9274             :     // SUBROUTINE INFORMATION:
    9275             :     //       AUTHOR         Richard Raustad
    9276             :     //       DATE WRITTEN   July 2005
    9277             : 
    9278             :     // PURPOSE OF THIS SUBROUTINE:
    9279             :     // Determine the part load fraction of the heat pump for this time step.
    9280             : 
    9281             :     // METHODOLOGY EMPLOYED:
    9282             :     // Use RegulaFalsi technique to iterate on part-load ratio until convergence is achieved.
    9283             : 
    9284      172761 :     PartLoadRatio = 0.0;
    9285      172761 :     state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = 0.0;
    9286      172761 :     state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = 0.0;
    9287             : 
    9288             :     // The RETURNS here will jump back to SimVRF where the CalcVRF routine will simulate with latest PLR
    9289             : 
    9290             :     // do nothing else if TU is scheduled off
    9291      172761 :     if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) == 0.0) return;
    9292             : 
    9293             :     // do nothing if TU has no load (TU will be modeled using PLR=0)
    9294      172761 :     if (QZnReq == 0.0) return;
    9295             : 
    9296             :     // Set EMS value for PLR and return
    9297      150630 :     if (this->EMSOverridePartLoadFrac) {
    9298           0 :         PartLoadRatio = this->EMSValueForPartLoadFrac;
    9299           0 :         return;
    9300             :     }
    9301             : 
    9302             :     // Get result when DX coil is operating at the minimum PLR (1E-20) if not otherwise specified
    9303      150630 :     PartLoadRatio = this->MinOperatingPLR;
    9304             : 
    9305      150630 :     this->ControlVRFToLoad(state, VRFTUNum, QZnReq, FirstHVACIteration, PartLoadRatio, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9306             : }
    9307             : 
    9308      150630 : void VRFTerminalUnitEquipment::ControlVRFToLoad(EnergyPlusData &state,
    9309             :                                                 int const VRFTUNum,
    9310             :                                                 Real64 const QZnReq,
    9311             :                                                 bool const FirstHVACIteration,
    9312             :                                                 Real64 &PartLoadRatio,
    9313             :                                                 Real64 &OnOffAirFlowRatio,
    9314             :                                                 Real64 &SuppHeatCoilLoad)
    9315             : {
    9316             : 
    9317      150630 :     int constexpr MaxIte(500);        // maximum number of iterations
    9318      150630 :     Real64 constexpr MinPLF(0.0);     // minimum part load factor allowed
    9319      150630 :     Real64 constexpr ErrorTol(0.001); // tolerance for RegulaFalsi iterations
    9320             : 
    9321      150630 :     int VRFCond = this->VRFSysNum;
    9322      150630 :     Real64 FullOutput = 0.0;   // unit full output when compressor is operating [W]
    9323      150630 :     Real64 TempOutput = 0.0;   // unit output when iteration limit exceeded [W]
    9324      150630 :     int SolFla = 0;            // Flag of RegulaFalsi solver
    9325      150630 :     Real64 TempMinPLR = 0.0;   // min PLR used in Regula Falsi call
    9326      150630 :     Real64 TempMaxPLR = 0.0;   // max PLR used in Regula Falsi call
    9327             :     bool ContinueIter;         // used when convergence is an issue
    9328      150630 :     Real64 NoCompOutput = 0.0; // output when no active compressor [W]
    9329      150630 :     bool VRFCoolingMode = state.dataHVACVarRefFlow->CoolingLoad(VRFCond);
    9330      150630 :     bool VRFHeatingMode = state.dataHVACVarRefFlow->HeatingLoad(VRFCond);
    9331      150630 :     int IndexToTUInTUList = this->IndexToTUInTUList;
    9332      150630 :     int TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
    9333      150630 :     bool HRCoolingMode = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList);
    9334      150630 :     bool HRHeatingMode = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList);
    9335             : 
    9336      150630 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9337             :         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9338           0 :         this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, NoCompOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9339             :     } else {
    9340             :         // Algorithm Type: VRF model based on system curve
    9341      150630 :         this->CalcVRF(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, NoCompOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9342             :     }
    9343             : 
    9344      150630 :     if (VRFCoolingMode && HRHeatingMode) {
    9345             :         // IF the system is in cooling mode, but the terminal unit requests heating (heat recovery)
    9346           0 :         if (NoCompOutput >= QZnReq) {
    9347           0 :             PartLoadRatio = 0.0;
    9348       27444 :             return;
    9349             :         }
    9350      150630 :     } else if (VRFHeatingMode && HRCoolingMode) {
    9351             :         // IF the system is in heating mode, but the terminal unit requests cooling (heat recovery)
    9352           8 :         if (NoCompOutput <= QZnReq) {
    9353           0 :             PartLoadRatio = 0.0;
    9354           0 :             return;
    9355             :         }
    9356      150626 :     } else if (VRFCoolingMode || HRCoolingMode) {
    9357             :         // IF the system is in cooling mode and/or the terminal unit requests cooling
    9358      149356 :         if (NoCompOutput <= QZnReq) {
    9359           0 :             PartLoadRatio = 0.0;
    9360           0 :             return;
    9361             :         }
    9362       75948 :     } else if (VRFHeatingMode || HRHeatingMode) {
    9363             :         // IF the system is in heating mode and/or the terminal unit requests heating
    9364       63430 :         if (NoCompOutput >= QZnReq) {
    9365          14 :             PartLoadRatio = 0.0;
    9366          14 :             return;
    9367             :         }
    9368             :     }
    9369             : 
    9370             :     // Otherwise the coil needs to turn on. Get full load result
    9371      150616 :     PartLoadRatio = 1.0;
    9372      150616 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9373             :         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9374           0 :         this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, FullOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9375             :     } else {
    9376             :         // Algorithm Type: VRF model based on system curve
    9377      150616 :         this->CalcVRF(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, FullOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9378             :     }
    9379             : 
    9380             :     // set supplemental heating coil calculation if the condition requires
    9381      150616 :     if (this->SuppHeatingCoilPresent) {
    9382       29090 :         if ((QZnReq > DataHVACGlobals::SmallLoad && QZnReq > FullOutput) ||
    9383        9818 :             (this->isSetPointControlled && this->suppTempSetPoint > state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).Temp)) {
    9384        4727 :             Real64 ZoneLoad = 0.0;
    9385        4727 :             Real64 LoadToHeatingSP = 0.0;
    9386        4727 :             Real64 LoadToCoolingSP = 0.0;
    9387        4727 :             if (this->isSetPointControlled) {
    9388           0 :                 Real64 mDot = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).MassFlowRate;
    9389           0 :                 Real64 Tin = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).Temp;
    9390           0 :                 Real64 Win = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).HumRat;
    9391           0 :                 Real64 CpAirIn = Psychrometrics::PsyCpAirFnW(Win);
    9392           0 :                 SuppHeatCoilLoad = mDot * CpAirIn * (this->suppTempSetPoint - Tin);
    9393           0 :                 this->SuppHeatingCoilLoad = SuppHeatCoilLoad;
    9394           0 :                 if (this->DesignSuppHeatingCapacity > 0.0) {
    9395           0 :                     this->SuppHeatPartLoadRatio = min(1.0, SuppHeatCoilLoad / this->DesignSuppHeatingCapacity);
    9396             :                 }
    9397             :             } else {
    9398        4727 :                 getVRFTUZoneLoad(state, VRFTUNum, ZoneLoad, LoadToHeatingSP, LoadToCoolingSP, false);
    9399        4727 :                 if ((FullOutput < (LoadToHeatingSP - DataHVACGlobals::SmallLoad)) && !FirstHVACIteration) {
    9400        2384 :                     SuppHeatCoilLoad = max(0.0, LoadToHeatingSP - FullOutput);
    9401        2384 :                     this->SuppHeatingCoilLoad = SuppHeatCoilLoad;
    9402        4768 :                     if (this->DesignSuppHeatingCapacity > 0.0) {
    9403        2384 :                         this->SuppHeatPartLoadRatio = min(1.0, SuppHeatCoilLoad / this->DesignSuppHeatingCapacity);
    9404             :                     }
    9405             :                 } else {
    9406        2343 :                     SuppHeatCoilLoad = 0.0;
    9407        2343 :                     this->SuppHeatPartLoadRatio = 0.0;
    9408             :                 }
    9409             :             }
    9410             :         } else {
    9411        9818 :             SuppHeatCoilLoad = 0.0;
    9412        9818 :             this->SuppHeatPartLoadRatio = 0.0;
    9413             :         }
    9414             :     } else { // does it matter what these are if there is no supp heater?
    9415      136071 :         SuppHeatCoilLoad = 0.0;
    9416      136071 :         this->SuppHeatPartLoadRatio = 0.0;
    9417             :     }
    9418             : 
    9419      311099 :     if ((VRFCoolingMode && !state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) ||
    9420      103703 :         (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && HRCoolingMode)) {
    9421             :         // Since we are cooling, we expect FullOutput < NoCompOutput
    9422             :         // If the QZnReq <= FullOutput the unit needs to run full out
    9423       74682 :         if (QZnReq <= FullOutput) {
    9424             :             // if no coil present in terminal unit, no need to reset PLR?
    9425        4117 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    9426        4117 :                 PartLoadRatio = 1.0;
    9427             :                 // the zone set point could be exceeded if set point control is used so protect against that
    9428        4117 :                 if (this->isSetPointControlled) {
    9429           0 :                     if (state.dataLoopNodes->Node(this->coolCoilAirOutNode).Temp > this->coilTempSetPoint) return;
    9430             :                 } else {
    9431        4117 :                     return;
    9432             :                 }
    9433             :             } else {
    9434           0 :                 PartLoadRatio = 0.0;
    9435           0 :                 return;
    9436             :             }
    9437             :         }
    9438      159899 :     } else if ((VRFHeatingMode && !state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) ||
    9439       28584 :                (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && HRHeatingMode)) {
    9440             :         // Since we are heating, we expect FullOutput > NoCompOutput
    9441             :         // If the QZnReq >= FullOutput the unit needs to run full out
    9442       63416 :         if (QZnReq >= FullOutput) {
    9443             :             // if no coil present in terminal unit, no need reset PLR?
    9444       10795 :             if (this->HeatingCoilPresent) {
    9445       10795 :                 PartLoadRatio = 1.0;
    9446             :                 // the zone set point could be exceeded if set point control is used so protect against that
    9447       10795 :                 if (this->isSetPointControlled) {
    9448           1 :                     if (state.dataLoopNodes->Node(this->heatCoilAirOutNode).Temp < this->coilTempSetPoint) return;
    9449             :                 } else {
    9450       10794 :                     return;
    9451             :                 }
    9452             :             } else {
    9453           0 :                 PartLoadRatio = 0.0;
    9454           0 :                 return;
    9455             :             }
    9456             :         }
    9457             :     } else {
    9458             :         // VRF terminal unit is off
    9459             :         // shouldn't actually get here
    9460       12518 :         PartLoadRatio = 0.0;
    9461       12518 :         return;
    9462             :     }
    9463             : 
    9464             :     // The coil will not operate at PLR=0 or PLR=1, calculate the operating part-load ratio
    9465             : 
    9466      123186 :     if ((VRFHeatingMode || HRHeatingMode) || (VRFCoolingMode || HRCoolingMode)) {
    9467             : 
    9468    11297780 :         auto f = [&state, VRFTUNum, FirstHVACIteration, QZnReq, OnOffAirFlowRatio](Real64 const PartLoadRatio) {
    9469      865094 :             Real64 QZnReqTemp = QZnReq; // denominator representing zone load (W)
    9470             :             Real64 ActualOutput;        // delivered capacity of VRF terminal unit
    9471      865094 :             Real64 SuppHeatCoilLoad = 0.0;
    9472     1730188 :             bool setPointControlled = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isSetPointControlled;
    9473      865094 :             Real64 nonConstOnOffAirFlowRatio = OnOffAirFlowRatio;
    9474             : 
    9475     2595282 :             if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9476             :                 // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9477           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
    9478             :                     state, VRFTUNum, FirstHVACIteration, PartLoadRatio, ActualOutput, nonConstOnOffAirFlowRatio, SuppHeatCoilLoad);
    9479             :             } else {
    9480             :                 // Algorithm Type: VRF model based on system curve
    9481     3460376 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
    9482             :                     state, VRFTUNum, FirstHVACIteration, PartLoadRatio, ActualOutput, nonConstOnOffAirFlowRatio, SuppHeatCoilLoad);
    9483             :             }
    9484             : 
    9485      865094 :             if (setPointControlled) {
    9486       51558 :                 Real64 outletNodeT = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum).Temp;
    9487       34372 :                 return (outletNodeT - state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilTempSetPoint);
    9488             :             } else {
    9489      847908 :                 if (std::abs(QZnReq) < 100.0) QZnReqTemp = sign(100.0, QZnReq);
    9490     1695816 :                 return (ActualOutput - QZnReq) / QZnReqTemp;
    9491             :             }
    9492      123186 :         };
    9493      123186 :         General::SolveRoot(state, ErrorTol, MaxIte, SolFla, PartLoadRatio, f, 0.0, 1.0);
    9494      123186 :         if (SolFla == -1) {
    9495             :             //     Very low loads may not converge quickly. Tighten PLR boundary and try again.
    9496           0 :             TempMaxPLR = -0.1;
    9497           0 :             ContinueIter = true;
    9498           0 :             while (ContinueIter && TempMaxPLR < 1.0) {
    9499           0 :                 TempMaxPLR += 0.1;
    9500             : 
    9501           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9502             :                     // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9503           0 :                     this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, TempMaxPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9504             :                 } else {
    9505             :                     // Algorithm Type: VRF model based on system curve
    9506           0 :                     this->CalcVRF(state, VRFTUNum, FirstHVACIteration, TempMaxPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9507             :                 }
    9508             : 
    9509           0 :                 if (VRFHeatingMode && TempOutput > QZnReq) ContinueIter = false;
    9510           0 :                 if (VRFCoolingMode && TempOutput < QZnReq) ContinueIter = false;
    9511             :             }
    9512           0 :             TempMinPLR = TempMaxPLR;
    9513           0 :             ContinueIter = true;
    9514           0 :             while (ContinueIter && TempMinPLR > 0.0) {
    9515           0 :                 TempMaxPLR = TempMinPLR;
    9516           0 :                 TempMinPLR -= 0.01;
    9517             : 
    9518           0 :                 if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9519             :                     // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9520           0 :                     this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, TempMinPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9521             :                 } else {
    9522             :                     // Algorithm Type: VRF model based on system curve
    9523           0 :                     this->CalcVRF(state, VRFTUNum, FirstHVACIteration, TempMinPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9524             :                 }
    9525             : 
    9526           0 :                 if (VRFHeatingMode && TempOutput < QZnReq) ContinueIter = false;
    9527           0 :                 if (VRFCoolingMode && TempOutput > QZnReq) ContinueIter = false;
    9528             :             }
    9529           0 :             General::SolveRoot(state, ErrorTol, MaxIte, SolFla, PartLoadRatio, f, TempMinPLR, TempMaxPLR);
    9530           0 :             if (SolFla == -1) {
    9531           0 :                 if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
    9532           0 :                     if (this->IterLimitExceeded == 0) {
    9533           0 :                         ShowWarningMessage(state, DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name + "\"");
    9534           0 :                         ShowContinueError(
    9535           0 :                             state, format(" Iteration limit exceeded calculating terminal unit part-load ratio, maximum iterations = {}", MaxIte));
    9536           0 :                         ShowContinueErrorTimeStamp(state, format(" Part-load ratio returned = {:.3R}", PartLoadRatio));
    9537             : 
    9538           0 :                         if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
    9539             :                             // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
    9540           0 :                             this->CalcVRF_FluidTCtrl(
    9541             :                                 state, VRFTUNum, FirstHVACIteration, PartLoadRatio, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9542             :                         } else {
    9543             :                             // Algorithm Type: VRF model based on system curve
    9544           0 :                             this->CalcVRF(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
    9545             :                         }
    9546             : 
    9547           0 :                         ShowContinueError(state, format(" Load requested = {:.5T}, Load delivered = {:.5T}", QZnReq, TempOutput));
    9548           0 :                         ShowRecurringWarningErrorAtEnd(state,
    9549           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9550             :                                                            "\" -- Terminal unit Iteration limit exceeded error continues...",
    9551             :                                                        this->IterLimitExceeded);
    9552             :                     } else {
    9553           0 :                         ShowRecurringWarningErrorAtEnd(state,
    9554           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9555             :                                                            "\" -- Terminal unit Iteration limit exceeded error continues...",
    9556             :                                                        this->IterLimitExceeded);
    9557             :                     }
    9558             :                 }
    9559           0 :             } else if (SolFla == -2) {
    9560           0 :                 if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
    9561           0 :                     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FirstIterfailed == 0) {
    9562           0 :                         ShowWarningMessage(state, DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name + "\"");
    9563           0 :                         ShowContinueError(state, "Terminal unit part-load ratio calculation failed: PLR limits of 0 to 1 exceeded");
    9564           0 :                         ShowContinueError(state, "Please fill out a bug report and forward to the EnergyPlus support group.");
    9565           0 :                         ShowContinueErrorTimeStamp(state, "");
    9566           0 :                         if (state.dataGlobal->WarmupFlag) ShowContinueError(state, "Error occurred during warmup days.");
    9567           0 :                         ShowRecurringWarningErrorAtEnd(state,
    9568           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9569             :                                                            "\" -- Terminal unit part-load ratio limits of 0 to 1 exceeded error continues...",
    9570             :                                                        this->FirstIterfailed);
    9571             :                     } else {
    9572           0 :                         ShowRecurringWarningErrorAtEnd(state,
    9573           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9574             :                                                            "\" -- Terminal unit part-load ratio limits of 0 to 1 exceeded error continues...",
    9575           0 :                                                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FirstIterfailed);
    9576             :                     }
    9577             :                 }
    9578           0 :                 PartLoadRatio = max(MinPLF, std::abs(QZnReq - NoCompOutput) / std::abs(FullOutput - NoCompOutput));
    9579             :             }
    9580      123186 :         } else if (SolFla == -2) {
    9581           0 :             if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
    9582           0 :                 if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FirstIterfailed == 0) {
    9583           0 :                     ShowWarningMessage(state, DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name + "\"");
    9584           0 :                     ShowContinueError(state, "Terminal unit part-load ratio calculation failed: PLR limits of 0 to 1 exceeded");
    9585           0 :                     ShowContinueError(state, "Please fill out a bug report and forward to the EnergyPlus support group.");
    9586           0 :                     ShowContinueErrorTimeStamp(state, "");
    9587           0 :                     if (state.dataGlobal->WarmupFlag) ShowContinueError(state, "Error occurred during warmup days.");
    9588           0 :                     ShowRecurringWarningErrorAtEnd(state,
    9589           0 :                                                    DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9590             :                                                        "\" -- Terminal unit part-load ratio limits of 0 to 1 exceeded error continues...",
    9591             :                                                    this->FirstIterfailed);
    9592             :                 } else {
    9593           0 :                     ShowRecurringWarningErrorAtEnd(state,
    9594           0 :                                                    DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
    9595             :                                                        "\" -- Terminal unit part-load ratio limits of 0 to 1 exceeded error continues...",
    9596             :                                                    this->FirstIterfailed);
    9597             :                 }
    9598             :             }
    9599           0 :             if (FullOutput - NoCompOutput == 0.0) {
    9600           0 :                 PartLoadRatio = 0.0;
    9601             :             } else {
    9602           0 :                 PartLoadRatio = min(1.0, max(MinPLF, std::abs(QZnReq - NoCompOutput) / std::abs(FullOutput - NoCompOutput)));
    9603             :             }
    9604             :         }
    9605             :     }
    9606             : }
    9607             : 
    9608     1553911 : void VRFTerminalUnitEquipment::CalcVRF(EnergyPlusData &state,
    9609             :                                        int const VRFTUNum,                // Unit index in VRF terminal unit array
    9610             :                                        bool const FirstHVACIteration,     // flag for 1st HVAC iteration in the time step
    9611             :                                        Real64 const PartLoadRatio,        // compressor part load fraction
    9612             :                                        Real64 &LoadMet,                   // load met by unit (W)
    9613             :                                        Real64 &OnOffAirFlowRatio,         // ratio of ON air flow to average air flow
    9614             :                                        Real64 &SuppHeatCoilLoad,          // supplemental heating coil load (W)
    9615             :                                        Optional<Real64> LatOutputProvided // delivered latent capacity (kgWater/s)
    9616             : )
    9617             : {
    9618             : 
    9619             :     // SUBROUTINE INFORMATION:
    9620             :     //       AUTHOR         Richard Raustad
    9621             :     //       DATE WRITTEN   July 2005
    9622             :     //       MODIFIED       July 2012, Chandan Sharma - FSEC: Added zone sys avail managers
    9623             :     //       RE-ENGINEERED  na
    9624             : 
    9625             :     // PURPOSE OF THIS SUBROUTINE:
    9626             :     // Simulate the components making up the VRF terminal unit.
    9627             : 
    9628             :     // METHODOLOGY EMPLOYED:
    9629             :     // Simulates the unit components sequentially in the air flow direction.
    9630             : 
    9631             :     using DXCoils::SimDXCoil;
    9632             :     using MixedAir::SimOAMixer;
    9633             :     using SingleDuct::SimATMixer;
    9634             :     using SteamCoils::SimulateSteamCoilComponents;
    9635             :     using WaterCoils::SimulateWaterCoilComponents;
    9636             : 
    9637             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    9638             :     int VRFTUOutletNodeNum; // TU air outlet node
    9639             :     int VRFTUInletNodeNum;  // TU air inlet node
    9640             :     Real64 AirMassFlow;     // total supply air mass flow [m3/s]
    9641             :     int OpMode;             // fan operating mode, DataHVACGlobals::CycFanCycCoil or DataHVACGlobals::ContFanCycCoil
    9642             :     int VRFCond;            // index to VRF condenser
    9643     1553911 :     Real64 SpecHumOut(0.0); // specific humidity ratio at outlet node
    9644     1553911 :     Real64 SpecHumIn(0.0);  // specific humidity ratio at inlet node
    9645             :     int TUListIndex;        // index to TU list for this VRF system
    9646             :     int IndexToTUInTUList;  // index to TU in specific list for the VRF system
    9647     1553911 :     auto &ATMixOutNode = state.dataHVACVarRefFlow->ATMixOutNode;
    9648             :     int ZoneNode; // Zone node of VRFTU is serving
    9649             : 
    9650     1553911 :     VRFCond = this->VRFSysNum;
    9651     1553911 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
    9652     1553911 :     IndexToTUInTUList = this->IndexToTUInTUList;
    9653     1553911 :     VRFTUOutletNodeNum = this->VRFTUOutletNodeNum;
    9654     1553911 :     VRFTUInletNodeNum = this->VRFTUInletNodeNum;
    9655     1553911 :     OpMode = this->OpMode;
    9656     1553911 :     ZoneNode = this->ZoneAirNode;
    9657             : 
    9658             :     // Set inlet air mass flow rate based on PLR and compressor on/off air flow rates
    9659     1553911 :     SetAverageAirFlow(state, VRFTUNum, PartLoadRatio, OnOffAirFlowRatio);
    9660             : 
    9661     1553911 :     AirMassFlow = state.dataLoopNodes->Node(VRFTUInletNodeNum).MassFlowRate;
    9662     1553911 :     if (this->ATMixerExists) {
    9663             :         // There is an air terminal mixer
    9664      189030 :         ATMixOutNode = this->ATMixerOutNode;
    9665      189030 :         if (this->ATMixerType == DataHVACGlobals::ATMixer_InletSide) { // if there is an inlet side air terminal mixer
    9666             :             // set the primary air inlet mass flow rate
    9667      116112 :             state.dataLoopNodes->Node(this->ATMixerPriNode).MassFlowRate =
    9668      116112 :                 min(state.dataLoopNodes->Node(this->ATMixerPriNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(VRFTUInletNodeNum).MassFlowRate);
    9669             :             // now calculate the the mixer outlet air conditions (and the secondary air inlet flow rate). The mixer outlet flow rate has already
    9670             :             // been set above (it is the "inlet" node flow rate)
    9671      116112 :             SimATMixer(state, this->ATMixerName, FirstHVACIteration, this->ATMixerIndex);
    9672             :         }
    9673             :     } else {
    9674             :         // ATMixOutNode = 0;
    9675     1364881 :         if (this->OAMixerUsed) SimOAMixer(state, this->OAMixerName, FirstHVACIteration, this->OAMixerIndex);
    9676             :     }
    9677             :     // if blow through, simulate fan then coils
    9678     1553911 :     if (this->FanPlace == DataHVACGlobals::BlowThru) {
    9679      190963 :         if (this->fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    9680           0 :             if (OnOffAirFlowRatio > 0.0) {
    9681           0 :                 state.dataHVACFan->fanObjs[this->FanIndex]->simulate(
    9682           0 :                     state, _, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
    9683             :             } else {
    9684           0 :                 state.dataHVACFan->fanObjs[this->FanIndex]->simulate(
    9685           0 :                     state, PartLoadRatio, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
    9686             :             }
    9687             :         } else {
    9688      954815 :             Fans::SimulateFanComponents(state,
    9689             :                                         "",
    9690             :                                         FirstHVACIteration,
    9691             :                                         this->FanIndex,
    9692      190963 :                                         state.dataHVACVarRefFlow->FanSpeedRatio,
    9693      190963 :                                         state.dataHVACGlobal->ZoneCompTurnFansOn,
    9694      381926 :                                         state.dataHVACGlobal->ZoneCompTurnFansOff);
    9695             :         }
    9696             :     }
    9697             : 
    9698     1553911 :     if (this->CoolingCoilPresent) {
    9699             :         // above condition for heat pump mode, below condition for heat recovery mode
    9700     3233043 :         if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) ||
    9701      876204 :             (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
    9702      193012 :              state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList))) {
    9703     2987820 :             SimDXCoil(state,
    9704             :                       "",
    9705             :                       DataHVACGlobals::CompressorOperation::On,
    9706             :                       FirstHVACIteration,
    9707             :                       this->CoolCoilIndex,
    9708             :                       OpMode,
    9709             :                       PartLoadRatio,
    9710             :                       OnOffAirFlowRatio,
    9711             :                       _,
    9712      995940 :                       state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond),
    9713     1991880 :                       state.dataHVACVarRefFlow->VRF(this->VRFSysNum).VRFCondCyclingRatio);
    9714             :         } else { // cooling coil is off
    9715      557971 :             SimDXCoil(state, "", DataHVACGlobals::CompressorOperation::Off, FirstHVACIteration, this->CoolCoilIndex, OpMode, 0.0, OnOffAirFlowRatio);
    9716             :         }
    9717     1553911 :         state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = state.dataAirLoop->LoopDXCoilRTF;
    9718             :     } else {
    9719           0 :         state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = 0.0;
    9720             :     }
    9721             : 
    9722     1553911 :     if (this->HeatingCoilPresent) {
    9723             :         // above condition for heat pump mode, below condition for heat recovery mode
    9724     3169733 :         if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) ||
    9725     1402787 :             (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
    9726      193012 :              state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList))) {
    9727     1218141 :             SimDXCoil(state,
    9728             :                       "",
    9729             :                       DataHVACGlobals::CompressorOperation::Off,
    9730             :                       FirstHVACIteration,
    9731             :                       this->HeatCoilIndex,
    9732             :                       OpMode,
    9733             :                       PartLoadRatio,
    9734             :                       OnOffAirFlowRatio,
    9735             :                       _,
    9736      812094 :                       state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond));
    9737             :         } else {
    9738     2295728 :             SimDXCoil(
    9739     1147864 :                 state, "", DataHVACGlobals::CompressorOperation::Off, FirstHVACIteration, this->HeatCoilIndex, OpMode, 0.0, OnOffAirFlowRatio, _);
    9740             :         }
    9741     1553911 :         state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = state.dataAirLoop->LoopDXCoilRTF;
    9742             :     } else {
    9743           0 :         state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = 0.0;
    9744             :     }
    9745             : 
    9746             :     // if draw through, simulate coils then fan
    9747     1553911 :     if (this->FanPlace == DataHVACGlobals::DrawThru) {
    9748     1336235 :         if (this->fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    9749      758612 :             if (OnOffAirFlowRatio > 0.0) {
    9750     2246340 :                 state.dataHVACFan->fanObjs[this->FanIndex]->simulate(
    9751     1497560 :                     state, _, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
    9752             :             } else {
    9753       29496 :                 state.dataHVACFan->fanObjs[this->FanIndex]->simulate(
    9754       19664 :                     state, PartLoadRatio, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
    9755             :             }
    9756             : 
    9757             :         } else {
    9758     2888115 :             Fans::SimulateFanComponents(state,
    9759             :                                         "",
    9760             :                                         FirstHVACIteration,
    9761             :                                         this->FanIndex,
    9762      577623 :                                         state.dataHVACVarRefFlow->FanSpeedRatio,
    9763      577623 :                                         state.dataHVACGlobal->ZoneCompTurnFansOn,
    9764     1155246 :                                         state.dataHVACGlobal->ZoneCompTurnFansOff);
    9765             :         }
    9766             :     }
    9767             : 
    9768             :     // track fan power per terminal unit for calculating COP
    9769     1553911 :     if (this->fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
    9770      758612 :         this->FanPower = state.dataHVACFan->fanObjs[this->FanIndex]->fanPower();
    9771             :     } else {
    9772      795299 :         this->FanPower = Fans::GetFanPower(state, this->FanIndex);
    9773             :     }
    9774             : 
    9775             :     // run supplemental heating coil
    9776     1553911 :     if (this->SuppHeatingCoilPresent) {
    9777      157124 :         Real64 SuppPLR = this->SuppHeatPartLoadRatio;
    9778      157124 :         this->CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, SuppPLR, SuppHeatCoilLoad);
    9779      157124 :         if ((state.dataLoopNodes->Node(this->SuppHeatCoilAirOutletNode).Temp > this->MaxSATFromSuppHeatCoil) && SuppPLR > 0.0) {
    9780             :             // adjust the heating load to maximum allowed
    9781           0 :             Real64 MaxHeatCoilLoad = this->HeatingCoilCapacityLimit(state, this->SuppHeatCoilAirInletNode, this->MaxSATFromSuppHeatCoil);
    9782           0 :             this->CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, SuppPLR, MaxHeatCoilLoad);
    9783           0 :             SuppHeatCoilLoad = MaxHeatCoilLoad;
    9784             :         }
    9785             :     }
    9786             : 
    9787     1553911 :     Real64 LatentLoadMet = 0.0; // latent load deleivered [kgWater/s]
    9788     1553911 :     Real64 TempOut = 0.0;
    9789     1553911 :     Real64 TempIn = 0.0;
    9790     1553911 :     if (this->ATMixerExists) {
    9791      189030 :         if (this->ATMixerType == DataHVACGlobals::ATMixer_SupplySide) {
    9792             :             // Air terminal supply side mixer, calculate supply side mixer output
    9793       72918 :             SimATMixer(state, this->ATMixerName, FirstHVACIteration, this->ATMixerIndex);
    9794       72918 :             TempOut = state.dataLoopNodes->Node(ATMixOutNode).Temp;
    9795       72918 :             SpecHumOut = state.dataLoopNodes->Node(ATMixOutNode).HumRat;
    9796       72918 :             AirMassFlow = state.dataLoopNodes->Node(ATMixOutNode).MassFlowRate;
    9797             :         } else {
    9798             :             // Air terminal inlet side mixer
    9799      116112 :             TempOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).Temp;
    9800      116112 :             SpecHumOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).HumRat;
    9801             :         }
    9802      189030 :         TempIn = state.dataLoopNodes->Node(ZoneNode).Temp;
    9803      189030 :         SpecHumIn = state.dataLoopNodes->Node(ZoneNode).HumRat;
    9804             :     } else {
    9805     1364881 :         TempOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).Temp;
    9806     1364881 :         SpecHumOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).HumRat;
    9807     1364881 :         if (ZoneNode > 0) {
    9808     1338168 :             TempIn = state.dataLoopNodes->Node(ZoneNode).Temp;
    9809     1338168 :             SpecHumIn = state.dataLoopNodes->Node(ZoneNode).HumRat;
    9810             :         } else {
    9811       26713 :             TempIn = state.dataLoopNodes->Node(VRFTUInletNodeNum).Temp;
    9812       26713 :             SpecHumIn = state.dataLoopNodes->Node(VRFTUInletNodeNum).HumRat;
    9813             :         }
    9814             :     }
    9815             :     // calculate sensible load met using delta enthalpy
    9816     1553911 :     LoadMet = AirMassFlow * PsyDeltaHSenFnTdb2W2Tdb1W1(TempOut, SpecHumOut, TempIn, SpecHumIn); // sensible {W}
    9817     1553911 :     LatentLoadMet = AirMassFlow * (SpecHumOut - SpecHumIn);                                     // latent {kgWater/s}
    9818     1553911 :     if (present(LatOutputProvided)) {
    9819             :         //   CR9155 Remove specific humidity calculations
    9820      172761 :         LatOutputProvided = LatentLoadMet;
    9821             :     }
    9822     1553911 : }
    9823             : 
    9824      231306 : void ReportVRFTerminalUnit(EnergyPlusData &state, int const VRFTUNum) // index to VRF terminal unit
    9825             : {
    9826             : 
    9827             :     // SUBROUTINE INFORMATION:
    9828             :     //       AUTHOR         Richard Raustad, FSEC
    9829             :     //       DATE WRITTEN   August 2010
    9830             :     //       MODIFIED       na
    9831             :     //       RE-ENGINEERED  na
    9832             : 
    9833             :     // PURPOSE OF THIS SUBROUTINE:
    9834             :     // This subroutine updates the report variables for the VRF Terminal Units.
    9835             : 
    9836             :     using namespace DataSizing;
    9837             : 
    9838             :     int DXCoolingCoilIndex;      // - index to DX cooling coil
    9839             :     int DXHeatingCoilIndex;      // - index to DX heating coil
    9840             :     Real64 TotalConditioning;    // - sum of sensible and latent rates
    9841             :     Real64 SensibleConditioning; // - sensible rate
    9842             :     Real64 LatentConditioning;   // - latent rate
    9843             :     Real64 ReportingConstant;    // - used to convert watts to joules
    9844             :     int VRFCond;                 // - index to VRF condenser
    9845             :     int TUListIndex;             // - index to terminal unit list
    9846             :     int IndexToTUInTUList;       // - index to the TU in the list
    9847             :     bool HRHeatRequestFlag;      // - indicates TU could be in heat mode
    9848             :     bool HRCoolRequestFlag;      // - indicates TU could be in cool mode
    9849             : 
    9850      231306 :     DXCoolingCoilIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolCoilIndex;
    9851      231306 :     DXHeatingCoilIndex = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatCoilIndex;
    9852      231306 :     VRFCond = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
    9853      231306 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
    9854      231306 :     IndexToTUInTUList = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).IndexToTUInTUList;
    9855      231306 :     HRHeatRequestFlag = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList);
    9856      231306 :     HRCoolRequestFlag = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList);
    9857      231306 :     ReportingConstant = state.dataHVACGlobal->TimeStepSys * DataGlobalConstants::SecInHour;
    9858             : 
    9859             :     // account for terminal unit parasitic On/Off power use
    9860             :     // account for heat recovery first since these flags will be FALSE otherwise, each TU may have different operating mode
    9861             : 
    9862      231306 :     if (HRCoolRequestFlag) {
    9863       22247 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    9864       22247 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower =
    9865       44494 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElec * state.dataHVACVarRefFlow->LoopDXCoolCoilRTF +
    9866       22247 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec * (1.0 - state.dataHVACVarRefFlow->LoopDXCoolCoilRTF);
    9867       22247 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9868       22247 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9869       22247 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = 0.0;
    9870       22247 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption = 0.0;
    9871             :         } else {
    9872             :             // cooling parasitic power report variable is not even available when there is no cooling coil, report for heating
    9873           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9874           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9875           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9876             :         }
    9877      209059 :     } else if (HRHeatRequestFlag) {
    9878       14449 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent) {
    9879       14449 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = 0.0;
    9880       14449 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption = 0.0;
    9881       14449 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower =
    9882       28898 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElec * state.dataHVACVarRefFlow->LoopDXHeatCoilRTF +
    9883       14449 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec * (1.0 - state.dataHVACVarRefFlow->LoopDXHeatCoilRTF);
    9884       14449 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9885       14449 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9886             :         } else {
    9887             :             // heating parasitic power report variable is not even available when there is no heating coil, report for cooling
    9888           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9889           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9890           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9891             :         }
    9892      402039 :     } else if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) ||
    9893      126902 :                (!state.dataHVACVarRefFlow->HeatingLoad(VRFCond) &&
    9894       27921 :                 state.dataHVACVarRefFlow->LastModeCooling(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum))) {
    9895      108448 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    9896      108448 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower =
    9897      216896 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElec * state.dataHVACVarRefFlow->LoopDXCoolCoilRTF +
    9898      108448 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec * (1.0 - state.dataHVACVarRefFlow->LoopDXCoolCoilRTF);
    9899      108448 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9900      108448 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9901      108448 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = 0.0;
    9902      108448 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption = 0.0;
    9903             :         } else {
    9904             :             // cooling parasitic power report variable is not even available when there is no cooling coil, report for heating
    9905           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9906           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9907           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9908             :         }
    9909      187426 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) ||
    9910       30204 :                (!state.dataHVACVarRefFlow->CoolingLoad(VRFCond) &&
    9911       15102 :                 state.dataHVACVarRefFlow->LastModeHeating(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum))) {
    9912       86162 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent) {
    9913       86162 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = 0.0;
    9914       86162 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption = 0.0;
    9915       86162 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower =
    9916      172324 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElec * state.dataHVACVarRefFlow->LoopDXHeatCoilRTF +
    9917       86162 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec * (1.0 - state.dataHVACVarRefFlow->LoopDXHeatCoilRTF);
    9918       86162 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9919       86162 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9920             :         } else {
    9921             :             // heating parasitic power report variable is not even available when there is no heating coil, report for cooling
    9922           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9923           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9924           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9925             :         }
    9926             :     } else {
    9927             :         // happens when there is no cooling or heating load
    9928           0 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
    9929             :             // report all for heating
    9930           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9931           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9932           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9933           0 :         } else if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).HeatingCoilPresent) {
    9934             :             // report all for cooling
    9935           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec;
    9936           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9937           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9938             :         } else {
    9939             :             // split parasitic between both reporting variables
    9940           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec / 2.0;
    9941           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecCoolConsumption =
    9942           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticCoolElecPower * ReportingConstant;
    9943           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticOffElec / 2.0;
    9944           0 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticElecHeatConsumption =
    9945           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ParasiticHeatElecPower * ReportingConstant;
    9946             :         }
    9947             :     }
    9948             : 
    9949      231306 :     SensibleConditioning = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TerminalUnitSensibleRate;
    9950      231306 :     LatentConditioning = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TerminalUnitLatentRate;
    9951      231306 :     Real64 TempOut = 0.0;
    9952      231306 :     Real64 TempIn = 0.0;
    9953      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerExists) {
    9954       15580 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerType == DataHVACGlobals::ATMixer_SupplySide) {
    9955             :             // Air terminal supply side mixer
    9956        6232 :             TempOut = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ATMixerOutNode).Temp;
    9957        6232 :             TempIn = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode).Temp;
    9958             :         } else {
    9959             :             // Air terminal inlet side mixer
    9960        9348 :             TempOut = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum).Temp;
    9961        9348 :             TempIn = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneAirNode).Temp;
    9962             :         }
    9963             :     } else {
    9964      215726 :         TempOut = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum).Temp;
    9965      215726 :         TempIn = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum).Temp;
    9966             :     }
    9967             :     // latent heat vaporization/condensation used in moist air psychometrics
    9968      231306 :     Real64 const H2OHtOfVap = PsyHgAirFnWTdb(0.0, TempOut);
    9969             :     // convert latent in kg/s to watts
    9970      231306 :     TotalConditioning = SensibleConditioning + (LatentConditioning * H2OHtOfVap);
    9971             : 
    9972      231306 :     if (TotalConditioning <= 0.0) {
    9973      137812 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalCoolingRate = std::abs(TotalConditioning);
    9974      137812 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalHeatingRate = 0.0;
    9975             :     } else {
    9976       93494 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalCoolingRate = 0.0;
    9977       93494 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalHeatingRate = TotalConditioning;
    9978             :     }
    9979      231306 :     if (SensibleConditioning <= 0.0) {
    9980      141907 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleCoolingRate = std::abs(SensibleConditioning);
    9981      141907 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleHeatingRate = 0.0;
    9982             :     } else {
    9983       89399 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleCoolingRate = 0.0;
    9984       89399 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleHeatingRate = SensibleConditioning;
    9985             :     }
    9986      231306 :     if (LatentConditioning <= 0.0) {
    9987      181769 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentCoolingRate = std::abs(LatentConditioning) * H2OHtOfVap;
    9988      181769 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentHeatingRate = 0.0;
    9989             :     } else {
    9990       49537 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentCoolingRate = 0.0;
    9991       49537 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentHeatingRate = LatentConditioning * H2OHtOfVap;
    9992             :     }
    9993      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalCoolingEnergy = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalCoolingRate * ReportingConstant;
    9994      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleCoolingEnergy =
    9995      231306 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleCoolingRate * ReportingConstant;
    9996      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentCoolingEnergy = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentCoolingRate * ReportingConstant;
    9997      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalHeatingEnergy = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).TotalHeatingRate * ReportingConstant;
    9998      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleHeatingEnergy =
    9999      231306 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SensibleHeatingRate * ReportingConstant;
   10000      231306 :     state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentHeatingEnergy = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).LatentHeatingRate * ReportingConstant;
   10001             : 
   10002      231306 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).firstPass) {
   10003         110 :         if (!state.dataHVACVarRefFlow->MySizeFlag(VRFTUNum)) {
   10004          56 :             DataSizing::resetHVACSizingGlobals(state, state.dataSize->CurZoneEqNum, 0, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).firstPass);
   10005             :         }
   10006             :     }
   10007             : 
   10008             :     // reset to 1 in case blow through fan configuration (fan resets to 1, but for blow thru fans coil sets back down < 1)
   10009      231306 :     state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
   10010      231306 : }
   10011             : 
   10012       49389 : void ReportVRFCondenser(EnergyPlusData &state, int const VRFCond) // index to VRF condensing unit
   10013             : {
   10014             : 
   10015             :     // SUBROUTINE INFORMATION:
   10016             :     //       AUTHOR         Richard Raustad, FSEC
   10017             :     //       DATE WRITTEN   August 2010
   10018             :     //       MODIFIED       na
   10019             :     //       RE-ENGINEERED  na
   10020             : 
   10021             :     // PURPOSE OF THIS SUBROUTINE:
   10022             :     // This subroutine updates the report variables for the VRF Condenser.
   10023             : 
   10024             :     Real64 ReportingConstant; // - conversion constant for energy
   10025             : 
   10026       49389 :     ReportingConstant = state.dataHVACGlobal->TimeStepSys * DataGlobalConstants::SecInHour;
   10027             : 
   10028             :     //   calculate VRF condenser power/energy use
   10029       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).CoolElecConsumption = state.dataHVACVarRefFlow->VRF(VRFCond).ElecCoolingPower * ReportingConstant;
   10030       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).HeatElecConsumption = state.dataHVACVarRefFlow->VRF(VRFCond).ElecHeatingPower * ReportingConstant;
   10031             : 
   10032       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).DefrostConsumption = state.dataHVACVarRefFlow->VRF(VRFCond).DefrostPower * ReportingConstant;
   10033       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).BasinHeaterConsumption = state.dataHVACVarRefFlow->VRF(VRFCond).BasinHeaterPower * ReportingConstant;
   10034             : 
   10035       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpElecConsumption =
   10036       49389 :         state.dataHVACVarRefFlow->VRF(VRFCond).EvapCondPumpElecPower * ReportingConstant;
   10037       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).CrankCaseHeaterElecConsumption =
   10038       49389 :         state.dataHVACVarRefFlow->VRF(VRFCond).CrankCaseHeaterPower * ReportingConstant;
   10039             : 
   10040       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).QCondEnergy = state.dataHVACVarRefFlow->VRF(VRFCond).QCondenser * ReportingConstant;
   10041       49389 :     state.dataHVACVarRefFlow->VRF(VRFCond).VRFHeatEnergyRec = state.dataHVACVarRefFlow->VRF(VRFCond).VRFHeatRec * ReportingConstant;
   10042       49389 : }
   10043             : 
   10044        3771 : void UpdateVRFCondenser(EnergyPlusData &state, int const VRFCond) // index to VRF condensing unit
   10045             : {
   10046             : 
   10047             :     // SUBROUTINE INFORMATION:
   10048             :     //       AUTHOR         Richard Raustad, FSEC
   10049             :     //       DATE WRITTEN   May 2012
   10050             :     //       MODIFIED       na
   10051             :     //       RE-ENGINEERED  na
   10052             : 
   10053             :     // PURPOSE OF THIS SUBROUTINE:
   10054             :     // This subroutine updates the node data for the VRF Condenser.
   10055             : 
   10056             :     int CondenserOutletNode; // - outlet node for VRF water-cooled condenser
   10057             : 
   10058        3771 :     CondenserOutletNode = state.dataHVACVarRefFlow->VRF(VRFCond).CondenserOutletNodeNum;
   10059             : 
   10060        3771 :     state.dataLoopNodes->Node(CondenserOutletNode).Temp = state.dataHVACVarRefFlow->VRF(VRFCond).CondenserSideOutletTemp;
   10061             : 
   10062        3771 :     state.dataLoopNodes->Node(CondenserOutletNode).MassFlowRate = state.dataHVACVarRefFlow->CondenserWaterMassFlowRate;
   10063        3771 :     state.dataLoopNodes->Node(CondenserOutletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(CondenserOutletNode).MassFlowRateMaxAvail;
   10064        3771 :     state.dataLoopNodes->Node(CondenserOutletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(CondenserOutletNode).MassFlowRateMinAvail;
   10065        3771 : }
   10066             : 
   10067           2 : void isVRFCoilPresent(EnergyPlusData &state, std::string_view VRFTUName, bool &CoolCoilPresent, bool &HeatCoilPresent)
   10068             : {
   10069             : 
   10070           2 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10071           0 :         GetVRFInput(state);
   10072           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10073             :     }
   10074             : 
   10075           4 :     int WhichVRFTU = UtilityRoutines::FindItemInList(
   10076           6 :         VRFTUName, state.dataHVACVarRefFlow->VRFTU, &VRFTerminalUnitEquipment::Name, state.dataHVACVarRefFlow->NumVRFTU);
   10077           2 :     if (WhichVRFTU != 0) {
   10078           2 :         CoolCoilPresent = state.dataHVACVarRefFlow->VRFTU(WhichVRFTU).CoolingCoilPresent;
   10079           2 :         HeatCoilPresent = state.dataHVACVarRefFlow->VRFTU(WhichVRFTU).HeatingCoilPresent;
   10080             :     } else {
   10081           0 :         ShowSevereError(state, "isVRFCoilPresent: Could not find VRF TU = \"" + std::string{VRFTUName} + "\"");
   10082             :     }
   10083           2 : }
   10084             : 
   10085             : //        End of Reporting subroutines for the Module
   10086             : // *****************************************************************************
   10087             : 
   10088             : // Utility subroutines for the Module
   10089             : 
   10090     3788995 : void SetAverageAirFlow(EnergyPlusData &state,
   10091             :                        int const VRFTUNum,         // Unit index
   10092             :                        Real64 const PartLoadRatio, // unit part load ratio
   10093             :                        Real64 &OnOffAirFlowRatio   // ratio of compressor ON airflow to average airflow over timestep
   10094             : )
   10095             : {
   10096             : 
   10097             :     // SUBROUTINE INFORMATION:
   10098             :     //       AUTHOR         Richard Raustad
   10099             :     //       DATE WRITTEN   August 2010
   10100             :     //       MODIFIED       July 2012, Chandan Sharma - FSEC: Added zone sys avail managers
   10101             :     //       RE-ENGINEERED  na
   10102             : 
   10103             :     // PURPOSE OF THIS SUBROUTINE:
   10104             :     // Set the average air mass flow rates using the part load fraction of the heat pump for this time step
   10105             :     // Set OnOffAirFlowRatio to be used by DX coils
   10106             : 
   10107             :     using ScheduleManager::GetCurrentScheduleValue;
   10108             : 
   10109             :     int InletNode;                   // inlet node number
   10110             :     int OutsideAirNode;              // outside air node number
   10111             :     int AirRelNode;                  // relief air node number
   10112     3788995 :     Real64 AverageUnitMassFlow(0.0); // average supply air mass flow rate over time step
   10113     3788995 :     Real64 AverageOAMassFlow(0.0);   // average outdoor air mass flow rate over time step
   10114             : 
   10115     3788995 :     InletNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum;
   10116     3788995 :     OutsideAirNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum;
   10117     3788995 :     AirRelNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRelNodeNum;
   10118             : 
   10119     3788995 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode == DataHVACGlobals::CycFanCycCoil) {
   10120      450863 :         AverageUnitMassFlow =
   10121      450863 :             (PartLoadRatio * state.dataHVACVarRefFlow->CompOnMassFlow) + ((1 - PartLoadRatio) * state.dataHVACVarRefFlow->CompOffMassFlow);
   10122      450863 :         AverageOAMassFlow =
   10123      450863 :             (PartLoadRatio * state.dataHVACVarRefFlow->OACompOnMassFlow) + ((1 - PartLoadRatio) * state.dataHVACVarRefFlow->OACompOffMassFlow);
   10124             :     } else {
   10125     3338132 :         if (PartLoadRatio == 0.0) {
   10126             :             // set the average OA air flow to off compressor values if the compressor PartLoadRatio is zero
   10127      715917 :             AverageUnitMassFlow = state.dataHVACVarRefFlow->CompOffMassFlow;
   10128      715917 :             AverageOAMassFlow = state.dataHVACVarRefFlow->OACompOffMassFlow;
   10129             :         } else {
   10130     2622215 :             AverageUnitMassFlow = state.dataHVACVarRefFlow->CompOnMassFlow;
   10131     2622215 :             AverageOAMassFlow = state.dataHVACVarRefFlow->OACompOnMassFlow;
   10132             :         }
   10133             :     }
   10134     3788995 :     if (state.dataHVACVarRefFlow->CompOffFlowRatio > 0.0) {
   10135     3328069 :         state.dataHVACVarRefFlow->FanSpeedRatio =
   10136     3328069 :             (PartLoadRatio * state.dataHVACVarRefFlow->CompOnFlowRatio) + ((1 - PartLoadRatio) * state.dataHVACVarRefFlow->CompOffFlowRatio);
   10137             :     } else {
   10138      460926 :         state.dataHVACVarRefFlow->FanSpeedRatio = state.dataHVACVarRefFlow->CompOnFlowRatio;
   10139             :     }
   10140             : 
   10141             :     // if the terminal unit and fan are scheduled on then set flow rate
   10142    11366985 :     if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SchedPtr) > 0.0 &&
   10143     3933808 :         (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanAvailSchedPtr) > 0.0 ||
   10144     7634307 :          state.dataHVACGlobal->ZoneCompTurnFansOn) &&
   10145     3700499 :         !state.dataHVACGlobal->ZoneCompTurnFansOff) {
   10146             : 
   10147             :         // so for sure OA system TUs should use inlet node flow rate, don't overwrite inlet node flow rate
   10148             :         // could there be a reason for air loops to use inlet node flow? Possibly when VAV TUs used?
   10149     3700499 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys) state.dataLoopNodes->Node(InletNode).MassFlowRate = AverageUnitMassFlow;
   10150     3700499 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys) state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = AverageUnitMassFlow;
   10151     3700499 :         if (OutsideAirNode > 0) {
   10152     3464396 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = AverageOAMassFlow;
   10153     3464396 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRateMaxAvail = AverageOAMassFlow;
   10154     3464396 :             state.dataLoopNodes->Node(AirRelNode).MassFlowRate = AverageOAMassFlow;
   10155     3464396 :             state.dataLoopNodes->Node(AirRelNode).MassFlowRateMaxAvail = AverageOAMassFlow;
   10156             :         }
   10157     3700499 :         if (AverageUnitMassFlow > 0.0) {
   10158     3623927 :             OnOffAirFlowRatio = state.dataHVACVarRefFlow->CompOnMassFlow / AverageUnitMassFlow;
   10159             :         } else {
   10160       76572 :             OnOffAirFlowRatio = 0.0;
   10161             :         }
   10162             : 
   10163             :     } else { // terminal unit and/or fan is off
   10164             : 
   10165       88496 :         if (!state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInOASys) state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0;
   10166       88496 :         if (OutsideAirNode > 0) {
   10167       88496 :             state.dataLoopNodes->Node(OutsideAirNode).MassFlowRate = 0.0;
   10168       88496 :             state.dataLoopNodes->Node(AirRelNode).MassFlowRate = 0.0;
   10169             :         }
   10170       88496 :         OnOffAirFlowRatio = 0.0;
   10171             :     }
   10172     3788995 : }
   10173             : 
   10174       45315 : void InitializeOperatingMode(EnergyPlusData &state,
   10175             :                              bool const FirstHVACIteration, // flag for first time through HVAC systems
   10176             :                              int const VRFCond,             // Condenser Unit index
   10177             :                              int const TUListNum,           // Condenser Unit terminal unit list
   10178             :                              Real64 &OnOffAirFlowRatio      // ratio of on to off flow rate
   10179             : )
   10180             : {
   10181             : 
   10182             :     // SUBROUTINE INFORMATION:
   10183             :     //       AUTHOR         Richard Raustad
   10184             :     //       DATE WRITTEN   July 2012 (Moved from InitVRF)
   10185             :     //       MODIFIED       na
   10186             :     //       RE-ENGINEERED  na
   10187             : 
   10188             :     // PURPOSE OF THIS SUBROUTINE:
   10189             :     // Scans each zone coil and determines the load based on control
   10190             :     // Moved from Init to clean up and localize code segments
   10191             : 
   10192             :     using MixedAir::SimOAMixer;
   10193             :     using ScheduleManager::GetCurrentScheduleValue;
   10194             : 
   10195             :     Real64 ZoneDeltaT;       // zone temperature difference from setpoint
   10196             :     Real64 SPTempHi;         // thermostat setpoint high
   10197             :     Real64 SPTempLo;         // thermostat setpoint low
   10198             :     int NumTU;               // loop counter, number of TU's in list
   10199             :     int TUIndex;             // index to TU
   10200             :     int ThisZoneNum;         // index to zone number where TU is located
   10201             :     Real64 ZoneLoad;         // current zone load (W)
   10202             :     Real64 LoadToCoolingSP;  // thermostat load to cooling setpoint (W)
   10203             :     Real64 LoadToHeatingSP;  // thermostat load to heating setpoint (W)
   10204             :     Real64 TempOutput;       // terminal unit output [W]
   10205             :     Real64 SuppHeatCoilLoad; // supplemental heating coil load
   10206             : 
   10207       45315 :     state.dataHVACVarRefFlow->MaxDeltaT = 0.0;
   10208       45315 :     state.dataHVACVarRefFlow->MinDeltaT = 0.0;
   10209       45315 :     state.dataHVACVarRefFlow->NumCoolingLoads = 0;
   10210       45315 :     state.dataHVACVarRefFlow->SumCoolingLoads = 0.0;
   10211       45315 :     state.dataHVACVarRefFlow->NumHeatingLoads = 0;
   10212       45315 :     state.dataHVACVarRefFlow->SumHeatingLoads = 0.0;
   10213       45315 :     SuppHeatCoilLoad = 0.0;
   10214             : 
   10215       45315 :     state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond) = 0;
   10216       45315 :     state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond) = 0;
   10217       45315 :     state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) = 0.0;
   10218       45315 :     state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) = 0.0;
   10219       45315 :     state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = 0.0;
   10220       45315 :     state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = 0.0;
   10221       45315 :     ZoneDeltaT = 0.0;
   10222       45315 :     state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10223       45315 :     state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10224       45315 :     state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailable = false;
   10225       45315 :     state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailable = false;
   10226             :     // loop through all TU's to find operating mode. Be careful not to mix loop counters with current TU/Cond index
   10227      256144 :     for (NumTU = 1; NumTU <= state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList; ++NumTU) {
   10228             :         // make sure TU's have been sized before looping through each one of them to determine operating mode
   10229      210846 :         if (any(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TerminalUnitNotSizedYet)) break;
   10230      210829 :         TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   10231      210829 :         ThisZoneNum = state.dataHVACVarRefFlow->VRFTU(TUIndex).ZoneNum;
   10232             : 
   10233             :         //       check to see if coil is present
   10234      210829 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilPresent(NumTU)) {
   10235             :             //         now check to see if coil is scheduled off
   10236      210829 :             if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailSchPtr(NumTU)) > 0.0) {
   10237      210829 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilAvailable(NumTU) = true;
   10238             :             }
   10239             :         }
   10240             : 
   10241             :         //       check to see if coil is present
   10242      210829 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilPresent(NumTU)) {
   10243             :             //         now check to see if coil is scheduled off
   10244      210829 :             if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailSchPtr(NumTU)) > 0.0) {
   10245      210829 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilAvailable(NumTU) = true;
   10246             :             }
   10247             :         }
   10248             : 
   10249      210829 :         if (state.dataHVACVarRefFlow->VRFTU(TUIndex).isSetPointControlled) {
   10250             :             // set point temperature may only reside at the TU outlet node
   10251        3188 :             Real64 coolCoilTempSetPoint = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOutletNodeNum).TempSetPoint;
   10252        3188 :             state.dataHVACVarRefFlow->VRFTU(TUIndex).suppTempSetPoint = coolCoilTempSetPoint;
   10253        3188 :             Real64 heatCoilTempSetPoint = coolCoilTempSetPoint;
   10254             :             // adjust coil control for fan heat when set point is at outlet node
   10255        3188 :             Real64 coolfanDeltaT = 0.0;
   10256        3188 :             Real64 heatfanDeltaT = 0.0;
   10257        3188 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).FanPlace == DataHVACGlobals::DrawThru) {
   10258           0 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).fanOutletNode > 0)
   10259           0 :                     coolfanDeltaT = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).fanOutletNode).Temp -
   10260           0 :                                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).fanInletNode).Temp;
   10261             :             }
   10262        3188 :             heatfanDeltaT = coolfanDeltaT;
   10263             :             // or the set point could be placed at either or both coils, update both if necessary
   10264        3188 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolingCoilPresent) {
   10265        3188 :                 if (state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirOutNode).TempSetPoint !=
   10266             :                     DataLoopNode::SensedNodeFlagValue) {
   10267        3188 :                     coolCoilTempSetPoint = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirOutNode).TempSetPoint;
   10268             :                     //// should we adjust for fan heat or not? What if it's a mixed air SP that already adjusts for fan heat?
   10269             :                     // coolfanDeltaT = 0.0;
   10270             :                 }
   10271             :             }
   10272        3188 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatingCoilPresent) {
   10273        3188 :                 if (state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirOutNode).TempSetPoint !=
   10274             :                     DataLoopNode::SensedNodeFlagValue) {
   10275        3188 :                     heatCoilTempSetPoint = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirOutNode).TempSetPoint;
   10276             :                     //// should we adjust for fan heat or not? What if it's a mixed air SP that already adjusts for fan heat?
   10277             :                     // heatfanDeltaT = 0.0;
   10278             :                 }
   10279             :             }
   10280             :             // set a flow rate and simulate ATMixer/OASystem if needed
   10281        3188 :             if (FirstHVACIteration) {
   10282        1596 :                 SetAverageAirFlow(state, TUIndex, 1.0, OnOffAirFlowRatio);
   10283        1596 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerExists) {
   10284             :                     // There is an air terminal mixer
   10285           0 :                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerType ==
   10286             :                         DataHVACGlobals::ATMixer_InletSide) { // if there is an inlet side air terminal mixer
   10287             :                                                               // set the primary air inlet mass flow rate
   10288           0 :                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerPriNode).MassFlowRate =
   10289           0 :                             min(state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerPriNode).MassFlowRateMaxAvail,
   10290           0 :                                 state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum).MassFlowRate);
   10291             :                         // now calculate the the mixer outlet air conditions (and the secondary air inlet flow rate). The mixer outlet flow rate
   10292             :                         // has already been set above (it is the "inlet" node flow rate)
   10293           0 :                         SingleDuct::SimATMixer(state,
   10294           0 :                                                state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerName,
   10295             :                                                FirstHVACIteration,
   10296           0 :                                                state.dataHVACVarRefFlow->VRFTU(TUIndex).ATMixerIndex);
   10297             :                     }
   10298             :                 } else {
   10299             :                     // simulate OA Mixer
   10300        1596 :                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerUsed)
   10301           0 :                         SimOAMixer(state,
   10302           0 :                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerName,
   10303             :                                    FirstHVACIteration,
   10304           0 :                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerIndex);
   10305             :                 }
   10306             :             }
   10307             :             // identify a coil inlet temperature
   10308        3188 :             if (state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolingCoilPresent) {
   10309        3188 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeT =
   10310        3188 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirInNode).Temp;
   10311        3188 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeW =
   10312        3188 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).coolCoilAirInNode).HumRat;
   10313             :             } else {
   10314           0 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeT =
   10315           0 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirInNode).Temp;
   10316           0 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeW =
   10317           0 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).heatCoilAirInNode).HumRat;
   10318             :             }
   10319        3188 :             Real64 coilInletTemp = state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeT;
   10320        3188 :             Real64 coilInletHumRat = state.dataHVACVarRefFlow->VRFTU(TUIndex).coilInNodeW;
   10321        3188 :             Real64 coilInletMassFlow = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum).MassFlowRate;
   10322        3188 :             state.dataHVACVarRefFlow->VRFTU(TUIndex).coolSPActive = false;
   10323        3188 :             state.dataHVACVarRefFlow->VRFTU(TUIndex).heatSPActive = false;
   10324             : 
   10325        3188 :             if ((heatCoilTempSetPoint - coilInletTemp - heatfanDeltaT) > DataHVACGlobals::SmallTempDiff) { // heating
   10326        1366 :                 Real64 CpAirIn = Psychrometrics::PsyCpAirFnW(coilInletHumRat);
   10327        1366 :                 ZoneLoad = coilInletMassFlow * CpAirIn * (heatCoilTempSetPoint - coilInletTemp - heatfanDeltaT);
   10328        1366 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).heatSPActive = true;
   10329        1366 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).heatLoadToSP = ZoneLoad;
   10330        1366 :                 ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10331        1366 :                 state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += ZoneLoad;
   10332        1366 :                 state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), -1.0);
   10333        1366 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilTempSetPoint = heatCoilTempSetPoint - heatfanDeltaT;
   10334        1822 :             } else if ((coilInletTemp - coolCoilTempSetPoint - coolfanDeltaT) > DataHVACGlobals::SmallTempDiff) { // cooling
   10335        1808 :                 Real64 CpAirIn = Psychrometrics::PsyCpAirFnW(coilInletHumRat);
   10336        1808 :                 ZoneLoad = coilInletMassFlow * CpAirIn * (coolCoilTempSetPoint - coilInletTemp - coolfanDeltaT);
   10337        1808 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coolSPActive = true;
   10338        1808 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coolLoadToSP = ZoneLoad;
   10339        1808 :                 ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10340        1808 :                 state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += ZoneLoad;
   10341        1808 :                 state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), 1.0);
   10342        1808 :                 state.dataHVACVarRefFlow->VRFTU(TUIndex).coilTempSetPoint = coolCoilTempSetPoint - coolfanDeltaT;
   10343             :             }
   10344             :         } else { // else is not set point controlled
   10345             :             //     Constant fan systems are tested for ventilation load to determine if load to be met changes.
   10346             :             //     more logic may be needed here, what is the OA flow rate, was last mode heating or cooling, what control is used, etc...
   10347             : 
   10348      207641 :             getVRFTUZoneLoad(state, TUIndex, ZoneLoad, LoadToHeatingSP, LoadToCoolingSP, true);
   10349             : 
   10350      207641 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority == ThermostatCtrlType::ThermostatOffsetPriority) {
   10351             :                 //         for TSTATPriority, just check difference between zone temp and thermostat setpoint
   10352           0 :                 if (ThisZoneNum > 0) {
   10353           0 :                     auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ThisZoneNum);
   10354           0 :                     SPTempHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ThisZoneNum);
   10355           0 :                     SPTempLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ThisZoneNum);
   10356             : 
   10357           0 :                     switch (state.dataHeatBalFanSys->TempControlType(ThisZoneNum)) {
   10358           0 :                     case DataHVACGlobals::ThermostatType::Uncontrolled:
   10359             :                         // MaxDeltaT denotes cooling, MinDeltaT denotes heating
   10360           0 :                         break;
   10361           0 :                     case DataHVACGlobals::ThermostatType::SingleHeating:
   10362             :                         // if heating load, ZoneDeltaT will be negative
   10363           0 :                         ZoneDeltaT = min(0.0, thisZoneHB.ZT - SPTempLo);
   10364           0 :                         state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), ZoneDeltaT);
   10365           0 :                         break;
   10366           0 :                     case DataHVACGlobals::ThermostatType::SingleCooling:
   10367             :                         // if cooling load, ZoneDeltaT will be positive
   10368           0 :                         ZoneDeltaT = max(0.0, thisZoneHB.ZT - SPTempHi);
   10369           0 :                         state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT);
   10370           0 :                         break;
   10371           0 :                     case DataHVACGlobals::ThermostatType::SingleHeatCool:
   10372           0 :                         ZoneDeltaT = thisZoneHB.ZT - SPTempHi; //- SPTempHi and SPTempLo are same value
   10373           0 :                         if (ZoneDeltaT > 0.0) {
   10374           0 :                             state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT);
   10375             :                         } else {
   10376           0 :                             state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), ZoneDeltaT);
   10377             :                         }
   10378           0 :                         break;
   10379           0 :                     case DataHVACGlobals::ThermostatType::DualSetPointWithDeadBand:
   10380           0 :                         if (thisZoneHB.ZT - SPTempHi > 0.0) {
   10381           0 :                             ZoneDeltaT = max(0.0, thisZoneHB.ZT - SPTempHi);
   10382           0 :                             state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) = max(state.dataHVACVarRefFlow->MaxDeltaT(VRFCond), ZoneDeltaT);
   10383           0 :                         } else if (SPTempLo - thisZoneHB.ZT > 0.0) {
   10384           0 :                             ZoneDeltaT = min(0.0, thisZoneHB.ZT - SPTempLo);
   10385           0 :                             state.dataHVACVarRefFlow->MinDeltaT(VRFCond) = min(state.dataHVACVarRefFlow->MinDeltaT(VRFCond), ZoneDeltaT);
   10386             :                         }
   10387           0 :                         break;
   10388           0 :                     default:
   10389           0 :                         break;
   10390             :                     }
   10391             :                 }
   10392      211411 :             } else if (state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority == ThermostatCtrlType::LoadPriority ||
   10393        3770 :                        state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority == ThermostatCtrlType::ZonePriority) {
   10394      203871 :                 if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OpMode == DataHVACGlobals::ContFanCycCoil) {
   10395      162085 :                     SetCompFlowRate(state, TUIndex, VRFCond);
   10396             : 
   10397      162085 :                     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
   10398             :                         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   10399       58515 :                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF_FluidTCtrl(
   10400             :                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10401             :                     } else {
   10402             :                         // Algorithm Type: VRF model based on system curve
   10403      103570 :                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF(
   10404             :                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10405             :                     }
   10406             : 
   10407             :                     //           If the Terminal Unit has a net cooling capacity (NoCompOutput < 0) and
   10408             :                     //           the zone temp is above the Tstat heating setpoint (QToHeatSetPt < 0)
   10409      162085 :                     if (TempOutput < 0.0 && LoadToHeatingSP < 0.0) {
   10410             :                         //             If the net cooling capacity overshoots the heating setpoint count as heating load
   10411       17020 :                         if (TempOutput < LoadToHeatingSP) {
   10412             :                             //               Don't count as heating load unless mode is allowed. Also check for floating zone.
   10413        3186 :                             if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != DataHVACGlobals::ThermostatType::SingleCooling &&
   10414        1593 :                                 state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != DataHVACGlobals::ThermostatType::Uncontrolled) {
   10415        1593 :                                 if (!state.dataHVACVarRefFlow->LastModeHeating(VRFCond)) {
   10416             :                                     // if last mode was cooling, make sure heating flow rate is used
   10417           7 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerUsed) {
   10418           7 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOAMixerRetNodeNum).MassFlowRate =
   10419           7 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).MaxHeatAirMassFlow;
   10420           7 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOAMixerOANodeNum).MassFlowRate =
   10421           7 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatOutAirMassFlow;
   10422          14 :                                         SimOAMixer(state,
   10423           7 :                                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerName,
   10424             :                                                    FirstHVACIteration,
   10425           7 :                                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerIndex);
   10426             :                                     } else {
   10427           0 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum).MassFlowRate =
   10428           0 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).MaxHeatAirMassFlow;
   10429             :                                     }
   10430             : 
   10431             :                                     // recalculate using correct flow rate
   10432           7 :                                     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
   10433             :                                         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   10434           2 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF_FluidTCtrl(
   10435             :                                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10436             :                                     } else {
   10437             :                                         // Algorithm Type: VRF model based on system curve
   10438           5 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF(
   10439             :                                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10440             :                                     }
   10441             : 
   10442           7 :                                     if (TempOutput < LoadToHeatingSP) {
   10443           7 :                                         ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10444             :                                         // sum heating load on condenser, not total zone heating load
   10445           7 :                                         state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += (LoadToHeatingSP - TempOutput);
   10446             :                                     }
   10447             :                                 } else {
   10448        1586 :                                     ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10449             :                                     // sum heating load on condenser, not total zone heating load
   10450        1586 :                                     state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += (LoadToHeatingSP - TempOutput);
   10451             :                                 }
   10452             :                             }
   10453        6917 :                         } else if (TempOutput < ZoneLoad) {
   10454             :                             //             If the net cooling capacity meets the zone cooling load but does not overshoot heating setpoint, turn
   10455             :                             //             off coil do nothing, the zone will float
   10456         781 :                         } else if (ZoneLoad < 0.0) {
   10457             :                             //               still a cooling load
   10458         781 :                             ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10459             :                             // sum cooling load on condenser, not total zone cooling load
   10460         781 :                             state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += (LoadToCoolingSP - TempOutput);
   10461             :                         }
   10462             : 
   10463             :                         //           If the terminal unit has a net heating capacity and the zone temp is below the Tstat cooling setpoint
   10464      153575 :                     } else if (TempOutput > 0.0 && LoadToCoolingSP > 0.0) {
   10465             :                         //             If the net heating capacity overshoots the cooling setpoint count as cooling load
   10466       34238 :                         if (TempOutput > LoadToCoolingSP) {
   10467             :                             //               Don't count as cooling load unless mode is allowed. Also check for floating zone.
   10468       11748 :                             if (state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != DataHVACGlobals::ThermostatType::SingleHeating &&
   10469        5874 :                                 state.dataHeatBalFanSys->TempControlType(ThisZoneNum) != DataHVACGlobals::ThermostatType::Uncontrolled) {
   10470        5874 :                                 if (!state.dataHVACVarRefFlow->LastModeCooling(VRFCond)) {
   10471          27 :                                     if (state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerUsed) {
   10472          26 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOAMixerRetNodeNum).MassFlowRate =
   10473          26 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).MaxCoolAirMassFlow;
   10474          26 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUOAMixerOANodeNum).MassFlowRate =
   10475          26 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolOutAirMassFlow;
   10476          52 :                                         SimOAMixer(state,
   10477          26 :                                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerName,
   10478             :                                                    FirstHVACIteration,
   10479          26 :                                                    state.dataHVACVarRefFlow->VRFTU(TUIndex).OAMixerIndex);
   10480             :                                     } else {
   10481           1 :                                         state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(TUIndex).VRFTUInletNodeNum).MassFlowRate =
   10482           1 :                                             state.dataHVACVarRefFlow->VRFTU(TUIndex).MaxCoolAirMassFlow;
   10483             :                                     }
   10484             : 
   10485          27 :                                     if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
   10486             :                                         // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   10487           6 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF_FluidTCtrl(
   10488             :                                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10489             :                                     } else {
   10490             :                                         // Algorithm Type: VRF model based on system curve
   10491          21 :                                         state.dataHVACVarRefFlow->VRFTU(TUIndex).CalcVRF(
   10492             :                                             state, TUIndex, FirstHVACIteration, 0.0, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   10493             :                                     }
   10494             : 
   10495          27 :                                     if (TempOutput > LoadToCoolingSP) {
   10496          27 :                                         ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10497          27 :                                         state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += (LoadToCoolingSP - TempOutput);
   10498             :                                     }
   10499             :                                 } else {
   10500        5847 :                                     ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10501        5847 :                                     state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += (LoadToCoolingSP - TempOutput);
   10502             :                                 }
   10503             :                             }
   10504       11245 :                         } else if (TempOutput > ZoneLoad) {
   10505             :                             // do nothing, zone will float
   10506        7826 :                         } else if (ZoneLoad > 0.0) {
   10507        7826 :                             ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10508        7826 :                             state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += ZoneLoad;
   10509             :                         }
   10510             :                         //           ELSE there is no overshoot and the zone has a valid cooling load
   10511      136456 :                     } else if (ZoneLoad < 0.0) {
   10512       76763 :                         ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10513       76763 :                         state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += ZoneLoad;
   10514             :                         // ELSE there is no overshoot and the zone has a valid heating load
   10515       59693 :                     } else if (ZoneLoad > 0.0) {
   10516       59241 :                         ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10517       59241 :                         state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += ZoneLoad;
   10518             :                     }
   10519             :                 } else { // is cycling fan
   10520       41786 :                     if (ZoneLoad > 0.0) {
   10521       13318 :                         ++state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond);
   10522       13318 :                         state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) += ZoneLoad;
   10523       28468 :                     } else if (ZoneLoad < 0.0) {
   10524       25330 :                         ++state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond);
   10525       25330 :                         state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) += ZoneLoad;
   10526             :                     }
   10527             :                 }
   10528             :             }
   10529             :         }
   10530             :     }
   10531             : 
   10532             :     // Determine operating mode based on VRF type and thermostat control selection
   10533       45315 :     switch (state.dataHVACVarRefFlow->VRF(VRFCond).ThermostatPriority) {
   10534           0 :     case ThermostatCtrlType::ThermostatOffsetPriority: {
   10535           0 :         if (state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) > std::abs(state.dataHVACVarRefFlow->MinDeltaT(VRFCond)) &&
   10536           0 :             state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) > 0.0) {
   10537           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10538           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10539           0 :         } else if (state.dataHVACVarRefFlow->MaxDeltaT(VRFCond) < std::abs(state.dataHVACVarRefFlow->MinDeltaT(VRFCond)) &&
   10540           0 :                    state.dataHVACVarRefFlow->MinDeltaT(VRFCond) < 0.0) {
   10541           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10542           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10543             :         } else {
   10544           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10545           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10546             :         }
   10547           0 :     } break;
   10548       41544 :     case ThermostatCtrlType::LoadPriority: {
   10549       58370 :         if (state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) > std::abs(state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond)) &&
   10550       16826 :             state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) > 0.0) {
   10551       16826 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10552       16826 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10553       49436 :         } else if (state.dataHVACVarRefFlow->SumHeatingLoads(VRFCond) <= std::abs(state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond)) &&
   10554       24718 :                    state.dataHVACVarRefFlow->SumCoolingLoads(VRFCond) < 0.0) {
   10555       23213 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10556       23213 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10557             :         } else {
   10558        1505 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10559        1505 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10560             :         }
   10561       41544 :     } break;
   10562           0 :     case ThermostatCtrlType::ZonePriority: {
   10563           0 :         if (state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond) > state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond) &&
   10564           0 :             state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond) > 0) {
   10565           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10566           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10567           0 :         } else if (state.dataHVACVarRefFlow->NumHeatingLoads(VRFCond) <= state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond) &&
   10568           0 :                    state.dataHVACVarRefFlow->NumCoolingLoads(VRFCond) > 0) {
   10569           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10570           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10571             :         } else {
   10572           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10573           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10574             :         }
   10575           0 :     } break;
   10576           0 :     case ThermostatCtrlType::ScheduledPriority: {
   10577           0 :         if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPriorityPtr) == 0) {
   10578           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10579           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10580           0 :         } else if (GetCurrentScheduleValue(state, state.dataHVACVarRefFlow->VRF(VRFCond).SchedPriorityPtr) == 1) {
   10581           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10582           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10583             :         } else {
   10584           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10585           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10586             :         }
   10587           0 :     } break;
   10588        3771 :     case ThermostatCtrlType::MasterThermostatPriority: {
   10589        7542 :         ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZonePtr).RemainingOutputRequired /
   10590        3771 :                    state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex).controlZoneMassFlowFrac;
   10591        3771 :         if (state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex).OpMode == DataHVACGlobals::ContFanCycCoil) {
   10592        3757 :             SetCompFlowRate(state, state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex, VRFCond);
   10593             : 
   10594        3757 :             if (state.dataHVACVarRefFlow->VRF(VRFCond).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
   10595             :                 // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   10596           0 :                 state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex)
   10597           0 :                     .CalcVRF_FluidTCtrl(state,
   10598           0 :                                         state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex,
   10599             :                                         FirstHVACIteration,
   10600             :                                         0.0,
   10601             :                                         TempOutput,
   10602             :                                         OnOffAirFlowRatio,
   10603             :                                         SuppHeatCoilLoad);
   10604             :             } else {
   10605             :                 // Algorithm Type: VRF model based on system curve
   10606        3757 :                 state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex)
   10607        7514 :                     .CalcVRF(state,
   10608        3757 :                              state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex,
   10609             :                              FirstHVACIteration,
   10610             :                              0.0,
   10611             :                              TempOutput,
   10612             :                              OnOffAirFlowRatio,
   10613             :                              SuppHeatCoilLoad);
   10614             :             }
   10615             : 
   10616        3757 :             LoadToCoolingSP =
   10617        7514 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZonePtr).OutputRequiredToCoolingSP /
   10618        3757 :                 state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex).controlZoneMassFlowFrac;
   10619        3757 :             LoadToHeatingSP =
   10620        7514 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZonePtr).OutputRequiredToHeatingSP /
   10621        3757 :                 state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->VRF(VRFCond).MasterZoneTUIndex).controlZoneMassFlowFrac;
   10622        3757 :             if (TempOutput < LoadToHeatingSP) {
   10623        1458 :                 state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10624        1458 :                 state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10625        2299 :             } else if (TempOutput > LoadToCoolingSP) {
   10626        1674 :                 state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10627        1674 :                 state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10628             :             } else {
   10629         625 :                 state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10630         625 :                 state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10631             :             }
   10632          14 :         } else if (ZoneLoad > 0.0) {
   10633           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = true;
   10634           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10635          14 :         } else if (ZoneLoad < 0.0) {
   10636           0 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10637           0 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = true;
   10638             :         } else {
   10639          14 :             state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10640          14 :             state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   10641             :         }
   10642        3771 :     } break;
   10643           0 :     case ThermostatCtrlType::FirstOnPriority: {
   10644             :         // na
   10645           0 :     } break;
   10646           0 :     default:
   10647           0 :         break;
   10648             :     }
   10649             : 
   10650             :     // limit to one possible mode
   10651       45315 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && state.dataHVACVarRefFlow->HeatingLoad(VRFCond))
   10652           0 :         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   10653       45315 : }
   10654             : 
   10655        2516 : void LimitTUCapacity(EnergyPlusData &state,
   10656             :                      int const VRFCond,               // Condenser Unit index
   10657             :                      int const NumTUInList,           // Number of terminal units in list
   10658             :                      Real64 const StartingCapacity,   // temporary variable holding condenser capacity [W]
   10659             :                      const Array1D<Real64> &CapArray, // Array of coil capacities in either cooling or heating mode [W]
   10660             :                      Real64 &MaxLimit,                // Maximum terminal unit capacity for coils in same operating mode [W]
   10661             :                      Real64 const AltCapacity,        // temporary variable holding heat recovery capacity [W]
   10662             :                      const Array1D<Real64> &AltArray, // Array of coil capacities of heat recovery [W]
   10663             :                      Real64 &AltLimit                 // Maximum terminal unit capacity of heat recovery coils [W]
   10664             : )
   10665             : {
   10666             : 
   10667             :     // SUBROUTINE INFORMATION:
   10668             :     //       AUTHOR         Richard Raustad
   10669             :     //       DATE WRITTEN   July 2012 (Moved from InitVRF)
   10670             :     //       MODIFIED       na
   10671             :     //       RE-ENGINEERED  na
   10672             : 
   10673             :     // PURPOSE OF THIS SUBROUTINE:
   10674             :     // Calculate the maximum allowed terminal unit capacity. Total terminal unit capacity must not
   10675             :     // exceed the available condenser capacity. This variable, MaxCapacity (passed out to MaxCoolingCapacity
   10676             :     // or MaxHeatingCapacity), is used to limit the terminal units providing more capacity than allowed.
   10677             :     // Example: TU loads are 1-ton, 2-ton, 3-ton, and 4-ton connected to a condenser having only 9-tons available.
   10678             :     // This variable is will be set to 3-tons and the 4-ton terminal unit will be limited to 3-tons
   10679             :     // (see InitVRF where this variable is reset and CalcVRF where the call to the DX coils passes this argument).
   10680             : 
   10681             :     // METHODOLOGY EMPLOYED:
   10682             :     // The coils are simulated and summed. This value is compared to the available capacity. If the summed
   10683             :     // TU capacity is greater than the available capacity, limit the TU's with the highest capacity so that
   10684             :     // the TU capacity equals the available capacity. The report variable Variable Refrigerant Flow Heat Pump
   10685             :     // Maximum Terminal Unit Cool/Heating Capacity holds the value for maximum TU capacity. This value may not
   10686             :     // match the maximum individual coil capacity exactly since the available capacity uses a load weighted
   10687             :     // average WB temperature to calculate available capacity. When the TU's are limited, this weighting changes.
   10688             :     // The extra iterations required for these values to converge is considered excessive.
   10689             :     // If the global flag SimZoneEquipment could be set for 1 additional iteration, these variables would
   10690             :     // converge more closely (setting this global flag is not yet implemented).
   10691             : 
   10692             :     Real64 RemainingCapacity; // decrement capacity counter to find limiting TU capacity [W]
   10693             : 
   10694             :     // limit TU coil capacity to be equal to the condenser capacity (piping losses already accounted for)
   10695        2516 :     LimitCoilCapacity(NumTUInList, StartingCapacity, CapArray, MaxLimit);
   10696             : 
   10697             :     // ** add in logic to limit coils operating opposite to mode when heat recovery is used
   10698             :     // ** this is a hard one since we are here because the system is overloaded. That means
   10699             :     // ** that we do not know at this point the actual operating capacity or compressor power.
   10700        2516 :     if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) {
   10701        1079 :         if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
   10702        1078 :             RemainingCapacity = StartingCapacity * (1 + 1 / state.dataHVACVarRefFlow->VRF(VRFCond).CoolingCOP);
   10703        1078 :             if (AltCapacity > RemainingCapacity) {
   10704           0 :                 LimitCoilCapacity(NumTUInList, RemainingCapacity, AltArray, AltLimit);
   10705             :             }
   10706             :         }
   10707        1079 :         if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
   10708           1 :             RemainingCapacity = StartingCapacity / (1 + 1 / state.dataHVACVarRefFlow->VRF(VRFCond).HeatingCOP);
   10709           1 :             if (AltCapacity > RemainingCapacity) {
   10710           0 :                 LimitCoilCapacity(NumTUInList, RemainingCapacity, AltArray, AltLimit);
   10711             :             }
   10712             :         }
   10713             :     }
   10714        2516 : }
   10715             : 
   10716        2516 : void LimitCoilCapacity(int const NumTUInList,           // Number of terminal units in list
   10717             :                        Real64 const TotalCapacity,      // temporary variable holding condenser capacity [W]
   10718             :                        const Array1D<Real64> &CapArray, // Array of coil capacities in either cooling or heating mode [W]
   10719             :                        Real64 &MaxLimit                 // Maximum terminal unit capacity for coils in same operating mode [W]
   10720             : )
   10721             : {
   10722             : 
   10723             :     // SUBROUTINE INFORMATION:
   10724             :     //       AUTHOR         Richard Raustad
   10725             :     //       DATE WRITTEN   July 2012 (Moved from InitVRF)
   10726             :     //       MODIFIED       na
   10727             :     //       RE-ENGINEERED  na
   10728             : 
   10729             :     // PURPOSE OF THIS SUBROUTINE:
   10730             :     // Calculate the maximum allowed terminal unit capacity. Total terminal unit capacity must not
   10731             :     // exceed the available condenser capacity. This variable, MaxCapacity (passed out to MaxCoolingCapacity
   10732             :     // or MaxHeatingCapacity), is used to limit the terminal units providing more capacity than allowed.
   10733             :     // Example: TU loads are 1-ton, 2-ton, 3-ton, and 4-ton connected to a condenser having only 9-tons available.
   10734             :     // This variable is will be set to 3-tons and the 4-ton terminal unit will be limited to 3-tons
   10735             :     // (see InitVRF where this variable is reset and CalcVRF where the call to the DX coils passes this argument).
   10736             : 
   10737             :     // METHODOLOGY EMPLOYED:
   10738             :     // The coils are simulated and summed. This value is compared to the available capacity. If the summed
   10739             :     // TU capacity is greater than the available capacity, limit the TU's with the highest capacity so that
   10740             :     // the TU capacity equals the available capacity. The report variable Variable Refrigerant Flow Heat Pump
   10741             :     // Maximum Terminal Unit Cool/Heating Capacity holds the value for maximum TU capacity. This value may not
   10742             :     // match the maximum individual coil capacity exactly since the available capacity uses a load weighted
   10743             :     // average WB temperature to calculate available capacity. When the TU's are limited, this weighting changes.
   10744             :     // The extra iterations required for these values to converge is considered excessive.
   10745             :     // If the global flag SimZoneEquipment could be set for 1 additional iteration, these variables would
   10746             :     // converge more closely (setting this global flag is not yet implemented).
   10747             : 
   10748             :     int NumTU;                                   // loop counter
   10749             :     int TempTUIndex;                             // temp variable used to find max terminal unit limit
   10750             :     int MinOutputIndex;                          // index to TU with lowest load
   10751             :     Real64 MinOutput;                            // used when finding TU "max" capacity limit
   10752             :     Real64 RemainingCapacity;                    // decrement capacity counter to find limiting TU capacity [W]
   10753        5032 :     Array1D<Real64> Temp(NumTUInList, CapArray); // temporary array for processing terminal units
   10754        5032 :     Array1D<Real64> Temp2(NumTUInList, Temp);    // temporary array for processing terminal units
   10755             : 
   10756        2516 :     RemainingCapacity = TotalCapacity;
   10757             : 
   10758             :     // sort TU capacity from lowest to highest
   10759       15096 :     for (TempTUIndex = 1; TempTUIndex <= NumTUInList; ++TempTUIndex) {
   10760       12580 :         MinOutput = MaxCap;
   10761       75482 :         for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
   10762       62902 :             if (Temp2(NumTU) < MinOutput) {
   10763       20397 :                 MinOutput = Temp2(NumTU);
   10764       20397 :                 Temp(TempTUIndex) = MinOutput;
   10765       20397 :                 MinOutputIndex = NumTU;
   10766             :             }
   10767             :         }
   10768       12580 :         Temp2(MinOutputIndex) = MaxCap;
   10769             :     }
   10770             : 
   10771             :     // find limit of "terminal unit" capacity so that sum of all TU's does not exceed condenser capacity
   10772             :     // if the terminal unit capacity multiplied by number of remaining TU's does not exceed remaining available, subtract and cycle
   10773       10630 :     for (TempTUIndex = 1; TempTUIndex <= NumTUInList; ++TempTUIndex) {
   10774       18740 :         if ((Temp(TempTUIndex) * (NumTUInList - TempTUIndex + 1)) < RemainingCapacity) {
   10775        8114 :             RemainingCapacity -= Temp(TempTUIndex);
   10776        8114 :             continue;
   10777             :         } else {
   10778             :             // if it does exceed, limit is found
   10779        2512 :             MaxLimit = RemainingCapacity / (NumTUInList - TempTUIndex + 1);
   10780        2512 :             break;
   10781             :         }
   10782             :     }
   10783        2516 : }
   10784             : 
   10785       13838 : int GetVRFTUOutAirNode(EnergyPlusData &state, int const VRFTUNum)
   10786             : {
   10787             : 
   10788             :     // FUNCTION INFORMATION:
   10789             :     //       AUTHOR         R. Raustad (copy of B Griffith routine)
   10790             :     //       DATE WRITTEN   Jan  2015
   10791             :     //       MODIFIED       na
   10792             :     //       RE-ENGINEERED  na
   10793             : 
   10794             :     // PURPOSE OF THIS FUNCTION:
   10795             :     // lookup function for VRF terminal unit OA inlet node
   10796             : 
   10797       13838 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10798           0 :         GetVRFInput(state);
   10799           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10800             :     }
   10801             : 
   10802       13838 :     if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
   10803       13838 :         return state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum;
   10804             :     } else {
   10805           0 :         return 0;
   10806             :     }
   10807             : }
   10808             : 
   10809       13838 : int GetVRFTUZoneInletAirNode(EnergyPlusData &state, int const VRFTUNum)
   10810             : {
   10811             : 
   10812             :     // FUNCTION INFORMATION:
   10813             :     //       AUTHOR         R. Raustad (copy of B Griffith routine)
   10814             :     //       DATE WRITTEN   Jan  2015
   10815             :     //       MODIFIED       na
   10816             :     //       RE-ENGINEERED  na
   10817             : 
   10818             :     // PURPOSE OF THIS FUNCTION:
   10819             :     // lookup function for VRF terminal unit zone inlet node
   10820             : 
   10821       13838 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10822           0 :         GetVRFInput(state);
   10823           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10824             :     }
   10825             : 
   10826       13838 :     if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
   10827       13838 :         return state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum;
   10828             :     } else {
   10829           0 :         return 0;
   10830             :     }
   10831             : }
   10832             : 
   10833           0 : int GetVRFTUOutAirNodeFromName(EnergyPlusData &state, std::string const VRFTUName, bool &errorsFound)
   10834             : {
   10835             :     int NodeNum; // return value of node number
   10836             : 
   10837           0 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10838           0 :         GetVRFInput(state);
   10839           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10840             :     }
   10841             : 
   10842           0 :     int WhichVRFTU = UtilityRoutines::FindItemInList(
   10843           0 :         VRFTUName, state.dataHVACVarRefFlow->VRFTU, &VRFTerminalUnitEquipment::Name, state.dataHVACVarRefFlow->NumVRFTU);
   10844           0 :     if (WhichVRFTU != 0) {
   10845           0 :         NodeNum = state.dataHVACVarRefFlow->VRFTU(WhichVRFTU).VRFTUOutletNodeNum;
   10846             :     } else {
   10847           0 :         ShowSevereError(state, "GetVRFTUOutAirNodeFromName: Could not find VRF TU = \"" + VRFTUName + "\"");
   10848           0 :         errorsFound = true;
   10849           0 :         NodeNum = 0;
   10850             :     }
   10851             : 
   10852           0 :     return NodeNum;
   10853             : }
   10854             : 
   10855           0 : int GetVRFTUInAirNodeFromName(EnergyPlusData &state, std::string const VRFTUName, bool &errorsFound)
   10856             : {
   10857             :     int NodeNum; // return value of node number
   10858             : 
   10859           0 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10860           0 :         GetVRFInput(state);
   10861           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10862             :     }
   10863             : 
   10864           0 :     int WhichVRFTU = UtilityRoutines::FindItemInList(
   10865           0 :         VRFTUName, state.dataHVACVarRefFlow->VRFTU, &VRFTerminalUnitEquipment::Name, state.dataHVACVarRefFlow->NumVRFTU);
   10866           0 :     if (WhichVRFTU != 0) {
   10867           0 :         NodeNum = state.dataHVACVarRefFlow->VRFTU(WhichVRFTU).VRFTUInletNodeNum;
   10868             :     } else {
   10869           0 :         ShowSevereError(state, "GetVRFTUInAirNodeFromName: Could not find VRF TU = \"" + VRFTUName + "\"");
   10870           0 :         errorsFound = true;
   10871           0 :         NodeNum = 0;
   10872             :     }
   10873             : 
   10874           0 :     return NodeNum;
   10875             : }
   10876             : 
   10877       13838 : int GetVRFTUMixedAirNode(EnergyPlusData &state, int const VRFTUNum)
   10878             : {
   10879             : 
   10880             :     // FUNCTION INFORMATION:
   10881             :     //       AUTHOR         R. Raustad (copy of B Griffith routine)
   10882             :     //       DATE WRITTEN   Jan  2015
   10883             :     //       MODIFIED       na
   10884             :     //       RE-ENGINEERED  na
   10885             : 
   10886             :     // PURPOSE OF THIS FUNCTION:
   10887             :     // lookup function for VRF terminal unit mixed air node
   10888             : 
   10889       13838 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10890           0 :         GetVRFInput(state);
   10891           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10892             :     }
   10893             : 
   10894       13838 :     if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
   10895       13838 :         return state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerOANodeNum;
   10896             :     } else {
   10897           0 :         return 0;
   10898             :     }
   10899             : }
   10900             : 
   10901       13838 : int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum)
   10902             : {
   10903             : 
   10904             :     // FUNCTION INFORMATION:
   10905             :     //       AUTHOR         R. Raustad (copy of B Griffith routine)
   10906             :     //       DATE WRITTEN   Jan  2015
   10907             :     //       MODIFIED       na
   10908             :     //       RE-ENGINEERED  na
   10909             : 
   10910             :     // PURPOSE OF THIS FUNCTION:
   10911             :     // lookup function for VRF terminal unit return air node
   10912             : 
   10913       13838 :     if (state.dataHVACVarRefFlow->GetVRFInputFlag) {
   10914           0 :         GetVRFInput(state);
   10915           0 :         state.dataHVACVarRefFlow->GetVRFInputFlag = false;
   10916             :     }
   10917             : 
   10918       13838 :     if (VRFTUNum > 0 && VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU) {
   10919       13838 :         return state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOAMixerRetNodeNum;
   10920             :     } else {
   10921           0 :         return 0;
   10922             :     }
   10923             : }
   10924             : 
   10925      465012 : void getVRFTUZoneLoad(
   10926             :     EnergyPlusData &state, int const VRFTUNum, Real64 &zoneLoad, Real64 &LoadToHeatingSP, Real64 &LoadToCoolingSP, bool const InitFlag)
   10927             : {
   10928             : 
   10929      936396 :     if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).zoneSequenceCoolingNum > 0 &&
   10930      471384 :         state.dataHVACVarRefFlow->VRFTU(VRFTUNum).zoneSequenceHeatingNum > 0 && state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isInAirLoop) {
   10931             :         // air loop equipment uses sequenced variables
   10932       12744 :         LoadToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum)
   10933       12744 :                               .SequencedOutputRequiredToCoolingSP(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).zoneSequenceCoolingNum) /
   10934        6372 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10935       12744 :         LoadToHeatingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum)
   10936       12744 :                               .SequencedOutputRequiredToHeatingSP(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).zoneSequenceHeatingNum) /
   10937        6372 :                           state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10938        8984 :         if (LoadToHeatingSP > 0.0 && LoadToCoolingSP > 0.0 &&
   10939        2612 :             state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
   10940             :                 DataHVACGlobals::ThermostatType::SingleCooling) {
   10941        2612 :             zoneLoad = LoadToHeatingSP;
   10942        3760 :         } else if (LoadToHeatingSP > 0.0 && LoadToCoolingSP > 0.0 &&
   10943           0 :                    state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) ==
   10944             :                        DataHVACGlobals::ThermostatType::SingleCooling) {
   10945           0 :             zoneLoad = 0.0;
   10946        6488 :         } else if (LoadToHeatingSP < 0.0 && LoadToCoolingSP < 0.0 &&
   10947        2728 :                    state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) !=
   10948             :                        DataHVACGlobals::ThermostatType::SingleHeating) {
   10949        2728 :             zoneLoad = LoadToCoolingSP;
   10950        1032 :         } else if (LoadToHeatingSP < 0.0 && LoadToCoolingSP < 0.0 &&
   10951           0 :                    state.dataHeatBalFanSys->TempControlType(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum) ==
   10952             :                        DataHVACGlobals::ThermostatType::SingleHeating) {
   10953           0 :             zoneLoad = 0.0;
   10954        1032 :         } else if (LoadToHeatingSP <= 0.0 && LoadToCoolingSP >= 0.0) {
   10955        1032 :             zoneLoad = 0.0;
   10956             :         }
   10957      458640 :     } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum > 0) {
   10958             :         // zone equipment uses Remaining* variables
   10959      455456 :         if (InitFlag) {
   10960             :             // this will need more investigation. Using Remaining* variable during the initial load calculation seems wrong.
   10961             :             // This may also have implications when VRF TUs are in the air loop or if SP control is used
   10962             :             // another question is whether initialization of the opeating mode should look at TotalOutputRequired or RemainingOutputRequired
   10963      408906 :             zoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).RemainingOutputRequired /
   10964      204453 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10965      204453 :             LoadToCoolingSP =
   10966      408906 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).OutputRequiredToCoolingSP /
   10967      204453 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10968      204453 :             LoadToHeatingSP =
   10969      408906 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).OutputRequiredToHeatingSP /
   10970      204453 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10971             :         } else {
   10972      502006 :             zoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).RemainingOutputRequired /
   10973      251003 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10974      251003 :             LoadToCoolingSP =
   10975      502006 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).RemainingOutputReqToCoolSP /
   10976      251003 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10977      251003 :             LoadToHeatingSP =
   10978      502006 :                 state.dataZoneEnergyDemand->ZoneSysEnergyDemand(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).ZoneNum).RemainingOutputReqToHeatSP /
   10979      251003 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).controlZoneMassFlowFrac;
   10980             :         }
   10981        3184 :     } else if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isSetPointControlled) {
   10982        3184 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolSPActive) {
   10983        1806 :             LoadToCoolingSP = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coolLoadToSP;
   10984        1806 :             zoneLoad = LoadToCoolingSP;
   10985        1806 :             LoadToHeatingSP = 0.0;
   10986             :         }
   10987        3184 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatSPActive) {
   10988        1365 :             LoadToHeatingSP = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).heatLoadToSP;
   10989        1365 :             zoneLoad = LoadToHeatingSP;
   10990        1365 :             LoadToCoolingSP = 0.0;
   10991             :         }
   10992             :     }
   10993      465012 : }
   10994             : 
   10995       11709 : void VRFCondenserEquipment::CalcVRFIUTeTc_FluidTCtrl(EnergyPlusData &state)
   10996             : {
   10997             :     // SUBROUTINE INFORMATION:
   10998             :     //       AUTHOR         RP Zhang (LBNL), XF Pang (LBNL), Y Yura (Daikin Inc)
   10999             :     //       DATE WRITTEN   June 2015
   11000             :     //       MODIFIED       na
   11001             :     //       RE-ENGINEERED  na
   11002             : 
   11003             :     // PURPOSE OF THIS SUBROUTINE:
   11004             :     //       This subroutine is part of the new VRF model based on physics, applicable for Fluid Temperature Control.
   11005             :     //       This subroutine determines the VRF evaporating temperature at cooling mode and the condensing temperature
   11006             :     //       at heating mode. This is the indoor unit side analysis.
   11007             : 
   11008             :     // METHODOLOGY EMPLOYED:
   11009             :     //       There are two options to calculate the IU Te/Tc: (1) HighSensible method analyzes the conditions of each IU
   11010             :     //       and then decide and Te/Tc that can satisfy all the zones (2) TeTcConstant method uses fixed values provided
   11011             :     //       by the user.
   11012             : 
   11013             :     // Followings for FluidTCtrl Only
   11014       23418 :     Array1D<Real64> EvapTemp;
   11015       23418 :     Array1D<Real64> CondTemp;
   11016             :     Real64 IUMinEvapTemp;
   11017             :     Real64 IUMaxCondTemp;
   11018             : 
   11019       11709 :     int TUListNum = this->ZoneTUListPtr;
   11020       11709 :     EvapTemp.allocate(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList);
   11021       11709 :     CondTemp.allocate(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList);
   11022       11709 :     IUMinEvapTemp = 100.0;
   11023       11709 :     IUMaxCondTemp = 0.0;
   11024             : 
   11025       11709 :     if (this->AlgorithmIUCtrl == 1) {
   11026             :         // 1. HighSensible: analyze the conditions of each IU
   11027             : 
   11028       23250 :         for (int i = 1; i <= state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList; i++) {
   11029       19375 :             int VRFTUNum = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(i);
   11030             :             // analyze the conditions of each IU
   11031       19375 :             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRFIUVariableTeTc(state, EvapTemp(i), CondTemp(i));
   11032             : 
   11033             :             // select the Te/Tc that can satisfy all the zones
   11034       19375 :             IUMinEvapTemp = min(IUMinEvapTemp, EvapTemp(i), this->IUEvapTempHigh);
   11035       19375 :             IUMaxCondTemp = max(IUMaxCondTemp, CondTemp(i), this->IUCondTempLow);
   11036             :         }
   11037             : 
   11038        3875 :         this->IUEvaporatingTemp = max(IUMinEvapTemp, this->IUEvapTempLow);
   11039        3875 :         this->IUCondensingTemp = min(IUMaxCondTemp, this->IUCondTempHigh);
   11040             : 
   11041             :     } else {
   11042             :         // 2. TeTcConstant: use fixed values provided by the user
   11043        7834 :         this->IUEvaporatingTemp = this->EvapTempFixed;
   11044        7834 :         this->IUCondensingTemp = this->CondTempFixed;
   11045             :     }
   11046       11709 : }
   11047             : 
   11048       19375 : void VRFTerminalUnitEquipment::CalcVRFIUVariableTeTc(EnergyPlusData &state,
   11049             :                                                      Real64 &EvapTemp, // evaporating temperature
   11050             :                                                      Real64 &CondTemp  // condensing temperature
   11051             : )
   11052             : {
   11053             :     // SUBROUTINE INFORMATION:
   11054             :     //       AUTHOR         Xiufeng Pang, LBNL
   11055             :     //       DATE WRITTEN   Feb 2014
   11056             :     //       MODIFIED       Jul 2015, RP Zhang, LBNL, Modify the bounds of the Te/Tc
   11057             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL, take into account OA in Te/Tc determination
   11058             :     //       RE-ENGINEERED  na
   11059             : 
   11060             :     // PURPOSE OF THIS SUBROUTINE:
   11061             :     //       Calculate the VRF IU Te (cooling mode) and Tc (heating mode), given zonal loads.
   11062             : 
   11063             :     // METHODOLOGY EMPLOYED:
   11064             :     //       A new physics based VRF model applicable for Fluid Temperature Control.
   11065             : 
   11066             :     using namespace DataZoneEnergyDemands;
   11067             :     using MixedAir::SimOAMixer;
   11068             :     using Psychrometrics::PsyHFnTdbW;
   11069             :     using SingleDuct::SimATMixer;
   11070             : 
   11071             :     int CoolCoilNum;             // index to the VRF Cooling DX coil to be simulated
   11072             :     int HeatCoilNum;             // index to the VRF Heating DX coil to be simulated
   11073             :     int IndexToTUInTUList;       // index to TU in specific list for the VRF system
   11074             :     int TUListIndex;             // index to TU list for this VRF system
   11075             :     int VRFNum;                  // index to VRF that the VRF Terminal Unit serves
   11076             :     int VRFInletNode;            // VRF inlet node number
   11077             :     int ZoneIndex;               // index to zone where the VRF Terminal Unit resides
   11078             :     Real64 BFC;                  // Bypass factor at the cooling mode (-)
   11079             :     Real64 BFH;                  // Bypass factor at the heating mode (-)
   11080             :     Real64 C1Tevap;              // Coefficient for indoor unit coil evaporating temperature curve (-)
   11081             :     Real64 C2Tevap;              // Coefficient for indoor unit coil evaporating temperature curve (-)
   11082             :     Real64 C3Tevap;              // Coefficient for indoor unit coil evaporating temperature curve (-)
   11083             :     Real64 C1Tcond;              // Coefficient for indoor unit coil condensing temperature curve (-)
   11084             :     Real64 C2Tcond;              // Coefficient for indoor unit coil condensing temperature curve (-)
   11085             :     Real64 C3Tcond;              // Coefficient for indoor unit coil condensing temperature curve (-)
   11086             :     Real64 CondTempMin;          // Min condensing temperature (C)
   11087             :     Real64 CondTempMax;          // Max condensing temperature, correspond to the maximum heating capacity (C)
   11088             :     Real64 DeltaT;               // Difference between evaporating/condensing temperature and coil surface temperature (C)
   11089             :     Real64 EvapTempMax;          // Max evaporating temperature (C)
   11090             :     Real64 EvapTempMin;          // Min evaporating temperature, correspond to the maximum cooling capacity (C)
   11091             :     Real64 Garate;               // Nominal air mass flow rate
   11092             :     Real64 H_coil_in;            // Air enthalpy at the coil inlet (kJ/kg)
   11093             :     Real64 QZnReqSenCoolingLoad; // Zone required sensible cooling load (W)
   11094             :     Real64 QZnReqSenHeatingLoad; // Zone required sensible heating load (W)
   11095             :     Real64 RHsat;                // Relative humidity of the air at saturated condition(-)
   11096             :     Real64 SH;                   // Super heating degrees (C)
   11097             :     Real64 SC;                   // Subcooling degrees (C)
   11098             :     Real64 T_coil_in;            // Temperature of the air at the coil inlet, after absorbing the heat released by fan (C)
   11099             :     Real64 T_TU_in;              // Air temperature at the indoor unit inlet (C)
   11100             :     Real64 Tout;                 // Air temperature at the indoor unit outlet (C)
   11101             :     Real64 Th2;                  // Air temperature at the coil surface (C)
   11102             :     Real64 W_coil_in;            // coil inlet air humidity ratio [kg/kg]
   11103             :     Real64 W_TU_in;              // Air humidity ratio at the indoor unit inlet[kg/kg]
   11104             : 
   11105             :     // Get the equipment/zone index corresponding to the VRFTU
   11106       19375 :     CoolCoilNum = this->CoolCoilIndex;
   11107       19375 :     HeatCoilNum = this->HeatCoilIndex;
   11108       19375 :     ZoneIndex = this->ZoneNum;
   11109       19375 :     VRFNum = this->VRFSysNum;
   11110       19375 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFNum).ZoneTUListPtr;
   11111       19375 :     IndexToTUInTUList = this->IndexToTUInTUList;
   11112             : 
   11113             :     // Bounds of Te/Tc for VRF IU Control Algorithm: VariableTemp
   11114       19375 :     EvapTempMin = state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempLow;
   11115       19375 :     EvapTempMax = state.dataHVACVarRefFlow->VRF(VRFNum).IUEvapTempHigh;
   11116       19375 :     CondTempMin = state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempLow;
   11117       19375 :     CondTempMax = state.dataHVACVarRefFlow->VRF(VRFNum).IUCondTempHigh;
   11118             : 
   11119             :     // Coefficients describing coil performance
   11120       19375 :     SH = state.dataDXCoils->DXCoil(CoolCoilNum).SH;
   11121       19375 :     SC = state.dataDXCoils->DXCoil(HeatCoilNum).SC;
   11122       19375 :     C1Tevap = state.dataDXCoils->DXCoil(CoolCoilNum).C1Te;
   11123       19375 :     C2Tevap = state.dataDXCoils->DXCoil(CoolCoilNum).C2Te;
   11124       19375 :     C3Tevap = state.dataDXCoils->DXCoil(CoolCoilNum).C3Te;
   11125       19375 :     C1Tcond = state.dataDXCoils->DXCoil(HeatCoilNum).C1Tc;
   11126       19375 :     C2Tcond = state.dataDXCoils->DXCoil(HeatCoilNum).C2Tc;
   11127       19375 :     C3Tcond = state.dataDXCoils->DXCoil(HeatCoilNum).C3Tc;
   11128             : 
   11129       19375 :     VRFInletNode = this->VRFTUInletNodeNum;
   11130       19375 :     T_TU_in = state.dataLoopNodes->Node(VRFInletNode).Temp;
   11131       19375 :     W_TU_in = state.dataLoopNodes->Node(VRFInletNode).HumRat;
   11132       19375 :     T_coil_in = this->coilInNodeT;
   11133       19375 :     W_coil_in = this->coilInNodeW;
   11134             : 
   11135       19375 :     Garate = state.dataHVACVarRefFlow->CompOnMassFlow;
   11136       19375 :     H_coil_in = PsyHFnTdbW(T_coil_in, W_coil_in);
   11137       19375 :     RHsat = 0.98;
   11138       19375 :     BFC = 0.0592;
   11139       19375 :     BFH = 0.136;
   11140       19375 :     Real64 ZoneLoad = 0.0;
   11141       19375 :     Real64 LoadToHeatingSP = 0.0;
   11142       19375 :     Real64 LoadToCoolingSP = 0.0;
   11143             : 
   11144             :     // 1. COOLING Mode
   11145       51125 :     if ((Garate > 0.0) && ((!state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFNum)) ||
   11146       38740 :                            (state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed &&
   11147       19370 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList)))) {
   11148             :         // 1.1) Cooling coil is running
   11149       12380 :         getVRFTUZoneLoad(state, IndexToTUInTUList, ZoneLoad, LoadToHeatingSP, LoadToCoolingSP, false);
   11150       12380 :         QZnReqSenCoolingLoad = max(0.0, -1.0 * LoadToCoolingSP);
   11151       12380 :         Tout = T_TU_in - QZnReqSenCoolingLoad * 1.2 / Garate / 1005;
   11152       12380 :         Th2 = T_coil_in - (T_coil_in - Tout) / (1 - BFC);
   11153       12380 :         DeltaT = C3Tevap * SH * SH + C2Tevap * SH + C1Tevap;
   11154       12380 :         EvapTemp = max(min((Th2 - DeltaT), EvapTempMax), EvapTempMin);
   11155             : 
   11156             :     } else {
   11157             :         // 1.2) Cooling coil is not running
   11158        6995 :         EvapTemp = T_coil_in;
   11159             :     }
   11160             : 
   11161             :     // 2. HEATING Mode
   11162       45163 :     if ((Garate > 0.0) && ((!state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFNum)) ||
   11163       38740 :                            (state.dataHVACVarRefFlow->VRF(VRFNum).HeatRecoveryUsed &&
   11164       19370 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList)))) {
   11165             :         // 2.1) Heating coil is running
   11166        6418 :         getVRFTUZoneLoad(state, IndexToTUInTUList, ZoneLoad, LoadToHeatingSP, LoadToCoolingSP, false);
   11167        6418 :         QZnReqSenHeatingLoad = max(0.0, LoadToHeatingSP);
   11168        6418 :         Tout = T_TU_in + QZnReqSenHeatingLoad / Garate / 1005;
   11169        6418 :         Th2 = T_coil_in + (Tout - T_coil_in) / (1 - BFH);
   11170        6418 :         DeltaT = C3Tcond * SC * SC + C2Tcond * SC + C1Tcond;
   11171        6418 :         CondTemp = max(min((Th2 + DeltaT), CondTempMax), CondTempMin);
   11172             :     } else {
   11173             :         // 2.2) Heating coil is not running
   11174       12957 :         CondTemp = T_coil_in;
   11175             :     }
   11176       19375 : }
   11177             : 
   11178       11709 : void VRFCondenserEquipment::CalcVRFCondenser_FluidTCtrl(EnergyPlusData &state)
   11179             : {
   11180             : 
   11181             :     // SUBROUTINE INFORMATION:
   11182             :     //       AUTHOR         RP Zhang (LBNL), XF Pang (LBNL), Y Yura (Daikin Inc)
   11183             :     //       DATE WRITTEN   June 2015
   11184             :     //       MODIFIED       Feb 2016, RP Zhang, add the control logics for VRF-HR operations
   11185             :     //       RE-ENGINEERED  na
   11186             : 
   11187             :     // PURPOSE OF THIS SUBROUTINE:
   11188             :     //       This subroutine is part of the new VRF model based on physics, applicable for Fluid Temperature Control.
   11189             :     //       This is adapted from subroutine CalcVRFCondenser, which is part of the VRF model based on system curves.
   11190             :     //       This subroutine models the interactions of VRF indoor units with the outdoor unit.
   11191             :     //       The indoor terminal units are simulated first, and then the outdoor unit is simulated.
   11192             : 
   11193             :     // METHODOLOGY EMPLOYED:
   11194             :     //       A new physics based VRF model applicable for Fluid Temperature Control.
   11195             : 
   11196             :     using Curve::CurveValue;
   11197             :     using FluidProperties::FindRefrigerant;
   11198             :     using FluidProperties::GetSatEnthalpyRefrig;
   11199             :     using FluidProperties::GetSatPressureRefrig;
   11200             :     using FluidProperties::GetSatTemperatureRefrig;
   11201             :     using FluidProperties::GetSpecificHeatGlycol;
   11202             :     using FluidProperties::GetSupHeatDensityRefrig;
   11203             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   11204             :     using FluidProperties::GetSupHeatTempRefrig;
   11205             :     using General::SolveRoot;
   11206             : 
   11207             :     using PlantUtilities::SetComponentFlowRate;
   11208             :     using Psychrometrics::RhoH2O;
   11209             : 
   11210             :     static constexpr std::string_view RoutineName("CalcVRFCondenser_FluidTCtrl");
   11211             : 
   11212             :     int VRFCond;            // index to VRF condenser
   11213             :     int TUListNum;          // index to TU List
   11214             :     int NumTUInList;        // number of terminal units is list
   11215             :     int NumTU;              // index for loop on terminal units
   11216             :     int TUIndex;            // Index to terminal unit
   11217             :     int CoolCoilIndex;      // index to cooling coil in terminal unit
   11218             :     int HeatCoilIndex;      // index to heating coil in terminal unit
   11219             :     int NumTUInCoolingMode; // number of terminal units actually cooling
   11220             :     int NumTUInHeatingMode; // number of terminal units actually heating
   11221             : 
   11222             :     Real64 TUParasiticPower;          // total terminal unit parasitic power (W)
   11223             :     Real64 TUFanPower;                // total terminal unit fan power (W)
   11224             :     Real64 InletAirWetBulbC;          // coil inlet air wet-bulb temperature (C)
   11225             :     Real64 InletAirDryBulbC;          // coil inlet air dry-bulb temperature (C)
   11226             :     Real64 CondInletTemp;             // condenser inlet air temperature (C)
   11227             :     Real64 OutdoorDryBulb;            // outdoor dry-bulb temperature (C)
   11228             :     Real64 OutdoorHumRat;             // outdoor humidity ratio (kg/kg)
   11229             :     Real64 OutdoorPressure;           // outdoor pressure (Pa)
   11230             :     Real64 OutdoorWetBulb;            // outdoor wet-bulb temperature (C)
   11231             :     Real64 SumCoolInletWB;            // sum of active TU's DX cooling coil inlet air wet-bulb temperature
   11232             :     Real64 SumHeatInletDB;            // sum of active TU's DX heating coil inlet air dry-bulb temperature
   11233             :     Real64 SumHeatInletWB;            // sum of active TU's DX heating coil inlet air wet-bulb temperature
   11234             :     Real64 TotalTUCoolingCapacity;    // sum of TU's cooling capacity (W)
   11235             :     Real64 TotalTUHeatingCapacity;    // sum of TU's heating capacity (W)
   11236             :     Real64 TotalCondCoolingCapacity;  // total available condenser cooling capacity (W)
   11237             :     Real64 TotalCondHeatingCapacity;  // total available condenser heating capacity (W)
   11238             :     Real64 CoolingPLR;                // condenser cooling PLR
   11239             :     Real64 HeatingPLR;                // condenser heating PLR
   11240             :     Real64 CyclingRatio;              // cycling ratio of condenser's compressors
   11241             :     int Stage;                        // used for crankcase heater power calculation
   11242             :     Real64 UpperStageCompressorRatio; // used for crankcase heater power calculation
   11243             :     Real64 RhoAir;                    // Density of air [kg/m3]
   11244             :     Real64 PartLoadFraction;          // Part load fraction from PLFFPLR curve
   11245             :     Real64 VRFRTF;                    // VRF runtime fraction when cycling below MINPLR
   11246             :     Real64 OutdoorCoilT;              // Outdoor coil temperature (C)
   11247             :     Real64 OutdoorCoildw;             // Outdoor coil delta w assuming coil temp of OutdoorCoilT (kg/kg)
   11248             :     Real64 FractionalDefrostTime;     // Fraction of time step system is in defrost
   11249             :     Real64 HeatingCapacityMultiplier; // Multiplier for heating capacity when system is in defrost
   11250             :     Real64 InputPowerMultiplier;      // Multiplier for power when system is in defrost
   11251             :     Real64 LoadDueToDefrost;          // Additional load due to defrost
   11252             :     Real64 DefrostEIRTempModFac;      // EIR modifier for defrost (function of entering drybulb, outside wetbulb)
   11253             :     Real64 HRInitialCapFrac;          // Fractional cooling degradation at the start of heat recovery from cooling mode
   11254             :     Real64 HRCapTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
   11255             :     Real64 HRInitialEIRFrac;          // Fractional cooling degradation at the start of heat recovery from cooling mode
   11256             :     Real64 HREIRTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
   11257             :     Real64 CurrentEndTime;            // end time of current time step
   11258             :     Real64 SUMultiplier;              // multiplier for simulating mode changes
   11259             :     Real64 CondPower;                 // condenser power [W]
   11260             :     Real64 CondCapacity;              // condenser heat rejection [W]
   11261             :     Real64 TotPower;                  // total condenser power use [W]
   11262             :     bool HRHeatRequestFlag;           // flag indicating VRF TU could operate in heating mode
   11263             :     bool HRCoolRequestFlag;           // flag indicating VRF TU could operate in cooling mode
   11264             : 
   11265             :     // Followings for VRF FluidTCtrl Only
   11266             :     int Counter;                     // index for iterations [-]
   11267             :     int NumIteHIUIn;                 // index for HIU calculation iterations [-]
   11268             :     int NumOfCompSpdInput;           // Number of compressor speed input by the user [-]
   11269             :     int RefrigerantIndex;            // Index of the refrigerant [-]
   11270             :     Real64 CompSpdActual;            // Actual compressor running speed [rps]
   11271             :     Real64 C_cap_operation;          // Compressor capacity modification algorithm_modified Cap [-]
   11272             :     Real64 CompEvaporatingCAPSpdMin; // evaporating capacity at the lowest compressor speed [W]
   11273             :     Real64 CompEvaporatingCAPSpdMax; // evaporating capacity at the highest compressor speed [W]
   11274             :     Real64 CompEvaporatingPWRSpdMin; // compressor power at the lowest compressor speed [W]
   11275             :     Real64 CompEvaporatingPWRSpdMax; // compressor power at the highest compressor speed [W]
   11276             :     Real64 CapMaxTe;                 // maximum Te during operation, for capacity calculations [C]
   11277             :     Real64 CapMinTe;                 // minimum Te during operation, for capacity calculations [C]
   11278             :     Real64 CapMinPe;                 // minimum Pe during operation, for capacity calculations [Pa]
   11279             :     Real64 CapMaxTc;                 // maximum Tc during operation, for capacity calculations [C]
   11280             :     Real64 CapMaxPc;                 // maximum Pc during operation, for capacity calculations [Pa]
   11281             :     Real64 CapMinTc;                 // minimum Tc during operation, for capacity calculations [C]
   11282             :     Real64 CapMinPc;                 // minimum Pc during operation, for capacity calculations [Pa]
   11283             :     Real64 h_IU_evap_in;             // enthalpy of IU evaporator at inlet [kJ/kg]
   11284             :     Real64 h_IU_evap_in_new;         // enthalpy of IU evaporator at inlet (new) [kJ/kg]
   11285             :     Real64 h_IU_evap_in_low;         // enthalpy of IU evaporator at inlet (low) [kJ/kg]
   11286             :     Real64 h_IU_evap_in_up;          // enthalpy of IU evaporator at inlet (up) [kJ/kg]
   11287             :     Real64 h_IU_evap_out;            // enthalpy of IU evaporator at outlet [kJ/kg]
   11288             :     Real64 h_IU_evap_out_i;          // enthalpy of IU evaporator at outlet (individual) [kJ/kg]
   11289             :     Real64 h_IU_cond_in;             // enthalpy of IU condenser at inlet [kJ/kg]
   11290             :     Real64 h_IU_cond_in_low;         // enthalpy of IU condenser at inlet (low) [kJ/kg]
   11291             :     Real64 h_IU_cond_in_up;          // enthalpy of IU condenser at inlet (up) [kJ/kg]
   11292             :     Real64 h_IU_cond_out;            // enthalpy of IU condenser at outlet [kJ/kg]
   11293             :     Real64 h_IU_cond_out_i;          // enthalpy of IU condenser at outlet (individual) [kJ/kg]
   11294             :     Real64 h_IU_cond_out_ave;        // average enthalpy of the refrigerant leaving IU condensers [kJ/kg]
   11295             :     Real64 h_IU_PLc_out;             // enthalpy of refrigerant at the outlet of IU evaporator side main pipe, after piping loss (c) [kJ/kg]
   11296             :     Real64 h_comp_in;                // enthalpy of refrigerant at compressor inlet, after piping loss (c) [kJ/kg]
   11297             :     Real64 h_comp_in_new;            // enthalpy of refrigerant at compressor inlet (new) [kJ/kg]
   11298             :     Real64 h_comp_out;               // enthalpy of refrigerant at compressor outlet [kJ/kg]
   11299             :     Real64 h_comp_out_new;           // enthalpy of refrigerant at compressor outlet (new) [kJ/kg]
   11300             :     Real64 m_air;                    // OU coil air mass flow rate [kg/s]
   11301             :     Real64 m_ref_IU_cond;            // mass flow rate of Refrigerant through IU condensers [kg/s]
   11302             :     Real64 m_ref_IU_cond_i;          // mass flow rate of Refrigerant through an individual IU condenser [kg/s]
   11303             :     Real64 m_ref_IU_evap;            // mass flow rate of Refrigerant through IU evaporators [kg/s]
   11304             :     Real64 m_ref_IU_evap_i;          // mass flow rate of Refrigerant through an individual IU evaporator [kg/s]
   11305             :     Real64 m_ref_OU_evap;            // mass flow rate of Refrigerant through OU evaporator [kg/s]
   11306             :     Real64 m_ref_OU_cond;            // mass flow rate of Refrigerant through OU condenser [kg/s]
   11307             :     Real64 Ncomp;                    // compressor power [W]
   11308             :     Real64 Ncomp_new;                // compressor power for temporary use in iterations [W]
   11309             :     Real64 P_comp_in;                // pressure of refrigerant at IU condenser outlet [Pa]
   11310             :     Real64 Pcond;                    // VRF condensing pressure [Pa]
   11311             :     Real64 Pevap;                    // VRF evaporating pressure [Pa]
   11312             :     Real64 Pdischarge;               // VRF compressor discharge pressure [Pa]
   11313             :     Real64 Psuction;                 // VRF compressor suction pressure [Pa]
   11314             :     Real64 Pipe_DeltP_c;             // Piping Loss Algorithm Parameter: Pipe pressure drop (c) [Pa]
   11315             :     Real64 Pipe_DeltP_h;             // Piping Loss Algorithm Parameter: Pipe pressure drop (h) [Pa]
   11316             :     Real64 Pipe_Q_c;                 // Piping Loss Algorithm Parameter: Heat loss (c) [W]
   11317             :     Real64 Pipe_Q_h;                 // Piping Loss Algorithm Parameter: Heat loss (h) [W]
   11318             :     Real64 Q_c_TU_PL;                // Cooling load to be met at heating mode, including the piping loss(W)
   11319             :     Real64 Q_h_TU_PL;                // Heating load to be met at heating mode, including the piping loss (W)
   11320             :     Real64 Q_h_OU;                   // outdoor unit condenser heat release (cooling mode) [W]
   11321             :     Real64 Q_c_OU;                   // outdoor unit evaporator heat extract (heating mode) [W]
   11322             :     Real64 RefMaxPc;                 // maximum refrigerant condensing pressure [Pa]
   11323             :     Real64 RefMinTe;                 // Minimum refrigerant evaporating temperature [Pa]
   11324             :     Real64 RefMinPe;                 // Minimum refrigerant evaporating pressure [Pa]
   11325             :     Real64 RefPLow;                  // Low Pressure Value for Ps (>0.0) [Pa]
   11326             :     Real64 RefPHigh;                 // High Pressure Value for Ps (max in tables) [Pa]
   11327             :     Real64 RefTLow;                  // Low Temperature Value for Ps (max in tables) [C]
   11328             :     Real64 RefTHigh;                 // High Temperature Value for Ps (max in tables) [C]
   11329             :     Real64 RefTSat;                  // Saturated temperature of the refrigerant. Used to check whether the refrigerant is in the superheat area [C]
   11330             :     Real64 SC_IU_merged;             // Piping Loss Algorithm Parameter: average subcooling degrees after the indoor units [C]
   11331             :     Real64 SH_IU_merged;             // Piping Loss Algorithm Parameter: average super heating degrees after the indoor units [C]
   11332             :     Real64 SC_OU;                    // subcooling degrees at OU condenser [C]
   11333             :     Real64 SH_OU;                    // super heating degrees at OU evaporator [C]
   11334             :     Real64 SH_Comp;                  // Temperature difference between compressor inlet node and Tsuction [C]
   11335             :     Real64 T_comp_in;                // temperature of refrigerant at compressor inlet, after piping loss (c) [C]
   11336             :     Real64 TU_HeatingLoad;           // Heating load from terminal units, excluding heating loss [W]
   11337             :     Real64 TU_CoolingLoad;           // Cooling load from terminal units, excluding heating loss [W]
   11338             :     Real64 Tdischarge;               // VRF Compressor discharge refrigerant temperature [C]
   11339             :     Real64 Tsuction;                 // VRF compressor suction refrigerant temperature [C]
   11340             :     Real64 Tolerance;                // Tolerance for condensing temperature calculation [C]
   11341             :     Real64 Tfs;                      // Temperature of the air at the coil surface [C]
   11342       23418 :     Array1D<Real64> CompEvaporatingPWRSpd; // Array for the compressor power at certain speed [W]
   11343       23418 :     Array1D<Real64> CompEvaporatingCAPSpd; // Array for the evaporating capacity at certain speed [W]
   11344             : 
   11345             :     // variable initializations
   11346       11709 :     TUListNum = this->ZoneTUListPtr;
   11347       11709 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   11348       11709 :     VRFCond = state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(1)).VRFSysNum;
   11349       11709 :     TU_CoolingLoad = 0.0;
   11350       11709 :     TU_HeatingLoad = 0.0;
   11351       11709 :     TUParasiticPower = 0.0;
   11352       11709 :     TUFanPower = 0.0;
   11353       11709 :     CoolingPLR = 0.0;
   11354       11709 :     HeatingPLR = 0.0;
   11355       11709 :     CyclingRatio = 1.0;
   11356       11709 :     SumCoolInletWB = 0.0;
   11357       11709 :     SumHeatInletDB = 0.0;
   11358       11709 :     SumHeatInletWB = 0.0;
   11359       11709 :     TotalCondCoolingCapacity = 0.0;
   11360       11709 :     TotalCondHeatingCapacity = 0.0;
   11361       11709 :     TotalTUCoolingCapacity = 0.0;
   11362       11709 :     TotalTUHeatingCapacity = 0.0;
   11363       11709 :     NumTUInCoolingMode = 0;
   11364       11709 :     NumTUInHeatingMode = 0;
   11365       11709 :     Tolerance = 0.05;
   11366       11709 :     RefrigerantIndex = -1;
   11367       11709 :     Counter = 1;
   11368       11709 :     NumIteHIUIn = 1;
   11369       11709 :     this->ElecCoolingPower = 0.0;
   11370       11709 :     this->ElecHeatingPower = 0.0;
   11371       11709 :     this->CrankCaseHeaterPower = 0.0;
   11372       11709 :     this->EvapCondPumpElecPower = 0.0; // for EvaporativelyCooled condenser
   11373       11709 :     this->EvapWaterConsumpRate = 0.0;
   11374       11709 :     this->DefrostPower = 0.0;
   11375       11709 :     this->OperatingCoolingCOP = 0.0;
   11376       11709 :     this->OperatingHeatingCOP = 0.0;
   11377       11709 :     this->OperatingCOP = 0.0;
   11378       11709 :     this->SCHE = 0.0;
   11379       11709 :     this->BasinHeaterPower = 0.0;
   11380       11709 :     this->CondensingTemp = 60.0; // OutDryBulbTemp;
   11381       11709 :     this->VRFHeatRec = 0.0;
   11382             : 
   11383             :     // Refrigerant data
   11384       11709 :     RefMinTe = -15;
   11385       11709 :     RefMaxPc = 4000000.0;
   11386       11709 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   11387       11709 :     RefMinPe = GetSatPressureRefrig(state, this->RefrigerantName, RefMinTe, RefrigerantIndex, RoutineName);
   11388       11709 :     RefMinPe = GetSatPressureRefrig(state, this->RefrigerantName, RefMinTe, RefrigerantIndex, RoutineName);
   11389       11709 :     RefTLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowTempValue;   // High Temperature Value for Ps (max in tables)
   11390       11709 :     RefTHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighTempValue; // High Temperature Value for Ps (max in tables)
   11391       11709 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;   // Low Pressure Value for Ps (>0.0)
   11392       11709 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue; // High Pressure Value for Ps (max in tables)
   11393             : 
   11394             :     // sum loads on TU coils
   11395       70254 :     for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
   11396       58545 :         TU_CoolingLoad += state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU);
   11397       58545 :         TU_HeatingLoad += state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU);
   11398       58545 :         TUParasiticPower +=
   11399      117090 :             state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU)).ParasiticCoolElecPower +
   11400       58545 :             state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU)).ParasiticHeatElecPower;
   11401       58545 :         TUFanPower += state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU)).FanPower;
   11402             :     }
   11403       11709 :     this->TUCoolingLoad = TU_CoolingLoad; // this is cooling coil load, not terminal unit load
   11404       11709 :     this->TUHeatingLoad = TU_HeatingLoad; // this is heating coil load, not terminal unit load
   11405             : 
   11406             :     // loop through TU's and calculate average inlet conditions for active coils
   11407       70254 :     for (NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
   11408       58545 :         TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   11409       58545 :         CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   11410       58545 :         HeatCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex;
   11411             : 
   11412       58545 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0.0) {
   11413      102660 :             SumCoolInletWB += state.dataDXCoils->DXCoilCoolInletAirWBTemp(CoolCoilIndex) *
   11414       68440 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) / TU_CoolingLoad;
   11415       34220 :             ++NumTUInCoolingMode;
   11416             :         }
   11417       58545 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) > 0.0) {
   11418       61644 :             SumHeatInletDB += state.dataDXCoils->DXCoilHeatInletAirDBTemp(HeatCoilIndex) *
   11419       41096 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / TU_HeatingLoad;
   11420       61644 :             SumHeatInletWB += state.dataDXCoils->DXCoilHeatInletAirWBTemp(HeatCoilIndex) *
   11421       41096 :                               state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / TU_HeatingLoad;
   11422       20548 :             ++NumTUInHeatingMode;
   11423             :         }
   11424             :     }
   11425             : 
   11426             :     // set condenser entering air conditions (Outdoor air conditions)
   11427       11709 :     if (this->CondenserNodeNum != 0) {
   11428           0 :         OutdoorDryBulb = state.dataLoopNodes->Node(this->CondenserNodeNum).Temp;
   11429           0 :         if (this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   11430           0 :             OutdoorHumRat = state.dataLoopNodes->Node(this->CondenserNodeNum).HumRat;
   11431           0 :             OutdoorPressure = state.dataLoopNodes->Node(this->CondenserNodeNum).Press;
   11432           0 :             OutdoorWetBulb = state.dataLoopNodes->Node(this->CondenserNodeNum).OutAirWetBulb;
   11433             :         } else {
   11434           0 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11435           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11436           0 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11437             :         }
   11438             :     } else {
   11439       11709 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   11440       11709 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11441       11709 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11442       11709 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11443             :     }
   11444       11709 :     RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
   11445             : 
   11446       11709 :     CondInletTemp = OutdoorDryBulb; // this->CondenserType == AirCooled
   11447       11709 :     this->CondenserInletTemp = CondInletTemp;
   11448             : 
   11449             :     //*************
   11450             :     // VRF-HP MODES:
   11451             :     //     1. Cooling
   11452             :     //     2. Heating
   11453             :     //     3. No running
   11454             :     // VRF-HR MODES:
   11455             :     //     1. Cooling Only
   11456             :     //     2. Cooling Dominant w/o HR Loss
   11457             :     //     3. Cooling Dominant w/ HR Loss
   11458             :     //     4. Heating Dominant w/ HR Loss
   11459             :     //     5. Heating Dominant w/o HR Loss
   11460             :     //     6. Heating Only
   11461             :     //     7. No running
   11462             : 
   11463             :     // Flag for VRF-HR Operations
   11464       11709 :     if (TU_HeatingLoad > 0) {
   11465        4183 :         HRHeatRequestFlag = true;
   11466             :     } else {
   11467        7526 :         state.dataHVACVarRefFlow->HeatingLoad(VRFCond) = false;
   11468        7526 :         HRHeatRequestFlag = false;
   11469             :     }
   11470       11709 :     if (TU_CoolingLoad > 0) {
   11471        6977 :         HRCoolRequestFlag = true;
   11472             :     } else {
   11473        4732 :         state.dataHVACVarRefFlow->CoolingLoad(VRFCond) = false;
   11474        4732 :         HRCoolRequestFlag = false;
   11475             :     }
   11476             : 
   11477             :     // Initialization for Ncomp iterations
   11478       11709 :     NumOfCompSpdInput = this->CompressorSpeed.size();
   11479       11709 :     CompEvaporatingPWRSpd.dimension(NumOfCompSpdInput);
   11480       11709 :     CompEvaporatingCAPSpd.dimension(NumOfCompSpdInput);
   11481       11709 :     this->OperatingMode = 0; // report variable for heating or cooling mode
   11482             : 
   11483             :     // 1. VRF-HP Cooling Mode .OR. VRF-HR Mode_1
   11484       25900 :     if ((!this->HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) ||
   11485       11089 :         (this->HeatRecoveryUsed && !HRHeatRequestFlag && HRCoolRequestFlag)) {
   11486             : 
   11487        6977 :         this->OperatingMode = ModeCoolingOnly;
   11488        6977 :         this->VRFOperationSimPath = 10;
   11489             : 
   11490             :         // Initialization of VRF-FluidTCtrl Model
   11491        6977 :         Q_c_TU_PL = TU_CoolingLoad;
   11492             : 
   11493             :         // Evaporator (IU side) operational parameters
   11494        6977 :         Pevap = GetSatPressureRefrig(state, this->RefrigerantName, this->IUEvaporatingTemp, RefrigerantIndex, RoutineName);
   11495        6977 :         Psuction = Pevap;
   11496        6977 :         Tsuction = this->IUEvaporatingTemp; // GetSatTemperatureRefrig(state,  this->RefrigerantName, max( min( Psuction, RefPHigh ), RefPLow ),
   11497             :                                             // RefrigerantIndex, RoutineName );
   11498        6977 :         this->EvaporatingTemp =
   11499        6977 :             this->IUEvaporatingTemp; // GetSatTemperatureRefrig(state,  this->RefrigerantName, max( min( Pevap, RefPHigh ), RefPLow
   11500             :                                      // ), RefrigerantIndex, RoutineName );
   11501             : 
   11502             :         // Condenser (OU side) operation ranges
   11503        6977 :         CapMaxPc = min(Psuction + this->CompMaxDeltaP, RefMaxPc);
   11504        6977 :         CapMaxTc = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMaxPc, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11505        6977 :         CapMinTc = OutdoorDryBulb + this->SC;
   11506        6977 :         CapMinPc = GetSatPressureRefrig(state, this->RefrigerantName, CapMinTc, RefrigerantIndex, RoutineName);
   11507             : 
   11508             :         // Evaporator (IU side) operation ranges
   11509        6977 :         CapMinPe = max(CapMinPc - this->CompMaxDeltaP, RefMinPe);
   11510        6977 :         CapMinTe = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMinPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11511             : 
   11512             :         // Evaporative capacity ranges
   11513        6977 :         CompEvaporatingCAPSpdMin = this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(1), CapMinTc, CapMinTe);
   11514        6977 :         CompEvaporatingPWRSpdMin = this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(1), CapMinTc, CapMinTe);
   11515       13954 :         CompEvaporatingCAPSpdMax = this->CoffEvapCap * this->RatedEvapCapacity *
   11516       13954 :                                    CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), this->CondensingTemp, this->IUEvaporatingTemp);
   11517        6977 :         CompEvaporatingPWRSpdMax =
   11518       13954 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(NumOfCompSpdInput), this->CondensingTemp, this->IUEvaporatingTemp);
   11519             : 
   11520             :         // Initialization for h_IU_evap_in iterations (Label12)
   11521        6977 :         h_IU_evap_in_low =
   11522        6977 :             GetSatEnthalpyRefrig(state, this->RefrigerantName, OutdoorDryBulb - this->SC, 0.0, RefrigerantIndex, RoutineName); // Tc = Tamb
   11523        6977 :         h_IU_evap_in_up =
   11524        6977 :             GetSatEnthalpyRefrig(state, this->RefrigerantName, CapMaxTc - this->SC, 0.0, RefrigerantIndex, RoutineName); // Tc = CapMaxTc
   11525        6977 :         h_IU_evap_in =
   11526        6977 :             GetSatEnthalpyRefrig(state, this->RefrigerantName, OutdoorDryBulb + 10 - this->SC, 0.0, RefrigerantIndex, RoutineName); // Tc = Tamb+10
   11527             : 
   11528        6977 :         NumIteHIUIn = 1;
   11529        9485 :     Label12:;
   11530        9485 :         m_ref_IU_evap = 0;
   11531        9485 :         h_IU_evap_out = 0;
   11532        9485 :         h_IU_evap_out_i = 0;
   11533        9485 :         m_ref_IU_evap_i = 0;
   11534        9485 :         SH_IU_merged = 0;
   11535             : 
   11536             :         // Calculate total IU refrigerant flow rate and SH_IU_merged
   11537        9485 :         if (Q_c_TU_PL > CompEvaporatingCAPSpdMax) {
   11538             :             // Required load is beyond the max system capacity
   11539             : 
   11540        4483 :             Q_c_TU_PL = CompEvaporatingCAPSpdMax;
   11541        4483 :             TU_CoolingLoad = CompEvaporatingCAPSpdMax;
   11542        4483 :             this->TUCoolingLoad = TU_CoolingLoad;
   11543        4483 :             RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11544        8966 :             h_IU_evap_out = GetSupHeatEnthalpyRefrig(state,
   11545             :                                                      this->RefrigerantName,
   11546        4483 :                                                      max(RefTSat, this->IUEvaporatingTemp + 3),
   11547             :                                                      max(min(Pevap, RefPHigh), RefPLow),
   11548             :                                                      RefrigerantIndex,
   11549             :                                                      RoutineName);
   11550        4483 :             SH_IU_merged = 3;
   11551        4483 :             m_ref_IU_evap = TU_CoolingLoad / (h_IU_evap_out - h_IU_evap_in);
   11552             : 
   11553             :         } else {
   11554             : 
   11555       30012 :             for (NumTU = 1; NumTU <= NumTUInList; NumTU++) { // Calc total refrigerant flow rate
   11556       25010 :                 if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0) {
   11557       24345 :                     TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   11558       24345 :                     CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   11559             : 
   11560       24345 :                     RefTSat =
   11561       24345 :                         GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11562       24345 :                     h_IU_evap_out_i =
   11563       48690 :                         GetSupHeatEnthalpyRefrig(state,
   11564             :                                                  this->RefrigerantName,
   11565       24345 :                                                  max(RefTSat, this->IUEvaporatingTemp + state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH),
   11566             :                                                  max(min(Pevap, RefPHigh), RefPLow),
   11567             :                                                  RefrigerantIndex,
   11568             :                                                  RoutineName);
   11569             : 
   11570       24345 :                     if (h_IU_evap_out_i > h_IU_evap_in) {
   11571       48690 :                         m_ref_IU_evap_i = (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) <= 0.0)
   11572       48690 :                                               ? 0.0
   11573       24345 :                                               : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) /
   11574       24345 :                                                  (h_IU_evap_out_i - h_IU_evap_in)); // Ref Flow Rate in the IU( kg/s )
   11575       24345 :                         m_ref_IU_evap = m_ref_IU_evap + m_ref_IU_evap_i;
   11576       24345 :                         h_IU_evap_out = h_IU_evap_out + m_ref_IU_evap_i * h_IU_evap_out_i;
   11577       24345 :                         SH_IU_merged = SH_IU_merged + m_ref_IU_evap_i * state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH;
   11578             :                     }
   11579             :                 }
   11580             :             }
   11581        5002 :             if (m_ref_IU_evap > 0) {
   11582        5002 :                 h_IU_evap_out = h_IU_evap_out / m_ref_IU_evap;
   11583        5002 :                 SH_IU_merged = SH_IU_merged / m_ref_IU_evap;
   11584             :             } else {
   11585           0 :                 RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11586           0 :                 h_IU_evap_out = GetSupHeatEnthalpyRefrig(state,
   11587             :                                                          this->RefrigerantName,
   11588           0 :                                                          max(RefTSat, this->IUEvaporatingTemp + 3),
   11589             :                                                          max(min(Pevap, RefPHigh), RefPLow),
   11590             :                                                          RefrigerantIndex,
   11591             :                                                          RoutineName);
   11592           0 :                 SH_IU_merged = 3;
   11593           0 :                 m_ref_IU_evap = TU_CoolingLoad / (h_IU_evap_out - h_IU_evap_in);
   11594             :             }
   11595             :         }
   11596             : 
   11597             :         // *Calculate piping loss
   11598        9485 :         this->VRFOU_PipeLossC(
   11599             :             state, m_ref_IU_evap, max(min(Pevap, RefPHigh), RefPLow), h_IU_evap_out, SH_IU_merged, OutdoorDryBulb, Pipe_Q_c, Pipe_DeltP_c, h_comp_in);
   11600        9485 :         Tsuction =
   11601        9485 :             GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap - Pipe_DeltP_c, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11602        9485 :         Psuction = Pevap - Pipe_DeltP_c; // This Psuction is used for rps > min; will be updated for rps = min
   11603             : 
   11604             :         // Perform iteration to calculate T_comp_in
   11605        9485 :         T_comp_in = GetSupHeatTempRefrig(state,
   11606             :                                          this->RefrigerantName,
   11607             :                                          max(min(Pevap - Pipe_DeltP_c, RefPHigh), RefPLow),
   11608             :                                          h_comp_in,
   11609             :                                          Tsuction + 3,
   11610             :                                          Tsuction + 30,
   11611             :                                          RefrigerantIndex,
   11612             :                                          RoutineName);
   11613        9485 :         SH_Comp = T_comp_in - Tsuction; // This is used for rps > min; will be updated for rps = min
   11614             : 
   11615        9485 :         Q_c_TU_PL = TU_CoolingLoad + Pipe_Q_c;
   11616        9485 :         Q_h_OU = Q_c_TU_PL + CompEvaporatingPWRSpdMin;
   11617             : 
   11618             :         // *Calculate capacity modification factor
   11619        9485 :         C_cap_operation = this->VRFOU_CapModFactor(
   11620             :             state, h_comp_in, h_IU_evap_in, max(min(Psuction, RefPHigh), RefPLow), Tsuction + SH_Comp, Tsuction + 8, CapMinTc - 5);
   11621             : 
   11622        9485 :         if (Q_c_TU_PL * C_cap_operation < CompEvaporatingCAPSpdMin) {
   11623             :             // Required cooling load is less than the min cooling capacity, on-off strategy
   11624             : 
   11625        1194 :             this->VRFOperationSimPath = 11;
   11626             : 
   11627        1194 :             CyclingRatio = Q_c_TU_PL * C_cap_operation / CompEvaporatingCAPSpdMin;
   11628        1194 :             double CyclingRatioFrac = 0.85 + 0.15 * CyclingRatio;
   11629        1194 :             double HPRTF = CyclingRatio / CyclingRatioFrac;
   11630        1194 :             Ncomp = CompEvaporatingPWRSpdMin * HPRTF; //
   11631        1194 :             CompSpdActual = this->CompressorSpeed(1); //
   11632        1194 :             this->CondensingTemp = CapMinTc;          //
   11633             : 
   11634             :         } else {
   11635             :             // Required cooling load is greater than or equal to the min cooling capacity
   11636             : 
   11637             :             // Iteration_Ncomp: Perform iterations to calculate Ncomp (Label10)
   11638        8291 :             Counter = 1;
   11639        8291 :             Ncomp = TU_CoolingLoad / this->CoolingCOP;
   11640        8291 :             Ncomp_new = Ncomp;
   11641       13630 :         Label10:;
   11642       13630 :             Q_h_OU = Q_c_TU_PL + Ncomp_new; // Ncomp_new may be updated during Iteration_Ncomp Label10
   11643             : 
   11644             :             // *VRF OU TeTc calculations
   11645       13630 :             m_air = this->OUAirFlowRate * RhoAir;
   11646       13630 :             SC_OU = this->SC;
   11647       13630 :             this->VRFOU_TeTc(
   11648             :                 state, HXOpMode::CondMode, Q_h_OU, SC_OU, m_air, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure, Tfs, this->CondensingTemp);
   11649       13630 :             this->CondensingTemp = min(CapMaxTc, this->CondensingTemp);
   11650       13630 :             this->SC = SC_OU;
   11651             : 
   11652             :             // *VEF OU Compressor Simulation at cooling mode: Specify the compressor speed and power consumption
   11653       13630 :             this->VRFOU_CalcCompC(state,
   11654             :                                   TU_CoolingLoad,
   11655             :                                   Tsuction,
   11656             :                                   this->CondensingTemp,
   11657             :                                   Psuction,
   11658             :                                   T_comp_in,
   11659             :                                   h_comp_in,
   11660             :                                   h_IU_evap_in,
   11661             :                                   Pipe_Q_c,
   11662             :                                   CapMaxTc,
   11663             :                                   Q_h_OU,
   11664             :                                   CompSpdActual,
   11665             :                                   Ncomp);
   11666             : 
   11667       13630 :             if ((std::abs(Ncomp - Ncomp_new) > (Tolerance * Ncomp_new)) && (Counter < 30)) {
   11668        5339 :                 Ncomp_new = Ncomp;
   11669        5339 :                 Counter = Counter + 1;
   11670        5339 :                 goto Label10;
   11671             :             }
   11672             :         }
   11673             : 
   11674             :         // Update h_IU_evap_in in iterations Label12
   11675        9485 :         h_IU_evap_in_new = GetSatEnthalpyRefrig(state, this->RefrigerantName, this->CondensingTemp - this->SC, 0.0, RefrigerantIndex, RoutineName);
   11676        9485 :         if ((std::abs(h_IU_evap_in - h_IU_evap_in_new) > Tolerance * h_IU_evap_in) && (h_IU_evap_in < h_IU_evap_in_up) &&
   11677             :             (h_IU_evap_in > h_IU_evap_in_low)) {
   11678        2508 :             h_IU_evap_in = h_IU_evap_in_new;
   11679        2508 :             NumIteHIUIn = NumIteHIUIn + 1;
   11680        2508 :             goto Label12;
   11681             :         }
   11682        6977 :         if ((std::abs(h_IU_evap_in - h_IU_evap_in_new) > Tolerance * h_IU_evap_in)) {
   11683           0 :             h_IU_evap_in = 0.5 * (h_IU_evap_in_low + h_IU_evap_in_up);
   11684        6977 :         } else if (h_IU_evap_in > h_IU_evap_in_up) {
   11685           0 :             h_IU_evap_in = h_IU_evap_in_up;
   11686        6977 :         } else if (h_IU_evap_in < h_IU_evap_in_low) {
   11687           0 :             h_IU_evap_in = h_IU_evap_in_low;
   11688             :         } else {
   11689        6977 :             h_IU_evap_in = (h_IU_evap_in + h_IU_evap_in_new) / 2;
   11690             :         }
   11691             : 
   11692             :         // Key outputs of this subroutine
   11693        6977 :         this->CompActSpeed = max(CompSpdActual, 0.0);
   11694        6977 :         this->Ncomp = max(Ncomp, 0.0) / this->EffCompInverter; // 0.95 is the efficiency of the compressor inverter, can come from IDF //@minor
   11695        6977 :         this->OUFanPower = this->RatedOUFanPower;              //@ * pow_3( CondFlowRatio )
   11696        6977 :         this->VRFCondCyclingRatio = CyclingRatio;              // report variable for cycling rate
   11697             : 
   11698        6977 :         Tdischarge = this->CondensingTemp; // outdoor unit condensing temperature
   11699        6977 :         this->CoolingCapacity =
   11700       13954 :             this->CoffEvapCap * this->RatedEvapCapacity *
   11701       20931 :             CurveValue(
   11702        6977 :                 state, this->OUCoolingCAPFT(NumOfCompSpdInput), Tdischarge, Tsuction); // Include the piping loss, at the highest compressor speed
   11703        6977 :         this->PipingCorrectionCooling = TU_CoolingLoad / (TU_CoolingLoad + Pipe_Q_c);
   11704        6977 :         state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = this->CoolingCapacity; // for report, maximum evaporating capacity of the system
   11705             : 
   11706        6977 :         this->HeatingCapacity = 0.0;         // Include the piping loss
   11707        6977 :         this->PipingCorrectionHeating = 1.0; // 1 means no piping loss
   11708        6977 :         state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = 0.0;
   11709             : 
   11710        6977 :         this->OUCondHeatRate = Q_h_OU;
   11711        6977 :         this->OUEvapHeatRate = 0;
   11712        6977 :         this->IUCondHeatRate = 0;
   11713        6977 :         this->IUEvapHeatRate = TU_CoolingLoad;
   11714             : 
   11715             :         // 2. VRF-HP Heating Mode .OR. VRF-HR Mode_6
   11716       10821 :     } else if ((!this->HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) ||
   11717        3299 :                (this->HeatRecoveryUsed && !HRCoolRequestFlag && HRHeatRequestFlag)) {
   11718             : 
   11719        4183 :         this->OperatingMode = ModeHeatingOnly;
   11720        4183 :         this->VRFOperationSimPath = 60;
   11721             : 
   11722             :         // Initialization of VRF-FluidTCtrl Model
   11723        4183 :         Q_h_TU_PL = TU_HeatingLoad;
   11724        4183 :         Ncomp = TU_HeatingLoad / this->HeatingCOP;
   11725        4183 :         this->CondensingTemp = this->IUCondensingTemp;
   11726             : 
   11727             :         // Evaporative capacity ranges_Max
   11728        4183 :         CapMaxTe = OutdoorDryBulb - this->SH;
   11729        8366 :         CompEvaporatingCAPSpdMax = this->CoffEvapCap * this->RatedEvapCapacity *
   11730        8366 :                                    CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), this->IUCondensingTemp, CapMaxTe);
   11731        4183 :         CompEvaporatingPWRSpdMax =
   11732        8366 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(NumOfCompSpdInput), this->IUCondensingTemp, CapMaxTe);
   11733             : 
   11734             :         // Initialization of h_comp_out iterations (Label23)
   11735        4183 :         Pcond = GetSatPressureRefrig(state, this->RefrigerantName, 40.0, RefrigerantIndex, RoutineName);
   11736        4183 :         RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, Pcond, RefrigerantIndex, RoutineName);
   11737        4183 :         h_IU_cond_in_up = GetSupHeatEnthalpyRefrig(
   11738        4183 :             state, this->RefrigerantName, max(RefTSat, min(this->IUCondensingTemp + 50, RefTHigh)), Pcond, RefrigerantIndex, RoutineName);
   11739        4183 :         h_IU_cond_in_low =
   11740        4183 :             GetSatEnthalpyRefrig(state, this->RefrigerantName, this->IUCondensingTemp, 1.0, RefrigerantIndex, RoutineName); // Quality=1
   11741        4183 :         h_IU_cond_in = h_IU_cond_in_low;
   11742             : 
   11743       15709 :     Label23:;
   11744       15709 :         m_ref_IU_cond = 0;
   11745       15709 :         h_IU_cond_out_ave = 0;
   11746       15709 :         SC_IU_merged = 0;
   11747             : 
   11748             :         // Calculate total refrigerant flow rate
   11749       15709 :         if (Q_h_TU_PL > CompEvaporatingCAPSpdMax + CompEvaporatingPWRSpdMax) {
   11750             :             // Required load is beyond the max system capacity
   11751             : 
   11752        1368 :             Q_h_TU_PL = CompEvaporatingCAPSpdMax;
   11753        1368 :             TU_HeatingLoad = CompEvaporatingCAPSpdMax;
   11754        1368 :             this->TUHeatingLoad = TU_HeatingLoad;
   11755        1368 :             h_IU_cond_out = GetSatEnthalpyRefrig(
   11756             :                 state,
   11757             :                 this->RefrigerantName,
   11758        1368 :                 GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) - 5.0,
   11759             :                 0.0,
   11760             :                 RefrigerantIndex,
   11761             :                 RoutineName); // Quality=0
   11762        1368 :             h_IU_cond_out_ave = h_IU_cond_out;
   11763        1368 :             SC_IU_merged = 5;
   11764        1368 :             m_ref_IU_cond = TU_HeatingLoad / (h_IU_cond_in - h_IU_cond_out);
   11765             : 
   11766             :         } else {
   11767       86046 :             for (NumTU = 1; NumTU <= NumTUInList; NumTU++) {
   11768       71705 :                 if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) > 0) {
   11769       71338 :                     TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   11770       71338 :                     HeatCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex;
   11771       71338 :                     h_IU_cond_out_i = GetSatEnthalpyRefrig(
   11772             :                         state,
   11773             :                         this->RefrigerantName,
   11774       71338 :                         GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) -
   11775       71338 :                             state.dataDXCoils->DXCoil(HeatCoilIndex).ActualSC,
   11776             :                         0.0,
   11777             :                         RefrigerantIndex,
   11778             :                         RoutineName); // Quality=0
   11779       71338 :                     m_ref_IU_cond_i =
   11780       71338 :                         (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) <= 0.0)
   11781      142676 :                             ? 0.0
   11782       71338 :                             : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / (h_IU_cond_in - h_IU_cond_out_i));
   11783       71338 :                     m_ref_IU_cond = m_ref_IU_cond + m_ref_IU_cond_i;
   11784       71338 :                     h_IU_cond_out_ave = h_IU_cond_out_ave + m_ref_IU_cond_i * h_IU_cond_out_i;
   11785       71338 :                     SC_IU_merged = SC_IU_merged + m_ref_IU_cond_i * state.dataDXCoils->DXCoil(HeatCoilIndex).ActualSC;
   11786             :                 }
   11787             :             }
   11788       14341 :             if (m_ref_IU_cond > 0) {
   11789       14341 :                 h_IU_cond_out_ave = h_IU_cond_out_ave / m_ref_IU_cond; // h_merge
   11790       14341 :                 SC_IU_merged = SC_IU_merged / m_ref_IU_cond;
   11791             :             } else {
   11792           0 :                 h_IU_cond_out_ave = GetSatEnthalpyRefrig(
   11793             :                     state,
   11794             :                     this->RefrigerantName,
   11795           0 :                     GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) - 5.0,
   11796             :                     0.0,
   11797             :                     RefrigerantIndex,
   11798             :                     RoutineName); // Quality=0
   11799           0 :                 SC_IU_merged = 5;
   11800           0 :                 m_ref_IU_cond = TU_HeatingLoad / (h_IU_cond_in - h_IU_cond_out_ave);
   11801             :             }
   11802             :         }
   11803             : 
   11804             :         // *Calculate piping loss
   11805       15709 :         this->VRFOU_PipeLossH(
   11806             :             state, m_ref_IU_cond, max(min(Pcond, RefPHigh), RefPLow), h_IU_cond_in, OutdoorDryBulb, Pipe_Q_h, Pipe_DeltP_h, h_comp_out);
   11807             : 
   11808       15709 :         Pdischarge = max(Pcond + Pipe_DeltP_h, Pcond); // affected by piping loss
   11809       15709 :         Tdischarge = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pdischarge, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11810             : 
   11811             :         // Evaporative capacity ranges_Min
   11812       15709 :         CapMinPe = min(Pdischarge - this->CompMaxDeltaP, RefMinPe);
   11813       15709 :         CapMinTe = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMinPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11814       15709 :         CompEvaporatingCAPSpdMin = this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(1), Tdischarge, CapMinTe);
   11815       15709 :         CompEvaporatingPWRSpdMin = this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(1), Tdischarge, CapMinTe);
   11816             : 
   11817       15709 :         Q_h_TU_PL = TU_HeatingLoad + Pipe_Q_h;
   11818       15709 :         Q_c_OU = max(0.0, Q_h_TU_PL - CompEvaporatingPWRSpdMin);
   11819             : 
   11820             :         // *Calculate capacity modification factor
   11821       15709 :         RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMinPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11822       31418 :         h_comp_in = GetSupHeatEnthalpyRefrig(
   11823       15709 :             state, this->RefrigerantName, max(RefTSat, CapMinTe + this->SH), max(min(CapMinPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11824       31418 :         C_cap_operation = this->VRFOU_CapModFactor(state,
   11825             :                                                    h_comp_in,
   11826             :                                                    h_IU_cond_out_ave,
   11827             :                                                    max(min(CapMinPe, RefPHigh), RefPLow),
   11828       15709 :                                                    CapMinTe + this->SH,
   11829             :                                                    CapMinTe + 8,
   11830       15709 :                                                    this->IUCondensingTemp - 5);
   11831             : 
   11832       15709 :         if ((Q_c_OU * C_cap_operation) <= CompEvaporatingCAPSpdMin) {
   11833             :             // Required heating load is smaller than the min heating capacity
   11834             : 
   11835        1382 :             if (Q_c_OU == 0) {
   11836             :                 // Q_h_TU_PL is less than or equal to CompEvaporatingPWRSpdMin
   11837          17 :                 CyclingRatio = Q_h_TU_PL / CompEvaporatingPWRSpdMin;
   11838          17 :                 this->EvaporatingTemp = OutdoorDryBulb;
   11839             :             } else {
   11840             :                 // Q_h_TU_PL is greater than CompEvaporatingPWRSpdMin
   11841        1365 :                 CyclingRatio = Q_c_OU * C_cap_operation / CompEvaporatingCAPSpdMin;
   11842        1365 :                 this->EvaporatingTemp = max(CapMinTe, RefTLow);
   11843             :             }
   11844             : 
   11845        1382 :             double CyclingRatioFrac = 0.85 + 0.15 * CyclingRatio;
   11846        1382 :             double HPRTF = CyclingRatio / CyclingRatioFrac;
   11847        1382 :             Ncomp = CompEvaporatingPWRSpdMin * HPRTF;
   11848        1382 :             CompSpdActual = this->CompressorSpeed(1);
   11849             : 
   11850             :         } else {
   11851             :             // Required heating load is greater than or equal to the min heating capacity
   11852             : 
   11853             :             // Iteration_Ncomp: Perform iterations to calculate Ncomp (Label20)
   11854       14327 :             Counter = 1;
   11855       20100 :         Label20:;
   11856       20100 :             Ncomp_new = Ncomp;
   11857       20100 :             Q_c_OU = max(0.0, Q_h_TU_PL - Ncomp);
   11858             : 
   11859             :             // *VRF OU Te calculations
   11860       20100 :             m_air = this->OUAirFlowRate * RhoAir;
   11861       20100 :             SH_OU = this->SH;
   11862       20100 :             this->VRFOU_TeTc(
   11863             :                 state, HXOpMode::EvapMode, Q_c_OU, SH_OU, m_air, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure, Tfs, this->EvaporatingTemp);
   11864       20100 :             this->SH = SH_OU;
   11865             : 
   11866             :             // *VRF OU Compressor Simulation at heating mode: Specify the compressor speed and power consumption
   11867       20100 :             this->VRFOU_CalcCompH(state,
   11868             :                                   TU_HeatingLoad,
   11869             :                                   this->EvaporatingTemp,
   11870             :                                   Tdischarge,
   11871             :                                   h_IU_cond_out_ave,
   11872             :                                   this->IUCondensingTemp,
   11873             :                                   CapMinTe,
   11874             :                                   Tfs,
   11875             :                                   Pipe_Q_h,
   11876             :                                   Q_c_OU,
   11877             :                                   CompSpdActual,
   11878             :                                   Ncomp_new);
   11879             : 
   11880       20100 :             if ((std::abs(Ncomp_new - Ncomp) > (Tolerance * Ncomp)) && (Counter < 30)) {
   11881        5773 :                 Ncomp = Ncomp_new;
   11882        5773 :                 Counter = Counter + 1;
   11883        5773 :                 goto Label20;
   11884             :             }
   11885             : 
   11886             :             // Update h_comp_out in iteration Label23
   11887       14327 :             P_comp_in = GetSatPressureRefrig(state, this->RefrigerantName, this->EvaporatingTemp, RefrigerantIndex, RoutineName);
   11888       14327 :             RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(P_comp_in, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11889       28654 :             h_comp_in_new = GetSupHeatEnthalpyRefrig(state,
   11890             :                                                      this->RefrigerantName,
   11891       14327 :                                                      max(RefTSat, this->SH + this->EvaporatingTemp),
   11892             :                                                      max(min(P_comp_in, RefPHigh), RefPLow),
   11893             :                                                      RefrigerantIndex,
   11894             :                                                      RoutineName);
   11895       14327 :             h_comp_out_new = Ncomp_new / m_ref_IU_cond + h_comp_in_new;
   11896             : 
   11897       14327 :             if ((std::abs(h_comp_out - h_comp_out_new) > Tolerance * h_comp_out) && (h_IU_cond_in < h_IU_cond_in_up)) {
   11898       11526 :                 h_IU_cond_in = h_IU_cond_in + 0.1 * (h_IU_cond_in_up - h_IU_cond_in_low);
   11899       11526 :                 goto Label23;
   11900             :             }
   11901        2801 :             if (h_IU_cond_in > h_IU_cond_in_up) {
   11902           0 :                 h_IU_cond_in = 0.5 * (h_IU_cond_in_up + h_IU_cond_in_low);
   11903             :             }
   11904        2801 :             Ncomp = Ncomp_new;
   11905             :         }
   11906             : 
   11907             :         // Key outputs of this subroutine
   11908        4183 :         this->CompActSpeed = max(CompSpdActual, 0.0);
   11909        4183 :         this->Ncomp = max(Ncomp, 0.0) / this->EffCompInverter;
   11910        4183 :         this->OUFanPower = this->RatedOUFanPower;
   11911        4183 :         this->VRFCondCyclingRatio = CyclingRatio;
   11912             : 
   11913        4183 :         Tsuction = this->EvaporatingTemp; // Outdoor unit evaporating temperature
   11914        4183 :         this->HeatingCapacity =
   11915       12549 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), Tdischarge, Tsuction) +
   11916       12549 :             this->RatedCompPower * CurveValue(state,
   11917        4183 :                                               this->OUCoolingPWRFT(NumOfCompSpdInput),
   11918             :                                               Tdischarge,
   11919             :                                               Tsuction); // Include the piping loss, at the highest compressor speed
   11920        4183 :         this->PipingCorrectionHeating = TU_HeatingLoad / (TU_HeatingLoad + Pipe_Q_h);
   11921        4183 :         state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) =
   11922        4183 :             this->HeatingCapacity; // for report, maximum condensing capacity the system can provide
   11923             : 
   11924        4183 :         this->CoolingCapacity = 0.0; // Include the piping loss
   11925        4183 :         this->PipingCorrectionCooling = 0.0;
   11926        4183 :         state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = 0.0; // for report
   11927             : 
   11928        4183 :         this->OUCondHeatRate = 0;
   11929        4183 :         this->OUEvapHeatRate = Q_c_OU;
   11930        4183 :         this->IUCondHeatRate = TU_HeatingLoad;
   11931        4183 :         this->IUEvapHeatRate = 0;
   11932             : 
   11933             :         // 3. VRF-HR Mode_2-5, Simultaneous Heating and Cooling
   11934         549 :     } else if (this->HeatRecoveryUsed && HRCoolRequestFlag && HRHeatRequestFlag) {
   11935             : 
   11936           0 :         this->OperatingMode = ModeCoolingAndHeating;
   11937             : 
   11938             :         // Initialization of VRF-FluidTCtrl Model
   11939           0 :         Q_c_TU_PL = TU_CoolingLoad;
   11940           0 :         Q_h_TU_PL = TU_HeatingLoad;
   11941             : 
   11942             :         // Evaporator (IU side) operational parameters
   11943           0 :         Pevap = GetSatPressureRefrig(state, this->RefrigerantName, this->IUEvaporatingTemp, RefrigerantIndex, RoutineName);
   11944           0 :         Psuction = Pevap;
   11945           0 :         Tsuction = this->IUEvaporatingTemp;
   11946           0 :         this->EvaporatingTemp = this->IUEvaporatingTemp;
   11947             : 
   11948             :         // Condenser (OU side) operation ranges
   11949           0 :         CapMaxPc = min(Psuction + this->CompMaxDeltaP, RefMaxPc);
   11950           0 :         CapMaxTc = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMaxPc, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11951           0 :         CapMinTc = OutdoorDryBulb + this->SC;
   11952           0 :         CapMinPc = GetSatPressureRefrig(state, this->RefrigerantName, CapMinTc, RefrigerantIndex, RoutineName);
   11953             : 
   11954             :         // Evaporator (IU side) operation ranges
   11955           0 :         CapMinPe = max(CapMinPc - this->CompMaxDeltaP, RefMinPe);
   11956           0 :         CapMinTe = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(CapMinPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   11957             : 
   11958             :         //===**h_comp_out Iteration Starts
   11959             : 
   11960             :         // Initialization of h_comp_out iterations (Label230)
   11961             :         {
   11962           0 :             Pcond = GetSatPressureRefrig(state, this->RefrigerantName, this->IUCondensingTemp, RefrigerantIndex, RoutineName);
   11963           0 :             Real64 Pcond_temp = GetSatPressureRefrig(state, this->RefrigerantName, 40.0, RefrigerantIndex, RoutineName);
   11964           0 :             RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, Pcond_temp, RefrigerantIndex, RoutineName);
   11965           0 :             h_IU_cond_in_up = GetSupHeatEnthalpyRefrig(
   11966           0 :                 state, this->RefrigerantName, max(RefTSat, min(this->IUCondensingTemp + 50, RefTHigh)), Pcond_temp, RefrigerantIndex, RoutineName);
   11967           0 :             h_IU_cond_in_low =
   11968           0 :                 GetSatEnthalpyRefrig(state, this->RefrigerantName, this->IUCondensingTemp, 1.0, RefrigerantIndex, RoutineName); // Quality=1
   11969           0 :             h_IU_cond_in = h_IU_cond_in_low;
   11970             :         }
   11971             : 
   11972           0 :     Label230:;
   11973             : 
   11974             :         // *PL-h: Calculate total refrigerant flow rate
   11975           0 :         m_ref_IU_cond = 0;
   11976           0 :         h_IU_cond_out_ave = 0;
   11977           0 :         SC_IU_merged = 0;
   11978           0 :         for (NumTU = 1; NumTU <= NumTUInList; NumTU++) {
   11979           0 :             if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) > 0) {
   11980           0 :                 TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   11981           0 :                 HeatCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex;
   11982           0 :                 h_IU_cond_out_i = GetSatEnthalpyRefrig(
   11983             :                     state,
   11984             :                     this->RefrigerantName,
   11985           0 :                     GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) -
   11986           0 :                         state.dataDXCoils->DXCoil(HeatCoilIndex).ActualSC,
   11987             :                     0.0,
   11988             :                     RefrigerantIndex,
   11989             :                     RoutineName); // Quality=0
   11990           0 :                 m_ref_IU_cond_i =
   11991           0 :                     (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) <= 0.0)
   11992           0 :                         ? 0.0
   11993           0 :                         : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad(NumTU) / (h_IU_cond_in - h_IU_cond_out_i));
   11994           0 :                 m_ref_IU_cond = m_ref_IU_cond + m_ref_IU_cond_i;
   11995           0 :                 h_IU_cond_out_ave = h_IU_cond_out_ave + m_ref_IU_cond_i * h_IU_cond_out_i;
   11996           0 :                 SC_IU_merged = SC_IU_merged + m_ref_IU_cond_i * state.dataDXCoils->DXCoil(HeatCoilIndex).ActualSC;
   11997             :             }
   11998             :         }
   11999           0 :         if (m_ref_IU_cond > 0) {
   12000           0 :             h_IU_cond_out_ave = h_IU_cond_out_ave / m_ref_IU_cond;
   12001           0 :             SC_IU_merged = SC_IU_merged / m_ref_IU_cond;
   12002             :         } else {
   12003           0 :             h_IU_cond_out_ave = GetSatEnthalpyRefrig(
   12004             :                 state,
   12005             :                 this->RefrigerantName,
   12006           0 :                 GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) - 5.0,
   12007             :                 0.0,
   12008             :                 RefrigerantIndex,
   12009             :                 RoutineName); // Quality=0
   12010           0 :             SC_IU_merged = 5;
   12011           0 :             m_ref_IU_cond = TU_HeatingLoad / (h_IU_cond_in - h_IU_cond_out_ave);
   12012             :         }
   12013             : 
   12014             :         // *PL-h: Calculate piping loss
   12015           0 :         this->VRFOU_PipeLossH(
   12016             :             state, m_ref_IU_cond, max(min(Pcond, RefPHigh), RefPLow), h_IU_cond_in, OutdoorDryBulb, Pipe_Q_h, Pipe_DeltP_h, h_comp_out);
   12017           0 :         Pdischarge = max(Pcond + Pipe_DeltP_h, Pcond); // affected by piping loss
   12018           0 :         Tdischarge = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pdischarge, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   12019           0 :         Q_h_TU_PL = TU_HeatingLoad + Pipe_Q_h;
   12020             : 
   12021             :         // *PL-c: Calculate total IU refrigerant flow rate and SH_IU_merged
   12022           0 :         h_IU_evap_in = h_IU_cond_out_ave;
   12023           0 :         m_ref_IU_evap = 0;
   12024           0 :         h_IU_evap_out = 0;
   12025           0 :         SH_IU_merged = 0;
   12026           0 :         for (NumTU = 1; NumTU <= NumTUInList; NumTU++) { // Calc total refrigerant flow rate
   12027           0 :             if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0) {
   12028           0 :                 TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   12029           0 :                 CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   12030             : 
   12031           0 :                 RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   12032           0 :                 h_IU_evap_out_i = GetSupHeatEnthalpyRefrig(state,
   12033             :                                                            this->RefrigerantName,
   12034           0 :                                                            max(RefTSat, this->IUEvaporatingTemp + state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH),
   12035             :                                                            max(min(Pevap, RefPHigh), RefPLow),
   12036             :                                                            RefrigerantIndex,
   12037             :                                                            RoutineName);
   12038             : 
   12039           0 :                 if (h_IU_evap_out_i > h_IU_evap_in) {
   12040           0 :                     m_ref_IU_evap_i = (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) <= 0.0)
   12041           0 :                                           ? 0.0
   12042           0 :                                           : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) /
   12043           0 :                                              (h_IU_evap_out_i - h_IU_evap_in)); // Ref Flow Rate in the IU( kg/s )
   12044           0 :                     m_ref_IU_evap = m_ref_IU_evap + m_ref_IU_evap_i;
   12045           0 :                     h_IU_evap_out = h_IU_evap_out + m_ref_IU_evap_i * h_IU_evap_out_i;
   12046           0 :                     SH_IU_merged = SH_IU_merged + m_ref_IU_evap_i * state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH;
   12047             :                 }
   12048             :             }
   12049             :         }
   12050           0 :         if (m_ref_IU_evap > 0) {
   12051           0 :             h_IU_evap_out = h_IU_evap_out / m_ref_IU_evap;
   12052           0 :             SH_IU_merged = SH_IU_merged / m_ref_IU_evap;
   12053             :         } else {
   12054           0 :             RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pevap, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   12055           0 :             h_IU_evap_out = GetSupHeatEnthalpyRefrig(state,
   12056             :                                                      this->RefrigerantName,
   12057           0 :                                                      max(RefTSat, this->IUEvaporatingTemp + 3),
   12058             :                                                      max(min(Pevap, RefPHigh), RefPLow),
   12059             :                                                      RefrigerantIndex,
   12060             :                                                      RoutineName);
   12061           0 :             SH_IU_merged = 3;
   12062           0 :             m_ref_IU_evap = TU_CoolingLoad / (h_IU_evap_out - h_IU_evap_in);
   12063             :         }
   12064             : 
   12065             :         // *PL-c: Calculate piping loss
   12066           0 :         this->VRFOU_PipeLossC(state,
   12067             :                               m_ref_IU_evap,
   12068             :                               max(min(Pevap, RefPHigh), RefPLow),
   12069             :                               h_IU_evap_out,
   12070             :                               SH_IU_merged,
   12071             :                               OutdoorDryBulb,
   12072             :                               Pipe_Q_c,
   12073             :                               Pipe_DeltP_c,
   12074             :                               h_IU_PLc_out);
   12075           0 :         Psuction = min(Pevap - Pipe_DeltP_c, Pevap); // This Psuction is used for rps > min; will be updated for rps = min
   12076           0 :         Tsuction = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Psuction, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   12077           0 :         h_comp_in = h_IU_PLc_out;
   12078           0 :         Q_c_TU_PL = TU_CoolingLoad + Pipe_Q_c;
   12079             : 
   12080             :         //**OU operations: Determine VRF-HR OU system operational mode
   12081             :         //  Determine the operational mode of the VRF-HR system, given the terminal unit side load conditions.
   12082             :         //  A number of OU side operational parameters are also calculated here, including:
   12083             :         //  (1) OU evaporator load Q_c_OU, (2) OU condenser load Q_h_OU,
   12084             :         //  (3) m_ref_OU_evap, (4) m_ref_OU_cond
   12085             :         //  Note that Te and Te' may be updated here, and thus IU evaporator side piping loss recalculations.
   12086             :         //  Then a number of operational parameters need to be updated, including:
   12087             :         //  (1) IU evaporating temperature Te (2) OU evaporating temperature Te' etc (3) m_ref_IU_evap
   12088             :         //  (4) Pipe_Q_c (5) h_IU_PLc_out (6) h_comp_in
   12089             :         //*VRF OU Compressor Simulation at HR mode: Specify the compressor speed and power consumption
   12090             :         {
   12091           0 :             Real64 Pipe_Q_c_new = Pipe_Q_c;
   12092           0 :             Real64 Tsuction_new = Tsuction;
   12093           0 :             Real64 Te_new = this->IUEvaporatingTemp;
   12094             :             Real64 N_fan_OU;
   12095             : 
   12096           0 :             this->VRFHR_OU_HR_Mode(state,
   12097             :                                    h_IU_evap_in,
   12098             :                                    h_comp_out,
   12099             :                                    Q_c_TU_PL,
   12100             :                                    Q_h_TU_PL,
   12101             :                                    Tdischarge,
   12102             :                                    Tsuction_new,
   12103             :                                    Te_new,
   12104             :                                    h_comp_in,
   12105             :                                    h_IU_PLc_out,
   12106             :                                    Pipe_Q_c_new,
   12107             :                                    Q_c_OU,
   12108             :                                    Q_h_OU,
   12109             :                                    m_ref_IU_evap,
   12110             :                                    m_ref_OU_evap,
   12111             :                                    m_ref_OU_cond,
   12112             :                                    N_fan_OU,
   12113             :                                    CompSpdActual,
   12114             :                                    Ncomp);
   12115             : 
   12116             :             // parameter update
   12117           0 :             Tsuction = Tsuction_new;
   12118           0 :             Pipe_Q_c = Pipe_Q_c_new;
   12119           0 :             this->OUFanPower = N_fan_OU;
   12120           0 :             this->IUEvaporatingTemp = Te_new;
   12121             :         }
   12122             : 
   12123             :         //* Update h_comp_out in iteration (Label230)
   12124           0 :         h_comp_out_new = Ncomp / (m_ref_IU_evap + m_ref_OU_evap) + h_comp_in;
   12125             : 
   12126           0 :         if ((std::abs(h_comp_out - h_comp_out_new) > Tolerance * h_comp_out) && (h_IU_cond_in < h_IU_cond_in_up)) {
   12127           0 :             h_IU_cond_in = h_IU_cond_in + 0.1 * (h_IU_cond_in_up - h_IU_cond_in_low);
   12128           0 :             goto Label230;
   12129             :         }
   12130           0 :         if (h_IU_cond_in > h_IU_cond_in_up) {
   12131           0 :             h_IU_cond_in = 0.5 * (h_IU_cond_in_up + h_IU_cond_in_low);
   12132             :         }
   12133             : 
   12134             :         //===**h_comp_out Iteration Ends (Label230)
   12135             : 
   12136             :         // Key outputs of this subroutine
   12137           0 :         this->CompActSpeed = max(CompSpdActual, 0.0);
   12138           0 :         this->Ncomp = max(Ncomp, 0.0) / this->EffCompInverter;
   12139           0 :         this->VRFCondCyclingRatio = 1.0;
   12140             : 
   12141           0 :         this->HeatingCapacity =
   12142           0 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), Tdischarge, Tsuction) +
   12143           0 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(NumOfCompSpdInput), Tdischarge, Tsuction); // Include the piping loss
   12144           0 :         state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) =
   12145           0 :             this->HeatingCapacity; // for report, maximum heating capacity of the system, at the highest compressor speed
   12146           0 :         this->PipingCorrectionHeating = TU_HeatingLoad / Q_h_TU_PL;
   12147             : 
   12148           0 :         this->CoolingCapacity =
   12149           0 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), Tdischarge, Tsuction);
   12150           0 :         state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) =
   12151           0 :             this->CoolingCapacity; // for report, maximum evaporating capacity of the system, at the highest compressor speed
   12152           0 :         this->PipingCorrectionCooling = TU_CoolingLoad / Q_c_TU_PL;
   12153             : 
   12154           0 :         this->CondensingTemp = Tdischarge; // OU condensing temperature
   12155           0 :         this->EvaporatingTemp = Tsuction;  // OU evaporating temperature
   12156             : 
   12157           0 :         this->OUCondHeatRate = Q_h_OU;
   12158           0 :         this->OUEvapHeatRate = Q_c_OU;
   12159           0 :         this->IUCondHeatRate = TU_HeatingLoad;
   12160           0 :         this->IUEvapHeatRate = TU_CoolingLoad;
   12161             : 
   12162             :         // 4. Stop running
   12163             :     } else {
   12164             : 
   12165         549 :         this->OperatingMode = 0;
   12166         549 :         this->VRFOperationSimPath = 0;
   12167             : 
   12168         549 :         this->Ncomp = 0.0;
   12169         549 :         this->CompActSpeed = 0.0;
   12170         549 :         this->OUFanPower = 0.0;
   12171         549 :         this->VRFCondCyclingRatio = 0.0;
   12172             : 
   12173         549 :         this->HeatingCapacity = 0.0;         // Include the piping loss
   12174         549 :         this->PipingCorrectionHeating = 1.0; // 1 means no piping loss
   12175         549 :         state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond) = 0.0;
   12176             : 
   12177         549 :         this->CoolingCapacity = 0.0; // Include the piping loss
   12178         549 :         this->PipingCorrectionCooling = 0.0;
   12179         549 :         state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond) = 0.0; // for report
   12180             : 
   12181         549 :         this->CondensingTemp = state.dataEnvrn->OutDryBulbTemp;
   12182         549 :         this->EvaporatingTemp = state.dataEnvrn->OutDryBulbTemp;
   12183             : 
   12184         549 :         this->OUCondHeatRate = 0.0;
   12185         549 :         this->OUEvapHeatRate = 0.0;
   12186         549 :         this->IUCondHeatRate = 0.0;
   12187         549 :         this->IUEvapHeatRate = 0.0;
   12188             :     }
   12189             : 
   12190             :     // calculate capacities and energy use
   12191       18686 :     if (((!this->HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) || (this->HeatRecoveryUsed && HRCoolRequestFlag)) &&
   12192        6977 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).CoolingCoilPresent(NumTUInList)) {
   12193        6977 :         InletAirWetBulbC = SumCoolInletWB;
   12194             : 
   12195             :         // From the VRF_FluidTCtrl model
   12196        6977 :         TotalCondCoolingCapacity = this->CoolingCapacity;
   12197        6977 :         TotalTUCoolingCapacity = TotalCondCoolingCapacity * this->PipingCorrectionCooling;
   12198             : 
   12199        6977 :         if (TotalCondCoolingCapacity > 0.0) {
   12200        6977 :             CoolingPLR = min(1.0, (this->TUCoolingLoad / this->PipingCorrectionCooling) / TotalCondCoolingCapacity);
   12201             :         } else {
   12202           0 :             CoolingPLR = 0.0;
   12203             :         }
   12204             :     }
   12205       15892 :     if (((!this->HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) || (this->HeatRecoveryUsed && HRHeatRequestFlag)) &&
   12206        4183 :         state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).HeatingCoilPresent(NumTUInList)) {
   12207        4183 :         InletAirDryBulbC = SumHeatInletDB;
   12208        4183 :         InletAirWetBulbC = SumHeatInletWB;
   12209             : 
   12210             :         // Initializing defrost adjustment factors
   12211        4183 :         LoadDueToDefrost = 0.0;
   12212        4183 :         HeatingCapacityMultiplier = 1.0;
   12213        4183 :         FractionalDefrostTime = 0.0;
   12214        4183 :         InputPowerMultiplier = 1.0;
   12215             : 
   12216             :         // Check outdoor temperature to determine of defrost is active
   12217        4183 :         if (OutdoorDryBulb <= this->MaxOATDefrost && this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   12218             : 
   12219             :             // Calculating adjustment factors for defrost
   12220             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
   12221        1421 :             OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
   12222        1421 :             OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure)));
   12223             : 
   12224             :             // Calculate defrost adjustment factors depending on defrost control type
   12225        1421 :             if (this->DefrostControl == StandardRatings::HPdefrostControl::Timed) {
   12226        1421 :                 FractionalDefrostTime = this->DefrostFraction;
   12227        1421 :                 if (FractionalDefrostTime > 0.0) {
   12228        1421 :                     HeatingCapacityMultiplier = 0.909 - 107.33 * OutdoorCoildw;
   12229        1421 :                     InputPowerMultiplier = 0.90 - 36.45 * OutdoorCoildw;
   12230             :                 }
   12231             :             } else { // else defrost control is on-demand
   12232           0 :                 FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / OutdoorCoildw);
   12233           0 :                 HeatingCapacityMultiplier = 0.875 * (1.0 - FractionalDefrostTime);
   12234           0 :                 InputPowerMultiplier = 0.954 * (1.0 - FractionalDefrostTime);
   12235             :             }
   12236             : 
   12237        1421 :             if (FractionalDefrostTime > 0.0) {
   12238             :                 // Calculate defrost adjustment factors depending on defrost control strategy
   12239        2842 :                 if (this->DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
   12240        1421 :                     this->DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
   12241           0 :                     LoadDueToDefrost = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) * (this->HeatingCapacity / 1.01667);
   12242           0 :                     DefrostEIRTempModFac = CurveValue(state, this->DefrostEIRPtr, max(15.555, InletAirWetBulbC), max(15.555, OutdoorDryBulb));
   12243             : 
   12244             :                     //         Warn user if curve output goes negative
   12245           0 :                     if (DefrostEIRTempModFac < 0.0) {
   12246           0 :                         if (!state.dataGlobal->WarmupFlag) {
   12247           0 :                             if (this->DefrostHeatErrorIndex == 0) {
   12248           0 :                                 ShowSevereMessage(state, std::string(cVRFTypes(VRF_HeatPump)) + " \"" + this->Name + "\":");
   12249           0 :                                 ShowContinueError(
   12250             :                                     state,
   12251           0 :                                     format(" Defrost Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).",
   12252           0 :                                            DefrostEIRTempModFac));
   12253           0 :                                 ShowContinueError(state,
   12254           0 :                                                   format(" Negative value occurs using an outdoor air dry-bulb temperature of {:.1T} C and an "
   12255             :                                                          "average indoor air wet-bulb temperature of {:.1T} C.",
   12256             :                                                          OutdoorDryBulb,
   12257           0 :                                                          InletAirWetBulbC));
   12258           0 :                                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   12259             :                             }
   12260           0 :                             ShowRecurringWarningErrorAtEnd(state,
   12261           0 :                                                            format("{} \"{}\": Defrost Energy Input Ratio Modifier curve (function of temperature) "
   12262             :                                                                   "output is negative warning continues...",
   12263           0 :                                                                   PlantEquipTypeNames[static_cast<int>(PlantEquipmentType::HeatPumpVRF)],
   12264           0 :                                                                   this->Name),
   12265             :                                                            this->DefrostHeatErrorIndex,
   12266             :                                                            DefrostEIRTempModFac,
   12267             :                                                            DefrostEIRTempModFac);
   12268           0 :                             DefrostEIRTempModFac = 0.0;
   12269             :                         }
   12270             :                     }
   12271             : 
   12272           0 :                     this->DefrostPower = DefrostEIRTempModFac * (this->HeatingCapacity / 1.01667) * FractionalDefrostTime;
   12273             : 
   12274             :                 } else { // Defrost strategy is resistive
   12275        1421 :                     this->DefrostPower = this->DefrostCapacity * FractionalDefrostTime;
   12276             :                 }
   12277             :             } else { // Defrost is not active because FractionalDefrostTime = 0.0
   12278           0 :                 this->DefrostPower = 0.0;
   12279             :             }
   12280             :         }
   12281             : 
   12282             :         // From the VRF_FluidTCtrl model
   12283        4183 :         TotalCondHeatingCapacity = this->HeatingCapacity;
   12284        4183 :         TotalTUHeatingCapacity = TotalCondHeatingCapacity * this->PipingCorrectionHeating;
   12285             : 
   12286        4183 :         if (TotalCondHeatingCapacity > 0.0) {
   12287        4183 :             HeatingPLR = min(1.0, (this->TUHeatingLoad / this->PipingCorrectionHeating) / TotalCondHeatingCapacity);
   12288        4183 :             HeatingPLR += (LoadDueToDefrost * HeatingPLR) / TotalCondHeatingCapacity;
   12289             :         } else {
   12290           0 :             HeatingPLR = 0.0;
   12291             :         }
   12292             :     }
   12293             : 
   12294       11709 :     this->VRFCondPLR = max(CoolingPLR, HeatingPLR);
   12295             : 
   12296             :     // For VRF-HR Operations
   12297       11709 :     HRInitialCapFrac = 1.0;
   12298       11709 :     HRInitialEIRFrac = 1.0;
   12299       11709 :     HRCapTC = 0.0;
   12300       11709 :     HREIRTC = 0.0;
   12301       11709 :     if (!state.dataGlobal->DoingSizing && !state.dataGlobal->WarmupFlag) {
   12302        1626 :         if (HRHeatRequestFlag && HRCoolRequestFlag) { // Simultaneous Heating and Cooling operations for HR system
   12303             :             // determine operating mode change: (1) ModeChange (2) HRCoolingActive (3) HRHeatingActive
   12304           0 :             if (!this->HRCoolingActive && !this->HRHeatingActive) {
   12305           0 :                 this->ModeChange = true;
   12306             :             }
   12307           0 :             if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) {
   12308           0 :                 if (this->HRHeatingActive && !this->HRCoolingActive) {
   12309           0 :                     this->HRModeChange = true;
   12310             :                 }
   12311           0 :                 this->HRCoolingActive = true;
   12312           0 :                 this->HRHeatingActive = false;
   12313             : 
   12314           0 :                 HRInitialCapFrac = this->HRInitialCoolCapFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode
   12315           0 :                 HRCapTC = this->HRCoolCapTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
   12316             : 
   12317           0 :                 HRInitialEIRFrac = this->HRInitialCoolEIRFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode
   12318           0 :                 HREIRTC = this->HRCoolEIRTC;                   // Time constant used to recover from initial degradation in cooling heat recovery
   12319             : 
   12320           0 :             } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) {
   12321           0 :                 if (!this->HRHeatingActive && this->HRCoolingActive) {
   12322           0 :                     this->HRModeChange = true;
   12323             :                 }
   12324           0 :                 this->HRCoolingActive = false;
   12325           0 :                 this->HRHeatingActive = true;
   12326             : 
   12327           0 :                 HRInitialCapFrac = this->HRInitialHeatCapFrac; // Fractional heating degradation at the start of heat recovery from cooling mode
   12328           0 :                 HRCapTC = this->HRHeatCapTC;                   // Time constant used to recover from initial degradation in heating heat recovery
   12329             : 
   12330           0 :                 HRInitialEIRFrac = this->HRInitialHeatEIRFrac; // Fractional heating degradation at the start of heat recovery from heating mode
   12331           0 :                 HREIRTC = this->HRHeatEIRTC;                   // Time constant used to recover from initial degradation in heating heat recovery
   12332             : 
   12333             :             } else {
   12334             :                 // zone thermostats satisfied, condenser is off. Set values anyway
   12335             :                 // HRCAPFTConst = 1.0;
   12336           0 :                 HRInitialCapFrac = 1.0;
   12337           0 :                 HRCapTC = 1.0;
   12338             :                 // HREIRFTConst = 1.0;
   12339           0 :                 HRInitialEIRFrac = 1.0;
   12340           0 :                 HREIRTC = 1.0;
   12341           0 :                 if (this->HRHeatingActive || this->HRCoolingActive) {
   12342           0 :                     this->HRModeChange = true;
   12343             :                 }
   12344           0 :                 this->HRCoolingActive = false;
   12345           0 :                 this->HRHeatingActive = false;
   12346             :             }
   12347             : 
   12348             :         } else { // IF(HRHeatRequestFlag .AND. HRCoolRequestFlag)THEN -- Heat recovery turned off
   12349        1626 :             HRInitialCapFrac = 1.0;
   12350        1626 :             HRCapTC = 0.0;
   12351        1626 :             HRInitialEIRFrac = 1.0;
   12352        1626 :             HREIRTC = 0.0;
   12353        1626 :             this->HRModeChange = false;
   12354        1626 :             this->HRCoolingActive = false;
   12355        1626 :             this->HRHeatingActive = false;
   12356             :         }
   12357             : 
   12358             :         // Calculate the capacity modification factor (SUMultiplier) for the HR mode transition period
   12359             :         {
   12360        3252 :             CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone +
   12361        1626 :                              state.dataHVACGlobal->SysTimeElapsed;
   12362             : 
   12363        1626 :             if (this->ModeChange || this->HRModeChange) {
   12364           0 :                 if (this->HRCoolingActive && this->HRTimer == 0.0) {
   12365           0 :                     this->HRTimer = state.dataHVACVarRefFlow->CurrentEndTimeLast;
   12366           0 :                 } else if (this->HRHeatingActive && this->HRTimer == 0.0) {
   12367           0 :                     this->HRTimer = state.dataHVACVarRefFlow->CurrentEndTimeLast;
   12368           0 :                 } else if (!this->HRCoolingActive && !this->HRHeatingActive) {
   12369           0 :                     this->HRTimer = 0.0;
   12370             :                 }
   12371             :             }
   12372             : 
   12373        1626 :             this->HRTime = max(0.0, CurrentEndTime - this->HRTimer);
   12374        1626 :             if (this->HRTime < (HRCapTC * 5.0)) {
   12375           0 :                 if (HRCapTC > 0.0) {
   12376           0 :                     SUMultiplier = min(1.0, 1.0 - std::exp(-this->HRTime / HRCapTC));
   12377             :                 } else {
   12378           0 :                     SUMultiplier = 1.0;
   12379             :                 }
   12380             :             } else {
   12381        1626 :                 SUMultiplier = 1.0;
   12382        1626 :                 this->ModeChange = false;
   12383        1626 :                 this->HRModeChange = false;
   12384             :             }
   12385        1626 :             this->SUMultiplier = SUMultiplier;
   12386             : 
   12387        1626 :             state.dataHVACVarRefFlow->CurrentEndTimeLast = CurrentEndTime;
   12388             :         }
   12389             : 
   12390             :         // Modify HR capacity for the transition period
   12391             :         {
   12392        1626 :             if (this->HeatRecoveryUsed && this->HRCoolingActive) {
   12393           0 :                 TotalCondCoolingCapacity =
   12394           0 :                     HRInitialCapFrac * TotalCondCoolingCapacity + (1.0 - HRInitialCapFrac) * TotalCondCoolingCapacity * SUMultiplier;
   12395           0 :                 TotalTUCoolingCapacity = TotalCondCoolingCapacity * this->PipingCorrectionCooling;
   12396           0 :                 if (TotalCondCoolingCapacity > 0.0) {
   12397           0 :                     CoolingPLR = min(1.0, (this->TUCoolingLoad / this->PipingCorrectionCooling) / TotalCondCoolingCapacity);
   12398             :                 } else {
   12399           0 :                     CoolingPLR = 0.0;
   12400             :                 }
   12401           0 :                 this->VRFHeatRec = this->TUHeatingLoad;
   12402        1626 :             } else if (this->HeatRecoveryUsed && this->HRHeatingActive) {
   12403           0 :                 TotalCondHeatingCapacity =
   12404           0 :                     HRInitialCapFrac * TotalCondHeatingCapacity + (1.0 - HRInitialCapFrac) * TotalCondHeatingCapacity * SUMultiplier;
   12405           0 :                 TotalTUHeatingCapacity = TotalCondHeatingCapacity * this->PipingCorrectionHeating;
   12406           0 :                 if (TotalCondHeatingCapacity > 0.0) {
   12407           0 :                     HeatingPLR = min(1.0, (this->TUHeatingLoad / this->PipingCorrectionHeating) / TotalCondHeatingCapacity);
   12408             :                 } else {
   12409           0 :                     HeatingPLR = 0.0;
   12410             :                 }
   12411           0 :                 this->VRFHeatRec = this->TUCoolingLoad;
   12412             :             }
   12413             : 
   12414        1626 :             this->VRFCondPLR = max(CoolingPLR, HeatingPLR);
   12415             :         }
   12416             :     }
   12417             : 
   12418       11709 :     this->TotalCoolingCapacity = TotalCondCoolingCapacity * CoolingPLR;
   12419       11709 :     this->TotalHeatingCapacity = TotalCondHeatingCapacity * HeatingPLR;
   12420             : 
   12421       11709 :     if (this->MinPLR > 0.0) {
   12422           0 :         bool const plrTooLow = this->VRFCondPLR < this->MinPLR;
   12423           0 :         bool const plrGreaterThanZero = this->VRFCondPLR > 0.0;
   12424           0 :         if (plrTooLow && plrGreaterThanZero) {
   12425           0 :             this->VRFCondPLR = this->MinPLR;
   12426             :         }
   12427             :     }
   12428             : 
   12429       11709 :     VRFRTF = 0.0;
   12430             :     // VRF Cooling and Heating Electric Power (output variables)
   12431       11709 :     if (this->OperatingMode == ModeCoolingOnly) {
   12432        6977 :         PartLoadFraction = 1.0;
   12433        6977 :         VRFRTF = min(1.0, (CyclingRatio / PartLoadFraction));
   12434             : 
   12435        6977 :         this->ElecCoolingPower = state.dataHVACVarRefFlow->VRF(VRFCond).Ncomp + this->OUFanPower;
   12436        6977 :         this->ElecHeatingPower = 0;
   12437             : 
   12438        4732 :     } else if (this->OperatingMode == ModeHeatingOnly) {
   12439        4183 :         PartLoadFraction = 1.0;
   12440        4183 :         VRFRTF = min(1.0, (CyclingRatio / PartLoadFraction));
   12441             : 
   12442        4183 :         this->ElecCoolingPower = 0;
   12443        4183 :         this->ElecHeatingPower = this->Ncomp + this->OUFanPower;
   12444             : 
   12445         549 :     } else if (this->OperatingMode == ModeCoolingAndHeating) {
   12446           0 :         PartLoadFraction = 1.0;
   12447           0 :         VRFRTF = min(1.0, (CyclingRatio / PartLoadFraction));
   12448             : 
   12449           0 :         this->ElecCoolingPower = (this->Ncomp + this->OUFanPower) * this->IUEvapHeatRate / (this->IUCondHeatRate + this->IUEvapHeatRate);
   12450           0 :         this->ElecHeatingPower = (this->Ncomp + this->OUFanPower) * this->IUCondHeatRate / (this->IUCondHeatRate + this->IUEvapHeatRate);
   12451             : 
   12452             :     } else {
   12453         549 :         this->ElecCoolingPower = 0;
   12454         549 :         this->ElecHeatingPower = 0;
   12455             :     }
   12456       11709 :     this->VRFCondRTF = VRFRTF;
   12457             : 
   12458             :     // Calculate CrankCaseHeaterPower: VRF Heat Pump Crankcase Heater Electric Power [W]
   12459       11709 :     if (this->MaxOATCCHeater > OutdoorDryBulb) {
   12460             :         // calculate crankcase heater power
   12461        1421 :         this->CrankCaseHeaterPower = this->CCHeaterPower * (1.0 - VRFRTF);
   12462        1421 :         if (this->NumCompressors > 1) {
   12463           0 :             UpperStageCompressorRatio = (1.0 - this->CompressorSizeRatio) / (this->NumCompressors - 1);
   12464           0 :             for (Stage = 1; Stage <= this->NumCompressors - 2; ++Stage) {
   12465           0 :                 if (this->VRFCondPLR < (this->CompressorSizeRatio + Stage * UpperStageCompressorRatio)) {
   12466           0 :                     this->CrankCaseHeaterPower += this->CCHeaterPower;
   12467             :                 }
   12468             :             }
   12469             :         }
   12470             :     } else {
   12471       10288 :         this->CrankCaseHeaterPower = 0.0;
   12472             :     }
   12473             : 
   12474             :     // Calculate QCondenser: VRF Heat Pump Condenser Heat Transfer Rate [W]
   12475       11709 :     CondCapacity = max(this->TotalCoolingCapacity, this->TotalHeatingCapacity) * VRFRTF;
   12476       11709 :     CondPower = max(this->ElecCoolingPower, this->ElecHeatingPower);
   12477       11709 :     if (this->ElecHeatingPower > 0.0) {
   12478        4183 :         this->QCondenser = CondCapacity + CondPower - this->TUHeatingLoad / this->PipingCorrectionHeating;
   12479        7526 :     } else if (this->ElecCoolingPower > 0.0) {
   12480        6977 :         this->QCondenser = -CondCapacity + CondPower + this->TUCoolingLoad / this->PipingCorrectionCooling;
   12481             :     } else {
   12482         549 :         this->QCondenser = 0.0;
   12483             :     }
   12484             :     // if ( this->CondenserType == DataHVACGlobals::EvapCooled )
   12485             : 
   12486             :     // Calculate OperatingHeatingCOP & OperatingCoolingCOP: VRF Heat Pump Operating COP []
   12487       11709 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && CoolingPLR > 0.0) {
   12488        6977 :         if (this->ElecCoolingPower != 0.0) {
   12489             :             // this calc should use delivered capacity, not condenser capacity, use VRF(VRFCond).TUCoolingLoad
   12490       13954 :             this->OperatingCoolingCOP = (this->TotalCoolingCapacity) /
   12491        6977 :                                         (this->ElecCoolingPower + this->CrankCaseHeaterPower + this->EvapCondPumpElecPower + this->DefrostPower);
   12492             :         } else {
   12493           0 :             this->OperatingCoolingCOP = 0.0;
   12494             :         }
   12495             :     }
   12496       11709 :     if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && HeatingPLR > 0.0) {
   12497             :         // this calc should use delivered capacity, not condenser capacity, use VRF(VRFCond).TUHeatingLoad
   12498        4183 :         if (this->ElecHeatingPower != 0.0) {
   12499        8366 :             this->OperatingHeatingCOP = (this->TotalHeatingCapacity) /
   12500        4183 :                                         (this->ElecHeatingPower + this->CrankCaseHeaterPower + this->EvapCondPumpElecPower + this->DefrostPower);
   12501             :         } else {
   12502           0 :             this->OperatingHeatingCOP = 0.0;
   12503             :         }
   12504             :     }
   12505             : 
   12506       35127 :     TotPower = TUParasiticPower + TUFanPower + this->ElecHeatingPower + this->ElecCoolingPower + this->CrankCaseHeaterPower +
   12507       23418 :                this->EvapCondPumpElecPower + this->DefrostPower;
   12508       11709 :     if (TotPower > 0.0) {
   12509       11709 :         this->OperatingCOP = (this->TUCoolingLoad + this->TUHeatingLoad) / TotPower;
   12510       11709 :         this->SCHE = this->OperatingCOP * 3.412;
   12511             :     }
   12512             : 
   12513             :     // limit the TU capacity when the condenser is maxed out on capacity
   12514             :     // I think this next line will make the max cap report variable match the coil objects, will probably change the answer though
   12515             :     //  IF(CoolingLoad(VRFCond) .AND. NumTUInCoolingMode .GT. 0 .AND. MaxCoolingCapacity(VRFCond) == MaxCap)THEN
   12516       11709 :     if (state.dataHVACVarRefFlow->CoolingLoad(VRFCond) && NumTUInCoolingMode > 0) {
   12517             : 
   12518             :         //   IF TU capacity is greater than condenser capacity find maximum allowed TU capacity (i.e., conserve energy)
   12519        6977 :         if (TU_CoolingLoad > TotalTUCoolingCapacity) {
   12520        2156 :             LimitTUCapacity(state,
   12521             :                             VRFCond,
   12522             :                             NumTUInList,
   12523             :                             TotalTUCoolingCapacity,
   12524        1078 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad,
   12525        1078 :                             state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond),
   12526             :                             TotalTUHeatingCapacity,
   12527        1078 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad,
   12528        1078 :                             state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond));
   12529             :         }
   12530        4732 :     } else if (state.dataHVACVarRefFlow->HeatingLoad(VRFCond) && NumTUInHeatingMode > 0) {
   12531             :         //   IF TU capacity is greater than condenser capacity
   12532        4183 :         if (TU_HeatingLoad > TotalTUHeatingCapacity) {
   12533           0 :             LimitTUCapacity(state,
   12534             :                             VRFCond,
   12535             :                             NumTUInList,
   12536             :                             TotalTUHeatingCapacity,
   12537           0 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalHeatLoad,
   12538           0 :                             state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond),
   12539             :                             TotalTUCoolingCapacity,
   12540           0 :                             state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad,
   12541           0 :                             state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond));
   12542             :         }
   12543             :     } else {
   12544             :     }
   12545             : 
   12546             :     // Calculate the IU Te/Tc for the next time step
   12547       11709 :     this->CalcVRFIUTeTc_FluidTCtrl(state);
   12548       11709 : }
   12549             : 
   12550       58545 : void VRFTerminalUnitEquipment::ControlVRF_FluidTCtrl(EnergyPlusData &state,
   12551             :                                                      int const VRFTUNum,            // Index to VRF terminal unit
   12552             :                                                      Real64 const QZnReq,           // Index to zone number
   12553             :                                                      bool const FirstHVACIteration, // flag for 1st HVAC iteration in the time step
   12554             :                                                      Real64 &PartLoadRatio,         // unit part load ratio
   12555             :                                                      Real64 &OnOffAirFlowRatio,     // ratio of compressor ON airflow to AVERAGE airflow over timestep
   12556             :                                                      Real64 &SuppHeatCoilLoad       // supplemental heating coil load (W)
   12557             : )
   12558             : {
   12559             : 
   12560             :     // SUBROUTINE INFORMATION:
   12561             :     //       AUTHOR         Rongpeng Zhang
   12562             :     //       DATE WRITTEN   Nov 2015
   12563             :     //       MODIFIED       na
   12564             :     //       RE-ENGINEERED  na
   12565             : 
   12566             :     // PURPOSE OF THIS SUBROUTINE:
   12567             :     // Determine the coil load and part load ratio, given the zone load
   12568             :     // Determine the air mass flow rate corresponding to the coil load of the heat pump for this time step
   12569             : 
   12570             :     // METHODOLOGY EMPLOYED:
   12571             :     // Use RegulaFalsi technique to iterate on part-load ratio until convergence is achieved.
   12572             : 
   12573             :     using General::SolveRoot;
   12574             :     using ScheduleManager::GetCurrentScheduleValue;
   12575             : 
   12576       58545 :     int constexpr MaxIte(500);        // maximum number of iterations
   12577       58545 :     Real64 constexpr MinPLF(0.0);     // minimum part load factor allowed
   12578       58545 :     Real64 constexpr ErrorTol(0.001); // tolerance for RegulaFalsi iterations
   12579             : 
   12580             :     Real64 FullOutput;     // unit full output when compressor is operating [W]
   12581             :     Real64 TempOutput;     // unit output when iteration limit exceeded [W]
   12582             :     Real64 NoCompOutput;   // output when no active compressor [W]
   12583             :     int SolFla;            // Flag of RegulaFalsi solver
   12584             :     Real64 TempMinPLR;     // min PLR used in Regula Falsi call
   12585             :     Real64 TempMaxPLR;     // max PLR used in Regula Falsi call
   12586             :     bool ContinueIter;     // used when convergence is an issue
   12587             :     int VRFCond;           // index to VRF condenser
   12588             :     int IndexToTUInTUList; // index to TU in specific list for the VRF system
   12589             :     int TUListIndex;       // index to TU list for this VRF system
   12590             :     bool VRFCoolingMode;
   12591             :     bool VRFHeatingMode;
   12592             :     bool HRCoolingMode;
   12593             :     bool HRHeatingMode;
   12594             : 
   12595       58545 :     PartLoadRatio = 0.0;
   12596       58545 :     state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = 0.0;
   12597       58545 :     state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = 0.0;
   12598       58545 :     VRFCond = this->VRFSysNum;
   12599       58545 :     IndexToTUInTUList = this->IndexToTUInTUList;
   12600       58545 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
   12601       58545 :     VRFCoolingMode = state.dataHVACVarRefFlow->CoolingLoad(VRFCond);
   12602       58545 :     VRFHeatingMode = state.dataHVACVarRefFlow->HeatingLoad(VRFCond);
   12603       58545 :     HRCoolingMode = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList);
   12604       58545 :     HRHeatingMode = state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList);
   12605             : 
   12606             :     // The RETURNS here will jump back to SimVRF where the CalcVRF routine will simulate with latest PLR
   12607             : 
   12608             :     // do nothing else if TU is scheduled off
   12609       65141 :     if (GetCurrentScheduleValue(state, this->SchedPtr) == 0.0) return;
   12610             : 
   12611             :     // Block the following statement: QZnReq==0 doesn't mean QCoilReq==0 due to possible OA mixer operation. zrp_201511
   12612             :     // do nothing if TU has no load (TU will be modeled using PLR=0)
   12613             :     // if ( QZnReq == 0.0 ) return;
   12614             : 
   12615             :     // Set EMS value for PLR and return
   12616       58545 :     if (this->EMSOverridePartLoadFrac) {
   12617           0 :         PartLoadRatio = this->EMSValueForPartLoadFrac;
   12618           0 :         return;
   12619             :     }
   12620             : 
   12621             :     // Get result when DX coil is off
   12622       58545 :     PartLoadRatio = 0.0;
   12623             : 
   12624             :     // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   12625       58545 :     this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, 0.0, NoCompOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   12626             : 
   12627       58545 :     if (VRFCoolingMode && HRHeatingMode) {
   12628             :         // IF the system is in cooling mode, but the terminal unit requests heating (heat recovery)
   12629           0 :         if (NoCompOutput >= QZnReq) return;
   12630       58545 :     } else if (VRFHeatingMode && HRCoolingMode) {
   12631             :         // IF the system is in heating mode, but the terminal unit requests cooling (heat recovery)
   12632           0 :         if (NoCompOutput <= QZnReq) return;
   12633       58545 :     } else if (VRFCoolingMode || HRCoolingMode) {
   12634             :         // IF the system is in cooling mode and/or the terminal unit requests cooling
   12635       34845 :         if (NoCompOutput <= QZnReq) return;
   12636       23700 :     } else if (VRFHeatingMode || HRHeatingMode) {
   12637             :         // IF the system is in heating mode and/or the terminal unit requests heating
   12638       20915 :         if (NoCompOutput >= QZnReq) return;
   12639             :     }
   12640             : 
   12641             :     // Otherwise the coil needs to turn on. Get full load result
   12642       57950 :     PartLoadRatio = 1.0;
   12643       57950 :     this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, PartLoadRatio, FullOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   12644       57950 :     if (this->CoolingCoilPresent) {
   12645       57950 :         this->coilInNodeT = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(this->CoolCoilIndex).AirInNode).Temp;
   12646       57950 :         this->coilInNodeW = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(this->CoolCoilIndex).AirInNode).HumRat;
   12647             :     } else {
   12648           0 :         this->coilInNodeT = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(this->HeatCoilIndex).AirInNode).Temp;
   12649           0 :         this->coilInNodeW = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(this->HeatCoilIndex).AirInNode).HumRat;
   12650             :     }
   12651             : 
   12652             :     // set supplemental heating coil calculation if the condition requires
   12653       57950 :     if (this->SuppHeatingCoilPresent) {
   12654       38580 :         if ((QZnReq > DataHVACGlobals::SmallLoad && QZnReq > FullOutput) ||
   12655       16750 :             (this->isSetPointControlled && this->suppTempSetPoint > state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).Temp)) {
   12656        2540 :             Real64 ZoneLoad = 0.0;
   12657        2540 :             Real64 LoadToHeatingSP = 0.0;
   12658        2540 :             Real64 LoadToCoolingSP = 0.0;
   12659        2540 :             if (this->isSetPointControlled) {
   12660           0 :                 Real64 mDot = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).MassFlowRate;
   12661           0 :                 Real64 Tin = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).Temp;
   12662           0 :                 Real64 Win = state.dataLoopNodes->Node(this->SuppHeatCoilAirInletNode).HumRat;
   12663           0 :                 Real64 CpAirIn = Psychrometrics::PsyCpAirFnW(Win);
   12664           0 :                 SuppHeatCoilLoad = mDot * CpAirIn * (this->suppTempSetPoint - Tin);
   12665           0 :                 this->SuppHeatingCoilLoad = SuppHeatCoilLoad;
   12666           0 :                 if (this->DesignSuppHeatingCapacity > 0.0) {
   12667           0 :                     this->SuppHeatPartLoadRatio = min(1.0, SuppHeatCoilLoad / this->DesignSuppHeatingCapacity);
   12668             :                 }
   12669             :             } else {
   12670        2540 :                 getVRFTUZoneLoad(state, VRFTUNum, ZoneLoad, LoadToHeatingSP, LoadToCoolingSP, false);
   12671        2540 :                 if ((FullOutput < (LoadToHeatingSP - DataHVACGlobals::SmallLoad)) && !FirstHVACIteration) {
   12672        1269 :                     SuppHeatCoilLoad = max(0.0, LoadToHeatingSP - FullOutput);
   12673        1269 :                     this->SuppHeatingCoilLoad = SuppHeatCoilLoad;
   12674        2538 :                     if (this->DesignSuppHeatingCapacity > 0.0) {
   12675        1269 :                         this->SuppHeatPartLoadRatio = min(1.0, SuppHeatCoilLoad / this->DesignSuppHeatingCapacity);
   12676             :                     }
   12677             :                 } else {
   12678        1271 :                     SuppHeatCoilLoad = 0.0;
   12679        1271 :                     this->SuppHeatPartLoadRatio = 0.0;
   12680             :                 }
   12681             :             }
   12682             :         } else {
   12683       16750 :             SuppHeatCoilLoad = 0.0;
   12684       16750 :             this->SuppHeatPartLoadRatio = 0.0;
   12685             :         }
   12686             :     } else {
   12687       38660 :         SuppHeatCoilLoad = 0.0;
   12688       38660 :         this->SuppHeatPartLoadRatio = 0.0;
   12689             :     }
   12690             : 
   12691      128280 :     if ((VRFCoolingMode && !state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) ||
   12692       55485 :         (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && HRCoolingMode)) {
   12693             :         // Since we are cooling, we expect FullOutput < NoCompOutput
   12694             :         // If the QZnReq <= FullOutput the unit needs to run full out
   12695       34220 :         if (QZnReq <= FullOutput) {
   12696             :             // if no coil present in terminal unit, no need to reset PLR?
   12697         309 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CoolingCoilPresent) {
   12698         309 :                 PartLoadRatio = 1.0;
   12699             :                 // the zone set point could be exceeded if set point control is used so protect against that
   12700         309 :                 if (this->isSetPointControlled) {
   12701           0 :                     if (state.dataLoopNodes->Node(this->coolCoilAirOutNode).Temp > this->coilTempSetPoint) return;
   12702             :                 } else {
   12703         309 :                     return;
   12704             :                 }
   12705             :             } else {
   12706           0 :                 PartLoadRatio = 0.0;
   12707           0 :                 return;
   12708             :             }
   12709             :         }
   12710       53878 :     } else if ((VRFHeatingMode && !state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) ||
   12711       16595 :                (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && HRHeatingMode)) {
   12712             :         // Since we are heating, we expect FullOutput > NoCompOutput
   12713             :         // If the QZnReq >= FullOutput the unit needs to run full out
   12714       20548 :         if (QZnReq >= FullOutput) {
   12715             :             // if no coil present in terminal unit, no need reset PLR?
   12716        2510 :             if (this->HeatingCoilPresent) {
   12717        2510 :                 PartLoadRatio = 1.0;
   12718             :                 // the zone set point could be exceeded if set point control is used so protect against that
   12719        2510 :                 if (this->isSetPointControlled) {
   12720           0 :                     if (state.dataLoopNodes->Node(this->heatCoilAirOutNode).Temp < this->coilTempSetPoint) return;
   12721             :                 } else {
   12722        2510 :                     return;
   12723             :                 }
   12724             :             } else {
   12725           0 :                 PartLoadRatio = 0.0;
   12726           0 :                 return;
   12727             :             }
   12728             :         }
   12729             :     } else {
   12730             :         // VRF terminal unit is off
   12731             :         // shouldn't actually get here
   12732        3182 :         PartLoadRatio = 0.0;
   12733        3182 :         return;
   12734             :     }
   12735             : 
   12736             :     // The coil will not operate at PLR=0 or PLR=1, calculate the operating part-load ratio
   12737             : 
   12738       51949 :     if ((VRFHeatingMode || HRHeatingMode) || (VRFCoolingMode || HRCoolingMode)) {
   12739     4299035 :         auto f = [&state, VRFTUNum, FirstHVACIteration, QZnReq, OnOffAirFlowRatio](Real64 const PartLoadRatio) {
   12740      330695 :             Real64 QZnReqTemp = QZnReq;    // denominator representing zone load (W)
   12741             :             Real64 ActualOutput;           // delivered capacity of VRF terminal unit
   12742      330695 :             Real64 SuppHeatCoilLoad = 0.0; // supplemetal heating coil load (W)
   12743      661390 :             bool setPointControlled = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).isSetPointControlled;
   12744      330695 :             Real64 nonConstOnOffAirFlowRatio = OnOffAirFlowRatio;
   12745             : 
   12746      992085 :             if (state.dataHVACVarRefFlow->VRF(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum).VRFAlgorithmTypeNum == AlgorithmType::FluidTCtrl) {
   12747             :                 // Algorithm Type: VRF model based on physics, applicable for Fluid Temperature Control
   12748     1322780 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF_FluidTCtrl(
   12749             :                     state, VRFTUNum, FirstHVACIteration, PartLoadRatio, ActualOutput, nonConstOnOffAirFlowRatio, SuppHeatCoilLoad);
   12750             :             } else {
   12751             :                 // Algorithm Type: VRF model based on system curve
   12752           0 :                 state.dataHVACVarRefFlow->VRFTU(VRFTUNum).CalcVRF(
   12753             :                     state, VRFTUNum, FirstHVACIteration, PartLoadRatio, ActualOutput, nonConstOnOffAirFlowRatio, SuppHeatCoilLoad);
   12754             :             }
   12755             : 
   12756      330695 :             if (setPointControlled) {
   12757           0 :                 Real64 outletNodeT = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUOutletNodeNum).Temp;
   12758           0 :                 return (outletNodeT - state.dataHVACVarRefFlow->VRFTU(VRFTUNum).coilTempSetPoint);
   12759             :             } else {
   12760      330695 :                 if (std::abs(QZnReq) < 100.0) QZnReqTemp = sign(100.0, QZnReq);
   12761      661390 :                 return (ActualOutput - QZnReq) / QZnReqTemp;
   12762             :             }
   12763       51949 :         };
   12764       51949 :         SolveRoot(state, ErrorTol, MaxIte, SolFla, PartLoadRatio, f, 0.0, 1.0);
   12765       51949 :         if (SolFla == -1) {
   12766             :             //     Very low loads may not converge quickly. Tighten PLR boundary and try again.
   12767        2461 :             TempMaxPLR = -0.1;
   12768        2461 :             ContinueIter = true;
   12769       28521 :             while (ContinueIter && TempMaxPLR < 1.0) {
   12770       13030 :                 TempMaxPLR += 0.1;
   12771             : 
   12772       13030 :                 this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, TempMaxPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   12773             : 
   12774       13030 :                 if (VRFHeatingMode && TempOutput > QZnReq) ContinueIter = false;
   12775       13030 :                 if (VRFCoolingMode && TempOutput < QZnReq) ContinueIter = false;
   12776             :             }
   12777        2461 :             TempMinPLR = TempMaxPLR;
   12778        2461 :             ContinueIter = true;
   12779       43493 :             while (ContinueIter && TempMinPLR > 0.0) {
   12780       20516 :                 TempMaxPLR = TempMinPLR;
   12781       20516 :                 TempMinPLR -= 0.01;
   12782             : 
   12783       20516 :                 this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, TempMaxPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   12784             : 
   12785       20516 :                 if (VRFHeatingMode && TempOutput < QZnReq) ContinueIter = false;
   12786       20516 :                 if (VRFCoolingMode && TempOutput > QZnReq) ContinueIter = false;
   12787             :             }
   12788             : 
   12789        2461 :             SolveRoot(state, ErrorTol, MaxIte, SolFla, PartLoadRatio, f, TempMinPLR, TempMaxPLR);
   12790        2461 :             if (SolFla == -1) {
   12791           0 :                 if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
   12792           0 :                     if (this->IterLimitExceeded == 0) {
   12793           0 :                         ShowWarningMessage(state, DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name + "\"");
   12794           0 :                         ShowContinueError(
   12795           0 :                             state, format(" Iteration limit exceeded calculating terminal unit part-load ratio, maximum iterations = {}", MaxIte));
   12796           0 :                         ShowContinueErrorTimeStamp(state, format(" Part-load ratio returned = {:.3R}", PartLoadRatio));
   12797             : 
   12798           0 :                         this->CalcVRF_FluidTCtrl(state, VRFTUNum, FirstHVACIteration, TempMinPLR, TempOutput, OnOffAirFlowRatio, SuppHeatCoilLoad);
   12799             : 
   12800           0 :                         ShowContinueError(state, format(" Load requested = {:.5T}, Load delivered = {:.5T}", QZnReq, TempOutput));
   12801           0 :                         ShowRecurringWarningErrorAtEnd(state,
   12802           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
   12803             :                                                            "\" -- Terminal unit Iteration limit exceeded error continues...",
   12804             :                                                        this->IterLimitExceeded);
   12805             :                     } else {
   12806           0 :                         ShowRecurringWarningErrorAtEnd(state,
   12807           0 :                                                        DataHVACGlobals::cVRFTUTypes(this->VRFTUType_Num) + " \"" + this->Name +
   12808             :                                                            "\" -- Terminal unit Iteration limit exceeded error continues...",
   12809             :                                                        this->IterLimitExceeded);
   12810             :                     }
   12811             :                 }
   12812        2461 :             } else if (SolFla == -2) {
   12813        2461 :                 PartLoadRatio = max(MinPLF, std::abs(QZnReq - NoCompOutput) / std::abs(FullOutput - NoCompOutput));
   12814             :             }
   12815       49488 :         } else if (SolFla == -2) {
   12816           0 :             if (FullOutput - NoCompOutput == 0.0) {
   12817           0 :                 PartLoadRatio = 0.0;
   12818             :             } else {
   12819           0 :                 PartLoadRatio = min(1.0, max(MinPLF, std::abs(QZnReq - NoCompOutput) / std::abs(FullOutput - NoCompOutput)));
   12820             :             }
   12821             :         }
   12822             :     }
   12823             : }
   12824             : 
   12825      656372 : void VRFTerminalUnitEquipment::CalcVRF_FluidTCtrl(EnergyPlusData &state,
   12826             :                                                   int const VRFTUNum,                // Index to VRF terminal unit
   12827             :                                                   bool const FirstHVACIteration,     // flag for 1st HVAC iteration in the time step
   12828             :                                                   Real64 const PartLoadRatio,        // compressor part load fraction
   12829             :                                                   Real64 &LoadMet,                   // load met by unit (W)
   12830             :                                                   Real64 &OnOffAirFlowRatio,         // ratio of ON air flow to average air flow
   12831             :                                                   Real64 &SuppHeatCoilLoad,          // supplemental heating coil load (W)
   12832             :                                                   Optional<Real64> LatOutputProvided // delivered latent capacity (W)
   12833             : )
   12834             : {
   12835             : 
   12836             :     // SUBROUTINE INFORMATION:
   12837             :     //       AUTHOR         RP Zhang (LBNL), XF Pang (LBNL), Y Yura (Daikin Inc)
   12838             :     //       DATE WRITTEN   June 2015
   12839             :     //       MODIFIED       na
   12840             :     //       RE-ENGINEERED  na
   12841             : 
   12842             :     // PURPOSE OF THIS SUBROUTINE:
   12843             :     //         This subroutine is part of the new VRF model based on physics, applicable for Fluid Temperature Control.
   12844             :     //         This is adapted from subroutine CalcVRF, which is part of the VRF model based on system curves.
   12845             :     //         This subroutine simulates the components making up the VRF indoor terminal unit.
   12846             : 
   12847             :     // METHODOLOGY EMPLOYED:
   12848             :     //        A new physics based VRF model applicable for Fluid Temperature Control.
   12849             :     using DXCoils::SimDXCoil;
   12850             :     using MixedAir::SimOAMixer;
   12851             :     using SingleDuct::SimATMixer;
   12852             :     using SteamCoils::SimulateSteamCoilComponents;
   12853             :     using WaterCoils::SimulateWaterCoilComponents;
   12854             : 
   12855             :     int VRFTUOutletNodeNum; // TU air outlet node
   12856             :     int VRFTUInletNodeNum;  // TU air inlet node
   12857             :     Real64 AirMassFlow;     // total supply air mass flow [m3/s]
   12858             :     int OpMode;             // fan operating mode, DataHVACGlobals::CycFanCycCoil or DataHVACGlobals::ContFanCycCoil
   12859             :     int VRFCond;            // index to VRF condenser
   12860             :     Real64 SpecHumOut;      // specific humidity ratio at outlet node
   12861             :     Real64 SpecHumIn;       // specific humidity ratio at inlet node
   12862             :     int TUListIndex;        // index to TU list for this VRF system
   12863             :     int IndexToTUInTUList;  // index to TU in specific list for the VRF system
   12864             :     Real64 EvapTemp;        // evaporating temperature
   12865             :     Real64 CondTemp;        // condensing temperature
   12866      656372 :     auto &ATMixOutNode2 = state.dataHVACVarRefFlow->ATMixOutNode2; // outlet node of ATM Mixer
   12867             :     int ZoneNode;                                                  // Zone node of VRFTU is serving
   12868             : 
   12869      656372 :     VRFCond = this->VRFSysNum;
   12870      656372 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
   12871      656372 :     IndexToTUInTUList = this->IndexToTUInTUList;
   12872      656372 :     VRFTUOutletNodeNum = this->VRFTUOutletNodeNum;
   12873      656372 :     VRFTUInletNodeNum = this->VRFTUInletNodeNum;
   12874      656372 :     OpMode = this->OpMode;
   12875      656372 :     EvapTemp = state.dataHVACVarRefFlow->VRF(VRFCond).IUEvaporatingTemp;
   12876      656372 :     CondTemp = state.dataHVACVarRefFlow->VRF(VRFCond).IUCondensingTemp;
   12877      656372 :     ZoneNode = this->ZoneAirNode;
   12878             : 
   12879             :     // Set inlet air mass flow rate based on PLR and compressor on/off air flow rates
   12880      656372 :     if (PartLoadRatio == 0) {
   12881             :         // only provide required OA when coil is off
   12882      233823 :         state.dataHVACVarRefFlow->CompOnMassFlow = state.dataHVACVarRefFlow->OACompOnMassFlow;
   12883      233823 :         state.dataHVACVarRefFlow->CompOffMassFlow = state.dataHVACVarRefFlow->OACompOffMassFlow;
   12884             :     } else {
   12885             :         // identify the air flow rate corresponding to the coil load
   12886      422549 :         state.dataHVACVarRefFlow->CompOnMassFlow = CalVRFTUAirFlowRate_FluidTCtrl(state, VRFTUNum, PartLoadRatio, FirstHVACIteration);
   12887             :     }
   12888      656372 :     SetAverageAirFlow(state, VRFTUNum, PartLoadRatio, OnOffAirFlowRatio);
   12889      656372 :     AirMassFlow = state.dataLoopNodes->Node(VRFTUInletNodeNum).MassFlowRate;
   12890             : 
   12891      656372 :     if (this->ATMixerExists) {
   12892             :         // There is an air terminal mixer
   12893           0 :         ATMixOutNode2 = this->ATMixerOutNode;
   12894           0 :         if (this->ATMixerType == DataHVACGlobals::ATMixer_InletSide) { // if there is an inlet side air terminal mixer
   12895             :             // set the primary air inlet mass flow rate
   12896           0 :             state.dataLoopNodes->Node(this->ATMixerPriNode).MassFlowRate =
   12897           0 :                 min(state.dataLoopNodes->Node(this->ATMixerPriNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(VRFTUInletNodeNum).MassFlowRate);
   12898             :             // now calculate the the mixer outlet air conditions (and the secondary air inlet flow rate). The mixer outlet flow rate has already
   12899             :             // been set above (it is the "inlet" node flow rate)
   12900           0 :             SimATMixer(state, this->ATMixerName, FirstHVACIteration, this->ATMixerIndex);
   12901             :         }
   12902             :     } else {
   12903      656372 :         ATMixOutNode2 = 0;
   12904             :         // simulate OA Mixer
   12905      656372 :         if (this->OAMixerUsed) SimOAMixer(state, this->OAMixerName, FirstHVACIteration, this->OAMixerIndex);
   12906             :     }
   12907             :     // if blow through, simulate fan then coils
   12908      656372 :     if (this->FanPlace == DataHVACGlobals::BlowThru) {
   12909           0 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
   12910           0 :             if (OnOffAirFlowRatio > 0.0) {
   12911           0 :                 state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   12912           0 :                     state, _, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   12913             :             } else {
   12914           0 :                 state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   12915           0 :                     state, PartLoadRatio, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   12916             :             }
   12917             :         } else {
   12918           0 :             Fans::SimulateFanComponents(state,
   12919             :                                         "",
   12920             :                                         FirstHVACIteration,
   12921             :                                         this->FanIndex,
   12922           0 :                                         state.dataHVACVarRefFlow->FanSpeedRatio,
   12923           0 :                                         state.dataHVACGlobal->ZoneCompTurnFansOn,
   12924           0 :                                         state.dataHVACGlobal->ZoneCompTurnFansOff);
   12925             :         }
   12926             :     }
   12927      656372 :     if (this->CoolingCoilPresent) {
   12928             :         // above condition for heat pump mode, below condition for heat recovery mode
   12929     1455619 :         if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) ||
   12930      628388 :             (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
   12931      235167 :              state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList))) {
   12932     1218078 :             SimDXCoil(state,
   12933             :                       "",
   12934             :                       DataHVACGlobals::CompressorOperation::On,
   12935             :                       FirstHVACIteration,
   12936             :                       this->CoolCoilIndex,
   12937             :                       OpMode,
   12938             :                       PartLoadRatio,
   12939             :                       _,
   12940             :                       _,
   12941      406026 :                       state.dataHVACVarRefFlow->MaxCoolingCapacity(VRFCond),
   12942      812052 :                       state.dataHVACVarRefFlow->VRF(this->VRFSysNum).VRFCondCyclingRatio);
   12943             :         } else { // cooling coil is off
   12944      250346 :             SimDXCoil(state, "", DataHVACGlobals::CompressorOperation::Off, FirstHVACIteration, this->CoolCoilIndex, OpMode, 0.0, _);
   12945             :         }
   12946      656372 :         state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = state.dataAirLoop->LoopDXCoilRTF;
   12947             :     } else {
   12948           0 :         state.dataHVACVarRefFlow->LoopDXCoolCoilRTF = 0.0;
   12949             :     }
   12950             : 
   12951      656372 :     if (this->HeatingCoilPresent) {
   12952             :         // above condition for heat pump mode, below condition for heat recovery mode
   12953     1400261 :         if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) ||
   12954      783084 :             (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
   12955      235167 :              state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList))) {
   12956      587916 :             SimDXCoil(state,
   12957             :                       "",
   12958             :                       DataHVACGlobals::CompressorOperation::On,
   12959             :                       FirstHVACIteration,
   12960             :                       this->HeatCoilIndex,
   12961             :                       OpMode,
   12962             :                       PartLoadRatio,
   12963             :                       _,
   12964             :                       _,
   12965      391944 :                       state.dataHVACVarRefFlow->MaxHeatingCapacity(VRFCond));
   12966             :         } else {
   12967      460400 :             SimDXCoil(state, "", DataHVACGlobals::CompressorOperation::Off, FirstHVACIteration, this->HeatCoilIndex, OpMode, 0.0, _);
   12968             :         }
   12969      656372 :         state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = state.dataAirLoop->LoopDXCoilRTF;
   12970             :     } else {
   12971           0 :         state.dataHVACVarRefFlow->LoopDXHeatCoilRTF = 0.0;
   12972             :     }
   12973             : 
   12974             :     // if draw through, simulate coils then fan
   12975      656372 :     if (this->FanPlace == DataHVACGlobals::DrawThru) {
   12976      656372 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
   12977           0 :             if (OnOffAirFlowRatio > 0.0) {
   12978           0 :                 state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   12979           0 :                     state, _, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   12980             :             } else {
   12981           0 :                 state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   12982           0 :                     state, PartLoadRatio, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   12983             :             }
   12984             : 
   12985             :         } else {
   12986     3281860 :             Fans::SimulateFanComponents(state,
   12987             :                                         "",
   12988             :                                         FirstHVACIteration,
   12989             :                                         this->FanIndex,
   12990      656372 :                                         state.dataHVACVarRefFlow->FanSpeedRatio,
   12991      656372 :                                         state.dataHVACGlobal->ZoneCompTurnFansOn,
   12992     1312744 :                                         state.dataHVACGlobal->ZoneCompTurnFansOff);
   12993             :         }
   12994             :     }
   12995             : 
   12996             :     // track fan power per terminal unit for calculating COP
   12997      656372 :     if (this->fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
   12998           0 :         this->FanPower = state.dataHVACFan->fanObjs[this->FanIndex]->fanPower();
   12999             :     } else {
   13000      656372 :         this->FanPower = Fans::GetFanPower(state, this->FanIndex);
   13001             :     }
   13002             : 
   13003             :     // run supplemental heating coil
   13004      656372 :     if (this->SuppHeatingCoilPresent) {
   13005      199212 :         Real64 SuppPLR = this->SuppHeatPartLoadRatio;
   13006      199212 :         this->CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, SuppPLR, SuppHeatCoilLoad);
   13007      199212 :         if ((state.dataLoopNodes->Node(this->SuppHeatCoilAirOutletNode).Temp > this->MaxSATFromSuppHeatCoil) && SuppPLR > 0.0) {
   13008             :             // adjust the heating load to maximum allowed
   13009           0 :             Real64 MaxHeatCoilLoad = this->HeatingCoilCapacityLimit(state, this->SuppHeatCoilAirInletNode, this->MaxSATFromSuppHeatCoil);
   13010           0 :             this->CalcVRFSuppHeatingCoil(state, VRFTUNum, FirstHVACIteration, SuppPLR, MaxHeatCoilLoad);
   13011           0 :             SuppHeatCoilLoad = MaxHeatCoilLoad;
   13012             :         }
   13013             :     }
   13014             : 
   13015      656372 :     Real64 LatentLoadMet = 0.0;
   13016      656372 :     Real64 TempOut = 0.0;
   13017      656372 :     Real64 TempIn = 0.0;
   13018      656372 :     if (this->ATMixerExists) {
   13019           0 :         if (this->ATMixerType == DataHVACGlobals::ATMixer_SupplySide) {
   13020             :             // Air terminal supply side mixer, calculate supply side mixer output
   13021           0 :             SimATMixer(state, this->ATMixerName, FirstHVACIteration, this->ATMixerIndex);
   13022           0 :             TempOut = state.dataLoopNodes->Node(ATMixOutNode2).Temp;
   13023           0 :             SpecHumOut = state.dataLoopNodes->Node(ATMixOutNode2).HumRat;
   13024           0 :             AirMassFlow = state.dataLoopNodes->Node(ATMixOutNode2).MassFlowRate;
   13025             :         } else {
   13026             :             // Air terminal inlet side mixer
   13027           0 :             TempOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).Temp;
   13028           0 :             SpecHumOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).HumRat;
   13029             :         }
   13030           0 :         TempIn = state.dataLoopNodes->Node(ZoneNode).Temp;
   13031           0 :         SpecHumIn = state.dataLoopNodes->Node(ZoneNode).HumRat;
   13032             :     } else {
   13033      656372 :         TempOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).Temp;
   13034      656372 :         SpecHumOut = state.dataLoopNodes->Node(VRFTUOutletNodeNum).HumRat;
   13035      656372 :         if (ZoneNode > 0) {
   13036      656372 :             TempIn = state.dataLoopNodes->Node(ZoneNode).Temp;
   13037      656372 :             SpecHumIn = state.dataLoopNodes->Node(ZoneNode).HumRat;
   13038             :         } else {
   13039           0 :             TempIn = state.dataLoopNodes->Node(VRFTUInletNodeNum).Temp;
   13040           0 :             SpecHumIn = state.dataLoopNodes->Node(VRFTUInletNodeNum).HumRat;
   13041             :         }
   13042             :     }
   13043             :     // calculate sensible load met using delta enthalpy
   13044      656372 :     LoadMet = AirMassFlow * PsyDeltaHSenFnTdb2W2Tdb1W1(TempOut, SpecHumOut, TempIn, SpecHumIn); // sensible {W}
   13045      656372 :     LatentLoadMet = AirMassFlow * (SpecHumOut - SpecHumIn);                                     // latent {kgWater/s}
   13046      656372 :     if (present(LatOutputProvided)) {
   13047       58545 :         LatOutputProvided = LatentLoadMet;
   13048             :     }
   13049      656372 : }
   13050             : 
   13051      422549 : Real64 VRFTerminalUnitEquipment::CalVRFTUAirFlowRate_FluidTCtrl(EnergyPlusData &state,
   13052             :                                                                 int const VRFTUNum,     // Index to VRF terminal unit
   13053             :                                                                 Real64 PartLoadRatio,   // part load ratio of the coil
   13054             :                                                                 bool FirstHVACIteration // FirstHVACIteration flag
   13055             : )
   13056             : {
   13057             :     // SUBROUTINE INFORMATION:
   13058             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13059             :     //       DATE WRITTEN   Nov 2015
   13060             :     //       MODIFIED       na
   13061             :     //       RE-ENGINEERED  na
   13062             : 
   13063             :     // PURPOSE OF THIS FUNCTION:
   13064             :     //  This function determines the TU airflow rate corresponding to the coil load.
   13065             :     //  This is used to address the coupling between OA mixer simulation and VRF-FluidTCtrl coil simulation.
   13066             : 
   13067             :     // METHODOLOGY EMPLOYED:
   13068             :     //  VRF-FluidTCtrl TU airflow rate is determined by the control logic of VRF-FluidTCtrl coil to match the
   13069             :     //  coil load. This is affected by the coil inlet conditions. However, the airflow rate will affect the
   13070             :     //  OA mixer simulation, which leads to different coil inlet conditions. So, there is a coupling issue here.
   13071             : 
   13072             :     using General::SolveRoot;
   13073             : 
   13074             :     Real64 AirMassFlowRate; // air mass flow rate of the coil (kg/s)
   13075             : 
   13076      422549 :     int constexpr Mode(1);           // Performance mode for MultiMode DX coil. Always 1 for other coil types
   13077      422549 :     int constexpr MaxIte(500);       // maximum number of iterations
   13078             :     int DXCoilNum;                   // index to DX Coil
   13079             :     int IndexToTUInTUList;           // index to TU in specific list for the VRF system
   13080             :     int SolFla;                      // Flag of RegulaFalsi solver
   13081             :     int TUListIndex;                 // index to TU list for this VRF system
   13082             :     int VRFCond;                     // index to VRF condenser
   13083      422549 :     Real64 constexpr ErrorTol(0.01); // tolerance for RegulaFalsi iterations
   13084             :     Real64 FanSpdRatio;              // ratio of required and rated air flow rate
   13085             :     Real64 FanSpdRatioMin;           // min fan speed ratio
   13086             :     Real64 FanSpdRatioMax;           // min fan speed ratio
   13087             :     Real64 QCoilReq;                 // required coil load (W)
   13088             :     Real64 QCoilAct;                 // actual coil load (W)
   13089             :     Real64 TeTc;                     // evaporating temperature or condensing temperature for VRF indoor unit(C)
   13090             : 
   13091      422549 :     VRFCond = this->VRFSysNum;
   13092      422549 :     TUListIndex = state.dataHVACVarRefFlow->VRF(VRFCond).ZoneTUListPtr;
   13093      422549 :     IndexToTUInTUList = this->IndexToTUInTUList;
   13094             : 
   13095      939281 :     if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->CoolingLoad(VRFCond)) ||
   13096      384479 :         (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
   13097      156652 :          state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRCoolRequest(IndexToTUInTUList))) {
   13098             :         // VRF terminal unit is on cooling mode
   13099      288905 :         DXCoilNum = this->CoolCoilIndex;
   13100      288905 :         QCoilReq = -PartLoadRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   13101      288905 :         TeTc = state.dataHVACVarRefFlow->VRF(VRFCond).IUEvaporatingTemp;
   13102             : 
   13103             :         // For HR operations, Te is lower than the outdoor air temperature because of outdoor evaporator operations
   13104             :         // The difference is usually 2-3C according to the engineering experience. 2 is used here for a slightly bigger fan flow rate.
   13105      288905 :         if (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed) TeTc = min(TeTc, state.dataEnvrn->OutDryBulbTemp - 2);
   13106             : 
   13107      329180 :     } else if ((!state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed && state.dataHVACVarRefFlow->HeatingLoad(VRFCond)) ||
   13108      127543 :                (state.dataHVACVarRefFlow->VRF(VRFCond).HeatRecoveryUsed &&
   13109       62469 :                 state.dataHVACVarRefFlow->TerminalUnitList(TUListIndex).HRHeatRequest(IndexToTUInTUList))) {
   13110             :         // VRF terminal unit is on heating mode
   13111      130462 :         DXCoilNum = this->HeatCoilIndex;
   13112      130462 :         QCoilReq = PartLoadRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   13113      130462 :         TeTc = state.dataHVACVarRefFlow->VRF(VRFCond).IUCondensingTemp;
   13114             : 
   13115             :     } else {
   13116             :         // VRF terminal unit is off
   13117        3182 :         QCoilAct = 0.0;
   13118        3182 :         AirMassFlowRate = max(state.dataHVACVarRefFlow->OACompOnMassFlow, 0.0);
   13119        3182 :         return AirMassFlowRate;
   13120             :     }
   13121             : 
   13122             :     // minimum airflow rate
   13123      419367 :     if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode) > 0.0) {
   13124      419367 :         FanSpdRatioMin = min(state.dataHVACVarRefFlow->OACompOnMassFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode), 1.0);
   13125             :     } else {
   13126             :         // VRF terminal unit is off
   13127           0 :         QCoilAct = 0.0;
   13128           0 :         AirMassFlowRate = max(state.dataHVACVarRefFlow->OACompOnMassFlow, 0.0);
   13129           0 :         return AirMassFlowRate;
   13130             :     }
   13131             : 
   13132      419367 :     FanSpdRatioMax = 1.0;
   13133             : 
   13134    40374300 :     auto f = [&state, FirstHVACIteration, VRFTUNum, DXCoilNum, QCoilReq, TeTc, PartLoadRatio](Real64 const FanSpdRatio) {
   13135             :         using DXCoils::ControlVRFIUCoil;
   13136             :         using Fans::SimulateFanComponents;
   13137             :         using MixedAir::SimOAMixer;
   13138             :         using Psychrometrics::PsyHFnTdbW;
   13139             :         using SingleDuct::SimATMixer;
   13140             : 
   13141     1345810 :         int constexpr Mode(1);  // Performance mode for MultiMode DX coil. Always 1 for other coil types
   13142             :         int OAMixNode;          // index to the mix node of OA mixer
   13143             :         int VRFCond;            // index to VRF condenser
   13144             :         int VRFInletNode;       // VRF inlet node number
   13145             :         Real64 FanSpdRatioBase; // baseline FanSpdRatio for VRFTUAirFlowResidual
   13146             :         Real64 FanSpdRatioAct;  // calculated FanSpdRatio for VRFTUAirFlowResidual
   13147             :         Real64 QCoilAct;        // actual coil load [W]
   13148             :         Real64 temp;            // for temporary use
   13149             :         Real64 Tin;             // coil inlet air temperature [C]
   13150             :         Real64 Win;             // coil inlet air humidity ratio [kg/kg]
   13151             :         Real64 Hin;             // coil inlet air enthalpy
   13152             :         Real64 Wout;            // coil outlet air humidity ratio
   13153             :         Real64 Tout;            // coil outlet air temperature
   13154             :         Real64 Hout;            // coil outlet air enthalpy
   13155             :         Real64 SHact;           // coil actual SH
   13156             :         Real64 SCact;           // coil actual SC
   13157             : 
   13158     2691620 :         VRFCond = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFSysNum;
   13159     2691620 :         VRFInletNode = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).VRFTUInletNodeNum;
   13160             : 
   13161     1345810 :         if (std::abs(FanSpdRatio) < 0.01)
   13162           0 :             FanSpdRatioBase = sign(0.01, FanSpdRatio);
   13163             :         else
   13164     1345810 :             FanSpdRatioBase = FanSpdRatio;
   13165             : 
   13166             :         // Set inlet air mass flow rate based on PLR and compressor on/off air flow rates
   13167     4037430 :         state.dataHVACVarRefFlow->CompOnMassFlow = FanSpdRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   13168     1345810 :         SetAverageAirFlow(state, VRFTUNum, PartLoadRatio, temp);
   13169     1345810 :         Tin = state.dataLoopNodes->Node(VRFInletNode).Temp;
   13170     1345810 :         Win = state.dataLoopNodes->Node(VRFInletNode).HumRat;
   13171             : 
   13172             :         // Simulation the OAMixer if there is any
   13173     2691620 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerUsed) {
   13174     5383240 :             SimOAMixer(state,
   13175     2691620 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerName,
   13176             :                        FirstHVACIteration,
   13177     2691620 :                        state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex);
   13178     4037430 :             OAMixNode = state.dataMixedAir->OAMixer(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OAMixerIndex).MixNode;
   13179     1345810 :             Tin = state.dataLoopNodes->Node(OAMixNode).Temp;
   13180     1345810 :             Win = state.dataLoopNodes->Node(OAMixNode).HumRat;
   13181             :         }
   13182             :         // Simulate the blow-through fan if there is any
   13183     2691620 :         if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanPlace == DataHVACGlobals::BlowThru) {
   13184           0 :             if (state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanType_Num == DataHVACGlobals::FanType_SystemModelObject) {
   13185           0 :                 if (temp > 0) {
   13186           0 :                     state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   13187           0 :                         state, _, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   13188             :                 } else {
   13189           0 :                     state.dataHVACFan->fanObjs[state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex]->simulate(
   13190           0 :                         state, PartLoadRatio, state.dataHVACGlobal->ZoneCompTurnFansOn, state.dataHVACGlobal->ZoneCompTurnFansOff, _);
   13191             :                 }
   13192             :             } else {
   13193           0 :                 Fans::SimulateFanComponents(state,
   13194             :                                             "",
   13195             :                                             false,
   13196           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).FanIndex,
   13197           0 :                                             state.dataHVACVarRefFlow->FanSpeedRatio,
   13198           0 :                                             state.dataHVACGlobal->ZoneCompTurnFansOn,
   13199           0 :                                             state.dataHVACGlobal->ZoneCompTurnFansOff);
   13200             :             }
   13201           0 :             Tin = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOutletNode).Temp;
   13202           0 :             Win = state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).fanOutletNode).HumRat;
   13203             :         }
   13204             : 
   13205             :         // Call the coil control logic to determine the air flow rate to match the given coil load
   13206     2691620 :         ControlVRFIUCoil(
   13207     1345810 :             state, DXCoilNum, QCoilReq, Tin, Win, TeTc, state.dataHVACVarRefFlow->OACompOnMassFlow, FanSpdRatioAct, Wout, Tout, Hout, SHact, SCact);
   13208             : 
   13209     1345810 :         Hin = PsyHFnTdbW(Tin, Win);
   13210     4037430 :         QCoilAct = FanSpdRatioAct * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode) *
   13211     1345810 :                    (Hout - Hin); // positive for heating, negative for cooling
   13212             : 
   13213     1345810 :         return (FanSpdRatioAct - FanSpdRatio);
   13214      419367 :     };
   13215             : 
   13216      419367 :     SolveRoot(state, ErrorTol, MaxIte, SolFla, FanSpdRatio, f, FanSpdRatioMin, FanSpdRatioMax);
   13217      419367 :     if (SolFla < 0) FanSpdRatio = FanSpdRatioMax; // over capacity
   13218             : 
   13219      419367 :     AirMassFlowRate = FanSpdRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   13220             : 
   13221      419367 :     return AirMassFlowRate;
   13222             : }
   13223             : 
   13224      106500 : Real64 CompResidual_FluidTCtrl(EnergyPlusData &state,
   13225             :                                Real64 T_dis,
   13226             :                                Real64 CondHeat,
   13227             :                                int CAPFT,
   13228             :                                Real64 const T_suc // Compressor suction temperature Te' [C]
   13229             : )
   13230             : {
   13231             :     // FUNCTION INFORMATION:
   13232             :     //       AUTHOR         Xiufeng Pang (XP)
   13233             :     //       DATE WRITTEN   Mar 2013
   13234             :     //       MODIFIED       Jul 2015, RP Zhang, LBNL
   13235             :     //       RE-ENGINEERED
   13236             :     //
   13237             :     // PURPOSE OF THIS FUNCTION:
   13238             :     //       Calculates residual function ((VRV terminal unit cooling output - Zone sensible cooling load)
   13239             :     //
   13240             :     using Curve::CurveValue;
   13241             : 
   13242             :     Real64 CAPSpd; // Evaporative capacity of the compressor at a given spd[W]
   13243             :     Real64 CompResidual;
   13244             : 
   13245      106500 :     CAPSpd = CurveValue(state, CAPFT, T_dis, T_suc);
   13246      106500 :     CompResidual = (CondHeat - CAPSpd) / CAPSpd;
   13247             : 
   13248      106500 :     return CompResidual;
   13249             : }
   13250             : 
   13251       40892 : void VRFCondenserEquipment::VRFOU_TeTc(EnergyPlusData &state,
   13252             :                                        HXOpMode const OperationMode, // Mode 0 for running as condenser, 1 for evaporator
   13253             :                                        Real64 const Q_coil,          // // OU coil heat release at cooling mode or heat extract at heating mode [W]
   13254             :                                        Real64 const SHSC,            // SC for OU condenser or SH for OU evaporator [C]
   13255             :                                        Real64 const m_air,           // OU coil air mass flow rate [kg/s]
   13256             :                                        Real64 const T_coil_in,       // Temperature of air at OU coil inlet [C]
   13257             :                                        Real64 const W_coil_in,       // Humidity ratio of air at OU coil inlet [kg/kg]
   13258             :                                        Real64 const OutdoorPressure, // Outdoor air pressure [Pa]
   13259             :                                        Real64 &T_coil_surf,          // Air temperature at coil surface [C]
   13260             :                                        Real64 &TeTc                  // VRF Tc at cooling mode, or Te at heating mode [C]
   13261             : )
   13262             : {
   13263             : 
   13264             :     // SUBROUTINE INFORMATION:
   13265             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13266             :     //       DATE WRITTEN   Jan 2016
   13267             :     //       MODIFIED       na
   13268             :     //
   13269             :     //       RE-ENGINEERED  na
   13270             :     //
   13271             :     // PURPOSE OF THIS SUBROUTINE:
   13272             :     //        Calculate the VRF OU refrigerant side temperature, i.e., condensing temperature
   13273             :     //        at cooling mode, or evaporating temperature at heating mode, given the coil heat
   13274             :     //        release/extract amount and air side parameters.
   13275             :     //
   13276             :     // METHODOLOGY EMPLOYED:
   13277             :     //        This is part of the physics based VRF model applicable for Fluid Temperature Control.
   13278             :     //
   13279             : 
   13280             :     Real64 BF;              // VRF OU bypass  [-]
   13281             :     Real64 deltaT;          // Difference between Te/Tc and air temperature at coil surface [C]
   13282             :     Real64 h_coil_in;       // Enthalpy of air at OU coil inlet [C]
   13283             :     Real64 h_coil_out;      // Enthalpy of air at OU coil outlet [C]
   13284             :     Real64 T_coil_out;      // Air temperature at coil outlet [C]
   13285             :     Real64 T_coil_surf_sat; // Saturated air temperature at coil surface [C]
   13286             :     Real64 W_coil_surf_sat; // Humidity ratio of saturated air at coil surface [kg/kg]
   13287             : 
   13288       40892 :     if (OperationMode == HXOpMode::CondMode) {
   13289             :         // IU Cooling: OperationMode 0
   13290             : 
   13291       20792 :         if (m_air <= 0) {
   13292           0 :             TeTc = this->CondensingTemp;
   13293           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13294           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit refrigerant temperature.");
   13295           0 :             ShowContinueError(state, format(" Default condensing temperature is used: {:.3T}", TeTc));
   13296             :         }
   13297             : 
   13298       20792 :         BF = this->RateBFOUCond; // 0.219;
   13299       20792 :         T_coil_out = T_coil_in + Q_coil / 1005.0 / m_air;
   13300       20792 :         T_coil_surf = T_coil_in + (T_coil_out - T_coil_in) / (1 - BF);
   13301             : 
   13302       20792 :         deltaT = this->C3Tc * pow_2(SHSC) + this->C2Tc * SHSC + this->C1Tc;
   13303             : 
   13304       20792 :         TeTc = T_coil_surf + deltaT;
   13305             : 
   13306       20100 :     } else if (OperationMode == HXOpMode::EvapMode) {
   13307             :         // IU Heating: OperationMode 1
   13308             : 
   13309       20100 :         if (m_air <= 0) {
   13310           0 :             TeTc = this->EvaporatingTemp;
   13311           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13312           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit refrigerant temperature.");
   13313           0 :             ShowContinueError(state, format(" Default condensing temperature is used: {:.3T}", TeTc));
   13314             :         }
   13315             : 
   13316       20100 :         BF = this->RateBFOUEvap; // 0.45581;
   13317       20100 :         h_coil_in = PsyHFnTdbW(T_coil_in, W_coil_in);
   13318       20100 :         h_coil_out = h_coil_in - Q_coil / m_air / (1 - BF);
   13319       20100 :         h_coil_out = max(0.01, h_coil_out);
   13320             : 
   13321       20100 :         T_coil_surf_sat = PsyTsatFnHPb(state, h_coil_out, OutdoorPressure, "VRFOU_TeTc");
   13322       20100 :         W_coil_surf_sat = PsyWFnTdbH(state, T_coil_surf_sat, h_coil_out, "VRFOU_TeTc");
   13323             : 
   13324       20100 :         if (W_coil_surf_sat < W_coil_in)
   13325             :             // There is dehumidification
   13326       11486 :             T_coil_surf = T_coil_surf_sat;
   13327             :         else
   13328             :             // No dehumidification
   13329        8614 :             T_coil_surf = PsyTdbFnHW(h_coil_out, W_coil_in);
   13330             : 
   13331       20100 :         deltaT = this->C3Te * pow_2(SHSC) + this->C2Te * SHSC + this->C1Te;
   13332             : 
   13333       20100 :         TeTc = T_coil_surf - deltaT;
   13334             :     }
   13335       40892 : }
   13336             : 
   13337           0 : Real64 VRFCondenserEquipment::VRFOU_Cap(EnergyPlusData &state,
   13338             :                                         HXOpMode const OperationMode, // Mode 0 for running as condenser, 1 for evaporator
   13339             :                                         Real64 const TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
   13340             :                                         Real64 const SHSC,            // SC for OU condenser or SH for OU evaporator [C]
   13341             :                                         Real64 const m_air,           // OU coil air mass flow rate [kg/s]
   13342             :                                         Real64 const T_coil_in,       // Temperature of air at OU coil inlet [C]
   13343             :                                         Real64 const W_coil_in        // Humidity ratio of air at OU coil inlet [kg/kg]
   13344             : )
   13345             : {
   13346             : 
   13347             :     // SUBROUTINE INFORMATION:
   13348             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13349             :     //       DATE WRITTEN   Jan 2016
   13350             :     //       MODIFIED       na
   13351             :     //
   13352             :     //       RE-ENGINEERED  na
   13353             :     //
   13354             :     // PURPOSE OF THIS SUBROUTINE:
   13355             :     //        Calculate the VRF OU load, given refrigerant side temperature, i.e., condensing temperature
   13356             :     //        and SC for condenser, or evaporating temperature and SH for evaporator.
   13357             :     //
   13358             :     // METHODOLOGY EMPLOYED:
   13359             :     //        This is part of the physics based VRF model applicable for Fluid Temperature Control.
   13360             : 
   13361             :     Real64 BF;              // VRF OU bypass [-]
   13362             :     Real64 deltaT;          // Difference between Te/Tc and air temperature at coil surface [C]
   13363             :     Real64 h_coil_in;       // Enthalpy of air at OU coil inlet [C]
   13364             :     Real64 h_coil_out;      // Enthalpy of air at OU coil outlet [C]
   13365             :     Real64 Q_coil;          // OU coil heat release at cooling mode or heat extract at heating mode [W]
   13366             :     Real64 T_coil_out;      // Air temperature at coil outlet [C]
   13367             :     Real64 T_coil_surf;     // Air temperature at coil surface [C]
   13368             :     Real64 W_coil_surf_sat; // Humidity ratio of saturated air at coil surface [kg/kg]
   13369             : 
   13370           0 :     Q_coil = 0.0;
   13371             : 
   13372           0 :     if (OperationMode == HXOpMode::CondMode) {
   13373             :         // IU Cooling: OperationMode 0
   13374           0 :         if (m_air <= 0) {
   13375           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13376           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit capacity.");
   13377             :         }
   13378             : 
   13379           0 :         BF = this->RateBFOUCond; // 0.219;
   13380           0 :         deltaT = this->C3Tc * pow_2(SHSC) + this->C2Tc * SHSC + this->C1Tc;
   13381           0 :         T_coil_surf = TeTc - deltaT;
   13382           0 :         T_coil_out = T_coil_in + (T_coil_surf - T_coil_in) * (1 - BF);
   13383           0 :         Q_coil = (T_coil_out - T_coil_in) * 1005.0 * m_air;
   13384             : 
   13385           0 :     } else if (OperationMode == HXOpMode::EvapMode) {
   13386             :         // IU Heating: OperationMode 1
   13387           0 :         if (m_air <= 0) {
   13388           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13389           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit capacity.");
   13390             :         }
   13391             : 
   13392           0 :         BF = this->RateBFOUEvap; // 0.45581;
   13393           0 :         deltaT = this->C3Te * pow_2(SHSC) + this->C2Te * SHSC + this->C1Te;
   13394           0 :         T_coil_surf = TeTc + deltaT;
   13395             : 
   13396             :         // saturated humidity ratio corresponding to T_coil_surf
   13397           0 :         W_coil_surf_sat = PsyWFnTdpPb(state, T_coil_surf, state.dataEnvrn->OutBaroPress);
   13398             : 
   13399           0 :         if (W_coil_surf_sat < W_coil_in) {
   13400             :             // There is dehumidification, W_coil_out = W_coil_surf_sat
   13401           0 :             h_coil_out = PsyHFnTdbW(T_coil_surf, W_coil_surf_sat);
   13402             :         } else {
   13403             :             // No dehumidification, W_coil_out = W_coil_in
   13404           0 :             h_coil_out = PsyHFnTdbW(T_coil_surf, W_coil_in);
   13405             :         }
   13406           0 :         h_coil_out = max(0.01, h_coil_out);
   13407           0 :         h_coil_in = PsyHFnTdbW(T_coil_in, W_coil_in);
   13408           0 :         Q_coil = (h_coil_in - h_coil_out) * m_air * (1 - BF); // bypass airflow should not be included here
   13409             : 
   13410             :     } else {
   13411             :         // Should not come here
   13412           0 :         ShowSevereMessage(state, " Unreasonable outdoor unit operational mode for \"" + this->Name + "\":");
   13413           0 :         ShowContinueError(state, " The operational mode is not correctly set in the function VRFOU_Cap.");
   13414             :     }
   13415             : 
   13416           0 :     return Q_coil;
   13417             : }
   13418             : 
   13419           0 : Real64 VRFCondenserEquipment::VRFOU_FlowRate(EnergyPlusData &state,
   13420             :                                              HXOpMode const OperationMode, // Mode 0 for running as condenser, 1 for evaporator
   13421             :                                              Real64 const TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
   13422             :                                              Real64 const SHSC,            // SC for OU condenser or SH for OU evaporator [C]
   13423             :                                              Real64 const Q_coil,          // absolute value of OU coil heat release or heat extract [W]
   13424             :                                              Real64 const T_coil_in,       // Temperature of air at OU coil inlet [C]
   13425             :                                              Real64 const W_coil_in        // Humidity ratio of air at OU coil inlet [kg/kg]
   13426             : ) const
   13427             : {
   13428             : 
   13429             :     // SUBROUTINE INFORMATION:
   13430             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13431             :     //       DATE WRITTEN   Mar 2016
   13432             :     //       MODIFIED       na
   13433             :     //
   13434             :     //       RE-ENGINEERED  na
   13435             :     //
   13436             :     // PURPOSE OF THIS SUBROUTINE:
   13437             :     //        Calculate the outdoor unit fan flow rate, given VRF OU load and refrigerant side temperature, i.e.,
   13438             :     //        condensing temperature and SC for condenser, or evaporating temperature and SH for evaporator.
   13439             :     //
   13440             :     // METHODOLOGY EMPLOYED:
   13441             :     //        This is part of the physics based VRF model applicable for Fluid Temperature Control.
   13442             : 
   13443             :     Real64 BF;              // VRF OU bypass [-]
   13444             :     Real64 deltaT;          // Difference between Te/Tc and air temperature at coil surface [C]
   13445             :     Real64 h_coil_in;       // Enthalpy of air at OU coil inlet [C]
   13446             :     Real64 h_coil_out;      // Enthalpy of air at OU coil outlet [C]
   13447             :     Real64 m_air;           // OU coil air mass flow rate [kg/s]
   13448             :     Real64 T_coil_out;      // Air temperature at coil outlet [C]
   13449             :     Real64 T_coil_surf;     // Air temperature at coil surface [C]
   13450             :     Real64 W_coil_surf_sat; // Humidity ratio of saturated air at coil surface [kg/kg]
   13451             : 
   13452           0 :     m_air = 0.0;
   13453             : 
   13454           0 :     if (OperationMode == HXOpMode::CondMode) {
   13455             :         // IU Cooling: OperationMode 0
   13456             : 
   13457           0 :         BF = this->RateBFOUCond; // 0.219;
   13458           0 :         deltaT = this->C3Tc * pow_2(SHSC) + this->C2Tc * SHSC + this->C1Tc;
   13459           0 :         T_coil_surf = TeTc - deltaT;
   13460           0 :         T_coil_out = T_coil_in + (T_coil_surf - T_coil_in) * (1 - BF);
   13461           0 :         m_air = Q_coil / (T_coil_out - T_coil_in) / 1005.0;
   13462             : 
   13463           0 :     } else if (OperationMode == HXOpMode::EvapMode) {
   13464             :         // IU Heating: OperationMode 1
   13465             : 
   13466           0 :         BF = this->RateBFOUEvap; // 0.45581;
   13467           0 :         deltaT = this->C3Te * pow_2(SHSC) + this->C2Te * SHSC + this->C1Te;
   13468           0 :         T_coil_surf = TeTc + deltaT;
   13469             : 
   13470             :         // saturated humidity ratio corresponding to T_coil_surf
   13471           0 :         W_coil_surf_sat = PsyWFnTdpPb(state, T_coil_surf, state.dataEnvrn->OutBaroPress);
   13472             : 
   13473           0 :         if (W_coil_surf_sat < W_coil_in) {
   13474             :             // There is dehumidification, W_coil_out = W_coil_surf_sat
   13475           0 :             h_coil_out = PsyHFnTdbW(T_coil_surf, W_coil_surf_sat);
   13476             :         } else {
   13477             :             // No dehumidification, W_coil_out = W_coil_in
   13478           0 :             h_coil_out = PsyHFnTdbW(T_coil_surf, W_coil_in);
   13479             :         }
   13480           0 :         h_coil_out = max(0.01, h_coil_out);
   13481           0 :         h_coil_in = PsyHFnTdbW(T_coil_in, W_coil_in);
   13482           0 :         m_air = Q_coil / (h_coil_in - h_coil_out) / (1 - BF);
   13483             : 
   13484             :     } else {
   13485             :         // Should not come here
   13486           0 :         ShowSevereMessage(state, " Unreasonable outdoor unit operational mode for \"" + this->Name + "\":");
   13487           0 :         ShowContinueError(state, " The operational mode is not correctly set in the function VRFOU_Cap.");
   13488             :     }
   13489             : 
   13490           0 :     return m_air;
   13491             : }
   13492             : 
   13493           0 : Real64 VRFCondenserEquipment::VRFOU_SCSH(EnergyPlusData &state,
   13494             :                                          HXOpMode const OperationMode, // Mode 0 for running as condenser, 1 for evaporator
   13495             :                                          Real64 const Q_coil,          // // OU coil heat release at cooling mode or heat extract at heating mode [W]
   13496             :                                          Real64 const TeTc,            // VRF Tc at cooling mode, or Te at heating mode [C]
   13497             :                                          Real64 const m_air,           // OU coil air mass flow rate [kg/s]
   13498             :                                          Real64 const T_coil_in,       // Temperature of air at OU coil inlet [C]
   13499             :                                          Real64 const W_coil_in,       // Humidity ratio of air at OU coil inlet [kg/kg]
   13500             :                                          Real64 const OutdoorPressure  // Outdoor air pressure [Pa]
   13501             : ) const
   13502             : {
   13503             : 
   13504             :     // SUBROUTINE INFORMATION:
   13505             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13506             :     //       DATE WRITTEN   Jan 2016
   13507             :     //       MODIFIED       na
   13508             :     //
   13509             :     //       RE-ENGINEERED  na
   13510             :     //
   13511             :     // PURPOSE OF THIS SUBROUTINE:
   13512             :     //        Calculate the SC for OU condenser, or SH for OU evaporator, given
   13513             :     //        VRF OU load and refrigerant side temperature, i.e., condensing temperature
   13514             :     //        for condenser, or evaporating temperature for evaporator.
   13515             :     //
   13516             :     // METHODOLOGY EMPLOYED:
   13517             :     //        This is part of the physics based VRF model applicable for Fluid Temperature Control.
   13518             : 
   13519             :     Real64 BF;              // VRF OU bypass [-]
   13520             :     Real64 deltaT;          // Difference between Te/Tc and air temperature at coil surface [C]
   13521             :     Real64 h_coil_in;       // Enthalpy of air at OU coil inlet [C]
   13522             :     Real64 h_coil_out;      // Enthalpy of air at OU coil outlet [C]
   13523             :     Real64 SHSC;            // SC for OU condenser, or SH for OU evaporator
   13524             :     Real64 T_coil_out;      // Air temperature at coil outlet [C]
   13525             :     Real64 T_coil_surf;     // Air temperature at coil surface [C]
   13526             :     Real64 T_coil_surf_sat; // Saturated air temperature at coil surface [C]
   13527             :     Real64 W_coil_surf_sat; // Humidity ratio of saturated air at coil surface [kg/kg]
   13528             : 
   13529           0 :     SHSC = 0.0;
   13530             : 
   13531           0 :     if (OperationMode == HXOpMode::CondMode) {
   13532             :         // Cooling: OperationMode 0
   13533           0 :         if (m_air <= 0) {
   13534           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13535           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit subcooling.");
   13536             :         }
   13537             : 
   13538           0 :         BF = this->RateBFOUCond; // 0.219;
   13539           0 :         T_coil_out = T_coil_in + Q_coil / 1005.0 / m_air;
   13540           0 :         T_coil_surf = T_coil_in + (T_coil_out - T_coil_in) / (1 - BF);
   13541           0 :         deltaT = TeTc - T_coil_surf;
   13542             : 
   13543             :         // SC_OU
   13544           0 :         if (this->C3Tc == 0)
   13545           0 :             SHSC = -(this->C1Tc - deltaT) / this->C2Tc;
   13546             :         else
   13547           0 :             SHSC = (-this->C2Tc + std::pow((pow_2(this->C2Tc) - 4 * (this->C1Tc - deltaT) * this->C3Tc), 0.5)) / (2 * this->C3Tc);
   13548             : 
   13549           0 :     } else if (OperationMode == HXOpMode::EvapMode) {
   13550             :         // Heating: OperationMode 1
   13551           0 :         if (m_air <= 0) {
   13552           0 :             ShowSevereMessage(state, format(" Unreasonable outdoor unit airflow rate ({:.3T} ) for \"{}\":", m_air, this->Name));
   13553           0 :             ShowContinueError(state, " This cannot be used to calculate outdoor unit super heating.");
   13554             :         }
   13555             : 
   13556           0 :         BF = this->RateBFOUEvap; // 0.45581;
   13557           0 :         h_coil_in = PsyHFnTdbW(T_coil_in, W_coil_in);
   13558           0 :         h_coil_out = h_coil_in - Q_coil / m_air / (1 - BF);
   13559           0 :         h_coil_out = max(0.01, h_coil_out);
   13560             : 
   13561           0 :         T_coil_surf_sat = PsyTsatFnHPb(state, h_coil_out, OutdoorPressure, "VRFOU_TeTc");
   13562           0 :         W_coil_surf_sat = PsyWFnTdbH(state, T_coil_surf_sat, h_coil_out, "VRFOU_TeTc");
   13563             : 
   13564           0 :         if (W_coil_surf_sat < W_coil_in)
   13565             :             // There is dehumidification
   13566           0 :             T_coil_surf = T_coil_surf_sat;
   13567             :         else
   13568             :             // No dehumidification
   13569           0 :             T_coil_surf = PsyTdbFnHW(h_coil_out, W_coil_in);
   13570             : 
   13571           0 :         deltaT = T_coil_surf - TeTc;
   13572             : 
   13573             :         // SH_OU
   13574           0 :         if (this->C3Te == 0)
   13575           0 :             SHSC = -(this->C1Te - deltaT) / this->C2Te;
   13576             :         else
   13577           0 :             SHSC = (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - deltaT) * this->C3Te), 0.5)) / (2 * this->C3Te);
   13578             : 
   13579             :     } else {
   13580             :         // Should not come here
   13581           0 :         ShowSevereMessage(state, " Unreasonable outdoor unit operational mode for \"" + this->Name + "\":");
   13582           0 :         ShowContinueError(state, " The operational mode is not correctly set in the function VRFOU_Cap.");
   13583             :     }
   13584             : 
   13585           0 :     return SHSC;
   13586             : }
   13587             : 
   13588       77590 : Real64 VRFCondenserEquipment::VRFOU_CapModFactor(
   13589             :     EnergyPlusData &state,
   13590             :     Real64 const h_comp_in_real, // Enthalpy of refrigerant at the compressor inlet at real conditions [kJ/kg]
   13591             :     Real64 const h_evap_in_real, // Enthalpy of refrigerant at the evaporator inlet at real conditions [kJ/kg]
   13592             :     Real64 const P_evap_real,    // Evaporative pressure at real conditions [Pa]
   13593             :     Real64 const T_comp_in_real, // Temperature of the refrigerant at the compressor inlet at real conditions [C]
   13594             :     Real64 const T_comp_in_rate, // Temperature of the refrigerant at the compressor inlet at rated conditions [C]
   13595             :     Real64 const T_cond_out_rate // Temperature of the refrigerant at the condenser outlet at rated conditions [C]
   13596             : )
   13597             : {
   13598             : 
   13599             :     // SUBROUTINE INFORMATION:
   13600             :     //       AUTHOR         Rongpeng Zhang
   13601             :     //       DATE WRITTEN   Nov 2015
   13602             :     //       MODIFIED       na
   13603             :     //       RE-ENGINEERED  na
   13604             : 
   13605             :     // PURPOSE OF THIS SUBROUTINE:
   13606             :     // Calculate capacity modification factor for the compressors at Outdoor Unit.
   13607             :     // This factor is used to modify the system evaporative capacity, by describing
   13608             :     // the difference between rated conditions and real conditions.
   13609             : 
   13610             :     // METHODOLOGY EMPLOYED:
   13611             :     // This is part of the VRF-FluidTCtrl Model.
   13612             : 
   13613             :     using FluidProperties::FindRefrigerant;
   13614             :     using FluidProperties::GetSatEnthalpyRefrig;
   13615             :     using FluidProperties::GetSatTemperatureRefrig;
   13616             :     using FluidProperties::GetSupHeatDensityRefrig;
   13617             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   13618             : 
   13619             :     int RefrigerantIndex;   // Index of the refrigerant [-]
   13620             :     Real64 C_cap_density;   // Compressor capacity modification algorithm_modified flow rate [-]
   13621             :     Real64 C_cap_enthalpy;  // Compressor capacity modification algorithm_modified enthalpy difference [-]
   13622             :     Real64 C_cap_operation; // Compressor capacity modification algorithm_modified Cap [-]
   13623             :     Real64 RefTSat;         // Saturated temperature of the refrigerant. Used to check whether the refrigerant is in the superheat area [C].
   13624             :     Real64 h_evap_out_rate; // enthalpy of refrigerant at the evaporator outlet at rated conditions [kJ/kg]
   13625             :     Real64 h_evap_in_rate;  // enthalpy of refrigerant at the evaporator inlet at rated conditions [kJ/kg]
   13626             :     Real64 density_rate;    // density of refrigerant at rated conditions [kg/m3]
   13627             :     Real64 density_real;    // density of refrigerant at rated conditions [kg/m3]
   13628             : 
   13629             :     static constexpr std::string_view RoutineName("VRFOU_CapModFactor");
   13630             : 
   13631             :     // variable initializations
   13632       77590 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   13633             : 
   13634             :     // Saturated temperature at real evaporating pressure
   13635       77590 :     RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, P_evap_real, RefrigerantIndex, RoutineName);
   13636             : 
   13637             :     // Enthalpy at rated conditions
   13638       77590 :     h_evap_out_rate =
   13639       77590 :         GetSupHeatEnthalpyRefrig(state, this->RefrigerantName, max(RefTSat, T_comp_in_rate), P_evap_real, RefrigerantIndex, RoutineName);
   13640       77590 :     h_evap_in_rate = GetSatEnthalpyRefrig(state, this->RefrigerantName, T_cond_out_rate, 0.0, RefrigerantIndex, RoutineName);
   13641             : 
   13642             :     // Density calculations
   13643       77590 :     density_rate = GetSupHeatDensityRefrig(state, this->RefrigerantName, T_comp_in_rate, P_evap_real, RefrigerantIndex, RoutineName);
   13644       77590 :     density_real = GetSupHeatDensityRefrig(state, this->RefrigerantName, T_comp_in_real, P_evap_real, RefrigerantIndex, RoutineName);
   13645             : 
   13646             :     // Modification factor calculations
   13647       77590 :     if (density_real > 0)
   13648       77590 :         C_cap_density = density_rate / density_real;
   13649             :     else
   13650           0 :         C_cap_density = 1.0;
   13651             : 
   13652       77590 :     if ((h_comp_in_real - h_evap_in_real) > 0)
   13653       77590 :         C_cap_enthalpy = std::abs(h_evap_out_rate - h_evap_in_rate) / std::abs(h_comp_in_real - h_evap_in_real);
   13654             :     else
   13655           0 :         C_cap_enthalpy = 1.0;
   13656             : 
   13657       77590 :     C_cap_operation = C_cap_density * C_cap_enthalpy;
   13658             : 
   13659       77590 :     return C_cap_operation;
   13660             : }
   13661             : 
   13662           0 : void VRFCondenserEquipment::VRFOU_TeModification(
   13663             :     EnergyPlusData &state,
   13664             :     Real64 const Te_up,          // Upper bound of Te during iteration, i.e., Te before reduction [C]
   13665             :     Real64 const Te_low,         // Lower bound of Te during iteration, i.e., the given suction temperature Te' [C]
   13666             :     Real64 const Pipe_h_IU_in,   // Piping Loss Algorithm Parameter: enthalpy of IU at inlet [kJ/kg]
   13667             :     Real64 const OutdoorDryBulb, // outdoor dry-bulb temperature [C]
   13668             :     Real64 &Te_update,           // Updated Te that can generate the required Tsuction [C]
   13669             :     Real64 &Pe_update,           // Piping Loss Algorithm Parameter: evaporating pressure assumed for iterations [Pa]
   13670             :     Real64 &Pipe_m_ref,          // Piping Loss Algorithm Parameter: Refrigerant mass flow rate [kg/s]
   13671             :     Real64 &Pipe_h_IU_out,       // Piping Loss Algorithm Parameter: enthalpy of IU at outlet [kJ/kg]
   13672             :     Real64 &Pipe_SH_merged       // Piping Loss Algorithm Parameter: Average SH after the indoor units [C]
   13673             : )
   13674             : {
   13675             : 
   13676             :     // SUBROUTINE INFORMATION:
   13677             :     //       AUTHOR         Rongpeng Zhang
   13678             :     //       DATE WRITTEN   Jan 2016
   13679             :     //       MODIFIED       na
   13680             :     //       RE-ENGINEERED  na
   13681             : 
   13682             :     // PURPOSE OF THIS SUBROUTINE:
   13683             :     // This is part of the low load modification algorithm for the VRF-FluidTCtrl model. It aims
   13684             :     // to find a new Te (Te_update) that can generate a new compressor suction temperature (Tsuction) equalling
   13685             :     // to the given compressor suction temperature (Te_low). This requires the re-calculate of piping loss.
   13686             : 
   13687             :     // METHODOLOGY EMPLOYED:
   13688             :     // This is part of the VRF-FluidTCtrl Model.
   13689             : 
   13690             :     using FluidProperties::FindRefrigerant;
   13691             :     using FluidProperties::GetSatPressureRefrig;
   13692             :     using FluidProperties::GetSatTemperatureRefrig;
   13693             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   13694             : 
   13695             :     int CoolCoilIndex;      // index to cooling coil in terminal unit
   13696             :     int NumTUInList;        // number of terminal units is list
   13697             :     int NumTeIte;           // counter for Te calculation iterations [-]
   13698             :     int RefrigerantIndex;   // Index of the refrigerant [-]
   13699             :     int TUListNum;          // index to TU List
   13700             :     int TUIndex;            // Index to terminal unit
   13701             :     Real64 MaxNumTeIte;     // Piping Loss Algorithm Parameter: max number of iterations for Te [-]
   13702             :     Real64 Pipe_h_comp_in;  // Piping Loss Algorithm Parameter: Enthalpy after piping loss (compressor inlet) [kJ/kg]
   13703             :     Real64 Pipe_DeltP;      // Piping Loss Algorithm Parameter: Pipe pressure drop [Pa]
   13704             :     Real64 Pipe_Q;          // Piping Loss Algorithm Parameter: Heat loss [W]
   13705             :     Real64 Pipe_m_ref_i;    // Piping Loss Algorithm Parameter: Refrigerant mass flow rate for a individual IU[kg/s]
   13706             :     Real64 Pipe_h_IU_out_i; // Piping Loss Algorithm Parameter: enthalpy of IU at outlet (individual) [kJ/kg]
   13707             :     Real64 RefTSat;         // Saturated temperature of the refrigerant [C]
   13708             :     Real64 RefPLow;         // Low Pressure Value for Ps (>0.0) [Pa]
   13709             :     Real64 RefPHigh;        // High Pressure Value for Ps (max in tables) [Pa]
   13710             :     Real64 SH_IU_update;    // Modified SH for VRF IU [C]
   13711             :     Real64 Te_ItePreci;     // Precision of iterations for Te [C]he superheat area [C]
   13712             :     Real64 Tfs;             // Temperature of the air at the coil surface [C]]
   13713             :     Real64 Tsuction;        // VRF compressor suction refrigerant temperature [Pa]
   13714             : 
   13715             :     static constexpr std::string_view RoutineName("VRFOU_TeModification");
   13716             : 
   13717             :     // variable initializations
   13718           0 :     TUListNum = this->ZoneTUListPtr;
   13719           0 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   13720           0 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   13721           0 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   13722           0 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   13723             : 
   13724             :     // Initialization of Te iterations (Label11)
   13725           0 :     NumTeIte = 1;
   13726           0 :     Te_ItePreci = 0.1;
   13727           0 :     MaxNumTeIte = (Te_up - Te_low) / Te_ItePreci + 1; // upper bound and lower bound of Te iterations
   13728           0 :     Te_update = Te_up - Te_ItePreci;
   13729             : 
   13730           0 : Label11:;
   13731           0 :     Pipe_m_ref = 0; // Total Ref Flow Rate( kg/s )
   13732           0 :     Pipe_h_IU_out = 0;
   13733           0 :     Pipe_h_IU_out_i = 0;
   13734           0 :     Pipe_m_ref_i = 0;
   13735           0 :     Pipe_SH_merged = 0;
   13736           0 :     Pe_update = GetSatPressureRefrig(state, this->RefrigerantName, Te_update, RefrigerantIndex, RoutineName);
   13737             : 
   13738             :     // Re-calculate total refrigerant flow rate, with updated SH
   13739           0 :     for (int NumTU = 1; NumTU <= NumTUInList; NumTU++) {
   13740           0 :         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0) {
   13741           0 :             TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   13742           0 :             CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   13743             : 
   13744             :             // The IU coil surface temperature should be the same.
   13745           0 :             Tfs = Te_up + (this->C3Te * pow_2(state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH) +
   13746           0 :                            this->C2Te * state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH + this->C1Te);
   13747             : 
   13748             :             // SH_IU_update is the updated SH for a specific IU
   13749           0 :             if (this->C3Te == 0)
   13750           0 :                 SH_IU_update = -(this->C1Te - Tfs + Te_update) / this->C2Te;
   13751             :             else
   13752           0 :                 SH_IU_update =
   13753           0 :                     (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + Te_update) * this->C3Te), 0.5)) / (2 * this->C3Te);
   13754             : 
   13755           0 :             RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, Pe_update, RefrigerantIndex, RoutineName);
   13756           0 :             Pipe_h_IU_out_i = GetSupHeatEnthalpyRefrig(state,
   13757             :                                                        this->RefrigerantName,
   13758           0 :                                                        max(RefTSat, Te_update + SH_IU_update),
   13759             :                                                        Pe_update,
   13760             :                                                        RefrigerantIndex,
   13761             :                                                        RoutineName); // hB_i for the IU
   13762             : 
   13763           0 :             if (Pipe_h_IU_out_i > Pipe_h_IU_in) {
   13764           0 :                 Pipe_m_ref_i = (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) <= 0.0)
   13765           0 :                                    ? 0.0
   13766           0 :                                    : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) / (Pipe_h_IU_out_i - Pipe_h_IU_in));
   13767           0 :                 Pipe_m_ref = Pipe_m_ref + Pipe_m_ref_i;
   13768           0 :                 Pipe_SH_merged = Pipe_SH_merged + Pipe_m_ref_i * SH_IU_update;
   13769           0 :                 Pipe_h_IU_out = Pipe_h_IU_out + Pipe_m_ref_i * Pipe_h_IU_out_i;
   13770             :             }
   13771             :         }
   13772             :     }
   13773           0 :     if (Pipe_m_ref > 0) {
   13774           0 :         Pipe_h_IU_out = Pipe_h_IU_out / Pipe_m_ref;
   13775           0 :         Pipe_SH_merged = Pipe_SH_merged / Pipe_m_ref;
   13776             :     } else {
   13777           0 :         Pipe_SH_merged = this->SH;
   13778           0 :         RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, Pe_update, RefrigerantIndex, RoutineName);
   13779           0 :         Pipe_h_IU_out = GetSupHeatEnthalpyRefrig(
   13780           0 :             state, this->RefrigerantName, max(RefTSat, Te_update + Pipe_SH_merged), Pe_update, RefrigerantIndex, RoutineName);
   13781             :     }
   13782             : 
   13783             :     // Re-calculate piping loss
   13784           0 :     this->VRFOU_PipeLossC(state, Pipe_m_ref, Pe_update, Pipe_h_IU_out, Pipe_SH_merged, OutdoorDryBulb, Pipe_Q, Pipe_DeltP, Pipe_h_comp_in);
   13785             : 
   13786           0 :     Tsuction =
   13787           0 :         GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pe_update - Pipe_DeltP, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   13788             : 
   13789           0 :     if ((std::abs(Tsuction - Te_low) > 0.5) && (Te_update < Te_up) && (Te_update > Te_low) && (NumTeIte < MaxNumTeIte)) {
   13790           0 :         Te_update = Te_update - 0.1;
   13791           0 :         NumTeIte = NumTeIte + 1;
   13792           0 :         goto Label11;
   13793             :     }
   13794             : 
   13795           0 :     if (std::abs(Tsuction - Te_low) > 0.5) {
   13796           0 :         NumTeIte = 999;
   13797           0 :         Tsuction = Te_low;
   13798           0 :         Pipe_SH_merged = 3.0;
   13799           0 :         Te_update = Te_low + 1;
   13800             :     }
   13801           0 : }
   13802             : 
   13803           0 : void VRFCondenserEquipment::VRFOU_CompSpd(
   13804             :     EnergyPlusData &state,
   13805             :     Real64 const Q_req,        // Required capacity [W]
   13806             :     HXOpMode const Q_type,     // Required capacity type:  0 for condenser, 1 for evaporator
   13807             :     Real64 const T_suction,    // Compressor suction temperature Te' [C]
   13808             :     Real64 const T_discharge,  // Compressor discharge temperature Tc' [C]
   13809             :     Real64 const h_IU_evap_in, // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg]
   13810             :     Real64 const h_comp_in,    // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg]
   13811             :     Real64 &CompSpdActual      // Actual compressor running speed [rps]
   13812             : )
   13813             : {
   13814             : 
   13815             :     // SUBROUTINE INFORMATION:
   13816             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13817             :     //       DATE WRITTEN   Feb 2016
   13818             :     //       MODIFIED       na
   13819             :     //       RE-ENGINEERED  na
   13820             : 
   13821             :     // PURPOSE OF THIS SUBROUTINE:
   13822             :     //       This subroutine specifies the compressor speed at given operational conditions to meet the evaporator or condenser capacity provided.
   13823             : 
   13824             :     // METHODOLOGY EMPLOYED:
   13825             :     //        This is part of the VRF-FluidTCtrl Model.
   13826             : 
   13827             :     using Curve::CurveValue;
   13828             :     using FluidProperties::FindRefrigerant;
   13829             :     using FluidProperties::GetSatPressureRefrig;
   13830             :     using FluidProperties::GetSupHeatTempRefrig;
   13831             : 
   13832             :     // Locals
   13833             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   13834             : 
   13835             :     // SUBROUTINE PARAMETER DEFINITIONS:
   13836             :     int CounterCompSpdTemp;                // Index for the compressor speed level[-]
   13837             :     int CompSpdLB;                         // index for Compressor speed low bound [-]
   13838             :     int CompSpdUB;                         // index for Compressor speed up bound [-]
   13839             :     int NumOfCompSpdInput;                 // Number of compressor speed input by the user [-]
   13840             :     int NumTUInList;                       // number of terminal units is list
   13841             :     int RefrigerantIndex;                  // Index of the refrigerant
   13842             :     int TUListNum;                         // index to TU List
   13843             :     Real64 C_cap_operation;                // Compressor capacity modification algorithm_modified Cap [-]
   13844             :     Real64 P_suction;                      // Compressor suction pressure Pe' [Pa]
   13845             :     Real64 Q_evap_req;                     // Required evaporative capacity [W]
   13846             :     Real64 Q_cond_req;                     // Required evaporative capacity [W]
   13847             :     Real64 RefPLow;                        // Low Pressure Value for Ps (>0.0) [Pa]
   13848             :     Real64 RefPHigh;                       // High Pressure Value for Ps (max in tables) [Pa]
   13849             :     Real64 SH_Comp;                        // Temperature between compressor inlet temperature and evaporative temperature Te' [C]
   13850             :     Real64 T_comp_in;                      // Refrigerant temperature at compressor inlet (after piping loss) [C]
   13851           0 :     Array1D<Real64> CompEvaporatingPWRSpd; // Array for the compressor power at certain speed [W]
   13852           0 :     Array1D<Real64> CompEvaporatingCAPSpd; // Array for the evaporating capacity at certain speed [W]
   13853             : 
   13854             :     static constexpr std::string_view RoutineName("VRFOU_CompSpd");
   13855             : 
   13856             :     // variable initializations: component index
   13857           0 :     TUListNum = this->ZoneTUListPtr;
   13858           0 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   13859           0 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   13860           0 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   13861           0 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   13862             : 
   13863             :     // variable initializations: compressor
   13864           0 :     NumOfCompSpdInput = this->CompressorSpeed.size();
   13865           0 :     CompEvaporatingPWRSpd.dimension(NumOfCompSpdInput);
   13866           0 :     CompEvaporatingCAPSpd.dimension(NumOfCompSpdInput);
   13867             : 
   13868             :     // variable initializations: system operational parameters
   13869           0 :     P_suction = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);
   13870           0 :     T_comp_in = GetSupHeatTempRefrig(state,
   13871             :                                      this->RefrigerantName,
   13872             :                                      max(min(P_suction, RefPHigh), RefPLow),
   13873             :                                      h_comp_in,
   13874             :                                      T_suction + 3,
   13875             :                                      T_suction + 30,
   13876             :                                      RefrigerantIndex,
   13877             :                                      RoutineName);
   13878           0 :     SH_Comp = T_comp_in - T_suction;
   13879             : 
   13880             :     // Calculate capacity modification factor
   13881           0 :     C_cap_operation = this->VRFOU_CapModFactor(
   13882             :         state, h_comp_in, h_IU_evap_in, max(min(P_suction, RefPHigh), RefPLow), T_suction + SH_Comp, T_suction + 8, T_discharge - 5);
   13883             : 
   13884           0 :     if (Q_type == HXOpMode::EvapMode) {
   13885             :         // Capacity to meet is for evaporator
   13886             : 
   13887           0 :         Q_evap_req = Q_req;
   13888             : 
   13889           0 :         for (CounterCompSpdTemp = 1; CounterCompSpdTemp <= NumOfCompSpdInput; CounterCompSpdTemp++) {
   13890             :             // Iteration to find the VRF speed that can meet the required load, Iteration DoName1
   13891             : 
   13892           0 :             CompEvaporatingPWRSpd(CounterCompSpdTemp) =
   13893           0 :                 this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   13894           0 :             CompEvaporatingCAPSpd(CounterCompSpdTemp) =
   13895           0 :                 this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   13896             : 
   13897           0 :             if (Q_evap_req * C_cap_operation <= CompEvaporatingCAPSpd(CounterCompSpdTemp)) {
   13898             :                 // Compressor speed stage CounterCompSpdTemp need not to be increased, finish Iteration DoName1
   13899             : 
   13900           0 :                 if (CounterCompSpdTemp > 1) {
   13901             : 
   13902           0 :                     CompSpdLB = CounterCompSpdTemp - 1;
   13903           0 :                     CompSpdUB = CounterCompSpdTemp;
   13904             : 
   13905           0 :                     CompSpdActual = this->CompressorSpeed(CompSpdLB) + (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) /
   13906           0 :                                                                            (CompEvaporatingCAPSpd(CompSpdUB) - CompEvaporatingCAPSpd(CompSpdLB)) *
   13907           0 :                                                                            (Q_evap_req * C_cap_operation - CompEvaporatingCAPSpd(CompSpdLB));
   13908             : 
   13909             :                 } else {
   13910           0 :                     CompSpdActual = this->CompressorSpeed(1) * (Q_evap_req * C_cap_operation) / CompEvaporatingCAPSpd(1);
   13911             :                 }
   13912             : 
   13913           0 :                 break; // EXIT DoName1
   13914             :             }
   13915             :         } // End: Iteration DoName1
   13916             : 
   13917           0 :         if (CounterCompSpdTemp > NumOfCompSpdInput) {
   13918           0 :             CompSpdActual = this->CompressorSpeed(NumOfCompSpdInput);
   13919             :         }
   13920             : 
   13921             :     } else {
   13922             :         // Capacity to meet is for condenser
   13923             : 
   13924           0 :         Q_cond_req = Q_req;
   13925             : 
   13926           0 :         for (CounterCompSpdTemp = 1; CounterCompSpdTemp <= NumOfCompSpdInput; CounterCompSpdTemp++) {
   13927             :             // Iteration to find the VRF speed that can meet the required load, Iteration DoName1
   13928             : 
   13929           0 :             CompEvaporatingPWRSpd(CounterCompSpdTemp) =
   13930           0 :                 this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   13931           0 :             CompEvaporatingCAPSpd(CounterCompSpdTemp) =
   13932           0 :                 this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   13933             : 
   13934           0 :             Q_evap_req = Q_cond_req - CompEvaporatingPWRSpd(CounterCompSpdTemp);
   13935             : 
   13936           0 :             if (Q_evap_req * C_cap_operation <= CompEvaporatingCAPSpd(CounterCompSpdTemp)) {
   13937             :                 // Compressor speed stage CounterCompSpdTemp need not to be increased, finish Iteration DoName1
   13938             : 
   13939           0 :                 if (CounterCompSpdTemp > 1) {
   13940             : 
   13941           0 :                     CompSpdLB = CounterCompSpdTemp - 1;
   13942           0 :                     CompSpdUB = CounterCompSpdTemp;
   13943             : 
   13944           0 :                     CompSpdActual = this->CompressorSpeed(CompSpdLB) + (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) /
   13945           0 :                                                                            (CompEvaporatingCAPSpd(CompSpdUB) - CompEvaporatingCAPSpd(CompSpdLB)) *
   13946           0 :                                                                            (Q_evap_req * C_cap_operation - CompEvaporatingCAPSpd(CompSpdLB));
   13947             : 
   13948             :                 } else {
   13949           0 :                     CompSpdActual = this->CompressorSpeed(1) * (Q_evap_req * C_cap_operation) / CompEvaporatingCAPSpd(1);
   13950             :                 }
   13951             : 
   13952           0 :                 break; // EXIT DoName1
   13953             :             }
   13954             :         } // End: Iteration DoName1
   13955             : 
   13956           0 :         if (CounterCompSpdTemp > NumOfCompSpdInput) {
   13957           0 :             CompSpdActual = this->CompressorSpeed(NumOfCompSpdInput);
   13958             :         }
   13959             :     }
   13960           0 : }
   13961             : 
   13962           0 : void VRFCondenserEquipment::VRFOU_CompCap(
   13963             :     EnergyPlusData &state,
   13964             :     int const CompSpdActual,   // Given compressor speed
   13965             :     Real64 const T_suction,    // Compressor suction temperature Te' [C]
   13966             :     Real64 const T_discharge,  // Compressor discharge temperature Tc' [C]
   13967             :     Real64 const h_IU_evap_in, // Enthalpy of IU at inlet, for C_cap_operation calculation [kJ/kg]
   13968             :     Real64 const h_comp_in,    // Enthalpy after piping loss (compressor inlet), for C_cap_operation calculation [kJ/kg]
   13969             :     Real64 &Q_c_tot,           // Compressor evaporative capacity [W]
   13970             :     Real64 &Ncomp              // Compressor power [W]
   13971             : )
   13972             : {
   13973             : 
   13974             :     // SUBROUTINE INFORMATION:
   13975             :     //       AUTHOR         Rongpeng Zhang, LBNL
   13976             :     //       DATE WRITTEN   Feb 2016
   13977             :     //       MODIFIED       na
   13978             :     //       RE-ENGINEERED  na
   13979             : 
   13980             :     // PURPOSE OF THIS SUBROUTINE:
   13981             :     //       This subroutine specifies the compressor performance (power and capacity) at given compressor speed and operational conditions.
   13982             : 
   13983             :     // METHODOLOGY EMPLOYED:
   13984             :     //       This is part of the VRF-FluidTCtrl Model.
   13985             : 
   13986             :     using Curve::CurveValue;
   13987             :     using FluidProperties::FindRefrigerant;
   13988             :     using FluidProperties::GetSatPressureRefrig;
   13989             :     using FluidProperties::GetSupHeatTempRefrig;
   13990             : 
   13991             :     int CounterCompSpdTemp;                // Index for the compressor speed level[-]
   13992             :     int CompSpdLB;                         // index for Compressor speed low bound [-]
   13993             :     int CompSpdUB;                         // index for Compressor speed up bound [-]
   13994             :     int NumOfCompSpdInput;                 // Number of compressor speed input by the user [-]
   13995             :     int NumTUInList;                       // number of terminal units is list
   13996             :     int RefrigerantIndex;                  // Index of the refrigerant
   13997             :     int TUListNum;                         // index to TU List
   13998             :     Real64 C_cap_operation;                // Compressor capacity modification algorithm_modified Cap [-]
   13999             :     Real64 P_suction;                      // Compressor suction pressure Pe' [Pa]
   14000             :     Real64 Q_evap_sys;                     // evaporative capacity [W]
   14001             :     Real64 RefPLow;                        // Low Pressure Value for Ps (>0.0) [Pa]
   14002             :     Real64 RefPHigh;                       // High Pressure Value for Ps (max in tables) [Pa]
   14003             :     Real64 SH_Comp;                        // Temperature between compressor inlet temperature and evaporative temperature Te' [C]
   14004             :     Real64 T_comp_in;                      // Refrigerant temperature at compressor inlet (after piping loss) [C]
   14005           0 :     Array1D<Real64> CompEvaporatingPWRSpd; // Array for the compressor power at certain speed [W]
   14006           0 :     Array1D<Real64> CompEvaporatingCAPSpd; // Array for the evaporating capacity at certain speed [W]
   14007             : 
   14008             :     static constexpr std::string_view RoutineName("VRFOU_CompCap");
   14009             : 
   14010             :     // variable initializations: component index
   14011           0 :     TUListNum = this->ZoneTUListPtr;
   14012           0 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   14013           0 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   14014           0 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   14015           0 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   14016             : 
   14017             :     // variable initializations: compressor
   14018           0 :     NumOfCompSpdInput = this->CompressorSpeed.size();
   14019           0 :     CompEvaporatingPWRSpd.dimension(NumOfCompSpdInput);
   14020           0 :     CompEvaporatingCAPSpd.dimension(NumOfCompSpdInput);
   14021             : 
   14022           0 :     for (CounterCompSpdTemp = 1; CounterCompSpdTemp <= NumOfCompSpdInput; CounterCompSpdTemp++) {
   14023             : 
   14024           0 :         CompEvaporatingPWRSpd(CounterCompSpdTemp) =
   14025           0 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   14026           0 :         CompEvaporatingCAPSpd(CounterCompSpdTemp) =
   14027           0 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   14028             : 
   14029           0 :         if (CompSpdActual <= this->CompressorSpeed(CounterCompSpdTemp)) {
   14030             :             // Compressor speed stage CounterCompSpdTemp need not to be increased, finish Iteration DoName1
   14031             : 
   14032           0 :             if (CounterCompSpdTemp > 1) {
   14033             : 
   14034           0 :                 CompSpdLB = CounterCompSpdTemp - 1;
   14035           0 :                 CompSpdUB = CounterCompSpdTemp;
   14036             : 
   14037           0 :                 Q_evap_sys = CompEvaporatingCAPSpd(CompSpdLB) + (CompEvaporatingCAPSpd(CompSpdUB) - CompEvaporatingCAPSpd(CompSpdLB)) *
   14038           0 :                                                                     (CompSpdActual - this->CompressorSpeed(CompSpdLB)) /
   14039           0 :                                                                     (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB));
   14040           0 :                 Ncomp = CompEvaporatingPWRSpd(CompSpdLB) + (CompEvaporatingPWRSpd(CompSpdUB) - CompEvaporatingPWRSpd(CompSpdLB)) *
   14041           0 :                                                                (CompSpdActual - this->CompressorSpeed(CompSpdLB)) /
   14042           0 :                                                                (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB));
   14043             : 
   14044             :             } else {
   14045           0 :                 Q_evap_sys = CompEvaporatingCAPSpd(1) * CompSpdActual / this->CompressorSpeed(1);
   14046           0 :                 Ncomp = CompEvaporatingPWRSpd(1) * CompSpdActual / this->CompressorSpeed(1);
   14047             :             }
   14048             : 
   14049           0 :             break;
   14050             :         }
   14051             :     }
   14052             : 
   14053           0 :     if (CounterCompSpdTemp > NumOfCompSpdInput) {
   14054           0 :         Q_evap_sys = CompEvaporatingCAPSpd(NumOfCompSpdInput);
   14055           0 :         Ncomp = CompEvaporatingPWRSpd(NumOfCompSpdInput);
   14056             :     }
   14057             : 
   14058             :     // variable initializations: system operational parameters
   14059           0 :     P_suction = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);
   14060           0 :     T_comp_in = GetSupHeatTempRefrig(state,
   14061             :                                      this->RefrigerantName,
   14062             :                                      max(min(P_suction, RefPHigh), RefPLow),
   14063             :                                      h_comp_in,
   14064             :                                      T_suction + 3,
   14065             :                                      T_suction + 30,
   14066             :                                      RefrigerantIndex,
   14067             :                                      RoutineName);
   14068           0 :     SH_Comp = T_comp_in - T_suction;
   14069             : 
   14070             :     // Calculate capacity modification factor
   14071           0 :     C_cap_operation = this->VRFOU_CapModFactor(
   14072             :         state, h_comp_in, h_IU_evap_in, max(min(P_suction, RefPHigh), RefPLow), T_suction + SH_Comp, T_suction + 8, T_discharge - 5);
   14073           0 :     C_cap_operation = min(1.5, max(0.5, C_cap_operation));
   14074           0 :     Q_c_tot = Q_evap_sys / C_cap_operation;
   14075           0 : }
   14076             : 
   14077       13630 : void VRFCondenserEquipment::VRFOU_CalcCompC(EnergyPlusData &state,
   14078             :                                             Real64 TU_load,            // Indoor unit cooling load [W]
   14079             :                                             Real64 T_suction,          // Compressor suction temperature Te' [C]
   14080             :                                             Real64 T_discharge,        // Compressor discharge temperature Tc' [C]
   14081             :                                             Real64 P_suction,          // Compressor suction pressure Pe' [Pa]
   14082             :                                             Real64 Pipe_T_comp_in,     // Refrigerant temperature at compressor inlet (after piping loss) [C]
   14083             :                                             Real64 Pipe_h_comp_in,     // Enthalpy after piping loss (compressor inlet) [kJ/kg]
   14084             :                                             Real64 Pipe_h_IU_in,       // Enthalpy of IU at inlet [kJ/kg]
   14085             :                                             Real64 Pipe_Q,             // Piping Loss Algorithm Parameter: Heat loss [W]
   14086             :                                             Real64 MaxOutdoorUnitTc,   // The maximum temperature that Tc can be at heating mode [C]
   14087             :                                             Real64 &OUCondHeatRelease, // Condenser heat release (cooling mode) [W]
   14088             :                                             Real64 &CompSpdActual,     // Actual compressor running speed [rps]
   14089             :                                             Real64 &Ncomp              // Compressor power [W]
   14090             : )
   14091             : {
   14092             : 
   14093             :     // SUBROUTINE INFORMATION:
   14094             :     //       AUTHOR         Xiufeng Pang
   14095             :     //       DATE WRITTEN   Feb 2014
   14096             :     //       MODIFIED       Rongpeng Zhang, Jan 2016
   14097             :     //       RE-ENGINEERED  na
   14098             : 
   14099             :     // PURPOSE OF THIS SUBROUTINE:
   14100             :     // This subroutine simulates the compressor performance at given oprtaional conditions (cooling mode). More specifically, it sepcifies
   14101             :     // the compressor speed to provide sufficient evaporative capacity, and calculate the power of the compressor running at the specified
   14102             :     // speed. Note that it may be needed to manipulate the operational conditions to further adjust system capacity at low load conditions.
   14103             :     // The low load modification logics are different for cooling mode and heating mode.
   14104             : 
   14105             :     // METHODOLOGY EMPLOYED:
   14106             :     // This is part of the VRF-FluidTCtrl Model.
   14107             : 
   14108             :     using Curve::CurveValue;
   14109             :     using FluidProperties::FindRefrigerant;
   14110             :     using FluidProperties::GetSatEnthalpyRefrig;
   14111             :     using FluidProperties::GetSatPressureRefrig;
   14112             :     using FluidProperties::GetSatTemperatureRefrig;
   14113             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   14114             :     using FluidProperties::GetSupHeatTempRefrig;
   14115             :     using General::SolveRoot;
   14116             : 
   14117             :     int CounterCompSpdTemp;                // Index for the compressor speed level[-]
   14118             :     int CompSpdLB;                         // index for Compressor speed low bound [-]
   14119             :     int CompSpdUB;                         // index for Compressor speed up bound [-]
   14120             :     int CoolCoilIndex;                     // index to cooling coil in terminal unit
   14121       13630 :     int MaxIter(500);                      // max iteration number allowed [-]
   14122             :     int NumOfCompSpdInput;                 // Number of compressor speed input by the user [-]
   14123             :     int NumIteCcap;                        // counter for Ccap calculation iterations [-]
   14124             :     int NumIteTe;                          // counter for Te calculation iterations [-]
   14125             :     int NumTUInList;                       // number of terminal units is list
   14126             :     int RefrigerantIndex;                  // Index of the refrigerant [-]
   14127             :     int SolFla;                            // Slove flag for SolveRoot [-]
   14128             :     int TUListNum;                         // index to TU List
   14129             :     int TUIndex;                           // Index to terminal unit
   14130             :     Real64 Cap_Eva0;                       // Evaporating capacity calculated based on physics model, used in the iterations [W]
   14131             :     Real64 Cap_Eva1;                       // Evaporating capacity calculated by curves, used in the iterations [W]
   14132             :     Real64 CapDiff;                        // Evaporating capacity difference used in the iterations [W]
   14133             :     Real64 C_cap_operation;                // Compressor capacity modification algorithm_modified Cap [-]
   14134             :     Real64 C_cap_operation0;               // Compressor capacity modification algorithm_modified Cap, for temporary use [-]
   14135             :     Real64 SmallLoadTe;                    // Updated suction temperature at small load conditions (Te') [C]
   14136             :     Real64 Modifi_SH;                      // Temperature between compressor inlet temperature and evaporative temperature Te' [C]
   14137             :     Real64 MaxNumIteTe;                    // Piping Loss Algorithm Parameter: max number of iterations for Te [-]
   14138             :     Real64 MinOutdoorUnitTe;               // The minimum temperature that Te can be at cooling mode (only used for calculating Min capacity)
   14139             :     Real64 MinOutdoorUnitPe;               // The minimum pressure that Pe can be at cooling mode (only used for calculating Min capacity)
   14140             :     Real64 MinRefriPe;                     // Minimum refrigerant evaporating pressure [Pa]
   14141             :     Real64 Modifi_SHin;                    // Compressor power modification algorithm_modified SH for IDU [C]
   14142             :     Real64 P_discharge;                    // VRF compressor discharge pressure [Pa]
   14143             :     Real64 Pipe_m_ref;                     // Piping Loss Algorithm Parameter: Refrigerant mass flow rate [kg/s]
   14144             :     Real64 Pipe_DeltP;                     // Piping Loss Algorithm Parameter: Pipe pressure drop [Pa]
   14145             :     Real64 Pipe_Q0;                        // Compressor capacity modification algorithm_modified Pipe_Q, for temporary use [W]
   14146             :     Real64 Pipe_m_ref_i;                   // Piping Loss Algorithm Parameter: Refrigerant mass flow rate for a individual IU[kg/s]
   14147             :     Real64 Pipe_h_IU_out;                  // Piping Loss Algorithm Parameter: enthalpy of IU at outlet [kJ/kg]
   14148             :     Real64 Pipe_h_IU_out_i;                // Piping Loss Algorithm Parameter: enthalpy of IU at outlet (individual) [kJ/kg]
   14149             :     Real64 Pipe_Pe_assumed;                // Piping Loss Algorithm Parameter: evaporating pressure assumed for iterations[Pa]
   14150             :     Real64 Pipe_SH_merged;                 // Piping Loss Algorithm Parameter: average super heating degrees after the indoor units [C]
   14151             :     Real64 Pipe_Te_assumed;                // Piping Loss Algorithm Parameter: evaporating temperature assumed for iterations[C]
   14152             :     Real64 Q_evap_req;                     // Required evaporative capacity [W]
   14153             :     Real64 RefTSat;                        // Saturated temperature of the refrigerant [C]
   14154             :     Real64 RefPLow;                        // Low Pressure Value for Ps (>0.0) [Pa]
   14155             :     Real64 RefPHigh;                       // High Pressure Value for Ps (max in tables) [Pa]
   14156             :     Real64 T_discharge_new;                // Condensing temperature, for temporary use in iterations [C]
   14157             :     Real64 Tfs;                            // Temperature of the air at the coil surface [C]]
   14158       13630 :     Real64 Tolerance(0.05);                // Tolerance for condensing temperature calculation [C}
   14159       27260 :     Array1D<Real64> CompEvaporatingPWRSpd; // Array for the compressor power at certain speed [W]
   14160       27260 :     Array1D<Real64> CompEvaporatingCAPSpd; // Array for the evaporating capacity at certain speed [W]
   14161             : 
   14162             :     static constexpr std::string_view RoutineName("VRFOU_CalcCompC");
   14163             : 
   14164             :     // variable initializations
   14165       13630 :     NumOfCompSpdInput = this->CompressorSpeed.size();
   14166       13630 :     CompEvaporatingPWRSpd.dimension(NumOfCompSpdInput);
   14167       13630 :     CompEvaporatingCAPSpd.dimension(NumOfCompSpdInput);
   14168       13630 :     Q_evap_req = TU_load + Pipe_Q;
   14169             : 
   14170       13630 :     TUListNum = this->ZoneTUListPtr;
   14171       13630 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   14172       13630 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   14173       13630 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   14174       13630 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   14175             : 
   14176       13630 :     Modifi_SH = Pipe_T_comp_in - T_suction;
   14177             : 
   14178             :     // set condenser entering air conditions (Outdoor air conditions)
   14179       13630 :     Real64 OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   14180       13630 :     Real64 OutdoorHumRat = state.dataEnvrn->OutHumRat;
   14181       13630 :     Real64 OutdoorPressure = state.dataEnvrn->OutBaroPress;
   14182       13630 :     Real64 RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
   14183             : 
   14184             :     // Calculate capacity modification factor
   14185       13630 :     C_cap_operation = this->VRFOU_CapModFactor(
   14186             :         state, Pipe_h_comp_in, Pipe_h_IU_in, max(min(P_suction, RefPHigh), RefPLow), T_suction + Modifi_SH, T_suction + 8, T_discharge - 5);
   14187             : 
   14188       36379 :     for (CounterCompSpdTemp = 1; CounterCompSpdTemp <= NumOfCompSpdInput; CounterCompSpdTemp++) {
   14189             :         // Iteration to find the VRF speed that can meet the required load, Iteration DoName1
   14190             : 
   14191       35146 :         CompEvaporatingPWRSpd(CounterCompSpdTemp) =
   14192       70292 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   14193       35146 :         CompEvaporatingCAPSpd(CounterCompSpdTemp) =
   14194       70292 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   14195             : 
   14196       35146 :         if (Q_evap_req * C_cap_operation <= CompEvaporatingCAPSpd(CounterCompSpdTemp)) {
   14197             :             // Compressor speed stage CounterCompSpdTemp need not to be increased, finish Iteration DoName1
   14198             : 
   14199       12397 :             if (CounterCompSpdTemp > 1) { // Since: if( CounterCompSpdTemp <= 1 )
   14200             :                 // Compressor speed > min
   14201             : 
   14202       10265 :                 CompSpdLB = CounterCompSpdTemp - 1;
   14203       10265 :                 CompSpdUB = CounterCompSpdTemp;
   14204             : 
   14205       30795 :                 CompSpdActual = this->CompressorSpeed(CompSpdLB) + (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) /
   14206       20530 :                                                                        (CompEvaporatingCAPSpd(CompSpdUB) - CompEvaporatingCAPSpd(CompSpdLB)) *
   14207       10265 :                                                                        (Q_evap_req * C_cap_operation - CompEvaporatingCAPSpd(CompSpdLB));
   14208             : 
   14209       30795 :                 Ncomp = CompEvaporatingPWRSpd(CompSpdLB) + (CompEvaporatingPWRSpd(CompSpdUB) - CompEvaporatingPWRSpd(CompSpdLB)) /
   14210       20530 :                                                                (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) *
   14211       10265 :                                                                (CompSpdActual - this->CompressorSpeed(CompSpdLB));
   14212       10265 :                 break; // EXIT DoName1
   14213             : 
   14214             :             } else {
   14215             :                 // Compressor runs at the min speed
   14216             :                 // Low Load Modification Algorithm for cooling (IU side modification)
   14217             : 
   14218             :                 // Initialization of NumIteCcap iterations (Label13)
   14219        2132 :                 Pipe_Q0 = Pipe_Q;
   14220        2132 :                 C_cap_operation0 = C_cap_operation;
   14221        2132 :                 T_discharge_new = T_discharge;
   14222        2132 :                 NumIteCcap = 1;
   14223             : 
   14224             :             // Update the C_cap_operation
   14225        7162 :             Label13:;
   14226        7162 :                 Q_evap_req = TU_load + Pipe_Q0; // Pipe_Q0 is updated during the iteration
   14227        7162 :                 Pipe_h_IU_in = GetSatEnthalpyRefrig(state, this->RefrigerantName, T_discharge_new - this->SC, 0.0, RefrigerantIndex, RoutineName);
   14228        7162 :                 CompSpdActual = this->CompressorSpeed(1);
   14229        7162 :                 Real64 CondHeat = Q_evap_req * C_cap_operation0 / this->RatedEvapCapacity; // 150130 To be confirmed
   14230        7162 :                 int CAPFT = this->OUCoolingCAPFT(CounterCompSpdTemp);
   14231             : 
   14232             :                 // Update Te' (SmallLoadTe) to meet the required evaporator capacity
   14233        7162 :                 MinOutdoorUnitTe = 6;
   14234        7162 :                 P_discharge = GetSatPressureRefrig(state, this->RefrigerantName, T_discharge, RefrigerantIndex, RoutineName);
   14235             : 
   14236        7162 :                 MinRefriPe = GetSatPressureRefrig(state, this->RefrigerantName, -15, RefrigerantIndex, RoutineName);
   14237        7162 :                 MinOutdoorUnitPe = max(P_discharge - this->CompMaxDeltaP, MinRefriPe);
   14238        7162 :                 MinOutdoorUnitTe = GetSatTemperatureRefrig(
   14239             :                     state, this->RefrigerantName, max(min(MinOutdoorUnitPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14240             : 
   14241       30488 :                 auto f = [&state, T_discharge_new, CondHeat, CAPFT](Real64 const T_suc) {
   14242             :                     return CompResidual_FluidTCtrl(state, T_discharge_new, CondHeat, CAPFT, T_suc);
   14243       37650 :                 };
   14244             : 
   14245        7162 :                 General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, SmallLoadTe, f, MinOutdoorUnitTe,
   14246             :                                    T_suction);   // SmallLoadTe is the updated Te'
   14247        7162 :                 if (SolFla < 0) SmallLoadTe = 6; // MinOutdoorUnitTe; //SmallLoadTe( Te'_new ) is constant during iterations
   14248             : 
   14249             :                 // Get an updated Te corresponding to the updated Te'
   14250             :                 // VRFOU_TeModification( VRFCond, this->EvaporatingTemp, SmallLoadTe, Pipe_h_IU_in, OutdoorDryBulb, Pipe_Te_assumed,
   14251             :                 // Pipe_Pe_assumed, Pipe_m_ref, Pipe_SH_merged );
   14252             :                 {
   14253             :                     // Initialization of Iteration_Te (Label11)
   14254             :                     // i.e., find a new Te (Pipe_Te_assumed) that can generate a new T_suction equalling to SmallLoadTe.
   14255             :                     // This requires the re-calculate of piping loss.
   14256        7162 :                     NumIteTe = 1;
   14257        7162 :                     MaxNumIteTe = (this->EvaporatingTemp - SmallLoadTe) / 0.1 + 1; // upper bound and lower bound of Te iterations
   14258        7162 :                     Pipe_Te_assumed = this->EvaporatingTemp - 0.1;
   14259             : 
   14260      568146 :                 Label11:;
   14261      568146 :                     Pipe_m_ref = 0; // Total Ref Flow Rate( kg/s )
   14262             : 
   14263             :                     // Re-calculate Piping loss due to the Te and SH updates
   14264      568146 :                     Pipe_h_IU_out = 0;
   14265      568146 :                     Pipe_h_IU_out_i = 0;
   14266      568146 :                     Pipe_m_ref_i = 0;
   14267      568146 :                     Pipe_SH_merged = 0;
   14268      568146 :                     Pipe_Pe_assumed = GetSatPressureRefrig(state, this->RefrigerantName, Pipe_Te_assumed, RefrigerantIndex, RoutineName);
   14269             : 
   14270             :                     // Re-calculate total refrigerant flow rate, with updated SH
   14271     3408876 :                     for (int NumTU = 1; NumTU <= NumTUInList; NumTU++) {
   14272     2840730 :                         if (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) > 0) {
   14273     2711198 :                             TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   14274     2711198 :                             CoolCoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   14275             : 
   14276     8133594 :                             Tfs = this->EvaporatingTemp + (this->C3Te * pow_2(state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH) +
   14277     5422396 :                                                            this->C2Te * state.dataDXCoils->DXCoil(CoolCoilIndex).ActualSH + this->C1Te);
   14278             : 
   14279             :                             // Modifi_SH is the updated SH for a specific IU
   14280     2711198 :                             if (this->C3Te == 0)
   14281           0 :                                 Modifi_SHin = -(this->C1Te - Tfs + Pipe_Te_assumed) / this->C2Te; // 150130 Modifi_SH>Modifi_SHin
   14282             :                             else
   14283     2711198 :                                 Modifi_SHin =
   14284     2711198 :                                     (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + Pipe_Te_assumed) * this->C3Te), 0.5)) /
   14285     2711198 :                                     (2 * this->C3Te);
   14286             : 
   14287     2711198 :                             RefTSat = GetSatTemperatureRefrig(
   14288             :                                 state, this->RefrigerantName, max(min(Pipe_Pe_assumed, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14289     2711198 :                             Pipe_h_IU_out_i = GetSupHeatEnthalpyRefrig(state,
   14290             :                                                                        this->RefrigerantName,
   14291             :                                                                        max(RefTSat, Pipe_Te_assumed + Modifi_SHin),
   14292             :                                                                        max(min(Pipe_Pe_assumed, RefPHigh), RefPLow),
   14293             :                                                                        RefrigerantIndex,
   14294             :                                                                        RoutineName);
   14295             : 
   14296     2711198 :                             if (Pipe_h_IU_out_i > Pipe_h_IU_in) {
   14297     5422396 :                                 Pipe_m_ref_i = (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) <= 0.0)
   14298     5422396 :                                                    ? 0.0
   14299     2711198 :                                                    : (state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).TotalCoolLoad(NumTU) /
   14300     2711198 :                                                       (Pipe_h_IU_out_i - Pipe_h_IU_in));
   14301     2711198 :                                 Pipe_m_ref = Pipe_m_ref + Pipe_m_ref_i;
   14302     2711198 :                                 Pipe_SH_merged = Pipe_SH_merged + Pipe_m_ref_i * Modifi_SHin;
   14303     2711198 :                                 Pipe_h_IU_out = Pipe_h_IU_out + Pipe_m_ref_i * Pipe_h_IU_out_i;
   14304             :                             }
   14305             :                         }
   14306             :                     }
   14307      568146 :                     if (Pipe_m_ref > 0) {
   14308      568146 :                         Pipe_h_IU_out = Pipe_h_IU_out / Pipe_m_ref;
   14309      568146 :                         Pipe_SH_merged = Pipe_SH_merged / Pipe_m_ref;
   14310             :                     } else {
   14311           0 :                         Pipe_SH_merged = this->SH;
   14312           0 :                         RefTSat = GetSatTemperatureRefrig(
   14313             :                             state, this->RefrigerantName, max(min(Pipe_Pe_assumed, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14314           0 :                         Pipe_h_IU_out = GetSupHeatEnthalpyRefrig(state,
   14315             :                                                                  this->RefrigerantName,
   14316             :                                                                  max(RefTSat, Pipe_Te_assumed + Pipe_SH_merged),
   14317             :                                                                  max(min(Pipe_Pe_assumed, RefPHigh), RefPLow),
   14318             :                                                                  RefrigerantIndex,
   14319             :                                                                  RoutineName);
   14320             :                     }
   14321             : 
   14322             :                     // Re-calculate piping loss
   14323      568146 :                     this->VRFOU_PipeLossC(state,
   14324             :                                           Pipe_m_ref,
   14325             :                                           max(min(Pipe_Pe_assumed, RefPHigh), RefPLow),
   14326             :                                           Pipe_h_IU_out,
   14327             :                                           Pipe_SH_merged,
   14328             :                                           OutdoorDryBulb,
   14329             :                                           Pipe_Q,
   14330             :                                           Pipe_DeltP,
   14331             :                                           Pipe_h_comp_in);
   14332             : 
   14333      568146 :                     T_suction = GetSatTemperatureRefrig(
   14334             :                         state, this->RefrigerantName, max(min(Pipe_Pe_assumed - Pipe_DeltP, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14335             : 
   14336     1129130 :                     if ((std::abs(T_suction - SmallLoadTe) > 0.5) && (Pipe_Te_assumed < this->EvaporatingTemp) && (Pipe_Te_assumed > SmallLoadTe) &&
   14337      560984 :                         (NumIteTe < MaxNumIteTe)) {
   14338      560984 :                         Pipe_Te_assumed = Pipe_Te_assumed - 0.1;
   14339      560984 :                         NumIteTe = NumIteTe + 1;
   14340      560984 :                         goto Label11;
   14341             :                     }
   14342             : 
   14343        7162 :                     if (std::abs(T_suction - SmallLoadTe) > 0.5) {
   14344           0 :                         NumIteTe = 999;
   14345           0 :                         T_suction = SmallLoadTe;
   14346           0 :                         Pipe_SH_merged = 3.0;
   14347           0 :                         Pipe_Te_assumed = SmallLoadTe + 1;
   14348             :                     }
   14349             :                     // Iteration_Te End
   14350             :                 }
   14351             : 
   14352             :                 // Perform iteration to calculate Pipe_T_comp_in( Te'+SH' )
   14353        7162 :                 Pipe_T_comp_in = GetSupHeatTempRefrig(state,
   14354             :                                                       this->RefrigerantName,
   14355             :                                                       max(min(Pipe_Pe_assumed - Pipe_DeltP, RefPHigh), RefPLow),
   14356             :                                                       Pipe_h_comp_in,
   14357             :                                                       T_suction + 3,
   14358             :                                                       T_suction + 30,
   14359             :                                                       RefrigerantIndex,
   14360             :                                                       RoutineName);
   14361             : 
   14362        7162 :                 Modifi_SH = Pipe_T_comp_in - T_suction;
   14363        7162 :                 P_suction = Pipe_Pe_assumed - Pipe_DeltP;
   14364        7162 :                 OUCondHeatRelease = TU_load + Pipe_Q + Ncomp; // Pipe_Q is changed when T_suction is changed -> Tc is also changed
   14365             : 
   14366             :                 // *VRF OU Tc calculations
   14367        7162 :                 this->VRFOU_TeTc(state,
   14368             :                                  HXOpMode::CondMode,
   14369             :                                  OUCondHeatRelease,
   14370             :                                  this->SC,
   14371        7162 :                                  this->OUAirFlowRate * RhoAir,
   14372             :                                  OutdoorDryBulb,
   14373             :                                  OutdoorHumRat,
   14374             :                                  OutdoorPressure,
   14375             :                                  Tfs,
   14376             :                                  T_discharge);
   14377        7162 :                 T_discharge = min(MaxOutdoorUnitTc, T_discharge);
   14378             : 
   14379             :                 // *Calculate capacity modification factor
   14380        7162 :                 C_cap_operation = this->VRFOU_CapModFactor(state,
   14381             :                                                            Pipe_h_comp_in,
   14382             :                                                            Pipe_h_IU_in,
   14383             :                                                            max(min(P_suction, RefPHigh), RefPLow),
   14384             :                                                            T_suction + Modifi_SH,
   14385             :                                                            T_suction + 8,
   14386             :                                                            T_discharge - 5);
   14387             : 
   14388        7162 :                 Cap_Eva0 = (TU_load + Pipe_Q) * C_cap_operation; // New Pipe_Q & C_cap_operation
   14389       14324 :                 Cap_Eva1 = this->CoffEvapCap * this->RatedEvapCapacity *
   14390       14324 :                            CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction); // New Tc
   14391        7162 :                 CapDiff = std::abs(Cap_Eva1 - Cap_Eva0);
   14392             : 
   14393        7162 :                 if ((CapDiff > (Tolerance * Cap_Eva0)) && (NumIteCcap < 30)) {
   14394        5030 :                     Pipe_Q0 = Pipe_Q;
   14395        5030 :                     C_cap_operation0 = C_cap_operation;
   14396        5030 :                     T_discharge_new = T_discharge;
   14397        5030 :                     NumIteCcap = NumIteCcap + 1;
   14398        5030 :                     goto Label13;
   14399             :                 }
   14400             : 
   14401        2132 :                 if (CapDiff > (Tolerance * Cap_Eva0)) NumIteCcap = 999;
   14402             : 
   14403        2132 :                 Ncomp = this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   14404             : 
   14405        2132 :                 this->CondensingTemp = T_discharge; // OU Tc' is updated due to OUCondHeatRelease updates, which is caused by IU Te' updates
   14406             :                                                     // during low load conditions
   14407             : 
   14408        2132 :                 break; // EXIT DoName1
   14409             : 
   14410             :             } // End: if( CounterCompSpdTemp <= 1 ) Low load modification
   14411             : 
   14412             :         } // End: if( Q_evap_req <= CompEvaporatingCAPSpd( CounterCompSpdTemp ) )
   14413             : 
   14414             :     } // End: Iteration DoName1
   14415             : 
   14416       13630 :     if (CounterCompSpdTemp > NumOfCompSpdInput) {
   14417             :         // Required load is beyond the maximum system capacity
   14418        1233 :         CompEvaporatingCAPSpd(NumOfCompSpdInput) =
   14419        2466 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), T_discharge, T_suction);
   14420        1233 :         OUCondHeatRelease = Ncomp + CompEvaporatingCAPSpd(NumOfCompSpdInput);
   14421        1233 :         CompSpdActual = this->CompressorSpeed(NumOfCompSpdInput);
   14422        1233 :         Ncomp = CompEvaporatingPWRSpd(NumOfCompSpdInput);
   14423             :     }
   14424       13630 : }
   14425             : 
   14426       20100 : void VRFCondenserEquipment::VRFOU_CalcCompH(
   14427             :     EnergyPlusData &state,
   14428             :     Real64 TU_load,            // Indoor unit heating load [W]
   14429             :     Real64 T_suction,          // Compressor suction temperature Te' [C]
   14430             :     Real64 T_discharge,        // Compressor discharge temperature Tc' [C]
   14431             :     Real64 Pipe_h_out_ave,     // Average Enthalpy of the refrigerant leaving IUs [kJ/kg]
   14432             :     Real64 IUMaxCondTemp,      // VRV IU condensing temperature, max among all indoor units [C]
   14433             :     Real64 MinOutdoorUnitTe,   // The minimum temperature that OU Te can be at cooling mode (only used for calculating Min capacity)
   14434             :     Real64 Tfs,                // Temperature of the air at the OU evaporator coil surface [C]]
   14435             :     Real64 Pipe_Q,             // Piping Loss Algorithm Parameter: Heat loss [W]
   14436             :     Real64 &OUEvapHeatExtract, // Condenser heat release (cooling mode) [W]
   14437             :     Real64 &CompSpdActual,     // Actual compressor running speed [rps]
   14438             :     Real64 &Ncomp              // Compressor power [W]
   14439             : )
   14440             : {
   14441             : 
   14442             :     // SUBROUTINE INFORMATION:
   14443             :     //       AUTHOR         Xiufeng Pang
   14444             :     //       DATE WRITTEN   Feb 2014
   14445             :     //       MODIFIED       Rongpeng Zhang, Jan 2016
   14446             :     //       RE-ENGINEERED  na
   14447             : 
   14448             :     // PURPOSE OF THIS SUBROUTINE:
   14449             :     // This subroutine simulates the compressor performance at given proportional conditions (heating mode). More specifically, it specifies
   14450             :     // the compressor speed to provide sufficient evaporative capacity, and calculate the power of the compressor running at the specified
   14451             :     // speed. Note that it may be needed to manipulate the operational conditions to further adjust system capacity at low load conditions.
   14452             :     // The low load modification logics are different for cooling mode and heating mode.
   14453             : 
   14454             :     // METHODOLOGY EMPLOYED:
   14455             :     // This is part of the VRF-FluidTCtrl Model.
   14456             : 
   14457             :     using Curve::CurveValue;
   14458             :     using FluidProperties::FindRefrigerant;
   14459             :     using FluidProperties::GetSatEnthalpyRefrig;
   14460             :     using FluidProperties::GetSatPressureRefrig;
   14461             :     using FluidProperties::GetSatTemperatureRefrig;
   14462             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   14463             :     using FluidProperties::GetSupHeatTempRefrig;
   14464             :     using General::SolveRoot;
   14465             : 
   14466             :     int CounterCompSpdTemp;                // Index for the compressor speed level[-]
   14467             :     int CompSpdLB;                         // index for Compressor speed low bound [-]
   14468             :     int CompSpdUB;                         // index for Compressor speed up bound [-]
   14469       20100 :     int MaxIter(500);                      // max iteration number allowed [-]
   14470             :     int NumOfCompSpdInput;                 // Number of compressor speed input by the user [-]
   14471             :     int NumIteCcap;                        // counter for Ccap calculation iterations [-]
   14472             :     int NumTUInList;                       // number of terminal units is list
   14473             :     int RefrigerantIndex;                  // Index of the refrigerant [-]
   14474             :     int SolFla;                            // Solve flag for SolveRoot [-]
   14475             :     int TUListNum;                         // index to TU List
   14476             :     Real64 Cap_Eva0;                       // Evaporating capacity calculated based on physics model, used in the iterations [W]
   14477             :     Real64 Cap_Eva1;                       // Evaporating capacity calculated by curves, used in the iterations [W]
   14478             :     Real64 CapDiff;                        // Evaporating capacity difference used in the iterations [W]
   14479             :     Real64 C_cap_operation;                // Compressor capacity modification algorithm_modified Cap [-]
   14480             :     Real64 SmallLoadTe;                    // Updated suction temperature at small load conditions (Te') [C]
   14481             :     Real64 Modifi_SH;                      // Temperature between compressor inlet temperature and evaporative temperature Te' [C]
   14482             :     Real64 MinOutdoorUnitPe;               // The minimum pressure that Pe can be at cooling mode (only used for calculating Min capacity)
   14483             :     Real64 Modifi_Pe;                      // Compressor power modification algorithm_modified Pe [Pa]
   14484             :     Real64 Pipe_h_comp_in;                 // Piping Loss Algorithm Parameter: Enthalpy after piping loss (compressor inlet) [kJ/kg]
   14485             :     Real64 Q_evap_req;                     // Required evaporative capacity [W]
   14486             :     Real64 RefTSat;                        // Saturated temperature of the refrigerant [C]
   14487             :     Real64 RefPLow;                        // Low Pressure Value for Ps (>0.0) [Pa]
   14488             :     Real64 RefPHigh;                       // High Pressure Value for Ps (max in tables) [Pa]
   14489       20100 :     Real64 Tolerance(0.05);                // Tolerance for condensing temperature calculation [C}
   14490       40200 :     Array1D<Real64> CompEvaporatingPWRSpd; // Array for the compressor power at certain speed [W]
   14491       40200 :     Array1D<Real64> CompEvaporatingCAPSpd; // Array for the evaporating capacity at certain speed [W]
   14492             : 
   14493             :     static constexpr std::string_view RoutineName("VRFOU_CalcCompH");
   14494             : 
   14495             :     // variable initializations
   14496       20100 :     NumOfCompSpdInput = this->CompressorSpeed.size();
   14497       20100 :     CompEvaporatingPWRSpd.dimension(NumOfCompSpdInput);
   14498       20100 :     CompEvaporatingCAPSpd.dimension(NumOfCompSpdInput);
   14499       20100 :     Q_evap_req = TU_load + Pipe_Q - Ncomp;
   14500             : 
   14501       20100 :     TUListNum = this->ZoneTUListPtr;
   14502       20100 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   14503       20100 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   14504       20100 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   14505       20100 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   14506             : 
   14507             :     // Calculate capacity modification factor
   14508       20100 :     MinOutdoorUnitPe = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);
   14509       20100 :     RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(MinOutdoorUnitPe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14510       40200 :     Pipe_h_comp_in = GetSupHeatEnthalpyRefrig(state,
   14511             :                                               this->RefrigerantName,
   14512       20100 :                                               max(RefTSat, T_suction + this->SH),
   14513             :                                               max(min(MinOutdoorUnitPe, RefPHigh), RefPLow),
   14514             :                                               RefrigerantIndex,
   14515             :                                               RoutineName);
   14516       40200 :     C_cap_operation = this->VRFOU_CapModFactor(
   14517       20100 :         state, Pipe_h_comp_in, Pipe_h_out_ave, max(min(MinOutdoorUnitPe, RefPHigh), RefPLow), T_suction + this->SH, T_suction + 8, IUMaxCondTemp - 5);
   14518             : 
   14519             :     // Perform iterations to find the compressor speed that can meet the required heating load, Iteration DoName2
   14520       28696 :     for (CounterCompSpdTemp = 1; CounterCompSpdTemp <= NumOfCompSpdInput; CounterCompSpdTemp++) {
   14521             : 
   14522       28696 :         CompEvaporatingPWRSpd(CounterCompSpdTemp) =
   14523       57392 :             this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   14524       28696 :         CompEvaporatingCAPSpd(CounterCompSpdTemp) =
   14525       57392 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   14526             : 
   14527       28696 :         if ((Q_evap_req * C_cap_operation) <= CompEvaporatingCAPSpd(CounterCompSpdTemp)) {
   14528             :             // Compressor Capacity is greater than the required, finish Iteration DoName2
   14529             : 
   14530       20100 :             if (CounterCompSpdTemp > 1) {
   14531             :                 // Compressor runs at higher speed than min speed
   14532        8596 :                 CompSpdLB = CounterCompSpdTemp - 1;
   14533        8596 :                 CompSpdUB = CounterCompSpdTemp;
   14534             : 
   14535       25788 :                 CompSpdActual = this->CompressorSpeed(CompSpdLB) + (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) /
   14536       17192 :                                                                        (CompEvaporatingCAPSpd(CompSpdUB) - CompEvaporatingCAPSpd(CompSpdLB)) *
   14537        8596 :                                                                        (Q_evap_req * C_cap_operation - CompEvaporatingCAPSpd(CompSpdLB));
   14538        8596 :                 Modifi_SH = this->SH;
   14539       25788 :                 Ncomp = CompEvaporatingPWRSpd(CompSpdLB) + (CompEvaporatingPWRSpd(CompSpdUB) - CompEvaporatingPWRSpd(CompSpdLB)) /
   14540       17192 :                                                                (this->CompressorSpeed(CompSpdUB) - this->CompressorSpeed(CompSpdLB)) *
   14541        8596 :                                                                (CompSpdActual - this->CompressorSpeed(CompSpdLB));
   14542             : 
   14543        8596 :                 break; // EXIT DoName2
   14544             : 
   14545             :             } else {
   14546             :                 // Compressor runs at the min speed
   14547             :                 // Low Load Modifications
   14548             : 
   14549       11504 :                 NumIteCcap = 1;
   14550       11504 :             Label19:;
   14551       11504 :                 Q_evap_req = max(0.0, TU_load + Pipe_Q - Ncomp);
   14552             : 
   14553             :                 // Update Te'( SmallLoadTe ) to meet the required evaporator capacity
   14554       11504 :                 CompSpdActual = this->CompressorSpeed(1);
   14555       11504 :                 Real64 CondHeat = Q_evap_req * C_cap_operation / this->RatedEvapCapacity;
   14556       11504 :                 int CAPFT = this->OUCoolingCAPFT(CounterCompSpdTemp);
   14557             : 
   14558       76012 :                 auto f = [&state, T_discharge, CondHeat, CAPFT](Real64 const T_suc) {
   14559             :                     return CompResidual_FluidTCtrl(state, T_discharge, CondHeat, CAPFT, T_suc);
   14560       87516 :                 };
   14561             : 
   14562       11504 :                 General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, SmallLoadTe, f, MinOutdoorUnitTe, T_suction);
   14563       11504 :                 if (SolFla < 0) SmallLoadTe = MinOutdoorUnitTe;
   14564             : 
   14565       11504 :                 T_suction = SmallLoadTe;
   14566             : 
   14567             :                 // Update SH and Pe to calculate Modification Factor, which is used to update rps to for N_comp calculations
   14568       11504 :                 if (this->C3Te == 0)
   14569           0 :                     Modifi_SH = -(this->C1Te - Tfs + T_suction) / this->C2Te;
   14570             :                 else
   14571       11504 :                     Modifi_SH =
   14572       11504 :                         (-this->C2Te + std::pow((pow_2(this->C2Te) - 4 * (this->C1Te - Tfs + T_suction) * this->C3Te), 0.5)) / (2 * this->C3Te);
   14573             : 
   14574       11504 :                 Modifi_Pe = GetSatPressureRefrig(state, this->RefrigerantName, T_suction, RefrigerantIndex, RoutineName);
   14575             : 
   14576             :                 // Calculate capacity modification factor
   14577       11504 :                 RefTSat =
   14578       11504 :                     GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Modifi_Pe, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   14579       11504 :                 Pipe_h_comp_in = GetSupHeatEnthalpyRefrig(state,
   14580             :                                                           this->RefrigerantName,
   14581             :                                                           max(RefTSat, T_suction + Modifi_SH),
   14582             :                                                           max(min(Modifi_Pe, RefPHigh), RefPLow),
   14583             :                                                           RefrigerantIndex,
   14584             :                                                           RoutineName);
   14585       11504 :                 C_cap_operation = this->VRFOU_CapModFactor(state,
   14586             :                                                            Pipe_h_comp_in,
   14587             :                                                            Pipe_h_out_ave,
   14588             :                                                            max(min(Modifi_Pe, RefPHigh), RefPLow),
   14589             :                                                            T_suction + Modifi_SH,
   14590             :                                                            T_suction + 8,
   14591             :                                                            IUMaxCondTemp - 5);
   14592             : 
   14593       11504 :                 Cap_Eva0 = Q_evap_req * C_cap_operation;
   14594       11504 :                 Cap_Eva1 =
   14595       23008 :                     this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(CounterCompSpdTemp), T_discharge, T_suction);
   14596       11504 :                 CapDiff = std::abs(Cap_Eva1 - Cap_Eva0);
   14597             : 
   14598       11504 :                 if ((CapDiff > (Tolerance * Cap_Eva0)) && (NumIteCcap < 30)) {
   14599           0 :                     NumIteCcap = NumIteCcap + 1;
   14600           0 :                     goto Label19;
   14601             :                 }
   14602       11504 :                 if (CapDiff > (Tolerance * Cap_Eva0)) NumIteCcap = 999;
   14603             : 
   14604       11504 :                 Ncomp = this->RatedCompPower * CurveValue(state, this->OUCoolingPWRFT(CounterCompSpdTemp), T_discharge, T_suction);
   14605             : 
   14606       11504 :                 break; // EXIT DoName2
   14607             : 
   14608             :             } // End: if( CounterCompSpdTemp <= 1 ) Low load modification
   14609             : 
   14610             :         } // End: if( Q_evap_req <= CompEvaporatingCAPSpd( CounterCompSpdTemp ) )
   14611             : 
   14612             :     } // End: Iteration DoName2
   14613             : 
   14614       20100 :     if (CounterCompSpdTemp > NumOfCompSpdInput) {
   14615             :         // Required heating load is beyond the maximum system capacity
   14616           0 :         CompEvaporatingCAPSpd(NumOfCompSpdInput) =
   14617           0 :             this->CoffEvapCap * this->RatedEvapCapacity * CurveValue(state, this->OUCoolingCAPFT(NumOfCompSpdInput), T_discharge, T_suction);
   14618           0 :         OUEvapHeatExtract = CompEvaporatingCAPSpd(NumOfCompSpdInput);
   14619           0 :         CompSpdActual = this->CompressorSpeed(NumOfCompSpdInput);
   14620           0 :         Ncomp = CompEvaporatingPWRSpd(NumOfCompSpdInput);
   14621             :     }
   14622       20100 : }
   14623             : 
   14624           0 : void VRFCondenserEquipment::VRFHR_OU_HR_Mode(EnergyPlusData &state,
   14625             :                                              Real64 const h_IU_evap_in, // enthalpy of IU evaporator at inlet [kJ/kg]
   14626             :                                              Real64 const h_comp_out,   // enthalpy of refrigerant at compressor outlet [kJ/kg]
   14627             :                                              Real64 const Q_c_TU_PL,    // IU evaporator load, including piping loss [W]
   14628             :                                              Real64 const Q_h_TU_PL,    // IU condenser load, including piping loss [W]
   14629             :                                              Real64 const Tdischarge,   // VRF Compressor discharge refrigerant temperature [C]
   14630             :                                              Real64 &Tsuction,          // VRF compressor suction refrigerant temperature [C]
   14631             :                                              Real64 &Te_update,         // updated evaporating temperature, only updated when Tsuction is updated [C]
   14632             :                                              Real64 &h_comp_in,         // enthalpy of refrigerant at compressor inlet [kJ/kg]
   14633             :                                              Real64 &h_IU_PLc_out,  // enthalpy of refrigerant at the outlet of IU evaporator side main pipe [kJ/kg]
   14634             :                                              Real64 &Pipe_Q_c,      // IU evaporator side piping loss [W]
   14635             :                                              Real64 &Q_c_OU,        // OU evaporator load [W]
   14636             :                                              Real64 &Q_h_OU,        // OU condenser load [W]
   14637             :                                              Real64 &m_ref_IU_evap, // mass flow rate of Refrigerant through IU evaporators [kg/s]
   14638             :                                              Real64 &m_ref_OU_evap, // mass flow rate of Refrigerant through OU evaporator [kg/s]
   14639             :                                              Real64 &m_ref_OU_cond, // mass flow rate of Refrigerant through OU condenser [kg/s]
   14640             :                                              Real64 &N_fan_OU,      // outdoor unit fan power [W]
   14641             :                                              Real64 &CompSpdActual, // Actual compressor running speed [rps]
   14642             :                                              Real64 &Ncomp          // compressor power [W]
   14643             : )
   14644             : {
   14645             : 
   14646             :     // SUBROUTINE INFORMATION:
   14647             :     //       AUTHOR         Rongpeng Zhang, LBNL
   14648             :     //       DATE WRITTEN   Jan 2016
   14649             :     //       MODIFIED       na
   14650             :     //
   14651             :     //       RE-ENGINEERED  na
   14652             :     //
   14653             :     // PURPOSE OF THIS SUBROUTINE:
   14654             :     //        Determine the operational mode of the VRF-HR system, given the terminal unit side load conditions.
   14655             :     //        Compressor and OU hex performance are analysed for each mode.
   14656             :     //        A number of OU side operational parameters are also calculated here, including:
   14657             :     //        (1) OU evaporator load Q_c_OU (2) OU condenser load Q_h_OU (3) OU fan energy consumption
   14658             :     //        (4) OU compressor speed and energy consumption
   14659             :     //        Note that Te and Te' may be updated here, and thus IU evaporator side piping loss recalculations.
   14660             :     //        Then a number of operational parameters need to be updated, including:
   14661             :     //        (1) IU evaporating temperature Te (2) OU evaporating temperature Te' etc.
   14662             :     //
   14663             :     // METHODOLOGY EMPLOYED:
   14664             :     //        This is part of the physics based VRF model applicable for Fluid Temperature Control.
   14665             : 
   14666             :     using FluidProperties::FindRefrigerant;
   14667             :     using FluidProperties::GetSatEnthalpyRefrig;
   14668             :     using FluidProperties::GetSatPressureRefrig;
   14669             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   14670             :     using General::SolveRoot;
   14671             : 
   14672           0 :     Real64 constexpr ErrorTol(0.1); // tolerance for RegulaFalsi iterations
   14673           0 :     int constexpr MaxIte(100);      // maximum number of iterations
   14674           0 :     int HRMode(0);                  // HR operational mode [W]
   14675           0 :     int HRMode_sub(0);              // HR operational mode (sub) [W]
   14676             :     int RefrigerantIndex;           // Index of the refrigerant [-]
   14677             :     int SolFla;                     // Flag of RegulaFalsi solver
   14678             :     Real64 C_OU_HexRatio;           // capacity ratio between the OU condenser and OU evaporator [-]
   14679             :     Real64 m_air_rated;             // OU coil air mass flow rate [kg/s]
   14680             :     Real64 m_air_evap;              // OU evaporator air mass flow rate [kg/s]
   14681             :     Real64 m_air_cond;              // OU condenser air mass flow rate [kg/s]
   14682             :     Real64 m_air_evap_rated;        // Rated OU evaporator air mass flow rate [kg/s]
   14683           0 :     Real64 N_fan_OU_evap(0);        // OU evaporator air mass flow rate [kg/s]
   14684           0 :     Real64 N_fan_OU_cond(0);        // OU condenser air mass flow rate [kg/s]
   14685             :     Real64 RhoAir;                  // outdoor air density [kg/m3]
   14686             :     Real64 Q_c_tot;                 // Total evaporator capacity [W]
   14687             :     Real64 Q_h_tot;                 // Total condenser capacity [W]
   14688             :     Real64 Pipe_Q_c_new;            // IU evaporator side piping loss (new), updated because of Te update [W]
   14689             :     Real64 rps1_evap;               // compressor speed satisfying IU cooling load
   14690             :     Real64 rps2_cond;               // compressor speed satisfying IU heating load
   14691             :     Real64 RefPLow;                 // Low Pressure Value for Ps (>0.0) [Pa]
   14692             :     Real64 RefPHigh;                // High Pressure Value for Ps (max in tables) [Pa]
   14693             :     Real64 Tfs;                     // temperature of the air at coil surface [C]
   14694           0 :     Real64 Tolerance(0.05);         // Tolerance for condensing temperature calculation [C}
   14695             :     Real64 Tsuction_new;            // VRF compressor suction refrigerant temperature (new) [C]
   14696             : 
   14697             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14698             :     static constexpr std::string_view RoutineName("VRFHR_OU_Mode");
   14699             : 
   14700             :     // Initialization: operational parameters
   14701           0 :     RhoAir = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
   14702           0 :     m_air_rated = this->OUAirFlowRate * RhoAir;
   14703           0 :     C_OU_HexRatio = this->HROUHexRatio;
   14704             : 
   14705             :     // Initializations: component index
   14706           0 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   14707           0 :     RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;
   14708           0 :     RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue;
   14709             : 
   14710             :     // **Q_OU: HR mode determination
   14711             :     //     HRMode-1. Cooling Only
   14712             :     //     HRMode-2. Cooling Dominant w/o HR Loss
   14713             :     //     HRMode-3. Cooling Dominant w/ HR Loss
   14714             :     //     HRMode-4. Heating Dominant w/ HR Loss
   14715             :     //     HRMode-5. Heating Dominant w/o HR Loss
   14716             :     //     HRMode-6. Heating Only
   14717             :     //     HRMode-7. OU Hex not running
   14718             :     {
   14719             : 
   14720             :         bool FlagMode5;   // true if compressor speed satisfying IU cooling load < that satisfying IU heating load
   14721             :         bool FlagToLower; // true if To-5 is lower than the Tsuction determined by IU part
   14722             :         Real64 temp_Tsuction;
   14723             : 
   14724             :         // Determine FlagToLower
   14725           0 :         if (state.dataEnvrn->OutDryBulbTemp - this->DiffOUTeTo < Tsuction) {
   14726           0 :             temp_Tsuction = state.dataEnvrn->OutDryBulbTemp - this->DiffOUTeTo;
   14727           0 :             FlagToLower = true;
   14728             :         } else {
   14729           0 :             temp_Tsuction = Tsuction;
   14730           0 :             FlagToLower = false;
   14731             :         }
   14732             : 
   14733             :         // Calculate compressor speed satisfying IU loads: rps1_evap & rps2_cond
   14734           0 :         this->VRFOU_CompSpd(state, Q_c_TU_PL, HXOpMode::EvapMode, temp_Tsuction, Tdischarge, h_IU_evap_in, h_IU_PLc_out, rps1_evap);
   14735           0 :         this->VRFOU_CompSpd(state, Q_h_TU_PL, HXOpMode::CondMode, temp_Tsuction, Tdischarge, h_IU_evap_in, h_IU_PLc_out, rps2_cond);
   14736             : 
   14737             :         // Determine FlagMode5
   14738           0 :         if (rps1_evap <= rps2_cond) {
   14739           0 :             FlagMode5 = true;
   14740             :         } else {
   14741           0 :             FlagMode5 = false;
   14742             :         }
   14743             : 
   14744             :         // Determine HR Mode
   14745           0 :         if (FlagMode5) {
   14746           0 :             HRMode = 5;
   14747           0 :             if (FlagToLower)
   14748           0 :                 HRMode_sub = 1;
   14749             :             else
   14750           0 :                 HRMode_sub = 2;
   14751             :         } else {
   14752             : 
   14753           0 :             if (FlagToLower)
   14754           0 :                 HRMode = 3; // Mode 3&4 share the same logics below
   14755             :             else
   14756           0 :                 HRMode = 2;
   14757             :         }
   14758             : 
   14759           0 :         this->VRFOperationSimPath = HRMode * 10 + HRMode_sub;
   14760             :     }
   14761             : 
   14762             :     // **Simulate outdoor unit and compressor performance, including
   14763             :     // (1) compressor spd/power (2) OU hex capacity (3) OU fan flow rate and power
   14764             :     // Tsuction/Te may also need updates
   14765           0 :     if (HRMode == 5 && HRMode_sub == 2) {
   14766             : 
   14767           0 :         CompSpdActual = rps2_cond; // constant in this mode
   14768             :         // Tsuction = Te'_iu < OutDryBulbTemp - 5; constant in this mode
   14769             : 
   14770             :         // compressor: Ncomp & Q_c_tot
   14771           0 :         this->VRFOU_CompCap(state, CompSpdActual, Tsuction, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp);
   14772             : 
   14773             :         // OU hex capacity
   14774           0 :         Q_c_OU = Q_c_tot - Q_c_TU_PL;
   14775           0 :         Q_h_OU = 0;
   14776             : 
   14777             :         // OU fan flow rate and power
   14778           0 :         m_air_evap =
   14779           0 :             this->VRFOU_FlowRate(state, HXOpMode::EvapMode, Tsuction, this->SH, Q_c_OU, state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
   14780           0 :         m_air_evap_rated = m_air_rated;
   14781           0 :         N_fan_OU_evap = this->RatedOUFanPower * m_air_evap / m_air_evap_rated;
   14782           0 :         N_fan_OU_cond = 0;
   14783             : 
   14784           0 :     } else if (HRMode == 5 && HRMode_sub == 1) {
   14785             : 
   14786             :         // local parameters
   14787             :         int Counter_Iter_Ncomp;
   14788           0 :         bool Flag_Iter_Ncomp(true); // Flag to perform iterations
   14789             :         Real64 Ncomp_ini;
   14790             :         Real64 Ncomp_new;
   14791             :         Real64 Q_c_tot_temp;
   14792             :         Real64 Q_c_OU_temp;
   14793             : 
   14794             :         //===**Ncomp Iterations
   14795             : 
   14796             :         // initialization: Ncomp_ini, CompSpdActual
   14797           0 :         Counter_Iter_Ncomp = 1;
   14798           0 :         CompSpdActual = rps2_cond;
   14799           0 :         Tsuction_new = state.dataEnvrn->OutDryBulbTemp - this->DiffOUTeTo;
   14800           0 :         Pipe_Q_c_new = Pipe_Q_c;
   14801             : 
   14802           0 :         this->VRFOU_CompCap(state, CompSpdActual, Tsuction_new, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp_ini);
   14803             : 
   14804           0 :         while (Flag_Iter_Ncomp) {
   14805             : 
   14806           0 :             Q_c_tot_temp = Q_h_TU_PL - Ncomp_ini; // Q_h_OU = 0
   14807           0 :             Q_c_OU_temp = Q_c_tot_temp - Q_c_TU_PL;
   14808             : 
   14809             :             // Tsuction_new updated based on OU evaporator air-side calculations (Tsuction_new < To)
   14810           0 :             m_air_evap_rated = m_air_rated;
   14811           0 :             this->VRFOU_TeTc(state,
   14812             :                              HXOpMode::EvapMode,
   14813             :                              Q_c_OU_temp,
   14814             :                              this->SH,
   14815             :                              m_air_evap_rated,
   14816           0 :                              state.dataEnvrn->OutDryBulbTemp,
   14817           0 :                              state.dataEnvrn->OutHumRat,
   14818           0 :                              state.dataEnvrn->OutBaroPress,
   14819             :                              Tfs,
   14820             :                              Tsuction_new);
   14821           0 :             Tsuction_new = min(Tsuction_new, Tsuction); // should be lower than Tsuction_IU
   14822             : 
   14823             :             // Calculate updated rps corresponding to updated Tsuction_new and Q_c_tot_temp
   14824           0 :             this->VRFOU_CompSpd(state, Q_c_tot_temp, HXOpMode::EvapMode, Tsuction_new, Tdischarge, h_IU_evap_in, h_comp_in, CompSpdActual);
   14825             : 
   14826             :             // Calculate Ncomp_new, using updated CompSpdActual and Tsuction_new
   14827           0 :             this->VRFOU_CompCap(state, CompSpdActual, Tsuction_new, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot_temp, Ncomp_new);
   14828             : 
   14829           0 :             if ((std::abs(Ncomp_new - Ncomp_ini) > (Tolerance * Ncomp_ini)) && (Counter_Iter_Ncomp < 30)) {
   14830           0 :                 Ncomp_ini = 0.5 * Ncomp_ini + 0.5 * Ncomp_new;
   14831           0 :                 Counter_Iter_Ncomp = Counter_Iter_Ncomp + 1;
   14832           0 :                 continue;
   14833             :             }
   14834             : 
   14835           0 :             Flag_Iter_Ncomp = false;
   14836             :         }
   14837             : 
   14838             :         // Ncomp Iterations Update
   14839           0 :         Ncomp = Ncomp_new;
   14840           0 :         Q_c_tot = Q_c_tot_temp;
   14841             : 
   14842           0 :         if (Tsuction_new < Tsuction) {
   14843             :             // Need to update the Tsuction, and thus update Te_update & Pipe_Q_c_new.
   14844             :             // Iteration continues.
   14845             : 
   14846             :             // temporary parameters
   14847             :             Real64 Pe_update;
   14848             :             Real64 Pipe_SH_merged;
   14849             :             Real64 Pipe_DeltP;
   14850             :             Real64 Pipe_h_IU_out;
   14851             : 
   14852             :             // Get an updated Te (Te_update) corresponding to the updated Te' (Tsuction_new). PL_c is re-performed.
   14853           0 :             this->VRFOU_TeModification(state,
   14854             :                                        this->EvaporatingTemp,
   14855             :                                        Tsuction_new,
   14856             :                                        h_IU_evap_in,
   14857           0 :                                        state.dataEnvrn->OutDryBulbTemp,
   14858             :                                        Te_update,
   14859             :                                        Pe_update,
   14860             :                                        m_ref_IU_evap,
   14861             :                                        Pipe_h_IU_out,
   14862             :                                        Pipe_SH_merged);
   14863             : 
   14864             :             // Re-calculate piping loss, update Pipe_Q_c_new
   14865           0 :             this->VRFOU_PipeLossC(state,
   14866             :                                   m_ref_IU_evap,
   14867             :                                   Pe_update,
   14868             :                                   Pipe_h_IU_out,
   14869             :                                   Pipe_SH_merged,
   14870           0 :                                   state.dataEnvrn->OutDryBulbTemp,
   14871             :                                   Pipe_Q_c_new,
   14872             :                                   Pipe_DeltP,
   14873             :                                   h_IU_PLc_out);
   14874             : 
   14875           0 :             Tsuction = Tsuction_new;
   14876           0 :             Pipe_Q_c = Pipe_Q_c_new;
   14877             :         }
   14878             : 
   14879             :         // No need to update the Tsuction.
   14880             : 
   14881             :         //===**Ncomp Iteration Ends (Label200)
   14882             : 
   14883             :         // OU hex capacity
   14884           0 :         Q_c_OU = Q_c_tot - Q_c_TU_PL;
   14885           0 :         Q_h_OU = 0;
   14886             : 
   14887             :         // OU fan power
   14888           0 :         N_fan_OU_evap = this->RatedOUFanPower;
   14889           0 :         N_fan_OU_cond = 0;
   14890             : 
   14891           0 :     } else if (HRMode == 3) { // Mode3 & Mode4 share the same algorithm
   14892             : 
   14893             :         // local parameters
   14894             :         Real64 Ncomp_new;
   14895             :         Real64 Q_c_tot_temp;
   14896             :         Real64 Q_c_OU_temp;
   14897             :         Real64 Tsuction_new;
   14898           0 :         Real64 Tsuction_LB = state.dataEnvrn->OutDryBulbTemp - this->DiffOUTeTo;
   14899           0 :         Real64 Tsuction_HB = Tsuction;
   14900             : 
   14901             :         // compressor speed is fixed in this mode
   14902           0 :         CompSpdActual = rps1_evap; // constant in this mode
   14903           0 :         m_air_evap_rated = m_air_rated * (1 - C_OU_HexRatio);
   14904           0 :         m_air_evap = m_air_evap_rated; // may be updated
   14905             : 
   14906             :         // perform iterations to calculate Te at the given compressor speed and operational conditions
   14907             :         {
   14908             : 
   14909           0 :             auto f = [&state, this, CompSpdActual, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_TU_PL, m_air_evap_rated](Real64 const Te) {
   14910           0 :                 int VRFCond = state.dataHVACVarRefFlow->VRFTU(state.dataHVACVarRefFlow->TerminalUnitList(this->ZoneTUListPtr).ZoneTUPtr(1))
   14911           0 :                                   .VRFSysNum; // VRFCond;
   14912             : 
   14913             :                 Real64 Ncomp_temp;   // compressor power [W]
   14914             :                 Real64 Q_c_tot_temp; // total evaporator load, including piping loss [W]
   14915             :                 Real64 Q_c_OU_temp;  // OU evaporator load, including piping loss [W]
   14916             :                 Real64 Te_new;       // newly calculated OU evaporating temperature
   14917             :                 Real64 Tfs;          // OU evaporator coil surface temperature [C]
   14918             : 
   14919           0 :                 state.dataHVACVarRefFlow->VRF(VRFCond).VRFOU_CompCap(
   14920             :                     state, CompSpdActual, Te, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot_temp, Ncomp_temp);
   14921           0 :                 Q_c_OU_temp = Q_c_tot_temp - Q_c_TU_PL;
   14922             : 
   14923             :                 // Tsuction_new calculated based on OU evaporator air-side calculations (Tsuction_new < To)
   14924           0 :                 state.dataHVACVarRefFlow->VRF(VRFCond).VRFOU_TeTc(state,
   14925             :                                                                   HXOpMode::EvapMode,
   14926             :                                                                   Q_c_OU_temp,
   14927           0 :                                                                   state.dataHVACVarRefFlow->VRF(VRFCond).SH,
   14928             :                                                                   m_air_evap_rated,
   14929           0 :                                                                   state.dataEnvrn->OutDryBulbTemp,
   14930           0 :                                                                   state.dataEnvrn->OutHumRat,
   14931           0 :                                                                   state.dataEnvrn->OutBaroPress,
   14932             :                                                                   Tfs,
   14933             :                                                                   Te_new);
   14934             : 
   14935           0 :                 return Te_new - Te;
   14936           0 :             };
   14937             : 
   14938           0 :             General::SolveRoot(state, ErrorTol, MaxIte, SolFla, Tsuction_new, f, Tsuction_LB, Tsuction_HB);
   14939           0 :             if (SolFla < 0) Tsuction_new = Tsuction_LB;
   14940             : 
   14941             :             // Update Q_c_tot_temp using updated Tsuction_new
   14942           0 :             this->VRFOU_CompCap(state, CompSpdActual, Tsuction_new, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot_temp, Ncomp_new);
   14943           0 :             Q_c_OU_temp = Q_c_tot_temp - Q_c_TU_PL;
   14944             : 
   14945             :             // Iterations_Te Update
   14946           0 :             Ncomp = Ncomp_new;
   14947           0 :             Tsuction = Tsuction_new;
   14948           0 :             Q_c_tot = Q_c_tot_temp;
   14949           0 :             Q_c_OU = Q_c_OU_temp;
   14950             :         }
   14951             : 
   14952           0 :         if (Tsuction >= Tsuction_HB) {
   14953             :             // modify m_air_evap to adjust OU evaporator capacity;
   14954             :             // update Ncomp, Q_c_OU, m_air_evap
   14955             : 
   14956           0 :             Tsuction = Tsuction_HB;
   14957             : 
   14958             :             // Q_c_tot
   14959           0 :             this->VRFOU_CompCap(state, CompSpdActual, Tsuction_new, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp);
   14960           0 :             Q_c_OU = Q_c_tot - Q_c_TU_PL;
   14961             : 
   14962             :             // OU evaporator fan flow rate and power
   14963           0 :             m_air_evap = this->VRFOU_FlowRate(
   14964           0 :                 state, HXOpMode::EvapMode, Tsuction, this->SH, Q_c_OU_temp, state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
   14965             : 
   14966             :         } else {
   14967             :             // Need to update Te_update & Pipe_Q_c_new, corresponding to Tsuction update.
   14968             : 
   14969             :             // temporary parameters
   14970             :             Real64 Pe_update;
   14971             :             Real64 Pipe_SH_merged;
   14972             :             Real64 Pipe_DeltP;
   14973             :             Real64 Pipe_h_IU_out;
   14974             : 
   14975             :             // Get an updated Te (Te_update) corresponding to the updated Te' (Tsuction_new). PL_c is re-performed.
   14976           0 :             this->VRFOU_TeModification(state,
   14977             :                                        this->EvaporatingTemp,
   14978             :                                        Tsuction_new,
   14979             :                                        h_IU_evap_in,
   14980           0 :                                        state.dataEnvrn->OutDryBulbTemp,
   14981             :                                        Te_update,
   14982             :                                        Pe_update,
   14983             :                                        m_ref_IU_evap,
   14984             :                                        Pipe_h_IU_out,
   14985             :                                        Pipe_SH_merged);
   14986             : 
   14987             :             // Re-calculate piping loss, update Pipe_Q_c_new
   14988           0 :             this->VRFOU_PipeLossC(state,
   14989             :                                   m_ref_IU_evap,
   14990             :                                   Pe_update,
   14991             :                                   Pipe_h_IU_out,
   14992             :                                   Pipe_SH_merged,
   14993           0 :                                   state.dataEnvrn->OutDryBulbTemp,
   14994             :                                   Pipe_Q_c_new,
   14995             :                                   Pipe_DeltP,
   14996             :                                   h_IU_PLc_out);
   14997           0 :             Pipe_Q_c = Pipe_Q_c_new;
   14998             :         }
   14999             : 
   15000             :         // Q_h_ou
   15001           0 :         Q_h_tot = Q_c_tot + Ncomp;
   15002           0 :         Q_h_OU = Q_h_tot - Q_h_TU_PL;
   15003             : 
   15004             :         // OU condenser fan flow rate and power
   15005           0 :         m_air_cond = this->VRFOU_FlowRate(
   15006           0 :             state, HXOpMode::CondMode, Tdischarge, this->SC, Q_h_OU, state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
   15007             : 
   15008             :         // OU fan power
   15009           0 :         N_fan_OU_evap = this->RatedOUFanPower * m_air_evap / m_air_rated;
   15010           0 :         N_fan_OU_cond = this->RatedOUFanPower * m_air_cond / m_air_rated;
   15011             : 
   15012           0 :     } else if (HRMode == 2) {
   15013             : 
   15014           0 :         CompSpdActual = rps1_evap; // constant in this mode
   15015             :         // Tsuction = Te'_iu < OutDryBulbTemp - 5; constant in this mode
   15016             : 
   15017             :         // compressor: Ncomp & Q_c_tot
   15018           0 :         this->VRFOU_CompCap(state, CompSpdActual, Tsuction, Tdischarge, h_IU_evap_in, h_comp_in, Q_c_tot, Ncomp);
   15019             : 
   15020             :         // OU hex capacity
   15021           0 :         Q_h_tot = Q_c_tot + Ncomp;
   15022           0 :         Q_h_OU = Q_h_tot - Q_h_TU_PL;
   15023           0 :         Q_c_OU = 0;
   15024             : 
   15025             :         // OU fan flow rate and power
   15026           0 :         m_air_cond = this->VRFOU_FlowRate(
   15027           0 :             state, HXOpMode::CondMode, Tdischarge, this->SC, Q_h_OU, state.dataEnvrn->OutDryBulbTemp, state.dataEnvrn->OutHumRat);
   15028           0 :         N_fan_OU_cond = this->RatedOUFanPower * m_air_cond / m_air_rated;
   15029           0 :         N_fan_OU_evap = 0;
   15030             : 
   15031             :     } else {
   15032           0 :         Ncomp = 0;
   15033           0 :         CompSpdActual = 0;
   15034           0 :         Q_c_OU = 0;
   15035           0 :         Q_h_OU = 0;
   15036           0 :         N_fan_OU_evap = 0;
   15037           0 :         N_fan_OU_cond = 0;
   15038             :     }
   15039             : 
   15040             :     // OU fan power
   15041           0 :     N_fan_OU = N_fan_OU_evap + N_fan_OU_cond;
   15042             : 
   15043             :     // Calculate the m_ref_OU_evap & m_ref_OU_cond, with updated Tsuction
   15044             :     {
   15045             :         Real64 h_OU_evap_in;  // enthalpy of OU evaporator at inlet [kJ/kg]
   15046             :         Real64 h_OU_evap_out; // enthalpy of OU evaporator at outlet [kJ/kg]
   15047             :         Real64 h_OU_cond_in;  // enthalpy of OU condenser at inlet [kJ/kg]
   15048             :         Real64 h_OU_cond_out; // enthalpy of OU condenser at outlet [kJ/kg]
   15049             : 
   15050           0 :         Real64 Psuction = GetSatPressureRefrig(state, this->RefrigerantName, Tsuction, RefrigerantIndex, RoutineName);
   15051             : 
   15052             :         // enthalpy of OU evaporator/condenser inlets and outlets
   15053           0 :         h_OU_evap_in = h_IU_evap_in;
   15054           0 :         h_OU_cond_in = h_comp_out;
   15055           0 :         h_OU_evap_out = GetSupHeatEnthalpyRefrig(
   15056           0 :             state, this->RefrigerantName, Tsuction + this->SH, max(min(Psuction, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   15057           0 :         h_OU_cond_out = GetSatEnthalpyRefrig(state, this->RefrigerantName, Tdischarge - this->SC, 0.0, RefrigerantIndex, RoutineName);
   15058             : 
   15059           0 :         if ((Q_c_OU == 0) || (h_OU_evap_out - h_OU_evap_in) <= 0) {
   15060           0 :             m_ref_OU_evap = 0;
   15061             :         } else {
   15062           0 :             m_ref_OU_evap = Q_c_OU / (h_OU_evap_out - h_OU_evap_in);
   15063             :         }
   15064             : 
   15065           0 :         if ((Q_h_OU == 0) || (h_OU_cond_in - h_OU_cond_out <= 0)) {
   15066           0 :             m_ref_OU_cond = 0;
   15067             :         } else {
   15068           0 :             m_ref_OU_cond = Q_h_OU / (h_OU_cond_in - h_OU_cond_out);
   15069             :         }
   15070             : 
   15071             :         // Calculate the parameters of refrigerant at compressor inlet, which is
   15072             :         // a combination of refrigerant from IU evaporators and OU evaporator
   15073           0 :         if ((m_ref_OU_evap + m_ref_IU_evap) > 0) {
   15074           0 :             h_comp_in = (m_ref_OU_evap * h_OU_evap_out + m_ref_IU_evap * h_IU_PLc_out) / (m_ref_OU_evap + m_ref_IU_evap);
   15075             :         }
   15076             :     }
   15077           0 : }
   15078             : 
   15079      577631 : void VRFCondenserEquipment::VRFOU_PipeLossC(
   15080             :     EnergyPlusData &state,
   15081             :     Real64 const Pipe_m_ref,     // Refrigerant mass flow rate [kg/s]
   15082             :     Real64 const Pevap,          // VRF evaporating pressure [Pa]
   15083             :     Real64 const Pipe_h_IU_out,  // Enthalpy of IU at outlet [kJ/kg]
   15084             :     Real64 const Pipe_SH_merged, // Average super heating degrees after the indoor units [C]
   15085             :     Real64 const OutdoorDryBulb, // outdoor dry-bulb temperature (C)
   15086             :     Real64 &Pipe_Q,              // unit part load ratio
   15087             :     Real64 &Pipe_DeltP,          // ratio of compressor ON airflow to AVERAGE airflow over timestep
   15088             :     Real64 &Pipe_h_comp_in       // Piping Loss Algorithm Parameter: Enthalpy after piping loss (compressor inlet) [kJ/kg]
   15089             : )
   15090             : {
   15091             : 
   15092             :     // SUBROUTINE INFORMATION:
   15093             :     //       AUTHOR         Rongpeng Zhang
   15094             :     //       DATE WRITTEN   Nov 2015
   15095             :     //       MODIFIED       na
   15096             :     //       RE-ENGINEERED  na
   15097             : 
   15098             :     // PURPOSE OF THIS SUBROUTINE:
   15099             :     // Determine the piping loss of the refrigerant, including both the heat loss and pressure drop.
   15100             :     // This happens at VRF cooling mode, within the Main Pipe connecting Outdoor Unit to Indoor Units.
   15101             : 
   15102             :     // METHODOLOGY EMPLOYED:
   15103             :     // Use a physics based piping loss model.
   15104             : 
   15105             :     using FluidProperties::FindRefrigerant;
   15106             :     using FluidProperties::GetSupHeatDensityRefrig;
   15107             :     using General::SolveRoot;
   15108             : 
   15109             :     int TUListNum;        // index to TU List
   15110             :     int TUIndex;          // Index to terminal unit
   15111             :     int CoilIndex;        // index to coil in terminal unit
   15112             :     int NumTUInList;      // number of terminal units is list
   15113             :     int NumIUActivated;   // number of the used indoor units [-]
   15114             :     int RefrigerantIndex; // Index of the refrigerant [-]
   15115             : 
   15116             :     Real64 Pipe_v_ref;            // Piping Loss Algorithm Parameter: Refrigerant velocity [m/s]
   15117             :     Real64 Pipe_T_room;           // Piping Loss Algorithm Parameter: Average Room Temperature [C]
   15118             :     Real64 Pipe_Num_Re;           // Piping Loss Algorithm Parameter: refrigerant Re Number [-]
   15119             :     Real64 Pipe_Num_Pr;           // Piping Loss Algorithm Parameter: refrigerant Pr Number [-]
   15120             :     Real64 Pipe_Num_Nu;           // Piping Loss Algorithm Parameter: refrigerant Nu Number [-]
   15121             :     Real64 Pipe_Num_St;           // Piping Loss Algorithm Parameter: refrigerant St Number [-]
   15122             :     Real64 Pipe_Coe_k1;           // Piping Loss Algorithm Parameter: coefficients [-]
   15123             :     Real64 Pipe_Coe_k2;           // Piping Loss Algorithm Parameter: coefficients [-]
   15124             :     Real64 Pipe_Coe_k3;           // Piping Loss Algorithm Parameter: coefficients [-]
   15125             :     Real64 Pipe_cp_ref;           // Piping Loss Algorithm_[kJ/kg/K]
   15126             :     Real64 Pipe_conductivity_ref; // Piping Loss Algorithm: refrigerant conductivity [W/m/K]
   15127             :     Real64 Pipe_viscosity_ref;    // Piping Loss Algorithm Parameter: refrigerant viscosity [MuPa*s]
   15128             :     Real64 Ref_Coe_v1;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15129             :     Real64 Ref_Coe_v2;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15130             :     Real64 Ref_Coe_v3;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15131             :     Real64 RefPipInsH;            // Heat transfer coefficient for calculating piping loss [W/m2K]
   15132             : 
   15133             :     static constexpr std::string_view RoutineName("VRFOU_PipeLossC");
   15134             : 
   15135      577631 :     TUListNum = this->ZoneTUListPtr;
   15136      577631 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   15137      577631 :     Pipe_conductivity_ref = this->RefPipInsCon;
   15138             : 
   15139      577631 :     RefPipInsH = 9.3;
   15140      577631 :     Pipe_cp_ref = 1.6;
   15141             : 
   15142             :     // Refrigerant data
   15143      577631 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   15144      577631 :     Real64 RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;   // Low Pressure Value for Ps (>0.0)
   15145      577631 :     Real64 RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue; // High Pressure Value for Ps (max in tables)
   15146             : 
   15147             :     // Calculate Pipe_T_room
   15148      577631 :     Pipe_T_room = 0;
   15149      577631 :     NumIUActivated = 0;
   15150     3465786 :     for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
   15151     2888155 :         TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   15152     2888155 :         CoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).CoolCoilIndex;
   15153             : 
   15154     2888155 :         if (state.dataDXCoils->DXCoil(CoilIndex).TotalCoolingEnergyRate > 0.0) {
   15155     2757958 :             Pipe_T_room = Pipe_T_room + state.dataDXCoils->DXCoil(CoilIndex).InletAirTemp;
   15156     2757958 :             NumIUActivated = NumIUActivated + 1;
   15157             :         }
   15158             :     }
   15159      577631 :     if (NumIUActivated > 0)
   15160      577631 :         Pipe_T_room = Pipe_T_room / NumIUActivated;
   15161             :     else
   15162           0 :         Pipe_T_room = 24;
   15163             : 
   15164      577631 :     if (Pipe_m_ref > 0) {
   15165      577631 :         if (this->RefPipDiaSuc <= 0) this->RefPipDiaSuc = 0.025;
   15166             : 
   15167      577631 :         Ref_Coe_v1 = Pevap / 1000000 / 4.926;
   15168      577631 :         Ref_Coe_v2 = Pipe_h_IU_out / 383.5510343;
   15169      577631 :         Ref_Coe_v3 = (this->EvaporatingTemp + Pipe_SH_merged + 273.15) / 344.39;
   15170             : 
   15171     1732893 :         Pipe_viscosity_ref = 4.302 * Ref_Coe_v1 + 0.81622 * pow_2(Ref_Coe_v1) - 120.98 * Ref_Coe_v2 + 139.17 * pow_2(Ref_Coe_v2) +
   15172     1732893 :                              118.76 * Ref_Coe_v3 + 81.04 * pow_2(Ref_Coe_v3) + 5.7858 * Ref_Coe_v1 * Ref_Coe_v2 - 8.3817 * Ref_Coe_v1 * Ref_Coe_v3 -
   15173      577631 :                              218.48 * Ref_Coe_v2 * Ref_Coe_v3 + 21.58;
   15174      577631 :         if (Pipe_viscosity_ref <= 0) Pipe_viscosity_ref = 16.26; // default superheated vapor viscosity data (MuPa*s) at T=353.15 K, P=2MPa
   15175             : 
   15176     1155262 :         Pipe_v_ref = Pipe_m_ref / (DataGlobalConstants::Pi * pow_2(this->RefPipDiaSuc) * 0.25) /
   15177     1155262 :                      GetSupHeatDensityRefrig(state,
   15178             :                                              this->RefrigerantName,
   15179      577631 :                                              this->EvaporatingTemp + Pipe_SH_merged,
   15180             :                                              max(min(Pevap, RefPHigh), RefPLow),
   15181             :                                              RefrigerantIndex,
   15182             :                                              RoutineName);
   15183      577631 :         Pipe_Num_Re = Pipe_m_ref / (DataGlobalConstants::Pi * pow_2(this->RefPipDiaSuc) * 0.25) * this->RefPipDiaSuc / Pipe_viscosity_ref * 1000000;
   15184      577631 :         Pipe_Num_Pr = Pipe_viscosity_ref * Pipe_cp_ref * 0.001 / Pipe_conductivity_ref;
   15185      577631 :         Pipe_Num_Nu = 0.023 * std::pow(Pipe_Num_Re, 0.8) * std::pow(Pipe_Num_Pr, 0.3);
   15186      577631 :         Pipe_Num_St = Pipe_Num_Nu / Pipe_Num_Re / Pipe_Num_Pr;
   15187             : 
   15188      577631 :         Pipe_DeltP = max(0.0,
   15189     1155262 :                          8 * Pipe_Num_St * std::pow(Pipe_Num_Pr, 0.6667) * this->RefPipEquLen / this->RefPipDiaSuc *
   15190     1155262 :                                  GetSupHeatDensityRefrig(state,
   15191             :                                                          this->RefrigerantName,
   15192      577631 :                                                          this->EvaporatingTemp + Pipe_SH_merged,
   15193             :                                                          max(min(Pevap, RefPHigh), RefPLow),
   15194             :                                                          RefrigerantIndex,
   15195      577631 :                                                          RoutineName) *
   15196     1155262 :                                  pow_2(Pipe_v_ref) / 2 -
   15197     1155262 :                              this->RefPipHei *
   15198     1155262 :                                  GetSupHeatDensityRefrig(state,
   15199             :                                                          this->RefrigerantName,
   15200      577631 :                                                          this->EvaporatingTemp + Pipe_SH_merged,
   15201             :                                                          max(min(Pevap, RefPHigh), RefPLow),
   15202             :                                                          RefrigerantIndex,
   15203      577631 :                                                          RoutineName) *
   15204             :                                  9.80665);
   15205             : 
   15206      577631 :         Pipe_Coe_k1 = Pipe_Num_Nu * Pipe_viscosity_ref;
   15207      577631 :         Pipe_Coe_k3 = RefPipInsH * (this->RefPipDiaSuc + 2 * this->RefPipInsThi);
   15208      577631 :         if (this->RefPipInsThi >= 0.0) {
   15209      577631 :             Pipe_Coe_k2 = 2 * this->RefPipInsCon / std::log(1.0 + 2 * this->RefPipInsThi / this->RefPipDiaSuc);
   15210             :         } else {
   15211           0 :             Pipe_Coe_k2 = 9999.9;
   15212             :         }
   15213             : 
   15214      577631 :         Pipe_Q = max(0.0,
   15215      577631 :                      (DataGlobalConstants::Pi * this->RefPipLen) * (OutdoorDryBulb / 2 + Pipe_T_room / 2 - this->EvaporatingTemp - Pipe_SH_merged) /
   15216      577631 :                          (1 / Pipe_Coe_k1 + 1 / Pipe_Coe_k2 + 1 / Pipe_Coe_k3));
   15217             : 
   15218      577631 :         Pipe_h_comp_in = Pipe_h_IU_out + Pipe_Q / Pipe_m_ref;
   15219             : 
   15220             :     } else {
   15221           0 :         Pipe_DeltP = 0;
   15222           0 :         Pipe_Q = 0;
   15223           0 :         Pipe_h_comp_in = Pipe_h_IU_out;
   15224             :     }
   15225      577631 : }
   15226             : 
   15227       15709 : void VRFCondenserEquipment::VRFOU_PipeLossH(
   15228             :     EnergyPlusData &state,
   15229             :     Real64 const Pipe_m_ref,     // Refrigerant mass flow rate [kg/s]
   15230             :     Real64 const Pcond,          // VRF condensing pressure [Pa]
   15231             :     Real64 const Pipe_h_IU_in,   // Enthalpy of IU at outlet [kJ/kg]
   15232             :     Real64 const OutdoorDryBulb, // outdoor dry-bulb temperature (C)
   15233             :     Real64 &Pipe_Q,              // unit part load ratio
   15234             :     Real64 &Pipe_DeltP,          // ratio of compressor ON airflow to AVERAGE airflow over timestep
   15235             :     Real64 &Pipe_h_comp_out      // Piping Loss Algorithm Parameter: Enthalpy before piping loss (compressor outlet) [kJ/kg]
   15236             : ) const
   15237             : {
   15238             : 
   15239             :     // SUBROUTINE INFORMATION:
   15240             :     //       AUTHOR         Rongpeng Zhang
   15241             :     //       DATE WRITTEN   Nov 2015
   15242             :     //       MODIFIED       na
   15243             :     //       RE-ENGINEERED  na
   15244             : 
   15245             :     // PURPOSE OF THIS SUBROUTINE:
   15246             :     // Determine the piping loss of the refrigerant, including both the heat loss and pressure drop.
   15247             :     // This happens at VRF cooling mode, within the Main Pipe connecting Outdoor Unit to Indoor Units.
   15248             : 
   15249             :     // METHODOLOGY EMPLOYED:
   15250             :     // Use a physics based piping loss model.
   15251             : 
   15252             :     using FluidProperties::FindRefrigerant;
   15253             :     using FluidProperties::GetSatTemperatureRefrig;
   15254             :     using FluidProperties::GetSupHeatDensityRefrig;
   15255             :     using FluidProperties::GetSupHeatEnthalpyRefrig;
   15256             :     using FluidProperties::GetSupHeatTempRefrig;
   15257             :     using General::SolveRoot;
   15258             : 
   15259             :     int TUListNum;        // index to TU List
   15260             :     int TUIndex;          // Index to terminal unit
   15261             :     int CoilIndex;        // index to coil in terminal unit
   15262             :     int NumTUInList;      // number of terminal units is list
   15263             :     int NumIUActivated;   // number of the used indoor units [-]
   15264             :     int RefrigerantIndex; // Index of the refrigerant [-]
   15265             : 
   15266             :     Real64 Pipe_v_ref;            // Piping Loss Algorithm Parameter: Refrigerant velocity [m/s]
   15267             :     Real64 Pipe_T_room;           // Piping Loss Algorithm Parameter: Average Room Temperature [C]
   15268             :     Real64 Pipe_T_IU_in;          // Piping Loss Algorithm Parameter: Average Refrigerant Temperature [C]
   15269             :     Real64 Pipe_Num_Re;           // Piping Loss Algorithm Parameter: refrigerant Re Number [-]
   15270             :     Real64 Pipe_Num_Pr;           // Piping Loss Algorithm Parameter: refrigerant Pr Number [-]
   15271             :     Real64 Pipe_Num_Nu;           // Piping Loss Algorithm Parameter: refrigerant Nu Number [-]
   15272             :     Real64 Pipe_Num_St;           // Piping Loss Algorithm Parameter: refrigerant St Number [-]
   15273             :     Real64 Pipe_Coe_k1;           // Piping Loss Algorithm Parameter: coefficients [-]
   15274             :     Real64 Pipe_Coe_k2;           // Piping Loss Algorithm Parameter: coefficients [-]
   15275             :     Real64 Pipe_Coe_k3;           // Piping Loss Algorithm Parameter: coefficients [-]
   15276             :     Real64 Pipe_cp_ref;           // Piping Loss Algorithm_[kJ/kg/K]
   15277             :     Real64 Pipe_conductivity_ref; // Piping Loss Algorithm: refrigerant conductivity [W/m/K]
   15278             :     Real64 Pipe_viscosity_ref;    // Piping Loss Algorithm Parameter: refrigerant viscosity [MuPa*s]
   15279             :     Real64 Ref_Coe_v1;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15280             :     Real64 Ref_Coe_v2;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15281             :     Real64 Ref_Coe_v3;            // Piping Loss Algorithm Parameter: coefficient to calculate Pipe_viscosity_ref [-]
   15282             :     Real64 RefPipInsH;            // Heat transfer coefficient for calculating piping loss [W/m2K]
   15283             : 
   15284             :     static constexpr std::string_view RoutineName("VRFOU_PipeLossH");
   15285             : 
   15286       15709 :     TUListNum = this->ZoneTUListPtr;
   15287       15709 :     NumTUInList = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).NumTUInList;
   15288       15709 :     Pipe_conductivity_ref = this->RefPipInsCon;
   15289             : 
   15290       15709 :     RefPipInsH = 9.3;
   15291       15709 :     Pipe_cp_ref = 1.6;
   15292             : 
   15293             :     // Refrigerant data
   15294       15709 :     RefrigerantIndex = FindRefrigerant(state, this->RefrigerantName);
   15295       15709 :     Real64 RefTHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighTempValue; // High Temperature Value for Ps (max in tables)
   15296       15709 :     Real64 RefPLow = state.dataFluidProps->RefrigData(RefrigerantIndex).PsLowPresValue;   // Low Pressure Value for Ps (>0.0)
   15297       15709 :     Real64 RefPHigh = state.dataFluidProps->RefrigData(RefrigerantIndex).PsHighPresValue; // High Pressure Value for Ps (max in tables)
   15298       15709 :     Real64 RefTSat = GetSatTemperatureRefrig(state, this->RefrigerantName, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   15299             : 
   15300             :     // Perform iteration to calculate Pipe_T_IU_in, given P and h
   15301       31418 :     Pipe_T_IU_in = GetSupHeatTempRefrig(state,
   15302             :                                         this->RefrigerantName,
   15303             :                                         max(min(Pcond, RefPHigh), RefPLow),
   15304             :                                         Pipe_h_IU_in,
   15305       15709 :                                         max(this->IUCondensingTemp, RefTSat),
   15306       15709 :                                         min(this->IUCondensingTemp + 50, RefTHigh),
   15307             :                                         RefrigerantIndex,
   15308             :                                         RoutineName);
   15309       15709 :     Pipe_T_IU_in = min(RefTHigh, Pipe_T_IU_in);
   15310             : 
   15311             :     // Calculate average room temperature
   15312       15709 :     Pipe_T_room = 0;
   15313       15709 :     NumIUActivated = 0;
   15314       94254 :     for (int NumTU = 1; NumTU <= NumTUInList; ++NumTU) {
   15315       78545 :         TUIndex = state.dataHVACVarRefFlow->TerminalUnitList(TUListNum).ZoneTUPtr(NumTU);
   15316       78545 :         CoilIndex = state.dataHVACVarRefFlow->VRFTU(TUIndex).HeatCoilIndex;
   15317             : 
   15318       78545 :         if (state.dataDXCoils->DXCoil(CoilIndex).TotalHeatingEnergyRate > 0.0) {
   15319       78178 :             Pipe_T_room = Pipe_T_room + state.dataDXCoils->DXCoil(CoilIndex).InletAirTemp;
   15320       78178 :             NumIUActivated = NumIUActivated + 1;
   15321             :         }
   15322             :     }
   15323       15709 :     if (NumIUActivated > 0)
   15324       15709 :         Pipe_T_room = Pipe_T_room / NumIUActivated;
   15325             :     else
   15326           0 :         Pipe_T_room = 18;
   15327             : 
   15328             :     // Calculate piping loss
   15329       15709 :     if (Pipe_m_ref > 0) {
   15330       15709 :         Ref_Coe_v1 = Pcond / 1000000 / 4.926;
   15331       15709 :         Ref_Coe_v2 = Pipe_h_IU_in / 383.5510343;
   15332       15709 :         Ref_Coe_v3 = (Pipe_T_IU_in + 273.15) / 344.39;
   15333       47127 :         Pipe_viscosity_ref = 4.302 * Ref_Coe_v1 + 0.81622 * pow_2(Ref_Coe_v1) - 120.98 * Ref_Coe_v2 + 139.17 * pow_2(Ref_Coe_v2) +
   15334       47127 :                              118.76 * Ref_Coe_v3 + 81.04 * pow_2(Ref_Coe_v3) + 5.7858 * Ref_Coe_v1 * Ref_Coe_v2 - 8.3817 * Ref_Coe_v1 * Ref_Coe_v3 -
   15335       15709 :                              218.48 * Ref_Coe_v2 * Ref_Coe_v3 + 21.58;
   15336       15709 :         if (Pipe_viscosity_ref <= 0) Pipe_viscosity_ref = 16.26; // default superheated vapor viscosity data (MuPa*s) at T=353.15 K, P=2MPa
   15337             : 
   15338       15709 :         Pipe_v_ref =
   15339       15709 :             Pipe_m_ref / (DataGlobalConstants::Pi * pow_2(this->RefPipDiaDis) * 0.25) /
   15340       15709 :             GetSupHeatDensityRefrig(state, this->RefrigerantName, Pipe_T_IU_in, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName);
   15341       15709 :         Pipe_Num_Re = Pipe_m_ref / (DataGlobalConstants::Pi * pow_2(this->RefPipDiaDis) * 0.25) * this->RefPipDiaDis / Pipe_viscosity_ref * 1000000;
   15342       15709 :         Pipe_Num_Pr = Pipe_viscosity_ref * Pipe_cp_ref * 0.001 / Pipe_conductivity_ref;
   15343       15709 :         Pipe_Num_Nu = 0.023 * std::pow(Pipe_Num_Re, 0.8) * std::pow(Pipe_Num_Pr, 0.4);
   15344       15709 :         Pipe_Num_St = Pipe_Num_Nu / Pipe_Num_Re / Pipe_Num_Pr;
   15345             : 
   15346       15709 :         Pipe_Coe_k1 = Pipe_Num_Nu * Pipe_viscosity_ref;
   15347       15709 :         Pipe_Coe_k2 = this->RefPipInsCon * (this->RefPipDiaDis + this->RefPipInsThi) / this->RefPipInsThi;
   15348       15709 :         Pipe_Coe_k3 = RefPipInsH * (this->RefPipDiaDis + 2 * this->RefPipInsThi);
   15349             : 
   15350       15709 :         Pipe_Q = max(0.0,
   15351       15709 :                      (DataGlobalConstants::Pi * this->RefPipLen) * (Pipe_T_IU_in - OutdoorDryBulb / 2 - Pipe_T_room / 2) /
   15352       15709 :                          (1 / Pipe_Coe_k1 + 1 / Pipe_Coe_k2 + 1 / Pipe_Coe_k3)); // [W]
   15353       15709 :         Pipe_DeltP = max(0.0,
   15354       31418 :                          8 * Pipe_Num_St * std::pow(Pipe_Num_Pr, 0.6667) * this->RefPipEquLen / this->RefPipDiaDis *
   15355       15709 :                                  GetSupHeatDensityRefrig(
   15356       15709 :                                      state, this->RefrigerantName, Pipe_T_IU_in, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) *
   15357       31418 :                                  pow_2(Pipe_v_ref) / 2 -
   15358       31418 :                              this->RefPipHei *
   15359       15709 :                                  GetSupHeatDensityRefrig(
   15360       15709 :                                      state, this->RefrigerantName, Pipe_T_IU_in, max(min(Pcond, RefPHigh), RefPLow), RefrigerantIndex, RoutineName) *
   15361             :                                  9.80665);
   15362             : 
   15363       15709 :         Pipe_h_comp_out = Pipe_h_IU_in + Pipe_Q / Pipe_m_ref;
   15364             : 
   15365             :     } else {
   15366           0 :         Pipe_DeltP = 0;
   15367           0 :         Pipe_Q = 0;
   15368           0 :         Pipe_h_comp_out = Pipe_h_IU_in;
   15369             :     }
   15370       15709 : }
   15371           0 : void VRFCondenserEquipment::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   15372             : {
   15373           0 : }
   15374           1 : void VRFCondenserEquipment::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   15375             : {
   15376           1 : }
   15377             : 
   15378      356336 : void VRFTerminalUnitEquipment::CalcVRFSuppHeatingCoil(EnergyPlusData &state,
   15379             :                                                       int const VRFTUNum,            // index of vrf terminal unit
   15380             :                                                       bool const FirstHVACIteration, // True when first HVAC iteration
   15381             :                                                       Real64 const PartLoadRatio,    // coil operating part-load ratio
   15382             :                                                       Real64 &SuppCoilLoad           // supp heating coil load max (W)
   15383             : )
   15384             : {
   15385             : 
   15386             :     // PURPOSE OF THIS SUBROUTINE:
   15387             :     // Manages VRF terminal unit supplemental heaters simulation.
   15388             : 
   15389             :     // Locals
   15390             :     // subroutine parameter definitions:
   15391      356336 :     int constexpr MaxIte(500);   // Maximum number of iterations for solver
   15392      356336 :     Real64 constexpr Acc(1.e-3); // Accuracy of solver result
   15393             : 
   15394             :     // local variable declaration:
   15395             :     int SolFla;              // Flag of solver, num iterations if >0, else error index
   15396             :     Real64 SuppHeatCoilLoad; // load passed to supplemental heating coil (W)
   15397             :     Real64 QActual;          // actual coil output (W)
   15398             :     Real64 PartLoadFrac;     // temporary PLR variable
   15399             : 
   15400      356336 :     QActual = 0.0;
   15401      356336 :     PartLoadFrac = 0.0;
   15402      356336 :     SuppHeatCoilLoad = 0.0;
   15403             : 
   15404             :     // simulate gas, electric, hot water, and steam heating coils
   15405      356336 :     if (state.dataEnvrn->OutDryBulbTemp <= this->MaxOATSuppHeatingCoil) {
   15406       98920 :         SuppHeatCoilLoad = SuppCoilLoad;
   15407             :     } else {
   15408      257416 :         SuppHeatCoilLoad = 0.0;
   15409             :     }
   15410             : 
   15411      356336 :     switch (this->SuppHeatCoilType_Num) {
   15412      217003 :     case DataHVACGlobals::Coil_HeatingGasOrOtherFuel:
   15413             :     case DataHVACGlobals::Coil_HeatingElectric: {
   15414      217003 :         HeatingCoils::SimulateHeatingCoilComponents(
   15415             :             state, this->SuppHeatCoilName, FirstHVACIteration, SuppHeatCoilLoad, this->SuppHeatCoilIndex, QActual, true, this->OpMode, PartLoadRatio);
   15416      217003 :         SuppHeatCoilLoad = QActual;
   15417      217003 :     } break;
   15418       70956 :     case DataHVACGlobals::Coil_HeatingWater: {
   15419       70956 :         if (SuppHeatCoilLoad > DataHVACGlobals::SmallLoad) {
   15420             :             //     see if HW coil has enough capacity to meet the load
   15421        1350 :             Real64 mdot = this->SuppHeatCoilFluidMaxFlow;
   15422        1350 :             state.dataLoopNodes->Node(this->SuppHeatCoilFluidInletNode).MassFlowRate = mdot;
   15423             :             //     simulate hot water coil to find the full flow operating capacity
   15424        1350 :             WaterCoils::SimulateWaterCoilComponents(
   15425             :                 state, this->SuppHeatCoilName, FirstHVACIteration, this->SuppHeatCoilIndex, QActual, this->OpMode, PartLoadRatio);
   15426        1350 :             if (QActual > SuppHeatCoilLoad) {
   15427      183515 :                 auto f = [&state, VRFTUNum, FirstHVACIteration, SuppHeatCoilLoad](Real64 const PartLoadFrac) {
   15428       10795 :                     Real64 QActual = 0.0; // actual heating load deleivered [W]
   15429       21590 :                     Real64 mdot = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow * PartLoadFrac;
   15430       43180 :                     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode).MassFlowRate = mdot;
   15431       64770 :                     WaterCoils::SimulateWaterCoilComponents(state,
   15432       21590 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
   15433             :                                                             FirstHVACIteration,
   15434       21590 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex,
   15435             :                                                             QActual,
   15436       21590 :                                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode,
   15437             :                                                             PartLoadFrac);
   15438       10795 :                     if (std::abs(SuppHeatCoilLoad) == 0.0) {
   15439           0 :                         return (QActual - SuppHeatCoilLoad) / 100.0;
   15440             :                     } else {
   15441       32385 :                         return (QActual - SuppHeatCoilLoad) / SuppHeatCoilLoad;
   15442             :                     }
   15443        1350 :                 };
   15444        1350 :                 General::SolveRoot(state, Acc, MaxIte, SolFla, PartLoadFrac, f, 0.0, 1.0);
   15445        1350 :                 this->SuppHeatPartLoadRatio = PartLoadFrac;
   15446             :             } else {
   15447           0 :                 this->SuppHeatPartLoadRatio = 1.0;
   15448           0 :                 SuppHeatCoilLoad = QActual;
   15449             :             }
   15450             :         } else {
   15451       69606 :             this->SuppHeatPartLoadRatio = 0.0;
   15452       69606 :             Real64 mdot = 0.0;
   15453       69606 :             SuppHeatCoilLoad = 0.0;
   15454       69606 :             PlantUtilities::SetComponentFlowRate(
   15455             :                 state, mdot, this->SuppHeatCoilFluidInletNode, this->SuppHeatCoilFluidOutletNode, this->SuppHeatCoilPlantLoc);
   15456             :         }
   15457             :         //     simulate water heating coil
   15458       70956 :         WaterCoils::SimulateWaterCoilComponents(
   15459             :             state, this->SuppHeatCoilName, FirstHVACIteration, this->SuppHeatCoilIndex, SuppHeatCoilLoad, this->OpMode, this->SuppHeatPartLoadRatio);
   15460       70956 :     } break;
   15461       68377 :     case DataHVACGlobals::Coil_HeatingSteam: {
   15462             :         //     simulate steam heating coil
   15463       68377 :         Real64 mdot = this->SuppHeatCoilFluidMaxFlow * PartLoadRatio;
   15464       68377 :         state.dataLoopNodes->Node(this->SuppHeatCoilFluidInletNode).MassFlowRate = mdot;
   15465       68377 :         SteamCoils::SimulateSteamCoilComponents(
   15466             :             state, this->SuppHeatCoilName, FirstHVACIteration, this->SuppHeatCoilIndex, SuppHeatCoilLoad, QActual, this->OpMode, PartLoadRatio);
   15467       68377 :         SuppHeatCoilLoad = QActual;
   15468       68377 :     } break;
   15469           0 :     default:
   15470           0 :         break;
   15471             :     }
   15472             : 
   15473      356336 :     SuppCoilLoad = SuppHeatCoilLoad;
   15474      356336 : }
   15475             : 
   15476           0 : Real64 VRFTerminalUnitEquipment::HotWaterHeatingCoilResidual(EnergyPlusData &state,
   15477             :                                                              Real64 const PartLoadFrac,     // water heating coil part-load ratio
   15478             :                                                              std::vector<Real64> const &Par // par(1) = index to current VRF terminal unit
   15479             : )
   15480             : {
   15481             : 
   15482             :     // PURPOSE OF THIS FUNCTION:
   15483             :     // Calculates supplemental hot water heating coils load fraction residual [(QActual - Load)/Load]
   15484             :     // hot water Coil output depends on the part load ratio which is being varied to drive the load
   15485             :     // fraction residual to zero.
   15486             : 
   15487             :     // METHODOLOGY EMPLOYED:
   15488             :     // runs Coil:Heating:Water component object to get the actual heating load deleivered [W] at a
   15489             :     // given part load ratio and calculates the residual as defined above
   15490             : 
   15491             :     // Return value
   15492             :     Real64 Residuum; // Residual to be minimized to zero
   15493             : 
   15494             :     // local variables declaration:
   15495           0 :     int VRFTUNum = int(Par[1]);       // index to current terminal unit simulated
   15496           0 :     bool FirstHVACIteration = Par[2]; // 0 flag if it first HVAC iteration, or else 1
   15497           0 :     Real64 SuppHeatCoilLoad = Par[3]; // supplemental heating coil load to be met [W]
   15498           0 :     Real64 QActual = 0.0;             // actual heating load deleivered [W]
   15499             : 
   15500             :     // Real64 mdot = min(state.dataLoopNodes->Node(VRFTU(VRFTUNum).SuppHeatCoilFluidOutletNode).MassFlowRateMaxAvail,
   15501             :     //                  VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow * PartLoadFrac);
   15502             : 
   15503           0 :     Real64 mdot = state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidMaxFlow * PartLoadFrac;
   15504           0 :     state.dataLoopNodes->Node(state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilFluidInletNode).MassFlowRate = mdot;
   15505           0 :     WaterCoils::SimulateWaterCoilComponents(state,
   15506           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilName,
   15507             :                                             FirstHVACIteration,
   15508           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).SuppHeatCoilIndex,
   15509             :                                             QActual,
   15510           0 :                                             state.dataHVACVarRefFlow->VRFTU(VRFTUNum).OpMode,
   15511             :                                             PartLoadFrac);
   15512             : 
   15513           0 :     if (std::abs(SuppHeatCoilLoad) == 0.0) {
   15514           0 :         Residuum = (QActual - SuppHeatCoilLoad) / 100.0;
   15515             :     } else {
   15516           0 :         Residuum = (QActual - SuppHeatCoilLoad) / SuppHeatCoilLoad;
   15517             :     }
   15518             : 
   15519           0 :     return Residuum;
   15520             : }
   15521             : 
   15522           0 : Real64 VRFTerminalUnitEquipment::HeatingCoilCapacityLimit(
   15523             :     EnergyPlusData &state,
   15524             :     Real64 const HeatCoilAirInletNode, // supplemental heating coil air inlet node
   15525             :     Real64 const HeatCoilMaxSATAllowed // supplemental heating coil maximum supply air temperature allowed [C]
   15526             : )
   15527             : {
   15528             :     // PURPOSE OF THIS FUNCTION:
   15529             :     // Calculates supplemental heating coils maximum heating capacity allowed based on the maximum
   15530             :     // supply air temperature limit specified.
   15531             : 
   15532             :     // METHODOLOGY EMPLOYED:
   15533             :     // ( m_dot_air * Cp_air_avg * DeltaT_air_across_heating_coil) [W]
   15534             : 
   15535             :     // Return value
   15536             :     Real64 HeatCoilCapacityAllowed; // heating coil maximum capacity that can be deleivered at current time [W]
   15537             : 
   15538           0 :     Real64 MDotAir = state.dataLoopNodes->Node(HeatCoilAirInletNode).MassFlowRate;
   15539           0 :     Real64 CpAirIn = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(HeatCoilAirInletNode).HumRat);
   15540           0 :     Real64 HCDeltaT = max(0.0, HeatCoilMaxSATAllowed - state.dataLoopNodes->Node(HeatCoilAirInletNode).Temp);
   15541           0 :     HeatCoilCapacityAllowed = MDotAir * CpAirIn * HCDeltaT;
   15542             : 
   15543           0 :     return HeatCoilCapacityAllowed;
   15544             : }
   15545             : 
   15546        2313 : } // namespace EnergyPlus::HVACVariableRefrigerantFlow

Generated by: LCOV version 1.13