LCOV - code coverage report
Current view: top level - EnergyPlus - PlantCentralGSHP.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 1461 1942 75.2 %
Date: 2023-01-17 19:17:23 Functions: 18 19 94.7 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <cmath>
      50             : #include <string>
      51             : 
      52             : // ObjexxFCL Headers
      53             : #include <ObjexxFCL/Array.functions.hh>
      54             : #include <ObjexxFCL/Fmath.hh>
      55             : 
      56             : // EnergyPlus Headers
      57             : #include <EnergyPlus/Autosizing/Base.hh>
      58             : #include <EnergyPlus/BranchNodeConnections.hh>
      59             : #include <EnergyPlus/CurveManager.hh>
      60             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      61             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      62             : #include <EnergyPlus/DataHVACGlobals.hh>
      63             : #include <EnergyPlus/DataIPShortCuts.hh>
      64             : #include <EnergyPlus/DataLoopNode.hh>
      65             : #include <EnergyPlus/DataSizing.hh>
      66             : #include <EnergyPlus/EMSManager.hh>
      67             : #include <EnergyPlus/FluidProperties.hh>
      68             : #include <EnergyPlus/General.hh>
      69             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      70             : #include <EnergyPlus/NodeInputManager.hh>
      71             : #include <EnergyPlus/OutputProcessor.hh>
      72             : #include <EnergyPlus/OutputReportPredefined.hh>
      73             : #include <EnergyPlus/Plant/DataPlant.hh>
      74             : #include <EnergyPlus/Plant/PlantLocation.hh>
      75             : #include <EnergyPlus/PlantCentralGSHP.hh>
      76             : #include <EnergyPlus/PlantUtilities.hh>
      77             : #include <EnergyPlus/ScheduleManager.hh>
      78             : #include <EnergyPlus/UtilityRoutines.hh>
      79             : 
      80             : namespace EnergyPlus::PlantCentralGSHP {
      81             : 
      82             : // MODULE INFORMATION:
      83             : //       AUTHOR         PNNL
      84             : //       DATE WRITTEN   Feb 2013
      85             : //       MODIFIED       na
      86             : //       RE-ENGINEERED  na
      87             : // PURPOSE OF THIS MODULE:
      88             : // This module simulates the performance of the Central Plant GSHP systems
      89             : // It currently includes one object: ChillerHeaterPerformance:Electric:EIR.
      90             : // The other object available for this central CGSHP system such as HeatPumpPerformance:WaterToWater:EIR
      91             : //      will be implemented later.
      92             : 
      93             : // METHODOLOGY EMPLOYED:
      94             : //  Once the PlantLoopManager determines that the Central Plant GSHP
      95             : //  is available to meet a loop cooling and heating demands, it calls simulate
      96             : //  which in turn calls the electric PlantCentralGSHP model. The PlantCentralGSHP model is based on
      97             : //  polynomial fits of chiller/heater or heat pump performance data.
      98             : 
      99           6 : PlantComponent *WrapperSpecs::factory(EnergyPlusData &state, std::string const &objectName)
     100             : {
     101             :     // Process the input data
     102           6 :     if (state.dataPlantCentralGSHP->getWrapperInputFlag) {
     103           2 :         GetWrapperInput(state);
     104           2 :         state.dataPlantCentralGSHP->getWrapperInputFlag = false;
     105             :     }
     106             : 
     107             :     // Now look for this particular object
     108           6 :     for (auto &thisWrapper : state.dataPlantCentralGSHP->Wrapper) {
     109           6 :         if (thisWrapper.Name == objectName) {
     110           6 :             return &thisWrapper;
     111             :         }
     112             :     }
     113             :     // If we didn't find it, fatal
     114             :     ShowFatalError(state, "LocalPlantCentralGSHPFactory: Error getting inputs for object named: " + objectName); // LCOV_EXCL_LINE
     115             :     // Shut up the compiler
     116             :     return nullptr; // LCOV_EXCL_LINE
     117             : }
     118             : 
     119          30 : void WrapperSpecs::onInitLoopEquip(EnergyPlusData &state, const PlantLocation &calledFromLocation)
     120             : {
     121          30 :     this->initialize(state, 0.0, calledFromLocation.loopNum);
     122          30 :     this->SizeWrapper(state);
     123          30 : }
     124             : 
     125          30 : void WrapperSpecs::getDesignCapacities(
     126             :     [[maybe_unused]] EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad)
     127             : {
     128          30 :     MinLoad = 0.0;
     129          30 :     MaxLoad = 0.0;
     130          30 :     OptLoad = 0.0;
     131          30 :     if (calledFromLocation.loopNum == this->CWPlantLoc.loopNum) { // Chilled water loop
     132          10 :         if (this->ControlMode == CondenserType::SmartMixing) {    // control mode is SmartMixing
     133          45 :             for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) {
     134          35 :                 MaxLoad += this->ChillerHeater(NumChillerHeater).RefCapCooling * this->ChillerHeater(NumChillerHeater).MaxPartLoadRatCooling;
     135          35 :                 OptLoad += this->ChillerHeater(NumChillerHeater).RefCapCooling * this->ChillerHeater(NumChillerHeater).OptPartLoadRatCooling;
     136          35 :                 MinLoad += this->ChillerHeater(NumChillerHeater).RefCapCooling * this->ChillerHeater(NumChillerHeater).MinPartLoadRatCooling;
     137             :             }
     138             :         }
     139          20 :     } else if (calledFromLocation.loopNum == this->HWPlantLoc.loopNum) { // Hot water loop
     140          10 :         if (this->ControlMode == CondenserType::SmartMixing) {           // control mode is SmartMixing
     141          45 :             for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) {
     142          35 :                 MaxLoad += this->ChillerHeater(NumChillerHeater).RefCapClgHtg * this->ChillerHeater(NumChillerHeater).MaxPartLoadRatClgHtg;
     143          35 :                 OptLoad += this->ChillerHeater(NumChillerHeater).RefCapClgHtg * this->ChillerHeater(NumChillerHeater).OptPartLoadRatClgHtg;
     144          35 :                 MinLoad += this->ChillerHeater(NumChillerHeater).RefCapClgHtg * this->ChillerHeater(NumChillerHeater).MinPartLoadRatClgHtg;
     145             :             }
     146             :         } // End of control mode determination
     147             :     }
     148          30 : }
     149             : 
     150           6 : void WrapperSpecs::getSizingFactor(Real64 &SizFac)
     151             : {
     152           6 :     SizFac = 1.0;
     153           6 : }
     154             : 
     155      255994 : void WrapperSpecs::simulate(
     156             :     EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, [[maybe_unused]] bool RunFlag)
     157             : {
     158      255994 :     if (calledFromLocation.loopNum != this->GLHEPlantLoc.loopNum) {
     159             : 
     160      170664 :         this->initialize(state, CurLoad, calledFromLocation.loopNum);
     161      170664 :         this->CalcWrapperModel(state, CurLoad, calledFromLocation.loopNum);
     162             : 
     163       85330 :     } else if (calledFromLocation.loopNum == this->GLHEPlantLoc.loopNum) {
     164      170660 :         PlantUtilities::UpdateChillerComponentCondenserSide(state,
     165       85330 :                                                             calledFromLocation.loopNum,
     166             :                                                             this->GLHEPlantLoc.loopSideNum,
     167             :                                                             DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump,
     168             :                                                             this->GLHEInletNodeNum,
     169             :                                                             this->GLHEOutletNodeNum,
     170             :                                                             this->Report.GLHERate,
     171             :                                                             this->Report.GLHEInletTemp,
     172             :                                                             this->Report.GLHEOutletTemp,
     173             :                                                             this->Report.GLHEmdot,
     174             :                                                             FirstHVACIteration);
     175             : 
     176             :         // Use the first chiller heater's evaporator capacity ratio to determine dominant load
     177       85330 :         this->SimulClgDominant = false;
     178       85330 :         this->SimulHtgDominant = false;
     179       85330 :         if (this->WrapperCoolingLoad > 0 && this->WrapperHeatingLoad > 0) {
     180       14608 :             Real64 SimulLoadRatio = this->WrapperCoolingLoad / this->WrapperHeatingLoad;
     181       14608 :             if (SimulLoadRatio > this->ChillerHeater(1).ClgHtgToCoolingCapRatio) {
     182       14608 :                 this->SimulClgDominant = true;
     183       14608 :                 this->SimulHtgDominant = false;
     184             :             } else {
     185           0 :                 this->SimulHtgDominant = true;
     186           0 :                 this->SimulClgDominant = false;
     187             :             }
     188             :         }
     189             :     }
     190      255994 : }
     191             : 
     192          30 : void WrapperSpecs::SizeWrapper(EnergyPlusData &state)
     193             : {
     194             :     // SUBROUTINE INFORMATION:
     195             :     //       AUTHOR         Yunzhi Huang, PNNL
     196             :     //       DATE WRITTEN   Feb 2013
     197             :     //       MODIFIED       November 2013 Daeho Kang, add component sizing table entries
     198             :     //       RE-ENGINEERED  na
     199             : 
     200             :     // PURPOSE OF THIS SUBROUTINE:
     201             :     //  This subroutine is for sizing all the components under each 'CentralHeatPumpSystem' object,
     202             :     //  for which capacities and flow rates have not been specified in the input.
     203             : 
     204             :     // METHODOLOGY EMPLOYED:
     205             :     //  Obtains evaporator flow rate from the plant sizing array. Calculates reference capacity from
     206             :     //  the evaporator (or load side) flow rate and the chilled water loop design delta T. The condenser
     207             :     //  flow (or source side) rate is calculated from the reference capacity, the COP, and the condenser
     208             :     //  loop design delta T.
     209             : 
     210             :     static constexpr std::string_view RoutineName("SizeCGSHPChillerHeater");
     211             : 
     212             :     bool ErrorsFound; // If errors detected in input
     213             : 
     214             :     // auto-size the chiller heater components
     215          30 :     if (this->ControlMode == CondenserType::SmartMixing) {
     216             : 
     217         135 :         for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) {
     218         105 :             ErrorsFound = false;
     219             : 
     220             :             // find the appropriate Plant Sizing object
     221         105 :             int PltSizNum = state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).PlantSizNum;
     222             : 
     223             :             // if ( Wrapper( WrapperNum ).ChillerHeater( NumChillerHeater ).CondVolFlowRate == AutoSize ) {
     224         105 :             int PltSizCondNum = state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).PlantSizNum;
     225             :             //}
     226             : 
     227         105 :             Real64 tmpNomCap = this->ChillerHeater(NumChillerHeater).RefCapCooling;
     228         105 :             Real64 tmpEvapVolFlowRate = this->ChillerHeater(NumChillerHeater).EvapVolFlowRate;
     229         105 :             Real64 tmpCondVolFlowRate = this->ChillerHeater(NumChillerHeater).CondVolFlowRate;
     230             : 
     231             :             // auto-size the Evaporator Flow Rate
     232         105 :             if (PltSizNum > 0) {
     233         105 :                 if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= DataHVACGlobals::SmallWaterVolFlow) {
     234          84 :                     tmpEvapVolFlowRate = state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate * this->ChillerHeater(NumChillerHeater).SizFac;
     235          84 :                     this->ChillerHeater(NumChillerHeater).tmpEvapVolFlowRate = tmpEvapVolFlowRate;
     236          84 :                     if (!this->ChillerHeater(NumChillerHeater).EvapVolFlowRateWasAutoSized)
     237          84 :                         tmpEvapVolFlowRate = this->ChillerHeater(NumChillerHeater).EvapVolFlowRate;
     238             : 
     239             :                 } else {
     240          21 :                     if (this->ChillerHeater(NumChillerHeater).EvapVolFlowRateWasAutoSized) tmpEvapVolFlowRate = 0.0;
     241          21 :                     this->ChillerHeater(NumChillerHeater).tmpEvapVolFlowRate = tmpEvapVolFlowRate;
     242             :                 }
     243         105 :                 if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     244          21 :                     if (this->ChillerHeater(NumChillerHeater).EvapVolFlowRateWasAutoSized) {
     245           0 :                         this->ChillerHeater(NumChillerHeater).EvapVolFlowRate = tmpEvapVolFlowRate;
     246           0 :                         if (state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     247           0 :                             BaseSizer::reportSizerOutput(state,
     248             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     249           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     250             :                                                          "Design Size Reference Chilled Water Flow Rate [m3/s]",
     251           0 :                                                          tmpEvapVolFlowRate);
     252             :                         }
     253           0 :                         if (state.dataPlnt->PlantFirstSizesOkayToReport) {
     254           0 :                             BaseSizer::reportSizerOutput(state,
     255             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     256           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     257             :                                                          "Initial Design Size Reference Chilled Water Flow Rate [m3/s]",
     258           0 :                                                          tmpEvapVolFlowRate);
     259             :                         }
     260             :                     } else {
     261          84 :                         if (this->ChillerHeater(NumChillerHeater).EvapVolFlowRate > 0.0 && tmpEvapVolFlowRate > 0.0 &&
     262          63 :                             state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     263             : 
     264             :                             // Hardsized evaporator design volume flow rate for reporting
     265           7 :                             Real64 EvapVolFlowRateUser = this->ChillerHeater(NumChillerHeater).EvapVolFlowRate;
     266          21 :                             BaseSizer::reportSizerOutput(state,
     267             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     268           7 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     269             :                                                          "Design Size Reference Chilled Water Flow Rate [m3/s]",
     270             :                                                          tmpEvapVolFlowRate,
     271             :                                                          "User-Specified Reference Chilled Water Flow Rate [m3/s]",
     272          14 :                                                          EvapVolFlowRateUser);
     273           7 :                             tmpEvapVolFlowRate = EvapVolFlowRateUser;
     274           7 :                             if (state.dataGlobal->DisplayExtraWarnings) {
     275           6 :                                 if ((std::abs(tmpEvapVolFlowRate - EvapVolFlowRateUser) / EvapVolFlowRateUser) >
     276           3 :                                     state.dataSize->AutoVsHardSizingThreshold) {
     277           0 :                                     ShowMessage(state,
     278           0 :                                                 "SizeChillerHeaterPerformanceElectricEIR: Potential issue with equipment sizing for " +
     279           0 :                                                     this->ChillerHeater(NumChillerHeater).Name);
     280           0 :                                     ShowContinueError(
     281           0 :                                         state, format("User-Specified Reference Chilled Water Flow Rate of {:.5R} [m3/s]", EvapVolFlowRateUser));
     282           0 :                                     ShowContinueError(
     283             :                                         state,
     284           0 :                                         format("differs from Design Size Reference Chilled Water Flow Rate of {:.5R} [m3/s]", tmpEvapVolFlowRate));
     285           0 :                                     ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
     286           0 :                                     ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
     287             :                                 }
     288             :                             }
     289             :                         }
     290             :                     }
     291             :                 }
     292             :             } else {
     293           0 :                 if (this->ChillerHeater(NumChillerHeater).EvapVolFlowRateWasAutoSized) {
     294           0 :                     if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     295           0 :                         ShowSevereError(state, "Autosizing of CGSHP Chiller Heater evap flow rate requires a loop Sizing:Plant object");
     296           0 :                         ShowContinueError(state, "Occurs in CGSHP Chiller Heater Performance object=" + this->ChillerHeater(NumChillerHeater).Name);
     297           0 :                         ErrorsFound = true;
     298             :                     }
     299             :                 } else {
     300           0 :                     if (this->ChillerHeater(NumChillerHeater).EvapVolFlowRate > 0.0 && state.dataPlnt->PlantFinalSizesOkayToReport &&
     301           0 :                         !this->mySizesReported) {
     302           0 :                         BaseSizer::reportSizerOutput(state,
     303             :                                                      "ChillerHeaterPerformance:Electric:EIR",
     304           0 :                                                      this->ChillerHeater(NumChillerHeater).Name,
     305             :                                                      "User-Specified Reference Chilled Water Flow Rate [m3/s]",
     306           0 :                                                      this->ChillerHeater(NumChillerHeater).EvapVolFlowRate);
     307             :                     }
     308             :                 }
     309             :             }
     310             : 
     311             :             // auto-size the Reference Cooling Capacity
     312             :             // each individual chiller heater module is sized to be capable of supporting the total load on the wrapper
     313         105 :             if (PltSizNum > 0) {
     314         105 :                 if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= DataHVACGlobals::SmallWaterVolFlow && tmpEvapVolFlowRate > 0.0) {
     315         168 :                     Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
     316          84 :                                                                        state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
     317             :                                                                        DataGlobalConstants::CWInitConvTemp,
     318          84 :                                                                        state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
     319          84 :                                                                        RoutineName);
     320             : 
     321         168 :                     Real64 rho = FluidProperties::GetDensityGlycol(state,
     322          84 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
     323             :                                                                    DataGlobalConstants::CWInitConvTemp,
     324          84 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
     325          84 :                                                                    RoutineName);
     326          84 :                     tmpNomCap = Cp * rho * state.dataSize->PlantSizData(PltSizNum).DeltaT * tmpEvapVolFlowRate;
     327          84 :                     if (!this->ChillerHeater(NumChillerHeater).RefCapCoolingWasAutoSized)
     328          84 :                         tmpNomCap = this->ChillerHeater(NumChillerHeater).RefCapCooling;
     329             :                 } else {
     330          21 :                     if (this->ChillerHeater(NumChillerHeater).RefCapCoolingWasAutoSized) tmpNomCap = 0.0;
     331             :                 }
     332         105 :                 if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     333          21 :                     if (this->ChillerHeater(NumChillerHeater).RefCapCoolingWasAutoSized) {
     334           0 :                         this->ChillerHeater(NumChillerHeater).RefCapCooling = tmpNomCap;
     335             : 
     336             :                         // Now that we have the Reference Cooling Capacity, we need to also initialize the Heating side
     337             :                         // given the ratios
     338           0 :                         this->ChillerHeater(NumChillerHeater).RefCapClgHtg =
     339           0 :                             this->ChillerHeater(NumChillerHeater).RefCapCooling * this->ChillerHeater(NumChillerHeater).ClgHtgToCoolingCapRatio;
     340             : 
     341           0 :                         this->ChillerHeater(NumChillerHeater).RefPowerClgHtg =
     342           0 :                             (this->ChillerHeater(NumChillerHeater).RefCapCooling / this->ChillerHeater(NumChillerHeater).RefCOPCooling) *
     343           0 :                             this->ChillerHeater(NumChillerHeater).ClgHtgtoCogPowerRatio;
     344             : 
     345           0 :                         this->ChillerHeater(NumChillerHeater).RefCOPClgHtg =
     346           0 :                             this->ChillerHeater(NumChillerHeater).RefCapClgHtg / this->ChillerHeater(NumChillerHeater).RefPowerClgHtg;
     347             : 
     348           0 :                         if (state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     349           0 :                             BaseSizer::reportSizerOutput(state,
     350             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     351           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     352             :                                                          "Design Size Reference Capacity [W]",
     353           0 :                                                          tmpNomCap);
     354             :                         }
     355           0 :                         if (state.dataPlnt->PlantFirstSizesOkayToReport) {
     356           0 :                             BaseSizer::reportSizerOutput(state,
     357             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     358           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     359             :                                                          "Initial Design Size Reference Capacity [W]",
     360           0 :                                                          tmpNomCap);
     361             :                         }
     362             :                     } else {
     363          84 :                         if (this->ChillerHeater(NumChillerHeater).RefCapCooling > 0.0 && tmpNomCap > 0.0 &&
     364          63 :                             state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     365             : 
     366             :                             // Hardsized nominal capacity cooling power for reporting
     367           7 :                             Real64 NomCapUser = this->ChillerHeater(NumChillerHeater).RefCapCooling;
     368          21 :                             BaseSizer::reportSizerOutput(state,
     369             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     370           7 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     371             :                                                          "Design Size Reference Capacity [W]",
     372             :                                                          tmpNomCap,
     373             :                                                          "User-Specified Reference Capacity [W]",
     374          14 :                                                          NomCapUser);
     375           7 :                             tmpNomCap = NomCapUser;
     376           7 :                             if (state.dataGlobal->DisplayExtraWarnings) {
     377           3 :                                 if ((std::abs(tmpNomCap - NomCapUser) / NomCapUser) > state.dataSize->AutoVsHardSizingThreshold) {
     378           0 :                                     ShowMessage(state,
     379           0 :                                                 "SizeChillerHeaterPerformanceElectricEIR: Potential issue with equipment sizing for " +
     380           0 :                                                     this->ChillerHeater(NumChillerHeater).Name);
     381           0 :                                     ShowContinueError(state, format("User-Specified Reference Capacity of {:.2R} [W]", NomCapUser));
     382           0 :                                     ShowContinueError(state, format("differs from Design Size Reference Capacity of {:.2R} [W]", tmpNomCap));
     383           0 :                                     ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
     384           0 :                                     ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
     385             :                                 }
     386             :                             }
     387             :                         }
     388             :                     }
     389             :                 }
     390             :             } else {
     391           0 :                 if (this->ChillerHeater(NumChillerHeater).RefCapCoolingWasAutoSized) {
     392           0 :                     if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     393           0 :                         ShowSevereError(state,
     394           0 :                                         "Size ChillerHeaterPerformance:Electric:EIR=\"" + this->ChillerHeater(NumChillerHeater).Name +
     395             :                                             "\", autosize error.");
     396           0 :                         ShowContinueError(state, "Autosizing of CGSHP Chiller Heater reference capacity requires");
     397           0 :                         ShowContinueError(state, "a cooling loop Sizing:Plant object.");
     398           0 :                         ErrorsFound = true;
     399             :                     }
     400             :                 } else {
     401           0 :                     if (this->ChillerHeater(NumChillerHeater).RefCapCooling > 0.0 && state.dataPlnt->PlantFinalSizesOkayToReport &&
     402           0 :                         !this->mySizesReported) {
     403           0 :                         BaseSizer::reportSizerOutput(state,
     404             :                                                      "ChillerHeaterPerformance:Electric:EIR",
     405           0 :                                                      this->ChillerHeater(NumChillerHeater).Name,
     406             :                                                      "User-Specified Reference Capacity [W]",
     407           0 :                                                      this->ChillerHeater(NumChillerHeater).RefCapCooling);
     408             :                     }
     409             :                 }
     410             :             }
     411             : 
     412             :             // auto-size the condenser volume flow rate
     413             :             // each individual chiller heater module is sized to be capable of supporting the total load on the wrapper
     414         105 :             if (PltSizCondNum > 0) {
     415         105 :                 if (state.dataSize->PlantSizData(PltSizNum).DesVolFlowRate >= DataHVACGlobals::SmallWaterVolFlow) {
     416         168 :                     Real64 rho = FluidProperties::GetDensityGlycol(state,
     417          84 :                                                                    state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidName,
     418             :                                                                    DataGlobalConstants::CWInitConvTemp,
     419          84 :                                                                    state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidIndex,
     420          84 :                                                                    RoutineName);
     421             :                     // TODO: JM 2018-12-06 I wonder why Cp isn't calculated at the same temp as rho...
     422         252 :                     Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
     423          84 :                                                                        state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidName,
     424          84 :                                                                        this->ChillerHeater(NumChillerHeater).TempRefCondInCooling,
     425          84 :                                                                        state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidIndex,
     426          84 :                                                                        RoutineName);
     427          84 :                     tmpCondVolFlowRate =
     428          84 :                         tmpNomCap *
     429         168 :                         (1.0 + (1.0 / this->ChillerHeater(NumChillerHeater).RefCOPCooling) * this->ChillerHeater(NumChillerHeater).OpenMotorEff) /
     430          84 :                         (state.dataSize->PlantSizData(PltSizCondNum).DeltaT * Cp * rho);
     431          84 :                     this->ChillerHeater(NumChillerHeater).tmpCondVolFlowRate = tmpCondVolFlowRate;
     432          84 :                     if (!this->ChillerHeater(NumChillerHeater).CondVolFlowRateWasAutoSized)
     433          84 :                         tmpCondVolFlowRate = this->ChillerHeater(NumChillerHeater).CondVolFlowRate;
     434             : 
     435             :                 } else {
     436          21 :                     if (this->ChillerHeater(NumChillerHeater).CondVolFlowRateWasAutoSized) tmpCondVolFlowRate = 0.0;
     437          21 :                     this->ChillerHeater(NumChillerHeater).tmpCondVolFlowRate = tmpCondVolFlowRate;
     438             :                 }
     439         105 :                 if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     440          21 :                     if (this->ChillerHeater(NumChillerHeater).CondVolFlowRateWasAutoSized) {
     441           0 :                         this->ChillerHeater(NumChillerHeater).CondVolFlowRate = tmpCondVolFlowRate;
     442           0 :                         if (state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     443           0 :                             BaseSizer::reportSizerOutput(state,
     444             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     445           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     446             :                                                          "Design Size Reference Condenser Water Flow Rate [m3/s]",
     447           0 :                                                          tmpCondVolFlowRate);
     448             :                         }
     449           0 :                         if (state.dataPlnt->PlantFirstSizesOkayToReport) {
     450           0 :                             BaseSizer::reportSizerOutput(state,
     451             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     452           0 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     453             :                                                          "Initial Design Size Reference Condenser Water Flow Rate [m3/s]",
     454           0 :                                                          tmpCondVolFlowRate);
     455             :                         }
     456             :                     } else {
     457          84 :                         if (this->ChillerHeater(NumChillerHeater).CondVolFlowRate > 0.0 && tmpCondVolFlowRate > 0.0 &&
     458          63 :                             state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     459             : 
     460             :                             // Hardsized condenser design volume flow rate for reporting
     461           7 :                             Real64 CondVolFlowRateUser = this->ChillerHeater(NumChillerHeater).CondVolFlowRate;
     462          21 :                             BaseSizer::reportSizerOutput(state,
     463             :                                                          "ChillerHeaterPerformance:Electric:EIR",
     464           7 :                                                          this->ChillerHeater(NumChillerHeater).Name,
     465             :                                                          "Design Size Reference Condenser Water Flow Rate [m3/s]",
     466             :                                                          tmpCondVolFlowRate,
     467             :                                                          "User-Specified Reference Condenser Water Flow Rate [m3/s]",
     468          14 :                                                          CondVolFlowRateUser);
     469           7 :                             if (state.dataGlobal->DisplayExtraWarnings) {
     470           6 :                                 if ((std::abs(tmpCondVolFlowRate - CondVolFlowRateUser) / CondVolFlowRateUser) >
     471           3 :                                     state.dataSize->AutoVsHardSizingThreshold) {
     472           0 :                                     ShowMessage(state,
     473           0 :                                                 "SizeChillerHeaterPerformanceElectricEIR: Potential issue with equipment sizing for " +
     474           0 :                                                     this->ChillerHeater(NumChillerHeater).Name);
     475           0 :                                     ShowContinueError(
     476           0 :                                         state, format("User-Specified Reference Condenser Water Flow Rate of {:.5R} [m3/s]", CondVolFlowRateUser));
     477           0 :                                     ShowContinueError(
     478             :                                         state,
     479           0 :                                         format("differs from Design Size Reference Condenser Water Flow Rate of {:.5R} [m3/s]", tmpCondVolFlowRate));
     480           0 :                                     ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
     481           0 :                                     ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
     482             :                                 }
     483             :                             }
     484             :                         }
     485             :                     }
     486             :                 }
     487             :             } else {
     488           0 :                 if (this->ChillerHeater(NumChillerHeater).CondVolFlowRateWasAutoSized) {
     489           0 :                     if (state.dataPlnt->PlantFirstSizesOkayToFinalize) {
     490           0 :                         ShowSevereError(state,
     491           0 :                                         "Size ChillerHeaterPerformance:Electric:EIR=\"" + this->ChillerHeater(NumChillerHeater).Name +
     492             :                                             "\", autosize error.");
     493           0 :                         ShowContinueError(state, "Autosizing of CGSHP Chiller Heater condenser flow rate requires");
     494           0 :                         ShowContinueError(state, "a condenser loop Sizing:Plant object.");
     495           0 :                         ErrorsFound = true;
     496             :                     }
     497             :                 } else {
     498           0 :                     if (this->ChillerHeater(NumChillerHeater).CondVolFlowRate > 0.0 && state.dataPlnt->PlantFinalSizesOkayToReport &&
     499           0 :                         !this->mySizesReported) {
     500           0 :                         BaseSizer::reportSizerOutput(state,
     501             :                                                      "ChillerHeaterPerformance:Electric:EIR",
     502           0 :                                                      this->ChillerHeater(NumChillerHeater).Name,
     503             :                                                      "User-Specified Reference Condenser Water Flow Rate [m3/s]",
     504           0 :                                                      this->ChillerHeater(NumChillerHeater).CondVolFlowRate);
     505             :                     }
     506             :                 }
     507             :             }
     508             : 
     509         105 :             if (state.dataPlnt->PlantFinalSizesOkayToReport && !this->mySizesReported) {
     510             :                 // create predefined report
     511          14 :                 std::string equipName = this->ChillerHeater(NumChillerHeater).Name;
     512          14 :                 OutputReportPredefined::PreDefTableEntry(
     513          14 :                     state, state.dataOutRptPredefined->pdchMechType, equipName, "ChillerHeaterPerformance:Electric:EIR");
     514          21 :                 OutputReportPredefined::PreDefTableEntry(
     515          14 :                     state, state.dataOutRptPredefined->pdchMechNomEff, equipName, this->ChillerHeater(NumChillerHeater).RefCOPCooling);
     516          21 :                 OutputReportPredefined::PreDefTableEntry(
     517          14 :                     state, state.dataOutRptPredefined->pdchMechNomCap, equipName, this->ChillerHeater(NumChillerHeater).RefCapCooling);
     518             :             }
     519             : 
     520         105 :             if (ErrorsFound) {
     521           0 :                 ShowFatalError(state, "Preceding sizing errors cause program termination");
     522             :             }
     523             :         }
     524             : 
     525             :         // sum individual volume flows and register wrapper inlets
     526          30 :         Real64 TotalEvapVolFlowRate = 0.0;
     527          30 :         Real64 TotalCondVolFlowRate = 0.0;
     528          30 :         Real64 TotalHotWaterVolFlowRate = 0.0;
     529         135 :         for (int NumChillerHeater = 1; NumChillerHeater <= this->ChillerHeaterNums; ++NumChillerHeater) {
     530         105 :             TotalEvapVolFlowRate += this->ChillerHeater(NumChillerHeater).tmpEvapVolFlowRate;
     531         105 :             TotalCondVolFlowRate += this->ChillerHeater(NumChillerHeater).tmpCondVolFlowRate;
     532         105 :             TotalHotWaterVolFlowRate += this->ChillerHeater(NumChillerHeater).DesignHotWaterVolFlowRate;
     533             :         }
     534             : 
     535          30 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->CHWInletNodeNum, TotalEvapVolFlowRate);
     536          30 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->HWInletNodeNum, TotalHotWaterVolFlowRate);
     537             :         // save the reference condenser water volumetric flow rate for use by the condenser water loop sizing algorithms
     538          30 :         PlantUtilities::RegisterPlantCompDesignFlow(state, this->GLHEInletNodeNum, TotalCondVolFlowRate);
     539             : 
     540          30 :         if (state.dataPlnt->PlantFinalSizesOkayToReport) {
     541           6 :             this->mySizesReported = true;
     542             :         }
     543             : 
     544          30 :         return;
     545             :     }
     546             : }
     547             : 
     548           2 : void GetWrapperInput(EnergyPlusData &state)
     549             : {
     550             :     // SUBROUTINE INFORMATION:
     551             :     //       AUTHOR:          Yunzhi Huang and Daeho Kang, PNNL
     552             :     //       DATE WRITTEN:    Feb 2013
     553             : 
     554             :     // PURPOSE OF THIS SUBROUTINE:
     555             :     //  This routine will get the input required by the Wrapper model.
     556             : 
     557           2 :     bool ErrorsFound(false); // True when input errors are found
     558             :     int NumAlphas;           // Number of elements in the alpha array
     559             :     int NumNums;             // Number of elements in the numeric array
     560             :     int IOStat;              // IO Status when calling get input subroutine
     561             : 
     562           2 :     state.dataIPShortCut->cCurrentModuleObject = "CentralHeatPumpSystem";
     563           2 :     state.dataPlantCentralGSHP->numWrappers =
     564           2 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject);
     565             : 
     566           2 :     if (state.dataPlantCentralGSHP->numWrappers <= 0) {
     567           0 :         ShowSevereError(state, "No " + state.dataIPShortCut->cCurrentModuleObject + " equipment specified in input file");
     568             :     }
     569             : 
     570           2 :     state.dataPlantCentralGSHP->Wrapper.allocate(state.dataPlantCentralGSHP->numWrappers);
     571             : 
     572             :     // Load arrays with electric EIR chiller data
     573           4 :     for (int WrapperNum = 1; WrapperNum <= state.dataPlantCentralGSHP->numWrappers; ++WrapperNum) {
     574          14 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     575           2 :                                                                  state.dataIPShortCut->cCurrentModuleObject,
     576             :                                                                  WrapperNum,
     577           2 :                                                                  state.dataIPShortCut->cAlphaArgs,
     578             :                                                                  NumAlphas,
     579           2 :                                                                  state.dataIPShortCut->rNumericArgs,
     580             :                                                                  NumNums,
     581             :                                                                  IOStat,
     582             :                                                                  _,
     583           2 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
     584           2 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
     585           2 :                                                                  state.dataIPShortCut->cNumericFieldNames);
     586             : 
     587           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     588             : 
     589             :         // initialize nth chiller heater index (including identical units) for current wrapper
     590           2 :         int NumChHtrPerWrapper = 0;
     591           2 :         if (UtilityRoutines::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, ErrorsFound)) {
     592           0 :             continue;
     593             :         }
     594             : 
     595           2 :         if (state.dataIPShortCut->cAlphaArgs(2) == "SMARTMIXING") {
     596           2 :             state.dataPlantCentralGSHP->Wrapper(WrapperNum).ControlMode = CondenserType::SmartMixing;
     597             :         }
     598             : 
     599           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).CHWInletNodeNum =
     600           4 :             NodeInputManager::GetOnlySingleNode(state,
     601           2 :                                                 state.dataIPShortCut->cAlphaArgs(3),
     602             :                                                 ErrorsFound,
     603             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     604           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     605             :                                                 DataLoopNode::NodeFluidType::Water,
     606             :                                                 DataLoopNode::ConnectionType::Inlet,
     607             :                                                 NodeInputManager::CompFluidStream::Primary,
     608           2 :                                                 DataLoopNode::ObjectIsNotParent); // node name : connection should be careful!
     609           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).CHWOutletNodeNum =
     610           4 :             NodeInputManager::GetOnlySingleNode(state,
     611           2 :                                                 state.dataIPShortCut->cAlphaArgs(4),
     612             :                                                 ErrorsFound,
     613             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     614           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     615             :                                                 DataLoopNode::NodeFluidType::Water,
     616             :                                                 DataLoopNode::ConnectionType::Outlet,
     617             :                                                 NodeInputManager::CompFluidStream::Primary,
     618           2 :                                                 DataLoopNode::ObjectIsNotParent);
     619           6 :         BranchNodeConnections::TestCompSet(state,
     620           2 :                                            state.dataIPShortCut->cCurrentModuleObject,
     621           2 :                                            state.dataIPShortCut->cAlphaArgs(1),
     622           2 :                                            state.dataIPShortCut->cAlphaArgs(3),
     623           2 :                                            state.dataIPShortCut->cAlphaArgs(4),
     624             :                                            "Chilled Water Nodes");
     625             : 
     626           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).GLHEInletNodeNum =
     627           4 :             NodeInputManager::GetOnlySingleNode(state,
     628           2 :                                                 state.dataIPShortCut->cAlphaArgs(5),
     629             :                                                 ErrorsFound,
     630             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     631           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     632             :                                                 DataLoopNode::NodeFluidType::Water,
     633             :                                                 DataLoopNode::ConnectionType::Inlet,
     634             :                                                 NodeInputManager::CompFluidStream::Secondary,
     635           2 :                                                 DataLoopNode::ObjectIsNotParent); // node name : connection should be careful!
     636           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).GLHEOutletNodeNum =
     637           4 :             NodeInputManager::GetOnlySingleNode(state,
     638           2 :                                                 state.dataIPShortCut->cAlphaArgs(6),
     639             :                                                 ErrorsFound,
     640             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     641           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     642             :                                                 DataLoopNode::NodeFluidType::Water,
     643             :                                                 DataLoopNode::ConnectionType::Outlet,
     644             :                                                 NodeInputManager::CompFluidStream::Secondary,
     645           2 :                                                 DataLoopNode::ObjectIsNotParent);
     646           6 :         BranchNodeConnections::TestCompSet(state,
     647           2 :                                            state.dataIPShortCut->cCurrentModuleObject,
     648           2 :                                            state.dataIPShortCut->cAlphaArgs(1),
     649           2 :                                            state.dataIPShortCut->cAlphaArgs(5),
     650           2 :                                            state.dataIPShortCut->cAlphaArgs(6),
     651             :                                            "GLHE Nodes");
     652             : 
     653           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).HWInletNodeNum =
     654           4 :             NodeInputManager::GetOnlySingleNode(state,
     655           2 :                                                 state.dataIPShortCut->cAlphaArgs(7),
     656             :                                                 ErrorsFound,
     657             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     658           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     659             :                                                 DataLoopNode::NodeFluidType::Water,
     660             :                                                 DataLoopNode::ConnectionType::Inlet,
     661             :                                                 NodeInputManager::CompFluidStream::Tertiary,
     662           2 :                                                 DataLoopNode::ObjectIsNotParent); // node name : connection should be careful!
     663           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).HWOutletNodeNum =
     664           4 :             NodeInputManager::GetOnlySingleNode(state,
     665           2 :                                                 state.dataIPShortCut->cAlphaArgs(8),
     666             :                                                 ErrorsFound,
     667             :                                                 DataLoopNode::ConnectionObjectType::CentralHeatPumpSystem,
     668           2 :                                                 state.dataIPShortCut->cAlphaArgs(1),
     669             :                                                 DataLoopNode::NodeFluidType::Water,
     670             :                                                 DataLoopNode::ConnectionType::Outlet,
     671             :                                                 NodeInputManager::CompFluidStream::Tertiary,
     672           2 :                                                 DataLoopNode::ObjectIsNotParent);
     673           6 :         BranchNodeConnections::TestCompSet(state,
     674           2 :                                            state.dataIPShortCut->cCurrentModuleObject,
     675           2 :                                            state.dataIPShortCut->cAlphaArgs(1),
     676           2 :                                            state.dataIPShortCut->cAlphaArgs(7),
     677           2 :                                            state.dataIPShortCut->cAlphaArgs(8),
     678             :                                            "Hot Water Nodes");
     679             : 
     680           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).AncillaryPower = state.dataIPShortCut->rNumericArgs(1);
     681           2 :         if (state.dataIPShortCut->lAlphaFieldBlanks(9)) {
     682           2 :             state.dataPlantCentralGSHP->Wrapper(WrapperNum).SchedPtr = 0;
     683             :         } else {
     684           0 :             state.dataPlantCentralGSHP->Wrapper(WrapperNum).SchedPtr = ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(9));
     685             :         }
     686             : 
     687           2 :         int NumberOfComp = (NumAlphas - 9) / 3;
     688           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).NumOfComp = NumberOfComp;
     689           2 :         state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp.allocate(NumberOfComp);
     690             : 
     691           2 :         if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).NumOfComp == 0) {
     692           0 :             ShowSevereError(state,
     693           0 :                             "GetWrapperInput: No component names on " + state.dataIPShortCut->cCurrentModuleObject + '=' +
     694           0 :                                 state.dataPlantCentralGSHP->Wrapper(WrapperNum).Name);
     695           0 :             ErrorsFound = true;
     696             :         } else {
     697           2 :             int Comp = 0;
     698           5 :             for (int loop = 10; loop <= NumAlphas; loop += 3) {
     699           3 :                 ++Comp;
     700           6 :                 state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType =
     701           6 :                     state.dataIPShortCut->cAlphaArgs(loop);
     702           3 :                 state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperComponentName = state.dataIPShortCut->cAlphaArgs(loop + 1);
     703           3 :                 if (state.dataIPShortCut->lAlphaFieldBlanks(loop + 2)) {
     704           0 :                     state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
     705             :                 } else {
     706           3 :                     state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr =
     707           3 :                         ScheduleManager::GetScheduleIndex(state, state.dataIPShortCut->cAlphaArgs(loop + 2));
     708           3 :                     if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr == 0) {
     709           0 :                         state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).CHSchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
     710           0 :                         ShowWarningError(state, "Chiller Heater Modules Control Schedule Name not found");
     711           0 :                         ShowContinueError(state,
     712           0 :                                           " for " + state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType +
     713           0 :                                               "= " + state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperComponentName);
     714           0 :                         ShowContinueError(
     715           0 :                             state, " in the object " + state.dataIPShortCut->cCurrentModuleObject + "= " + state.dataIPShortCut->cAlphaArgs(1));
     716           0 :                         ShowContinueError(state, "The Control Schedule is treated as AlwaysOn instead.");
     717             :                     }
     718             :                 }
     719           3 :                 state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperIdenticalObjectNum =
     720           3 :                     state.dataIPShortCut->rNumericArgs(1 + Comp);
     721           3 :                 if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType ==
     722             :                     "CHILLERHEATERPERFORMANCE:ELECTRIC:EIR") {
     723             : 
     724             :                     // count number of chiller heaters (including identical units) for current wrapper
     725           3 :                     if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperIdenticalObjectNum > 1) {
     726           3 :                         NumChHtrPerWrapper += state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperIdenticalObjectNum;
     727             :                     } else {
     728           0 :                         ++NumChHtrPerWrapper;
     729             :                     }
     730             : 
     731             :                     // count total number of chiller heaters (not including identical units) for ALL wrappers
     732           3 :                     ++state.dataPlantCentralGSHP->numChillerHeaters;
     733             :                 }
     734             :             }
     735             : 
     736           2 :             state.dataPlantCentralGSHP->Wrapper(WrapperNum).ChillerHeaterNums = NumChHtrPerWrapper;
     737             :         }
     738             : 
     739           2 :         if (ErrorsFound) {
     740           0 :             ShowFatalError(state,
     741           0 :                            "GetWrapperInput: Invalid " + state.dataIPShortCut->cCurrentModuleObject +
     742             :                                " Input, preceding condition(s) cause termination.");
     743             :         }
     744             : 
     745             :         // ALLOCATE ARRAYS
     746           2 :         if ((state.dataPlantCentralGSHP->numChillerHeaters == 0) &&
     747           0 :             (state.dataPlantCentralGSHP->Wrapper(WrapperNum).ControlMode == CondenserType::SmartMixing)) {
     748           0 :             ShowFatalError(state,
     749           0 :                            "SmartMixing Control Mode in object " + state.dataIPShortCut->cCurrentModuleObject + " : " +
     750           0 :                                state.dataPlantCentralGSHP->Wrapper(WrapperNum).Name +
     751             :                                " need to apply to ChillerHeaterPerformance:Electric:EIR object(s).");
     752             :         }
     753             :     }
     754             : 
     755           2 :     if (state.dataPlantCentralGSHP->numChillerHeaters > 0) {
     756             : 
     757           4 :         for (int WrapperNum = 1; WrapperNum <= state.dataPlantCentralGSHP->numWrappers; ++WrapperNum) {
     758           2 :             state.dataPlantCentralGSHP->Wrapper(WrapperNum).ChillerHeater.allocate(state.dataPlantCentralGSHP->Wrapper(WrapperNum).ChillerHeaterNums);
     759             :         }
     760           2 :         GetChillerHeaterInput(state);
     761             :     }
     762             : 
     763           4 :     for (int WrapperNum = 1; WrapperNum <= state.dataPlantCentralGSHP->numWrappers; ++WrapperNum) {
     764           2 :         int ChillerHeaterNum = 0; // initialize nth chiller heater index (including identical units) for current wrapper
     765           5 :         for (int Comp = 1; Comp <= state.dataPlantCentralGSHP->Wrapper(WrapperNum).NumOfComp; ++Comp) {
     766           3 :             if (state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectType ==
     767             :                 "CHILLERHEATERPERFORMANCE:ELECTRIC:EIR") {
     768           6 :                 std::string CompName = state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperComponentName;
     769           3 :                 int CompIndex = UtilityRoutines::FindItemInList(CompName, state.dataPlantCentralGSHP->ChillerHeater);
     770             :                 // User may enter invalid name rather than selecting one from the object list
     771           3 :                 if (CompIndex <= 0) {
     772           0 :                     ShowSevereError(state, "GetWrapperInput: Invalid Chiller Heater Modules Performance Component Name =" + std::string{CompName});
     773           0 :                     ShowContinueError(state, "Select the name of ChillerHeaterPerformance:Electric:EIR object(s) from the object list.");
     774           0 :                     ShowFatalError(state, "Program terminates due to preceding condition.");
     775             :                 }
     776           3 :                 state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperPerformanceObjectIndex = CompIndex;
     777           3 :                 if (state.dataPlantCentralGSHP->ChillerHeater(CompIndex).VariableFlow) {
     778           3 :                     state.dataPlantCentralGSHP->Wrapper(WrapperNum).VariableFlowCH = true;
     779             :                 }
     780          10 :                 for (int i_CH = 1; i_CH <= state.dataPlantCentralGSHP->Wrapper(WrapperNum).WrapperComp(Comp).WrapperIdenticalObjectNum; ++i_CH) {
     781             :                     // increment nth chiller heater index (including identical units) for current wrapper
     782           7 :                     ++ChillerHeaterNum;
     783           7 :                     state.dataPlantCentralGSHP->Wrapper(WrapperNum).ChillerHeater(ChillerHeaterNum) =
     784           7 :                         state.dataPlantCentralGSHP->ChillerHeater(CompIndex);
     785             :                 }
     786             :             }
     787             :         }
     788             :     }
     789             : 
     790             :     // Release memory from temporary arrays; values now copied into their associated Wrapper in above loop
     791           2 :     if (allocated(state.dataPlantCentralGSHP->ChillerHeater)) state.dataPlantCentralGSHP->ChillerHeater.deallocate();
     792             : 
     793             :     // Set up output variables
     794           2 :     for (int WrapperNum = 1; WrapperNum <= state.dataPlantCentralGSHP->numWrappers; ++WrapperNum) {
     795             :     } // End of wrapper count
     796           2 : }
     797             : 
     798           2 : void WrapperSpecs::setupOutputVars(EnergyPlusData &state)
     799             : {
     800           4 :     SetupOutputVariable(state,
     801             :                         "Chiller Heater System Cooling Electricity Energy",
     802             :                         OutputProcessor::Unit::J,
     803             :                         this->Report.TotElecCooling,
     804             :                         OutputProcessor::SOVTimeStepType::System,
     805             :                         OutputProcessor::SOVStoreType::Summed,
     806             :                         this->Name,
     807             :                         _,
     808             :                         "ELECTRICITY",
     809             :                         "Cooling",
     810             :                         _,
     811           2 :                         "Plant");
     812             : 
     813           4 :     SetupOutputVariable(state,
     814             :                         "Chiller Heater System Heating Electricity Energy",
     815             :                         OutputProcessor::Unit::J,
     816             :                         this->Report.TotElecHeating,
     817             :                         OutputProcessor::SOVTimeStepType::System,
     818             :                         OutputProcessor::SOVStoreType::Summed,
     819             :                         this->Name,
     820             :                         _,
     821             :                         "ELECTRICITY",
     822             :                         "Heating",
     823             :                         _,
     824           2 :                         "Plant");
     825             : 
     826           4 :     SetupOutputVariable(state,
     827             :                         "Chiller Heater System Cooling Electricity Rate",
     828             :                         OutputProcessor::Unit::W,
     829             :                         this->Report.TotElecCoolingPwr,
     830             :                         OutputProcessor::SOVTimeStepType::System,
     831             :                         OutputProcessor::SOVStoreType::Average,
     832           2 :                         this->Name);
     833             : 
     834           4 :     SetupOutputVariable(state,
     835             :                         "Chiller Heater System Heating Electricity Rate",
     836             :                         OutputProcessor::Unit::W,
     837             :                         this->Report.TotElecHeatingPwr,
     838             :                         OutputProcessor::SOVTimeStepType::System,
     839             :                         OutputProcessor::SOVStoreType::Average,
     840           2 :                         this->Name);
     841             : 
     842           4 :     SetupOutputVariable(state,
     843             :                         "Chiller Heater System Cooling Energy",
     844             :                         OutputProcessor::Unit::J,
     845             :                         this->Report.CoolingEnergy,
     846             :                         OutputProcessor::SOVTimeStepType::System,
     847             :                         OutputProcessor::SOVStoreType::Summed,
     848             :                         this->Name,
     849             :                         _,
     850             :                         "ENERGYTRANSFER",
     851             :                         "CHILLERS",
     852             :                         _,
     853           2 :                         "Plant");
     854             : 
     855           4 :     SetupOutputVariable(state,
     856             :                         "Chiller Heater System Heating Energy",
     857             :                         OutputProcessor::Unit::J,
     858             :                         this->Report.HeatingEnergy,
     859             :                         OutputProcessor::SOVTimeStepType::System,
     860             :                         OutputProcessor::SOVStoreType::Summed,
     861             :                         this->Name,
     862             :                         _,
     863             :                         "ENERGYTRANSFER",
     864             :                         "BOILER",
     865             :                         _,
     866           2 :                         "Plant");
     867             : 
     868           4 :     SetupOutputVariable(state,
     869             :                         "Chiller Heater System Source Heat Transfer Energy",
     870             :                         OutputProcessor::Unit::J,
     871             :                         this->Report.GLHEEnergy,
     872             :                         OutputProcessor::SOVTimeStepType::System,
     873             :                         OutputProcessor::SOVStoreType::Summed,
     874             :                         this->Name,
     875             :                         _,
     876             :                         "ENERGYTRANSFER",
     877             :                         "HEATREJECTION",
     878             :                         _,
     879           2 :                         "Plant");
     880             : 
     881           4 :     SetupOutputVariable(state,
     882             :                         "Chiller Heater System Cooling Rate",
     883             :                         OutputProcessor::Unit::W,
     884             :                         this->Report.CoolingRate,
     885             :                         OutputProcessor::SOVTimeStepType::System,
     886             :                         OutputProcessor::SOVStoreType::Average,
     887           2 :                         this->Name);
     888             : 
     889           4 :     SetupOutputVariable(state,
     890             :                         "Chiller Heater System Heating Rate",
     891             :                         OutputProcessor::Unit::W,
     892             :                         this->Report.HeatingRate,
     893             :                         OutputProcessor::SOVTimeStepType::System,
     894             :                         OutputProcessor::SOVStoreType::Average,
     895           2 :                         this->Name);
     896             : 
     897           4 :     SetupOutputVariable(state,
     898             :                         "Chiller Heater System Source Heat Transfer Rate",
     899             :                         OutputProcessor::Unit::W,
     900             :                         this->Report.GLHERate,
     901             :                         OutputProcessor::SOVTimeStepType::System,
     902             :                         OutputProcessor::SOVStoreType::Average,
     903           2 :                         this->Name);
     904             : 
     905           4 :     SetupOutputVariable(state,
     906             :                         "Chiller Heater System Cooling Mass Flow Rate",
     907             :                         OutputProcessor::Unit::kg_s,
     908             :                         this->Report.CHWmdot,
     909             :                         OutputProcessor::SOVTimeStepType::System,
     910             :                         OutputProcessor::SOVStoreType::Average,
     911           2 :                         this->Name);
     912             : 
     913           4 :     SetupOutputVariable(state,
     914             :                         "Chiller Heater System Heating Mass Flow Rate",
     915             :                         OutputProcessor::Unit::kg_s,
     916             :                         this->Report.HWmdot,
     917             :                         OutputProcessor::SOVTimeStepType::System,
     918             :                         OutputProcessor::SOVStoreType::Average,
     919           2 :                         this->Name);
     920             : 
     921           4 :     SetupOutputVariable(state,
     922             :                         "Chiller Heater System Source Mass Flow Rate",
     923             :                         OutputProcessor::Unit::kg_s,
     924             :                         this->Report.GLHEmdot,
     925             :                         OutputProcessor::SOVTimeStepType::System,
     926             :                         OutputProcessor::SOVStoreType::Average,
     927           2 :                         this->Name);
     928             : 
     929           4 :     SetupOutputVariable(state,
     930             :                         "Chiller Heater System Cooling Inlet Temperature",
     931             :                         OutputProcessor::Unit::C,
     932             :                         this->Report.CHWInletTemp,
     933             :                         OutputProcessor::SOVTimeStepType::System,
     934             :                         OutputProcessor::SOVStoreType::Average,
     935           2 :                         this->Name);
     936             : 
     937           4 :     SetupOutputVariable(state,
     938             :                         "Chiller Heater System Heating Inlet Temperature",
     939             :                         OutputProcessor::Unit::C,
     940             :                         this->Report.HWInletTemp,
     941             :                         OutputProcessor::SOVTimeStepType::System,
     942             :                         OutputProcessor::SOVStoreType::Average,
     943           2 :                         this->Name);
     944             : 
     945           4 :     SetupOutputVariable(state,
     946             :                         "Chiller Heater System Source Inlet Temperature",
     947             :                         OutputProcessor::Unit::C,
     948             :                         this->Report.GLHEInletTemp,
     949             :                         OutputProcessor::SOVTimeStepType::System,
     950             :                         OutputProcessor::SOVStoreType::Average,
     951           2 :                         this->Name);
     952             : 
     953           4 :     SetupOutputVariable(state,
     954             :                         "Chiller Heater System Cooling Outlet Temperature",
     955             :                         OutputProcessor::Unit::C,
     956             :                         this->Report.CHWOutletTemp,
     957             :                         OutputProcessor::SOVTimeStepType::System,
     958             :                         OutputProcessor::SOVStoreType::Average,
     959           2 :                         this->Name);
     960             : 
     961           4 :     SetupOutputVariable(state,
     962             :                         "Chiller Heater System Heating Outlet Temperature",
     963             :                         OutputProcessor::Unit::C,
     964             :                         this->Report.HWOutletTemp,
     965             :                         OutputProcessor::SOVTimeStepType::System,
     966             :                         OutputProcessor::SOVStoreType::Average,
     967           2 :                         this->Name);
     968             : 
     969           4 :     SetupOutputVariable(state,
     970             :                         "Chiller Heater System Source Outlet Temperature",
     971             :                         OutputProcessor::Unit::C,
     972             :                         this->Report.GLHEOutletTemp,
     973             :                         OutputProcessor::SOVTimeStepType::System,
     974             :                         OutputProcessor::SOVStoreType::Average,
     975           2 :                         this->Name);
     976             : 
     977           2 :     if (this->ChillerHeaterNums > 0) {
     978             : 
     979           9 :         for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
     980             : 
     981          35 :             SetupOutputVariable(state,
     982          14 :                                 format("Chiller Heater Operation Mode Unit {}", ChillerHeaterNum),
     983             :                                 OutputProcessor::Unit::None,
     984           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode,
     985             :                                 OutputProcessor::SOVTimeStepType::System,
     986             :                                 OutputProcessor::SOVStoreType::Average,
     987           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
     988             : 
     989          35 :             SetupOutputVariable(state,
     990          14 :                                 format("Chiller Heater Part Load Ratio Unit {}", ChillerHeaterNum),
     991             :                                 OutputProcessor::Unit::None,
     992           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatio,
     993             :                                 OutputProcessor::SOVTimeStepType::System,
     994             :                                 OutputProcessor::SOVStoreType::Average,
     995           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
     996             : 
     997          35 :             SetupOutputVariable(state,
     998          14 :                                 format("Chiller Heater Cycling Ratio Unit {}", ChillerHeaterNum),
     999             :                                 OutputProcessor::Unit::None,
    1000           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatio,
    1001             :                                 OutputProcessor::SOVTimeStepType::System,
    1002             :                                 OutputProcessor::SOVStoreType::Average,
    1003           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1004             : 
    1005          35 :             SetupOutputVariable(state,
    1006          14 :                                 format("Chiller Heater Cooling Electricity Rate Unit {}", ChillerHeaterNum),
    1007             :                                 OutputProcessor::Unit::W,
    1008           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower,
    1009             :                                 OutputProcessor::SOVTimeStepType::System,
    1010             :                                 OutputProcessor::SOVStoreType::Average,
    1011           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1012             : 
    1013          35 :             SetupOutputVariable(state,
    1014          14 :                                 format("Chiller Heater Heating Electricity Rate Unit {}", ChillerHeaterNum),
    1015             :                                 OutputProcessor::Unit::W,
    1016           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower,
    1017             :                                 OutputProcessor::SOVTimeStepType::System,
    1018             :                                 OutputProcessor::SOVStoreType::Average,
    1019           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1020             : 
    1021          35 :             SetupOutputVariable(state,
    1022          14 :                                 format("Chiller Heater Cooling Electricity Energy Unit {}", ChillerHeaterNum),
    1023             :                                 OutputProcessor::Unit::J,
    1024           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy,
    1025             :                                 OutputProcessor::SOVTimeStepType::System,
    1026             :                                 OutputProcessor::SOVStoreType::Summed,
    1027           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1028             : 
    1029          35 :             SetupOutputVariable(state,
    1030          14 :                                 format("Chiller Heater Heating Electricity Energy Unit {}", ChillerHeaterNum),
    1031             :                                 OutputProcessor::Unit::J,
    1032           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy,
    1033             :                                 OutputProcessor::SOVTimeStepType::System,
    1034             :                                 OutputProcessor::SOVStoreType::Summed,
    1035           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1036             : 
    1037          35 :             SetupOutputVariable(state,
    1038          14 :                                 format("Chiller Heater Cooling Rate Unit {}", ChillerHeaterNum),
    1039             :                                 OutputProcessor::Unit::W,
    1040           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.QEvap,
    1041             :                                 OutputProcessor::SOVTimeStepType::System,
    1042             :                                 OutputProcessor::SOVStoreType::Average,
    1043           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1044             : 
    1045          35 :             SetupOutputVariable(state,
    1046          14 :                                 format("Chiller Heater Cooling Energy Unit {}", ChillerHeaterNum),
    1047             :                                 OutputProcessor::Unit::J,
    1048           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy,
    1049             :                                 OutputProcessor::SOVTimeStepType::System,
    1050             :                                 OutputProcessor::SOVStoreType::Summed,
    1051           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1052             : 
    1053          35 :             SetupOutputVariable(state,
    1054          14 :                                 format("Chiller Heater False Load Heat Transfer Rate Unit {}", ChillerHeaterNum),
    1055             :                                 OutputProcessor::Unit::W,
    1056           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate,
    1057             :                                 OutputProcessor::SOVTimeStepType::System,
    1058             :                                 OutputProcessor::SOVStoreType::Average,
    1059           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1060             : 
    1061          35 :             SetupOutputVariable(state,
    1062          14 :                                 format("Chiller Heater False Load Heat Transfer Energy Unit {}", ChillerHeaterNum),
    1063             :                                 OutputProcessor::Unit::J,
    1064           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad,
    1065             :                                 OutputProcessor::SOVTimeStepType::System,
    1066             :                                 OutputProcessor::SOVStoreType::Summed,
    1067           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1068             : 
    1069          35 :             SetupOutputVariable(state,
    1070          14 :                                 format("Chiller Heater Evaporator Inlet Temperature Unit {}", ChillerHeaterNum),
    1071             :                                 OutputProcessor::Unit::C,
    1072           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTemp,
    1073             :                                 OutputProcessor::SOVTimeStepType::System,
    1074             :                                 OutputProcessor::SOVStoreType::Average,
    1075           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1076             : 
    1077          35 :             SetupOutputVariable(state,
    1078          14 :                                 format("Chiller Heater Evaporator Outlet Temperature Unit {}", ChillerHeaterNum),
    1079             :                                 OutputProcessor::Unit::C,
    1080           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp,
    1081             :                                 OutputProcessor::SOVTimeStepType::System,
    1082             :                                 OutputProcessor::SOVStoreType::Average,
    1083           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1084             : 
    1085          35 :             SetupOutputVariable(state,
    1086          14 :                                 format("Chiller Heater Evaporator Mass Flow Rate Unit {}", ChillerHeaterNum),
    1087             :                                 OutputProcessor::Unit::kg_s,
    1088           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot,
    1089             :                                 OutputProcessor::SOVTimeStepType::System,
    1090             :                                 OutputProcessor::SOVStoreType::Average,
    1091           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1092             : 
    1093          35 :             SetupOutputVariable(state,
    1094          14 :                                 format("Chiller Heater Condenser Heat Transfer Rate Unit {}", ChillerHeaterNum),
    1095             :                                 OutputProcessor::Unit::W,
    1096           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.QCond,
    1097             :                                 OutputProcessor::SOVTimeStepType::System,
    1098             :                                 OutputProcessor::SOVStoreType::Average,
    1099           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1100             : 
    1101          35 :             SetupOutputVariable(state,
    1102          14 :                                 format("Chiller Heater Condenser Heat Transfer Energy Unit {}", ChillerHeaterNum),
    1103             :                                 OutputProcessor::Unit::J,
    1104           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy,
    1105             :                                 OutputProcessor::SOVTimeStepType::System,
    1106             :                                 OutputProcessor::SOVStoreType::Summed,
    1107           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1108             : 
    1109          35 :             SetupOutputVariable(state,
    1110          14 :                                 format("Chiller Heater COP Unit {}", ChillerHeaterNum),
    1111             :                                 OutputProcessor::Unit::W_W,
    1112           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ActualCOP,
    1113             :                                 OutputProcessor::SOVTimeStepType::System,
    1114             :                                 OutputProcessor::SOVStoreType::Average,
    1115           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1116             : 
    1117          35 :             SetupOutputVariable(state,
    1118          14 :                                 format("Chiller Heater Capacity Temperature Modifier Multiplier Unit {}", ChillerHeaterNum),
    1119             :                                 OutputProcessor::Unit::None,
    1120           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFT,
    1121             :                                 OutputProcessor::SOVTimeStepType::System,
    1122             :                                 OutputProcessor::SOVStoreType::Average,
    1123           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1124             : 
    1125          35 :             SetupOutputVariable(state,
    1126          14 :                                 format("Chiller Heater EIR Temperature Modifier Multiplier Unit {}", ChillerHeaterNum),
    1127             :                                 OutputProcessor::Unit::None,
    1128           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFT,
    1129             :                                 OutputProcessor::SOVTimeStepType::System,
    1130             :                                 OutputProcessor::SOVStoreType::Average,
    1131           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1132             : 
    1133          35 :             SetupOutputVariable(state,
    1134          14 :                                 format("Chiller Heater EIR Part Load Modifier Multiplier Unit {}", ChillerHeaterNum),
    1135             :                                 OutputProcessor::Unit::None,
    1136           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLR,
    1137             :                                 OutputProcessor::SOVTimeStepType::System,
    1138             :                                 OutputProcessor::SOVStoreType::Average,
    1139           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1140             : 
    1141          35 :             SetupOutputVariable(state,
    1142          14 :                                 format("Chiller Heater Condenser Inlet Temperature Unit {}", ChillerHeaterNum),
    1143             :                                 OutputProcessor::Unit::C,
    1144           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CondInletTemp,
    1145             :                                 OutputProcessor::SOVTimeStepType::System,
    1146             :                                 OutputProcessor::SOVStoreType::Average,
    1147           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1148             : 
    1149          35 :             SetupOutputVariable(state,
    1150          14 :                                 format("Chiller Heater Condenser Outlet Temperature Unit {}", ChillerHeaterNum),
    1151             :                                 OutputProcessor::Unit::C,
    1152           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp,
    1153             :                                 OutputProcessor::SOVTimeStepType::System,
    1154             :                                 OutputProcessor::SOVStoreType::Average,
    1155           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1156             : 
    1157          35 :             SetupOutputVariable(state,
    1158          14 :                                 format("Chiller Heater Condenser Mass Flow Rate Unit {}", ChillerHeaterNum),
    1159             :                                 OutputProcessor::Unit::kg_s,
    1160           7 :                                 this->ChillerHeater(ChillerHeaterNum).Report.Condmdot,
    1161             :                                 OutputProcessor::SOVTimeStepType::System,
    1162             :                                 OutputProcessor::SOVStoreType::Average,
    1163           7 :                                 this->ChillerHeater(ChillerHeaterNum).Name);
    1164             :         } // End of individual chiller heater count for current wrapper
    1165             : 
    1166             :     } // End of individual chiller heater output
    1167           2 : }
    1168             : 
    1169           2 : void GetChillerHeaterInput(EnergyPlusData &state)
    1170             : {
    1171             :     // SUBROUTINE INFORMATION:
    1172             :     //       AUTHOR:          Kyung Tae Yun, Mississippi State University
    1173             :     //       DATE WRITTEN:    Feb 2013
    1174             : 
    1175             :     // PURPOSE OF THIS SUBROUTINE:
    1176             :     //  This routine will get the input required by the ChillerHeaterPerformance:Electric:EIR model.
    1177             : 
    1178           2 :     bool CHErrorsFound(false);         // True when input errors are found
    1179           2 :     bool FoundNegValue(false);         // Used to evaluate PLFFPLR curve objects
    1180             :     int NumAlphas;                     // Number of elements in the alpha array
    1181             :     int NumNums;                       // Number of elements in the numeric array
    1182             :     int IOStat;                        // IO Status when calling get input subroutine
    1183           4 :     Array1D<Real64> CurveValArray(11); // Used to evaluate PLFFPLR curve objects
    1184             : 
    1185           2 :     state.dataIPShortCut->cCurrentModuleObject = "ChillerHeaterPerformance:Electric:EIR";
    1186           2 :     state.dataPlantCentralGSHP->numChillerHeaters =
    1187           2 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject);
    1188             : 
    1189           2 :     if (state.dataPlantCentralGSHP->numChillerHeaters <= 0) {
    1190           0 :         ShowSevereError(state, "No " + state.dataIPShortCut->cCurrentModuleObject + " equipment specified in input file");
    1191           0 :         CHErrorsFound = true;
    1192             :     }
    1193             : 
    1194             :     // Allocate temporary ChillerHeater and ChillerHeaterReport arrays
    1195           2 :     if (allocated(state.dataPlantCentralGSHP->ChillerHeater)) state.dataPlantCentralGSHP->ChillerHeater.deallocate();
    1196           2 :     state.dataPlantCentralGSHP->ChillerHeater.allocate(state.dataPlantCentralGSHP->numChillerHeaters);
    1197             : 
    1198             :     // Load arrays with electric EIR chiller data
    1199           5 :     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= state.dataPlantCentralGSHP->numChillerHeaters; ++ChillerHeaterNum) {
    1200          21 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1201           3 :                                                                  state.dataIPShortCut->cCurrentModuleObject,
    1202             :                                                                  ChillerHeaterNum,
    1203           3 :                                                                  state.dataIPShortCut->cAlphaArgs,
    1204             :                                                                  NumAlphas,
    1205           3 :                                                                  state.dataIPShortCut->rNumericArgs,
    1206             :                                                                  NumNums,
    1207             :                                                                  IOStat,
    1208             :                                                                  _,
    1209           3 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1210           3 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1211           3 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1212             : 
    1213           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).Name = state.dataIPShortCut->cAlphaArgs(1);
    1214           3 :         UtilityRoutines::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), state.dataIPShortCut->cCurrentModuleObject, CHErrorsFound);
    1215             : 
    1216           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).CondModeCooling = state.dataIPShortCut->cAlphaArgs(4);
    1217             : 
    1218             :         // Performance curves
    1219           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTCoolingIDX =
    1220           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(5));
    1221           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTCoolingIDX == 0) {
    1222           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1223           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(5) + '=' + state.dataIPShortCut->cAlphaArgs(5));
    1224           0 :             CHErrorsFound = true;
    1225             :         }
    1226             : 
    1227           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTCoolingIDX =
    1228           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(6));
    1229           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTCoolingIDX == 0) {
    1230           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1231           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(6) + '=' + state.dataIPShortCut->cAlphaArgs(6));
    1232           0 :             CHErrorsFound = true;
    1233             :         }
    1234             : 
    1235           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX =
    1236           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(7));
    1237           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX == 0) {
    1238           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1239           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(7) + '=' + state.dataIPShortCut->cAlphaArgs(7));
    1240           0 :             CHErrorsFound = true;
    1241             :         }
    1242             : 
    1243           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).CondModeHeating = state.dataIPShortCut->cAlphaArgs(8);
    1244             : 
    1245             :         // Performance curves
    1246           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX =
    1247           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(9));
    1248           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX == 0) {
    1249           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1250           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(9) + '=' + state.dataIPShortCut->cAlphaArgs(9));
    1251           0 :             CHErrorsFound = true;
    1252             :         }
    1253             : 
    1254           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX =
    1255           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(10));
    1256           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX == 0) {
    1257           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1258           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(10) + '=' + state.dataIPShortCut->cAlphaArgs(10));
    1259           0 :             CHErrorsFound = true;
    1260             :         }
    1261             : 
    1262           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX =
    1263           3 :             Curve::GetCurveIndex(state, state.dataIPShortCut->cAlphaArgs(11));
    1264           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX == 0) {
    1265           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1266           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(11) + '=' + state.dataIPShortCut->cAlphaArgs(11));
    1267           0 :             CHErrorsFound = true;
    1268             :         }
    1269             : 
    1270           3 :         if (state.dataIPShortCut->cAlphaArgs(2) == "CONSTANTFLOW") {
    1271           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ConstantFlow = true;
    1272           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).VariableFlow = false;
    1273           3 :         } else if (state.dataIPShortCut->cAlphaArgs(2) == "VARIABLEFLOW") {
    1274           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ConstantFlow = false;
    1275           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).VariableFlow = true;
    1276             :         } else { // Assume a constant flow chiller if none is specified
    1277           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ConstantFlow = true;
    1278           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).VariableFlow = false;
    1279           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1280           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(2) + '=' + state.dataIPShortCut->cAlphaArgs(2));
    1281           0 :             ShowContinueError(state, "simulation assumes CONSTANTFLOW and continues..");
    1282             :         }
    1283             : 
    1284           3 :         if (ChillerHeaterNum > 1) {
    1285           2 :             if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ConstantFlow !=
    1286           1 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum - 1).ConstantFlow) {
    1287           0 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ConstantFlow = true;
    1288           0 :                 ShowWarningError(state,
    1289           0 :                                  "Water flow mode is different from the other chiller heater(s) " + state.dataIPShortCut->cCurrentModuleObject + '=' +
    1290           0 :                                      state.dataIPShortCut->cAlphaArgs(1));
    1291           0 :                 ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(2) + '=' + state.dataIPShortCut->cAlphaArgs(2));
    1292           0 :                 ShowContinueError(state, "Simulation assumes CONSTANTFLOW and continues..");
    1293             :             }
    1294             :         }
    1295             : 
    1296           3 :         if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(3), "WaterCooled")) {
    1297           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).condenserType = CondenserType::WaterCooled;
    1298             :         } else {
    1299           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1300           0 :             ShowContinueError(state, "Entered in " + state.dataIPShortCut->cAlphaFieldNames(3) + '=' + state.dataIPShortCut->cAlphaArgs(3));
    1301           0 :             ShowContinueError(state, "Valid entries is WaterCooled");
    1302           0 :             CHErrorsFound = true;
    1303             :         }
    1304             : 
    1305             :         // Chiller rated performance data
    1306           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCooling = state.dataIPShortCut->rNumericArgs(1);
    1307           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCooling == DataSizing::AutoSize) {
    1308           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCoolingWasAutoSized = true;
    1309             :         }
    1310           3 :         if (state.dataIPShortCut->rNumericArgs(1) == 0.0) {
    1311           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1312           0 :             ShowContinueError(state,
    1313           0 :                               format("Entered in {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(1), state.dataIPShortCut->rNumericArgs(1)));
    1314           0 :             CHErrorsFound = true;
    1315             :         }
    1316           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCOPCooling = state.dataIPShortCut->rNumericArgs(2);
    1317           3 :         if (state.dataIPShortCut->rNumericArgs(2) == 0.0) {
    1318           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1319           0 :             ShowContinueError(state,
    1320           0 :                               format("Entered in {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->rNumericArgs(2)));
    1321           0 :             CHErrorsFound = true;
    1322             :         }
    1323             : 
    1324           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutCooling = state.dataIPShortCut->rNumericArgs(3);
    1325           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInCooling = state.dataIPShortCut->rNumericArgs(4);
    1326           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondOutCooling = state.dataIPShortCut->rNumericArgs(5);
    1327             : 
    1328             :         // Reference Heating Mode Ratios for Capacity and Power
    1329           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ClgHtgToCoolingCapRatio = state.dataIPShortCut->rNumericArgs(6);
    1330           3 :         if (state.dataIPShortCut->rNumericArgs(6) == 0.0) {
    1331           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1332           0 :             ShowContinueError(state,
    1333           0 :                               format("Entered in {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(6), state.dataIPShortCut->rNumericArgs(6)));
    1334           0 :             CHErrorsFound = true;
    1335             :         }
    1336             : 
    1337           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ClgHtgtoCogPowerRatio = state.dataIPShortCut->rNumericArgs(7);
    1338           3 :         if (state.dataIPShortCut->rNumericArgs(7) == 0.0) {
    1339           0 :             ShowSevereError(state, "Invalid " + state.dataIPShortCut->cCurrentModuleObject + '=' + state.dataIPShortCut->cAlphaArgs(1));
    1340           0 :             ShowContinueError(state,
    1341           0 :                               format("Entered in {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(7), state.dataIPShortCut->rNumericArgs(7)));
    1342           0 :             CHErrorsFound = true;
    1343             :         }
    1344             : 
    1345           3 :         if (!state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCoolingWasAutoSized) {
    1346           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapClgHtg =
    1347           6 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ClgHtgToCoolingCapRatio *
    1348           3 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCooling;
    1349           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefPowerClgHtg =
    1350           6 :                 (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapCooling /
    1351           6 :                  state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCOPCooling) *
    1352           3 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ClgHtgtoCogPowerRatio;
    1353           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCOPClgHtg =
    1354           6 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefCapClgHtg /
    1355           3 :                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).RefPowerClgHtg;
    1356             :         }
    1357             : 
    1358           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg = state.dataIPShortCut->rNumericArgs(8);
    1359           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondOutClgHtg = state.dataIPShortCut->rNumericArgs(9);
    1360           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInClgHtg = state.dataIPShortCut->rNumericArgs(10);
    1361           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempLowLimitEvapOut = state.dataIPShortCut->rNumericArgs(11);
    1362           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate = state.dataIPShortCut->rNumericArgs(12);
    1363           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate == DataSizing::AutoSize) {
    1364           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).EvapVolFlowRateWasAutoSized = true;
    1365             :         }
    1366           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).CondVolFlowRate = state.dataIPShortCut->rNumericArgs(13);
    1367           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).CondVolFlowRate == DataSizing::AutoSize) {
    1368           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).CondVolFlowRateWasAutoSized = true;
    1369             :         }
    1370           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).DesignHotWaterVolFlowRate = state.dataIPShortCut->rNumericArgs(14);
    1371           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).OpenMotorEff = state.dataIPShortCut->rNumericArgs(15);
    1372           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).OptPartLoadRatCooling = state.dataIPShortCut->rNumericArgs(16);
    1373           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).OptPartLoadRatClgHtg = state.dataIPShortCut->rNumericArgs(17);
    1374           3 :         state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).SizFac = state.dataIPShortCut->rNumericArgs(18);
    1375             : 
    1376           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).SizFac <= 0.0)
    1377           0 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).SizFac = 1.0;
    1378             : 
    1379           6 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).OpenMotorEff < 0.0 ||
    1380           3 :             state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).OpenMotorEff > 1.0) {
    1381           0 :             ShowSevereError(state, "GetCurveInput: For " + state.dataIPShortCut->cCurrentModuleObject + ": " + state.dataIPShortCut->cAlphaArgs(1));
    1382           0 :             ShowContinueError(state, format("{} = {:.3R}", state.dataIPShortCut->cNumericFieldNames(14), state.dataIPShortCut->rNumericArgs(14)));
    1383           0 :             ShowContinueError(state, state.dataIPShortCut->cNumericFieldNames(14) + " must be greater than or equal to zero");
    1384           0 :             ShowContinueError(state, state.dataIPShortCut->cNumericFieldNames(14) + " must be less than or equal to one");
    1385           0 :             CHErrorsFound = true;
    1386             :         }
    1387             : 
    1388             :         // Check the CAP-FT, EIR-FT, and PLR curves and warn user if different from 1.0 by more than +-10%
    1389           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTCoolingIDX > 0) {
    1390          15 :             Real64 CurveVal = Curve::CurveValue(state,
    1391           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTCoolingIDX,
    1392           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutCooling,
    1393           6 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInCooling);
    1394           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1395           0 :                 ShowWarningError(state, "Capacity ratio as a function of temperature curve output is not equal to 1.0");
    1396           0 :                 ShowContinueError(state,
    1397           0 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1398           0 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1399           0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1400             :             }
    1401             :         }
    1402             : 
    1403           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTCoolingIDX > 0) {
    1404          15 :             Real64 CurveVal = Curve::CurveValue(state,
    1405           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTCoolingIDX,
    1406           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutCooling,
    1407           6 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInCooling);
    1408           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1409           0 :                 ShowWarningError(state, "Energy input ratio as a function of temperature curve output is not equal to 1.0");
    1410           0 :                 ShowContinueError(state,
    1411           0 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1412           0 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1413           0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1414             :             }
    1415             :         }
    1416             : 
    1417           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX > 0) {
    1418           3 :             Real64 CurveVal = Curve::CurveValue(state, state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX, 1.0);
    1419             : 
    1420           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1421           0 :                 ShowWarningError(state, "Energy input ratio as a function of part-load ratio curve output is not equal to 1.0");
    1422           0 :                 ShowContinueError(state,
    1423           0 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1424           0 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1425           0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1426             :             }
    1427             :         }
    1428             : 
    1429           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX > 0) {
    1430           3 :             FoundNegValue = false;
    1431          36 :             for (int CurveCheck = 0; CurveCheck <= 10; ++CurveCheck) {
    1432          99 :                 Real64 CurveValTmp = Curve::CurveValue(
    1433          66 :                     state, state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX, double(CurveCheck / 10.0));
    1434          33 :                 if (CurveValTmp < 0.0) FoundNegValue = true;
    1435          33 :                 CurveValArray(CurveCheck + 1) = int(CurveValTmp * 100.0) / 100.0;
    1436             :             }
    1437           3 :             if (FoundNegValue) {
    1438           0 :                 ShowWarningError(state, "Energy input ratio as a function of part-load ratio curve shows negative values ");
    1439           0 :                 ShowContinueError(state, "for " + state.dataIPShortCut->cCurrentModuleObject + "= " + state.dataIPShortCut->cAlphaArgs(1));
    1440           0 :                 ShowContinueError(state, "EIR as a function of PLR curve output at various part-load ratios shown below:");
    1441           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");
    1442             : 
    1443           0 :                 ShowContinueError(state, fmt::format("Curve Output = {:7.2F}", fmt::join(CurveValArray, ",")));
    1444             : 
    1445           0 :                 CHErrorsFound = true;
    1446             :             }
    1447             :         }
    1448             : 
    1449           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX > 0) {
    1450          15 :             Real64 CurveVal = Curve::CurveValue(state,
    1451           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX,
    1452           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg,
    1453           6 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInClgHtg);
    1454           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1455           3 :                 ShowWarningError(state, "Capacity ratio as a function of temperature curve output is not equal to 1.0");
    1456           9 :                 ShowContinueError(state,
    1457           6 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1458           3 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1459           3 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1460             :             }
    1461             :         }
    1462             : 
    1463           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX > 0) {
    1464          15 :             Real64 CurveVal = Curve::CurveValue(state,
    1465           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX,
    1466           3 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg,
    1467           6 :                                                 state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).TempRefCondInClgHtg);
    1468           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1469           3 :                 ShowWarningError(state, "Energy input ratio as a function of temperature curve output is not equal to 1.0");
    1470           9 :                 ShowContinueError(state,
    1471           6 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1472           3 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1473           3 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1474             :             }
    1475             :         }
    1476             : 
    1477           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX > 0) {
    1478           3 :             Real64 CurveVal = Curve::CurveValue(state, state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX, 1.0);
    1479             : 
    1480           3 :             if (CurveVal > 1.10 || CurveVal < 0.90) {
    1481           0 :                 ShowWarningError(state, "Energy input ratio as a function of part-load ratio curve output is not equal to 1.0");
    1482           0 :                 ShowContinueError(state,
    1483           0 :                                   "(+ or - 10%) at reference conditions for " + state.dataIPShortCut->cCurrentModuleObject + "= " +
    1484           0 :                                       state.dataIPShortCut->cAlphaArgs(1));
    1485           0 :                 ShowContinueError(state, format("Curve output at reference conditions = {:.3T}", CurveVal));
    1486             :             }
    1487             :         }
    1488             : 
    1489           3 :         if (state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX > 0) {
    1490           3 :             FoundNegValue = false;
    1491          36 :             for (int CurveCheck = 0; CurveCheck <= 10; ++CurveCheck) {
    1492          99 :                 Real64 CurveValTmp = Curve::CurveValue(
    1493          66 :                     state, state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX, double(CurveCheck / 10.0));
    1494          33 :                 if (CurveValTmp < 0.0) FoundNegValue = true;
    1495          33 :                 CurveValArray(CurveCheck + 1) = int(CurveValTmp * 100.0) / 100.0;
    1496             :             }
    1497           3 :             if (FoundNegValue) {
    1498           0 :                 ShowWarningError(state, "Energy input ratio as a function of part-load ratio curve shows negative values ");
    1499           0 :                 ShowContinueError(state, "for " + state.dataIPShortCut->cCurrentModuleObject + "= " + state.dataIPShortCut->cAlphaArgs(1));
    1500           0 :                 ShowContinueError(state, "EIR as a function of PLR curve output at various part-load ratios shown below:");
    1501           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");
    1502             : 
    1503           0 :                 const auto curve_output = fmt::format("Curve Output = {:7.2F}", fmt::join(CurveValArray, ","));
    1504           0 :                 ShowContinueError(state, curve_output);
    1505             : 
    1506           0 :                 CHErrorsFound = true;
    1507             :             }
    1508             :         }
    1509             : 
    1510          12 :         Curve::GetCurveMinMaxValues(state,
    1511           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX,
    1512           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).MinPartLoadRatClgHtg,
    1513           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).MaxPartLoadRatClgHtg);
    1514             : 
    1515          12 :         Curve::GetCurveMinMaxValues(state,
    1516           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX,
    1517           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).MinPartLoadRatCooling,
    1518           3 :                                     state.dataPlantCentralGSHP->ChillerHeater(ChillerHeaterNum).MaxPartLoadRatCooling);
    1519             :     }
    1520             : 
    1521           2 :     if (CHErrorsFound) {
    1522           0 :         ShowFatalError(state, "Errors found in processing input for " + state.dataIPShortCut->cCurrentModuleObject);
    1523             :     }
    1524           2 : }
    1525             : 
    1526      170694 : void WrapperSpecs::initialize(EnergyPlusData &state,
    1527             :                               Real64 MyLoad, // Demand Load
    1528             :                               int LoopNum    // Loop Number Index
    1529             : )
    1530             : {
    1531             :     // SUBROUTINE INFORMATION:
    1532             :     //       AUTHOR         Daeho Kang, PNNL
    1533             :     //       DATE WRITTEN   Feb 2013
    1534             :     //       MODIFIED       na
    1535             :     //       RE-ENGINEERED  na
    1536             : 
    1537             :     // PURPOSE OF THIS SUBROUTINE:
    1538             :     //  This subroutine is for initializations of the CentralHeatPumpSystem variables
    1539             : 
    1540             :     // METHODOLOGY EMPLOYED:
    1541             :     //  Uses the status flags to trigger initializations.
    1542             : 
    1543             :     static constexpr std::string_view RoutineName("InitCGSHPHeatPump");
    1544             : 
    1545      170694 :     if (this->setupOutputVarsFlag) {
    1546           2 :         this->setupOutputVars(state);
    1547           2 :         this->setupOutputVarsFlag = false;
    1548             :     }
    1549             : 
    1550      170694 :     if (this->MyWrapperFlag) {
    1551             :         // Locate the chillers on the plant loops for later usage
    1552           2 :         bool errFlag = false;
    1553           2 :         PlantUtilities::ScanPlantLoopsForObject(state,
    1554             :                                                 this->Name,
    1555             :                                                 DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump,
    1556             :                                                 this->CWPlantLoc,
    1557             :                                                 errFlag,
    1558             :                                                 _,
    1559             :                                                 _,
    1560             :                                                 _,
    1561             :                                                 this->CHWInletNodeNum,
    1562             :                                                 _);
    1563             : 
    1564           2 :         PlantUtilities::ScanPlantLoopsForObject(state,
    1565             :                                                 this->Name,
    1566             :                                                 DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump,
    1567             :                                                 this->HWPlantLoc,
    1568             :                                                 errFlag,
    1569             :                                                 _,
    1570             :                                                 _,
    1571             :                                                 _,
    1572             :                                                 this->HWInletNodeNum,
    1573             :                                                 _);
    1574             : 
    1575           2 :         PlantUtilities::ScanPlantLoopsForObject(state,
    1576             :                                                 this->Name,
    1577             :                                                 DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump,
    1578             :                                                 this->GLHEPlantLoc,
    1579             :                                                 errFlag,
    1580             :                                                 _,
    1581             :                                                 _,
    1582             :                                                 _,
    1583             :                                                 this->GLHEInletNodeNum,
    1584             :                                                 _);
    1585             : 
    1586           2 :         PlantUtilities::InterConnectTwoPlantLoopSides(
    1587             :             state, this->CWPlantLoc, this->GLHEPlantLoc, DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump, true);
    1588             : 
    1589           2 :         PlantUtilities::InterConnectTwoPlantLoopSides(
    1590             :             state, this->HWPlantLoc, this->GLHEPlantLoc, DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump, true);
    1591             : 
    1592           2 :         PlantUtilities::InterConnectTwoPlantLoopSides(
    1593             :             state, this->CWPlantLoc, this->HWPlantLoc, DataPlant::PlantEquipmentType::CentralGroundSourceHeatPump, true);
    1594             : 
    1595           2 :         if (this->VariableFlowCH) {
    1596             :             // Reset flow priority
    1597           2 :             if (LoopNum == this->CWPlantLoc.loopNum) {
    1598           2 :                 DataPlant::CompData::getPlantComponent(state, this->CWPlantLoc).FlowPriority = DataPlant::LoopFlowStatus::NeedyIfLoopOn;
    1599           0 :             } else if (LoopNum == this->HWPlantLoc.loopNum) {
    1600           0 :                 DataPlant::CompData::getPlantComponent(state, this->HWPlantLoc).FlowPriority = DataPlant::LoopFlowStatus::NeedyIfLoopOn;
    1601             :             }
    1602             : 
    1603             :             // check if setpoint on outlet node - chilled water loop
    1604           2 :             if (state.dataLoopNodes->Node(this->CHWOutletNodeNum).TempSetPoint == DataLoopNode::SensedNodeFlagValue) {
    1605           2 :                 if (!state.dataGlobal->AnyEnergyManagementSystemInModel) {
    1606           2 :                     if (!this->CoolSetPointErrDone) {
    1607           2 :                         ShowWarningError(state, "Missing temperature setpoint on cooling side for CentralHeatPumpSystem named " + this->Name);
    1608           2 :                         ShowContinueError(state,
    1609             :                                           "  A temperature setpoint is needed at the outlet node of a CentralHeatPumpSystem, use a SetpointManager");
    1610           2 :                         ShowContinueError(state,
    1611             :                                           "  The overall loop setpoint will be assumed for CentralHeatPumpSystem. The simulation continues ... ");
    1612           2 :                         this->CoolSetPointErrDone = true;
    1613             :                     }
    1614             :                 } else {
    1615             :                     // need call to EMS to check node
    1616           0 :                     bool FatalError = false; // but not really fatal yet, but should be.
    1617           0 :                     EMSManager::CheckIfNodeSetPointManagedByEMS(
    1618             :                         state, this->CHWOutletNodeNum, EMSManager::SPControlType::TemperatureSetPoint, FatalError);
    1619           0 :                     state.dataLoopNodes->NodeSetpointCheck(this->CHWOutletNodeNum).needsSetpointChecking = false;
    1620           0 :                     if (FatalError) {
    1621           0 :                         if (!this->CoolSetPointErrDone) {
    1622           0 :                             ShowWarningError(state, "Missing temperature setpoint on cooling side for CentralHeatPumpSystem named " + this->Name);
    1623           0 :                             ShowContinueError(state, "A temperature setpoint is needed at the outlet node of a CentralHeatPumpSystem ");
    1624           0 :                             ShowContinueError(state, "use a Setpoint Manager to establish a setpoint at the chiller side outlet node ");
    1625           0 :                             ShowContinueError(state, "or use an EMS actuator to establish a setpoint at the outlet node ");
    1626           0 :                             ShowContinueError(state, "The overall loop setpoint will be assumed for chiller side. The simulation continues ... ");
    1627           0 :                             this->CoolSetPointErrDone = true;
    1628             :                         }
    1629             :                     }
    1630             :                 }
    1631           2 :                 this->CoolSetPointSetToLoop = true;
    1632           2 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).TempSetPoint =
    1633           2 :                     state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    1634             :             }
    1635             : 
    1636           2 :             if (state.dataLoopNodes->Node(this->HWOutletNodeNum).TempSetPoint == DataLoopNode::SensedNodeFlagValue) {
    1637           2 :                 if (!state.dataGlobal->AnyEnergyManagementSystemInModel) {
    1638           2 :                     if (!this->HeatSetPointErrDone) {
    1639           2 :                         ShowWarningError(state, "Missing temperature setpoint on heating side for CentralHeatPumpSystem named " + this->Name);
    1640           2 :                         ShowContinueError(state,
    1641             :                                           "  A temperature setpoint is needed at the outlet node of a CentralHeatPumpSystem, use a SetpointManager");
    1642           2 :                         ShowContinueError(state,
    1643             :                                           "  The overall loop setpoint will be assumed for CentralHeatPumpSystem. The simulation continues ... ");
    1644           2 :                         this->HeatSetPointErrDone = true;
    1645             :                     }
    1646             :                 } else {
    1647             :                     // need call to EMS to check node
    1648           0 :                     bool FatalError = false; // but not really fatal yet, but should be.
    1649           0 :                     EMSManager::CheckIfNodeSetPointManagedByEMS(
    1650             :                         state, this->HWOutletNodeNum, EMSManager::SPControlType::TemperatureSetPoint, FatalError);
    1651           0 :                     state.dataLoopNodes->NodeSetpointCheck(this->HWOutletNodeNum).needsSetpointChecking = false;
    1652           0 :                     if (FatalError) {
    1653           0 :                         if (!this->HeatSetPointErrDone) {
    1654           0 :                             ShowWarningError(state, "Missing temperature setpoint on heating side for CentralHeatPumpSystem named " + this->Name);
    1655           0 :                             ShowContinueError(state, "A temperature setpoint is needed at the outlet node of a CentralHeatPumpSystem ");
    1656           0 :                             ShowContinueError(state, "use a Setpoint Manager to establish a setpoint at the chiller side outlet node ");
    1657           0 :                             ShowContinueError(state, "or use an EMS actuator to establish a setpoint at the outlet node ");
    1658           0 :                             ShowContinueError(state, "The overall loop setpoint will be assumed for chiller side. The simulation continues ... ");
    1659           0 :                             this->HeatSetPointErrDone = true;
    1660             :                         }
    1661             :                     }
    1662             :                 }
    1663           2 :                 this->HeatSetPointSetToLoop = true;
    1664           2 :                 state.dataLoopNodes->Node(this->HWOutletNodeNum).TempSetPoint =
    1665           2 :                     state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    1666             :             }
    1667             :         }
    1668           2 :         this->MyWrapperFlag = false;
    1669             :     }
    1670             : 
    1671      170694 :     if (this->MyWrapperEnvrnFlag && state.dataGlobal->BeginEnvrnFlag && (state.dataPlnt->PlantFirstSizesOkayToFinalize)) {
    1672             : 
    1673          11 :         if (this->ControlMode == CondenserType::SmartMixing) {
    1674             : 
    1675          11 :             this->CHWVolFlowRate = 0.0;
    1676          11 :             this->HWVolFlowRate = 0.0;
    1677          11 :             this->GLHEVolFlowRate = 0.0;
    1678             : 
    1679          50 :             for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    1680          39 :                 this->CHWVolFlowRate += this->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate;
    1681          39 :                 this->HWVolFlowRate += this->ChillerHeater(ChillerHeaterNum).DesignHotWaterVolFlowRate;
    1682          39 :                 this->GLHEVolFlowRate += this->ChillerHeater(ChillerHeaterNum).CondVolFlowRate;
    1683             :             }
    1684             : 
    1685          22 :             Real64 rho = FluidProperties::GetDensityGlycol(state,
    1686          11 :                                                            state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    1687             :                                                            DataGlobalConstants::CWInitConvTemp,
    1688          11 :                                                            state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    1689          11 :                                                            RoutineName);
    1690             : 
    1691          11 :             this->CHWMassFlowRateMax = this->CHWVolFlowRate * rho;
    1692          11 :             this->HWMassFlowRateMax = this->HWVolFlowRate * rho;
    1693          11 :             this->GLHEMassFlowRateMax = this->GLHEVolFlowRate * rho;
    1694             : 
    1695          11 :             PlantUtilities::InitComponentNodes(state, 0.0, this->CHWMassFlowRateMax, this->CHWInletNodeNum, this->CHWOutletNodeNum);
    1696          11 :             PlantUtilities::InitComponentNodes(state, 0.0, this->HWMassFlowRateMax, this->HWInletNodeNum, this->HWOutletNodeNum);
    1697          11 :             PlantUtilities::InitComponentNodes(state, 0.0, this->GLHEMassFlowRateMax, this->GLHEInletNodeNum, this->GLHEOutletNodeNum);
    1698             : 
    1699             :             // Initialize nodes for individual chiller heaters
    1700          50 :             for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    1701          39 :                 this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMin = 0.0;
    1702          39 :                 this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMinAvail = 0.0;
    1703          39 :                 this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMax = rho * this->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate;
    1704          39 :                 this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMaxAvail =
    1705          39 :                     rho * this->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate;
    1706          39 :                 this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRate = 0.0;
    1707          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMin = 0.0;
    1708          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMinAvail = 0.0;
    1709          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMax = rho * this->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate;
    1710          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMaxAvail =
    1711          39 :                     rho * this->ChillerHeater(ChillerHeaterNum).EvapVolFlowRate;
    1712          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRate = 0.0;
    1713          39 :                 this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateRequest = 0.0;
    1714             :             }
    1715             :         }
    1716          11 :         this->MyWrapperEnvrnFlag = false;
    1717             :     }
    1718             : 
    1719      170694 :     if (!state.dataGlobal->BeginEnvrnFlag) {
    1720      170272 :         this->MyWrapperEnvrnFlag = true;
    1721             :     }
    1722             : 
    1723      170694 :     if (this->CoolSetPointSetToLoop) {
    1724             :         // IF (CurCoolingLoad > 0.0d0) THEN
    1725      170694 :         state.dataLoopNodes->Node(this->CHWOutletNodeNum).TempSetPoint =
    1726      170694 :             state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    1727             :     }
    1728             :     // IF (CurHeatingLoad > 0.0d0) THEN
    1729      170694 :     if (this->HeatSetPointSetToLoop) {
    1730      170694 :         state.dataLoopNodes->Node(this->HWOutletNodeNum).TempSetPoint =
    1731      170694 :             state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    1732             :         // ENDIF
    1733             :     }
    1734             : 
    1735             :     Real64 mdotCHW;  // Chilled water mass flow rate
    1736             :     Real64 mdotHW;   // Hot water mass flow rate
    1737             :     Real64 mdotGLHE; // Condenser water mass flow rate
    1738             : 
    1739             :     // Switch over the mass flow rate to the condenser loop, i.e., ground heat exchanger
    1740      170694 :     if (LoopNum == this->CWPlantLoc.loopNum) { // called for on cooling loop
    1741       85342 :         if (MyLoad < -1.0) {                   // calling for cooling
    1742       19840 :             mdotCHW = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRateMax;
    1743             :         } else {
    1744       65502 :             mdotCHW = 0.0;
    1745             :         }
    1746       85342 :         if (this->WrapperHeatingLoad > 1.0) {
    1747       31548 :             mdotHW = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRateMax;
    1748             :         } else {
    1749       53794 :             mdotHW = 0.0;
    1750             :         }
    1751       85342 :         if ((MyLoad < -1.0) || (this->WrapperHeatingLoad > 1.0)) {
    1752       36824 :             mdotGLHE = state.dataLoopNodes->Node(this->GLHEInletNodeNum).MassFlowRateMax;
    1753             :         } else {
    1754       48518 :             mdotGLHE = 0.0;
    1755             :         }
    1756             : 
    1757       85352 :     } else if (LoopNum == this->HWPlantLoc.loopNum) {
    1758       85342 :         if (MyLoad > 1.0) {
    1759       31548 :             mdotHW = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRateMax;
    1760             :         } else {
    1761       53794 :             mdotHW = 0.0;
    1762             :         }
    1763       85342 :         if (this->WrapperCoolingLoad > 1.0) {
    1764       19840 :             mdotCHW = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRateMax;
    1765             :         } else {
    1766       65502 :             mdotCHW = 0.0;
    1767             :         }
    1768       85342 :         if ((MyLoad > 1.0) || (this->WrapperCoolingLoad > 1.0)) {
    1769       36780 :             mdotGLHE = state.dataLoopNodes->Node(this->GLHEInletNodeNum).MassFlowRateMax;
    1770             :         } else {
    1771       48562 :             mdotGLHE = 0.0;
    1772             :         }
    1773             : 
    1774          10 :     } else if (LoopNum == this->GLHEPlantLoc.loopNum) {
    1775          10 :         if (this->WrapperCoolingLoad > 1.0) {
    1776           0 :             mdotCHW = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRateMax;
    1777             :         } else {
    1778          10 :             mdotCHW = 0.0;
    1779             :         }
    1780          10 :         if (this->WrapperHeatingLoad > 1.0) {
    1781           0 :             mdotHW = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRateMax;
    1782             :         } else {
    1783          10 :             mdotHW = 0.0;
    1784             :         }
    1785          10 :         if ((this->WrapperHeatingLoad > 1.0) || (this->WrapperCoolingLoad > 1.0)) {
    1786           0 :             mdotGLHE = state.dataLoopNodes->Node(this->GLHEInletNodeNum).MassFlowRateMax;
    1787             :         } else {
    1788          10 :             mdotGLHE = 0.0;
    1789             :         }
    1790             :     }
    1791             : 
    1792      170694 :     PlantUtilities::SetComponentFlowRate(state, mdotCHW, this->CHWInletNodeNum, this->CHWOutletNodeNum, this->CWPlantLoc);
    1793             : 
    1794      170694 :     PlantUtilities::SetComponentFlowRate(state, mdotHW, this->HWInletNodeNum, this->HWOutletNodeNum, this->HWPlantLoc);
    1795             : 
    1796      170694 :     PlantUtilities::SetComponentFlowRate(state, mdotGLHE, this->GLHEInletNodeNum, this->GLHEOutletNodeNum, this->GLHEPlantLoc);
    1797      170694 : }
    1798             : 
    1799       19840 : void WrapperSpecs::CalcChillerModel(EnergyPlusData &state)
    1800             : {
    1801             :     // SUBROUTINE INFORMATION:
    1802             :     //       AUTHOR         Daeho Kang, PNNL
    1803             :     //       DATE WRITTEN   Feb 2013
    1804             :     //       MODIFIED       na
    1805             :     //       RE-ENGINEERED  na
    1806             : 
    1807             :     // PURPOSE OF THIS SUBROUTINE:
    1808             :     //  Simulate a ChillerHeaterPerformance:Electric:EIR using curve fit
    1809             : 
    1810             :     // METHODOLOGY EMPLOYED:
    1811             :     //  Use empirical curve fits to model performance at off-reference conditions
    1812             : 
    1813             :     // REFERENCES:
    1814             :     // 1. DOE-2 Engineers Manual, Version 2.1A, November 1982, LBL-11353
    1815             : 
    1816             :     static constexpr std::string_view RoutineName("CalcChillerHeaterModel");
    1817             :     static constexpr std::string_view RoutineNameElecEIRChiller("CalcElectricEIRChillerModel");
    1818             : 
    1819       19840 :     bool IsLoadCoolRemaining(true);
    1820       19840 :     bool NextCompIndicator(false);       // Component indicator when identical chiller heaters exist
    1821       19840 :     int CompNum = 0;                     // Component number in the loop  REAL(r64) :: FRAC
    1822       19840 :     int IdenticalUnitCounter = 0;        // Pointer to count number of identical unit passed
    1823       19840 :     Real64 CurAvailCHWMassFlowRate(0.0); // Maximum available mass flow rate for current chiller heater
    1824             : 
    1825             :     // Cooling load evaporator should meet
    1826       19840 :     Real64 EvaporatorLoad = this->WrapperCoolingLoad;
    1827             : 
    1828             :     // Chilled water inlet mass flow rate
    1829       19840 :     Real64 CHWInletMassFlowRate = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRate;
    1830             : 
    1831       84416 :     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    1832             : 
    1833             :         // Initialize local variables for each chiller heater
    1834       64576 :         int CurrentMode = 0;
    1835       64576 :         state.dataPlantCentralGSHP->ChillerCapFT = 0.0;
    1836       64576 :         state.dataPlantCentralGSHP->ChillerEIRFT = 0.0;
    1837       64576 :         state.dataPlantCentralGSHP->ChillerEIRFPLR = 0.0;
    1838       64576 :         state.dataPlantCentralGSHP->ChillerPartLoadRatio = 0.0;
    1839       64576 :         state.dataPlantCentralGSHP->ChillerCyclingRatio = 0.0;
    1840       64576 :         state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    1841             : 
    1842       64576 :         Real64 CHPower = 0.0;
    1843       64576 :         Real64 QCondenser = 0.0;
    1844       64576 :         Real64 QEvaporator = 0.0;
    1845       64576 :         Real64 FRAC = 1.0;
    1846       64576 :         Real64 ActualCOP = 0.0;
    1847       64576 :         Real64 EvapInletTemp = state.dataLoopNodes->Node(this->CHWInletNodeNum).Temp;
    1848       64576 :         Real64 CondInletTemp = state.dataLoopNodes->Node(this->GLHEInletNodeNum).Temp;
    1849       64576 :         Real64 EvapOutletTemp = EvapInletTemp;
    1850       64576 :         Real64 CondOutletTemp = CondInletTemp;
    1851       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = 0;
    1852             : 
    1853             :         // Find proper schedule values
    1854       64576 :         if (this->NumOfComp != this->ChillerHeaterNums) { // Identical units exist
    1855       64576 :             if (ChillerHeaterNum == 1) {
    1856       19840 :                 IdenticalUnitCounter = 0;
    1857       19840 :                 NextCompIndicator = false;
    1858       19840 :                 CompNum = ChillerHeaterNum;
    1859             :             }
    1860       64576 :             if (NextCompIndicator) {
    1861        5056 :                 ++CompNum;
    1862             :             }
    1863       64576 :             if (CompNum == 1) {
    1864       54464 :                 if (ChillerHeaterNum != this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    1865       34624 :                     NextCompIndicator = false;
    1866       19840 :                 } else if (ChillerHeaterNum == this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    1867       19840 :                     NextCompIndicator = true;
    1868             :                 }
    1869       10112 :             } else if (CompNum > 1) {
    1870       10112 :                 if ((ChillerHeaterNum - ((ChillerHeaterNum - 1) - IdenticalUnitCounter)) != this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    1871        5056 :                     NextCompIndicator = false;
    1872       10112 :                 } else if ((ChillerHeaterNum - ((ChillerHeaterNum - 1) - IdenticalUnitCounter)) ==
    1873        5056 :                            this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    1874        5056 :                     NextCompIndicator = true;
    1875             :                 }
    1876             :             }
    1877       64576 :             ++IdenticalUnitCounter;
    1878       64576 :             int IdenticalUnitRemaining = this->WrapperComp(CompNum).WrapperIdenticalObjectNum - IdenticalUnitCounter;
    1879       64576 :             if (IdenticalUnitRemaining == 0) IdenticalUnitCounter = 0;
    1880           0 :         } else if (this->NumOfComp == this->ChillerHeaterNums) {
    1881           0 :             ++CompNum;
    1882             :         }
    1883             : 
    1884       64576 :         if (CompNum > this->NumOfComp) {
    1885           0 :             ShowSevereError(state, "CalcChillerModel: ChillerHeater=\"" + this->Name + "\", calculated component number too big.");
    1886           0 :             ShowContinueError(state, format("Max number of components=[{}], indicated component number=[{}].", this->NumOfComp, CompNum));
    1887           0 :             ShowFatalError(state, "Program terminates due to preceding condition.");
    1888             :         }
    1889             : 
    1890             :         Real64 EvapMassFlowRate; // Actual evaporator mass flow rate
    1891             :         Real64 CondMassFlowRate; // Condenser mass flow rate
    1892             : 
    1893             :         // Check whether this chiller heater needs to run
    1894       64576 :         if (EvaporatorLoad > 0.0 && (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0.0)) {
    1895       48712 :             IsLoadCoolRemaining = true;
    1896             : 
    1897             :             // Calculate density ratios to adjust mass flow rates from initialized ones
    1898             :             // Hot water temperature is known, but evaporator mass flow rates will be adjusted in the following "Do" loop
    1899       97424 :             Real64 InitDensity = FluidProperties::GetDensityGlycol(state,
    1900       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    1901             :                                                                    DataGlobalConstants::CWInitConvTemp,
    1902       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    1903       48712 :                                                                    RoutineName);
    1904       97424 :             Real64 EvapDensity = FluidProperties::GetDensityGlycol(state,
    1905       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    1906             :                                                                    EvapInletTemp,
    1907       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    1908       48712 :                                                                    RoutineName);
    1909       97424 :             Real64 CondDensity = FluidProperties::GetDensityGlycol(state,
    1910       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    1911             :                                                                    CondInletTemp,
    1912       48712 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    1913       48712 :                                                                    RoutineName);
    1914             : 
    1915             :             // Calculate density ratios to adjust mass flow rates from initialized ones
    1916             : 
    1917             :             // Fraction between standardized density and local density in the chilled water side
    1918       48712 :             Real64 CHWDensityRatio = EvapDensity / InitDensity;
    1919             : 
    1920             :             // Fraction between standardized density and local density in the condenser side
    1921       48712 :             Real64 GLHEDensityRatio = CondDensity / InitDensity;
    1922       48712 :             CondMassFlowRate = this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMaxAvail;
    1923       48712 :             EvapMassFlowRate = this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMaxAvail;
    1924       48712 :             EvapMassFlowRate *= CHWDensityRatio;
    1925       48712 :             CondMassFlowRate *= GLHEDensityRatio;
    1926             : 
    1927             :             // Check available flows from plant and then adjust as necessary
    1928       48712 :             if (CurAvailCHWMassFlowRate == 0) { // The very first chiller heater to operate
    1929       19995 :                 CurAvailCHWMassFlowRate = CHWInletMassFlowRate;
    1930       28717 :             } else if (ChillerHeaterNum > 1) {
    1931       28717 :                 CurAvailCHWMassFlowRate -= this->ChillerHeater(ChillerHeaterNum - 1).EvapOutletNode.MassFlowRate;
    1932             :             }
    1933       48712 :             EvapMassFlowRate = min(CurAvailCHWMassFlowRate, EvapMassFlowRate);
    1934             :         } else {
    1935       15864 :             IsLoadCoolRemaining = false;
    1936       15864 :             EvapMassFlowRate = 0.0;
    1937       15864 :             CondMassFlowRate = 0.0;
    1938       15864 :             CurrentMode = 0;
    1939             :         }
    1940             : 
    1941             :         // Chiller heater is on when cooling load for this chiller heater remains and chilled water available
    1942      111145 :         if (IsLoadCoolRemaining && (EvapMassFlowRate > 0) &&
    1943       46569 :             (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) {
    1944             :             // Indicate current mode is cooling-only mode. Simultaneous clg/htg mode will be set later
    1945       46569 :             CurrentMode = 1;
    1946             : 
    1947             :             // Assign proper performance curve information depending on the control mode
    1948             :             // Cooling curve is used only for cooling-only mode, and the others (Simultaneous and heating) read the heating curve
    1949       46569 :             if (this->SimulClgDominant || this->SimulHtgDominant) {
    1950       31888 :                 this->ChillerHeater(ChillerHeaterNum).RefCap = this->ChillerHeater(ChillerHeaterNum).RefCapClgHtg;
    1951       31888 :                 this->ChillerHeater(ChillerHeaterNum).RefCOP = this->ChillerHeater(ChillerHeaterNum).RefCOPClgHtg;
    1952       31888 :                 this->ChillerHeater(ChillerHeaterNum).TempRefEvapOut = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg;
    1953       31888 :                 this->ChillerHeater(ChillerHeaterNum).TempRefCondIn = this->ChillerHeater(ChillerHeaterNum).TempRefCondInClgHtg;
    1954       31888 :                 this->ChillerHeater(ChillerHeaterNum).TempRefCondOut = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutClgHtg;
    1955       31888 :                 this->ChillerHeater(ChillerHeaterNum).OptPartLoadRat = this->ChillerHeater(ChillerHeaterNum).OptPartLoadRatClgHtg;
    1956       31888 :                 this->ChillerHeater(ChillerHeaterNum).CondMode = this->ChillerHeater(ChillerHeaterNum).CondModeHeating;
    1957       31888 :                 this->ChillerHeater(ChillerHeaterNum).ChillerCapFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX;
    1958       31888 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX;
    1959       31888 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX;
    1960             :             } else {
    1961       14681 :                 this->ChillerHeater(ChillerHeaterNum).RefCap = this->ChillerHeater(ChillerHeaterNum).RefCapCooling;
    1962       14681 :                 this->ChillerHeater(ChillerHeaterNum).RefCOP = this->ChillerHeater(ChillerHeaterNum).RefCOPCooling;
    1963       14681 :                 this->ChillerHeater(ChillerHeaterNum).TempRefEvapOut = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutCooling;
    1964       14681 :                 this->ChillerHeater(ChillerHeaterNum).TempRefCondIn = this->ChillerHeater(ChillerHeaterNum).TempRefCondInCooling;
    1965       14681 :                 this->ChillerHeater(ChillerHeaterNum).TempRefCondOut = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutCooling;
    1966       14681 :                 this->ChillerHeater(ChillerHeaterNum).OptPartLoadRat = this->ChillerHeater(ChillerHeaterNum).OptPartLoadRatCooling;
    1967       14681 :                 this->ChillerHeater(ChillerHeaterNum).CondMode = this->ChillerHeater(ChillerHeaterNum).CondModeCooling;
    1968       14681 :                 this->ChillerHeater(ChillerHeaterNum).ChillerCapFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerCapFTCoolingIDX;
    1969       14681 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTCoolingIDX;
    1970       14681 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRCoolingIDX;
    1971             :             }
    1972             : 
    1973             :             // Only used to read curve values
    1974       46569 :             CondOutletTemp = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutCooling;
    1975             :             Real64 CondTempforCurve;
    1976       46569 :             if (this->ChillerHeater(ChillerHeaterNum).CondMode == "ENTERINGCONDENSER") {
    1977       14681 :                 CondTempforCurve = CondInletTemp;
    1978       31888 :             } else if (this->ChillerHeater(ChillerHeaterNum).CondMode == "LEAVINGCONDENSER") {
    1979       31888 :                 CondTempforCurve = CondOutletTemp;
    1980             :             } else {
    1981           0 :                 ShowWarningError(state, "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name + "\":");
    1982           0 :                 ShowContinueError(state,
    1983           0 :                                   format("Chiller condenser temperature for curve fit are not decided, defalt value= cond_leaving ({:.3R}).",
    1984           0 :                                          state.dataPlantCentralGSHP->ChillerCapFT));
    1985           0 :                 CondTempforCurve = CondOutletTemp;
    1986             :             }
    1987             : 
    1988             :             // Bind local variables from the curve
    1989             :             Real64 MinPartLoadRat; // Min allowed operating fraction of full load
    1990             :             Real64 MaxPartLoadRat; // Max allowed operating fraction of full load
    1991             : 
    1992       46569 :             Curve::GetCurveMinMaxValues(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX, MinPartLoadRat, MaxPartLoadRat);
    1993             : 
    1994             :             // Chiller reference capacity
    1995       46569 :             Real64 ChillerRefCap = this->ChillerHeater(ChillerHeaterNum).RefCap;
    1996       46569 :             Real64 ReferenceCOP = this->ChillerHeater(ChillerHeaterNum).RefCOP;
    1997       46569 :             Real64 TempLowLimitEout = this->ChillerHeater(ChillerHeaterNum).TempLowLimitEvapOut;
    1998       46569 :             Real64 EvapOutletTempSetPoint = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutCooling;
    1999       46569 :             state.dataPlantCentralGSHP->ChillerCapFT =
    2000       93138 :                 Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerCapFTIDX, EvapOutletTempSetPoint, CondTempforCurve);
    2001             : 
    2002       46569 :             if (state.dataPlantCentralGSHP->ChillerCapFT < 0) {
    2003           0 :                 if (this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError < 1 && !state.dataGlobal->WarmupFlag) {
    2004           0 :                     ++this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError;
    2005           0 :                     ShowWarningError(state, "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name + "\":");
    2006           0 :                     ShowContinueError(state,
    2007           0 :                                       format(" ChillerHeater Capacity as a Function of Temperature curve output is negative ({:.3R}).",
    2008           0 :                                              state.dataPlantCentralGSHP->ChillerCapFT));
    2009           0 :                     ShowContinueError(state,
    2010           0 :                                       format(" Negative value occurs using an Evaporator Outlet Temp of {:.1R} and a Condenser Inlet Temp of {:.1R}.",
    2011             :                                              EvapOutletTempSetPoint,
    2012           0 :                                              CondInletTemp));
    2013           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    2014           0 :                 } else if (!state.dataGlobal->WarmupFlag) {
    2015           0 :                     ++this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError;
    2016           0 :                     ShowRecurringWarningErrorAtEnd(
    2017             :                         state,
    2018           0 :                         "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name +
    2019             :                             "\": ChillerHeater Capacity as a Function of Temperature curve output is negative warning continues...",
    2020           0 :                         this->ChillerHeater(ChillerHeaterNum).ChillerCapFTErrorIndex,
    2021           0 :                         state.dataPlantCentralGSHP->ChillerCapFT,
    2022           0 :                         state.dataPlantCentralGSHP->ChillerCapFT);
    2023             :                 }
    2024           0 :                 state.dataPlantCentralGSHP->ChillerCapFT = 0.0;
    2025             :             }
    2026             : 
    2027             :             // Calculate the specific heat of chilled water
    2028       93138 :             Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2029       46569 :                                                                state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    2030             :                                                                EvapInletTemp,
    2031       46569 :                                                                state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    2032       46569 :                                                                RoutineName);
    2033             : 
    2034             :             // Calculate cooling load this chiller should meet and the other chillers are demanded
    2035       46569 :             EvapOutletTempSetPoint = state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    2036             : 
    2037             :             // Minimum capacity of the evaporator
    2038             :             Real64 EvaporatorCapMin =
    2039       46569 :                 this->ChillerHeater(ChillerHeaterNum).MinPartLoadRatCooling * this->ChillerHeater(ChillerHeaterNum).RefCapCooling;
    2040             : 
    2041             :             // Remaining cooling load the other chiller heaters should meet
    2042       46569 :             Real64 CoolingLoadToMeet = min(this->ChillerHeater(ChillerHeaterNum).RefCapCooling, max(std::abs(EvaporatorLoad), EvaporatorCapMin));
    2043             : 
    2044             :             // Available chiller capacity as a function of temperature
    2045             :             // Chiller available capacity at current operating conditions [W]
    2046       46569 :             Real64 AvailChillerCap = ChillerRefCap * state.dataPlantCentralGSHP->ChillerCapFT;
    2047             : 
    2048             :             // Set load this chiller heater should meet
    2049       46569 :             QEvaporator = min(CoolingLoadToMeet, (AvailChillerCap * MaxPartLoadRat));
    2050       46569 :             EvapOutletTemp = EvapOutletTempSetPoint;
    2051       46569 :             Real64 EvapDeltaTemp = EvapInletTemp - EvapOutletTemp;
    2052             : 
    2053             :             Real64 PartLoadRat; // Operating part load ratio
    2054             : 
    2055             :             // Calculate temperatures for constant flow and mass flow rates for variable flow
    2056       46569 :             if (EvapMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2057       46569 :                 if (this->SimulHtgDominant) { // Evaporator operates at full capacity for heating
    2058           0 :                     PartLoadRat = max(0.0, min((ChillerRefCap / AvailChillerCap), MaxPartLoadRat));
    2059           0 :                     QEvaporator = AvailChillerCap * PartLoadRat;
    2060           0 :                     EvapDeltaTemp = QEvaporator / EvapMassFlowRate / Cp;
    2061           0 :                     EvapOutletTemp = EvapInletTemp - EvapDeltaTemp;
    2062             :                 } else {                        // Cooling only mode or cooling dominant simultaneous htg/clg mode
    2063       46569 :                     if (this->VariableFlowCH) { // Variable flow
    2064       46569 :                         Real64 EvapMassFlowRateCalc = QEvaporator / EvapDeltaTemp / Cp;
    2065       46569 :                         if (EvapMassFlowRateCalc > EvapMassFlowRate) {
    2066       12976 :                             EvapMassFlowRateCalc = EvapMassFlowRate;
    2067       12976 :                             Real64 EvapDeltaTempCalc = QEvaporator / EvapMassFlowRate / Cp;
    2068       12976 :                             EvapOutletTemp = EvapInletTemp - EvapDeltaTempCalc;
    2069       12976 :                             if (EvapDeltaTempCalc > EvapDeltaTemp) {
    2070       12603 :                                 QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2071             :                             }
    2072             :                         }
    2073       46569 :                         EvapMassFlowRate = EvapMassFlowRateCalc;
    2074             :                     } else { // Constant Flow
    2075           0 :                         Real64 EvapOutletTempCalc = EvapInletTemp - EvapDeltaTemp;
    2076           0 :                         if (EvapOutletTempCalc > EvapOutletTemp) { // Load to meet should be adjusted
    2077           0 :                             EvapOutletTempCalc = EvapOutletTemp;
    2078           0 :                             QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2079             :                         }
    2080           0 :                         EvapOutletTemp = EvapOutletTempCalc;
    2081             :                     } // End of flow control decision
    2082             :                 }     // End of operation mode
    2083             :             } else {
    2084           0 :                 QEvaporator = 0.0;
    2085           0 :                 EvapOutletTemp = EvapInletTemp;
    2086             :             }
    2087             : 
    2088             :             // Check evaporator temperature low limit and adjust capacity if needed
    2089       46569 :             if (EvapOutletTemp < TempLowLimitEout) {
    2090        8453 :                 if ((EvapInletTemp - TempLowLimitEout) > DataPlant::DeltaTempTol) {
    2091        8453 :                     EvapOutletTemp = TempLowLimitEout;
    2092        8453 :                     EvapDeltaTemp = EvapInletTemp - EvapOutletTemp;
    2093        8453 :                     QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2094             :                 } else {
    2095           0 :                     QEvaporator = 0.0;
    2096           0 :                     EvapOutletTemp = EvapInletTemp;
    2097             :                 }
    2098             :             }
    2099             : 
    2100             :             // Check if the outlet temperature exceeds the node minimum temperature and adjust capacity if needed
    2101       46569 :             if (EvapOutletTemp < this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin) {
    2102           0 :                 if ((this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp - this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin) >
    2103             :                     DataPlant::DeltaTempTol) {
    2104           0 :                     EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin;
    2105           0 :                     EvapDeltaTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin - EvapOutletTemp;
    2106           0 :                     QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2107             :                 } else {
    2108           0 :                     QEvaporator = 0.0;
    2109           0 :                     EvapOutletTemp = EvapInletTemp;
    2110             :                 }
    2111             :             }
    2112             : 
    2113             :             // Calculate part load once more since evaporator capacity might be modified
    2114       46569 :             if (AvailChillerCap > 0.0) {
    2115       46569 :                 PartLoadRat = max(0.0, min((QEvaporator / AvailChillerCap), MaxPartLoadRat));
    2116             :             } else {
    2117           0 :                 PartLoadRat = 0.0;
    2118             :             }
    2119             : 
    2120             :             // Chiller cycles below minimum part load ratio, FRAC = amount of time chiller is ON during this time step
    2121       46569 :             if (PartLoadRat < MinPartLoadRat) FRAC = min(1.0, (PartLoadRat / MinPartLoadRat));
    2122             : 
    2123             :             // set the module level variable used for reporting FRAC
    2124       46569 :             state.dataPlantCentralGSHP->ChillerCyclingRatio = FRAC;
    2125             : 
    2126             :             // Chiller is false loading below PLR = minimum unloading ratio, find PLR used for energy calculation
    2127       46569 :             if (AvailChillerCap > 0.0) {
    2128       46569 :                 PartLoadRat = max(PartLoadRat, MinPartLoadRat);
    2129             :             } else {
    2130           0 :                 PartLoadRat = 0.0;
    2131             :             }
    2132             : 
    2133             :             // set the module level variable used for reporting PLR
    2134       46569 :             state.dataPlantCentralGSHP->ChillerPartLoadRatio = PartLoadRat;
    2135             : 
    2136             :             // calculate the load due to false loading on chiller over and above water side load
    2137       46569 :             state.dataPlantCentralGSHP->ChillerFalseLoadRate = (AvailChillerCap * PartLoadRat * FRAC) - QEvaporator;
    2138       46569 :             if (state.dataPlantCentralGSHP->ChillerFalseLoadRate < DataHVACGlobals::SmallLoad) {
    2139       46569 :                 state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    2140             :             }
    2141             : 
    2142             :             // Determine chiller compressor power and transfer heat calculation
    2143       46569 :             state.dataPlantCentralGSHP->ChillerEIRFT =
    2144       93138 :                 max(0.0, Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTIDX, EvapOutletTemp, CondTempforCurve));
    2145       46569 :             state.dataPlantCentralGSHP->ChillerEIRFPLR =
    2146       93138 :                 max(0.0, Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX, PartLoadRat));
    2147             : 
    2148       46569 :             if (ReferenceCOP <= 0.0) {
    2149           0 :                 CHPower = 0.0;
    2150             :             } else {
    2151       46569 :                 CHPower =
    2152       46569 :                     (AvailChillerCap / ReferenceCOP) * state.dataPlantCentralGSHP->ChillerEIRFPLR * state.dataPlantCentralGSHP->ChillerEIRFT * FRAC;
    2153             :             }
    2154             : 
    2155       46569 :             QCondenser =
    2156       46569 :                 CHPower * this->ChillerHeater(ChillerHeaterNum).OpenMotorEff + QEvaporator + state.dataPlantCentralGSHP->ChillerFalseLoadRate;
    2157             : 
    2158       46569 :             if (CHPower == 0.0) {
    2159           0 :                 ActualCOP = 0.0;
    2160             :             } else {
    2161       46569 :                 ActualCOP = (QEvaporator + state.dataPlantCentralGSHP->ChillerFalseLoadRate) / CHPower;
    2162             :             }
    2163             : 
    2164       46569 :             if (CondMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2165       93138 :                 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2166       46569 :                                                             state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidName,
    2167             :                                                             CondInletTemp,
    2168       46569 :                                                             state.dataPlnt->PlantLoop(this->GLHEPlantLoc.loopNum).FluidIndex,
    2169             :                                                             RoutineNameElecEIRChiller);
    2170       46569 :                 CondOutletTemp = QCondenser / CondMassFlowRate / Cp + CondInletTemp;
    2171             :             } else {
    2172           0 :                 ShowSevereError(state, "CalcChillerheaterModel: Condenser flow = 0, for Chillerheater=" + this->ChillerHeater(ChillerHeaterNum).Name);
    2173           0 :                 ShowContinueErrorTimeStamp(state, "");
    2174             :             }
    2175             : 
    2176             :             // Determine load next chillers should meet
    2177       46569 :             if (EvaporatorLoad < QEvaporator) {
    2178        5091 :                 EvaporatorLoad = 0.0; // No remaining load so the rest will be off
    2179             :             } else {
    2180       41478 :                 EvaporatorLoad -= QEvaporator;
    2181             :             }
    2182             : 
    2183             :             // Initialize reporting variable when this chiller doesn't need to operate
    2184       46569 :             if (QEvaporator == 0.0) {
    2185           0 :                 CurrentMode = 0;
    2186           0 :                 state.dataPlantCentralGSHP->ChillerPartLoadRatio = 0.0;
    2187           0 :                 state.dataPlantCentralGSHP->ChillerCyclingRatio = 0.0;
    2188           0 :                 state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    2189           0 :                 EvapMassFlowRate = 0.0;
    2190           0 :                 CondMassFlowRate = 0.0;
    2191           0 :                 CHPower = 0.0;
    2192           0 :                 QCondenser = 0.0;
    2193           0 :                 EvapOutletTemp = EvapInletTemp;
    2194           0 :                 CondOutletTemp = CondInletTemp;
    2195           0 :                 EvaporatorLoad = 0.0;
    2196             :             }
    2197             : 
    2198             :         } // End of calculation for cooling
    2199             : 
    2200             :         // Set variables to the arrays
    2201       64576 :         this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.MassFlowRate = EvapMassFlowRate;
    2202       64576 :         this->ChillerHeater(ChillerHeaterNum).CondOutletNode.MassFlowRate = CondMassFlowRate;
    2203       64576 :         this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.Temp = EvapOutletTemp;
    2204       64576 :         this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp = EvapInletTemp;
    2205       64576 :         this->ChillerHeater(ChillerHeaterNum).CondOutletNode.Temp = CondOutletTemp;
    2206       64576 :         this->ChillerHeater(ChillerHeaterNum).CondInletNode.Temp = CondInletTemp;
    2207       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = CurrentMode;
    2208       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatio = state.dataPlantCentralGSHP->ChillerPartLoadRatio;
    2209       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatio = state.dataPlantCentralGSHP->ChillerCyclingRatio;
    2210       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate = state.dataPlantCentralGSHP->ChillerFalseLoadRate;
    2211       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFT = state.dataPlantCentralGSHP->ChillerCapFT;
    2212       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFT = state.dataPlantCentralGSHP->ChillerEIRFT;
    2213       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLR = state.dataPlantCentralGSHP->ChillerEIRFPLR;
    2214       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower = CHPower;
    2215       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower = 0.0;
    2216       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.QEvap = QEvaporator;
    2217       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.QCond = QCondenser;
    2218       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp = EvapOutletTemp;
    2219       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTemp = EvapInletTemp;
    2220       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp = CondOutletTemp;
    2221       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CondInletTemp = CondInletTemp;
    2222       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot = EvapMassFlowRate;
    2223       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot = CondMassFlowRate;
    2224       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ActualCOP = ActualCOP;
    2225             : 
    2226       64576 :         if (this->SimulClgDominant || this->SimulHtgDominant) { // Store for using these cooling side data in the hot water loop
    2227       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = CurrentMode;
    2228       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatioSimul = state.dataPlantCentralGSHP->ChillerPartLoadRatio;
    2229       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatioSimul = state.dataPlantCentralGSHP->ChillerCyclingRatio;
    2230       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRateSimul = state.dataPlantCentralGSHP->ChillerFalseLoadRate;
    2231       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFTSimul = state.dataPlantCentralGSHP->ChillerCapFT;
    2232       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFTSimul = state.dataPlantCentralGSHP->ChillerEIRFT;
    2233       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLRSimul = state.dataPlantCentralGSHP->ChillerEIRFPLR;
    2234       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.CoolingPowerSimul = CHPower;
    2235       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul = QEvaporator;
    2236       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTempSimul = EvapOutletTemp;
    2237       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTempSimul = EvapInletTemp;
    2238       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapmdotSimul = EvapMassFlowRate;
    2239       43692 :             if (this->SimulClgDominant) {
    2240       43692 :                 this->ChillerHeater(ChillerHeaterNum).Report.QCondSimul = QCondenser;
    2241       43692 :                 this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTempSimul = CondOutletTemp;
    2242       43692 :                 this->ChillerHeater(ChillerHeaterNum).Report.CondInletTempSimul = CondInletTemp;
    2243       43692 :                 this->ChillerHeater(ChillerHeaterNum).Report.CondmdotSimul = CondMassFlowRate;
    2244             :             }
    2245             :         }
    2246             :     }
    2247       19840 : }
    2248             : 
    2249       31548 : void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state)
    2250             : {
    2251             :     // SUBROUTINE INFORMATION:
    2252             :     //       AUTHOR         Daeho Kang, PNNL
    2253             :     //       DATE WRITTEN   Feb 2013
    2254             :     //       MODIFIED       na
    2255             :     //       RE-ENGINEERED  na
    2256             : 
    2257             :     // PURPOSE OF THIS SUBROUTINE:
    2258             :     //  Simulate a ChillerHeaterPerformance:Electric:EIR using curve fit
    2259             : 
    2260             :     // METHODOLOGY EMPLOYED:
    2261             :     //  Use empirical curve fits to model performance at off-reference conditions
    2262             : 
    2263             :     // REFERENCES:
    2264             :     // 1. DOE-2 Engineers Manual, Version 2.1A, November 1982, LBL-11353
    2265             : 
    2266             :     static constexpr std::string_view RoutineName("CalcChillerHeaterModel");
    2267             :     static constexpr std::string_view RoutineNameElecEIRChiller("CalcElectricEIRChillerModel");
    2268             : 
    2269       31548 :     bool IsLoadHeatRemaining(true);     // Ture if heating load remains for this chiller heater
    2270       31548 :     bool NextCompIndicator(false);      // Component indicator when identical chiller heaters exist
    2271       31548 :     int CompNum(0);                     // Component number
    2272       31548 :     int IdenticalUnitCounter = 0;       // Pointer to count number of identical unit passed
    2273             :     int IdenticalUnitRemaining;         // Pointer to count number of identical unit available for a component
    2274       31548 :     Real64 CondenserLoad(0.0);          // Remaining heating load that this wrapper should meet
    2275       31548 :     Real64 CurAvailHWMassFlowRate(0.0); // Maximum available hot water mass within the wrapper bank
    2276             : 
    2277       31548 :     CondenserLoad = this->WrapperHeatingLoad;
    2278       31548 :     Real64 HWInletMassFlowRate = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRate;
    2279             : 
    2280      134616 :     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    2281             : 
    2282             :         // Set module level inlet and outlet nodes and initialize other local variables
    2283      103068 :         int CurrentMode = 0;
    2284      103068 :         state.dataPlantCentralGSHP->ChillerPartLoadRatio = 0.0;
    2285      103068 :         state.dataPlantCentralGSHP->ChillerCyclingRatio = 0.0;
    2286      103068 :         state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    2287      103068 :         Real64 CHPower = 0.0;
    2288      103068 :         Real64 QCondenser = 0.0;
    2289      103068 :         Real64 QEvaporator = 0.0;
    2290      103068 :         Real64 FRAC = 1.0;
    2291      103068 :         Real64 CondDeltaTemp = 0.0;
    2292      103068 :         Real64 CoolingPower = 0.0;
    2293      103068 :         Real64 ActualCOP = 0.0;
    2294      103068 :         Real64 EvapInletTemp = state.dataLoopNodes->Node(this->GLHEInletNodeNum).Temp;
    2295      103068 :         Real64 CondInletTemp = state.dataLoopNodes->Node(this->HWInletNodeNum).Temp;
    2296      103068 :         Real64 EvapOutletTemp = EvapInletTemp;
    2297      103068 :         Real64 CondOutletTemp = CondInletTemp;
    2298             : 
    2299             :         // Find proper schedule values
    2300      103068 :         if (this->NumOfComp != this->ChillerHeaterNums) { // Identical units exist
    2301      103068 :             if (ChillerHeaterNum == 1) {
    2302       31548 :                 IdenticalUnitCounter = 0;
    2303       31548 :                 NextCompIndicator = false;
    2304       31548 :                 CompNum = ChillerHeaterNum;
    2305             :             }
    2306      103068 :             if (NextCompIndicator) {
    2307        8424 :                 ++CompNum;
    2308             :             }
    2309      103068 :             if (CompNum == 1) {
    2310       86220 :                 if (ChillerHeaterNum != this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    2311       54672 :                     NextCompIndicator = false;
    2312       31548 :                 } else if (ChillerHeaterNum == this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    2313       31548 :                     NextCompIndicator = true;
    2314             :                 }
    2315       16848 :             } else if (CompNum > 1) {
    2316       16848 :                 if ((ChillerHeaterNum - ((ChillerHeaterNum - 1) - IdenticalUnitCounter)) != this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    2317        8424 :                     NextCompIndicator = false;
    2318       16848 :                 } else if ((ChillerHeaterNum - ((ChillerHeaterNum - 1) - IdenticalUnitCounter)) ==
    2319        8424 :                            this->WrapperComp(CompNum).WrapperIdenticalObjectNum) {
    2320        8424 :                     NextCompIndicator = true;
    2321             :                 }
    2322             :             }
    2323      103068 :             ++IdenticalUnitCounter;
    2324      103068 :             IdenticalUnitRemaining = this->WrapperComp(CompNum).WrapperIdenticalObjectNum - IdenticalUnitCounter;
    2325      103068 :             if (IdenticalUnitRemaining == 0) IdenticalUnitCounter = 0;
    2326           0 :         } else if (this->NumOfComp == this->ChillerHeaterNums) {
    2327           0 :             ++CompNum;
    2328             :         }
    2329             : 
    2330             :         Real64 CondMassFlowRate; // Condenser mass flow rate through this chiller heater
    2331             :         Real64 EvapMassFlowRate; // Evaporator mass flow rate through this chiller heater
    2332             : 
    2333             :         // Check to see if this chiller heater needs to run
    2334      103068 :         if (CondenserLoad > 0.0 && (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) {
    2335       87202 :             IsLoadHeatRemaining = true;
    2336             : 
    2337             :             // Calculate density ratios to adjust mass flow rates from initialized ones
    2338             :             // Hot water temperature is known, but condenser mass flow rates will be adjusted in the following "Do" loop
    2339      174404 :             Real64 InitDensity = FluidProperties::GetDensityGlycol(state,
    2340       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    2341             :                                                                    DataGlobalConstants::CWInitConvTemp,
    2342       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    2343       87202 :                                                                    RoutineName);
    2344      174404 :             Real64 EvapDensity = FluidProperties::GetDensityGlycol(state,
    2345       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    2346             :                                                                    EvapInletTemp,
    2347       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    2348       87202 :                                                                    RoutineName);
    2349      174404 :             Real64 CondDensity = FluidProperties::GetDensityGlycol(state,
    2350       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidName,
    2351             :                                                                    CondInletTemp,
    2352       87202 :                                                                    state.dataPlnt->PlantLoop(this->CWPlantLoc.loopNum).FluidIndex,
    2353       87202 :                                                                    RoutineName);
    2354             : 
    2355             :             // Calculate density ratios to adjust mass flow rates from initialized ones
    2356       87202 :             Real64 HWDensityRatio = CondDensity / InitDensity;
    2357       87202 :             Real64 GLHEDensityRatio = EvapDensity / InitDensity;
    2358       87202 :             EvapMassFlowRate = this->ChillerHeater(ChillerHeaterNum).EvapInletNode.MassFlowRateMaxAvail;
    2359       87202 :             CondMassFlowRate = this->ChillerHeater(ChillerHeaterNum).CondInletNode.MassFlowRateMaxAvail;
    2360       87202 :             EvapMassFlowRate *= GLHEDensityRatio;
    2361       87202 :             CondMassFlowRate *= HWDensityRatio;
    2362             : 
    2363             :             // Check flows from plant to adjust as necessary
    2364       87202 :             if (CurAvailHWMassFlowRate == 0) { // First chiller heater which is on
    2365       31554 :                 CurAvailHWMassFlowRate = HWInletMassFlowRate;
    2366       55648 :             } else if (ChillerHeaterNum > 1) {
    2367       55648 :                 CurAvailHWMassFlowRate -= this->ChillerHeater(ChillerHeaterNum - 1).CondOutletNode.MassFlowRate;
    2368             :             }
    2369       87202 :             CondMassFlowRate = min(CurAvailHWMassFlowRate, CondMassFlowRate);
    2370             : 
    2371             :             // It is not enforced to be the smaller of CH max temperature and plant temp setpoint.
    2372             :             // Hot water temperatures at the individual CHs' outlet may be greater than plant setpoint temp,
    2373             :             // but should be lower than the CHs max temp
    2374       87202 :             CondOutletTemp = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutClgHtg;
    2375       87202 :             CondDeltaTemp = CondOutletTemp - CondInletTemp;
    2376             : 
    2377       87202 :             if (CondDeltaTemp < 0.0) { // Hot water temperature is greater than the maximum
    2378           0 :                 if (this->ChillerHeater(ChillerHeaterNum).ChillerEIRRefTempErrorIndex == 0) {
    2379           0 :                     ShowSevereMessage(state,
    2380           0 :                                       "CalcChillerHeaterModel: ChillerHeaterPerformance:Electric:EIR=\"" +
    2381           0 :                                           this->ChillerHeater(ChillerHeaterNum).Name + "\", DeltaTemp < 0");
    2382           0 :                     ShowContinueError(
    2383           0 :                         state, format(" Reference Simultaneous Cooling-Heating Mode Leaving Condenser Water Temperature [{:.1R}]", CondOutletTemp));
    2384           0 :                     ShowContinueError(state, format("is below condenser inlet temperature of [{:.1R}].", CondInletTemp));
    2385           0 :                     ShowContinueErrorTimeStamp(state, "");
    2386           0 :                     ShowContinueError(state, " Reset reference temperature to one greater than the inlet temperature ");
    2387             :                 }
    2388           0 :                 ShowRecurringSevereErrorAtEnd(state,
    2389           0 :                                               "ChillerHeaterPerformance:Electric:EIR=\"" + this->ChillerHeater(ChillerHeaterNum).Name +
    2390             :                                                   "\": Reference temperature problems continue.",
    2391           0 :                                               this->ChillerHeater(ChillerHeaterNum).ChillerEIRRefTempErrorIndex,
    2392             :                                               CondDeltaTemp,
    2393             :                                               CondDeltaTemp,
    2394             :                                               _,
    2395             :                                               "deltaC",
    2396             :                                               "deltaC");
    2397           0 :                 QCondenser = 0.0;
    2398           0 :                 IsLoadHeatRemaining = false;
    2399             :             }
    2400             : 
    2401       87202 :             if (ChillerHeaterNum > 1) {
    2402             :                 // Operation mode needs to be set in a simultaneous clg/htg mode
    2403             :                 // Always off even heating load remains if this CH is assumed to be off in the loop 1
    2404       55654 :                 if (this->SimulClgDominant) {
    2405       19644 :                     if (this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul == 0.0) {
    2406        4276 :                         CurrentMode = 0;
    2407        4276 :                         IsLoadHeatRemaining = false;
    2408             :                     } else { // Heat recovery
    2409       15368 :                         CurrentMode = 3;
    2410             :                     }
    2411             :                 }
    2412             :             } // End of simulataneous clg/htg mode detemination
    2413             : 
    2414             :         } else { // chiller heater is off
    2415       15866 :             IsLoadHeatRemaining = false;
    2416       15866 :             CondMassFlowRate = 0.0;
    2417       15866 :             EvapMassFlowRate = 0.0;
    2418       15866 :             CurrentMode = 0;
    2419       15866 :             if (this->SimulClgDominant) {
    2420        9396 :                 if (this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul > 0.0) {
    2421        1912 :                     CurrentMode = 4; // Simultaneous cooling dominant mode: 4
    2422             :                 }
    2423             :             } // End of mode determination
    2424             :         }     // End of system operation determinatoin
    2425             : 
    2426      182644 :         if (IsLoadHeatRemaining && CondMassFlowRate > 0.0 &&
    2427       79576 :             (ScheduleManager::GetCurrentScheduleValue(state, this->WrapperComp(CompNum).CHSchedPtr) > 0)) { // System is on
    2428             :             // Operation mode
    2429       79576 :             if (this->SimulHtgDominant) {
    2430           0 :                 if (this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul == 0.0) {
    2431           0 :                     CurrentMode = 5; // No cooling necessary
    2432             :                 } else {             // Heat recovery mode. Both chilled water and hot water loops are connected. No condenser flow.
    2433           0 :                     CurrentMode = 3;
    2434             :                 }
    2435             :             }
    2436             : 
    2437             :             // Mode 3 and 5 use cooling side data stored from the chilled water loop
    2438             :             // Mode 4 uses all data from the chilled water loop due to no heating demand
    2439       79576 :             if (this->SimulClgDominant || CurrentMode == 3) {
    2440       28952 :                 CurrentMode = 3;
    2441       57904 :                 Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2442       28952 :                                                                    state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
    2443             :                                                                    CondInletTemp,
    2444       28952 :                                                                    state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
    2445       28952 :                                                                    RoutineName);
    2446             : 
    2447       28952 :                 QCondenser = this->ChillerHeater(ChillerHeaterNum).Report.QCondSimul;
    2448             : 
    2449       28952 :                 if (this->VariableFlowCH) { // Variable flow
    2450       28952 :                     Real64 CondMassFlowRateCalc = QCondenser / CondDeltaTemp / Cp;
    2451       28952 :                     if (CondMassFlowRateCalc > CondMassFlowRate) {
    2452       28952 :                         CondMassFlowRateCalc = CondMassFlowRate;
    2453       28952 :                         Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
    2454       28952 :                         if (CondDeltaTempCalc > CondDeltaTemp) { // Load to meet should be adjusted
    2455       28952 :                             QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
    2456             :                         }
    2457             :                     }
    2458       28952 :                     CondMassFlowRate = CondMassFlowRateCalc;
    2459             :                 } else { // Constant flow control
    2460           0 :                     Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
    2461           0 :                     Real64 CondOutletTempCalc = CondDeltaTempCalc + CondInletTemp;
    2462           0 :                     if (CondOutletTempCalc > CondOutletTemp) {
    2463           0 :                         CondOutletTempCalc = CondOutletTemp;
    2464           0 :                         QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
    2465             :                     }
    2466           0 :                     CondOutletTemp = CondOutletTempCalc;
    2467       28952 :                 }
    2468             : 
    2469             :             } else { // Either Mode 2 or 3 or 5
    2470       50624 :                 if (this->SimulHtgDominant) {
    2471           0 :                     CurrentMode = 5;
    2472             :                 } else {
    2473       50624 :                     CurrentMode = 2;
    2474             :                 }
    2475             : 
    2476       50624 :                 state.dataPlantCentralGSHP->ChillerCapFT = 0.0;
    2477       50624 :                 state.dataPlantCentralGSHP->ChillerEIRFT = 0.0;
    2478       50624 :                 state.dataPlantCentralGSHP->ChillerEIRFPLR = 0.0;
    2479             : 
    2480             :                 // Assign curve values to local data array
    2481       50624 :                 this->ChillerHeater(ChillerHeaterNum).RefCap = this->ChillerHeater(ChillerHeaterNum).RefCapClgHtg;
    2482       50624 :                 this->ChillerHeater(ChillerHeaterNum).RefCOP = this->ChillerHeater(ChillerHeaterNum).RefCOPClgHtg;
    2483       50624 :                 this->ChillerHeater(ChillerHeaterNum).TempRefEvapOut = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg;
    2484       50624 :                 this->ChillerHeater(ChillerHeaterNum).TempRefCondOut = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutClgHtg;
    2485       50624 :                 this->ChillerHeater(ChillerHeaterNum).OptPartLoadRat = this->ChillerHeater(ChillerHeaterNum).OptPartLoadRatClgHtg;
    2486       50624 :                 this->ChillerHeater(ChillerHeaterNum).CondMode = this->ChillerHeater(ChillerHeaterNum).CondModeHeating;
    2487       50624 :                 this->ChillerHeater(ChillerHeaterNum).ChillerCapFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerCapFTHeatingIDX;
    2488       50624 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTHeatingIDX;
    2489       50624 :                 this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX = this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRHeatingIDX;
    2490             : 
    2491             :                 Real64 CondTempforCurve; // Reference condenser temperature for the performance curve reading
    2492             : 
    2493       50624 :                 if (this->ChillerHeater(ChillerHeaterNum).CondMode == "ENTERINGCONDENSER") {
    2494           0 :                     CondTempforCurve = CondInletTemp;
    2495       50624 :                 } else if (this->ChillerHeater(ChillerHeaterNum).CondMode == "LEAVINGCONDENSER") {
    2496       50624 :                     CondTempforCurve = this->ChillerHeater(ChillerHeaterNum).TempRefCondOutClgHtg; //! CondOutletTemp
    2497             :                 } else {
    2498           0 :                     ShowWarningError(state, "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name + "\":");
    2499           0 :                     ShowContinueError(state,
    2500           0 :                                       format("Chiller condenser temperature for curve fit are not decided, default value= cond_leaving ({:.3R}).",
    2501           0 :                                              state.dataPlantCentralGSHP->ChillerCapFT));
    2502           0 :                     CondTempforCurve =
    2503           0 :                         state.dataLoopNodes->Node(state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).TempSetPointNodeNum).TempSetPoint;
    2504             :                 }
    2505             : 
    2506             :                 Real64 MinPartLoadRat; // Min allowed operating fraction of full load
    2507             :                 Real64 MaxPartLoadRat; // Max allowed operating fraction of full load
    2508             : 
    2509       50624 :                 Curve::GetCurveMinMaxValues(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX, MinPartLoadRat, MaxPartLoadRat);
    2510       50624 :                 Real64 ChillerRefCap = this->ChillerHeater(ChillerHeaterNum).RefCap;
    2511       50624 :                 Real64 ReferenceCOP = this->ChillerHeater(ChillerHeaterNum).RefCOP;
    2512       50624 :                 EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg;
    2513       50624 :                 Real64 TempLowLimitEout = this->ChillerHeater(ChillerHeaterNum).TempLowLimitEvapOut;
    2514       50624 :                 Real64 EvapOutletTempSetPoint = this->ChillerHeater(ChillerHeaterNum).TempRefEvapOutClgHtg;
    2515       50624 :                 state.dataPlantCentralGSHP->ChillerCapFT =
    2516      101248 :                     Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerCapFTIDX, EvapOutletTempSetPoint, CondTempforCurve);
    2517             : 
    2518       50624 :                 if (state.dataPlantCentralGSHP->ChillerCapFT < 0) {
    2519           0 :                     if (this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError < 1 && !state.dataGlobal->WarmupFlag) {
    2520           0 :                         ++this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError;
    2521           0 :                         ShowWarningError(state, "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name + "\":");
    2522           0 :                         ShowContinueError(state,
    2523           0 :                                           format(" ChillerHeater Capacity as a Function of Temperature curve output is negative ({:.3R}).",
    2524           0 :                                                  state.dataPlantCentralGSHP->ChillerCapFT));
    2525           0 :                         ShowContinueError(
    2526             :                             state,
    2527           0 :                             format(" Negative value occurs using an Evaporator Outlet Temp of {:.1R} and a Condenser Inlet Temp of {:.1R}.",
    2528             :                                    EvapOutletTempSetPoint,
    2529           0 :                                    CondInletTemp));
    2530           0 :                         ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    2531           0 :                     } else if (!state.dataGlobal->WarmupFlag) {
    2532           0 :                         ++this->ChillerHeater(ChillerHeaterNum).ChillerCapFTError;
    2533           0 :                         ShowRecurringWarningErrorAtEnd(
    2534             :                             state,
    2535           0 :                             "ChillerHeaterPerformance:Electric:EIR \"" + this->ChillerHeater(ChillerHeaterNum).Name +
    2536             :                                 "\": ChillerHeater Capacity as a Function of Temperature curve output is negative warning continues...",
    2537           0 :                             this->ChillerHeater(ChillerHeaterNum).ChillerCapFTErrorIndex,
    2538           0 :                             state.dataPlantCentralGSHP->ChillerCapFT,
    2539           0 :                             state.dataPlantCentralGSHP->ChillerCapFT);
    2540             :                     }
    2541           0 :                     state.dataPlantCentralGSHP->ChillerCapFT = 0.0;
    2542             :                 }
    2543             : 
    2544             :                 // Available chiller capacity as a function of temperature
    2545       50624 :                 Real64 AvailChillerCap = ChillerRefCap * state.dataPlantCentralGSHP->ChillerCapFT;
    2546             : 
    2547             :                 Real64 PartLoadRat; // Operating part load ratio
    2548             : 
    2549             :                 // Part load ratio based on reference capacity and available chiller capacity
    2550       50624 :                 if (AvailChillerCap > 0) {
    2551       50624 :                     PartLoadRat = max(0.0, min((ChillerRefCap / AvailChillerCap), MaxPartLoadRat));
    2552             :                 } else {
    2553           0 :                     PartLoadRat = 0.0;
    2554             :                 }
    2555             : 
    2556      151872 :                 Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2557       50624 :                                                                    state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
    2558       50624 :                                                                    this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp,
    2559       50624 :                                                                    state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
    2560       50624 :                                                                    RoutineName);
    2561             : 
    2562             :                 // Calculate evaporator heat transfer
    2563       50624 :                 if (EvapMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
    2564       50624 :                     QEvaporator = AvailChillerCap * PartLoadRat;
    2565       50624 :                     Real64 EvapDeltaTemp = QEvaporator / EvapMassFlowRate / Cp;
    2566       50624 :                     EvapOutletTemp = EvapInletTemp - EvapDeltaTemp;
    2567             :                 }
    2568             : 
    2569             :                 // Check that the evaporator outlet temp honors both plant loop temp low limit and also the chiller low limit
    2570       50624 :                 if (EvapOutletTemp < TempLowLimitEout) {
    2571           4 :                     if ((this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp - TempLowLimitEout) > DataPlant::DeltaTempTol) {
    2572           4 :                         EvapOutletTemp = TempLowLimitEout;
    2573           4 :                         Real64 EvapDeltaTemp = this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp - EvapOutletTemp;
    2574           4 :                         QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2575             :                     } else {
    2576           0 :                         EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp;
    2577           0 :                         Real64 EvapDeltaTemp = this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp - EvapOutletTemp;
    2578           0 :                         QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2579             :                     }
    2580             :                 }
    2581             : 
    2582       50624 :                 if (EvapOutletTemp < this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin) {
    2583           0 :                     if ((this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp - this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin) >
    2584             :                         DataPlant::DeltaTempTol) {
    2585           0 :                         EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin;
    2586           0 :                         Real64 EvapDeltaTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin - EvapOutletTemp;
    2587           0 :                         QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2588             :                     } else {
    2589           0 :                         EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin;
    2590           0 :                         Real64 EvapDeltaTemp = this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.TempMin - EvapOutletTemp;
    2591           0 :                         QEvaporator = EvapMassFlowRate * Cp * EvapDeltaTemp;
    2592             :                     }
    2593             :                 }
    2594             : 
    2595             :                 // Evaporator operates at full load
    2596       50624 :                 if (AvailChillerCap > 0.0) {
    2597       50624 :                     PartLoadRat = max(0.0, min((QEvaporator / AvailChillerCap), MaxPartLoadRat));
    2598             :                 } else {
    2599           0 :                     PartLoadRat = 0.0;
    2600             :                 }
    2601             : 
    2602             :                 // Chiller cycles below minimum part load ratio, FRAC = amount of time chiller is ON during this time step
    2603       50624 :                 if (PartLoadRat < MinPartLoadRat) FRAC = min(1.0, (PartLoadRat / MinPartLoadRat));
    2604       50624 :                 if (FRAC <= 0.0) FRAC = 1.0; // CR 9303 COP reporting issue, it should be greater than zero in this routine
    2605       50624 :                 state.dataPlantCentralGSHP->ChillerCyclingRatio = FRAC;
    2606             : 
    2607             :                 // Chiller is false loading below PLR = minimum unloading ratio, find PLR used for energy calculation
    2608       50624 :                 if (AvailChillerCap > 0.0) {
    2609       50624 :                     PartLoadRat = max(PartLoadRat, MinPartLoadRat);
    2610             :                 } else {
    2611           0 :                     PartLoadRat = 0.0;
    2612             :                 }
    2613             :                 // Evaporator part load ratio
    2614       50624 :                 state.dataPlantCentralGSHP->ChillerPartLoadRatio = PartLoadRat;
    2615             : 
    2616             :                 // calculate the load due to false loading on chiller over and above water side load
    2617       50624 :                 state.dataPlantCentralGSHP->ChillerFalseLoadRate = (AvailChillerCap * PartLoadRat * FRAC) - QEvaporator;
    2618       50624 :                 if (state.dataPlantCentralGSHP->ChillerFalseLoadRate < DataHVACGlobals::SmallLoad) {
    2619       50624 :                     state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    2620             :                 }
    2621             : 
    2622       50624 :                 state.dataPlantCentralGSHP->ChillerEIRFT =
    2623      101248 :                     max(0.0, Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFTIDX, EvapOutletTemp, CondTempforCurve));
    2624       50624 :                 state.dataPlantCentralGSHP->ChillerEIRFPLR =
    2625      101248 :                     max(0.0, Curve::CurveValue(state, this->ChillerHeater(ChillerHeaterNum).ChillerEIRFPLRIDX, PartLoadRat));
    2626       50624 :                 CHPower =
    2627       50624 :                     (AvailChillerCap / ReferenceCOP) * state.dataPlantCentralGSHP->ChillerEIRFPLR * state.dataPlantCentralGSHP->ChillerEIRFT * FRAC;
    2628             : 
    2629       50624 :                 if (CHPower <= 0.0) {
    2630           0 :                     ActualCOP = 0.0;
    2631             :                 } else {
    2632       50624 :                     ActualCOP = (QEvaporator + state.dataPlantCentralGSHP->ChillerFalseLoadRate) / CHPower;
    2633             :                 }
    2634             : 
    2635       50624 :                 QCondenser =
    2636       50624 :                     CHPower * this->ChillerHeater(ChillerHeaterNum).OpenMotorEff + QEvaporator + state.dataPlantCentralGSHP->ChillerFalseLoadRate;
    2637             : 
    2638             :                 // Determine heating load for this heater and pass the remaining load to the next chiller heater
    2639       50624 :                 Real64 CondenserCapMin = QCondenser * MinPartLoadRat;
    2640       50624 :                 Real64 HeatingLoadToMeet = min(QCondenser, max(std::abs(CondenserLoad), CondenserCapMin));
    2641             : 
    2642             :                 // Set load this chiller heater should meet and temperatures given
    2643       50624 :                 QCondenser = min(HeatingLoadToMeet, QCondenser);
    2644             : 
    2645      101248 :                 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2646       50624 :                                                             state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
    2647             :                                                             CondInletTemp,
    2648       50624 :                                                             state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
    2649             :                                                             RoutineNameElecEIRChiller);
    2650             : 
    2651             :                 // Calculate temperatures for constant flow and mass flow rate for variable flow
    2652             :                 // Limit mass for this chiller heater to the available mass at given temperature conditions
    2653             :                 // when mass calculated to meet the load is greater than the maximum available
    2654             :                 // then recalculate heating load this chiller heater can meet
    2655       50624 :                 if (CurrentMode == 2 || this->SimulHtgDominant) {
    2656       50624 :                     if (CondMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance && CondDeltaTemp > 0.0) {
    2657       50624 :                         if (this->VariableFlowCH) { // Variable flow
    2658       50624 :                             Real64 CondMassFlowRateCalc = QCondenser / CondDeltaTemp / Cp;
    2659       50624 :                             if (CondMassFlowRateCalc > CondMassFlowRate) {
    2660       45996 :                                 CondMassFlowRateCalc = CondMassFlowRate;
    2661       45996 :                                 Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
    2662       45996 :                                 if (CondDeltaTempCalc > CondDeltaTemp) { // Load to meet should be adjusted
    2663       45752 :                                     QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
    2664             :                                 }
    2665             :                             }
    2666       50624 :                             CondMassFlowRate = CondMassFlowRateCalc;
    2667             :                         } else { // Constant Flow at a fixed flow rate and capacity
    2668           0 :                             Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
    2669           0 :                             Real64 CondOutletTempCalc = CondDeltaTempCalc + CondInletTemp;
    2670           0 :                             if (CondOutletTempCalc > CondOutletTemp) { // Load to meet should be adjusted
    2671           0 :                                 CondOutletTempCalc = CondOutletTemp;
    2672           0 :                                 QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
    2673             :                             }
    2674           0 :                             CondOutletTemp = CondOutletTempCalc;
    2675       50624 :                         }
    2676             :                     } else {
    2677           0 :                         QCondenser = 0.0;
    2678           0 :                         CondOutletTemp = CondInletTemp;
    2679             :                     }
    2680             :                 }
    2681             : 
    2682             :             } // End of calculation depending on the modes
    2683             : 
    2684             :             // Determine load next chiller heater meets
    2685       79576 :             if (CondenserLoad < QCondenser) { // Heating load is met by this chiller heater
    2686        4932 :                 CondenserLoad = 0.0;
    2687             :             } else {
    2688       74644 :                 CondenserLoad -= QCondenser;
    2689             :             }
    2690             : 
    2691       79576 :             if (QCondenser == 0.0) {
    2692           0 :                 CurrentMode = 0;
    2693           0 :                 state.dataPlantCentralGSHP->ChillerPartLoadRatio = 0.0;
    2694           0 :                 state.dataPlantCentralGSHP->ChillerCyclingRatio = 0.0;
    2695           0 :                 state.dataPlantCentralGSHP->ChillerFalseLoadRate = 0.0;
    2696           0 :                 EvapMassFlowRate = 0.0;
    2697           0 :                 CondMassFlowRate = 0.0;
    2698           0 :                 CHPower = 0.0;
    2699           0 :                 QEvaporator = 0.0;
    2700           0 :                 EvapOutletTemp = EvapInletTemp;
    2701           0 :                 CondOutletTemp = CondInletTemp;
    2702           0 :                 CondenserLoad = 0.0;
    2703             :             }
    2704             : 
    2705             :             // Heat recovery or cooling dominant modes need to use the evaporator side information
    2706       79576 :             if (CurrentMode == 3 || CurrentMode == 4) {
    2707       28952 :                 state.dataPlantCentralGSHP->ChillerPartLoadRatio = this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatioSimul;
    2708       28952 :                 state.dataPlantCentralGSHP->ChillerCyclingRatio = this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatioSimul;
    2709       28952 :                 state.dataPlantCentralGSHP->ChillerFalseLoadRate = this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRateSimul;
    2710       28952 :                 state.dataPlantCentralGSHP->ChillerCapFT = this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFTSimul;
    2711       28952 :                 state.dataPlantCentralGSHP->ChillerEIRFT = this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFTSimul;
    2712       28952 :                 state.dataPlantCentralGSHP->ChillerEIRFPLR = this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLRSimul;
    2713       28952 :                 QEvaporator = this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul;
    2714       28952 :                 EvapOutletTemp = this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTempSimul;
    2715       28952 :                 EvapInletTemp = this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTempSimul;
    2716       28952 :                 EvapMassFlowRate = this->ChillerHeater(ChillerHeaterNum).Report.EvapmdotSimul;
    2717       28952 :                 if (this->SimulClgDominant) {
    2718       28952 :                     CHPower = this->ChillerHeater(ChillerHeaterNum).Report.CoolingPowerSimul;
    2719       28952 :                     this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower = 0.0;
    2720             :                 }
    2721             :             }
    2722             :         }
    2723             : 
    2724             :         // Check if it is mode 4, then skip binding local variables
    2725      103068 :         if (CurrentMode == 4) {
    2726        1912 :             this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = CurrentMode;
    2727             :         } else {
    2728      101156 :             this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.MassFlowRate = EvapMassFlowRate;
    2729      101156 :             this->ChillerHeater(ChillerHeaterNum).CondOutletNode.MassFlowRate = CondMassFlowRate;
    2730      101156 :             this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.Temp = EvapOutletTemp;
    2731      101156 :             this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp = EvapInletTemp;
    2732      101156 :             this->ChillerHeater(ChillerHeaterNum).CondOutletNode.Temp = CondOutletTemp;
    2733      101156 :             this->ChillerHeater(ChillerHeaterNum).CondInletNode.Temp = CondInletTemp;
    2734      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = CurrentMode;
    2735      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatio = state.dataPlantCentralGSHP->ChillerPartLoadRatio;
    2736      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatio = state.dataPlantCentralGSHP->ChillerCyclingRatio;
    2737      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate = state.dataPlantCentralGSHP->ChillerFalseLoadRate;
    2738      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFT = state.dataPlantCentralGSHP->ChillerCapFT;
    2739      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFT = state.dataPlantCentralGSHP->ChillerEIRFT;
    2740      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLR = state.dataPlantCentralGSHP->ChillerEIRFPLR;
    2741      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower = CoolingPower;
    2742      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower = CHPower;
    2743      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.QEvap = QEvaporator;
    2744      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.QCond = QCondenser;
    2745      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp = EvapOutletTemp;
    2746      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTemp = EvapInletTemp;
    2747      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp = CondOutletTemp;
    2748      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.CondInletTemp = CondInletTemp;
    2749      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot = EvapMassFlowRate;
    2750      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.Condmdot = CondMassFlowRate;
    2751      101156 :             this->ChillerHeater(ChillerHeaterNum).Report.ActualCOP = ActualCOP;
    2752             :         }
    2753             :     }
    2754       31548 : }
    2755             : 
    2756      170664 : void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int const LoopNum)
    2757             : {
    2758             :     // SUBROUTINE INFORMATION:
    2759             :     //       AUTHOR         Daeho Kang, PNNL
    2760             :     //       DATE WRITTEN   Feb 2013
    2761             :     //       MODIFIED       na
    2762             :     //       RE-ENGINEERED  na
    2763             : 
    2764             :     // PURPOSE OF THIS SUBROUTINE:
    2765             :     //  Calculate node information connected to plant & condenser loop
    2766             : 
    2767             :     // METHODOLOGY EMPLOYED:
    2768             :     //  Use empirical curve fits to model performance at off-reference conditions
    2769             : 
    2770      170664 :     Real64 CurHeatingLoad = 0.0;       // Total heating load chiller heater bank (wrapper) meets
    2771             :     Real64 CHWOutletTemp;              // Chiller heater bank chilled water outlet temperature
    2772             :     Real64 CHWOutletMassFlowRate;      // Chiller heater bank chilled water outlet mass flow rate
    2773             :     Real64 HWOutletTemp;               // Chiller heater bank hot water outlet temperature
    2774             :     Real64 GLHEOutletTemp;             // Chiller heater bank condenser loop outlet temperature
    2775             :     Real64 GLHEOutletMassFlowRate;     // Chiller heater bank condenser loop outlet mass flow rate
    2776      170664 :     Real64 WrapperElecPowerCool(0.0);  // Chiller heater bank total cooling electricity [W]
    2777      170664 :     Real64 WrapperElecPowerHeat(0.0);  // Chiller heater bank total heating electricity [W]
    2778      170664 :     Real64 WrapperCoolRate(0.0);       // Chiller heater bank total cooling rate [W]
    2779      170664 :     Real64 WrapperHeatRate(0.0);       // Chiller heater bank total heating rate [W]
    2780      170664 :     Real64 WrapperGLHERate(0.0);       // Chiller heater bank total condenser heat transfer rate [W]
    2781      170664 :     Real64 WrapperElecEnergyCool(0.0); // Chiller heater bank total electric cooling energy [J]
    2782      170664 :     Real64 WrapperElecEnergyHeat(0.0); // Chiller heater bank total electric heating energy [J]
    2783      170664 :     Real64 WrapperCoolEnergy(0.0);     // Chiller heater bank total cooling energy [J]
    2784      170664 :     Real64 WrapperHeatEnergy(0.0);     // Chiller heater bank total heating energy [J]
    2785      170664 :     Real64 WrapperGLHEEnergy(0.0);     // Chiller heater bank total condenser heat transfer energy [J]
    2786             : 
    2787             :     // Chiller heater bank chilled water inlet mass flow rate
    2788      170664 :     Real64 CHWInletMassFlowRate = 0.0;
    2789             : 
    2790      170664 :     Real64 HWInletMassFlowRate = 0.0;
    2791      170664 :     Real64 GLHEInletMassFlowRate = 0.0;
    2792      170664 :     Real64 CHWInletTemp = state.dataLoopNodes->Node(this->CHWInletNodeNum).Temp;
    2793             : 
    2794             :     // Chiller heater bank hot water inlet temperature
    2795      170664 :     Real64 HWInletTemp = state.dataLoopNodes->Node(this->HWInletNodeNum).Temp;
    2796             : 
    2797             :     // Chiller heater bank condenser loop inlet temperature
    2798      170664 :     Real64 GLHEInletTemp = state.dataLoopNodes->Node(this->GLHEInletNodeNum).Temp;
    2799             : 
    2800      170664 :     Real64 CurCoolingLoad = 0.0; // Total cooling load chiller heater bank (wrapper) meets
    2801             : 
    2802             :     // Initiate loads and inlet temperatures each loop
    2803      170664 :     if (LoopNum == this->CWPlantLoc.loopNum) {
    2804       85332 :         CHWInletMassFlowRate = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRateMaxAvail;
    2805       85332 :         HWInletMassFlowRate = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRate;
    2806       85332 :         GLHEInletMassFlowRate = state.dataLoopNodes->Node(this->GLHEInletNodeNum).MassFlowRateMaxAvail;
    2807       85332 :         DataPlant::LoopSideLocation LoopSideNum = this->CWPlantLoc.loopSideNum;
    2808       85332 :         this->WrapperCoolingLoad = 0.0;
    2809       85332 :         CurCoolingLoad = std::abs(MyLoad);
    2810       85332 :         this->WrapperCoolingLoad = CurCoolingLoad;
    2811             :         // Set actual mass flow rate at the nodes when it's locked
    2812       85332 :         if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(LoopSideNum).FlowLock == DataPlant::FlowLock::Locked) {
    2813       42660 :             CHWInletMassFlowRate = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRate;
    2814             :         }
    2815       85332 :         if (CHWInletMassFlowRate == 0.0) GLHEInletMassFlowRate = 0.0;
    2816             : 
    2817       85332 :     } else if (LoopNum == this->HWPlantLoc.loopNum) {
    2818       85332 :         CHWInletMassFlowRate = state.dataLoopNodes->Node(this->CHWInletNodeNum).MassFlowRate;
    2819       85332 :         HWInletMassFlowRate = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRateMaxAvail;
    2820       85332 :         GLHEInletMassFlowRate = state.dataLoopNodes->Node(this->GLHEInletNodeNum).MassFlowRateMaxAvail;
    2821       85332 :         DataPlant::LoopSideLocation LoopSideNum = this->HWPlantLoc.loopSideNum;
    2822       85332 :         this->WrapperHeatingLoad = 0.0;
    2823       85332 :         CurHeatingLoad = MyLoad;
    2824       85332 :         this->WrapperHeatingLoad = CurHeatingLoad;
    2825             :         // Set actual mass flow rate at the nodes when it's locked
    2826       85332 :         if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(LoopSideNum).FlowLock == DataPlant::FlowLock::Locked) {
    2827       42660 :             HWInletMassFlowRate = state.dataLoopNodes->Node(this->HWInletNodeNum).MassFlowRate;
    2828             :         }
    2829       85332 :         if (HWInletMassFlowRate == 0.0) GLHEInletMassFlowRate = 0.0;
    2830             :     }
    2831             : 
    2832      170664 :     if (LoopNum == this->CWPlantLoc.loopNum) {
    2833       85332 :         if (this->ControlMode == CondenserType::SmartMixing) {
    2834       85332 :             if (CurCoolingLoad > 0.0 && CHWInletMassFlowRate > 0.0 && GLHEInletMassFlowRate > 0) {
    2835             : 
    2836       19840 :                 this->CalcChillerModel(state);
    2837       19840 :                 this->UpdateChillerRecords(state);
    2838             : 
    2839             :                 // Initialize local variables only for calculating mass-weighed temperatures
    2840       19840 :                 CHWOutletTemp = 0.0;
    2841       19840 :                 GLHEOutletTemp = 0.0;
    2842       19840 :                 CHWOutletMassFlowRate = 0.0;
    2843       19840 :                 GLHEOutletMassFlowRate = 0.0;
    2844             : 
    2845       84416 :                 for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    2846             : 
    2847             :                     // Calculated mass flow rate used by individual chiller heater and bypasses
    2848       64576 :                     CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot;
    2849      129152 :                     CHWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp *
    2850       64576 :                                      (this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot / CHWInletMassFlowRate);
    2851       64576 :                     WrapperElecPowerCool += this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower;
    2852       64576 :                     WrapperCoolRate += this->ChillerHeater(ChillerHeaterNum).Report.QEvap;
    2853       64576 :                     WrapperElecEnergyCool += this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy;
    2854       64576 :                     WrapperCoolEnergy += this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy;
    2855       64576 :                     if (GLHEInletMassFlowRate > 0.0) {
    2856       64576 :                         GLHEOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum).Report.Condmdot;
    2857       64576 :                         if (GLHEOutletMassFlowRate > GLHEInletMassFlowRate) GLHEOutletMassFlowRate = GLHEInletMassFlowRate;
    2858      129152 :                         GLHEOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp *
    2859       64576 :                                           (this->ChillerHeater(ChillerHeaterNum).Report.Condmdot / GLHEInletMassFlowRate);
    2860       64576 :                         WrapperGLHERate += this->ChillerHeater(ChillerHeaterNum).Report.QCond;
    2861       64576 :                         WrapperGLHEEnergy += this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy;
    2862             :                     } else {
    2863           0 :                         GLHEInletMassFlowRate = 0.0;
    2864           0 :                         GLHEOutletMassFlowRate = 0.0;
    2865           0 :                         GLHEOutletTemp = GLHEInletTemp;
    2866           0 :                         WrapperGLHERate = 0.0;
    2867           0 :                         WrapperGLHEEnergy = 0.0;
    2868             :                     }
    2869             :                 } // End of summation of mass flow rates and mass weighted temperatrue
    2870             : 
    2871             :                 // Calculate temperatures for the mixed flows in the chiller bank
    2872       19840 :                 Real64 CHWBypassMassFlowRate = CHWInletMassFlowRate - CHWOutletMassFlowRate;
    2873       19840 :                 if (CHWBypassMassFlowRate > 0.0) {
    2874       13350 :                     CHWOutletTemp += CHWInletTemp * CHWBypassMassFlowRate / CHWInletMassFlowRate;
    2875             :                 } else {
    2876             :                     // CHWOutletTemp = CHWOutletTemp; // Self-assignment commented out
    2877             :                 }
    2878             : 
    2879       19840 :                 if (GLHEInletMassFlowRate > 0.0) {
    2880       19840 :                     Real64 GLHEBypassMassFlowRate = GLHEInletMassFlowRate - GLHEOutletMassFlowRate;
    2881       19840 :                     if (GLHEBypassMassFlowRate > 0.0) {
    2882        5055 :                         GLHEOutletTemp += GLHEInletTemp * GLHEBypassMassFlowRate / GLHEInletMassFlowRate;
    2883             :                     } else {
    2884             :                         // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    2885             :                     }
    2886             :                 } else {
    2887           0 :                     GLHEOutletTemp = GLHEInletTemp;
    2888             :                 }
    2889             : 
    2890       19840 :                 HWOutletTemp = HWInletTemp;
    2891             : 
    2892       19840 :                 if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) {
    2893           0 :                     WrapperElecPowerCool += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr));
    2894             :                 }
    2895             : 
    2896       19840 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp;
    2897       19840 :                 state.dataLoopNodes->Node(this->HWOutletNodeNum).Temp = HWOutletTemp;
    2898       19840 :                 state.dataLoopNodes->Node(this->GLHEOutletNodeNum).Temp = GLHEOutletTemp;
    2899             : 
    2900             :             } else {
    2901             : 
    2902             :                 // Initialize local variables
    2903       65492 :                 CHWOutletTemp = CHWInletTemp;
    2904       65492 :                 HWOutletTemp = HWInletTemp;
    2905       65492 :                 GLHEOutletTemp = GLHEInletTemp;
    2906             : 
    2907      283214 :                 for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    2908      217722 :                     this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.MassFlowRate = 0.0;
    2909      217722 :                     this->ChillerHeater(ChillerHeaterNum).CondOutletNode.MassFlowRate = 0.0;
    2910      217722 :                     this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.Temp = CHWInletTemp;
    2911      217722 :                     this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp = CHWInletTemp;
    2912      217722 :                     this->ChillerHeater(ChillerHeaterNum).CondOutletNode.Temp = GLHEInletTemp;
    2913      217722 :                     this->ChillerHeater(ChillerHeaterNum).CondInletNode.Temp = GLHEInletTemp;
    2914      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = 0;
    2915      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatio = 0.0;
    2916      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatio = 0.0;
    2917      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate = 0.0;
    2918      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFT = 0.0;
    2919      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFT = 0.0;
    2920      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLR = 0.0;
    2921      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower = 0.0;
    2922      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower = 0.0;
    2923      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.QEvap = 0.0;
    2924      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.QCond = 0.0;
    2925      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp = CHWOutletTemp;
    2926      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTemp = CHWInletTemp;
    2927      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp = GLHEOutletTemp;
    2928      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CondInletTemp = GLHEInletTemp;
    2929      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot = 0.0;
    2930      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.Condmdot = 0.0;
    2931      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad = 0.0;
    2932      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy = 0.0;
    2933      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy = 0.0;
    2934      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy = 0.0;
    2935      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy = 0.0;
    2936      217722 :                     this->ChillerHeater(ChillerHeaterNum).Report.ActualCOP = 0.0;
    2937             :                 }
    2938             :             }
    2939             : 
    2940       85332 :             if (this->SimulHtgDominant || this->SimulClgDominant) {
    2941       14608 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp;
    2942       14608 :                 this->Report.CHWInletTempSimul = CHWInletTemp;
    2943       14608 :                 this->Report.CHWOutletTempSimul = CHWOutletTemp;
    2944       14608 :                 this->Report.CHWmdotSimul = CHWInletMassFlowRate;
    2945       14608 :                 this->Report.GLHEInletTempSimul = GLHEInletTemp;
    2946       14608 :                 this->Report.GLHEOutletTempSimul = GLHEOutletTemp;
    2947       14608 :                 this->Report.GLHEmdotSimul = GLHEInletMassFlowRate;
    2948       14608 :                 this->Report.TotElecCoolingSimul = WrapperElecEnergyCool;
    2949       14608 :                 this->Report.CoolingEnergySimul = WrapperCoolEnergy;
    2950       14608 :                 this->Report.TotElecCoolingPwrSimul = WrapperElecPowerCool;
    2951       14608 :                 this->Report.CoolingRateSimul = WrapperCoolRate;
    2952             : 
    2953             :             } else {
    2954             : 
    2955       70724 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp;
    2956       70724 :                 state.dataLoopNodes->Node(this->HWOutletNodeNum).Temp = HWOutletTemp;
    2957       70724 :                 state.dataLoopNodes->Node(this->GLHEOutletNodeNum).Temp = GLHEOutletTemp;
    2958       70724 :                 this->Report.CHWInletTemp = CHWInletTemp;
    2959       70724 :                 this->Report.CHWOutletTemp = CHWOutletTemp;
    2960       70724 :                 this->Report.HWInletTemp = HWInletTemp;
    2961       70724 :                 this->Report.HWOutletTemp = HWOutletTemp;
    2962       70724 :                 this->Report.GLHEInletTemp = GLHEInletTemp;
    2963       70724 :                 this->Report.GLHEOutletTemp = GLHEOutletTemp;
    2964       70724 :                 this->Report.CHWmdot = CHWInletMassFlowRate;
    2965       70724 :                 this->Report.HWmdot = HWInletMassFlowRate;
    2966       70724 :                 this->Report.GLHEmdot = GLHEInletMassFlowRate;
    2967       70724 :                 this->Report.TotElecCooling = WrapperElecEnergyCool;
    2968       70724 :                 this->Report.TotElecHeating = WrapperElecEnergyHeat;
    2969       70724 :                 this->Report.CoolingEnergy = WrapperCoolEnergy;
    2970       70724 :                 this->Report.HeatingEnergy = WrapperHeatEnergy;
    2971       70724 :                 this->Report.GLHEEnergy = WrapperGLHEEnergy;
    2972       70724 :                 this->Report.TotElecCoolingPwr = WrapperElecPowerCool;
    2973       70724 :                 this->Report.TotElecHeatingPwr = WrapperElecPowerHeat;
    2974       70724 :                 this->Report.CoolingRate = WrapperCoolRate;
    2975       70724 :                 this->Report.HeatingRate = WrapperHeatRate;
    2976       70724 :                 this->Report.GLHERate = WrapperGLHERate;
    2977             :             }
    2978       85332 :             PlantUtilities::SetComponentFlowRate(state, CHWInletMassFlowRate, this->CHWInletNodeNum, this->CHWOutletNodeNum, this->CWPlantLoc);
    2979             : 
    2980       85332 :             PlantUtilities::SetComponentFlowRate(state, HWInletMassFlowRate, this->HWInletNodeNum, this->HWOutletNodeNum, this->HWPlantLoc);
    2981             : 
    2982       85332 :             PlantUtilities::SetComponentFlowRate(state, GLHEInletMassFlowRate, this->GLHEInletNodeNum, this->GLHEOutletNodeNum, this->GLHEPlantLoc);
    2983             : 
    2984             :         } // End of cooling
    2985             : 
    2986       85332 :     } else if (LoopNum == this->HWPlantLoc.loopNum) {          // Hot water loop
    2987       85332 :         if (this->ControlMode == CondenserType::SmartMixing) { // Chiller heater component
    2988       85332 :             if (CurHeatingLoad > 0.0 && HWInletMassFlowRate > 0.0) {
    2989             : 
    2990       31548 :                 this->CalcChillerHeaterModel(state);
    2991       31548 :                 this->UpdateChillerHeaterRecords(state);
    2992             : 
    2993             :                 // Calculate individual CH units's temperatures and mass flow rates
    2994       31548 :                 CHWOutletTemp = 0.0;
    2995       31548 :                 HWOutletTemp = 0.0;
    2996       31548 :                 GLHEOutletTemp = 0.0;
    2997       31548 :                 CHWOutletMassFlowRate = 0.0;
    2998       31548 :                 Real64 HWOutletMassFlowRate = 0.0;
    2999       31548 :                 GLHEOutletMassFlowRate = 0.0;
    3000             : 
    3001       31548 :                 if (this->SimulHtgDominant || this->SimulClgDominant) {
    3002       14520 :                     if (this->SimulClgDominant) {
    3003       58080 :                         for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3004       43560 :                             int CurrentMode = this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode;
    3005       43560 :                             CHWInletTemp = this->Report.CHWInletTempSimul;
    3006       43560 :                             GLHEInletTemp = this->Report.GLHEInletTempSimul;
    3007       43560 :                             CHWInletMassFlowRate = this->Report.CHWmdotSimul;
    3008       43560 :                             GLHEInletMassFlowRate = this->Report.GLHEmdotSimul;
    3009             : 
    3010       43560 :                             if (CurrentMode != 0) {     // This chiller heater unit is on
    3011       31800 :                                 if (CurrentMode == 3) { // Heat recovery mode. Both chilled water and hot water connections
    3012       29888 :                                     CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum)
    3013             :                                                                  .Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop
    3014       29888 :                                     HWOutletMassFlowRate +=
    3015       29888 :                                         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot; // Wrapper condenser side to plant hot water loop
    3016       29888 :                                     if (HWInletMassFlowRate > 0.0) {
    3017       59776 :                                         HWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp *
    3018       29888 :                                                         (this->ChillerHeater(ChillerHeaterNum).Report.Condmdot /
    3019             :                                                          HWInletMassFlowRate); // Only calculate in the heat recovery mode
    3020             :                                     } else {
    3021           0 :                                         HWOutletTemp = HWInletTemp;
    3022             :                                     }
    3023             :                                 } else { // Mode 4. Cooling-only mode with other heat recovery units. Condenser flows.
    3024        1912 :                                     CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum)
    3025             :                                                                  .Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop
    3026             :                                     // Sum condenser node mass flow rates and mass weighed temperatures
    3027        1912 :                                     if (GLHEInletMassFlowRate > 0.0) {
    3028        1912 :                                         GLHEOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum).Report.CondmdotSimul;
    3029        1912 :                                         if (GLHEOutletMassFlowRate > GLHEInletMassFlowRate) GLHEOutletMassFlowRate = GLHEInletMassFlowRate;
    3030        3824 :                                         GLHEOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTempSimul *
    3031        1912 :                                                           (this->ChillerHeater(ChillerHeaterNum).Report.CondmdotSimul / GLHEInletMassFlowRate);
    3032        1912 :                                         WrapperGLHERate += this->ChillerHeater(ChillerHeaterNum).Report.QCondSimul;
    3033        1912 :                                         WrapperGLHEEnergy += this->ChillerHeater(ChillerHeaterNum).Report.CondEnergySimul;
    3034             :                                     } else {
    3035           0 :                                         GLHEInletMassFlowRate = 0.0;
    3036           0 :                                         GLHEOutletMassFlowRate = 0.0;
    3037           0 :                                         GLHEOutletTemp = GLHEInletTemp;
    3038           0 :                                         WrapperGLHERate = 0.0;
    3039           0 :                                         WrapperGLHEEnergy = 0.0;
    3040             :                                     }
    3041             :                                 }
    3042             :                             } else { // This chiller heater is off
    3043             :                                 // Check if any unit is cooling only mode
    3044       11760 :                                 if (ChillerHeaterNum == this->ChillerHeaterNums) { // All units are heat revocery mode. No condenser flow
    3045       11760 :                                     GLHEOutletMassFlowRate = 0.0;
    3046       11760 :                                     GLHEInletMassFlowRate = 0.0;
    3047       11760 :                                     GLHEOutletTemp = GLHEInletTemp;
    3048             :                                 } else { // At leaset, one of chiller heater units is cooling-only mode
    3049             :                                          // GLHEOutletMassFlowRate = GLHEOutletMassFlowRate; // Self-assignment commented out
    3050             :                                          // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    3051             :                                 }
    3052             :                             }
    3053             :                             // Calculate mass weighed chilled water temperatures
    3054       43560 :                             if (CHWInletMassFlowRate > 0.0) {
    3055       87120 :                                 CHWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTempSimul *
    3056       43560 :                                                  (this->ChillerHeater(ChillerHeaterNum).Report.EvapmdotSimul / CHWInletMassFlowRate);
    3057             :                             } else {
    3058           0 :                                 CHWOutletTemp = CHWInletTemp;
    3059             :                             }
    3060             : 
    3061       43560 :                             WrapperElecPowerCool += this->ChillerHeater(ChillerHeaterNum).Report.CoolingPowerSimul; // Cooling electricity
    3062       43560 :                             WrapperCoolRate += this->ChillerHeater(ChillerHeaterNum).Report.QEvapSimul;
    3063       43560 :                             WrapperElecEnergyCool += this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergySimul;
    3064       43560 :                             WrapperCoolEnergy += this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergySimul;
    3065             :                             // Avoid double counting wrapper energy use
    3066       43560 :                             WrapperElecPowerHeat = 0.0;
    3067       43560 :                             WrapperHeatRate = 0.0;
    3068       43560 :                             WrapperHeatEnergy = 0.0;
    3069             :                         }
    3070             : 
    3071             :                         // Calculate chilled water temperature
    3072       14520 :                         if (CHWInletMassFlowRate > 0.0) {
    3073       14520 :                             Real64 CHWBypassMassFlowRate = CHWInletMassFlowRate - CHWOutletMassFlowRate;
    3074       14520 :                             if (CHWBypassMassFlowRate > 0.0) {
    3075        3056 :                                 CHWOutletTemp += CHWInletTemp * CHWBypassMassFlowRate / CHWInletMassFlowRate;
    3076             :                             } else { // No bypass withnin a wrapper
    3077             :                                      // CHWOutletTemp = CHWOutletTemp; // Self-assignment commented out
    3078             :                             }
    3079             :                         } else {
    3080           0 :                             CHWOutletTemp = CHWInletTemp;
    3081             :                         }
    3082             :                         // Calculate hot water outlet temperature
    3083       14520 :                         if (HWInletMassFlowRate > 0.0) {
    3084       14520 :                             Real64 HWBypassMassFlowRate = HWInletMassFlowRate - HWOutletMassFlowRate;
    3085       14520 :                             if (HWBypassMassFlowRate > 0.0) {
    3086          44 :                                 HWOutletTemp += HWInletTemp * HWBypassMassFlowRate / HWInletMassFlowRate;
    3087             :                             } else {
    3088             :                                 // HWOutletTemp = HWOutletTemp; // Self-assignment commented out
    3089             :                             }
    3090             :                         } else {
    3091           0 :                             HWOutletTemp = HWInletTemp;
    3092             :                         }
    3093             :                         // Calculate condenser outlet temperature
    3094       14520 :                         if (GLHEInletMassFlowRate > 0.0) {
    3095        2760 :                             Real64 GLHEBypassMassFlowRate = GLHEInletMassFlowRate - GLHEOutletMassFlowRate;
    3096        2760 :                             if (GLHEBypassMassFlowRate > 0.0) {
    3097        2756 :                                 GLHEOutletTemp += GLHEInletTemp * GLHEBypassMassFlowRate / GLHEInletMassFlowRate;
    3098             :                             } else {
    3099             :                                 // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    3100             :                             }
    3101             :                         } else {
    3102       11760 :                             GLHEOutletTemp = GLHEInletTemp;
    3103             :                         }
    3104             : 
    3105             :                         // Add ancilliary power if scheduled
    3106       14520 :                         if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) {
    3107           0 :                             WrapperElecPowerCool += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr));
    3108             :                         }
    3109             : 
    3110             :                         // Electricity should be counted once for cooling in this mode
    3111       14520 :                         WrapperElecEnergyHeat = 0.0;
    3112             : 
    3113           0 :                     } else if (this->SimulHtgDominant) { // Heating dominant simultaneous clg/htg mode
    3114             : 
    3115           0 :                         for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3116             :                             // Set temperatures and mass flow rates for the cooling side
    3117           0 :                             int CurrentMode = this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode;
    3118           0 :                             CHWInletTemp = this->Report.CHWInletTempSimul;
    3119           0 :                             CHWInletMassFlowRate = this->Report.CHWmdotSimul;
    3120             : 
    3121           0 :                             if (CurrentMode != 0) {     // This chiller heater unit is on
    3122           0 :                                 if (CurrentMode == 3) { // Heat recovery mode. Both chilled water and hot water connections
    3123           0 :                                     CHWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum)
    3124             :                                                                  .Report.EvapmdotSimul; // Wrapper evaporator side to plant chilled water loop
    3125           0 :                                     HWOutletMassFlowRate +=
    3126           0 :                                         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot; // Wrapper condenser side to plant hot water loop
    3127           0 :                                     if (CHWInletMassFlowRate > 0.0) {
    3128           0 :                                         CHWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTempSimul *
    3129           0 :                                                          (this->ChillerHeater(ChillerHeaterNum).Report.EvapmdotSimul /
    3130             :                                                           CHWInletMassFlowRate); // Only need to calculate in the heat recovery mode
    3131             :                                     } else {
    3132           0 :                                         CHWOutletTemp = CHWInletTemp;
    3133             :                                     }
    3134             :                                 } else { // Mode 5. Heating only mode with other heat recovery units
    3135           0 :                                     HWOutletMassFlowRate +=
    3136           0 :                                         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot; // Wrapper condenser side to plant hot water loop
    3137           0 :                                     if (GLHEInletMassFlowRate > 0.0) {
    3138           0 :                                         GLHEOutletMassFlowRate +=
    3139           0 :                                             this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot; // Wrapper evaporator side to plant condenser loop
    3140           0 :                                         if (GLHEOutletMassFlowRate > GLHEInletMassFlowRate) GLHEOutletMassFlowRate = GLHEInletMassFlowRate;
    3141           0 :                                         GLHEOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp *
    3142           0 :                                                           (this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot / GLHEInletMassFlowRate);
    3143           0 :                                         WrapperGLHERate += this->ChillerHeater(ChillerHeaterNum).Report.QEvap;
    3144           0 :                                         WrapperGLHEEnergy += this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy;
    3145             :                                     } else {
    3146           0 :                                         GLHEInletMassFlowRate = 0.0;
    3147           0 :                                         GLHEOutletMassFlowRate = 0.0;
    3148           0 :                                         GLHEOutletTemp = GLHEInletTemp;
    3149           0 :                                         WrapperGLHERate = 0.0;
    3150           0 :                                         WrapperGLHEEnergy = 0.0;
    3151             :                                     }
    3152             :                                 } // End of heat recovery mode
    3153             : 
    3154             :                             } else { // This chiller heater is off
    3155             : 
    3156             :                                 // Check if any unit is heating only mode
    3157           0 :                                 if (ChillerHeaterNum == this->ChillerHeaterNums) { // All are heat revocery mode. No condenser flow
    3158           0 :                                     GLHEOutletMassFlowRate = 0.0;
    3159           0 :                                     GLHEInletMassFlowRate = 0.0;
    3160           0 :                                     GLHEOutletTemp = GLHEInletTemp;
    3161             :                                 } else { // At leaset, one of chiller heater units is heating only mode
    3162             :                                          // GLHEOutletMassFlowRate = GLHEOutletMassFlowRate; // Self-assignment commented out
    3163             :                                          // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    3164             :                                 }
    3165             :                             }
    3166             : 
    3167             :                             // Calculate mass weighed hot water temperatures
    3168           0 :                             if (HWInletMassFlowRate > 0.0) {
    3169           0 :                                 HWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp *
    3170           0 :                                                 (this->ChillerHeater(ChillerHeaterNum).Report.Condmdot /
    3171             :                                                  HWInletMassFlowRate); // Always heating as long as heating load remains
    3172             :                             } else {
    3173           0 :                                 HWOutletTemp = HWInletTemp;
    3174             :                             }
    3175             : 
    3176           0 :                             WrapperElecPowerHeat += this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower;
    3177           0 :                             WrapperHeatRate += this->ChillerHeater(ChillerHeaterNum).Report.QCond;
    3178           0 :                             WrapperElecEnergyHeat += this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy;
    3179           0 :                             WrapperHeatEnergy += this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy;
    3180             : 
    3181             :                             // Avoid double counting wrapper energy use
    3182           0 :                             WrapperElecPowerCool = 0.0;
    3183           0 :                             WrapperCoolRate = 0.0;
    3184             :                         }
    3185             :                         // Calculate chilled water outlet temperature
    3186           0 :                         if (CHWInletMassFlowRate > 0.0) {
    3187           0 :                             Real64 CHWBypassMassFlowRate = CHWInletMassFlowRate - CHWOutletMassFlowRate;
    3188           0 :                             if (CHWBypassMassFlowRate > 0.0) {
    3189           0 :                                 CHWOutletTemp += CHWInletTemp * CHWBypassMassFlowRate / CHWInletMassFlowRate;
    3190             :                             } else { // No bypass withnin a wrapper
    3191             :                                      // CHWOutletTemp = CHWOutletTemp; // Self-assignment commented out
    3192             :                             }
    3193             :                         } else {
    3194           0 :                             CHWOutletTemp = CHWInletTemp;
    3195             :                         }
    3196             :                         // Calculate hot water outlet temperature
    3197           0 :                         if (HWInletMassFlowRate > 0.0) {
    3198           0 :                             Real64 HWBypassMassFlowRate = HWInletMassFlowRate - HWOutletMassFlowRate;
    3199           0 :                             if (HWBypassMassFlowRate > 0.0) {
    3200           0 :                                 HWOutletTemp += HWInletTemp * HWBypassMassFlowRate / HWInletMassFlowRate;
    3201             :                             } else {
    3202             :                                 // HWOutletTemp = HWOutletTemp; // Self-assignment commented out
    3203             :                             }
    3204             :                         } else {
    3205           0 :                             HWOutletTemp = HWInletTemp;
    3206             :                         }
    3207             :                         // Calculate condenser outlet temperature
    3208           0 :                         if (GLHEInletMassFlowRate > 0.0) {
    3209           0 :                             Real64 GLHEBypassMassFlowRate = GLHEInletMassFlowRate - GLHEOutletMassFlowRate;
    3210           0 :                             if (GLHEBypassMassFlowRate > 0.0) {
    3211           0 :                                 GLHEOutletTemp += GLHEInletTemp * GLHEBypassMassFlowRate / GLHEInletMassFlowRate;
    3212             :                             } else {
    3213             :                                 // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    3214             :                             }
    3215             :                         } else {
    3216           0 :                             GLHEOutletTemp = GLHEInletTemp;
    3217             :                         }
    3218             : 
    3219             :                         // Check if ancilliary power is used
    3220           0 :                         if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) {
    3221           0 :                             WrapperElecPowerHeat += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr));
    3222             :                         }
    3223             : 
    3224             :                         // Electricity should be counted once
    3225           0 :                         WrapperElecEnergyCool = 0.0;
    3226             : 
    3227       14520 :                     } // End of simultaneous clg/htg mode calculations
    3228             : 
    3229             :                 } else { // Heating only mode (mode 2)
    3230             : 
    3231       76536 :                     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3232       59508 :                         HWOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum).Report.Condmdot;
    3233      178524 :                         HWOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp *
    3234      119016 :                                         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot / HWInletMassFlowRate;
    3235       59508 :                         WrapperElecPowerHeat += this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower;
    3236       59508 :                         WrapperHeatRate += this->ChillerHeater(ChillerHeaterNum).Report.QCond;
    3237       59508 :                         WrapperElecEnergyHeat += this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy;
    3238       59508 :                         WrapperHeatEnergy += this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy;
    3239             : 
    3240       59508 :                         if (GLHEInletMassFlowRate > 0.0) {
    3241       59508 :                             GLHEOutletMassFlowRate += this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot;
    3242       59508 :                             if (GLHEOutletMassFlowRate > GLHEInletMassFlowRate) GLHEOutletMassFlowRate = GLHEInletMassFlowRate;
    3243      119016 :                             GLHEOutletTemp += this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp *
    3244       59508 :                                               (this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot / GLHEInletMassFlowRate);
    3245       59508 :                             WrapperGLHERate += this->ChillerHeater(ChillerHeaterNum).Report.QEvap;
    3246       59508 :                             WrapperGLHEEnergy += this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy;
    3247             :                         } else { // No source water flow
    3248           0 :                             GLHEOutletMassFlowRate = 0.0;
    3249           0 :                             GLHEInletMassFlowRate = 0.0;
    3250           0 :                             GLHEOutletTemp = GLHEInletTemp;
    3251           0 :                             WrapperGLHERate = 0.0;
    3252           0 :                             WrapperGLHEEnergy = 0.0;
    3253             :                         }
    3254             :                     }
    3255             : 
    3256             :                     // Calculate hot water outlet temperature
    3257       17028 :                     if (HWInletMassFlowRate > 0.0) {
    3258       17028 :                         Real64 HWBypassMassFlowRate = HWInletMassFlowRate - HWOutletMassFlowRate;
    3259       17028 :                         if (HWBypassMassFlowRate > 0.0) {
    3260       11629 :                             HWOutletTemp += HWInletTemp * HWBypassMassFlowRate / HWInletMassFlowRate;
    3261             :                         } else {
    3262             :                             // HWOutletTemp = HWOutletTemp; // Self-assignment commented out
    3263        5399 :                             if (HWOutletTemp > HWInletTemp) HWOutletTemp = HWInletTemp;
    3264             :                         }
    3265             :                     } else {
    3266           0 :                         HWOutletTemp = HWInletTemp;
    3267             :                     }
    3268             : 
    3269             :                     // Calculate condenser outlet temperature
    3270       17028 :                     if (GLHEInletMassFlowRate > 0.0) {
    3271       17028 :                         Real64 GLHEBypassMassFlowRate = GLHEInletMassFlowRate - GLHEOutletMassFlowRate;
    3272       17028 :                         if (GLHEBypassMassFlowRate > 0.0) {
    3273        2272 :                             GLHEOutletTemp += GLHEInletTemp * GLHEBypassMassFlowRate / GLHEInletMassFlowRate;
    3274             :                         } else {
    3275             :                             // GLHEOutletTemp = GLHEOutletTemp; // Self-assignment commented out
    3276             :                         }
    3277             :                     } else {
    3278           0 :                         GLHEOutletTemp = GLHEInletTemp;
    3279             :                     }
    3280             : 
    3281       17028 :                     CHWOutletTemp = CHWInletTemp;
    3282             : 
    3283             :                     // Add ancilliary power if necessary
    3284       17028 :                     if (ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr) > 0) {
    3285           0 :                         WrapperElecPowerHeat += (this->AncillaryPower * ScheduleManager::GetCurrentScheduleValue(state, this->SchedPtr));
    3286             :                     }
    3287             : 
    3288             :                 } // End of calculations
    3289             : 
    3290       31548 :                 PlantUtilities::SetComponentFlowRate(state, CHWInletMassFlowRate, this->CHWInletNodeNum, this->CHWOutletNodeNum, this->CWPlantLoc);
    3291             : 
    3292       31548 :                 PlantUtilities::SetComponentFlowRate(state, HWInletMassFlowRate, this->HWInletNodeNum, this->HWOutletNodeNum, this->HWPlantLoc);
    3293             : 
    3294       31548 :                 PlantUtilities::SetComponentFlowRate(
    3295             :                     state, GLHEInletMassFlowRate, this->GLHEInletNodeNum, this->GLHEOutletNodeNum, this->GLHEPlantLoc);
    3296             : 
    3297             :                 // Local variables
    3298       31548 :                 this->Report.CHWInletTemp = CHWInletTemp;
    3299       31548 :                 this->Report.CHWOutletTemp = CHWOutletTemp;
    3300       31548 :                 this->Report.HWInletTemp = HWInletTemp;
    3301       31548 :                 this->Report.HWOutletTemp = HWOutletTemp;
    3302       31548 :                 this->Report.GLHEInletTemp = GLHEInletTemp;
    3303       31548 :                 this->Report.GLHEOutletTemp = GLHEOutletTemp;
    3304       31548 :                 this->Report.CHWmdot = CHWInletMassFlowRate;
    3305       31548 :                 this->Report.HWmdot = HWInletMassFlowRate;
    3306       31548 :                 this->Report.GLHEmdot = GLHEInletMassFlowRate;
    3307       31548 :                 this->Report.TotElecCooling = WrapperElecEnergyCool;
    3308       31548 :                 this->Report.TotElecHeating = WrapperElecEnergyHeat;
    3309       31548 :                 this->Report.CoolingEnergy = WrapperCoolEnergy;
    3310       31548 :                 this->Report.HeatingEnergy = WrapperHeatEnergy;
    3311       31548 :                 this->Report.GLHEEnergy = WrapperGLHEEnergy;
    3312       31548 :                 this->Report.TotElecCoolingPwr = WrapperElecPowerCool;
    3313       31548 :                 this->Report.TotElecHeatingPwr = WrapperElecPowerHeat;
    3314       31548 :                 this->Report.CoolingRate = WrapperCoolRate;
    3315       31548 :                 this->Report.HeatingRate = WrapperHeatRate;
    3316       31548 :                 this->Report.GLHERate = WrapperGLHERate;
    3317             : 
    3318       31548 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp;
    3319       31548 :                 state.dataLoopNodes->Node(this->HWOutletNodeNum).Temp = HWOutletTemp;
    3320       31548 :                 state.dataLoopNodes->Node(this->GLHEOutletNodeNum).Temp = GLHEOutletTemp;
    3321             : 
    3322             :             } else { // Central chiller heater system is off
    3323             : 
    3324       53784 :                 CHWOutletTemp = CHWInletTemp;
    3325       53784 :                 HWOutletTemp = HWInletTemp;
    3326       53784 :                 GLHEOutletTemp = GLHEInletTemp;
    3327       53784 :                 state.dataLoopNodes->Node(this->CHWOutletNodeNum).Temp = CHWOutletTemp;
    3328       53784 :                 state.dataLoopNodes->Node(this->HWOutletNodeNum).Temp = HWOutletTemp;
    3329       53784 :                 state.dataLoopNodes->Node(this->GLHEOutletNodeNum).Temp = GLHEOutletTemp;
    3330             : 
    3331       53784 :                 if (this->WrapperCoolingLoad == 0.0 && !this->SimulHtgDominant) {
    3332             : 
    3333      207030 :                     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3334      158478 :                         this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.MassFlowRate = 0.0;
    3335      158478 :                         this->ChillerHeater(ChillerHeaterNum).CondOutletNode.MassFlowRate = 0.0;
    3336      158478 :                         this->ChillerHeater(ChillerHeaterNum).EvapOutletNode.Temp = CHWInletTemp;
    3337      158478 :                         this->ChillerHeater(ChillerHeaterNum).EvapInletNode.Temp = CHWInletTemp;
    3338      158478 :                         this->ChillerHeater(ChillerHeaterNum).CondOutletNode.Temp = GLHEInletTemp;
    3339      158478 :                         this->ChillerHeater(ChillerHeaterNum).CondInletNode.Temp = GLHEInletTemp;
    3340      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CurrentMode = 0;
    3341      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerPartLoadRatio = 0.0;
    3342      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerCyclingRatio = 0.0;
    3343      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate = 0.0;
    3344      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerCapFT = 0.0;
    3345      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFT = 0.0;
    3346      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerEIRFPLR = 0.0;
    3347      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower = 0.0;
    3348      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower = 0.0;
    3349      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.QEvap = 0.0;
    3350      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.QCond = 0.0;
    3351      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.EvapOutletTemp = CHWOutletTemp;
    3352      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.EvapInletTemp = CHWInletTemp;
    3353      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CondOutletTemp = GLHEOutletTemp;
    3354      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CondInletTemp = GLHEInletTemp;
    3355      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.Evapmdot = 0.0;
    3356      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.Condmdot = 0.0;
    3357      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad = 0.0;
    3358      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy = 0.0;
    3359      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy = 0.0;
    3360      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy = 0.0;
    3361      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy = 0.0;
    3362      158478 :                         this->ChillerHeater(ChillerHeaterNum).Report.ActualCOP = 0.0;
    3363             :                     }
    3364             : 
    3365       48552 :                     this->Report.CHWInletTemp = CHWInletTemp;
    3366       48552 :                     this->Report.CHWOutletTemp = CHWOutletTemp;
    3367       48552 :                     this->Report.HWInletTemp = HWInletTemp;
    3368       48552 :                     this->Report.HWOutletTemp = HWOutletTemp;
    3369       48552 :                     this->Report.GLHEInletTemp = GLHEInletTemp;
    3370       48552 :                     this->Report.GLHEOutletTemp = GLHEOutletTemp;
    3371       48552 :                     this->Report.CHWmdot = CHWInletMassFlowRate;
    3372       48552 :                     this->Report.HWmdot = HWInletMassFlowRate;
    3373       48552 :                     this->Report.GLHEmdot = GLHEInletMassFlowRate;
    3374       48552 :                     this->Report.TotElecCooling = WrapperElecEnergyCool;
    3375       48552 :                     this->Report.TotElecHeating = WrapperElecEnergyHeat;
    3376       48552 :                     this->Report.CoolingEnergy = WrapperCoolEnergy;
    3377       48552 :                     this->Report.HeatingEnergy = WrapperHeatEnergy;
    3378       48552 :                     this->Report.GLHEEnergy = WrapperGLHEEnergy;
    3379       48552 :                     this->Report.TotElecCoolingPwr = WrapperElecPowerCool;
    3380       48552 :                     this->Report.TotElecHeatingPwr = WrapperElecPowerHeat;
    3381       48552 :                     this->Report.CoolingRate = WrapperCoolRate;
    3382       48552 :                     this->Report.HeatingRate = WrapperHeatRate;
    3383       48552 :                     this->Report.GLHERate = WrapperGLHERate;
    3384             : 
    3385       48552 :                     PlantUtilities::SetComponentFlowRate(
    3386             :                         state, CHWInletMassFlowRate, this->CHWInletNodeNum, this->CHWOutletNodeNum, this->CWPlantLoc);
    3387             : 
    3388       48552 :                     PlantUtilities::SetComponentFlowRate(state, HWInletMassFlowRate, this->HWInletNodeNum, this->HWOutletNodeNum, this->HWPlantLoc);
    3389             : 
    3390       48552 :                     PlantUtilities::SetComponentFlowRate(
    3391             :                         state, GLHEInletMassFlowRate, this->GLHEInletNodeNum, this->GLHEOutletNodeNum, this->GLHEPlantLoc);
    3392             :                 }
    3393             : 
    3394             :             } // Heating loop calculation
    3395             :         }
    3396             :     }
    3397      170664 : }
    3398             : 
    3399       19840 : void WrapperSpecs::UpdateChillerRecords(EnergyPlusData &state) // Wrapper number
    3400             : {
    3401             : 
    3402             :     // SUBROUTINE INFORMATION:
    3403             :     //       AUTHOR:          Daeho Kang, PNNL
    3404             :     //       DATE WRITTEN:    Feb 2013
    3405             : 
    3406             :     // PURPOSE OF THIS SUBROUTINE:
    3407             :     //  Update chiller heater variables
    3408             : 
    3409             :     Real64 SecInTimeStep; // Number of seconds per HVAC system time step, to convert from W (J/s) to J
    3410             :     int ChillerHeaterNum; // Chiller heater number
    3411             : 
    3412       19840 :     SecInTimeStep = state.dataHVACGlobal->TimeStepSys * DataGlobalConstants::SecInHour;
    3413             : 
    3414       84416 :     for (ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3415       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad =
    3416       64576 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate * SecInTimeStep;
    3417       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy = this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower * SecInTimeStep;
    3418       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy = this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower * SecInTimeStep;
    3419       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy = this->ChillerHeater(ChillerHeaterNum).Report.QEvap * SecInTimeStep;
    3420       64576 :         this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy = this->ChillerHeater(ChillerHeaterNum).Report.QCond * SecInTimeStep;
    3421       64576 :         if (this->SimulClgDominant || this->SimulHtgDominant) {
    3422       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadSimul = this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad;
    3423       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergySimul = this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy;
    3424       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergySimul = this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy;
    3425       43692 :             this->ChillerHeater(ChillerHeaterNum).Report.CondEnergySimul = this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy;
    3426             :         }
    3427             :     }
    3428       19840 : }
    3429             : 
    3430       31548 : void WrapperSpecs::UpdateChillerHeaterRecords(EnergyPlusData &state) // Wrapper number
    3431             : {
    3432             : 
    3433             :     // SUBROUTINE INFORMATION:
    3434             :     //       AUTHOR:          Daeho Kang, PNNL
    3435             :     //       DATE WRITTEN:    Feb 2013
    3436             : 
    3437             :     // Number of seconds per HVAC system time step, to convert from W (J/s) to J
    3438       31548 :     Real64 SecInTimeStep = state.dataHVACGlobal->TimeStepSys * DataGlobalConstants::SecInHour;
    3439             : 
    3440      134616 :     for (int ChillerHeaterNum = 1; ChillerHeaterNum <= this->ChillerHeaterNums; ++ChillerHeaterNum) {
    3441      103068 :         this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoad =
    3442      103068 :             this->ChillerHeater(ChillerHeaterNum).Report.ChillerFalseLoadRate * SecInTimeStep;
    3443      103068 :         this->ChillerHeater(ChillerHeaterNum).Report.CoolingEnergy = this->ChillerHeater(ChillerHeaterNum).Report.CoolingPower * SecInTimeStep;
    3444      103068 :         this->ChillerHeater(ChillerHeaterNum).Report.HeatingEnergy = this->ChillerHeater(ChillerHeaterNum).Report.HeatingPower * SecInTimeStep;
    3445      103068 :         this->ChillerHeater(ChillerHeaterNum).Report.EvapEnergy = this->ChillerHeater(ChillerHeaterNum).Report.QEvap * SecInTimeStep;
    3446      103068 :         this->ChillerHeater(ChillerHeaterNum).Report.CondEnergy = this->ChillerHeater(ChillerHeaterNum).Report.QCond * SecInTimeStep;
    3447             :     }
    3448       31548 : }
    3449           2 : void WrapperSpecs::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
    3450             : {
    3451           2 : }
    3452             : 
    3453           0 : void WrapperSpecs::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
    3454             : {
    3455           0 : }
    3456             : 
    3457        2313 : } // namespace EnergyPlus::PlantCentralGSHP

Generated by: LCOV version 1.13