LCOV - code coverage report
Current view: top level - EnergyPlus - PlantCentralGSHP.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 1463 1902 76.9 %
Date: 2024-08-24 18:31:18 Functions: 21 22 95.5 %

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

Generated by: LCOV version 1.14