LCOV - code coverage report
Current view: top level - EnergyPlus - HeatPumpWaterToWaterCOOLING.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 339 406 83.5 %
Date: 2024-08-24 18:31:18 Functions: 10 11 90.9 %

          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             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/string.functions.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/BranchNodeConnections.hh>
      56             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      57             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      58             : #include <EnergyPlus/DataHVACGlobals.hh>
      59             : #include <EnergyPlus/DataLoopNode.hh>
      60             : #include <EnergyPlus/FluidProperties.hh>
      61             : #include <EnergyPlus/General.hh>
      62             : #include <EnergyPlus/HeatPumpWaterToWaterCOOLING.hh>
      63             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      64             : #include <EnergyPlus/NodeInputManager.hh>
      65             : #include <EnergyPlus/OutputProcessor.hh>
      66             : #include <EnergyPlus/Plant/DataPlant.hh>
      67             : #include <EnergyPlus/Plant/PlantLocation.hh>
      68             : #include <EnergyPlus/PlantUtilities.hh>
      69             : #include <EnergyPlus/UtilityRoutines.hh>
      70             : 
      71             : namespace EnergyPlus::HeatPumpWaterToWaterCOOLING {
      72             : // Module containing the routines dealing with the Water to Water Heat Pump (Cooling)
      73             : 
      74             : // MODULE INFORMATION:
      75             : //       AUTHOR         ARUN
      76             : //       DATE WRITTEN   7/18/2000
      77             : //       MODIFIED       ARUN: 6/27/2002: Cycle Time
      78             : //                      L Lawrie: V1.1.1 (5/20/2003) add meters and energy to several reporting variables
      79             : //                      L Lawrie: V1.1.1 (5/20/2003) restructure modules to comply with standard templates
      80             : //                      B Griffith, Sept 2010, plant upgrades, general fluid properties
      81             : 
      82             : // PURPOSE OF THIS MODULE:
      83             : // This module simulates a water to Water Heat Pump (Cooling)
      84             : 
      85             : // METHODOLOGY EMPLOYED:
      86             : // This simulation is based on a set of selected parameters,
      87             : // Which are obtained using Parameter Estimation technique.
      88             : 
      89             : // MODULE PARAMETER DEFINITIONS
      90             : std::string const ModuleCompName("HeatPump:WaterToWater:ParameterEstimation:Cooling");
      91             : std::string const ModuleCompNameUC("HEATPUMP:WATERTOWATER:PARAMETERESTIMATION:COOLING");
      92             : std::string const GSHPRefrigerant("R22"); // refrigerant name and index
      93             : 
      94           6 : GshpPeCoolingSpecs *GshpPeCoolingSpecs::factory(EnergyPlusData &state, const std::string &objectName)
      95             : {
      96           6 :     if (state.dataHPWaterToWaterClg->GetWWHPCoolingInput) {
      97           3 :         GetGshpInput(state);
      98           3 :         state.dataHPWaterToWaterClg->GetWWHPCoolingInput = false;
      99             :     }
     100           6 :     auto thisObj = std::find_if(state.dataHPWaterToWaterClg->GSHP.begin(),
     101           6 :                                 state.dataHPWaterToWaterClg->GSHP.end(),
     102           6 :                                 [&objectName](const GshpPeCoolingSpecs &myObj) { return myObj.Name == objectName; });
     103           6 :     if (thisObj != state.dataHPWaterToWaterClg->GSHP.end()) return thisObj;
     104             :     // If we didn't find it, fatal
     105             :     ShowFatalError(state, format("WWHPCoolingFactory: Error getting inputs for heat pump named: {}", objectName)); // LCOV_EXCL_LINE
     106             :     // Shut up the compiler
     107             :     return nullptr; // LCOV_EXCL_LINE
     108             : }
     109             : 
     110       93022 : void GshpPeCoolingSpecs::simulate(
     111             :     EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, [[maybe_unused]] bool RunFlag)
     112             : {
     113             :     // Simulate the model for the Demand "MyLoad"
     114       93022 :     if (calledFromLocation.loopNum == this->LoadPlantLoc.loopNum) { // chilled water loop
     115       46511 :         this->initialize(state);
     116       46511 :         this->calculate(state, CurLoad);
     117       46511 :         this->update(state);
     118       46511 :     } else if (calledFromLocation.loopNum == this->SourcePlantLoc.loopNum) { // condenser loop
     119       46511 :         PlantUtilities::UpdateChillerComponentCondenserSide(state,
     120             :                                                             this->SourcePlantLoc.loopNum,
     121             :                                                             this->SourcePlantLoc.loopSideNum,
     122             :                                                             DataPlant::PlantEquipmentType::HPWaterEFCooling,
     123             :                                                             this->SourceSideInletNodeNum,
     124             :                                                             this->SourceSideOutletNodeNum,
     125             :                                                             this->QSource,
     126             :                                                             this->SourceSideWaterInletTemp,
     127             :                                                             this->SourceSideWaterOutletTemp,
     128             :                                                             this->SourceSideWaterMassFlowRate,
     129             :                                                             FirstHVACIteration);
     130             :     } else {
     131           0 :         ShowFatalError(state, format("SimHPWatertoWaterCOOLING:: Invalid loop connection {}, Requested Unit={}", ModuleCompName, this->Name));
     132             :     }
     133       93022 : }
     134             : 
     135          30 : void GshpPeCoolingSpecs::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     136             :                                              [[maybe_unused]] const PlantLocation &calledFromLocation,
     137             :                                              Real64 &MaxLoad,
     138             :                                              Real64 &MinLoad,
     139             :                                              Real64 &OptLoad)
     140             : {
     141          30 :     MinLoad = this->NomCap * this->MinPartLoadRat;
     142          30 :     MaxLoad = this->NomCap * this->MaxPartLoadRat;
     143          30 :     OptLoad = this->NomCap * this->OptPartLoadRat;
     144          30 : }
     145             : 
     146          30 : void GshpPeCoolingSpecs::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
     147             : {
     148          30 :     if (this->plantScanFlag) {
     149             :         // Locate the heating on the plant loops for later usage
     150           3 :         bool errFlag = false;
     151           9 :         PlantUtilities::ScanPlantLoopsForObject(state,
     152             :                                                 this->Name,
     153             :                                                 DataPlant::PlantEquipmentType::HPWaterPECooling,
     154           3 :                                                 this->SourcePlantLoc,
     155             :                                                 errFlag,
     156             :                                                 _,
     157             :                                                 _,
     158             :                                                 _,
     159           3 :                                                 this->SourceSideInletNodeNum,
     160             :                                                 _);
     161           9 :         PlantUtilities::ScanPlantLoopsForObject(
     162           6 :             state, this->Name, DataPlant::PlantEquipmentType::HPWaterPECooling, this->LoadPlantLoc, errFlag, _, _, _, this->LoadSideInletNodeNum, _);
     163           3 :         if (errFlag) {
     164           0 :             ShowFatalError(state, "InitGshp: Program terminated due to previous condition(s).");
     165             :         }
     166             : 
     167           3 :         PlantUtilities::InterConnectTwoPlantLoopSides(state, this->LoadPlantLoc, this->SourcePlantLoc, this->WWHPPlantTypeOfNum, true);
     168           3 :         this->plantScanFlag = false;
     169             :     }
     170          30 : }
     171             : 
     172           3 : void GetGshpInput(EnergyPlusData &state)
     173             : {
     174             :     //       SUBROUTINE INFORMATION:
     175             :     //       DATE WRITTEN:    April 1998
     176             : 
     177             :     // PURPOSE OF THIS SUBROUTINE:
     178             :     // This routine will get the input
     179             :     // required by the GSHP models.  As such
     180             :     // it will interact with the Input Scanner to retrieve
     181             :     // information from the input file, count the number of
     182             :     // GSHPs and begin to fill the
     183             :     // arrays associated with the typeGSHP.
     184             : 
     185             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     186             :     int GSHPNum;                  // Gshp counter
     187             :     int NumAlphas;                // Number of elements in the alpha array
     188             :     int NumNums;                  // Number of elements in the numeric array
     189             :     int IOStat;                   // IO Status when calling get input subroutine
     190           3 :     Array1D_string AlphArray(5);  // character string data
     191           3 :     Array1D<Real64> NumArray(23); // numeric data
     192             : 
     193           3 :     bool ErrorsFound(false);
     194             : 
     195           3 :     state.dataHPWaterToWaterClg->NumGSHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ModuleCompNameUC);
     196             : 
     197           3 :     if (state.dataHPWaterToWaterClg->NumGSHPs <= 0) {
     198           0 :         ShowSevereError(state, "No Equipment found in SimGshp");
     199           0 :         ErrorsFound = true;
     200             :     }
     201             : 
     202             :     // Allocate Arrays
     203           3 :     state.dataHPWaterToWaterClg->GSHP.allocate(state.dataHPWaterToWaterClg->NumGSHPs);
     204             : 
     205           6 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     206           3 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     207           3 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, ModuleCompNameUC, GSHPNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     208             : 
     209           3 :         thisGSHP.Name = AlphArray(1);
     210             : 
     211           3 :         thisGSHP.WWHPPlantTypeOfNum = DataPlant::PlantEquipmentType::HPWaterPECooling;
     212             : 
     213           3 :         thisGSHP.COP = NumArray(1);
     214           3 :         if (NumArray(1) == 0.0) {
     215           0 :             ShowSevereError(state, format("{}:COP = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     216           0 :             ErrorsFound = true;
     217             :         }
     218             : 
     219             :         // zero values for NumArray 0 - 6 checked in input - idd
     220             : 
     221           3 :         thisGSHP.NomCap = NumArray(2);
     222             : 
     223           3 :         thisGSHP.MinPartLoadRat = NumArray(3);
     224             : 
     225           3 :         thisGSHP.MaxPartLoadRat = NumArray(4);
     226             : 
     227           3 :         thisGSHP.OptPartLoadRat = NumArray(5);
     228             : 
     229           3 :         thisGSHP.LoadSideVolFlowRate = NumArray(6);
     230           3 :         if (NumArray(6) == 0.0) {
     231           0 :             ShowSevereError(state, format("{}:Load Side Vol Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     232           0 :             ErrorsFound = true;
     233             :         }
     234             : 
     235           3 :         thisGSHP.SourceSideVolFlowRate = NumArray(7);
     236           3 :         if (NumArray(7) == 0.0) {
     237           0 :             ShowSevereError(state, format("{}:Source Side Vol Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     238           0 :             ErrorsFound = true;
     239             :         }
     240             : 
     241           3 :         thisGSHP.LoadSideUACoeff = NumArray(8);
     242           3 :         if (NumArray(9) == 0.0) {
     243           0 :             ShowSevereError(state, format("{}:Load Side Heat Transfer Coefficient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     244           0 :             ErrorsFound = true;
     245             :         }
     246             : 
     247           3 :         thisGSHP.SourceSideUACoeff = NumArray(9);
     248           3 :         if (NumArray(8) == 0.0) {
     249           0 :             ShowSevereError(state, format("{}:Source Side Heat Transfer Coefficient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     250           0 :             ErrorsFound = true;
     251             :         }
     252             : 
     253           3 :         thisGSHP.CompPistonDisp = NumArray(10);
     254           3 :         if (NumArray(10) == 0.0) {
     255           0 :             ShowSevereError(state, format("{}:Compressor Piston displacement/Stroke = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     256           0 :             ErrorsFound = true;
     257             :         }
     258             : 
     259           3 :         thisGSHP.CompClearanceFactor = NumArray(11);
     260           3 :         if (NumArray(11) == 0.0) {
     261           0 :             ShowSevereError(state, format("{}:Compressor Clearance Factor = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     262           0 :             ErrorsFound = true;
     263             :         }
     264             : 
     265           3 :         thisGSHP.CompSucPressDrop = NumArray(12);
     266           3 :         if (NumArray(12) == 0.0) {
     267           0 :             ShowSevereError(state, format("{}: Pressure Drop = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     268           0 :             ErrorsFound = true;
     269             :         }
     270             : 
     271           3 :         thisGSHP.SuperheatTemp = NumArray(13);
     272           3 :         if (NumArray(13) == 0.0) {
     273           0 :             ShowSevereError(state, format("{}:Source Side SuperHeat = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     274           0 :             ErrorsFound = true;
     275             :         }
     276             : 
     277           3 :         thisGSHP.PowerLosses = NumArray(14);
     278           3 :         if (NumArray(14) == 0.0) {
     279           0 :             ShowSevereError(state, format("{}:Compressor Power Loss = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     280           0 :             ErrorsFound = true;
     281             :         }
     282           3 :         thisGSHP.LossFactor = NumArray(15);
     283           3 :         if (NumArray(15) == 0.0) {
     284           0 :             ShowSevereError(state, format("{}:Efficiency = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     285           0 :             ErrorsFound = true;
     286             :         }
     287             : 
     288           3 :         thisGSHP.HighPressCutoff = NumArray(16);
     289           3 :         if (NumArray(16) == 0.0) {
     290           3 :             thisGSHP.HighPressCutoff = 500000000.0;
     291             :         }
     292             : 
     293           3 :         thisGSHP.LowPressCutoff = NumArray(17);
     294           3 :         if (NumArray(17) == 0.0) {
     295           3 :             thisGSHP.LowPressCutoff = 0.0;
     296             :         }
     297             : 
     298           3 :         thisGSHP.SourceSideInletNodeNum = GetOnlySingleNode(state,
     299           3 :                                                             AlphArray(2),
     300             :                                                             ErrorsFound,
     301             :                                                             DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     302           3 :                                                             thisGSHP.Name,
     303             :                                                             DataLoopNode::NodeFluidType::Water,
     304             :                                                             DataLoopNode::ConnectionType::Inlet,
     305             :                                                             NodeInputManager::CompFluidStream::Primary,
     306             :                                                             DataLoopNode::ObjectIsNotParent);
     307             : 
     308           3 :         thisGSHP.SourceSideOutletNodeNum = GetOnlySingleNode(state,
     309           3 :                                                              AlphArray(3),
     310             :                                                              ErrorsFound,
     311             :                                                              DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     312           3 :                                                              thisGSHP.Name,
     313             :                                                              DataLoopNode::NodeFluidType::Water,
     314             :                                                              DataLoopNode::ConnectionType::Outlet,
     315             :                                                              NodeInputManager::CompFluidStream::Primary,
     316             :                                                              DataLoopNode::ObjectIsNotParent);
     317             : 
     318           3 :         thisGSHP.LoadSideInletNodeNum = GetOnlySingleNode(state,
     319           3 :                                                           AlphArray(4),
     320             :                                                           ErrorsFound,
     321             :                                                           DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     322           3 :                                                           thisGSHP.Name,
     323             :                                                           DataLoopNode::NodeFluidType::Water,
     324             :                                                           DataLoopNode::ConnectionType::Inlet,
     325             :                                                           NodeInputManager::CompFluidStream::Secondary,
     326             :                                                           DataLoopNode::ObjectIsNotParent);
     327             : 
     328           3 :         thisGSHP.LoadSideOutletNodeNum = GetOnlySingleNode(state,
     329           3 :                                                            AlphArray(5),
     330             :                                                            ErrorsFound,
     331             :                                                            DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     332           3 :                                                            thisGSHP.Name,
     333             :                                                            DataLoopNode::NodeFluidType::Water,
     334             :                                                            DataLoopNode::ConnectionType::Outlet,
     335             :                                                            NodeInputManager::CompFluidStream::Secondary,
     336             :                                                            DataLoopNode::ObjectIsNotParent);
     337             : 
     338             :         // Test node sets
     339           3 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(2), AlphArray(3), "Condenser Water Nodes");
     340           3 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(4), AlphArray(5), "Chilled Water Nodes");
     341             : 
     342             :         // save the design source side flow rate for use by plant loop sizing algorithms
     343           3 :         PlantUtilities::RegisterPlantCompDesignFlow(state, thisGSHP.SourceSideInletNodeNum, 0.5 * thisGSHP.SourceSideVolFlowRate);
     344             : 
     345           3 :         thisGSHP.QLoad = 0.0;
     346           3 :         thisGSHP.QSource = 0.0;
     347           3 :         thisGSHP.Power = 0.0;
     348           3 :         thisGSHP.LoadSideWaterInletTemp = 0.0;
     349           3 :         thisGSHP.SourceSideWaterInletTemp = 0.0;
     350           3 :         thisGSHP.LoadSideWaterOutletTemp = 0.0;
     351           3 :         thisGSHP.SourceSideWaterOutletTemp = 0.0;
     352           3 :         thisGSHP.SourceSideWaterMassFlowRate = 0.0;
     353           3 :         thisGSHP.LoadSideWaterMassFlowRate = 0.0;
     354           3 :         thisGSHP.IsOn = false;
     355           3 :         thisGSHP.MustRun = true;
     356             :     }
     357             : 
     358           3 :     if (ErrorsFound) {
     359           0 :         ShowFatalError(state, "Errors Found in getting Gshp input");
     360             :     }
     361             : 
     362           3 :     state.dataHPWaterToWaterClg->GSHPRefrigIndex = FluidProperties::GetRefrigNum(state, GSHPRefrigerant);
     363           3 :     if (state.dataHPWaterToWaterClg->GSHPRefrigIndex == 0) {
     364           0 :         ShowFatalError(state, format("Refrigerant for {} not found, should have been={}", ModuleCompName, GSHPRefrigerant));
     365           0 :         ShowFatalError(state, format("FluidProperties:* objects for {} must be included in the idf file.", GSHPRefrigerant));
     366             :     }
     367             : 
     368             :     // CurrentModuleObject='HeatPump:WaterToWater:ParameterEstimation:Cooling'
     369           6 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     370           3 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     371           6 :         SetupOutputVariable(state,
     372             :                             "Heat Pump Electricity Rate",
     373             :                             Constant::Units::W,
     374           3 :                             thisGSHP.Power,
     375             :                             OutputProcessor::TimeStepType::System,
     376             :                             OutputProcessor::StoreType::Average,
     377           3 :                             thisGSHP.Name);
     378           6 :         SetupOutputVariable(state,
     379             :                             "Heat Pump Electricity Energy",
     380             :                             Constant::Units::J,
     381           3 :                             thisGSHP.Energy,
     382             :                             OutputProcessor::TimeStepType::System,
     383             :                             OutputProcessor::StoreType::Sum,
     384           3 :                             thisGSHP.Name,
     385             :                             Constant::eResource::Electricity,
     386             :                             OutputProcessor::Group::Plant,
     387             :                             OutputProcessor::EndUseCat::Cooling);
     388             : 
     389           6 :         SetupOutputVariable(state,
     390             :                             "Heat Pump Load Side Heat Transfer Rate",
     391             :                             Constant::Units::W,
     392           3 :                             thisGSHP.QLoad,
     393             :                             OutputProcessor::TimeStepType::System,
     394             :                             OutputProcessor::StoreType::Average,
     395           3 :                             thisGSHP.Name);
     396           6 :         SetupOutputVariable(state,
     397             :                             "Heat Pump Load Side Heat Transfer Energy",
     398             :                             Constant::Units::J,
     399           3 :                             thisGSHP.QLoadEnergy,
     400             :                             OutputProcessor::TimeStepType::System,
     401             :                             OutputProcessor::StoreType::Sum,
     402           3 :                             thisGSHP.Name);
     403             : 
     404           6 :         SetupOutputVariable(state,
     405             :                             "Heat Pump Source Side Heat Transfer Rate",
     406             :                             Constant::Units::W,
     407           3 :                             thisGSHP.QSource,
     408             :                             OutputProcessor::TimeStepType::System,
     409             :                             OutputProcessor::StoreType::Average,
     410           3 :                             thisGSHP.Name);
     411           6 :         SetupOutputVariable(state,
     412             :                             "Heat Pump Source Side Heat Transfer Energy",
     413             :                             Constant::Units::J,
     414           3 :                             thisGSHP.QSourceEnergy,
     415             :                             OutputProcessor::TimeStepType::System,
     416             :                             OutputProcessor::StoreType::Sum,
     417           3 :                             thisGSHP.Name);
     418             : 
     419           6 :         SetupOutputVariable(state,
     420             :                             "Heat Pump Load Side Outlet Temperature",
     421             :                             Constant::Units::C,
     422           3 :                             thisGSHP.LoadSideWaterOutletTemp,
     423             :                             OutputProcessor::TimeStepType::System,
     424             :                             OutputProcessor::StoreType::Average,
     425           3 :                             thisGSHP.Name);
     426           6 :         SetupOutputVariable(state,
     427             :                             "Heat Pump Load Side Inlet Temperature",
     428             :                             Constant::Units::C,
     429           3 :                             thisGSHP.LoadSideWaterInletTemp,
     430             :                             OutputProcessor::TimeStepType::System,
     431             :                             OutputProcessor::StoreType::Average,
     432           3 :                             thisGSHP.Name);
     433           6 :         SetupOutputVariable(state,
     434             :                             "Heat Pump Source Side Outlet Temperature",
     435             :                             Constant::Units::C,
     436           3 :                             thisGSHP.SourceSideWaterOutletTemp,
     437             :                             OutputProcessor::TimeStepType::System,
     438             :                             OutputProcessor::StoreType::Average,
     439           3 :                             thisGSHP.Name);
     440           6 :         SetupOutputVariable(state,
     441             :                             "Heat Pump Source Side Inlet Temperature",
     442             :                             Constant::Units::C,
     443           3 :                             thisGSHP.SourceSideWaterInletTemp,
     444             :                             OutputProcessor::TimeStepType::System,
     445             :                             OutputProcessor::StoreType::Average,
     446           3 :                             thisGSHP.Name);
     447           6 :         SetupOutputVariable(state,
     448             :                             "Heat Pump Load Side Mass Flow Rate",
     449             :                             Constant::Units::kg_s,
     450           3 :                             thisGSHP.LoadSideWaterMassFlowRate,
     451             :                             OutputProcessor::TimeStepType::System,
     452             :                             OutputProcessor::StoreType::Average,
     453           3 :                             thisGSHP.Name);
     454           6 :         SetupOutputVariable(state,
     455             :                             "Heat Pump Source Side Mass Flow Rate",
     456             :                             Constant::Units::kg_s,
     457           3 :                             thisGSHP.SourceSideWaterMassFlowRate,
     458             :                             OutputProcessor::TimeStepType::System,
     459             :                             OutputProcessor::StoreType::Average,
     460           3 :                             thisGSHP.Name);
     461             :     }
     462           3 : }
     463             : 
     464       46511 : void GshpPeCoolingSpecs::initialize(EnergyPlusData &state)
     465             : {
     466             : 
     467             :     // SUBROUTINE INFORMATION:
     468             :     //       AUTHOR:          Dan Fisher
     469             :     //       DATE WRITTEN:    July 2007
     470             : 
     471             :     // SUBROUTINE PARAMETER DEFINITIONS:
     472             :     static constexpr std::string_view RoutineName("InitGshp");
     473             : 
     474             :     // For each new environment
     475       46511 :     if (state.dataGlobal->BeginEnvrnFlag && this->beginEnvironFlag) {
     476          18 :         this->QLoad = 0.0;
     477          18 :         this->QSource = 0.0;
     478          18 :         this->Power = 0.0;
     479          18 :         this->QLoadEnergy = 0.0;
     480          18 :         this->QSourceEnergy = 0.0;
     481          18 :         this->Energy = 0.0;
     482          18 :         this->LoadSideWaterInletTemp = 0.0;
     483          18 :         this->SourceSideWaterInletTemp = 0.0;
     484          18 :         this->LoadSideWaterOutletTemp = 0.0;
     485          18 :         this->SourceSideWaterOutletTemp = 0.0;
     486          18 :         this->SourceSideWaterMassFlowRate = 0.0;
     487          18 :         this->LoadSideWaterMassFlowRate = 0.0;
     488          18 :         this->IsOn = false;
     489          18 :         this->MustRun = true;
     490             : 
     491          18 :         this->beginEnvironFlag = false;
     492          18 :         Real64 rho = FluidProperties::GetDensityGlycol(state,
     493          18 :                                                        state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidName,
     494             :                                                        Constant::CWInitConvTemp,
     495          18 :                                                        state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidIndex,
     496             :                                                        RoutineName);
     497          18 :         this->LoadSideDesignMassFlow = this->LoadSideVolFlowRate * rho;
     498             : 
     499          18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->LoadSideDesignMassFlow, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum);
     500             : 
     501          18 :         rho = FluidProperties::GetDensityGlycol(state,
     502          18 :                                                 state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
     503             :                                                 Constant::CWInitConvTemp,
     504          18 :                                                 state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
     505             :                                                 RoutineName);
     506          18 :         this->SourceSideDesignMassFlow = this->SourceSideVolFlowRate * rho;
     507             : 
     508          18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->SourceSideDesignMassFlow, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum);
     509             : 
     510          18 :         state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp = 35.0;
     511             :     }
     512             : 
     513       46511 :     if (!state.dataGlobal->BeginEnvrnFlag) this->beginEnvironFlag = true;
     514             : 
     515             :     // Init more variables
     516             : 
     517             :     // On every call
     518       46511 :     this->Running = 0;
     519             : 
     520       46511 :     this->MustRun = true; // Reset MustRun Flag to TRUE
     521             : 
     522       46511 :     this->LoadSideWaterMassFlowRate = 0.0;   // Load Side mass flow rate, water side
     523       46511 :     this->SourceSideWaterMassFlowRate = 0.0; // Source Side mass flow rate, water side
     524       46511 :     this->Power = 0.0;                       // power consumption
     525       46511 :     this->QLoad = 0.0;                       // heat rejection from Load Side coil
     526       46511 :     this->QSource = 0.0;
     527       46511 : }
     528             : 
     529       46511 : void GshpPeCoolingSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad)
     530             : {
     531             :     // SUBROUTINE INFORMATION:
     532             :     //       DATE WRITTEN   Sept. 1998
     533             :     //       MODIFIED       April 1999
     534             :     //                      September 2002, SJR
     535             :     //       RE-ENGINEERED  Mar2000
     536             : 
     537             :     // SUBROUTINE PARAMETER DEFINITIONS:
     538       46511 :     Real64 constexpr gamma(1.114); // Expnasion Coefficient
     539       46511 :     Real64 constexpr HeatBalTol(0.0005);
     540       46511 :     Real64 constexpr RelaxParam(0.6);
     541       46511 :     Real64 constexpr SmallNum(1.0e-20);
     542       46511 :     int constexpr IterationLimit(500);
     543             :     static constexpr std::string_view RoutineName("CalcGshpModel");
     544             :     static constexpr std::string_view RoutineNameLoadSideRefridgTemp("CalcGSHPModel:LoadSideRefridgTemp");
     545             :     static constexpr std::string_view RoutineNameSourceSideRefridgTemp("CalcGSHPModel:SourceSideRefridgTemp");
     546             :     static constexpr std::string_view RoutineNameCompressInletTemp("CalcGSHPModel:CompressInletTemp");
     547             :     static constexpr std::string_view RoutineNameSuctionPr("CalcGSHPModel:SuctionPr");
     548             :     static constexpr std::string_view RoutineNameCompSuctionTemp("CalcGSHPModel:CompSuctionTemp");
     549             : 
     550             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     551             :     Real64 SourceSideEffect;      // Source Side effectiveness
     552             :     Real64 LoadSideEffect;        // Load Side effectiveness
     553             :     Real64 SourceSideRefridgTemp; // Source Side temperature
     554             :     Real64 LoadSideRefridgTemp;   // Load Side temperature
     555             :     Real64 SourceSidePressure;    // Source Side pressure
     556             :     Real64 LoadSidePressure;      // Load Side pressure
     557             :     Real64 SuctionPr;             // Suction Pressure
     558             :     Real64 DischargePr;           // Discharge Pressure
     559             :     Real64 CompressInletTemp;     // Compressor inlet temperature
     560             :     Real64 MassRef;               // mass flow rate of refrigerant
     561             :     Real64 SourceSideOutletEnth;  // Enthalpy at Source Side pressure
     562             :     Real64 LoadSideOutletEnth;    // Enthalpy at Condenser Pressure
     563             :     Real64 initialQSource;        // Guess Source Side Heat rate
     564             :     Real64 initialQLoad;          // Guess Load Side Heat rate
     565             :     Real64 qual;                  // quality
     566             :     Real64 SuperHeatEnth;
     567             :     Real64 T110;
     568             :     Real64 T111;
     569             :     Real64 CompSuctionTemp;
     570             :     Real64 CompSuctionEnth;
     571             :     Real64 CompSuctionDensity;
     572             :     Real64 CompSuctionSatTemp;
     573             :     Real64 DutyFactor;
     574             :     int IterationCount;
     575             : 
     576             :     Real64 CpSourceSide; // local temporary for fluid specific heat
     577             :     Real64 CpLoadSide;   // local temporary for fluid specific heat
     578             : 
     579       46511 :     if (MyLoad < 0.0) {
     580       35242 :         this->MustRun = true;
     581       35242 :         this->IsOn = true;
     582             :     } else {
     583       11269 :         this->MustRun = false;
     584       11269 :         this->IsOn = false;
     585             :     }
     586             : 
     587             :     //*******Set flow based on "flowlock" and "run" flags**********
     588             :     // Set flows if the heat pump is not running
     589       46511 :     if (!this->MustRun) {
     590       11269 :         this->LoadSideWaterMassFlowRate = 0.0;
     591       11269 :         PlantUtilities::SetComponentFlowRate(
     592       11269 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     593       11269 :         this->SourceSideWaterMassFlowRate = 0.0;
     594       11269 :         PlantUtilities::SetComponentFlowRate(
     595       11269 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     596       11269 :         PlantUtilities::PullCompInterconnectTrigger(state,
     597       11269 :                                                     this->LoadPlantLoc,
     598       11269 :                                                     this->CondMassFlowIndex,
     599       11269 :                                                     this->SourcePlantLoc,
     600             :                                                     DataPlant::CriteriaType::MassFlowRate,
     601             :                                                     this->SourceSideWaterMassFlowRate);
     602             :         // now initialize simulation variables for "heat pump off"
     603       11269 :         this->QLoad = 0.0;
     604       11269 :         this->QSource = 0.0;
     605       11269 :         this->Power = 0.0;
     606       11269 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     607       11269 :         this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     608       11269 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     609       11269 :         this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     610       46511 :         return; // if heat pump is not running return without simulation
     611             : 
     612             :         // Set flows if the heat pump is running
     613             :     } else { // the heat pump must run
     614       35242 :         this->LoadSideWaterMassFlowRate = this->LoadSideDesignMassFlow;
     615       35242 :         PlantUtilities::SetComponentFlowRate(
     616       35242 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     617             : 
     618       35242 :         this->SourceSideWaterMassFlowRate = this->SourceSideDesignMassFlow;
     619       35242 :         PlantUtilities::SetComponentFlowRate(
     620       35242 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     621             :         // get inlet temps
     622       35242 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     623       35242 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     624             :         // if there's no flow, turn the "heat pump off"
     625       35242 :         if (this->LoadSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance ||
     626       35235 :             this->SourceSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance) {
     627          14 :             this->LoadSideWaterMassFlowRate = 0.0;
     628          14 :             PlantUtilities::SetComponentFlowRate(
     629          14 :                 state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     630          14 :             this->SourceSideWaterMassFlowRate = 0.0;
     631          14 :             PlantUtilities::SetComponentFlowRate(
     632          14 :                 state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     633          14 :             PlantUtilities::PullCompInterconnectTrigger(state,
     634          14 :                                                         this->LoadPlantLoc,
     635          14 :                                                         this->CondMassFlowIndex,
     636          14 :                                                         this->SourcePlantLoc,
     637             :                                                         DataPlant::CriteriaType::MassFlowRate,
     638             :                                                         this->SourceSideWaterMassFlowRate);
     639          14 :             this->QLoad = 0.0;
     640          14 :             this->QSource = 0.0;
     641          14 :             this->Power = 0.0;
     642          14 :             this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     643          14 :             this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     644          14 :             this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     645          14 :             this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     646          14 :             return;
     647             :         }
     648       35228 :         PlantUtilities::PullCompInterconnectTrigger(state,
     649       35228 :                                                     this->LoadPlantLoc,
     650       35228 :                                                     this->CondMassFlowIndex,
     651       35228 :                                                     this->SourcePlantLoc,
     652             :                                                     DataPlant::CriteriaType::MassFlowRate,
     653             :                                                     this->SourceSideWaterMassFlowRate);
     654             :     }
     655             : 
     656             :     //**********BEGIN THE CALCULATION**************
     657             : 
     658             :     // initialize the source and load side heat transfer rates for the simulation
     659       35228 :     initialQSource = 0.0;
     660       35228 :     initialQLoad = 0.0;
     661       35228 :     IterationCount = 0;
     662             : 
     663       35228 :     CpSourceSide = FluidProperties::GetSpecificHeatGlycol(state,
     664       35228 :                                                           state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
     665             :                                                           this->SourceSideWaterInletTemp,
     666       35228 :                                                           state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
     667             :                                                           RoutineName);
     668             : 
     669       35228 :     CpLoadSide = FluidProperties::GetSpecificHeatGlycol(state,
     670       35228 :                                                         state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidName,
     671             :                                                         this->LoadSideWaterInletTemp,
     672       35228 :                                                         state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidIndex,
     673             :                                                         RoutineName);
     674             : 
     675             :     // Determine effectiveness of Load Side
     676       35228 :     LoadSideEffect = 1.0 - std::exp(-this->LoadSideUACoeff / (CpLoadSide * this->LoadSideWaterMassFlowRate));
     677             :     // Determine effectiveness of Source Side
     678       35228 :     SourceSideEffect = 1.0 - std::exp(-this->SourceSideUACoeff / (CpSourceSide * this->SourceSideWaterMassFlowRate));
     679             : 
     680             :     // main iteration loop to solve model equations
     681             :     while (true) {
     682      317108 :         ++IterationCount;
     683             : 
     684             :         // To determine Load Side temperature
     685      317108 :         LoadSideRefridgTemp = this->LoadSideWaterInletTemp - initialQLoad / (LoadSideEffect * CpLoadSide * this->LoadSideWaterMassFlowRate);
     686             : 
     687             :         // Determine Source Side tempertaure
     688      317108 :         SourceSideRefridgTemp =
     689      317108 :             this->SourceSideWaterInletTemp + initialQSource / (SourceSideEffect * CpSourceSide * this->SourceSideWaterMassFlowRate);
     690             : 
     691             :         // Determine the evaporating and condensing pressures
     692      317108 :         SourceSidePressure = FluidProperties::GetSatPressureRefrig(
     693      317108 :             state, GSHPRefrigerant, SourceSideRefridgTemp, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineName);
     694      317108 :         LoadSidePressure = FluidProperties::GetSatPressureRefrig(
     695      317108 :             state, GSHPRefrigerant, LoadSideRefridgTemp, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineName);
     696             : 
     697      317108 :         if (SourceSidePressure < this->LowPressCutoff) {
     698           0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Source Side Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     699           0 :             ShowContinueError(state,
     700           0 :                               format("Cooling Source Side Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}",
     701             :                                      SourceSidePressure,
     702           0 :                                      this->LowPressCutoff));
     703           0 :             ShowContinueErrorTimeStamp(state, "");
     704           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     705             :         }
     706             : 
     707      317108 :         if (LoadSidePressure > this->HighPressCutoff) {
     708           0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Load Side Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     709           0 :             ShowContinueError(state,
     710           0 :                               format("Cooling Load Side Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}",
     711             :                                      LoadSidePressure,
     712           0 :                                      this->HighPressCutoff));
     713           0 :             ShowContinueErrorTimeStamp(state, "");
     714           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     715             :         }
     716             :         // Determine Suction Pressure at compressor inlet
     717      317108 :         SuctionPr = LoadSidePressure - this->CompSucPressDrop;
     718             :         // Determine Discharge Pressure at compressor exit
     719      317108 :         DischargePr = SourceSidePressure + this->CompSucPressDrop;
     720             : 
     721      317108 :         if (SuctionPr < this->LowPressCutoff) {
     722           0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Suction Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     723           0 :             ShowContinueError(
     724           0 :                 state, format("Cooling Suction Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}", SuctionPr, this->LowPressCutoff));
     725           0 :             ShowContinueErrorTimeStamp(state, "");
     726           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     727             :         }
     728             : 
     729      317108 :         if (DischargePr > this->HighPressCutoff) {
     730           0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Discharge Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     731           0 :             ShowContinueError(
     732             :                 state,
     733           0 :                 format("Cooling Discharge Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}", DischargePr, this->HighPressCutoff));
     734           0 :             ShowContinueErrorTimeStamp(state, "");
     735           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     736             :         }
     737             : 
     738             :         // Determine the Source Side Outlet Enthalpy
     739             : 
     740      317108 :         qual = 1.0;
     741      317108 :         LoadSideOutletEnth = FluidProperties::GetSatEnthalpyRefrig(
     742      317108 :             state, GSHPRefrigerant, LoadSideRefridgTemp, qual, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameLoadSideRefridgTemp);
     743             : 
     744      317108 :         qual = 0.0;
     745      317108 :         SourceSideOutletEnth = FluidProperties::GetSatEnthalpyRefrig(
     746      317108 :             state, GSHPRefrigerant, SourceSideRefridgTemp, qual, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameSourceSideRefridgTemp);
     747             : 
     748             :         // Determine Load Side Outlet Enthalpy
     749             :         // Determine superheated temperature of the LoadSide outlet/compressor inlet
     750      317108 :         CompressInletTemp = LoadSideRefridgTemp + this->SuperheatTemp;
     751             : 
     752             :         // Determine the enathalpy of the super heated fluid at Source Side outlet
     753      317108 :         SuperHeatEnth = FluidProperties::GetSupHeatEnthalpyRefrig(
     754      317108 :             state, GSHPRefrigerant, CompressInletTemp, LoadSidePressure, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameCompressInletTemp);
     755             : 
     756             :         // Determining the suction state of the fluid from inlet state involves interation
     757             :         // Method employed...
     758             :         // Determine the saturated temp at suction pressure, shoot out into the superheated region find the enthalpy
     759             :         // check that with the inlet enthalpy ( as suction loss is isenthalpic). Iterate till desired accuracy is reached
     760             : 
     761             :         // this routine was reenginerred from HVACsim + takes pressure in Pascals, tolrance, refrgerant # R22 =6
     762      317108 :         CompSuctionSatTemp = FluidProperties::GetSatTemperatureRefrig(
     763      317108 :             state, GSHPRefrigerant, SuctionPr, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameSuctionPr);
     764             : 
     765      317108 :         T110 = CompSuctionSatTemp;
     766             :         //            Shoot into the super heated region
     767      317108 :         T111 = CompSuctionSatTemp + 100.0;
     768             :         // Iterate to find the Suction State
     769             :         while (true) {
     770     2789264 :             CompSuctionTemp = 0.5 * (T110 + T111);
     771             : 
     772     2789264 :             CompSuctionEnth = FluidProperties::GetSupHeatEnthalpyRefrig(
     773     2789264 :                 state, GSHPRefrigerant, CompSuctionTemp, SuctionPr, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameCompSuctionTemp);
     774             : 
     775     2789264 :             if (std::abs(CompSuctionEnth - SuperHeatEnth) / SuperHeatEnth < 0.0001) {
     776      317108 :                 goto LOOP_exit;
     777             :             }
     778             : 
     779     2472156 :             if (CompSuctionEnth < SuperHeatEnth) {
     780      729406 :                 T110 = CompSuctionTemp;
     781             :             } else {
     782     1742750 :                 T111 = CompSuctionTemp;
     783             :             }
     784             :         }
     785      317108 :     LOOP_exit:;
     786             : 
     787             :         // Determine the Mass flow rate of refrigerant
     788      317108 :         CompSuctionDensity = FluidProperties::GetSupHeatDensityRefrig(
     789      317108 :             state, GSHPRefrigerant, CompSuctionTemp, SuctionPr, state.dataHPWaterToWaterClg->GSHPRefrigIndex, RoutineNameCompSuctionTemp);
     790      317108 :         MassRef = this->CompPistonDisp * CompSuctionDensity *
     791      317108 :                   (1 + this->CompClearanceFactor - this->CompClearanceFactor * std::pow(DischargePr / SuctionPr, 1 / gamma));
     792             : 
     793             :         // Find the Source Side Heat Transfer
     794             : 
     795      317108 :         this->QLoad = MassRef * (LoadSideOutletEnth - SourceSideOutletEnth);
     796             : 
     797             :         // Determine the theoretical power
     798      317108 :         this->Power = this->PowerLosses + (MassRef * gamma / (gamma - 1) * SuctionPr / CompSuctionDensity / this->LossFactor *
     799      317108 :                                            (std::pow(DischargePr / SuctionPr, (gamma - 1) / gamma) - 1));
     800             : 
     801             :         // Determine the Loadside HeatRate (this->QLoad)
     802      317108 :         this->QSource = this->Power + this->QLoad;
     803             :         // convergence and iteration limit check
     804      317108 :         if (std::abs((this->QSource - initialQSource) / (initialQSource + SmallNum)) < HeatBalTol || IterationCount > IterationLimit) {
     805       35228 :             if (IterationCount > IterationLimit) {
     806           0 :                 ShowWarningError(state, "HeatPump:WaterToWater:ParameterEstimation, Cooling did not converge");
     807           0 :                 ShowContinueErrorTimeStamp(state, "");
     808           0 :                 ShowContinueError(state, format("Heatpump Name = {}", this->Name));
     809           0 :                 ShowContinueError(
     810             :                     state,
     811           0 :                     format("Heat Inbalance (%)             = {}", std::abs(100.0 * (this->QSource - initialQSource) / (initialQSource + SmallNum))));
     812           0 :                 ShowContinueError(state, format("Load-side heat transfer rate   = {}", this->QLoad));
     813           0 :                 ShowContinueError(state, format("Source-side heat transfer rate = {}", this->QSource));
     814           0 :                 ShowContinueError(state, format("Source-side mass flow rate     = {}", this->SourceSideWaterMassFlowRate));
     815           0 :                 ShowContinueError(state, format("Load-side mass flow rate       = {}", this->LoadSideWaterMassFlowRate));
     816           0 :                 ShowContinueError(state, format("Source-side inlet temperature  = {}", this->SourceSideWaterInletTemp));
     817           0 :                 ShowContinueError(state, format("Load-side inlet temperature    = {}", this->LoadSideWaterInletTemp));
     818             :             }
     819       35228 :             goto LOOPSourceEnth_exit;
     820             : 
     821             :         } else { // update load
     822      281880 :             initialQSource += RelaxParam * (this->QSource - initialQSource);
     823      281880 :             initialQLoad += RelaxParam * (this->QLoad - initialQLoad);
     824             :         }
     825             :     }
     826       35228 : LOOPSourceEnth_exit:;
     827             : 
     828             :     // Control Strategy
     829       35228 :     if (std::abs(MyLoad) < this->QLoad) {
     830       35228 :         DutyFactor = std::abs(MyLoad) / this->QLoad;
     831       35228 :         this->QLoad = std::abs(MyLoad);
     832       35228 :         this->Power *= DutyFactor;
     833       35228 :         this->QSource *= DutyFactor;
     834             :         // Determine the Exterior fluid temperature at the Load Side oulet and evaporator outlet...
     835       35228 :         this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp - this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide); // Chilled water
     836       35228 :         this->SourceSideWaterOutletTemp =
     837       35228 :             this->SourceSideWaterInletTemp + this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide); // cooling water
     838       35228 :         return;
     839             :     }
     840             : 
     841           0 :     this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp - this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide); // Chilled water
     842           0 :     this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp + this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide);
     843           0 :     this->Running = 1;
     844             : }
     845             : 
     846       46511 : void GshpPeCoolingSpecs::update(EnergyPlusData &state)
     847             : {
     848             :     // SUBROUTINE INFORMATION:
     849             :     //       AUTHOR:          Dan Fisher
     850             :     //       DATE WRITTEN:    October 1998
     851             : 
     852       46511 :     if (!this->MustRun) {
     853             :         // set node temperatures
     854       11269 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     855       11269 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     856       11269 :         this->Power = 0.0;
     857       11269 :         this->Energy = 0.0;
     858       11269 :         this->QSource = 0.0;
     859       11269 :         this->QLoad = 0.0;
     860       11269 :         this->QSourceEnergy = 0.0;
     861       11269 :         this->QLoadEnergy = 0.0;
     862       11269 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     863       11269 :         this->SourceSideWaterOutletTemp = state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp;
     864       11269 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     865       11269 :         this->LoadSideWaterOutletTemp = state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp;
     866             : 
     867             :     } else {
     868             :         // set node temperatures
     869       35242 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = this->LoadSideWaterOutletTemp;
     870       35242 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = this->SourceSideWaterOutletTemp;
     871             : 
     872             :         // set node flow rates;  for these load based models
     873             :         // assume that the sufficient Source Side flow rate available
     874             : 
     875       35242 :         Real64 const ReportingConstant = state.dataHVACGlobal->TimeStepSysSec;
     876             : 
     877       35242 :         this->Energy = this->Power * ReportingConstant;
     878       35242 :         this->QSourceEnergy = QSource * ReportingConstant;
     879       35242 :         this->QLoadEnergy = QLoad * ReportingConstant;
     880       35242 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     881       35242 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     882             :     }
     883       46511 : }
     884           0 : void GshpPeCoolingSpecs::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     885             : {
     886           0 : }
     887           3 : void GshpPeCoolingSpecs::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     888             : {
     889           3 : }
     890             : 
     891             : } // namespace EnergyPlus::HeatPumpWaterToWaterCOOLING

Generated by: LCOV version 1.14