LCOV - code coverage report
Current view: top level - EnergyPlus - ChillerReformulatedEIR.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 61.3 % 1524 934
Test Date: 2025-06-02 07:23:51 Functions: 94.7 % 19 18

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // C++ Headers
      49              : #include <cassert>
      50              : #include <cmath>
      51              : #include <string>
      52              : 
      53              : // ObjexxFCL Headers
      54              : #include <ObjexxFCL/Fmath.hh>
      55              : 
      56              : // EnergyPlus Headers
      57              : #include <EnergyPlus/Autosizing/Base.hh>
      58              : #include <EnergyPlus/BranchNodeConnections.hh>
      59              : #include <EnergyPlus/ChillerReformulatedEIR.hh>
      60              : #include <EnergyPlus/CurveManager.hh>
      61              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      62              : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      63              : #include <EnergyPlus/DataEnvironment.hh>
      64              : #include <EnergyPlus/DataHVACGlobals.hh>
      65              : #include <EnergyPlus/DataIPShortCuts.hh>
      66              : #include <EnergyPlus/DataLoopNode.hh>
      67              : #include <EnergyPlus/DataSizing.hh>
      68              : #include <EnergyPlus/EMSManager.hh>
      69              : #include <EnergyPlus/FaultsManager.hh>
      70              : #include <EnergyPlus/FluidProperties.hh>
      71              : #include <EnergyPlus/General.hh>
      72              : #include <EnergyPlus/GlobalNames.hh>
      73              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      74              : #include <EnergyPlus/NodeInputManager.hh>
      75              : #include <EnergyPlus/OutputProcessor.hh>
      76              : #include <EnergyPlus/OutputReportPredefined.hh>
      77              : #include <EnergyPlus/Plant/DataPlant.hh>
      78              : #include <EnergyPlus/Plant/PlantLocation.hh>
      79              : #include <EnergyPlus/PlantUtilities.hh>
      80              : #include <EnergyPlus/Psychrometrics.hh>
      81              : #include <EnergyPlus/ScheduleManager.hh>
      82              : #include <EnergyPlus/StandardRatings.hh>
      83              : #include <EnergyPlus/UtilityRoutines.hh>
      84              : 
      85              : namespace EnergyPlus::ChillerReformulatedEIR {
      86              : 
      87              : // The Electric EIR and Reformulated EIR chiller models are similar.
      88              : // They only differ in the independent variable used to evaluate the performance curves.
      89              : // Since the Reformulated EIR chiller uses outlet condenser water temperature as an
      90              : // independent variable, iteration is required to converge on a solution.
      91              : 
      92              : // MODULE INFORMATION:
      93              : //       AUTHOR         Lixing Gu
      94              : //       DATE WRITTEN   August 2006
      95              : 
      96              : //       MODIFIED
      97              : //       Aug.  2014, Rongpeng Zhang, added An additional part-load performance curve type
      98              : 
      99              : // PURPOSE OF THIS MODULE:
     100              : //  This module simulates the performance of the electric vapor compression
     101              : //  chiller using a reformulated model based on the DOE-2 EIR chiller.
     102              : 
     103              : // METHODOLOGY EMPLOYED:
     104              : //  Once the PlantLoopManager determines that the Reformulated EIR chiller
     105              : //  is available to meet a loop cooling demand, it calls SimReformulatedEIRChiller
     106              : //  which in turn calls the reformulated EIR chiller model.
     107              : //  The ReformulatedEIR chiller model is based on polynomial fits of chiller
     108              : //  performance data.
     109              : 
     110              : // REFERENCES:
     111              : // 1. Hydeman, M., P. Sreedharan, N. Webb, and S. Blanc. 2002. "Development and Testing of a Reformulated
     112              : //    Regression-Based Electric Chiller Model". ASHRAE Transactions, HI-02-18-2, Vol 108, Part 2, pp. 1118-1127.
     113              : 
     114           86 : ReformulatedEIRChillerSpecs *ReformulatedEIRChillerSpecs::factory(EnergyPlusData &state, std::string const &objectName)
     115              : {
     116              :     // Process the input data if it hasn't been done already
     117           86 :     if (state.dataChillerReformulatedEIR->GetInputREIR) {
     118           24 :         GetElecReformEIRChillerInput(state);
     119           24 :         state.dataChillerReformulatedEIR->GetInputREIR = false;
     120              :     }
     121              :     // Now look for this particular object in the list
     122           86 :     auto thisObj = std::find_if(state.dataChillerReformulatedEIR->ElecReformEIRChiller.begin(),
     123           86 :                                 state.dataChillerReformulatedEIR->ElecReformEIRChiller.end(),
     124          124 :                                 [&objectName](const ReformulatedEIRChillerSpecs &myObj) { return myObj.Name == objectName; });
     125           86 :     if (thisObj != state.dataChillerReformulatedEIR->ElecReformEIRChiller.end()) {
     126           86 :         return thisObj;
     127              :     }
     128              :     // If we didn't find it, fatal
     129              :     ShowFatalError(state, format("LocalReformulatedElectEIRChillerFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
     130              :     // Shut up the compiler
     131              :     return nullptr; // LCOV_EXCL_LINE
     132              : }
     133              : 
     134          478 : void ReformulatedEIRChillerSpecs::getDesignCapacities(
     135              :     [[maybe_unused]] EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad)
     136              : {
     137          478 :     if (calledFromLocation.loopNum == this->CWPlantLoc.loopNum) {
     138          239 :         MinLoad = this->RefCap * this->MinPartLoadRat;
     139          239 :         MaxLoad = this->RefCap * this->MaxPartLoadRat;
     140          239 :         OptLoad = this->RefCap * this->OptPartLoadRat;
     141              :     } else {
     142          239 :         MinLoad = 0.0;
     143          239 :         MaxLoad = 0.0;
     144          239 :         OptLoad = 0.0;
     145              :     }
     146          478 : }
     147              : 
     148          478 : void ReformulatedEIRChillerSpecs::getDesignTemperatures(Real64 &TempDesCondIn, Real64 &TempDesEvapOut)
     149              : {
     150          478 :     TempDesEvapOut = this->TempRefEvapOut;
     151          478 :     TempDesCondIn = this->TempRefCondIn;
     152          478 : }
     153              : 
     154           86 : void ReformulatedEIRChillerSpecs::getSizingFactor(Real64 &sizFac)
     155              : {
     156           86 :     sizFac = this->SizFac;
     157           86 : }
     158              : 
     159          478 : void ReformulatedEIRChillerSpecs::onInitLoopEquip(EnergyPlusData &state, const PlantLocation &calledFromLocation)
     160              : {
     161          478 :     bool runFlag = true;
     162          478 :     Real64 myLoad = 0.0;
     163          478 :     this->initialize(state, runFlag, myLoad);
     164              : 
     165          478 :     if (calledFromLocation.loopNum == this->CWPlantLoc.loopNum) {
     166          239 :         this->size(state);
     167              :     }
     168          478 : }
     169              : 
     170      5326024 : void ReformulatedEIRChillerSpecs::simulate(
     171              :     EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag)
     172              : {
     173              :     // SUBROUTINE INFORMATION:
     174              :     //       AUTHOR         Lixing Gu
     175              :     //       DATE WRITTEN   July 2004
     176              : 
     177              :     // PURPOSE OF THIS SUBROUTINE:
     178              :     //  This is the reformulated EIR chiller model driver. It gets the input for the
     179              :     //  models, initializes simulation variables, calls the appropriate model and sets
     180              :     //  up reporting variables.
     181              : 
     182      5326024 :     if (calledFromLocation.loopNum == this->CWPlantLoc.loopNum) {
     183      2717561 :         this->initialize(state, RunFlag, CurLoad);
     184      2717561 :         this->control(state, CurLoad, RunFlag, FirstHVACIteration);
     185      2717561 :         this->update(state, CurLoad, RunFlag);
     186      2608463 :     } else if (calledFromLocation.loopNum == this->CDPlantLoc.loopNum) {
     187      2608463 :         DataPlant::LoopSideLocation LoopSide = this->CDPlantLoc.loopSideNum;
     188      2608463 :         PlantUtilities::UpdateChillerComponentCondenserSide(state,
     189      2608463 :                                                             calledFromLocation.loopNum,
     190              :                                                             LoopSide,
     191              :                                                             DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
     192              :                                                             this->CondInletNodeNum,
     193              :                                                             this->CondOutletNodeNum,
     194              :                                                             this->QCondenser,
     195              :                                                             this->CondInletTemp,
     196              :                                                             this->CondOutletTemp,
     197              :                                                             this->CondMassFlowRate,
     198              :                                                             FirstHVACIteration);
     199            0 :     } else if (calledFromLocation.loopNum == this->HRPlantLoc.loopNum) {
     200            0 :         PlantUtilities::UpdateComponentHeatRecoverySide(state,
     201              :                                                         this->HRPlantLoc.loopNum,
     202              :                                                         this->HRPlantLoc.loopSideNum,
     203              :                                                         DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
     204              :                                                         this->HeatRecInletNodeNum,
     205              :                                                         this->HeatRecOutletNodeNum,
     206              :                                                         this->QHeatRecovery,
     207              :                                                         this->HeatRecInletTemp,
     208              :                                                         this->HeatRecOutletTemp,
     209              :                                                         this->HeatRecMassFlow,
     210              :                                                         FirstHVACIteration);
     211              :     }
     212      5326024 : }
     213              : 
     214           24 : void GetElecReformEIRChillerInput(EnergyPlusData &state)
     215              : {
     216              :     // SUBROUTINE INFORMATION:
     217              :     //       AUTHOR:          Lixing Gu, FSEC
     218              :     //       DATE WRITTEN:    July 2006
     219              :     //       MODIFIED
     220              :     //       Aug.  2014, Rongpeng Zhang, added an additional part-load performance curve type
     221              : 
     222              :     // PURPOSE OF THIS SUBROUTINE:
     223              :     //  This routine will get the input required by the Reformulated Electric EIR Chiller model
     224              : 
     225              :     static constexpr std::string_view RoutineName("GetElecReformEIRChillerInput: "); // include trailing blank space
     226              :     static constexpr std::string_view routineName = "GetElecReformEIRChillerInput";
     227              : 
     228           24 :     bool ErrorsFound(false); // True when input errors found
     229              : 
     230           24 :     auto &s_ipsc = state.dataIPShortCut;
     231              : 
     232           24 :     s_ipsc->cCurrentModuleObject = "Chiller:Electric:ReformulatedEIR";
     233           24 :     int NumElecReformEIRChillers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject);
     234              : 
     235           24 :     if (NumElecReformEIRChillers <= 0) {
     236            0 :         ShowSevereError(state, format("No {} equipment specified in input file", s_ipsc->cCurrentModuleObject));
     237            0 :         ErrorsFound = true;
     238              :     }
     239              : 
     240              :     // ALLOCATE ARRAYS
     241           24 :     state.dataChillerReformulatedEIR->ElecReformEIRChiller.allocate(NumElecReformEIRChillers);
     242              : 
     243              :     // Load arrays with reformulated electric EIR chiller data
     244           67 :     for (int EIRChillerNum = 1; EIRChillerNum <= NumElecReformEIRChillers; ++EIRChillerNum) {
     245           43 :         int NumAlphas = 0; // Number of elements in the alpha array
     246           43 :         int NumNums = 0;   // Number of elements in the numeric array
     247           43 :         int IOStat = 0;    // IO Status when calling get input subroutine
     248           86 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     249           43 :                                                                  s_ipsc->cCurrentModuleObject,
     250              :                                                                  EIRChillerNum,
     251           43 :                                                                  s_ipsc->cAlphaArgs,
     252              :                                                                  NumAlphas,
     253           43 :                                                                  s_ipsc->rNumericArgs,
     254              :                                                                  NumNums,
     255              :                                                                  IOStat,
     256           43 :                                                                  s_ipsc->lNumericFieldBlanks,
     257           43 :                                                                  s_ipsc->lAlphaFieldBlanks,
     258           43 :                                                                  s_ipsc->cAlphaFieldNames,
     259           43 :                                                                  s_ipsc->cNumericFieldNames);
     260              : 
     261           43 :         ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)};
     262              : 
     263              :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
     264           43 :         GlobalNames::VerifyUniqueChillerName(
     265           86 :             state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name");
     266              : 
     267           43 :         auto &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(EIRChillerNum);
     268           43 :         thisChiller.Name = s_ipsc->cAlphaArgs(1);
     269              :         // Performance curves
     270           43 :         thisChiller.ChillerCapFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(2));
     271           43 :         thisChiller.CAPFTName = s_ipsc->cAlphaArgs(2);
     272           43 :         if (thisChiller.ChillerCapFTIndex == 0) {
     273            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     274            0 :             ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)));
     275            0 :             ErrorsFound = true;
     276              :         }
     277              : 
     278           43 :         thisChiller.ChillerEIRFTIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(3));
     279           43 :         thisChiller.EIRFTName = s_ipsc->cAlphaArgs(3);
     280           43 :         if (thisChiller.ChillerEIRFTIndex == 0) {
     281            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     282            0 :             ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)));
     283            0 :             ErrorsFound = true;
     284              :         }
     285              : 
     286              :         // The default type of part-load curve is: LeavingCondenserWaterTemperature
     287           43 :         std::string PartLoadCurveType; // Part load curve type
     288           43 :         if (s_ipsc->lAlphaFieldBlanks(4)) {
     289           37 :             PartLoadCurveType = "LeavingCondenserWaterTemperature";
     290              :         } else {
     291            6 :             PartLoadCurveType = s_ipsc->cAlphaArgs(4);
     292              :         }
     293              : 
     294           43 :         thisChiller.EIRFPLRName = s_ipsc->cAlphaArgs(5);
     295           43 :         thisChiller.ChillerEIRFPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(5));
     296           43 :         if (thisChiller.ChillerEIRFPLRIndex == 0) {
     297            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     298            0 :             ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)));
     299            0 :             ErrorsFound = true;
     300              :         }
     301              : 
     302              :         // Check the type of part-load curves implemented: 1_LeavingCondenserWaterTemperature, 2_Lift
     303           85 :         if (Util::SameString(PartLoadCurveType, "LeavingCondenserWaterTemperature") &&
     304           42 :             state.dataCurveManager->curves(thisChiller.ChillerEIRFPLRIndex)->numDims == 2) {
     305           42 :             thisChiller.PartLoadCurveType = PLR::LeavingCondenserWaterTemperature;
     306            1 :         } else if (Util::SameString(PartLoadCurveType, "Lift") && state.dataCurveManager->curves(thisChiller.ChillerEIRFPLRIndex)->numDims == 3) {
     307            1 :             thisChiller.PartLoadCurveType = PLR::Lift;
     308              :         } else {
     309            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     310            0 :             ShowContinueError(state,
     311            0 :                               format("Invalid {}={} for {}={}",
     312            0 :                                      s_ipsc->cAlphaFieldNames(5),
     313            0 :                                      s_ipsc->cAlphaArgs(5),
     314            0 :                                      s_ipsc->cAlphaFieldNames(4),
     315            0 :                                      s_ipsc->cAlphaArgs(4)));
     316            0 :             ErrorsFound = true;
     317              :         }
     318              : 
     319              :         // Chilled water inlet/outlet node names are necessary
     320           43 :         if (s_ipsc->lAlphaFieldBlanks(6)) {
     321            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     322            0 :             ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(6)));
     323            0 :             ErrorsFound = true;
     324              :         }
     325           43 :         if (s_ipsc->lAlphaFieldBlanks(7)) {
     326            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     327            0 :             ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(7)));
     328            0 :             ErrorsFound = true;
     329              :         }
     330              : 
     331           43 :         thisChiller.EvapInletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     332           43 :                                                                            s_ipsc->cAlphaArgs(6),
     333              :                                                                            ErrorsFound,
     334              :                                                                            DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     335           43 :                                                                            s_ipsc->cAlphaArgs(1),
     336              :                                                                            DataLoopNode::NodeFluidType::Water,
     337              :                                                                            DataLoopNode::ConnectionType::Inlet,
     338              :                                                                            NodeInputManager::CompFluidStream::Primary,
     339              :                                                                            DataLoopNode::ObjectIsNotParent);
     340           86 :         thisChiller.EvapOutletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     341           43 :                                                                             s_ipsc->cAlphaArgs(7),
     342              :                                                                             ErrorsFound,
     343              :                                                                             DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     344           43 :                                                                             s_ipsc->cAlphaArgs(1),
     345              :                                                                             DataLoopNode::NodeFluidType::Water,
     346              :                                                                             DataLoopNode::ConnectionType::Outlet,
     347              :                                                                             NodeInputManager::CompFluidStream::Primary,
     348              :                                                                             DataLoopNode::ObjectIsNotParent);
     349           86 :         BranchNodeConnections::TestCompSet(
     350           43 :             state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(6), s_ipsc->cAlphaArgs(7), "Chilled Water Nodes");
     351              : 
     352           43 :         thisChiller.CondenserType = DataPlant::CondenserType::WaterCooled;
     353              : 
     354              :         // Condenser inlet/outlet node names are necessary
     355           43 :         if (s_ipsc->lAlphaFieldBlanks(8)) {
     356            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     357            0 :             ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(8)));
     358            0 :             ErrorsFound = true;
     359              :         }
     360           43 :         if (s_ipsc->lAlphaFieldBlanks(9)) {
     361            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     362            0 :             ShowContinueError(state, format("{} is blank.", s_ipsc->cAlphaFieldNames(9)));
     363            0 :             ErrorsFound = true;
     364              :         }
     365              : 
     366           43 :         thisChiller.CondInletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     367           43 :                                                                            s_ipsc->cAlphaArgs(8),
     368              :                                                                            ErrorsFound,
     369              :                                                                            DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     370           43 :                                                                            s_ipsc->cAlphaArgs(1),
     371              :                                                                            DataLoopNode::NodeFluidType::Water,
     372              :                                                                            DataLoopNode::ConnectionType::Inlet,
     373              :                                                                            NodeInputManager::CompFluidStream::Secondary,
     374              :                                                                            DataLoopNode::ObjectIsNotParent);
     375           86 :         thisChiller.CondOutletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     376           43 :                                                                             s_ipsc->cAlphaArgs(9),
     377              :                                                                             ErrorsFound,
     378              :                                                                             DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     379           43 :                                                                             s_ipsc->cAlphaArgs(1),
     380              :                                                                             DataLoopNode::NodeFluidType::Water,
     381              :                                                                             DataLoopNode::ConnectionType::Outlet,
     382              :                                                                             NodeInputManager::CompFluidStream::Secondary,
     383              :                                                                             DataLoopNode::ObjectIsNotParent);
     384              : 
     385           86 :         BranchNodeConnections::TestCompSet(
     386           43 :             state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(8), s_ipsc->cAlphaArgs(9), "Condenser Water Nodes");
     387              : 
     388              :         {
     389           43 :             thisChiller.FlowMode = static_cast<DataPlant::FlowMode>(getEnumValue(DataPlant::FlowModeNamesUC, s_ipsc->cAlphaArgs(10)));
     390           43 :             if (thisChiller.FlowMode == DataPlant::FlowMode::Invalid) {
     391            0 :                 ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     392            0 :                 ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(10), s_ipsc->cAlphaArgs(10)));
     393            0 :                 ShowContinueError(state, "Available choices are ConstantFlow, NotModulated, or LeavingSetpointModulated");
     394            0 :                 ShowContinueError(state, "Flow mode NotModulated is assumed and the simulation continues.");
     395            0 :                 thisChiller.FlowMode = DataPlant::FlowMode::NotModulated;
     396              :             };
     397              :         }
     398              : 
     399              :         //   Chiller rated performance data
     400           43 :         thisChiller.RefCap = s_ipsc->rNumericArgs(1);
     401           43 :         if (thisChiller.RefCap == DataSizing::AutoSize) {
     402           38 :             thisChiller.RefCapWasAutoSized = true;
     403              :         }
     404           43 :         if (s_ipsc->rNumericArgs(1) == 0.0) {
     405            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     406            0 :             ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1)));
     407            0 :             ErrorsFound = true;
     408              :         }
     409              : 
     410           43 :         thisChiller.RefCOP = s_ipsc->rNumericArgs(2);
     411           43 :         if (s_ipsc->rNumericArgs(2) == 0.0) {
     412            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     413            0 :             ShowContinueError(state, format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2)));
     414            0 :             ErrorsFound = true;
     415              :         }
     416              : 
     417           43 :         thisChiller.TempRefEvapOut = s_ipsc->rNumericArgs(3);
     418           43 :         thisChiller.TempRefCondOut = s_ipsc->rNumericArgs(4);
     419           43 :         if (thisChiller.TempRefEvapOut >= thisChiller.TempRefCondOut) {
     420            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     421            0 :             ShowContinueError(state,
     422            0 :                               format("{} [{:.2R}] >= {} [{:.2R}]",
     423            0 :                                      s_ipsc->cNumericFieldNames(3),
     424            0 :                                      s_ipsc->rNumericArgs(3),
     425            0 :                                      s_ipsc->cNumericFieldNames(4),
     426            0 :                                      s_ipsc->rNumericArgs(4)));
     427            0 :             ShowContinueError(state, "Reference Leaving Chilled Water Temperature must be less than Reference Leaving Condenser Water Temperature ");
     428            0 :             ErrorsFound = true;
     429              :         }
     430              : 
     431           43 :         thisChiller.EvapVolFlowRate = s_ipsc->rNumericArgs(5);
     432           43 :         if (thisChiller.EvapVolFlowRate == DataSizing::AutoSize) {
     433           38 :             thisChiller.EvapVolFlowRateWasAutoSized = true;
     434              :         }
     435           43 :         thisChiller.CondVolFlowRate = s_ipsc->rNumericArgs(6);
     436           43 :         if (thisChiller.CondVolFlowRate == DataSizing::AutoSize) {
     437           42 :             thisChiller.CondVolFlowRateWasAutoSized = true;
     438              :         }
     439           43 :         thisChiller.MinPartLoadRat = s_ipsc->rNumericArgs(7);
     440           43 :         thisChiller.MaxPartLoadRat = s_ipsc->rNumericArgs(8);
     441           43 :         thisChiller.OptPartLoadRat = s_ipsc->rNumericArgs(9);
     442           43 :         thisChiller.MinUnloadRat = s_ipsc->rNumericArgs(10);
     443           43 :         thisChiller.SizFac = s_ipsc->rNumericArgs(14);
     444           43 :         if (thisChiller.SizFac <= 0.0) {
     445            0 :             thisChiller.SizFac = 1.0;
     446              :         }
     447              : 
     448           43 :         if (thisChiller.MinPartLoadRat > thisChiller.MaxPartLoadRat) {
     449            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     450            0 :             ShowContinueError(state,
     451            0 :                               format("{} [{:.3R}] > {} [{:.3R}]",
     452            0 :                                      s_ipsc->cNumericFieldNames(7),
     453            0 :                                      s_ipsc->rNumericArgs(7),
     454            0 :                                      s_ipsc->cNumericFieldNames(8),
     455            0 :                                      s_ipsc->rNumericArgs(8)));
     456            0 :             ShowContinueError(state, "Minimum part load ratio must be less than or equal to the maximum part load ratio ");
     457            0 :             ErrorsFound = true;
     458              :         }
     459              : 
     460           43 :         if (thisChiller.MinUnloadRat < thisChiller.MinPartLoadRat || thisChiller.MinUnloadRat > thisChiller.MaxPartLoadRat) {
     461            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     462            0 :             ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(10), s_ipsc->rNumericArgs(10)));
     463            0 :             ShowContinueError(state,
     464            0 :                               format("{} must be greater than or equal to the {}", s_ipsc->cNumericFieldNames(10), s_ipsc->cNumericFieldNames(7)));
     465            0 :             ShowContinueError(state,
     466            0 :                               format("{} must be less than or equal to the {}", s_ipsc->cNumericFieldNames(10), s_ipsc->cNumericFieldNames(8)));
     467            0 :             ErrorsFound = true;
     468              :         }
     469              : 
     470           43 :         if (thisChiller.OptPartLoadRat < thisChiller.MinPartLoadRat || thisChiller.OptPartLoadRat > thisChiller.MaxPartLoadRat) {
     471            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     472            0 :             ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(9), s_ipsc->rNumericArgs(9)));
     473            0 :             ShowContinueError(state,
     474            0 :                               format("{} must be greater than or equal to the {}", s_ipsc->cNumericFieldNames(9), s_ipsc->cNumericFieldNames(7)));
     475            0 :             ShowContinueError(state, format("{} must be less than or equal to the {}", s_ipsc->cNumericFieldNames(9), s_ipsc->cNumericFieldNames(8)));
     476            0 :             ErrorsFound = true;
     477              :         }
     478              : 
     479           43 :         thisChiller.CompPowerToCondenserFrac = s_ipsc->rNumericArgs(11);
     480              : 
     481           43 :         if (thisChiller.CompPowerToCondenserFrac < 0.0 || thisChiller.CompPowerToCondenserFrac > 1.0) {
     482            0 :             ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     483            0 :             ShowContinueError(state, format("{} = {:.3R}", s_ipsc->cNumericFieldNames(11), s_ipsc->rNumericArgs(11)));
     484            0 :             ShowContinueError(state, format("{} must be greater than or equal to zero", s_ipsc->cNumericFieldNames(11)));
     485            0 :             ShowContinueError(state, format("{} must be less than or equal to one", s_ipsc->cNumericFieldNames(11)));
     486            0 :             ErrorsFound = true;
     487              :         }
     488              : 
     489           43 :         thisChiller.TempLowLimitEvapOut = s_ipsc->rNumericArgs(12);
     490              : 
     491              :         // These are the optional heat recovery inputs
     492           43 :         thisChiller.DesignHeatRecVolFlowRate = s_ipsc->rNumericArgs(13);
     493           43 :         if (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize) {
     494            0 :             thisChiller.DesignHeatRecVolFlowRateWasAutoSized = true;
     495              :         }
     496           43 :         if ((thisChiller.DesignHeatRecVolFlowRate > 0.0) || (thisChiller.DesignHeatRecVolFlowRate == DataSizing::AutoSize)) {
     497            0 :             thisChiller.HeatRecActive = true;
     498            0 :             thisChiller.HeatRecInletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     499            0 :                                                                                   s_ipsc->cAlphaArgs(11),
     500              :                                                                                   ErrorsFound,
     501              :                                                                                   DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     502            0 :                                                                                   s_ipsc->cAlphaArgs(1),
     503              :                                                                                   DataLoopNode::NodeFluidType::Water,
     504              :                                                                                   DataLoopNode::ConnectionType::Inlet,
     505              :                                                                                   NodeInputManager::CompFluidStream::Tertiary,
     506              :                                                                                   DataLoopNode::ObjectIsNotParent);
     507            0 :             if (thisChiller.HeatRecInletNodeNum == 0) {
     508            0 :                 ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     509            0 :                 ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(11), s_ipsc->cAlphaArgs(11)));
     510            0 :                 ErrorsFound = true;
     511              :             }
     512            0 :             thisChiller.HeatRecOutletNodeNum = NodeInputManager::GetOnlySingleNode(state,
     513            0 :                                                                                    s_ipsc->cAlphaArgs(12),
     514              :                                                                                    ErrorsFound,
     515              :                                                                                    DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     516            0 :                                                                                    s_ipsc->cAlphaArgs(1),
     517              :                                                                                    DataLoopNode::NodeFluidType::Water,
     518              :                                                                                    DataLoopNode::ConnectionType::Outlet,
     519              :                                                                                    NodeInputManager::CompFluidStream::Tertiary,
     520              :                                                                                    DataLoopNode::ObjectIsNotParent);
     521            0 :             if (thisChiller.HeatRecOutletNodeNum == 0) {
     522            0 :                 ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     523            0 :                 ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(12), s_ipsc->cAlphaArgs(12)));
     524            0 :                 ErrorsFound = true;
     525              :             }
     526              : 
     527            0 :             BranchNodeConnections::TestCompSet(
     528            0 :                 state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(11), s_ipsc->cAlphaArgs(12), "Heat Recovery Nodes");
     529              : 
     530            0 :             if (thisChiller.DesignHeatRecVolFlowRate > 0.0) {
     531            0 :                 PlantUtilities::RegisterPlantCompDesignFlow(state, thisChiller.HeatRecInletNodeNum, thisChiller.DesignHeatRecVolFlowRate);
     532              :             }
     533            0 :             if (NumNums > 14) {
     534            0 :                 if (!s_ipsc->lNumericFieldBlanks(15)) {
     535            0 :                     thisChiller.HeatRecCapacityFraction = s_ipsc->rNumericArgs(15);
     536              :                 } else {
     537            0 :                     thisChiller.HeatRecCapacityFraction = 1.0;
     538              :                 }
     539              :             } else {
     540            0 :                 thisChiller.HeatRecCapacityFraction = 1.0;
     541              :             }
     542              : 
     543            0 :             if (NumAlphas <= 12 || s_ipsc->lAlphaFieldBlanks(13)) {
     544            0 :                 thisChiller.heatRecInletLimitSched = nullptr; // Ok for this to be nullptr
     545            0 :             } else if ((thisChiller.heatRecInletLimitSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(13))) == nullptr) {
     546            0 :                 ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(13), s_ipsc->cAlphaArgs(13));
     547            0 :                 ErrorsFound = true;
     548              :             }
     549              : 
     550            0 :             if (NumAlphas > 13) {
     551            0 :                 if (!s_ipsc->lAlphaFieldBlanks(14)) {
     552            0 :                     thisChiller.HeatRecSetPointNodeNum =
     553            0 :                         NodeInputManager::GetOnlySingleNode(state,
     554            0 :                                                             s_ipsc->cAlphaArgs(14),
     555              :                                                             ErrorsFound,
     556              :                                                             DataLoopNode::ConnectionObjectType::ChillerElectricReformulatedEIR,
     557            0 :                                                             s_ipsc->cAlphaArgs(1),
     558              :                                                             DataLoopNode::NodeFluidType::Water,
     559              :                                                             DataLoopNode::ConnectionType::Sensor,
     560              :                                                             NodeInputManager::CompFluidStream::Primary,
     561              :                                                             DataLoopNode::ObjectIsNotParent);
     562              :                 } else {
     563            0 :                     thisChiller.HeatRecSetPointNodeNum = 0;
     564              :                 }
     565              :             } else {
     566            0 :                 thisChiller.HeatRecSetPointNodeNum = 0;
     567              :             }
     568              : 
     569              :         } else {
     570           43 :             thisChiller.HeatRecActive = false;
     571           43 :             thisChiller.DesignHeatRecMassFlowRate = 0.0;
     572           43 :             thisChiller.HeatRecInletNodeNum = 0;
     573           43 :             thisChiller.HeatRecOutletNodeNum = 0;
     574           43 :             if ((!s_ipsc->lAlphaFieldBlanks(11)) || (!s_ipsc->lAlphaFieldBlanks(12))) {
     575            0 :                 ShowWarningError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     576            0 :                 ShowWarningError(state, "Since Reference Heat Reclaim Volume Flow Rate = 0.0, heat recovery is inactive.");
     577            0 :                 ShowContinueError(state, "However, node names were specified for heat recovery inlet or outlet nodes.");
     578              :             }
     579              :         }
     580              : 
     581           43 :         if (NumAlphas > 14) {
     582            1 :             thisChiller.EndUseSubcategory = s_ipsc->cAlphaArgs(15);
     583              :         } else {
     584           42 :             thisChiller.EndUseSubcategory = "General";
     585              :         }
     586              : 
     587           43 :         if (NumAlphas > 15) {
     588            1 :             thisChiller.CondenserFlowControl =
     589            1 :                 static_cast<DataPlant::CondenserFlowControl>(getEnumValue(DataPlant::CondenserFlowControlNamesUC, s_ipsc->cAlphaArgs(16)));
     590              :         } else {
     591           42 :             thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow;
     592              :         }
     593              : 
     594           43 :         if (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::Invalid) {
     595            0 :             ShowSevereError(state, format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     596            0 :             ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(16), s_ipsc->cAlphaArgs(16)));
     597            0 :             ShowContinueError(state, "Available choices are ConstantFlow, ModulatedChillerPLR, ModulatedLoopPLR, or ModulatedDeltaTemperature");
     598            0 :             thisChiller.CondenserFlowControl = DataPlant::CondenserFlowControl::ConstantFlow;
     599            0 :             ErrorsFound = true;
     600              :         };
     601              : 
     602           43 :         if (NumAlphas > 16) {
     603            1 :             thisChiller.ChillerCondLoopFlowFLoopPLRIndex = Curve::GetCurveIndex(state, s_ipsc->cAlphaArgs(17));
     604              :         }
     605           43 :         if ((thisChiller.ChillerCondLoopFlowFLoopPLRIndex == 0) &&
     606           42 :             (thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedLoopPLR)) {
     607            0 :             ShowSevereError(state, format("{}{} \"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)));
     608            0 :             ShowContinueError(state, format("Invalid {}={}", s_ipsc->cAlphaFieldNames(17), s_ipsc->cAlphaArgs(17)));
     609            0 :             ErrorsFound = true;
     610              :         }
     611              : 
     612           43 :         if (NumAlphas < 17 || s_ipsc->lAlphaFieldBlanks(18)) {
     613           42 :             thisChiller.condDTSched = nullptr; // ok for this to be nullptr
     614            1 :         } else if (((thisChiller.condDTSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(18))) == nullptr) &&
     615            0 :                    thisChiller.CondenserFlowControl == DataPlant::CondenserFlowControl::ModulatedDeltaTemperature) {
     616            0 :             ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(18), s_ipsc->cAlphaArgs(18));
     617            0 :             ErrorsFound = true;
     618              :         }
     619              : 
     620           43 :         if (NumNums > 15) {
     621            1 :             thisChiller.MinCondFlowRatio = s_ipsc->rNumericArgs(16);
     622              :         }
     623           43 :         if (!s_ipsc->lAlphaFieldBlanks(19)) {
     624            0 :             thisChiller.thermosiphonTempCurveIndex = Curve::GetCurveIndex(state, Util::makeUPPER(s_ipsc->cAlphaArgs(19)));
     625            0 :             if (thisChiller.thermosiphonTempCurveIndex == 0) {
     626            0 :                 ShowSevereError(state, format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, thisChiller.Name));
     627            0 :                 ShowContinueError(state, format("Invalid {} = {}", s_ipsc->cAlphaFieldNames(19), s_ipsc->cAlphaArgs(19)));
     628            0 :                 ErrorsFound = true;
     629              :             }
     630              :         }
     631           43 :         thisChiller.thermosiphonMinTempDiff = s_ipsc->rNumericArgs(17);
     632           43 :     }
     633              : 
     634           24 :     if (ErrorsFound) {
     635            0 :         ShowFatalError(state, format("Errors found in processing input for {}", s_ipsc->cCurrentModuleObject));
     636              :     }
     637           24 : }
     638              : 
     639           43 : void ReformulatedEIRChillerSpecs::setupOutputVars(EnergyPlusData &state)
     640              : {
     641           86 :     SetupOutputVariable(state,
     642              :                         "Chiller Part Load Ratio",
     643              :                         Constant::Units::None,
     644           43 :                         this->ChillerPartLoadRatio,
     645              :                         OutputProcessor::TimeStepType::System,
     646              :                         OutputProcessor::StoreType::Average,
     647           43 :                         this->Name);
     648              : 
     649           86 :     SetupOutputVariable(state,
     650              :                         "Chiller Cycling Ratio",
     651              :                         Constant::Units::None,
     652           43 :                         this->ChillerCyclingRatio,
     653              :                         OutputProcessor::TimeStepType::System,
     654              :                         OutputProcessor::StoreType::Average,
     655           43 :                         this->Name);
     656              : 
     657           86 :     SetupOutputVariable(state,
     658              :                         "Chiller Electricity Rate",
     659              :                         Constant::Units::W,
     660           43 :                         this->Power,
     661              :                         OutputProcessor::TimeStepType::System,
     662              :                         OutputProcessor::StoreType::Average,
     663           43 :                         this->Name);
     664              : 
     665           86 :     SetupOutputVariable(state,
     666              :                         "Chiller Electricity Energy",
     667              :                         Constant::Units::J,
     668           43 :                         this->Energy,
     669              :                         OutputProcessor::TimeStepType::System,
     670              :                         OutputProcessor::StoreType::Sum,
     671           43 :                         this->Name,
     672              :                         Constant::eResource::Electricity,
     673              :                         OutputProcessor::Group::Plant,
     674              :                         OutputProcessor::EndUseCat::Cooling,
     675              :                         this->EndUseSubcategory);
     676              : 
     677           86 :     SetupOutputVariable(state,
     678              :                         "Chiller Evaporator Cooling Rate",
     679              :                         Constant::Units::W,
     680           43 :                         this->QEvaporator,
     681              :                         OutputProcessor::TimeStepType::System,
     682              :                         OutputProcessor::StoreType::Average,
     683           43 :                         this->Name);
     684              : 
     685           86 :     SetupOutputVariable(state,
     686              :                         "Chiller Evaporator Cooling Energy",
     687              :                         Constant::Units::J,
     688           43 :                         this->EvapEnergy,
     689              :                         OutputProcessor::TimeStepType::System,
     690              :                         OutputProcessor::StoreType::Sum,
     691           43 :                         this->Name,
     692              :                         Constant::eResource::EnergyTransfer,
     693              :                         OutputProcessor::Group::Plant,
     694              :                         OutputProcessor::EndUseCat::Chillers);
     695              : 
     696           86 :     SetupOutputVariable(state,
     697              :                         "Chiller False Load Heat Transfer Rate",
     698              :                         Constant::Units::W,
     699           43 :                         this->ChillerFalseLoadRate,
     700              :                         OutputProcessor::TimeStepType::System,
     701              :                         OutputProcessor::StoreType::Average,
     702           43 :                         this->Name);
     703              : 
     704           86 :     SetupOutputVariable(state,
     705              :                         "Chiller False Load Heat Transfer Energy",
     706              :                         Constant::Units::J,
     707           43 :                         this->ChillerFalseLoad,
     708              :                         OutputProcessor::TimeStepType::System,
     709              :                         OutputProcessor::StoreType::Sum,
     710           43 :                         this->Name);
     711              : 
     712           86 :     SetupOutputVariable(state,
     713              :                         "Chiller Evaporator Inlet Temperature",
     714              :                         Constant::Units::C,
     715           43 :                         this->EvapInletTemp,
     716              :                         OutputProcessor::TimeStepType::System,
     717              :                         OutputProcessor::StoreType::Average,
     718           43 :                         this->Name);
     719              : 
     720           86 :     SetupOutputVariable(state,
     721              :                         "Chiller Evaporator Outlet Temperature",
     722              :                         Constant::Units::C,
     723           43 :                         this->EvapOutletTemp,
     724              :                         OutputProcessor::TimeStepType::System,
     725              :                         OutputProcessor::StoreType::Average,
     726           43 :                         this->Name);
     727              : 
     728           86 :     SetupOutputVariable(state,
     729              :                         "Chiller Evaporator Mass Flow Rate",
     730              :                         Constant::Units::kg_s,
     731           43 :                         this->EvapMassFlowRate,
     732              :                         OutputProcessor::TimeStepType::System,
     733              :                         OutputProcessor::StoreType::Average,
     734           43 :                         this->Name);
     735              : 
     736           86 :     SetupOutputVariable(state,
     737              :                         "Chiller Condenser Heat Transfer Rate",
     738              :                         Constant::Units::W,
     739           43 :                         this->QCondenser,
     740              :                         OutputProcessor::TimeStepType::System,
     741              :                         OutputProcessor::StoreType::Average,
     742           43 :                         this->Name);
     743              : 
     744           86 :     SetupOutputVariable(state,
     745              :                         "Chiller Condenser Heat Transfer Energy",
     746              :                         Constant::Units::J,
     747           43 :                         this->CondEnergy,
     748              :                         OutputProcessor::TimeStepType::System,
     749              :                         OutputProcessor::StoreType::Sum,
     750           43 :                         this->Name,
     751              :                         Constant::eResource::EnergyTransfer,
     752              :                         OutputProcessor::Group::Plant,
     753              :                         OutputProcessor::EndUseCat::HeatRejection);
     754              : 
     755           86 :     SetupOutputVariable(state,
     756              :                         "Chiller COP",
     757              :                         Constant::Units::W_W,
     758           43 :                         this->ActualCOP,
     759              :                         OutputProcessor::TimeStepType::System,
     760              :                         OutputProcessor::StoreType::Average,
     761           43 :                         this->Name);
     762              : 
     763           86 :     SetupOutputVariable(state,
     764              :                         "Chiller Capacity Temperature Modifier Multiplier",
     765              :                         Constant::Units::None,
     766           43 :                         this->ChillerCapFT,
     767              :                         OutputProcessor::TimeStepType::System,
     768              :                         OutputProcessor::StoreType::Average,
     769           43 :                         this->Name);
     770              : 
     771           86 :     SetupOutputVariable(state,
     772              :                         "Chiller EIR Temperature Modifier Multiplier",
     773              :                         Constant::Units::None,
     774           43 :                         this->ChillerEIRFT,
     775              :                         OutputProcessor::TimeStepType::System,
     776              :                         OutputProcessor::StoreType::Average,
     777           43 :                         this->Name);
     778              : 
     779           86 :     SetupOutputVariable(state,
     780              :                         "Chiller EIR Part Load Modifier Multiplier",
     781              :                         Constant::Units::None,
     782           43 :                         this->ChillerEIRFPLR,
     783              :                         OutputProcessor::TimeStepType::System,
     784              :                         OutputProcessor::StoreType::Average,
     785           43 :                         this->Name);
     786              : 
     787           86 :     SetupOutputVariable(state,
     788              :                         "Chiller Condenser Inlet Temperature",
     789              :                         Constant::Units::C,
     790           43 :                         this->CondInletTemp,
     791              :                         OutputProcessor::TimeStepType::System,
     792              :                         OutputProcessor::StoreType::Average,
     793           43 :                         this->Name);
     794              : 
     795           86 :     SetupOutputVariable(state,
     796              :                         "Chiller Condenser Outlet Temperature",
     797              :                         Constant::Units::C,
     798           43 :                         this->CondOutletTemp,
     799              :                         OutputProcessor::TimeStepType::System,
     800              :                         OutputProcessor::StoreType::Average,
     801           43 :                         this->Name);
     802              : 
     803           86 :     SetupOutputVariable(state,
     804              :                         "Chiller Condenser Mass Flow Rate",
     805              :                         Constant::Units::kg_s,
     806           43 :                         this->CondMassFlowRate,
     807              :                         OutputProcessor::TimeStepType::System,
     808              :                         OutputProcessor::StoreType::Average,
     809           43 :                         this->Name);
     810              : 
     811           43 :     SetupOutputVariable(state,
     812              :                         "Thermosiphon Status",
     813              :                         Constant::Units::None,
     814           43 :                         this->thermosiphonStatus,
     815              :                         OutputProcessor::TimeStepType::System,
     816              :                         OutputProcessor::StoreType::Average,
     817           43 :                         this->Name);
     818              : 
     819              :     // If heat recovery is active then setup report variables
     820           43 :     if (this->HeatRecActive) {
     821            0 :         SetupOutputVariable(state,
     822              :                             "Chiller Total Recovered Heat Rate",
     823              :                             Constant::Units::W,
     824            0 :                             this->QHeatRecovery,
     825              :                             OutputProcessor::TimeStepType::System,
     826              :                             OutputProcessor::StoreType::Average,
     827            0 :                             this->Name);
     828              : 
     829            0 :         SetupOutputVariable(state,
     830              :                             "Chiller Total Recovered Heat Energy",
     831              :                             Constant::Units::J,
     832            0 :                             this->EnergyHeatRecovery,
     833              :                             OutputProcessor::TimeStepType::System,
     834              :                             OutputProcessor::StoreType::Sum,
     835            0 :                             this->Name,
     836              :                             Constant::eResource::EnergyTransfer,
     837              :                             OutputProcessor::Group::Plant,
     838              :                             OutputProcessor::EndUseCat::HeatRejection);
     839              : 
     840            0 :         SetupOutputVariable(state,
     841              :                             "Chiller Heat Recovery Inlet Temperature",
     842              :                             Constant::Units::C,
     843            0 :                             this->HeatRecInletTemp,
     844              :                             OutputProcessor::TimeStepType::System,
     845              :                             OutputProcessor::StoreType::Average,
     846            0 :                             this->Name);
     847              : 
     848            0 :         SetupOutputVariable(state,
     849              :                             "Chiller Heat Recovery Outlet Temperature",
     850              :                             Constant::Units::C,
     851            0 :                             this->HeatRecOutletTemp,
     852              :                             OutputProcessor::TimeStepType::System,
     853              :                             OutputProcessor::StoreType::Average,
     854            0 :                             this->Name);
     855              : 
     856            0 :         SetupOutputVariable(state,
     857              :                             "Chiller Heat Recovery Mass Flow Rate",
     858              :                             Constant::Units::kg_s,
     859            0 :                             this->HeatRecMassFlow,
     860              :                             OutputProcessor::TimeStepType::System,
     861              :                             OutputProcessor::StoreType::Average,
     862            0 :                             this->Name);
     863              : 
     864            0 :         SetupOutputVariable(state,
     865              :                             "Chiller Effective Heat Rejection Temperature",
     866              :                             Constant::Units::C,
     867            0 :                             this->ChillerCondAvgTemp,
     868              :                             OutputProcessor::TimeStepType::System,
     869              :                             OutputProcessor::StoreType::Average,
     870            0 :                             this->Name);
     871              :     }
     872              : 
     873           43 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
     874           15 :         SetupEMSInternalVariable(state, "Chiller Nominal Capacity", this->Name, "[W]", this->RefCap);
     875              :     }
     876           43 : }
     877              : 
     878           43 : void ReformulatedEIRChillerSpecs::oneTimeInit(EnergyPlusData &state)
     879              : {
     880              :     // Locate the chillers on the plant loops for later usage
     881           43 :     bool errFlag = false;
     882          129 :     PlantUtilities::ScanPlantLoopsForObject(state,
     883              :                                             this->Name,
     884              :                                             DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
     885           43 :                                             this->CWPlantLoc,
     886              :                                             errFlag,
     887           43 :                                             this->TempLowLimitEvapOut,
     888              :                                             _,
     889              :                                             _,
     890           43 :                                             this->EvapInletNodeNum,
     891              :                                             _);
     892           43 :     if (this->CondenserType != DataPlant::CondenserType::AirCooled) {
     893          129 :         PlantUtilities::ScanPlantLoopsForObject(state,
     894              :                                                 this->Name,
     895              :                                                 DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
     896           43 :                                                 this->CDPlantLoc,
     897              :                                                 errFlag,
     898              :                                                 _,
     899              :                                                 _,
     900              :                                                 _,
     901           43 :                                                 this->CondInletNodeNum,
     902              :                                                 _);
     903           43 :         PlantUtilities::InterConnectTwoPlantLoopSides(
     904           43 :             state, this->CWPlantLoc, this->CDPlantLoc, DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR, true);
     905              :     }
     906           43 :     if (this->HeatRecActive) {
     907            0 :         PlantUtilities::ScanPlantLoopsForObject(state,
     908              :                                                 this->Name,
     909              :                                                 DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
     910            0 :                                                 this->HRPlantLoc,
     911              :                                                 errFlag,
     912              :                                                 _,
     913              :                                                 _,
     914              :                                                 _,
     915            0 :                                                 this->HeatRecInletNodeNum,
     916              :                                                 _);
     917            0 :         PlantUtilities::InterConnectTwoPlantLoopSides(
     918            0 :             state, this->CWPlantLoc, this->HRPlantLoc, DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR, true);
     919              :     }
     920              : 
     921           43 :     if ((this->CondenserType != DataPlant::CondenserType::AirCooled) && (this->HeatRecActive)) {
     922            0 :         PlantUtilities::InterConnectTwoPlantLoopSides(
     923            0 :             state, this->CDPlantLoc, this->HRPlantLoc, DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR, false);
     924              :     }
     925              : 
     926           43 :     if (errFlag) {
     927            0 :         ShowFatalError(state, "InitElecReformEIRChiller: Program terminated due to previous condition(s).");
     928              :     }
     929              : 
     930           43 :     if (this->FlowMode == DataPlant::FlowMode::Constant) {
     931              :         // reset flow priority
     932            5 :         DataPlant::CompData::getPlantComponent(state, this->CWPlantLoc).FlowPriority = DataPlant::LoopFlowStatus::NeedyIfLoopOn;
     933              :     }
     934              : 
     935           43 :     if (this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) {
     936              :         // reset flow priority
     937           37 :         DataPlant::CompData::getPlantComponent(state, this->CWPlantLoc).FlowPriority = DataPlant::LoopFlowStatus::NeedyIfLoopOn;
     938              :         // check if setpoint on outlet node
     939           37 :         if ((state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint == DataLoopNode::SensedNodeFlagValue) &&
     940            0 :             (state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi == DataLoopNode::SensedNodeFlagValue)) {
     941            0 :             if (!state.dataGlobal->AnyEnergyManagementSystemInModel) {
     942            0 :                 if (!this->ModulatedFlowErrDone) {
     943            0 :                     ShowWarningError(state, format("Missing temperature setpoint for LeavingSetpointModulated mode chiller named {}", this->Name));
     944            0 :                     ShowContinueError(
     945              :                         state, "  A temperature setpoint is needed at the outlet node of a chiller in variable flow mode, use a SetpointManager");
     946            0 :                     ShowContinueError(state, "  The overall loop setpoint will be assumed for chiller. The simulation continues ... ");
     947            0 :                     this->ModulatedFlowErrDone = true;
     948              :                 }
     949              :             } else {
     950              :                 // need call to EMS to check node
     951            0 :                 bool fatalError = false; // but not really fatal yet, but should be.
     952            0 :                 EMSManager::CheckIfNodeSetPointManagedByEMS(state, this->EvapOutletNodeNum, HVAC::CtrlVarType::Temp, fatalError);
     953            0 :                 state.dataLoopNodes->NodeSetpointCheck(this->EvapOutletNodeNum).needsSetpointChecking = false;
     954            0 :                 if (fatalError) {
     955            0 :                     if (!this->ModulatedFlowErrDone) {
     956            0 :                         ShowWarningError(state,
     957            0 :                                          format("Missing temperature setpoint for LeavingSetpointModulated mode chiller named {}", this->Name));
     958            0 :                         ShowContinueError(state,
     959              :                                           "  A temperature setpoint is needed at the outlet node of a chiller evaporator in variable flow mode");
     960            0 :                         ShowContinueError(state, "  use a Setpoint Manager to establish a setpoint at the chiller evaporator outlet node ");
     961            0 :                         ShowContinueError(state, "  or use an EMS actuator to establish a setpoint at the outlet node ");
     962            0 :                         ShowContinueError(state, "  The overall loop setpoint will be assumed for chiller. The simulation continues ... ");
     963            0 :                         this->ModulatedFlowErrDone = true;
     964              :                     }
     965              :                 }
     966              :             }
     967            0 :             this->ModulatedFlowSetToLoop = true;
     968            0 :             state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint =
     969            0 :                 state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPoint;
     970            0 :             state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi =
     971            0 :                 state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPointHi;
     972              :         }
     973              :     }
     974           43 : }
     975              : 
     976      2718039 : void ReformulatedEIRChillerSpecs::initialize(EnergyPlusData &state, bool const RunFlag, Real64 const MyLoad)
     977              : {
     978              : 
     979              :     // SUBROUTINE INFORMATION:
     980              :     //       AUTHOR         Lixing Gu, FSEC
     981              :     //       DATE WRITTEN   July 2006
     982              : 
     983              :     // PURPOSE OF THIS SUBROUTINE:
     984              :     //  This subroutine is for initializations of the Reformulated Electric EIR Chiller variables
     985              : 
     986              :     // METHODOLOGY EMPLOYED:
     987              :     //  Uses the status flags to trigger initializations.
     988              : 
     989              :     static constexpr std::string_view RoutineName("InitElecReformEIRChiller");
     990              : 
     991              :     // Init more variables
     992      2718039 :     if (this->MyInitFlag) {
     993           43 :         this->oneTimeInit(state);
     994           43 :         this->setupOutputVars(state);
     995           43 :         this->MyInitFlag = false;
     996              :     }
     997              : 
     998      2718039 :     this->EquipFlowCtrl = DataPlant::CompData::getPlantComponent(state, this->CWPlantLoc).FlowCtrl;
     999              : 
    1000      2718039 :     if (this->MyEnvrnFlag && state.dataGlobal->BeginEnvrnFlag && (state.dataPlnt->PlantFirstSizesOkayToFinalize)) {
    1001              : 
    1002          414 :         Real64 rho = this->CWPlantLoc.loop->glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
    1003              : 
    1004          414 :         this->EvapMassFlowRateMax = this->EvapVolFlowRate * rho;
    1005              : 
    1006          414 :         PlantUtilities::InitComponentNodes(state, 0.0, this->EvapMassFlowRateMax, this->EvapInletNodeNum, this->EvapOutletNodeNum);
    1007              : 
    1008          414 :         if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1009              : 
    1010          414 :             rho = this->CDPlantLoc.loop->glycol->getDensity(state, this->TempRefCondIn, RoutineName);
    1011          414 :             this->CondMassFlowRateMax = rho * this->CondVolFlowRate;
    1012          414 :             PlantUtilities::InitComponentNodes(state, 0.0, this->CondMassFlowRateMax, this->CondInletNodeNum, this->CondOutletNodeNum);
    1013          414 :             state.dataLoopNodes->Node(this->CondInletNodeNum).Temp = this->TempRefCondIn;
    1014              :             // get minimum condenser plant loop pump mass flow rate
    1015          414 :             this->VSBranchPumpMinLimitMassFlowCond =
    1016          414 :                 PlantUtilities::MinFlowIfBranchHasVSPump(state, this->CDPlantLoc, this->VSBranchPumpFoundCond, this->VSLoopPumpFoundCond, false);
    1017              :         } else { // air or evap air condenser
    1018              :             // Initialize maximum available condenser flow rate
    1019            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate =
    1020            0 :                 this->CondVolFlowRate *
    1021            0 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, this->TempRefCondIn, 0.0, RoutineName);
    1022            0 :             state.dataLoopNodes->Node(this->CondOutletNodeNum).MassFlowRate = state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate;
    1023            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRateMaxAvail = state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate;
    1024            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRateMax = state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate;
    1025            0 :             state.dataLoopNodes->Node(this->CondOutletNodeNum).MassFlowRateMax = state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate;
    1026            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRateMinAvail = 0.0;
    1027            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRateMin = 0.0;
    1028            0 :             state.dataLoopNodes->Node(this->CondOutletNodeNum).MassFlowRateMinAvail = 0.0;
    1029            0 :             state.dataLoopNodes->Node(this->CondOutletNodeNum).MassFlowRateMin = 0.0;
    1030            0 :             state.dataLoopNodes->Node(this->CondInletNodeNum).Temp = this->TempRefCondIn;
    1031              :         }
    1032              : 
    1033          414 :         if (this->HeatRecActive) {
    1034            0 :             rho = this->HRPlantLoc.loop->glycol->getDensity(state, Constant::HWInitConvTemp, RoutineName);
    1035            0 :             this->DesignHeatRecMassFlowRate = rho * this->DesignHeatRecVolFlowRate;
    1036            0 :             PlantUtilities::InitComponentNodes(state, 0.0, this->DesignHeatRecMassFlowRate, this->HeatRecInletNodeNum, this->HeatRecOutletNodeNum);
    1037              :             // overall capacity limit
    1038            0 :             this->HeatRecMaxCapacityLimit = this->HeatRecCapacityFraction * (this->RefCap + this->RefCap / this->RefCOP);
    1039              :         }
    1040              : 
    1041          414 :         this->MyEnvrnFlag = false;
    1042              :     }
    1043      2718039 :     if (!state.dataGlobal->BeginEnvrnFlag) {
    1044      2696252 :         this->MyEnvrnFlag = true;
    1045              :     }
    1046              : 
    1047      2718039 :     if ((this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) && this->ModulatedFlowSetToLoop) {
    1048              :         // fix for clumsy old input that worked because loop setpoint was spread.
    1049              :         //  could be removed with transition, testing , model change, period of being obsolete.
    1050            0 :         state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint =
    1051            0 :             state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPoint;
    1052            0 :         state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi =
    1053            0 :             state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPointHi;
    1054              :     }
    1055              : 
    1056      2718039 :     Real64 mdot = 0.0;
    1057      2718039 :     Real64 mdotCond = 0.0;
    1058      2718039 :     if ((std::abs(MyLoad) > 0.0) && RunFlag) {
    1059      1039494 :         mdot = this->EvapMassFlowRateMax;
    1060      1039494 :         mdotCond = this->CondMassFlowRateMax;
    1061              :     }
    1062              : 
    1063      2718039 :     PlantUtilities::SetComponentFlowRate(state, mdot, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    1064              : 
    1065      2718039 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1066      2718039 :         PlantUtilities::SetComponentFlowRate(state, mdotCond, this->CondInletNodeNum, this->CondOutletNodeNum, this->CDPlantLoc);
    1067              :     }
    1068              :     // Initialize heat recovery flow rates at node
    1069      2718039 :     if (this->HeatRecActive) {
    1070              : 
    1071              :         // check if inlet limit active and if exceeded.
    1072            0 :         bool HeatRecRunFlag = RunFlag;
    1073            0 :         if (this->heatRecInletLimitSched != nullptr) {
    1074            0 :             Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal();
    1075            0 :             if (state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp > HeatRecHighInletLimit) { // shut down heat recovery
    1076            0 :                 HeatRecRunFlag = false;
    1077              :             } else {
    1078            0 :                 HeatRecRunFlag = RunFlag;
    1079              :             }
    1080              :         }
    1081              : 
    1082            0 :         mdot = HeatRecRunFlag ? this->DesignHeatRecMassFlowRate : 0.0;
    1083              : 
    1084            0 :         PlantUtilities::SetComponentFlowRate(state, mdot, this->HeatRecInletNodeNum, this->HeatRecOutletNodeNum, this->HRPlantLoc);
    1085              :     }
    1086      2718039 : }
    1087              : 
    1088          239 : void ReformulatedEIRChillerSpecs::size(EnergyPlusData &state)
    1089              : {
    1090              : 
    1091              :     // SUBROUTINE INFORMATION:
    1092              :     //       AUTHOR         Richard Raustad, FSEC
    1093              :     //       DATE WRITTEN   June 2004
    1094              :     //       MODIFIED       July 2006, L. Gu, modified for reformulated EIR chiller
    1095              :     //                      November 2013 Daeho Kang, add component sizing table entries
    1096              : 
    1097              :     // PURPOSE OF THIS SUBROUTINE:
    1098              :     //  This subroutine is for sizing Reformulated Electric EIR Chiller Components for which capacities and flow rates
    1099              :     //  have not been specified in the input.
    1100              : 
    1101              :     // METHODOLOGY EMPLOYED:
    1102              :     //  Obtains evaporator flow rate from the plant sizing array. Calculates reference capacity from
    1103              :     //  the evaporator flow rate and the chilled water loop design delta T. The condenser flow rate
    1104              :     //  is calculated from the reference capacity, the COP, and the condenser loop design delta T.
    1105              : 
    1106              :     static constexpr std::string_view RoutineName("SizeElecReformEIRChiller");
    1107              : 
    1108          239 :     bool ErrorsFound(false); // If errors detected in input
    1109              : 
    1110          239 :     Real64 tmpNomCap = this->RefCap;
    1111          239 :     Real64 tmpEvapVolFlowRate = this->EvapVolFlowRate;
    1112          239 :     Real64 tmpCondVolFlowRate = this->CondVolFlowRate;
    1113              : 
    1114          239 :     int PltSizCondNum(0); // Plant Sizing index for condenser loop
    1115          239 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1116          239 :         PltSizCondNum = this->CDPlantLoc.loop->PlantSizNum;
    1117              :     }
    1118              : 
    1119              :     // find the appropriate Plant Sizing object
    1120          239 :     int PltSizNum = this->CWPlantLoc.loop->PlantSizNum;
    1121              : 
    1122          239 :     if (PltSizNum > 0) {
    1123          234 :         if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= HVAC::SmallWaterVolFlow) {
    1124          188 :             tmpEvapVolFlowRate = state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate * this->SizFac;
    1125              :         } else {
    1126           46 :             if (this->EvapVolFlowRateWasAutoSized) {
    1127           38 :                 tmpEvapVolFlowRate = 0.0;
    1128              :             }
    1129              :         }
    1130          234 :         if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1131           66 :             if (this->EvapVolFlowRateWasAutoSized) {
    1132           62 :                 this->EvapVolFlowRate = tmpEvapVolFlowRate;
    1133           62 :                 if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1134           38 :                     BaseSizer::reportSizerOutput(state,
    1135              :                                                  "Chiller:Electric:ReformulatedEIR",
    1136              :                                                  this->Name,
    1137              :                                                  "Design Size Reference Chilled Water Flow Rate [m3/s]",
    1138              :                                                  tmpEvapVolFlowRate);
    1139              :                 }
    1140           62 :                 if (state.dataPlnt->PlantFirstSizesOkayToReport) {
    1141           12 :                     BaseSizer::reportSizerOutput(state,
    1142              :                                                  "Chiller:Electric:ReformulatedEIR",
    1143              :                                                  this->Name,
    1144              :                                                  "Initial Design Size Reference Chilled Water Flow Rate [m3/s]",
    1145              :                                                  tmpEvapVolFlowRate);
    1146              :                 }
    1147              :             } else { // Hard-size with sizing data
    1148            4 :                 if (this->EvapVolFlowRate > 0.0 && tmpEvapVolFlowRate > 0.0) {
    1149            4 :                     Real64 EvapVolFlowRateUser = this->EvapVolFlowRate;
    1150            4 :                     if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1151            4 :                         BaseSizer::reportSizerOutput(state,
    1152              :                                                      "Chiller:Electric:ReformulatedEIR",
    1153              :                                                      this->Name,
    1154              :                                                      "Design Size Reference Chilled Water Flow Rate [m3/s]",
    1155              :                                                      tmpEvapVolFlowRate,
    1156              :                                                      "User-Specified Reference Chilled Water Flow Rate [m3/s]",
    1157              :                                                      EvapVolFlowRateUser);
    1158            4 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    1159            0 :                             if ((std::abs(tmpEvapVolFlowRate - EvapVolFlowRateUser) / EvapVolFlowRateUser) >
    1160            0 :                                 state.dataSize->AutoVsHardSizingThreshold) {
    1161            0 :                                 ShowMessage(state,
    1162            0 :                                             format("SizeChillerElectricReformulatedEIR: Potential issue with equipment sizing for {}", this->Name));
    1163            0 :                                 ShowContinueError(state,
    1164            0 :                                                   format("User-Specified Reference Chilled Water Flow Rate of {:.5R} [m3/s]", EvapVolFlowRateUser));
    1165            0 :                                 ShowContinueError(
    1166            0 :                                     state, format("differs from Design Size Reference Chilled Water Flow Rate of {:.5R} [m3/s]", tmpEvapVolFlowRate));
    1167            0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    1168            0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    1169              :                             }
    1170              :                         }
    1171              :                     }
    1172            4 :                     tmpEvapVolFlowRate = EvapVolFlowRateUser;
    1173              :                 }
    1174              :             }
    1175              :         }
    1176              :     } else {
    1177            5 :         if (this->EvapVolFlowRateWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1178            0 :             ShowSevereError(state, "Autosizing of Reformulated Electric Chiller evap flow rate requires a loop Sizing:Plant object");
    1179            0 :             ShowContinueError(state, format("Occurs in Reformulated Electric Chiller object={}", this->Name));
    1180            0 :             ErrorsFound = true;
    1181              :         }
    1182            6 :         if (!this->EvapVolFlowRateWasAutoSized && state.dataPlnt->PlantFinalSizesOkayToReport &&
    1183            1 :             (this->EvapVolFlowRate > 0.0)) { // Hard-size with sizing data
    1184            1 :             BaseSizer::reportSizerOutput(state,
    1185              :                                          "Chiller:Electric:ReformulatedEIR",
    1186              :                                          this->Name,
    1187              :                                          "User-Specified Reference Chilled Water Flow Rate [m3/s]",
    1188              :                                          this->EvapVolFlowRate);
    1189              :         }
    1190              :     }
    1191              : 
    1192          239 :     PlantUtilities::RegisterPlantCompDesignFlow(state, this->EvapInletNodeNum, tmpEvapVolFlowRate);
    1193              : 
    1194          239 :     if (PltSizNum > 0) {
    1195          234 :         if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= HVAC::SmallWaterVolFlow) {
    1196          188 :             Real64 SizingEvapOutletTemp = this->TempRefEvapOut; // Plant Sizing outlet temperature for CurLoopNum [C]
    1197          188 :             Real64 SizingCondOutletTemp = this->TempRefCondOut; // Plant Sizing outlet temperature for condenser loop [C]
    1198          188 :             if (PltSizCondNum > 0 && PltSizNum > 0) {
    1199          188 :                 SizingEvapOutletTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    1200          188 :                 SizingCondOutletTemp = state.dataSize->PlantSizData(PltSizCondNum).ExitTemp + state.dataSize->PlantSizData(PltSizCondNum).DeltaT;
    1201              :             }
    1202          188 :             Real64 Cp = this->CWPlantLoc.loop->glycol->getSpecificHeat(state, Constant::CWInitConvTemp, RoutineName);
    1203          188 :             Real64 rho = this->CWPlantLoc.loop->glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
    1204          188 :             Real64 RefCapFT = Curve::CurveValue(state, this->ChillerCapFTIndex, SizingEvapOutletTemp, SizingCondOutletTemp);
    1205          188 :             tmpNomCap = (Cp * rho * state.dataSize->PlantSizData(PltSizNum).DeltaT * tmpEvapVolFlowRate) / RefCapFT;
    1206              :         } else {
    1207           46 :             if (this->RefCapWasAutoSized) {
    1208           38 :                 tmpNomCap = 0.0;
    1209              :             }
    1210              :         }
    1211          234 :         if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1212           66 :             if (this->RefCapWasAutoSized) {
    1213           62 :                 this->RefCap = tmpNomCap;
    1214           62 :                 if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1215           38 :                     BaseSizer::reportSizerOutput(
    1216              :                         state, "Chiller:Electric:ReformulatedEIR", this->Name, "Design Size Reference Capacity [W]", tmpNomCap);
    1217              :                 }
    1218           62 :                 if (state.dataPlnt->PlantFirstSizesOkayToReport) {
    1219           12 :                     BaseSizer::reportSizerOutput(
    1220              :                         state, "Chiller:Electric:ReformulatedEIR", this->Name, "Initial Design Size Reference Capacity [W]", tmpNomCap);
    1221              :                 }
    1222              :             } else {
    1223            4 :                 if (this->RefCap > 0.0 && tmpNomCap > 0.0) {
    1224            4 :                     Real64 RefCapUser = this->RefCap;
    1225            4 :                     if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1226            4 :                         BaseSizer::reportSizerOutput(state,
    1227              :                                                      "Chiller:Electric:ReformulatedEIR",
    1228              :                                                      this->Name,
    1229              :                                                      "Design Size Reference Capacity [W]",
    1230              :                                                      tmpNomCap,
    1231              :                                                      "User-Specified Reference Capacity [W]",
    1232              :                                                      RefCapUser);
    1233            4 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    1234            0 :                             if ((std::abs(tmpNomCap - RefCapUser) / RefCapUser) > state.dataSize->AutoVsHardSizingThreshold) {
    1235            0 :                                 ShowMessage(state,
    1236            0 :                                             format("Size:ChillerElectricReformulatedEIR: Potential issue with equipment sizing for {}", this->Name));
    1237            0 :                                 ShowContinueError(state, format("User-Specified Reference Capacity of {:.2R} [W]", RefCapUser));
    1238            0 :                                 ShowContinueError(state, format("differs from Design Size Reference Capacity of {:.2R} [W]", tmpNomCap));
    1239            0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    1240            0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    1241              :                             }
    1242              :                         }
    1243              :                     }
    1244            4 :                     tmpNomCap = RefCapUser;
    1245              :                 }
    1246              :             }
    1247              :         }
    1248              :     } else {
    1249            5 :         if (this->RefCapWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1250            0 :             ShowSevereError(state, "Autosizing of Reformulated Electric Chiller reference capacity requires a loop Sizing:Plant object");
    1251            0 :             ShowContinueError(state, format("Occurs in Reformulated Electric Chiller object={}", this->Name));
    1252            0 :             ErrorsFound = true;
    1253              :         }
    1254            5 :         if (!this->RefCapWasAutoSized && state.dataPlnt->PlantFinalSizesOkayToReport && (this->RefCap > 0.0)) {
    1255            1 :             BaseSizer::reportSizerOutput(
    1256              :                 state, "Chiller:Electric:ReformulatedEIR", this->Name, "User-Specified Reference Capacity [W]", this->RefCap);
    1257              :         }
    1258              :     }
    1259              : 
    1260          239 :     if (PltSizCondNum > 0 && PltSizNum > 0 && this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1261          234 :         if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= HVAC::SmallWaterVolFlow && tmpNomCap > 0.0) {
    1262          188 :             Real64 rho = this->CDPlantLoc.loop->glycol->getDensity(state, this->TempRefCondIn, RoutineName);
    1263          188 :             Real64 Cp = this->CDPlantLoc.loop->glycol->getSpecificHeat(state, this->TempRefCondIn, RoutineName);
    1264          376 :             tmpCondVolFlowRate = tmpNomCap * (1.0 + (1.0 / this->RefCOP) * this->CompPowerToCondenserFrac) /
    1265          188 :                                  (state.dataSize->PlantSizData(PltSizCondNum).DeltaT * Cp * rho);
    1266              :             // IF (DataPlant::PlantFirstSizesOkayToFinalize) ElecReformEIRChiller(EIRChillNum)%CondVolFlowRate = tmpCondVolFlowRate
    1267              :         } else {
    1268           46 :             if (this->CondVolFlowRateWasAutoSized) {
    1269           46 :                 tmpCondVolFlowRate = 0.0;
    1270              :             }
    1271              :             // IF (DataPlant::PlantFirstSizesOkayToFinalize) ElecReformEIRChiller(EIRChillNum)%CondVolFlowRate = tmpCondVolFlowRate
    1272              :         }
    1273          234 :         if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1274           66 :             if (this->CondVolFlowRateWasAutoSized) {
    1275           66 :                 this->CondVolFlowRate = tmpCondVolFlowRate;
    1276           66 :                 if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1277           42 :                     BaseSizer::reportSizerOutput(state,
    1278              :                                                  "Chiller:Electric:ReformulatedEIR",
    1279              :                                                  this->Name,
    1280              :                                                  "Design Size Reference Condenser Water Flow Rate [m3/s]",
    1281              :                                                  tmpCondVolFlowRate);
    1282              :                 }
    1283           66 :                 if (state.dataPlnt->PlantFirstSizesOkayToReport) {
    1284           12 :                     BaseSizer::reportSizerOutput(state,
    1285              :                                                  "Chiller:Electric:ReformulatedEIR",
    1286              :                                                  this->Name,
    1287              :                                                  "Initial Design Size Reference Condenser Water Flow Rate [m3/s]",
    1288              :                                                  tmpCondVolFlowRate);
    1289              :                 }
    1290              :             } else {
    1291            0 :                 if (this->CondVolFlowRate > 0.0 && tmpCondVolFlowRate > 0.0) {
    1292            0 :                     Real64 CondVolFlowRateUser = this->CondVolFlowRate;
    1293            0 :                     if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1294            0 :                         BaseSizer::reportSizerOutput(state,
    1295              :                                                      "Chiller:Electric:ReformulatedEIR",
    1296              :                                                      this->Name,
    1297              :                                                      "Design Size Reference Condenser Water Flow Rate [m3/s]",
    1298              :                                                      tmpCondVolFlowRate,
    1299              :                                                      "User-Specified Reference Condenser Water Flow Rate [m3/s]",
    1300              :                                                      CondVolFlowRateUser);
    1301            0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    1302            0 :                             if ((std::abs(tmpCondVolFlowRate - CondVolFlowRateUser) / CondVolFlowRateUser) >
    1303            0 :                                 state.dataSize->AutoVsHardSizingThreshold) {
    1304            0 :                                 ShowMessage(state,
    1305            0 :                                             format("Size:ChillerElectricReformulatedEIR: Potential issue with equipment sizing for {}", this->Name));
    1306            0 :                                 ShowContinueError(state,
    1307            0 :                                                   format("User-Specified Reference Condenser Water Flow Rate of {:.5R} [m3/s]", CondVolFlowRateUser));
    1308            0 :                                 ShowContinueError(
    1309              :                                     state,
    1310            0 :                                     format("differs from Design Size Reference Condenser Water Flow Rate of {:.5R} [m3/s]", tmpCondVolFlowRate));
    1311            0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    1312            0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    1313              :                             }
    1314              :                         }
    1315              :                     }
    1316            0 :                     tmpCondVolFlowRate = CondVolFlowRateUser;
    1317              :                 }
    1318              :             }
    1319              :         }
    1320          234 :     } else {
    1321            5 :         if (this->CondVolFlowRateWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize &&
    1322            0 :             this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1323            0 :             ShowSevereError(state, "Autosizing of Reformulated Electric EIR Chiller condenser flow rate requires a condenser");
    1324            0 :             ShowContinueError(state, "loop Sizing:Plant object");
    1325            0 :             ShowContinueError(state, format("Occurs in Reformulated Electric EIR Chiller object={}", this->Name));
    1326            0 :             ErrorsFound = true;
    1327              :         }
    1328            5 :         tmpCondVolFlowRate = this->CondVolFlowRateWasAutoSized ? this->RefCap * 0.000114 : this->CondVolFlowRate;
    1329            5 :         if (this->CondVolFlowRateWasAutoSized && state.dataPlnt->PlantFinalSizesOkayToReport && (tmpCondVolFlowRate > 0.0) &&
    1330            0 :             this->CondenserType != DataPlant::CondenserType::WaterCooled) {
    1331            0 :             this->CondVolFlowRate = tmpCondVolFlowRate;
    1332            0 :             BaseSizer::reportSizerOutput(
    1333              :                 state, "Chiller:Electric:ReformulatedEIR", this->Name, "Design Size Reference Condenser Air Flow Rate [m3/s]", this->CondVolFlowRate);
    1334            6 :         } else if (!this->CondVolFlowRateWasAutoSized && state.dataPlnt->PlantFinalSizesOkayToReport && (this->CondVolFlowRate > 0.0) &&
    1335            1 :                    this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1336            1 :             BaseSizer::reportSizerOutput(state,
    1337              :                                          "Chiller:Electric:ReformulatedEIR",
    1338              :                                          this->Name,
    1339              :                                          "User-Specified Reference Condenser Water Flow Rate [m3/s]",
    1340              :                                          this->CondVolFlowRate);
    1341              :         }
    1342              :     }
    1343              : 
    1344          239 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1345              :         // save the reference condenser water volumetric flow rate for use by the condenser water loop sizing algorithms
    1346          239 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->CondInletNodeNum, tmpCondVolFlowRate);
    1347              :     }
    1348              : 
    1349          239 :     if (this->HeatRecActive) {
    1350              :         Real64 tmpHeatRecVolFlowRate;
    1351            0 :         if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1352            0 :             tmpHeatRecVolFlowRate = tmpCondVolFlowRate * this->HeatRecCapacityFraction;
    1353              :         } else {
    1354            0 :             if (this->EvapVolFlowRateWasAutoSized) {
    1355            0 :                 tmpHeatRecVolFlowRate = tmpEvapVolFlowRate;
    1356              :             } else {
    1357            0 :                 tmpHeatRecVolFlowRate = this->EvapVolFlowRate;
    1358              :             }
    1359            0 :             tmpHeatRecVolFlowRate *= (1.0 + (1.0 / this->RefCOP)) * this->CompPowerToCondenserFrac * this->HeatRecCapacityFraction;
    1360              :         }
    1361            0 :         if (!this->DesignHeatRecVolFlowRateWasAutoSized) {
    1362            0 :             tmpHeatRecVolFlowRate = this->DesignHeatRecVolFlowRate;
    1363              :         }
    1364            0 :         if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
    1365            0 :             if (this->DesignHeatRecVolFlowRateWasAutoSized) {
    1366            0 :                 this->DesignHeatRecVolFlowRate = tmpHeatRecVolFlowRate;
    1367            0 :                 if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1368            0 :                     BaseSizer::reportSizerOutput(state,
    1369              :                                                  "Chiller:Electric:ReformulatedEIR",
    1370              :                                                  this->Name,
    1371              :                                                  "Design Size Design Heat Recovery Fluid Flow Rate [m3/s]",
    1372              :                                                  tmpHeatRecVolFlowRate);
    1373              :                 }
    1374            0 :                 if (state.dataPlnt->PlantFirstSizesOkayToReport) {
    1375            0 :                     BaseSizer::reportSizerOutput(state,
    1376              :                                                  "Chiller:Electric:ReformulatedEIR",
    1377              :                                                  this->Name,
    1378              :                                                  "Initial Design Size Design Heat Recovery Fluid Flow Rate [m3/s]",
    1379              :                                                  tmpHeatRecVolFlowRate);
    1380              :                 }
    1381              :             } else {
    1382            0 :                 if (this->DesignHeatRecVolFlowRate > 0.0 && tmpHeatRecVolFlowRate > 0.0) {
    1383            0 :                     Real64 DesignHeatRecVolFlowRateUser = this->DesignHeatRecVolFlowRate;
    1384            0 :                     if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1385            0 :                         BaseSizer::reportSizerOutput(state,
    1386              :                                                      "Chiller:Electric:ReformulatedEIR",
    1387              :                                                      this->Name,
    1388              :                                                      "Design Size Design Heat Recovery Fluid Flow Rate [m3/s]",
    1389              :                                                      tmpHeatRecVolFlowRate,
    1390              :                                                      "User-Specified Design Heat Recovery Fluid Flow Rate [m3/s]",
    1391              :                                                      DesignHeatRecVolFlowRateUser);
    1392            0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    1393            0 :                             if ((std::abs(tmpHeatRecVolFlowRate - DesignHeatRecVolFlowRateUser) / DesignHeatRecVolFlowRateUser) >
    1394            0 :                                 state.dataSize->AutoVsHardSizingThreshold) {
    1395            0 :                                 ShowMessage(state,
    1396            0 :                                             format("Size:ChillerElectricReformulatedEIR: Potential issue with equipment sizing for {}", this->Name));
    1397            0 :                                 ShowContinueError(
    1398              :                                     state,
    1399            0 :                                     format("User-Specified Design Heat Recovery Fluid Flow Rate of {:.5R} [m3/s]", DesignHeatRecVolFlowRateUser));
    1400            0 :                                 ShowContinueError(
    1401              :                                     state,
    1402            0 :                                     format("differs from Design Size Design Heat Recovery Fluid Flow Rate of {:.5R} [m3/s]", tmpHeatRecVolFlowRate));
    1403            0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    1404            0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    1405              :                             }
    1406              :                         }
    1407              :                     }
    1408            0 :                     tmpHeatRecVolFlowRate = DesignHeatRecVolFlowRateUser;
    1409              :                 }
    1410              :             }
    1411              :         }
    1412              :         // save the reference heat recovery fluid volumetric flow rate
    1413            0 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->HeatRecInletNodeNum, tmpHeatRecVolFlowRate);
    1414              :     }
    1415              : 
    1416          239 :     std::string equipName; // Name of chiller
    1417          239 :     if (state.dataPlnt->PlantFinalSizesOkayToReport) {
    1418              : 
    1419           43 :         Real64 IPLVSI_rpt_std229 = 0.0;
    1420           43 :         Real64 IPLVIP_rpt_std229 = 0.0;
    1421              : 
    1422           43 :         if (this->MySizeFlag) {
    1423           43 :             Real64 IPLVSI = 0.0;
    1424           43 :             Real64 IPLVIP = 0.0;
    1425           43 :             StandardRatings::CalcChillerIPLV(state,
    1426           43 :                                              this->Name,
    1427              :                                              DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR,
    1428              :                                              this->RefCap,
    1429              :                                              this->RefCOP,
    1430              :                                              this->CondenserType,
    1431              :                                              this->ChillerCapFTIndex,
    1432              :                                              this->ChillerEIRFTIndex,
    1433              :                                              this->ChillerEIRFPLRIndex,
    1434              :                                              this->MinUnloadRat,
    1435              :                                              IPLVSI,
    1436              :                                              IPLVIP,
    1437           43 :                                              this->CondVolFlowRate,
    1438           43 :                                              this->CDPlantLoc.loopNum,
    1439           43 :                                              this->CompPowerToCondenserFrac);
    1440              : 
    1441           43 :             IPLVSI_rpt_std229 = IPLVSI;
    1442           43 :             IPLVIP_rpt_std229 = IPLVIP;
    1443              : 
    1444           43 :             this->MySizeFlag = false;
    1445              :         }
    1446              :         // create predefined report
    1447           43 :         equipName = this->Name;
    1448           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechType, equipName, "Chiller:Electric:ReformulatedEIR");
    1449           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechNomEff, equipName, this->RefCOP);
    1450           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechNomCap, equipName, this->RefCap);
    1451              : 
    1452              :         // std 229 new Chiller table
    1453           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerType, this->Name, "Chiller:Electric:ReformulatedEIR");
    1454           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerRefCap, this->Name, this->RefCap);
    1455           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerRefEff, this->Name, this->RefCOP); // Eff == COP?
    1456           86 :         OutputReportPredefined::PreDefTableEntry(
    1457           43 :             state, state.dataOutRptPredefined->pdchChillerRatedCap, this->Name, this->RefCap); // did not find rated cap
    1458           86 :         OutputReportPredefined::PreDefTableEntry(
    1459           43 :             state, state.dataOutRptPredefined->pdchChillerRatedEff, this->Name, this->RefCOP); // did not find rated eff or cop ; also Eff == COP?
    1460           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerIPLVinSI, this->Name, IPLVSI_rpt_std229);
    1461           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerIPLVinIP, this->Name, IPLVIP_rpt_std229);
    1462           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1463           43 :                                                  state.dataOutRptPredefined->pdchChillerPlantloopName,
    1464              :                                                  this->Name,
    1465           86 :                                                  (this->CWPlantLoc.loop != nullptr) ? this->CWPlantLoc.loop->Name : "N/A");
    1466           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1467           43 :                                                  state.dataOutRptPredefined->pdchChillerPlantloopBranchName,
    1468              :                                                  this->Name,
    1469           86 :                                                  (this->CWPlantLoc.branch != nullptr) ? this->CWPlantLoc.branch->Name : "N/A");
    1470           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1471           43 :                                                  state.dataOutRptPredefined->pdchChillerCondLoopName,
    1472              :                                                  this->Name,
    1473           86 :                                                  (this->CDPlantLoc.loop != nullptr) ? this->CDPlantLoc.loop->Name : "N/A");
    1474           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1475           43 :                                                  state.dataOutRptPredefined->pdchChillerCondLoopBranchName,
    1476              :                                                  this->Name,
    1477           86 :                                                  (this->CDPlantLoc.branch != nullptr) ? this->CDPlantLoc.branch->Name : "N/A");
    1478           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerMinPLR, this->Name, this->MinPartLoadRat);
    1479           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerFuelType, this->Name, "Electricity");
    1480           86 :         OutputReportPredefined::PreDefTableEntry(
    1481           43 :             state, state.dataOutRptPredefined->pdchChillerRatedEntCondTemp, this->Name, this->TempRefCondIn); // Rated==Ref?
    1482           86 :         OutputReportPredefined::PreDefTableEntry(
    1483           43 :             state, state.dataOutRptPredefined->pdchChillerRatedLevEvapTemp, this->Name, this->TempRefEvapOut); // Rated==Ref?
    1484           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerRefEntCondTemp, this->Name, this->TempRefCondIn);
    1485           43 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchChillerRefLevEvapTemp, this->Name, this->TempRefEvapOut);
    1486              : 
    1487           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1488           43 :                                                  state.dataOutRptPredefined->pdchChillerDesSizeRefCHWFlowRate,
    1489              :                                                  this->Name,
    1490              :                                                  this->EvapMassFlowRateMax); // flowrate Max==DesignSizeRef flowrate?
    1491           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1492           43 :                                                  state.dataOutRptPredefined->pdchChillerDesSizeRefCondFluidFlowRate,
    1493              :                                                  this->Name,
    1494              :                                                  this->CondMassFlowRateMax); // Cond flowrate Max==DesignSizeRef Cond flowrate?
    1495           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1496           43 :                                                  state.dataOutRptPredefined->pdchChillerHeatRecPlantloopName,
    1497              :                                                  this->Name,
    1498          129 :                                                  (this->HRPlantLoc.loop != nullptr) ? this->HRPlantLoc.loop->Name : "N/A");
    1499           86 :         OutputReportPredefined::PreDefTableEntry(state,
    1500           43 :                                                  state.dataOutRptPredefined->pdchChillerHeatRecPlantloopBranchName,
    1501              :                                                  this->Name,
    1502          129 :                                                  (this->HRPlantLoc.branch != nullptr) ? this->HRPlantLoc.branch->Name : "N/A");
    1503           86 :         OutputReportPredefined::PreDefTableEntry(
    1504           43 :             state, state.dataOutRptPredefined->pdchChillerRecRelCapFrac, this->Name, this->HeatRecCapacityFraction);
    1505              :     }
    1506              : 
    1507              :     // Only check performance curves if Capacity and volumetric flow rate are greater than 0
    1508          239 :     if (this->RefCap > 0.0 && this->CondVolFlowRate > 0.0) {
    1509              :         //   Check the CAP-FT, EIR-FT, and PLR curves at reference conditions and warn user if different from 1.0 by more than +-10%
    1510           71 :         if (this->ChillerCapFTIndex > 0) {
    1511           71 :             Real64 CurveVal = Curve::CurveValue(state, this->ChillerCapFTIndex, this->TempRefEvapOut, this->TempRefCondOut);
    1512           71 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1513            0 :                 ShowWarningError(state, "Capacity ratio as a function of temperature curve output is not equal to 1.0");
    1514            0 :                 ShowContinueError(state, format("(+ or - 10%) at reference conditions for Chiller:Electric:ReformulatedEIR = {}", equipName));
    1515            0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1516              :             }
    1517           71 :             Curve::GetCurveMinMaxValues(state,
    1518              :                                         this->ChillerCapFTIndex,
    1519           71 :                                         this->ChillerCAPFTXTempMin,
    1520           71 :                                         this->ChillerCAPFTXTempMax,
    1521           71 :                                         this->ChillerCAPFTYTempMin,
    1522           71 :                                         this->ChillerCAPFTYTempMax);
    1523              :         }
    1524              : 
    1525           71 :         if (this->ChillerEIRFTIndex > 0) {
    1526           71 :             Real64 CurveVal = Curve::CurveValue(state, this->ChillerEIRFTIndex, this->TempRefEvapOut, this->TempRefCondOut);
    1527           71 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1528            0 :                 ShowWarningError(state, "Energy input ratio as a function of temperature curve output is not equal to 1.0");
    1529            0 :                 ShowContinueError(state, format("(+ or - 10%) at reference conditions for Chiller:Electric:ReformulatedEIR = {}", equipName));
    1530            0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1531              :             }
    1532           71 :             Curve::GetCurveMinMaxValues(state,
    1533              :                                         this->ChillerEIRFTIndex,
    1534           71 :                                         this->ChillerEIRFTXTempMin,
    1535           71 :                                         this->ChillerEIRFTXTempMax,
    1536           71 :                                         this->ChillerEIRFTYTempMin,
    1537           71 :                                         this->ChillerEIRFTYTempMax);
    1538              :         }
    1539              : 
    1540           71 :         if (this->ChillerEIRFPLRIndex > 0) {
    1541           71 :             Real64 CurveVal(0.0); // Used to verify EIR-FT/CAP-FT curves = 1 at reference conditions
    1542           71 :             if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1543           70 :                 CurveVal = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, this->TempRefCondOut, 1.0);
    1544            1 :             } else if (this->PartLoadCurveType == PLR::Lift) {
    1545            1 :                 CurveVal = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, 1.0, 1.0, 0.0);
    1546              :             }
    1547           71 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1548            0 :                 ShowWarningError(state, "Energy input ratio as a function of part-load ratio curve output is not equal to 1.0");
    1549            0 :                 ShowContinueError(state, format("(+ or - 10%) at reference conditions for Chiller:Electric:ReformulatedEIR = {}", equipName));
    1550            0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1551              :             }
    1552              : 
    1553           71 :             if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1554           70 :                 Curve::GetCurveMinMaxValues(state,
    1555              :                                             this->ChillerEIRFPLRIndex,
    1556           70 :                                             this->ChillerEIRFPLRTempMin,
    1557           70 :                                             this->ChillerEIRFPLRTempMax,
    1558           70 :                                             this->ChillerEIRFPLRPLRMin,
    1559           70 :                                             this->ChillerEIRFPLRPLRMax);
    1560            1 :             } else if (this->PartLoadCurveType == PLR::Lift) {
    1561            1 :                 Curve::GetCurveMinMaxValues(state,
    1562              :                                             this->ChillerEIRFPLRIndex,
    1563            1 :                                             this->ChillerLiftNomMin,
    1564            1 :                                             this->ChillerLiftNomMax,
    1565            1 :                                             this->ChillerEIRFPLRPLRMin,
    1566            1 :                                             this->ChillerEIRFPLRPLRMax,
    1567            1 :                                             this->ChillerTdevNomMin,
    1568            1 :                                             this->ChillerTdevNomMax);
    1569              :             }
    1570              : 
    1571           71 :             if (this->ChillerEIRFPLRPLRMin < 0 || this->ChillerEIRFPLRPLRMin >= this->ChillerEIRFPLRPLRMax || this->ChillerEIRFPLRPLRMin > 1) {
    1572            0 :                 ShowSevereError(state,
    1573            0 :                                 format("Invalid minimum value of PLR = {:.3T} in bicubic curve = {} which is used",
    1574            0 :                                        this->ChillerEIRFPLRPLRMin,
    1575            0 :                                        this->EIRFPLRName));
    1576            0 :                 ShowContinueError(state, format("by Chiller:Electric:ReformulatedEIR = {}.", equipName));
    1577            0 :                 ShowContinueError(state, "The minimum value of PLR [y] must be from zero to 1, and less than the maximum value of PLR.");
    1578            0 :                 ErrorsFound = true;
    1579              :             }
    1580           71 :             if (this->ChillerEIRFPLRPLRMax > 1.1 || this->ChillerEIRFPLRPLRMax <= this->ChillerEIRFPLRPLRMin || this->ChillerEIRFPLRPLRMax < 0) {
    1581            0 :                 ShowSevereError(state,
    1582            0 :                                 format("Invalid maximum value of PLR = {:.3T} in bicubic curve = {} which is used",
    1583            0 :                                        this->ChillerEIRFPLRPLRMax,
    1584            0 :                                        this->EIRFPLRName));
    1585            0 :                 ShowContinueError(state, format("by Chiller:Electric:ReformulatedEIR = {}.", equipName));
    1586            0 :                 ShowContinueError(state, "The maximum value of PLR [y] must be from zero to 1.1, and greater than the minimum value of PLR.");
    1587            0 :                 ErrorsFound = true;
    1588              :             }
    1589              :             //     calculate the condenser outlet temp proportional to PLR and test the EIRFPLR curve output for negative numbers.
    1590              :         }
    1591              : 
    1592              :         //  Initialize condenser reference inlet temperature (not a user input)
    1593           71 :         Real64 Density = this->CDPlantLoc.loop->glycol->getDensity(state, this->TempRefCondOut, RoutineName);
    1594              : 
    1595           71 :         Real64 SpecificHeat = this->CDPlantLoc.loop->glycol->getSpecificHeat(state, this->TempRefCondOut, RoutineName);
    1596           71 :         Real64 CondenserCapacity = this->RefCap * (1.0 + (1.0 / this->RefCOP) * this->CompPowerToCondenserFrac);
    1597           71 :         Real64 DeltaTCond = (CondenserCapacity) / (this->CondVolFlowRate * Density * SpecificHeat);
    1598           71 :         this->TempRefCondIn = this->TempRefCondOut - DeltaTCond;
    1599              : 
    1600           71 :         if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1601              :             //     Check EIRFPLR curve output. Calculate condenser inlet temp based on reference condenser outlet temp,
    1602              :             //     chiller capacity, and mass flow rate. Starting with the calculated condenser inlet temp and PLR = 0,
    1603              :             //     calculate the condenser outlet temp proportional to PLR and test the EIRFPLR curve output for negative numbers.
    1604           70 :             bool FoundNegValue = false;
    1605           70 :             Array1D<Real64> CurveValArray(11, 0.0); // Used to evaluate EIRFPLR curve objects
    1606           70 :             Array1D<Real64> CondTempArray(11, 0.0); // Used to evaluate EIRFPLR curve objects
    1607              : 
    1608           70 :             if (this->ChillerEIRFPLRIndex > 0) {
    1609           70 :                 CondTempArray = 0.0;
    1610          840 :                 for (int CurveCheck = 0; CurveCheck <= 10; ++CurveCheck) {
    1611          770 :                     Real64 PLRTemp = CurveCheck / 10.0;
    1612          770 :                     Real64 CondTemp = this->TempRefCondIn + (DeltaTCond * PLRTemp);
    1613          770 :                     CondTemp = min(CondTemp, this->ChillerEIRFPLRTempMax);
    1614          770 :                     CondTemp = max(CondTemp, this->ChillerEIRFPLRTempMin);
    1615              :                     Real64 CurveValTmp; // Used to evaluate EIRFPLR curve objects
    1616          770 :                     if (PLRTemp < this->ChillerEIRFPLRPLRMin) {
    1617          137 :                         CurveValTmp = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, CondTemp, this->ChillerEIRFPLRPLRMin);
    1618              :                     } else {
    1619          633 :                         CurveValTmp = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, CondTemp, PLRTemp);
    1620              :                     }
    1621          770 :                     if (CurveValTmp < 0.0) {
    1622            0 :                         FoundNegValue = true;
    1623              :                     }
    1624          770 :                     CurveValArray(CurveCheck + 1) = int(CurveValTmp * 100.0) / 100.0;
    1625          770 :                     CondTempArray(CurveCheck + 1) = int(CondTemp * 100.0) / 100.0;
    1626              :                 }
    1627              :             }
    1628              : 
    1629              :             //     Output warning message if negative values are found in the EIRFPLR curve output. Results in Fatal error.
    1630           70 :             if (FoundNegValue) {
    1631            0 :                 ShowWarningError(state, "Energy input to cooling output ratio function of part-load ratio curve shows negative values ");
    1632            0 :                 ShowContinueError(state, format("for  Chiller:Electric:ReformulatedEIR = {}.", equipName));
    1633            0 :                 ShowContinueError(state,
    1634              :                                   "EIR as a function of PLR curve output at various part-load ratios and condenser water temperatures shown below:");
    1635            0 :                 ShowContinueError(state, "PLR           =    0.00   0.10   0.20   0.30   0.40   0.50   0.60   0.70   0.80   0.90   1.00");
    1636            0 :                 ShowContinueError(state, fmt::format("Cond Temp(C) = {:7.2F}", fmt::join(CondTempArray, " ")));
    1637            0 :                 ShowContinueError(state, fmt::format("Curve Output = {:7.2F}", fmt::join(CurveValArray, " ")));
    1638            0 :                 ErrorsFound = true;
    1639              :             }
    1640           70 :         }
    1641           71 :     } else { // just get curve min/max values if capacity or cond volume flow rate = 0
    1642          168 :         Curve::GetCurveMinMaxValues(state,
    1643              :                                     this->ChillerCapFTIndex,
    1644          168 :                                     this->ChillerCAPFTXTempMin,
    1645          168 :                                     this->ChillerCAPFTXTempMax,
    1646          168 :                                     this->ChillerCAPFTYTempMin,
    1647          168 :                                     this->ChillerCAPFTYTempMax);
    1648          168 :         Curve::GetCurveMinMaxValues(state,
    1649              :                                     this->ChillerEIRFTIndex,
    1650          168 :                                     this->ChillerEIRFTXTempMin,
    1651          168 :                                     this->ChillerEIRFTXTempMax,
    1652          168 :                                     this->ChillerEIRFTYTempMin,
    1653          168 :                                     this->ChillerEIRFTYTempMax);
    1654          168 :         if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1655          164 :             Curve::GetCurveMinMaxValues(state,
    1656              :                                         this->ChillerEIRFPLRIndex,
    1657          164 :                                         this->ChillerEIRFPLRTempMin,
    1658          164 :                                         this->ChillerEIRFPLRTempMax,
    1659          164 :                                         this->ChillerEIRFPLRPLRMin,
    1660          164 :                                         this->ChillerEIRFPLRPLRMax);
    1661            4 :         } else if (this->PartLoadCurveType == PLR::Lift) {
    1662            4 :             Curve::GetCurveMinMaxValues(state,
    1663              :                                         this->ChillerEIRFPLRIndex,
    1664            4 :                                         this->ChillerLiftNomMin,
    1665            4 :                                         this->ChillerLiftNomMax,
    1666            4 :                                         this->ChillerEIRFPLRPLRMin,
    1667            4 :                                         this->ChillerEIRFPLRPLRMax,
    1668            4 :                                         this->ChillerTdevNomMin,
    1669            4 :                                         this->ChillerTdevNomMax);
    1670              :         }
    1671              :     }
    1672              : 
    1673          239 :     if (ErrorsFound) {
    1674            0 :         ShowFatalError(state, "Preceding sizing errors cause program termination");
    1675              :     }
    1676          239 : }
    1677              : 
    1678      2717561 : void ReformulatedEIRChillerSpecs::control(EnergyPlusData &state, Real64 &MyLoad, bool const RunFlag, bool const FirstIteration)
    1679              : {
    1680              : 
    1681              :     // SUBROUTINE INFORMATION:
    1682              :     //       AUTHOR         Lixing Gu, FSEC
    1683              :     //       DATE WRITTEN   July 2006
    1684              : 
    1685              :     // PURPOSE OF THIS SUBROUTINE:
    1686              :     // Simulate a vapor compression chiller using the reformulated model developed by Mark Hydeman
    1687              : 
    1688              :     // METHODOLOGY EMPLOYED:
    1689              :     // Use empirical curve fits to model performance at off-design conditions. This subroutine
    1690              :     // calls Subroutines CalcReformEIRChillerModel and General::SolveRoot to obtain solution.
    1691              :     // The actual chiller performance calculations are in Subroutine CalcReformEIRChillerModel.
    1692              : 
    1693              :     // REFERENCES:
    1694              :     // 1. Hydeman, M., P. Sreedharan, N. Webb, and S. Blanc. 2002. "Development and Testing of a Reformulated
    1695              :     //    Regression-Based Electric Chiller Model". ASHRAE Transactions, HI-02-18-2, Vol 108, Part 2, pp. 1118-1127.
    1696              : 
    1697      2717561 :     Real64 constexpr Acc(0.0001); // Accuracy control for General::SolveRoot
    1698      2717561 :     int constexpr MaxIter(500);   // Iteration control for General::SolveRoot
    1699              : 
    1700      2717561 :     if (MyLoad >= 0.0 || !RunFlag) {
    1701      1678067 :         this->calculate(state, MyLoad, RunFlag, state.dataLoopNodes->Node(this->CondInletNodeNum).Temp);
    1702              :     } else {
    1703              : 
    1704              :         //  Find min/max condenser outlet temperature used by curve objects
    1705              : 
    1706              :         // Minimum condenser leaving temperature allowed by CAPFT curve [C]
    1707      1039494 :         Real64 CAPFTYTmin = this->ChillerCAPFTYTempMin;
    1708              : 
    1709              :         // Minimum condenser leaving temperature allowed by EIRFT curve [C]
    1710      1039494 :         Real64 Tmin(-99); // Minimum condenser leaving temperature allowed by curve objects [C]
    1711              : 
    1712      1039494 :         Real64 EIRFTYTmin = this->ChillerEIRFTYTempMin;
    1713      1039494 :         if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1714              :             // Minimum condenser leaving temperature allowed by EIRFPLR curve [C]
    1715      1023826 :             Real64 EIRFPLRTmin = this->ChillerEIRFPLRTempMin;
    1716      1023826 :             Tmin = min(CAPFTYTmin, EIRFTYTmin, EIRFPLRTmin);
    1717        15668 :         } else if (this->PartLoadCurveType == PLR::Lift) {
    1718        15668 :             Tmin = min(CAPFTYTmin, EIRFTYTmin);
    1719              :         }
    1720              : 
    1721              :         // Maximum condenser leaving temperature allowed by CAPFT curve [C]
    1722      1039494 :         Real64 CAPFTYTmax = this->ChillerCAPFTYTempMax;
    1723              : 
    1724      1039494 :         Real64 Tmax(-99); // Maximum condenser leaving temperature allowed by curve objects [C]
    1725              : 
    1726              :         // Maximum condenser leaving temperature allowed by EIRFT curve [C]
    1727      1039494 :         Real64 EIRFTYTmax = this->ChillerEIRFTYTempMax;
    1728      1039494 :         if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    1729              :             // Maximum condenser leaving temperature allowed by EIRFPLR curve [C]
    1730      1023826 :             Real64 EIRFPLRTmax = this->ChillerEIRFPLRTempMax;
    1731      1023826 :             Tmax = max(CAPFTYTmax, EIRFTYTmax, EIRFPLRTmax);
    1732        15668 :         } else if (this->PartLoadCurveType == PLR::Lift) {
    1733        15668 :             Tmax = max(CAPFTYTmax, EIRFTYTmax);
    1734              :         }
    1735              : 
    1736              :         //  Check that condenser outlet temperature is within curve object limits prior to calling RegulaFalsi
    1737      1039494 :         this->calculate(state, MyLoad, RunFlag, Tmin);
    1738              : 
    1739              :         // Condenser outlet temperature when using Tmin as input to calculate [C]
    1740      1039494 :         Real64 CondTempMin = this->CondOutletTemp;
    1741              : 
    1742              :         //  Check that condenser outlet temperature is within curve object limits prior to calling RegulaFalsi
    1743      1039494 :         this->calculate(state, MyLoad, RunFlag, Tmax);
    1744              : 
    1745              :         // Condenser outlet temperature when using Tmax as input to CalcReformEIRChillerModel [C]
    1746      1039494 :         Real64 CondTempMax = this->CondOutletTemp;
    1747              : 
    1748      1039494 :         if (CondTempMin > Tmin && CondTempMax < Tmax) {
    1749              : 
    1750              :             int SolFla;                    // Feedback flag from General::SolveRoot
    1751      1039494 :             Real64 FalsiCondOutTemp = 0.0; // RegulaFalsi condenser outlet temperature result [C]
    1752      1039494 :             Real64 thisLoad =
    1753      1039494 :                 MyLoad; // using a temporary because a reference is necessary in the lambda, but we don't want to overwrite the outer value
    1754      5350287 :             auto f = [&state, this, &thisLoad, RunFlag](Real64 FalsiCondOutTemp) {
    1755      5350287 :                 this->calculate(state, thisLoad, RunFlag, FalsiCondOutTemp);
    1756      5350287 :                 return FalsiCondOutTemp - this->CondOutletTemp; // CondOutletTemp is module level variable, final value used for reporting
    1757      1039494 :             };
    1758      1039494 :             General::SolveRoot(state, Acc, MaxIter, SolFla, FalsiCondOutTemp, f, Tmin, Tmax);
    1759              : 
    1760      1039494 :             if (SolFla == -1) {
    1761            0 :                 if (!state.dataGlobal->WarmupFlag) {
    1762            0 :                     ++this->IterLimitExceededNum;
    1763            0 :                     if (this->IterLimitExceededNum == 1) {
    1764            0 :                         ShowWarningError(
    1765              :                             state,
    1766            0 :                             format("{}: Iteration limit exceeded calculating condenser outlet temperature and non-converged temperature is used",
    1767            0 :                                    this->Name));
    1768              :                     } else {
    1769            0 :                         ShowRecurringWarningErrorAtEnd(state,
    1770            0 :                                                        this->Name + ": Iteration limit exceeded calculating condenser outlet temperature.",
    1771            0 :                                                        this->IterLimitErrIndex,
    1772            0 :                                                        this->CondOutletTemp,
    1773            0 :                                                        this->CondOutletTemp);
    1774              :                     }
    1775              :                 }
    1776      1039494 :             } else if (SolFla == -2) {
    1777            0 :                 if (!state.dataGlobal->WarmupFlag) {
    1778            0 :                     ++this->IterFailed;
    1779            0 :                     if (this->IterFailed == 1) {
    1780            0 :                         ShowWarningError(state,
    1781            0 :                                          format("{}: Solution found when calculating condenser outlet temperature. The inlet temperature will used "
    1782              :                                                 "and the simulation continues...",
    1783            0 :                                                 this->Name));
    1784            0 :                         ShowContinueError(state, format("Please check minimum and maximum values of x in EIRFPLR Curve {}", this->EIRFPLRName));
    1785              :                     } else {
    1786            0 :                         ShowRecurringWarningErrorAtEnd(state,
    1787            0 :                                                        this->Name + ": Solution is not found in calculating condenser outlet temperature.",
    1788            0 :                                                        this->IterFailedIndex,
    1789            0 :                                                        this->CondOutletTemp,
    1790            0 :                                                        this->CondOutletTemp);
    1791              :                     }
    1792              :                 }
    1793            0 :                 this->calculate(state, MyLoad, RunFlag, state.dataLoopNodes->Node(this->CondInletNodeNum).Temp);
    1794              :             }
    1795      1039494 :         } else {
    1796              :             //    If iteration is not possible, average the min/max condenser outlet temperature and manually determine solution
    1797            0 :             this->calculate(state, MyLoad, RunFlag, (CondTempMin + CondTempMax) / 2.0);
    1798            0 :             this->calculate(state, MyLoad, RunFlag, this->CondOutletTemp);
    1799              :         }
    1800              : 
    1801              :         //  Call subroutine to evaluate all performance curve min/max values against evaporator/condenser outlet temps and PLR
    1802      1039494 :         this->checkMinMaxCurveBoundaries(state, FirstIteration);
    1803              :     }
    1804      2717561 : }
    1805              : 
    1806            0 : void ReformulatedEIRChillerSpecs::calcHeatRecovery(EnergyPlusData &state,
    1807              :                                                    Real64 &QCond,              // Current condenser load [W]
    1808              :                                                    Real64 const CondMassFlow,  // Current condenser mass flow [kg/s]
    1809              :                                                    Real64 const condInletTemp, // Current condenser inlet temp [C]
    1810              :                                                    Real64 &QHeatRec            // Amount of heat recovered [W]
    1811              : )
    1812              : {
    1813              :     // SUBROUTINE INFORMATION:
    1814              :     //       AUTHOR:          Lixing Gu, FSEC
    1815              :     //       DATE WRITTEN:    July 2006
    1816              : 
    1817              :     // PURPOSE OF THIS SUBROUTINE:
    1818              :     //  Calculate the heat recovered from the chiller condenser
    1819              : 
    1820              :     static constexpr std::string_view RoutineName("EIRChillerHeatRecovery");
    1821              : 
    1822              :     // inlet node to the heat recovery heat exchanger
    1823            0 :     Real64 heatRecInletTemp = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp;
    1824            0 :     Real64 HeatRecMassFlowRate = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).MassFlowRate;
    1825              : 
    1826            0 :     Real64 CpHeatRec = this->HRPlantLoc.loop->glycol->getSpecificHeat(state, heatRecInletTemp, RoutineName);
    1827              :     Real64 CpCond;
    1828            0 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    1829            0 :         CpCond = this->CDPlantLoc.loop->glycol->getSpecificHeat(state, condInletTemp, RoutineName);
    1830              :     } else {
    1831            0 :         CpCond = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->HeatRecInletNodeNum).HumRat);
    1832              :     }
    1833              : 
    1834              :     // Before we modify the QCondenser, the total or original value is transferred to QTot
    1835            0 :     Real64 QTotal = QCond;
    1836              : 
    1837            0 :     if (this->HeatRecSetPointNodeNum == 0) { // use original algorithm that blends temps
    1838            0 :         Real64 TAvgIn = (HeatRecMassFlowRate * CpHeatRec * heatRecInletTemp + CondMassFlow * CpCond * condInletTemp) /
    1839            0 :                         (HeatRecMassFlowRate * CpHeatRec + CondMassFlow * CpCond);
    1840              : 
    1841            0 :         Real64 TAvgOut = QTotal / (HeatRecMassFlowRate * CpHeatRec + CondMassFlow * CpCond) + TAvgIn;
    1842              : 
    1843            0 :         QHeatRec = HeatRecMassFlowRate * CpHeatRec * (TAvgOut - heatRecInletTemp);
    1844            0 :         QHeatRec = max(QHeatRec, 0.0); // ensure non negative
    1845              :         // check if heat flow too large for physical size of bundle
    1846            0 :         QHeatRec = min(QHeatRec, this->HeatRecMaxCapacityLimit);
    1847              :     } else { // use new algorithm to meet setpoint
    1848            0 :         Real64 THeatRecSetPoint(0.0);
    1849              : 
    1850            0 :         switch (this->HRPlantLoc.loop->LoopDemandCalcScheme) {
    1851            0 :         case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
    1852            0 :             THeatRecSetPoint = state.dataLoopNodes->Node(this->HeatRecSetPointNodeNum).TempSetPoint;
    1853            0 :         } break;
    1854            0 :         case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
    1855            0 :             THeatRecSetPoint = state.dataLoopNodes->Node(this->HeatRecSetPointNodeNum).TempSetPointHi;
    1856            0 :         } break;
    1857            0 :         default: {
    1858            0 :             assert(false);
    1859              :         } break;
    1860              :         }
    1861              : 
    1862            0 :         Real64 QHeatRecToSetPoint = HeatRecMassFlowRate * CpHeatRec * (THeatRecSetPoint - heatRecInletTemp);
    1863            0 :         QHeatRecToSetPoint = max(QHeatRecToSetPoint, 0.0);
    1864            0 :         QHeatRec = min(QTotal, QHeatRecToSetPoint);
    1865              :         // check if heat flow too large for physical size of bundle
    1866            0 :         QHeatRec = min(QHeatRec, this->HeatRecMaxCapacityLimit);
    1867              :     }
    1868              : 
    1869              :     // check if limit on inlet is present and exceeded.
    1870            0 :     if (this->heatRecInletLimitSched != nullptr) {
    1871            0 :         Real64 HeatRecHighInletLimit = this->heatRecInletLimitSched->getCurrentVal();
    1872            0 :         if (heatRecInletTemp > HeatRecHighInletLimit) { // shut down heat recovery
    1873            0 :             QHeatRec = 0.0;
    1874              :         }
    1875              :     }
    1876              : 
    1877            0 :     QCond = QTotal - QHeatRec;
    1878              : 
    1879              :     // Calculate a new Heat Recovery Coil Outlet Temp
    1880            0 :     if (HeatRecMassFlowRate > 0.0) {
    1881            0 :         this->HeatRecOutletTemp = QHeatRec / (HeatRecMassFlowRate * CpHeatRec) + heatRecInletTemp;
    1882              :     } else {
    1883            0 :         this->HeatRecOutletTemp = heatRecInletTemp;
    1884              :     }
    1885            0 : }
    1886              : 
    1887      2717561 : void ReformulatedEIRChillerSpecs::update(EnergyPlusData &state, Real64 const MyLoad, bool const RunFlag)
    1888              : {
    1889              :     // SUBROUTINE INFORMATION:
    1890              :     //       AUTHOR:          Lixing Gu, FSEC
    1891              :     //       DATE WRITTEN:    July 2006
    1892              : 
    1893              :     // PURPOSE OF THIS SUBROUTINE:
    1894              :     //  Reporting
    1895              : 
    1896      2717561 :     if (MyLoad >= 0.0 || !RunFlag) { // Chiller not running so pass inlet states to outlet states
    1897              :         // Set node temperatures
    1898      1691843 :         state.dataLoopNodes->Node(this->EvapOutletNodeNum).Temp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    1899      1691843 :         state.dataLoopNodes->Node(this->CondOutletNodeNum).Temp = state.dataLoopNodes->Node(this->CondInletNodeNum).Temp;
    1900              : 
    1901      1691843 :         this->ChillerPartLoadRatio = 0.0;
    1902      1691843 :         this->ChillerCyclingRatio = 0.0;
    1903      1691843 :         this->ChillerFalseLoadRate = 0.0;
    1904      1691843 :         this->ChillerFalseLoad = 0.0;
    1905      1691843 :         this->Power = 0.0;
    1906      1691843 :         this->QEvaporator = 0.0;
    1907      1691843 :         this->QCondenser = 0.0;
    1908      1691843 :         this->Energy = 0.0;
    1909      1691843 :         this->EvapEnergy = 0.0;
    1910      1691843 :         this->CondEnergy = 0.0;
    1911      1691843 :         this->EvapInletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    1912      1691843 :         this->CondInletTemp = state.dataLoopNodes->Node(this->CondInletNodeNum).Temp;
    1913      1691843 :         this->CondOutletTemp = state.dataLoopNodes->Node(this->CondOutletNodeNum).Temp;
    1914      1691843 :         this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapOutletNodeNum).Temp;
    1915      1691843 :         this->ActualCOP = 0.0;
    1916              : 
    1917      1691843 :         if (this->HeatRecActive) {
    1918              : 
    1919            0 :             PlantUtilities::SafeCopyPlantNode(state, this->HeatRecInletNodeNum, this->HeatRecOutletNodeNum);
    1920            0 :             this->QHeatRecovery = 0.0;
    1921            0 :             this->EnergyHeatRecovery = 0.0;
    1922            0 :             this->HeatRecInletTemp = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp;
    1923            0 :             this->HeatRecOutletTemp = state.dataLoopNodes->Node(this->HeatRecOutletNodeNum).Temp;
    1924            0 :             this->HeatRecMassFlow = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).MassFlowRate;
    1925              :         }
    1926              : 
    1927              :     } else { // Chiller is running, so pass calculated values
    1928              :         // Set node temperatures
    1929      1025718 :         state.dataLoopNodes->Node(this->EvapOutletNodeNum).Temp = this->EvapOutletTemp;
    1930      1025718 :         state.dataLoopNodes->Node(this->CondOutletNodeNum).Temp = this->CondOutletTemp;
    1931              :         // Set node flow rates;  for these load based models
    1932              :         // assume that sufficient evaporator flow rate is available
    1933      1025718 :         this->ChillerFalseLoad = this->ChillerFalseLoadRate * state.dataHVACGlobal->TimeStepSysSec;
    1934      1025718 :         this->Energy = this->Power * state.dataHVACGlobal->TimeStepSysSec;
    1935      1025718 :         this->EvapEnergy = this->QEvaporator * state.dataHVACGlobal->TimeStepSysSec;
    1936      1025718 :         this->CondEnergy = this->QCondenser * state.dataHVACGlobal->TimeStepSysSec;
    1937      1025718 :         this->EvapInletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    1938      1025718 :         this->CondInletTemp = state.dataLoopNodes->Node(this->CondInletNodeNum).Temp;
    1939      1025718 :         this->CondOutletTemp = state.dataLoopNodes->Node(this->CondOutletNodeNum).Temp;
    1940      1025718 :         if (this->Power != 0.0) {
    1941      1025718 :             this->ActualCOP = (this->QEvaporator + this->ChillerFalseLoadRate) / this->Power;
    1942              :         } else {
    1943            0 :             this->ActualCOP = 0.0;
    1944              :         }
    1945              : 
    1946      1025718 :         if (this->HeatRecActive) {
    1947              : 
    1948            0 :             PlantUtilities::SafeCopyPlantNode(state, this->HeatRecInletNodeNum, this->HeatRecOutletNodeNum);
    1949            0 :             this->EnergyHeatRecovery = this->QHeatRecovery * state.dataHVACGlobal->TimeStepSysSec;
    1950            0 :             state.dataLoopNodes->Node(this->HeatRecOutletNodeNum).Temp = this->HeatRecOutletTemp;
    1951            0 :             this->HeatRecInletTemp = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).Temp;
    1952            0 :             this->HeatRecOutletTemp = state.dataLoopNodes->Node(this->HeatRecOutletNodeNum).Temp;
    1953            0 :             this->HeatRecMassFlow = state.dataLoopNodes->Node(this->HeatRecInletNodeNum).MassFlowRate;
    1954              :         }
    1955              :     }
    1956      2717561 : }
    1957              : 
    1958      9107342 : void ReformulatedEIRChillerSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad, bool const RunFlag, Real64 const FalsiCondOutTemp)
    1959              : {
    1960              : 
    1961              :     // SUBROUTINE INFORMATION:
    1962              :     //       AUTHOR         Lixing Gu, FSEC
    1963              :     //       DATE WRITTEN   July 2006
    1964              : 
    1965              :     //       MODIFIED
    1966              :     //       Aug. 2014, Rongpeng Zhang, added an additional part-load performance curve type
    1967              :     //       Jun. 2016, Rongpeng Zhang, applied the chiller supply water temperature sensor fault model
    1968              :     //       Nov. 2016, Rongpeng Zhang, added fouling chiller fault
    1969              : 
    1970              :     // PURPOSE OF THIS SUBROUTINE:
    1971              :     //  Simulate a vapor compression chiller using the reformulated model developed by Mark Hydeman
    1972              : 
    1973              :     // METHODOLOGY EMPLOYED:
    1974              :     //  Use empirical curve fits to model performance at off-design conditions
    1975              : 
    1976              :     // REFERENCES:
    1977              :     // 1. Hydeman, M., P. Sreedharan, N. Webb, and S. Blanc. 2002. "Development and Testing of a Reformulated
    1978              :     //    Regression-Based Electric Chiller Model". ASHRAE Transactions, HI-02-18-2, Vol 108, Part 2, pp. 1118-1127.
    1979              : 
    1980              :     static constexpr std::string_view RoutineName("CalcElecReformEIRChillerModel");
    1981              : 
    1982      9107342 :     this->ChillerPartLoadRatio = 0.0;
    1983      9107342 :     this->ChillerCyclingRatio = 0.0;
    1984      9107342 :     this->ChillerFalseLoadRate = 0.0;
    1985      9107342 :     this->EvapMassFlowRate = 0.0;
    1986      9107342 :     this->CondMassFlowRate = 0.0;
    1987      9107342 :     this->Power = 0.0;
    1988      9107342 :     this->QCondenser = 0.0;
    1989      9107342 :     this->QEvaporator = 0.0;
    1990      9107342 :     this->QHeatRecovery = 0.0;
    1991              : 
    1992              :     // Set performance curve outputs to 0.0 when chiller is off
    1993      9107342 :     this->ChillerCapFT = 0.0;
    1994      9107342 :     this->ChillerEIRFT = 0.0;
    1995      9107342 :     this->ChillerEIRFPLR = 0.0;
    1996      9107342 :     this->thermosiphonStatus = 0;
    1997              : 
    1998              :     // Set module-level chiller evap and condenser inlet temperature variables
    1999      9107342 :     Real64 condInletTemp = state.dataLoopNodes->Node(this->CondInletNodeNum).Temp;
    2000      9107342 :     this->CondInletTemp = condInletTemp; // needed for thermosiphon model
    2001              : 
    2002              :     // If no loop demand or chiller OFF, return
    2003              :     // If chiller load is 0 or chiller is not running then leave the subroutine. Before leaving
    2004              :     //  if the component control is SERIESACTIVE we set the component flow to inlet flow so that
    2005              :     //  flow resolver will not shut down the branch
    2006      9107342 :     if (MyLoad >= 0 || !RunFlag) {
    2007      1733171 :         if (this->EquipFlowCtrl == DataBranchAirLoopPlant::ControlType::SeriesActive ||
    2008      1535565 :             this->CWPlantLoc.side->FlowLock == DataPlant::FlowLock::Locked) {
    2009       965263 :             this->EvapMassFlowRate = state.dataLoopNodes->Node(this->EvapInletNodeNum).MassFlowRate;
    2010              :         }
    2011      1733171 :         if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    2012      1733171 :             if (DataPlant::CompData::getPlantComponent(state, this->CDPlantLoc).FlowCtrl == DataBranchAirLoopPlant::ControlType::SeriesActive) {
    2013            0 :                 this->CondMassFlowRate = state.dataLoopNodes->Node(this->CondInletNodeNum).MassFlowRate;
    2014              :             }
    2015              :         }
    2016              : 
    2017      1746947 :         return;
    2018              :     }
    2019              : 
    2020              :     // Chiller reference capacity [W]
    2021      7374171 :     Real64 ChillerRefCap = this->RefCap;
    2022              : 
    2023              :     // Reference coefficient of performance, from user input
    2024      7374171 :     Real64 ReferenceCOP = this->RefCOP;
    2025      7374171 :     this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapOutletNodeNum).Temp;
    2026              : 
    2027              :     // Evaporator low temp. limit cut off [C]
    2028      7374171 :     Real64 TempLowLimitEout = this->TempLowLimitEvapOut;
    2029              : 
    2030              :     // If there is a fault of chiller fouling
    2031      7474078 :     if (this->FaultyChillerFoulingFlag && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) &&
    2032        99907 :         (!state.dataGlobal->KickOffSimulation)) {
    2033        99907 :         int FaultIndex = this->FaultyChillerFoulingIndex;
    2034        99907 :         Real64 NomCap_ff = ChillerRefCap;
    2035        99907 :         Real64 ReferenceCOP_ff = ReferenceCOP;
    2036              : 
    2037              :         // calculate the Faulty Chiller Fouling Factor using fault information
    2038        99907 :         this->FaultyChillerFoulingFactor = state.dataFaultsMgr->FaultsChillerFouling(FaultIndex).CalFoulingFactor(state);
    2039              : 
    2040              :         // update the Chiller nominal capacity and COP at faulty cases
    2041        99907 :         ChillerRefCap = NomCap_ff * this->FaultyChillerFoulingFactor;
    2042        99907 :         ReferenceCOP = ReferenceCOP_ff * this->FaultyChillerFoulingFactor;
    2043              :     }
    2044              : 
    2045              :     // Set initial mass flow rates
    2046      7374171 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    2047      7374171 :         this->CondMassFlowRate = this->CondMassFlowRateMax;
    2048      7374171 :         PlantUtilities::SetComponentFlowRate(state, this->CondMassFlowRate, this->CondInletNodeNum, this->CondOutletNodeNum, this->CDPlantLoc);
    2049      7374171 :         PlantUtilities::PullCompInterconnectTrigger(
    2050      7374171 :             state, this->CWPlantLoc, this->CondMassFlowIndex, this->CDPlantLoc, DataPlant::CriteriaType::MassFlowRate, this->CondMassFlowRate);
    2051              : 
    2052      7374171 :         if (this->CondMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance) {
    2053        13604 :             MyLoad = 0.0;
    2054        13604 :             this->EvapMassFlowRate = 0.0;
    2055        13604 :             PlantUtilities::SetComponentFlowRate(state, this->EvapMassFlowRate, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    2056        13604 :             return;
    2057              :         }
    2058              :     }
    2059      7360567 :     Real64 FRAC = 1.0;
    2060      7360567 :     Real64 EvapOutletTempSetPoint(0.0); // Evaporator outlet temperature setpoint [C]
    2061      7360567 :     switch (this->CWPlantLoc.loop->LoopDemandCalcScheme) {
    2062      7360567 :     case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
    2063     15362097 :         if ((this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) ||
    2064      8001530 :             (this->CWPlantLoc.comp->CurOpSchemeType == DataPlant::OpScheme::CompSetPtBased) ||
    2065       640963 :             (state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint != DataLoopNode::SensedNodeFlagValue)) {
    2066              :             // there will be a valid setpoint on outlet
    2067      6719604 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint;
    2068              :         } else { // use plant loop overall setpoint
    2069       640963 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPoint;
    2070              :         }
    2071      7360567 :     } break;
    2072            0 :     case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
    2073            0 :         if ((this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) ||
    2074            0 :             (this->CWPlantLoc.comp->CurOpSchemeType == DataPlant::OpScheme::CompSetPtBased) ||
    2075            0 :             (state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi != DataLoopNode::SensedNodeFlagValue)) {
    2076              :             // there will be a valid setpoint on outlet
    2077            0 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi;
    2078              :         } else { // use plant loop overall setpoint
    2079            0 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPointHi;
    2080              :         }
    2081            0 :     } break;
    2082            0 :     default: {
    2083            0 :         assert(false);
    2084              :     } break;
    2085              :     }
    2086              : 
    2087              :     // If there is a fault of Chiller SWT Sensor
    2088      7360567 :     if (this->FaultyChillerSWTFlag && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) && (!state.dataGlobal->KickOffSimulation)) {
    2089        50282 :         int FaultIndex = this->FaultyChillerSWTIndex;
    2090        50282 :         Real64 EvapOutletTempSetPoint_ff = EvapOutletTempSetPoint;
    2091              : 
    2092              :         // calculate the sensor offset using fault information
    2093        50282 :         this->FaultyChillerSWTOffset = state.dataFaultsMgr->FaultsChillerSWTSensor(FaultIndex).CalFaultOffsetAct(state);
    2094              :         // update the EvapOutletTempSetPoint
    2095              :         EvapOutletTempSetPoint =
    2096        50282 :             max(this->TempLowLimitEvapOut,
    2097        50282 :                 min(state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp, EvapOutletTempSetPoint_ff - this->FaultyChillerSWTOffset));
    2098        50282 :         this->FaultyChillerSWTOffset = EvapOutletTempSetPoint_ff - EvapOutletTempSetPoint;
    2099              :     }
    2100              : 
    2101              :     // correct temperature if using heat recovery
    2102              :     // use report values for latest valid calculation, lagged somewhat
    2103      7360567 :     if (this->HeatRecActive) {
    2104            0 :         if ((this->QHeatRecovery + this->QCondenser) > 0.0) { // protect div by zero
    2105            0 :             this->ChillerCondAvgTemp =
    2106            0 :                 (this->QHeatRecovery * this->HeatRecOutletTemp + this->QCondenser * this->CondOutletTemp) / (this->QHeatRecovery + this->QCondenser);
    2107              :         } else {
    2108            0 :             this->ChillerCondAvgTemp = FalsiCondOutTemp;
    2109              :         }
    2110              :     } else {
    2111      7360567 :         this->ChillerCondAvgTemp = FalsiCondOutTemp;
    2112              :     }
    2113              : 
    2114              :     // Get capacity curve info with respect to CW setpoint and leaving condenser water temps
    2115      7360567 :     this->ChillerCapFT = max(0.0, Curve::CurveValue(state, this->ChillerCapFTIndex, EvapOutletTempSetPoint, this->ChillerCondAvgTemp));
    2116              : 
    2117              :     // Available chiller capacity as a function of temperature
    2118      7360567 :     Real64 AvailChillerCap = ChillerRefCap * this->ChillerCapFT;
    2119              : 
    2120      7360567 :     this->EvapMassFlowRate = state.dataLoopNodes->Node(this->EvapInletNodeNum).MassFlowRate;
    2121              :     //   Some other component set the flow to 0. No reason to continue with calculations.
    2122      7360567 :     if (this->EvapMassFlowRate == 0.0) {
    2123          172 :         MyLoad = 0.0;
    2124          172 :         return;
    2125              :     }
    2126              : 
    2127              :     // This chiller is currently has only a water-cooled condenser
    2128              : 
    2129              :     // Calculate water side load
    2130      7360395 :     Real64 Cp = this->CWPlantLoc.loop->glycol->getSpecificHeat(state, state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp, RoutineName);
    2131              : 
    2132              :     // actual load to be met by chiller. This value is compared to MyLoad
    2133              :     // and reset when necessary since this chiller can cycle, the load passed
    2134              :     // should be the actual load.  Instead the minimum PLR * RefCap is
    2135              :     // passed in.
    2136      7360395 :     Real64 TempLoad = state.dataLoopNodes->Node(this->EvapInletNodeNum).MassFlowRateMaxAvail * Cp *
    2137      7360395 :                       (state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapOutletTempSetPoint);
    2138              : 
    2139      7360395 :     TempLoad = max(0.0, TempLoad);
    2140              : 
    2141              :     // MyLoad is capped at minimum PLR * RefCap, adjust load to actual water side load because this chiller can cycle
    2142      7360395 :     if (std::abs(MyLoad) > TempLoad) {
    2143         7241 :         MyLoad = sign(TempLoad, MyLoad);
    2144              :     }
    2145              : 
    2146              :     // Part load ratio based on load and available chiller capacity, cap at max part load ratio
    2147      7360395 :     Real64 PartLoadRat = 0.0; // Operating part load ratio
    2148      7360395 :     if (AvailChillerCap > 0) {
    2149      7360395 :         PartLoadRat = max(0.0, min(std::abs(MyLoad) / AvailChillerCap, this->MaxPartLoadRat));
    2150              :     }
    2151              : 
    2152              :     // Set evaporator heat transfer rate
    2153      7360395 :     this->QEvaporator = AvailChillerCap * PartLoadRat;
    2154      7360395 :     this->ChillerPartLoadRatio = PartLoadRat;
    2155              :     // If FlowLock is False (0), the chiller sets the plant loop mdot
    2156              :     // If FlowLock is True (1),  the new resolved plant loop mdot is used
    2157      7360395 :     if (this->CWPlantLoc.side->FlowLock == DataPlant::FlowLock::Unlocked) {
    2158      3680223 :         this->PossibleSubcooling = !(this->CWPlantLoc.comp->CurOpSchemeType == DataPlant::OpScheme::CompSetPtBased);
    2159              : 
    2160      3680223 :         Real64 EvapDeltaTemp(0.0); // Evaporator temperature difference [C]
    2161              : 
    2162              :         // Either set the flow to the Constant value or calculate the flow for the variable volume case
    2163      3680223 :         if ((this->FlowMode == DataPlant::FlowMode::Constant) || (this->FlowMode == DataPlant::FlowMode::NotModulated)) {
    2164              :             // Set the evaporator mass flow rate to design
    2165              :             // Start by assuming max (design) flow
    2166       320138 :             this->EvapMassFlowRate = this->EvapMassFlowRateMax;
    2167              :             // Use PlantUtilities::SetComponentFlowRate to decide actual flow
    2168       320138 :             PlantUtilities::SetComponentFlowRate(state, this->EvapMassFlowRate, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    2169       320138 :             if (this->EvapMassFlowRate != 0.0) {
    2170       320138 :                 EvapDeltaTemp = this->QEvaporator / this->EvapMassFlowRate / Cp;
    2171              :             } else {
    2172            0 :                 EvapDeltaTemp = 0.0;
    2173              :             }
    2174       320138 :             this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapDeltaTemp;
    2175      3360085 :         } else if (this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) {
    2176      3360085 :             switch (this->CWPlantLoc.loop->LoopDemandCalcScheme) {
    2177      3360085 :             case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
    2178              :                 // Calculate the Delta Temp from the inlet temp to the chiller outlet setpoint
    2179      3360085 :                 EvapDeltaTemp =
    2180      3360085 :                     state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint;
    2181      3360085 :             } break;
    2182            0 :             case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
    2183            0 :                 EvapDeltaTemp =
    2184            0 :                     state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi;
    2185            0 :             } break;
    2186            0 :             default: {
    2187            0 :                 assert(false);
    2188              :             } break;
    2189              :             }
    2190              : 
    2191      3360085 :             if (EvapDeltaTemp != 0) {
    2192      3360085 :                 this->EvapMassFlowRate = max(0.0, (this->QEvaporator / Cp / EvapDeltaTemp));
    2193      3360085 :                 if ((this->EvapMassFlowRate - this->EvapMassFlowRateMax) > DataBranchAirLoopPlant::MassFlowTolerance) {
    2194          171 :                     this->PossibleSubcooling = true;
    2195              :                 }
    2196              :                 // Check to see if the Maximum is exceeded, if so set to maximum
    2197      3360085 :                 this->EvapMassFlowRate = min(this->EvapMassFlowRateMax, this->EvapMassFlowRate);
    2198              :                 // Use PlantUtilities::SetComponentFlowRate to decide actual flow
    2199      3360085 :                 PlantUtilities::SetComponentFlowRate(
    2200      3360085 :                     state, this->EvapMassFlowRate, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    2201              :                 // Should we recalculate this with the corrected setpoint?
    2202      3360085 :                 switch (this->CWPlantLoc.loop->LoopDemandCalcScheme) {
    2203      3360085 :                 case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
    2204      3360085 :                     this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint;
    2205      3360085 :                 } break;
    2206            0 :                 case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
    2207            0 :                     this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi;
    2208            0 :                 } break;
    2209            0 :                 default:
    2210            0 :                     break;
    2211              :                 }
    2212      3360085 :                 this->QEvaporator = max(0.0, (this->EvapMassFlowRate * Cp * EvapDeltaTemp));
    2213              :             } else {
    2214              :                 // Try to request zero flow
    2215            0 :                 this->EvapMassFlowRate = 0.0;
    2216              :                 // Use PlantUtilities::SetComponentFlowRate to decide actual flow
    2217            0 :                 PlantUtilities::SetComponentFlowRate(
    2218            0 :                     state, this->EvapMassFlowRate, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    2219              :                 // No deltaT since component is not running
    2220            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    2221            0 :                 this->QEvaporator = 0.0;
    2222            0 :                 PartLoadRat = 0.0;
    2223            0 :                 this->ChillerPartLoadRatio = PartLoadRat;
    2224              : 
    2225            0 :                 if (this->DeltaTErrCount < 1 && !state.dataGlobal->WarmupFlag) {
    2226            0 :                     ++this->DeltaTErrCount;
    2227            0 :                     ShowWarningError(state, "Evaporator DeltaTemp = 0 in mass flow calculation (Tevapin = Tevapout setpoint temp).");
    2228            0 :                     ShowContinueErrorTimeStamp(state, "");
    2229            0 :                 } else if (!state.dataGlobal->WarmupFlag) {
    2230            0 :                     ++this->ChillerCapFTError;
    2231            0 :                     ShowRecurringWarningErrorAtEnd(state,
    2232            0 :                                                    "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2233              :                                                        "\": Evaporator DeltaTemp = 0 in mass flow calculation warning continues...",
    2234            0 :                                                    this->DeltaTErrCountIndex,
    2235              :                                                    EvapDeltaTemp,
    2236              :                                                    EvapDeltaTemp);
    2237              :                 }
    2238              :             }
    2239              :         } // End of Constant Variable Flow If Block
    2240              : 
    2241              :         // If there is a fault of Chiller SWT Sensor
    2242       169063 :         if (this->FaultyChillerSWTFlag && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) &&
    2243      3849286 :             (!state.dataGlobal->KickOffSimulation) && (this->EvapMassFlowRate > 0)) {
    2244              :             // calculate directly affected variables at faulty case: EvapOutletTemp, EvapMassFlowRate, QEvaporator
    2245        25223 :             int FaultIndex = this->FaultyChillerSWTIndex;
    2246        25223 :             bool VarFlowFlag = (this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated);
    2247        25223 :             state.dataFaultsMgr->FaultsChillerSWTSensor(FaultIndex)
    2248        25223 :                 .CalFaultChillerSWT(VarFlowFlag,
    2249              :                                     this->FaultyChillerSWTOffset,
    2250              :                                     Cp,
    2251        25223 :                                     state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp,
    2252        25223 :                                     this->EvapOutletTemp,
    2253        25223 :                                     this->EvapMassFlowRate,
    2254        25223 :                                     this->QEvaporator);
    2255              :             // update corresponding variables at faulty case
    2256        25223 :             PartLoadRat = (AvailChillerCap > 0.0) ? (this->QEvaporator / AvailChillerCap) : 0.0;
    2257        25223 :             PartLoadRat = max(0.0, min(PartLoadRat, this->MaxPartLoadRat));
    2258        25223 :             this->ChillerPartLoadRatio = PartLoadRat;
    2259              :         }
    2260              : 
    2261              :     } else { // If FlowLock is True
    2262      3680172 :         this->EvapMassFlowRate = state.dataLoopNodes->Node(this->EvapInletNodeNum).MassFlowRate;
    2263      3680172 :         PlantUtilities::SetComponentFlowRate(state, this->EvapMassFlowRate, this->EvapInletNodeNum, this->EvapOutletNodeNum, this->CWPlantLoc);
    2264              :         //       Some other component set the flow to 0. No reason to continue with calculations.
    2265      3680172 :         if (this->EvapMassFlowRate == 0.0) {
    2266            0 :             MyLoad = 0.0;
    2267            0 :             return;
    2268              :         }
    2269              : 
    2270              :         Real64 EvapDeltaTemp;
    2271      3680172 :         if (this->PossibleSubcooling) {
    2272      3680124 :             this->QEvaporator = std::abs(MyLoad);
    2273      3680124 :             EvapDeltaTemp = this->QEvaporator / this->EvapMassFlowRate / Cp;
    2274      3680124 :             this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapDeltaTemp;
    2275              :         } else {
    2276           48 :             EvapDeltaTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapOutletTempSetPoint;
    2277           48 :             this->QEvaporator = max(0.0, (this->EvapMassFlowRate * Cp * EvapDeltaTemp));
    2278           48 :             this->EvapOutletTemp = EvapOutletTempSetPoint;
    2279              :         }
    2280      3680172 :         if (this->EvapOutletTemp < TempLowLimitEout) {
    2281         9291 :             if ((state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - TempLowLimitEout) > DataPlant::DeltaTempTol) {
    2282         9291 :                 this->EvapOutletTemp = TempLowLimitEout;
    2283         9291 :                 EvapDeltaTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - this->EvapOutletTemp;
    2284         9291 :                 this->QEvaporator = this->EvapMassFlowRate * Cp * EvapDeltaTemp;
    2285              :             } else {
    2286            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    2287            0 :                 EvapDeltaTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - this->EvapOutletTemp;
    2288            0 :                 this->QEvaporator = this->EvapMassFlowRate * Cp * EvapDeltaTemp;
    2289              :             }
    2290              :         }
    2291      3680172 :         if (this->EvapOutletTemp < state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempMin) {
    2292            0 :             if ((state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempMin) >
    2293              :                 DataPlant::DeltaTempTol) {
    2294            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempMin;
    2295            0 :                 EvapDeltaTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - this->EvapOutletTemp;
    2296            0 :                 this->QEvaporator = this->EvapMassFlowRate * Cp * EvapDeltaTemp;
    2297              :             } else {
    2298            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    2299            0 :                 EvapDeltaTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - this->EvapOutletTemp;
    2300            0 :                 this->QEvaporator = this->EvapMassFlowRate * Cp * EvapDeltaTemp;
    2301              :             }
    2302              :         }
    2303              :         // If load exceeds the distributed load set to the distributed load
    2304      3680172 :         if (this->QEvaporator > std::abs(MyLoad)) {
    2305           48 :             if (this->EvapMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2306           48 :                 this->QEvaporator = std::abs(MyLoad);
    2307           48 :                 EvapDeltaTemp = this->QEvaporator / this->EvapMassFlowRate / Cp;
    2308           48 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapDeltaTemp;
    2309              :             } else {
    2310            0 :                 this->QEvaporator = 0.0;
    2311            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    2312              :             }
    2313              :         }
    2314              : 
    2315              :         // If there is a fault of Chiller SWT Sensor
    2316       169081 :         if (this->FaultyChillerSWTFlag && (!state.dataGlobal->WarmupFlag) && (!state.dataGlobal->DoingSizing) &&
    2317      3849253 :             (!state.dataGlobal->KickOffSimulation) && (this->EvapMassFlowRate > 0)) {
    2318              :             // calculate directly affected variables at faulty case: EvapOutletTemp, EvapMassFlowRate, QEvaporator
    2319        25059 :             int FaultIndex = this->FaultyChillerSWTIndex;
    2320        25059 :             bool VarFlowFlag = false;
    2321        25059 :             state.dataFaultsMgr->FaultsChillerSWTSensor(FaultIndex)
    2322        25059 :                 .CalFaultChillerSWT(VarFlowFlag,
    2323              :                                     this->FaultyChillerSWTOffset,
    2324              :                                     Cp,
    2325        25059 :                                     state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp,
    2326        25059 :                                     this->EvapOutletTemp,
    2327        25059 :                                     this->EvapMassFlowRate,
    2328        25059 :                                     this->QEvaporator);
    2329              :             // update corresponding variables at faulty case
    2330              :         }
    2331              : 
    2332              :         // Checks QEvaporator on the basis of the machine limits.
    2333      3680172 :         if (this->QEvaporator > (AvailChillerCap * this->MaxPartLoadRat)) {
    2334       344506 :             if (this->EvapMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2335       344506 :                 this->QEvaporator = AvailChillerCap * this->MaxPartLoadRat;
    2336       344506 :                 EvapDeltaTemp = this->QEvaporator / this->EvapMassFlowRate / Cp;
    2337              :                 // evaporator outlet temperature is allowed to float upwards (recalculate AvailChillerCap? iterate?)
    2338       344506 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp - EvapDeltaTemp;
    2339              :             } else {
    2340            0 :                 this->QEvaporator = 0.0;
    2341            0 :                 this->EvapOutletTemp = state.dataLoopNodes->Node(this->EvapInletNodeNum).Temp;
    2342              :             }
    2343              :         }
    2344              : 
    2345      3680172 :         if (AvailChillerCap > 0.0) {
    2346      3680172 :             PartLoadRat = max(0.0, min((this->QEvaporator / AvailChillerCap), this->MaxPartLoadRat));
    2347              :         } else {
    2348            0 :             PartLoadRat = 0.0;
    2349              :         }
    2350              : 
    2351              :         // Chiller cycles below minimum part load ratio, FRAC = amount of time chiller is ON during this time step
    2352      3680172 :         if (PartLoadRat < this->MinPartLoadRat) {
    2353       420516 :             FRAC = min(1.0, (PartLoadRat / this->MinPartLoadRat));
    2354              :         }
    2355              : 
    2356              :         // Chiller is false loading below PLR = minimum unloading ratio, find PLR used for energy calculation
    2357      3680172 :         if (AvailChillerCap > 0.0) {
    2358      3680172 :             PartLoadRat = max(PartLoadRat, this->MinUnloadRat);
    2359              :         } else {
    2360            0 :             PartLoadRat = 0.0;
    2361              :         }
    2362              : 
    2363              :         // set the module level variable used for reporting PLR
    2364      3680172 :         this->ChillerPartLoadRatio = PartLoadRat;
    2365              : 
    2366              :         // calculate the load due to false loading on chiller over and above water side load
    2367      3680172 :         this->ChillerFalseLoadRate = (AvailChillerCap * PartLoadRat * FRAC) - this->QEvaporator;
    2368      3680172 :         if (this->ChillerFalseLoadRate < HVAC::SmallLoad) {
    2369      3187157 :             this->ChillerFalseLoadRate = 0.0;
    2370              :         }
    2371              : 
    2372              :     } // This is the end of the FlowLock Block
    2373              : 
    2374              :     // set the module level variable used for reporting FRAC
    2375      7360395 :     this->ChillerCyclingRatio = FRAC;
    2376              : 
    2377      7360395 :     this->ChillerEIRFT = max(0.0, Curve::CurveValue(state, this->ChillerEIRFTIndex, this->EvapOutletTemp, this->ChillerCondAvgTemp));
    2378              : 
    2379              :     // Part Load Ratio Curve Type: 1_LeavingCondenserWaterTemperature; 2_Lift
    2380      7360395 :     if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    2381      7243478 :         this->ChillerEIRFPLR = max(0.0, Curve::CurveValue(state, this->ChillerEIRFPLRIndex, this->ChillerCondAvgTemp, PartLoadRat));
    2382       116917 :     } else if (this->PartLoadCurveType == PLR::Lift) {
    2383              : 
    2384              :         // Chiller lift
    2385       116917 :         Real64 ChillerLift = this->ChillerCondAvgTemp - this->EvapOutletTemp;
    2386              : 
    2387              :         // Deviation of leaving chilled water temperature from the reference condition
    2388       116917 :         Real64 ChillerTdev = std::abs(this->EvapOutletTemp - this->TempRefEvapOut);
    2389              : 
    2390              :         // Chiller lift under the reference condition
    2391       116917 :         Real64 ChillerLiftRef = this->TempRefCondOut - this->TempRefEvapOut;
    2392              : 
    2393       116917 :         if (ChillerLiftRef <= 0) {
    2394            0 :             ChillerLiftRef = 35 - 6.67;
    2395              :         }
    2396              : 
    2397              :         // Normalized chiller lift
    2398       116917 :         Real64 ChillerLiftNom = ChillerLift / ChillerLiftRef;
    2399              : 
    2400              :         // Normalized ChillerTdev
    2401       116917 :         Real64 ChillerTdevNom = ChillerTdev / ChillerLiftRef;
    2402              : 
    2403       116917 :         this->ChillerEIRFPLR = max(0.0, Curve::CurveValue(state, this->ChillerEIRFPLRIndex, ChillerLiftNom, PartLoadRat, ChillerTdevNom));
    2404              :     }
    2405              : 
    2406      7360395 :     if (ReferenceCOP <= 0) {
    2407            0 :         ReferenceCOP = 5.5;
    2408              :     }
    2409      7360395 :     if (this->thermosiphonDisabled(state)) {
    2410      7360395 :         this->Power = (AvailChillerCap / ReferenceCOP) * this->ChillerEIRFPLR * this->ChillerEIRFT * FRAC;
    2411              :     }
    2412              : 
    2413      7360395 :     this->QCondenser = this->Power * this->CompPowerToCondenserFrac + this->QEvaporator + this->ChillerFalseLoadRate;
    2414              : 
    2415              :     // set condenser mass flow rate
    2416      7360395 :     if (this->CondenserType == DataPlant::CondenserType::WaterCooled) {
    2417      7360395 :         switch (this->CondenserFlowControl) {
    2418      7186260 :         case DataPlant::CondenserFlowControl::ConstantFlow: {
    2419      7186260 :             this->CondMassFlowRate = this->CondMassFlowRateMax;
    2420      7186260 :         } break;
    2421            0 :         case DataPlant::CondenserFlowControl::ModulatedChillerPLR: {
    2422            0 :             this->CondMassFlowRate = this->CondMassFlowRateMax * PartLoadRat;
    2423            0 :         } break;
    2424       174135 :         case DataPlant::CondenserFlowControl::ModulatedLoopPLR: {
    2425       174135 :             int PltSizNum = this->CWPlantLoc.loop->PlantSizNum;
    2426       174135 :             int CondPltSizNum = this->CDPlantLoc.loop->PlantSizNum;
    2427       174135 :             if (PltSizNum > 0 && CondPltSizNum > 0) {
    2428       174135 :                 Real64 chwLoopCap = state.dataSize->PlantSizData(PltSizNum).DesCapacity;
    2429       174135 :                 Real64 chwLoopDemand = std::abs(this->CWPlantLoc.side->UpdatedDemandToLoopSetPoint);
    2430       174135 :                 Real64 cwhLoopPLR = 0.0;
    2431       174135 :                 if (chwLoopDemand > 0) {
    2432       174135 :                     cwhLoopPLR = chwLoopDemand / chwLoopCap;
    2433              :                 }
    2434       174135 :                 Real64 condWaterFlowFrac = Curve::CurveValue(state, this->ChillerCondLoopFlowFLoopPLRIndex, cwhLoopPLR);
    2435       174135 :                 Real64 cwLoopDesVolFlowRate = state.dataSize->PlantSizData(CondPltSizNum).DesVolFlowRate;
    2436       174135 :                 Real64 cwLoopVolFlowRate = condWaterFlowFrac * cwLoopDesVolFlowRate;
    2437       174135 :                 Real64 rho = this->CDPlantLoc.loop->glycol->getDensity(state, this->TempRefCondIn, RoutineName);
    2438       174135 :                 if (chwLoopDemand > 0) {
    2439       174135 :                     this->CondMassFlowRate = cwLoopVolFlowRate * rho * this->QEvaporator / chwLoopDemand;
    2440              :                 } else {
    2441            0 :                     this->CondMassFlowRate = 0.0;
    2442              :                 }
    2443       174135 :             } else {
    2444            0 :                 ShowFatalError(state,
    2445            0 :                                format("{}: The ModulatedLoopPLR condenser flow control requires a Sizing:Plant object for "
    2446              :                                       "both loops connected to the condenser and evaporator of the chiller.",
    2447              :                                       RoutineName));
    2448              :             }
    2449       174135 :         } break;
    2450            0 :         case DataPlant::CondenserFlowControl::ModulatedDeltaTemperature: {
    2451            0 :             Real64 CpCond = this->CWPlantLoc.loop->glycol->getSpecificHeat(state, this->CondInletTemp, RoutineName);
    2452            0 :             Real64 condDT = (this->condDTSched != nullptr) ? this->condDTSched->getCurrentVal() : 0.0;
    2453            0 :             this->CondMassFlowRate = this->QCondenser / (CpCond * condDT);
    2454            0 :         } break;
    2455              : 
    2456            0 :         default: {
    2457            0 :             this->CondMassFlowRate = this->CondMassFlowRateMax;
    2458            0 :         } break;
    2459              :         }
    2460      7360395 :         Real64 minCondMassFlowRate = this->MinCondFlowRatio * this->CondMassFlowRateMax;
    2461      7360395 :         Real64 minPumpMassFlowRate = this->VSBranchPumpMinLimitMassFlowCond;
    2462      7360395 :         Real64 maxCondMassFlowRate = min(this->CondMassFlowRate, this->CondMassFlowRateMax);
    2463      7360395 :         this->CondMassFlowRate = max(maxCondMassFlowRate, minCondMassFlowRate, minPumpMassFlowRate);
    2464      7360395 :         PlantUtilities::SetComponentFlowRate(state, this->CondMassFlowRate, this->CondInletNodeNum, this->CondOutletNodeNum, this->CDPlantLoc);
    2465      7360395 :         PlantUtilities::PullCompInterconnectTrigger(
    2466      7360395 :             state, this->CWPlantLoc, this->CondMassFlowIndex, this->CDPlantLoc, DataPlant::CriteriaType::MassFlowRate, this->CondMassFlowRate);
    2467              :     }
    2468              : 
    2469              :     //  Currently only water cooled chillers are allowed for the reformulated EIR chiller model
    2470      7360395 :     if (this->CondMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2471              :         // If Heat Recovery specified for this vapor compression chiller, then Qcondenser will be adjusted by this subroutine
    2472      7360395 :         if (this->HeatRecActive) {
    2473            0 :             this->calcHeatRecovery(state, this->QCondenser, this->CondMassFlowRate, condInletTemp, this->QHeatRecovery);
    2474              :         }
    2475      7360395 :         Real64 CpCond = this->CDPlantLoc.loop->glycol->getSpecificHeat(state, condInletTemp, RoutineName);
    2476      7360395 :         this->CondOutletTemp = this->QCondenser / this->CondMassFlowRate / CpCond + condInletTemp;
    2477              :     } else {
    2478            0 :         ShowSevereError(state, format("ControlReformEIRChillerModel: Condenser flow = 0, for ElecReformEIRChiller={}", this->Name));
    2479            0 :         ShowContinueErrorTimeStamp(state, "");
    2480              :     }
    2481              : }
    2482              : 
    2483      1039494 : void ReformulatedEIRChillerSpecs::checkMinMaxCurveBoundaries(EnergyPlusData &state, bool const FirstIteration)
    2484              : {
    2485              :     // SUBROUTINE INFORMATION:
    2486              :     //       AUTHOR:          R Raustad, FSEC
    2487              :     //       DATE WRITTEN:    August 2006
    2488              : 
    2489              :     // PURPOSE OF THIS SUBROUTINE:
    2490              :     //  To compare the evaporator/condenser outlet temperatures to curve object min/max values
    2491              : 
    2492              :     // Do not print out warnings if chiller not operating or FirstIteration/WarmupFlag/FlowLock
    2493      1039494 :     if (FirstIteration || state.dataGlobal->WarmupFlag || this->CWPlantLoc.side->FlowLock == DataPlant::FlowLock::Unlocked) {
    2494       998338 :         return;
    2495              :     }
    2496              : 
    2497              :     // Minimum evaporator leaving temperature allowed by CAPFT curve [C]
    2498        41156 :     Real64 CAPFTXTmin = this->ChillerCAPFTXTempMin;
    2499              : 
    2500              :     // Maximum evaporator leaving temperature allowed by CAPFT curve [C]
    2501        41156 :     Real64 CAPFTXTmax = this->ChillerCAPFTXTempMax;
    2502              : 
    2503              :     // Minimum evaporator leaving temperature allowed by EIRFT curve [C]
    2504        41156 :     Real64 EIRFTXTmin = this->ChillerEIRFTXTempMin;
    2505              : 
    2506              :     // Maximum evaporator leaving temperature allowed by EIRFT curve [C]
    2507        41156 :     Real64 EIRFTXTmax = this->ChillerEIRFTXTempMax;
    2508              : 
    2509              :     // Check bounds for curves, lump min/max into same check since min/max values are reported in recurring warning messages
    2510        41156 :     if (this->EvapOutletTemp < CAPFTXTmin || this->EvapOutletTemp > CAPFTXTmax) {
    2511          820 :         ++this->CAPFTXIter;
    2512          820 :         if (this->CAPFTXIter == 1) {
    2513            8 :             ShowWarningError(
    2514              :                 state,
    2515            8 :                 format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The evaporator outlet temperature ({:.2T} C) is outside the range of evaporator "
    2516              :                        "outlet temperatures (X var) given in Cooling Capacity Function of Temperature biquadratic curve = {}",
    2517            4 :                        this->Name,
    2518            4 :                        this->EvapOutletTemp,
    2519            4 :                        this->CAPFTName));
    2520            4 :             ShowContinueErrorTimeStamp(state, format("The range specified = {:.2T} C to {:.2T} C.", CAPFTXTmin, CAPFTXTmax));
    2521           32 :             ShowRecurringWarningErrorAtEnd(state,
    2522            8 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2523              :                                                "\": The evap outlet temp range in Cooling Capacity Function of Temp curve error continues.",
    2524            4 :                                            this->CAPFTXIterIndex,
    2525            4 :                                            this->EvapOutletTemp,
    2526            4 :                                            this->EvapOutletTemp);
    2527              :         } else {
    2528         6528 :             ShowRecurringWarningErrorAtEnd(state,
    2529         1632 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2530              :                                                "\": The evap outlet temp range in Cooling Capacity Function of Temp curve error continues.",
    2531          816 :                                            this->CAPFTXIterIndex,
    2532          816 :                                            this->EvapOutletTemp,
    2533          816 :                                            this->EvapOutletTemp);
    2534              :         }
    2535              :     }
    2536              : 
    2537        41156 :     if (this->EvapOutletTemp < EIRFTXTmin || this->EvapOutletTemp > EIRFTXTmax) {
    2538          820 :         ++this->EIRFTXIter;
    2539          820 :         if (this->EIRFTXIter == 1) {
    2540            8 :             ShowWarningError(
    2541              :                 state,
    2542            8 :                 format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The evaporator outlet temperature ({:.2T} C) is outside the range of evaporator "
    2543              :                        "outlet temperatures (X var) given in Electric Input to Cooling Output Ratio Function of Temperature biquadratic curve = {}",
    2544            4 :                        this->Name,
    2545            4 :                        this->EvapOutletTemp,
    2546            4 :                        this->EIRFTName));
    2547            4 :             ShowContinueErrorTimeStamp(state, format("The range specified = {:.2T} C to {:.2T} C.", EIRFTXTmin, EIRFTXTmax));
    2548           32 :             ShowRecurringWarningErrorAtEnd(
    2549              :                 state,
    2550            8 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2551              :                     "\": The evap outlet temp range in Electric Input to Cooling Output Ratio Function of Temp curve error continues.",
    2552            4 :                 this->EIRFTXIterIndex,
    2553            4 :                 this->EvapOutletTemp,
    2554            4 :                 this->EvapOutletTemp);
    2555              :         } else {
    2556         6528 :             ShowRecurringWarningErrorAtEnd(
    2557              :                 state,
    2558         1632 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2559              :                     "\": The evap outlet temp range in Electric Input to Cooling Output Ratio Function of Temp curve error continues.",
    2560          816 :                 this->EIRFTXIterIndex,
    2561          816 :                 this->EvapOutletTemp,
    2562          816 :                 this->EvapOutletTemp);
    2563              :         }
    2564              :     }
    2565              : 
    2566              :     // Move CAPFT, EIRFT, and EIRFPLR min/max condenser outlet temperature values to local variables
    2567              : 
    2568              :     // Minimum condenser  leaving temperature allowed by CAPFT curve [C]
    2569        41156 :     Real64 CAPFTYTmin = this->ChillerCAPFTYTempMin;
    2570              : 
    2571              :     // Maximum condenser  leaving temperature allowed by CAPFT curve [C]
    2572        41156 :     Real64 CAPFTYTmax = this->ChillerCAPFTYTempMax;
    2573              : 
    2574              :     // Minimum condenser  leaving temperature allowed by EIRFT curve [C]
    2575        41156 :     Real64 EIRFTYTmin = this->ChillerEIRFTYTempMin;
    2576              : 
    2577              :     // Maximum condenser  leaving temperature allowed by EIRFT curve [C]
    2578        41156 :     Real64 EIRFTYTmax = this->ChillerEIRFTYTempMax;
    2579              : 
    2580        41156 :     Real64 EIRFPLRTmin(0.0); // Minimum condenser  leaving temperature allowed by EIRFPLR curve [C]
    2581        41156 :     Real64 EIRFPLRTmax(0.0); // Maximum condenser  leaving temperature allowed by EIRFPLR curve [C]
    2582              : 
    2583        41156 :     if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    2584        40542 :         EIRFPLRTmin = this->ChillerEIRFPLRTempMin;
    2585        40542 :         EIRFPLRTmax = this->ChillerEIRFPLRTempMax;
    2586              :     }
    2587              : 
    2588              :     // Move EIRFPLR min/max part-load ratio values to local variables
    2589              : 
    2590              :     // Minimum PLR allowed by EIRFPLR curve
    2591        41156 :     Real64 EIRFPLRPLRmin = this->ChillerEIRFPLRPLRMin;
    2592              : 
    2593              :     // Maximum PLR allowed by EIRFPLR curve
    2594        41156 :     Real64 EIRFPLRPLRmax = this->ChillerEIRFPLRPLRMax;
    2595              : 
    2596              :     // Check bounds for curves, lump min/max into same check since min/max values are reported in recurring warning messages
    2597        41156 :     if (this->CondOutletTemp < CAPFTYTmin || this->CondOutletTemp > CAPFTYTmax) {
    2598            0 :         ++this->CAPFTYIter;
    2599            0 :         if (this->CAPFTYIter == 1) {
    2600            0 :             ShowWarningError(
    2601              :                 state,
    2602            0 :                 format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The condenser outlet temperature ({:.2T} C) is outside the range of condenser "
    2603              :                        "outlet temperatures (Y var) given in Cooling Capacity Function of Temperature biquadratic curve = {}",
    2604            0 :                        this->Name,
    2605            0 :                        this->CondOutletTemp,
    2606            0 :                        this->CAPFTName));
    2607            0 :             ShowContinueErrorTimeStamp(state, format("The range specified = {:.2T} C to {:.2T} C.", CAPFTYTmin, CAPFTYTmax));
    2608            0 :             ShowRecurringWarningErrorAtEnd(state,
    2609            0 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2610              :                                                "\": The cond outlet temp range in Cooling Capacity Function of Temp curve error continues.",
    2611            0 :                                            this->CAPFTYIterIndex,
    2612            0 :                                            this->CondOutletTemp,
    2613            0 :                                            this->CondOutletTemp);
    2614              :         } else {
    2615            0 :             ShowRecurringWarningErrorAtEnd(state,
    2616            0 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2617              :                                                "\": The cond outlet temp range in Cooling Capacity Function of Temp curve error continues.",
    2618            0 :                                            this->CAPFTYIterIndex,
    2619            0 :                                            this->CondOutletTemp,
    2620            0 :                                            this->CondOutletTemp);
    2621              :         }
    2622              :     }
    2623              : 
    2624        41156 :     if (this->CondOutletTemp < EIRFTYTmin || this->CondOutletTemp > EIRFTYTmax) {
    2625            0 :         ++this->EIRFTYIter;
    2626            0 :         if (this->EIRFTYIter == 1) {
    2627            0 :             ShowWarningError(
    2628              :                 state,
    2629            0 :                 format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The condenser outlet temperature ({:.2T} C) is outside the range of condenser "
    2630              :                        "outlet temperatures (Y var) given in Electric Input to Cooling Output Ratio Function of Temperature biquadratic curve = {}",
    2631            0 :                        this->Name,
    2632            0 :                        this->CondOutletTemp,
    2633            0 :                        this->EIRFTName));
    2634            0 :             ShowContinueErrorTimeStamp(state, format("The range specified = {:.2T} C to {:.2T} C.", EIRFTYTmin, EIRFTYTmax));
    2635            0 :             ShowRecurringWarningErrorAtEnd(
    2636              :                 state,
    2637            0 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2638              :                     "\": The cond outlet temp range in Electric Input to Cooling Output Ratio as a Function of Temp curve error continues.",
    2639            0 :                 this->EIRFTYIterIndex,
    2640            0 :                 this->CondOutletTemp,
    2641            0 :                 this->CondOutletTemp);
    2642              :         } else {
    2643            0 :             ShowRecurringWarningErrorAtEnd(
    2644              :                 state,
    2645            0 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2646              :                     "\": The cond outlet temp range in Electric Input to Cooling Output Ratio as a Function of Temp curve error continues.",
    2647            0 :                 this->EIRFTYIterIndex,
    2648            0 :                 this->CondOutletTemp,
    2649            0 :                 this->CondOutletTemp);
    2650              :         }
    2651              :     }
    2652              : 
    2653        41156 :     if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    2654        40542 :         if (this->CondOutletTemp < EIRFPLRTmin || this->CondOutletTemp > EIRFPLRTmax) {
    2655         4521 :             ++this->EIRFPLRTIter;
    2656         4521 :             if (this->EIRFPLRTIter == 1) {
    2657           14 :                 ShowWarningError(state,
    2658           14 :                                  format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The condenser outlet temperature ({:.2T} C) is outside the "
    2659              :                                         "range of condenser outlet temperatures (X var) given in Electric Input to Cooling Output Ratio Function "
    2660              :                                         "of Part-load Ratio bicubic curve = {}",
    2661            7 :                                         this->Name,
    2662            7 :                                         this->CondOutletTemp,
    2663            7 :                                         this->EIRFPLRName));
    2664            7 :                 ShowContinueErrorTimeStamp(state, format("The range specified = {:.2T} C to {:.2T} C.", EIRFPLRTmin, EIRFPLRTmax));
    2665           56 :                 ShowRecurringWarningErrorAtEnd(
    2666              :                     state,
    2667           14 :                     "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2668              :                         "\": The cond outlet temp range in Electric Input to Cooling Output Ratio Function of PLR curve error continues.",
    2669            7 :                     this->EIRFPLRTIterIndex,
    2670            7 :                     this->CondOutletTemp,
    2671            7 :                     this->CondOutletTemp);
    2672              :             } else {
    2673        36112 :                 ShowRecurringWarningErrorAtEnd(
    2674              :                     state,
    2675         9028 :                     "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2676              :                         "\": The cond outlet temp range in Electric Input to Cooling Output Ratio Function of PLR curve error continues.",
    2677         4514 :                     this->EIRFPLRTIterIndex,
    2678         4514 :                     this->CondOutletTemp,
    2679         4514 :                     this->CondOutletTemp);
    2680              :             }
    2681              :         }
    2682              :     }
    2683              : 
    2684        41156 :     if (this->ChillerPartLoadRatio < EIRFPLRPLRmin || this->ChillerPartLoadRatio > EIRFPLRPLRmax) {
    2685          162 :         ++this->EIRFPLRPLRIter;
    2686          162 :         if (this->EIRFPLRPLRIter == 1) {
    2687            6 :             ShowWarningError(
    2688              :                 state,
    2689            6 :                 format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\": The part-load ratio ({:.3T}) is outside the range of part-load ratios (Y var) "
    2690              :                        "given in Electric Input to Cooling Output Ratio Function of Part-load Ratio bicubic curve = {}",
    2691            3 :                        this->Name,
    2692            3 :                        this->ChillerPartLoadRatio,
    2693            3 :                        this->EIRFPLRName));
    2694            3 :             ShowContinueErrorTimeStamp(state, format("The range specified = {:.3T} to {:.3T}.", EIRFPLRPLRmin, EIRFPLRPLRmax));
    2695           24 :             ShowRecurringWarningErrorAtEnd(
    2696              :                 state,
    2697            6 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2698              :                     "\": The part-load ratio range in Electric Input to Cooling Output Ratio Function of PLRatio curve error continues.",
    2699            3 :                 this->EIRFPLRPLRIterIndex,
    2700            3 :                 this->ChillerPartLoadRatio,
    2701            3 :                 this->ChillerPartLoadRatio);
    2702              :         } else {
    2703         1272 :             ShowRecurringWarningErrorAtEnd(
    2704              :                 state,
    2705          318 :                 "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2706              :                     "\": The part-load ratio range in Electric Input to Cooling Output Ratio Function of PLRatio curve error continues.",
    2707          159 :                 this->EIRFPLRPLRIterIndex,
    2708          159 :                 this->ChillerPartLoadRatio,
    2709          159 :                 this->ChillerPartLoadRatio);
    2710              :         }
    2711              :     }
    2712              : 
    2713        41156 :     Real64 EvapOutletTempSetPoint(0.0); // Evaporator outlet temperature setpoint [C]
    2714              : 
    2715        41156 :     switch (this->CWPlantLoc.loop->LoopDemandCalcScheme) {
    2716        41156 :     case DataPlant::LoopDemandCalcScheme::SingleSetPoint: {
    2717        87210 :         if ((this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) ||
    2718        46054 :             (this->CWPlantLoc.comp->CurOpSchemeType == DataPlant::OpScheme::CompSetPtBased) ||
    2719         4898 :             (state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint != DataLoopNode::SensedNodeFlagValue)) {
    2720              :             // there will be a valid setpoint on outlet
    2721        36258 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPoint;
    2722              :         } else { // use plant loop overall setpoint
    2723         4898 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPoint;
    2724              :         }
    2725        41156 :     } break;
    2726            0 :     case DataPlant::LoopDemandCalcScheme::DualSetPointDeadBand: {
    2727            0 :         if ((this->FlowMode == DataPlant::FlowMode::LeavingSetpointModulated) ||
    2728            0 :             (this->CWPlantLoc.comp->CurOpSchemeType == DataPlant::OpScheme::CompSetPtBased) ||
    2729            0 :             (state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi != DataLoopNode::SensedNodeFlagValue)) {
    2730              :             // there will be a valid setpoint on outlet
    2731            0 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->EvapOutletNodeNum).TempSetPointHi;
    2732              :         } else { // use plant loop overall setpoint
    2733            0 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(this->CWPlantLoc.loop->TempSetPointNodeNum).TempSetPointHi;
    2734              :         }
    2735            0 :     } break;
    2736            0 :     default: {
    2737            0 :         assert(false);
    2738              :     } break;
    2739              :     }
    2740              : 
    2741        41156 :     this->ChillerCapFT = Curve::CurveValue(state, this->ChillerCapFTIndex, EvapOutletTempSetPoint, this->CondOutletTemp);
    2742              : 
    2743        41156 :     if (this->ChillerCapFT < 0) {
    2744            0 :         if (this->ChillerCapFTError < 1 && this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2745            0 :             ++this->ChillerCapFTError;
    2746            0 :             ShowWarningError(state, format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\":", this->Name));
    2747            0 :             ShowContinueError(state, format(" Chiller Capacity as a Function of Temperature curve output is negative ({:.3R}).", this->ChillerCapFT));
    2748            0 :             ShowContinueError(state,
    2749            0 :                               format(" Negative value occurs using an Evaporator Leaving Temp of {:.1R} and a Condenser Leaving Temp of {:.1R}.",
    2750              :                                      EvapOutletTempSetPoint,
    2751            0 :                                      this->CondOutletTemp));
    2752            0 :             ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    2753            0 :         } else if (this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2754            0 :             ++this->ChillerCapFTError;
    2755            0 :             ShowRecurringWarningErrorAtEnd(state,
    2756            0 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2757              :                                                "\": Chiller Capacity as a Function of Temperature curve output is negative warning continues...",
    2758            0 :                                            this->ChillerCapFTErrorIndex,
    2759            0 :                                            this->ChillerCapFT,
    2760            0 :                                            this->ChillerCapFT);
    2761              :         }
    2762              :     }
    2763              : 
    2764        41156 :     this->ChillerEIRFT = Curve::CurveValue(state, this->ChillerEIRFTIndex, this->EvapOutletTemp, this->CondOutletTemp);
    2765              : 
    2766        41156 :     if (this->ChillerEIRFT < 0.0) {
    2767            0 :         if (this->ChillerEIRFTError < 1 && this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2768            0 :             ++this->ChillerEIRFTError;
    2769            0 :             ShowWarningError(state, format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\":", this->Name));
    2770            0 :             ShowContinueError(
    2771            0 :                 state, format(" Reformulated Chiller EIR as a Function of Temperature curve output is negative ({:.3R}).", this->ChillerEIRFT));
    2772            0 :             ShowContinueError(state,
    2773            0 :                               format(" Negative value occurs using an Evaporator Leaving Temp of {:.1R} and a Condenser Leaving Temp of {:.1R}.",
    2774            0 :                                      this->EvapOutletTemp,
    2775            0 :                                      this->CondOutletTemp));
    2776            0 :             ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    2777            0 :         } else if (this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2778            0 :             ++this->ChillerEIRFTError;
    2779            0 :             ShowRecurringWarningErrorAtEnd(state,
    2780            0 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2781              :                                                "\": Chiller EIR as a Function of Temperature curve output is negative warning continues...",
    2782            0 :                                            this->ChillerEIRFTErrorIndex,
    2783            0 :                                            this->ChillerEIRFT,
    2784            0 :                                            this->ChillerEIRFT);
    2785              :         }
    2786              :     }
    2787              : 
    2788        41156 :     if (this->PartLoadCurveType == PLR::LeavingCondenserWaterTemperature) {
    2789        40542 :         this->ChillerEIRFPLR = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, this->CondOutletTemp, this->ChillerPartLoadRatio);
    2790          614 :     } else if (this->PartLoadCurveType == PLR::Lift) {
    2791              : 
    2792              :         // Chiller lift  [C]
    2793          614 :         Real64 ChillerLift = this->CondOutletTemp - this->EvapOutletTemp;
    2794              : 
    2795              :         // Deviation of leaving chilled water temperature from the reference condition
    2796          614 :         Real64 ChillerTdev = std::abs(this->EvapOutletTemp - this->TempRefEvapOut);
    2797              : 
    2798              :         // Chiller lift under the reference condition  [C]
    2799          614 :         Real64 ChillerLiftRef = this->TempRefCondOut - this->TempRefEvapOut;
    2800              : 
    2801          614 :         if (ChillerLiftRef <= 0) {
    2802            0 :             ChillerLiftRef = 35 - 6.67;
    2803              :         }
    2804              : 
    2805              :         // Normalized chiller lift
    2806          614 :         Real64 ChillerLiftNom = ChillerLift / ChillerLiftRef;
    2807              : 
    2808              :         // Normalized ChillerTdev
    2809          614 :         Real64 ChillerTdevNom = ChillerTdev / ChillerLiftRef;
    2810              : 
    2811          614 :         this->ChillerEIRFPLR = Curve::CurveValue(state, this->ChillerEIRFPLRIndex, ChillerLiftNom, this->ChillerPartLoadRatio, ChillerTdevNom);
    2812              :     }
    2813              : 
    2814        41156 :     if (this->ChillerEIRFPLR < 0.0) {
    2815            0 :         if (this->ChillerEIRFPLRError < 1 && this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2816            0 :             ++this->ChillerEIRFPLRError;
    2817            0 :             ShowWarningError(state, format("CHILLER:ELECTRIC:REFORMULATEDEIR \"{}\":", this->Name));
    2818            0 :             ShowContinueError(
    2819              :                 state,
    2820            0 :                 format(" Chiller EIR as a function of PLR and condenser water temperature curve output is negative ({:.3R}).", this->ChillerEIRFPLR));
    2821            0 :             ShowContinueError(state,
    2822            0 :                               format(" Negative value occurs using a part-load ratio of {:.3R} and a Condenser Leaving Temp of {:.1R} C.",
    2823            0 :                                      this->ChillerPartLoadRatio,
    2824            0 :                                      this->CondOutletTemp));
    2825            0 :             ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    2826            0 :         } else if (this->CWPlantLoc.side->FlowLock != DataPlant::FlowLock::Unlocked && !state.dataGlobal->WarmupFlag) {
    2827            0 :             ++this->ChillerEIRFPLRError;
    2828            0 :             ShowRecurringWarningErrorAtEnd(state,
    2829            0 :                                            "CHILLER:ELECTRIC:REFORMULATEDEIR \"" + this->Name +
    2830              :                                                "\": Chiller EIR as a function of PLR curve output is negative warning continues...",
    2831            0 :                                            this->ChillerEIRFPLRErrorIndex,
    2832            0 :                                            this->ChillerEIRFPLR,
    2833            0 :                                            this->ChillerEIRFPLR);
    2834              :         }
    2835              :     }
    2836              : }
    2837              : 
    2838      7360395 : bool ReformulatedEIRChillerSpecs::thermosiphonDisabled(EnergyPlusData &state)
    2839              : {
    2840      7360395 :     if (this->thermosiphonTempCurveIndex > 0) {
    2841            0 :         this->thermosiphonStatus = 0;
    2842            0 :         Real64 dT = this->EvapOutletTemp - this->CondInletTemp;
    2843            0 :         if (dT < this->thermosiphonMinTempDiff) {
    2844            0 :             return true;
    2845              :         }
    2846            0 :         Real64 thermosiphonCapFrac = Curve::CurveValue(state, this->thermosiphonTempCurveIndex, dT);
    2847            0 :         Real64 capFrac = this->ChillerPartLoadRatio * this->ChillerCyclingRatio;
    2848            0 :         if (thermosiphonCapFrac >= capFrac) {
    2849            0 :             this->thermosiphonStatus = 1;
    2850            0 :             this->Power = 0.0;
    2851            0 :             return false;
    2852              :         }
    2853            0 :         return true;
    2854              :     } else {
    2855      7360395 :         return true;
    2856              :     }
    2857              : }
    2858              : 
    2859              : } // namespace EnergyPlus::ChillerReformulatedEIR
        

Generated by: LCOV version 2.0-1