LCOV - code coverage report
Current view: top level - EnergyPlus - HeatPumpWaterToWaterCOOLING.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 0.0 % 390 0
Test Date: 2025-05-22 16:09:37 Functions: 0.0 % 11 0

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // C++ Headers
      49              : #include <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            0 : GshpPeCoolingSpecs *GshpPeCoolingSpecs::factory(EnergyPlusData &state, const std::string &objectName)
      95              : {
      96            0 :     if (state.dataHPWaterToWaterClg->GetWWHPCoolingInput) {
      97            0 :         GetGshpInput(state);
      98            0 :         state.dataHPWaterToWaterClg->GetWWHPCoolingInput = false;
      99              :     }
     100            0 :     auto thisObj = std::find_if(state.dataHPWaterToWaterClg->GSHP.begin(),
     101            0 :                                 state.dataHPWaterToWaterClg->GSHP.end(),
     102            0 :                                 [&objectName](const GshpPeCoolingSpecs &myObj) { return myObj.Name == objectName; });
     103            0 :     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            0 : 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            0 :     if (calledFromLocation.loopNum == this->LoadPlantLoc.loopNum) { // chilled water loop
     115            0 :         this->initialize(state);
     116            0 :         this->calculate(state, CurLoad);
     117            0 :         this->update(state);
     118            0 :     } else if (calledFromLocation.loopNum == this->SourcePlantLoc.loopNum) { // condenser loop
     119            0 :         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            0 : }
     134              : 
     135            0 : void GshpPeCoolingSpecs::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     136              :                                              [[maybe_unused]] const PlantLocation &calledFromLocation,
     137              :                                              Real64 &MaxLoad,
     138              :                                              Real64 &MinLoad,
     139              :                                              Real64 &OptLoad)
     140              : {
     141            0 :     MinLoad = this->NomCap * this->MinPartLoadRat;
     142            0 :     MaxLoad = this->NomCap * this->MaxPartLoadRat;
     143            0 :     OptLoad = this->NomCap * this->OptPartLoadRat;
     144            0 : }
     145              : 
     146            0 : void GshpPeCoolingSpecs::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
     147              : {
     148            0 :     if (this->plantScanFlag) {
     149              :         // Locate the heating on the plant loops for later usage
     150            0 :         bool errFlag = false;
     151            0 :         PlantUtilities::ScanPlantLoopsForObject(state,
     152              :                                                 this->Name,
     153              :                                                 DataPlant::PlantEquipmentType::HPWaterPECooling,
     154            0 :                                                 this->SourcePlantLoc,
     155              :                                                 errFlag,
     156              :                                                 _,
     157              :                                                 _,
     158              :                                                 _,
     159            0 :                                                 this->SourceSideInletNodeNum,
     160              :                                                 _);
     161            0 :         PlantUtilities::ScanPlantLoopsForObject(
     162            0 :             state, this->Name, DataPlant::PlantEquipmentType::HPWaterPECooling, this->LoadPlantLoc, errFlag, _, _, _, this->LoadSideInletNodeNum, _);
     163            0 :         if (errFlag) {
     164            0 :             ShowFatalError(state, "InitGshp: Program terminated due to previous condition(s).");
     165              :         }
     166              : 
     167            0 :         PlantUtilities::InterConnectTwoPlantLoopSides(state, this->LoadPlantLoc, this->SourcePlantLoc, this->WWHPPlantTypeOfNum, true);
     168            0 :         this->plantScanFlag = false;
     169              :     }
     170            0 : }
     171              : 
     172            0 : 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              :     static constexpr std::string_view routineName = "GetGshpInput";
     185              : 
     186              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     187              :     int GSHPNum;                  // Gshp counter
     188              :     int NumAlphas;                // Number of elements in the alpha array
     189              :     int NumNums;                  // Number of elements in the numeric array
     190              :     int IOStat;                   // IO Status when calling get input subroutine
     191            0 :     Array1D_string AlphArray(5);  // character string data
     192            0 :     Array1D<Real64> NumArray(23); // numeric data
     193              : 
     194            0 :     bool ErrorsFound(false);
     195              : 
     196            0 :     state.dataHPWaterToWaterClg->NumGSHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ModuleCompNameUC);
     197              : 
     198            0 :     if (state.dataHPWaterToWaterClg->NumGSHPs <= 0) {
     199            0 :         ShowSevereError(state, "No Equipment found in SimGshp");
     200            0 :         ErrorsFound = true;
     201              :     }
     202              : 
     203              :     // Allocate Arrays
     204            0 :     state.dataHPWaterToWaterClg->GSHP.allocate(state.dataHPWaterToWaterClg->NumGSHPs);
     205              : 
     206            0 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     207            0 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     208            0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, ModuleCompNameUC, GSHPNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     209              : 
     210            0 :         ErrorObjectHeader eoh{routineName, ModuleCompNameUC, AlphArray(1)};
     211              : 
     212            0 :         thisGSHP.Name = AlphArray(1);
     213              : 
     214            0 :         thisGSHP.WWHPPlantTypeOfNum = DataPlant::PlantEquipmentType::HPWaterPECooling;
     215              : 
     216            0 :         thisGSHP.COP = NumArray(1);
     217            0 :         if (NumArray(1) == 0.0) {
     218            0 :             ShowSevereError(state, format("{}:COP = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     219            0 :             ErrorsFound = true;
     220              :         }
     221              : 
     222              :         // zero values for NumArray 0 - 6 checked in input - idd
     223              : 
     224            0 :         thisGSHP.NomCap = NumArray(2);
     225              : 
     226            0 :         thisGSHP.MinPartLoadRat = NumArray(3);
     227              : 
     228            0 :         thisGSHP.MaxPartLoadRat = NumArray(4);
     229              : 
     230            0 :         thisGSHP.OptPartLoadRat = NumArray(5);
     231              : 
     232            0 :         thisGSHP.LoadSideVolFlowRate = NumArray(6);
     233            0 :         if (NumArray(6) == 0.0) {
     234            0 :             ShowSevereError(state, format("{}:Load Side Vol Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     235            0 :             ErrorsFound = true;
     236              :         }
     237              : 
     238            0 :         thisGSHP.SourceSideVolFlowRate = NumArray(7);
     239            0 :         if (NumArray(7) == 0.0) {
     240            0 :             ShowSevereError(state, format("{}:Source Side Vol Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     241            0 :             ErrorsFound = true;
     242              :         }
     243              : 
     244            0 :         thisGSHP.LoadSideUACoeff = NumArray(8);
     245            0 :         if (NumArray(9) == 0.0) {
     246            0 :             ShowSevereError(state, format("{}:Load Side Heat Transfer Coefficient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     247            0 :             ErrorsFound = true;
     248              :         }
     249              : 
     250            0 :         thisGSHP.SourceSideUACoeff = NumArray(9);
     251            0 :         if (NumArray(8) == 0.0) {
     252            0 :             ShowSevereError(state, format("{}:Source Side Heat Transfer Coefficient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     253            0 :             ErrorsFound = true;
     254              :         }
     255              : 
     256            0 :         thisGSHP.CompPistonDisp = NumArray(10);
     257            0 :         if (NumArray(10) == 0.0) {
     258            0 :             ShowSevereError(state, format("{}:Compressor Piston displacement/Stroke = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     259            0 :             ErrorsFound = true;
     260              :         }
     261              : 
     262            0 :         thisGSHP.CompClearanceFactor = NumArray(11);
     263            0 :         if (NumArray(11) == 0.0) {
     264            0 :             ShowSevereError(state, format("{}:Compressor Clearance Factor = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     265            0 :             ErrorsFound = true;
     266              :         }
     267              : 
     268            0 :         thisGSHP.CompSucPressDrop = NumArray(12);
     269            0 :         if (NumArray(12) == 0.0) {
     270            0 :             ShowSevereError(state, format("{}: Pressure Drop = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     271            0 :             ErrorsFound = true;
     272              :         }
     273              : 
     274            0 :         thisGSHP.SuperheatTemp = NumArray(13);
     275            0 :         if (NumArray(13) == 0.0) {
     276            0 :             ShowSevereError(state, format("{}:Source Side SuperHeat = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     277            0 :             ErrorsFound = true;
     278              :         }
     279              : 
     280            0 :         thisGSHP.PowerLosses = NumArray(14);
     281            0 :         if (NumArray(14) == 0.0) {
     282            0 :             ShowSevereError(state, format("{}:Compressor Power Loss = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     283            0 :             ErrorsFound = true;
     284              :         }
     285            0 :         thisGSHP.LossFactor = NumArray(15);
     286            0 :         if (NumArray(15) == 0.0) {
     287            0 :             ShowSevereError(state, format("{}:Efficiency = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     288            0 :             ErrorsFound = true;
     289              :         }
     290              : 
     291            0 :         thisGSHP.HighPressCutoff = NumArray(16);
     292            0 :         if (NumArray(16) == 0.0) {
     293            0 :             thisGSHP.HighPressCutoff = 500000000.0;
     294              :         }
     295              : 
     296            0 :         thisGSHP.LowPressCutoff = NumArray(17);
     297            0 :         if (NumArray(17) == 0.0) {
     298            0 :             thisGSHP.LowPressCutoff = 0.0;
     299              :         }
     300              : 
     301            0 :         thisGSHP.SourceSideInletNodeNum = GetOnlySingleNode(state,
     302            0 :                                                             AlphArray(2),
     303              :                                                             ErrorsFound,
     304              :                                                             DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     305            0 :                                                             thisGSHP.Name,
     306              :                                                             DataLoopNode::NodeFluidType::Water,
     307              :                                                             DataLoopNode::ConnectionType::Inlet,
     308              :                                                             NodeInputManager::CompFluidStream::Primary,
     309              :                                                             DataLoopNode::ObjectIsNotParent);
     310              : 
     311            0 :         thisGSHP.SourceSideOutletNodeNum = GetOnlySingleNode(state,
     312            0 :                                                              AlphArray(3),
     313              :                                                              ErrorsFound,
     314              :                                                              DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     315            0 :                                                              thisGSHP.Name,
     316              :                                                              DataLoopNode::NodeFluidType::Water,
     317              :                                                              DataLoopNode::ConnectionType::Outlet,
     318              :                                                              NodeInputManager::CompFluidStream::Primary,
     319              :                                                              DataLoopNode::ObjectIsNotParent);
     320              : 
     321            0 :         thisGSHP.LoadSideInletNodeNum = GetOnlySingleNode(state,
     322            0 :                                                           AlphArray(4),
     323              :                                                           ErrorsFound,
     324              :                                                           DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     325            0 :                                                           thisGSHP.Name,
     326              :                                                           DataLoopNode::NodeFluidType::Water,
     327              :                                                           DataLoopNode::ConnectionType::Inlet,
     328              :                                                           NodeInputManager::CompFluidStream::Secondary,
     329              :                                                           DataLoopNode::ObjectIsNotParent);
     330              : 
     331            0 :         thisGSHP.LoadSideOutletNodeNum = GetOnlySingleNode(state,
     332            0 :                                                            AlphArray(5),
     333              :                                                            ErrorsFound,
     334              :                                                            DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     335            0 :                                                            thisGSHP.Name,
     336              :                                                            DataLoopNode::NodeFluidType::Water,
     337              :                                                            DataLoopNode::ConnectionType::Outlet,
     338              :                                                            NodeInputManager::CompFluidStream::Secondary,
     339              :                                                            DataLoopNode::ObjectIsNotParent);
     340              : 
     341              :         // Test node sets
     342            0 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(2), AlphArray(3), "Condenser Water Nodes");
     343            0 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(4), AlphArray(5), "Chilled Water Nodes");
     344              : 
     345              :         // save the design source side flow rate for use by plant loop sizing algorithms
     346            0 :         PlantUtilities::RegisterPlantCompDesignFlow(state, thisGSHP.SourceSideInletNodeNum, 0.5 * thisGSHP.SourceSideVolFlowRate);
     347              : 
     348            0 :         thisGSHP.QLoad = 0.0;
     349            0 :         thisGSHP.QSource = 0.0;
     350            0 :         thisGSHP.Power = 0.0;
     351            0 :         thisGSHP.LoadSideWaterInletTemp = 0.0;
     352            0 :         thisGSHP.SourceSideWaterInletTemp = 0.0;
     353            0 :         thisGSHP.LoadSideWaterOutletTemp = 0.0;
     354            0 :         thisGSHP.SourceSideWaterOutletTemp = 0.0;
     355            0 :         thisGSHP.SourceSideWaterMassFlowRate = 0.0;
     356            0 :         thisGSHP.LoadSideWaterMassFlowRate = 0.0;
     357            0 :         thisGSHP.IsOn = false;
     358            0 :         thisGSHP.MustRun = true;
     359              : 
     360            0 :         if ((thisGSHP.refrig = Fluid::GetRefrig(state, GSHPRefrigerant)) == nullptr) {
     361            0 :             ShowSevereItemNotFound(state, eoh, "Refrigerant", GSHPRefrigerant);
     362            0 :             ErrorsFound = true;
     363              :         }
     364              :     }
     365              : 
     366            0 :     if (ErrorsFound) {
     367            0 :         ShowFatalError(state, "Errors Found in getting Gshp input");
     368              :     }
     369              : 
     370              :     // CurrentModuleObject='HeatPump:WaterToWater:ParameterEstimation:Cooling'
     371            0 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     372            0 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     373            0 :         SetupOutputVariable(state,
     374              :                             "Heat Pump Electricity Rate",
     375              :                             Constant::Units::W,
     376            0 :                             thisGSHP.Power,
     377              :                             OutputProcessor::TimeStepType::System,
     378              :                             OutputProcessor::StoreType::Average,
     379            0 :                             thisGSHP.Name);
     380            0 :         SetupOutputVariable(state,
     381              :                             "Heat Pump Electricity Energy",
     382              :                             Constant::Units::J,
     383            0 :                             thisGSHP.Energy,
     384              :                             OutputProcessor::TimeStepType::System,
     385              :                             OutputProcessor::StoreType::Sum,
     386            0 :                             thisGSHP.Name,
     387              :                             Constant::eResource::Electricity,
     388              :                             OutputProcessor::Group::Plant,
     389              :                             OutputProcessor::EndUseCat::Cooling);
     390              : 
     391            0 :         SetupOutputVariable(state,
     392              :                             "Heat Pump Load Side Heat Transfer Rate",
     393              :                             Constant::Units::W,
     394            0 :                             thisGSHP.QLoad,
     395              :                             OutputProcessor::TimeStepType::System,
     396              :                             OutputProcessor::StoreType::Average,
     397            0 :                             thisGSHP.Name);
     398            0 :         SetupOutputVariable(state,
     399              :                             "Heat Pump Load Side Heat Transfer Energy",
     400              :                             Constant::Units::J,
     401            0 :                             thisGSHP.QLoadEnergy,
     402              :                             OutputProcessor::TimeStepType::System,
     403              :                             OutputProcessor::StoreType::Sum,
     404            0 :                             thisGSHP.Name);
     405              : 
     406            0 :         SetupOutputVariable(state,
     407              :                             "Heat Pump Source Side Heat Transfer Rate",
     408              :                             Constant::Units::W,
     409            0 :                             thisGSHP.QSource,
     410              :                             OutputProcessor::TimeStepType::System,
     411              :                             OutputProcessor::StoreType::Average,
     412            0 :                             thisGSHP.Name);
     413            0 :         SetupOutputVariable(state,
     414              :                             "Heat Pump Source Side Heat Transfer Energy",
     415              :                             Constant::Units::J,
     416            0 :                             thisGSHP.QSourceEnergy,
     417              :                             OutputProcessor::TimeStepType::System,
     418              :                             OutputProcessor::StoreType::Sum,
     419            0 :                             thisGSHP.Name);
     420              : 
     421            0 :         SetupOutputVariable(state,
     422              :                             "Heat Pump Load Side Outlet Temperature",
     423              :                             Constant::Units::C,
     424            0 :                             thisGSHP.LoadSideWaterOutletTemp,
     425              :                             OutputProcessor::TimeStepType::System,
     426              :                             OutputProcessor::StoreType::Average,
     427            0 :                             thisGSHP.Name);
     428            0 :         SetupOutputVariable(state,
     429              :                             "Heat Pump Load Side Inlet Temperature",
     430              :                             Constant::Units::C,
     431            0 :                             thisGSHP.LoadSideWaterInletTemp,
     432              :                             OutputProcessor::TimeStepType::System,
     433              :                             OutputProcessor::StoreType::Average,
     434            0 :                             thisGSHP.Name);
     435            0 :         SetupOutputVariable(state,
     436              :                             "Heat Pump Source Side Outlet Temperature",
     437              :                             Constant::Units::C,
     438            0 :                             thisGSHP.SourceSideWaterOutletTemp,
     439              :                             OutputProcessor::TimeStepType::System,
     440              :                             OutputProcessor::StoreType::Average,
     441            0 :                             thisGSHP.Name);
     442            0 :         SetupOutputVariable(state,
     443              :                             "Heat Pump Source Side Inlet Temperature",
     444              :                             Constant::Units::C,
     445            0 :                             thisGSHP.SourceSideWaterInletTemp,
     446              :                             OutputProcessor::TimeStepType::System,
     447              :                             OutputProcessor::StoreType::Average,
     448            0 :                             thisGSHP.Name);
     449            0 :         SetupOutputVariable(state,
     450              :                             "Heat Pump Load Side Mass Flow Rate",
     451              :                             Constant::Units::kg_s,
     452            0 :                             thisGSHP.LoadSideWaterMassFlowRate,
     453              :                             OutputProcessor::TimeStepType::System,
     454              :                             OutputProcessor::StoreType::Average,
     455            0 :                             thisGSHP.Name);
     456            0 :         SetupOutputVariable(state,
     457              :                             "Heat Pump Source Side Mass Flow Rate",
     458              :                             Constant::Units::kg_s,
     459            0 :                             thisGSHP.SourceSideWaterMassFlowRate,
     460              :                             OutputProcessor::TimeStepType::System,
     461              :                             OutputProcessor::StoreType::Average,
     462            0 :                             thisGSHP.Name);
     463              :     }
     464            0 : }
     465              : 
     466            0 : void GshpPeCoolingSpecs::initialize(EnergyPlusData &state)
     467              : {
     468              : 
     469              :     // SUBROUTINE INFORMATION:
     470              :     //       AUTHOR:          Dan Fisher
     471              :     //       DATE WRITTEN:    July 2007
     472              : 
     473              :     // SUBROUTINE PARAMETER DEFINITIONS:
     474              :     static constexpr std::string_view RoutineName("InitGshp");
     475              : 
     476              :     // For each new environment
     477            0 :     if (state.dataGlobal->BeginEnvrnFlag && this->beginEnvironFlag) {
     478            0 :         this->QLoad = 0.0;
     479            0 :         this->QSource = 0.0;
     480            0 :         this->Power = 0.0;
     481            0 :         this->QLoadEnergy = 0.0;
     482            0 :         this->QSourceEnergy = 0.0;
     483            0 :         this->Energy = 0.0;
     484            0 :         this->LoadSideWaterInletTemp = 0.0;
     485            0 :         this->SourceSideWaterInletTemp = 0.0;
     486            0 :         this->LoadSideWaterOutletTemp = 0.0;
     487            0 :         this->SourceSideWaterOutletTemp = 0.0;
     488            0 :         this->SourceSideWaterMassFlowRate = 0.0;
     489            0 :         this->LoadSideWaterMassFlowRate = 0.0;
     490            0 :         this->IsOn = false;
     491            0 :         this->MustRun = true;
     492              : 
     493            0 :         this->beginEnvironFlag = false;
     494            0 :         Real64 rho = state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
     495            0 :         this->LoadSideDesignMassFlow = this->LoadSideVolFlowRate * rho;
     496              : 
     497            0 :         PlantUtilities::InitComponentNodes(state, 0.0, this->LoadSideDesignMassFlow, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum);
     498              : 
     499            0 :         rho = state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
     500            0 :         this->SourceSideDesignMassFlow = this->SourceSideVolFlowRate * rho;
     501              : 
     502            0 :         PlantUtilities::InitComponentNodes(state, 0.0, this->SourceSideDesignMassFlow, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum);
     503              : 
     504            0 :         state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp = 35.0;
     505              :     }
     506              : 
     507            0 :     if (!state.dataGlobal->BeginEnvrnFlag) this->beginEnvironFlag = true;
     508              : 
     509              :     // Init more variables
     510              : 
     511              :     // On every call
     512            0 :     this->Running = 0;
     513              : 
     514            0 :     this->MustRun = true; // Reset MustRun Flag to TRUE
     515              : 
     516            0 :     this->LoadSideWaterMassFlowRate = 0.0;   // Load Side mass flow rate, water side
     517            0 :     this->SourceSideWaterMassFlowRate = 0.0; // Source Side mass flow rate, water side
     518            0 :     this->Power = 0.0;                       // power consumption
     519            0 :     this->QLoad = 0.0;                       // heat rejection from Load Side coil
     520            0 :     this->QSource = 0.0;
     521            0 : }
     522              : 
     523            0 : void GshpPeCoolingSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad)
     524              : {
     525              :     // SUBROUTINE INFORMATION:
     526              :     //       DATE WRITTEN   Sept. 1998
     527              :     //       MODIFIED       April 1999
     528              :     //                      September 2002, SJR
     529              :     //       RE-ENGINEERED  Mar2000
     530              : 
     531              :     // SUBROUTINE PARAMETER DEFINITIONS:
     532            0 :     Real64 constexpr gamma(1.114); // Expnasion Coefficient
     533            0 :     Real64 constexpr HeatBalTol(0.0005);
     534            0 :     Real64 constexpr RelaxParam(0.6);
     535            0 :     Real64 constexpr SmallNum(1.0e-20);
     536            0 :     int constexpr IterationLimit(500);
     537              :     static constexpr std::string_view RoutineName("CalcGshpModel");
     538              :     static constexpr std::string_view RoutineNameLoadSideRefridgTemp("CalcGSHPModel:LoadSideRefridgTemp");
     539              :     static constexpr std::string_view RoutineNameSourceSideRefridgTemp("CalcGSHPModel:SourceSideRefridgTemp");
     540              :     static constexpr std::string_view RoutineNameCompressInletTemp("CalcGSHPModel:CompressInletTemp");
     541              :     static constexpr std::string_view RoutineNameSuctionPr("CalcGSHPModel:SuctionPr");
     542              :     static constexpr std::string_view RoutineNameCompSuctionTemp("CalcGSHPModel:CompSuctionTemp");
     543              : 
     544              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     545              :     Real64 SourceSideEffect;      // Source Side effectiveness
     546              :     Real64 LoadSideEffect;        // Load Side effectiveness
     547              :     Real64 SourceSideRefridgTemp; // Source Side temperature
     548              :     Real64 LoadSideRefridgTemp;   // Load Side temperature
     549              :     Real64 SourceSidePressure;    // Source Side pressure
     550              :     Real64 LoadSidePressure;      // Load Side pressure
     551              :     Real64 SuctionPr;             // Suction Pressure
     552              :     Real64 DischargePr;           // Discharge Pressure
     553              :     Real64 CompressInletTemp;     // Compressor inlet temperature
     554              :     Real64 MassRef;               // mass flow rate of refrigerant
     555              :     Real64 SourceSideOutletEnth;  // Enthalpy at Source Side pressure
     556              :     Real64 LoadSideOutletEnth;    // Enthalpy at Condenser Pressure
     557              :     Real64 initialQSource;        // Guess Source Side Heat rate
     558              :     Real64 initialQLoad;          // Guess Load Side Heat rate
     559              :     Real64 qual;                  // quality
     560              :     Real64 SuperHeatEnth;
     561              :     Real64 T110;
     562              :     Real64 T111;
     563              :     Real64 CompSuctionTemp;
     564              :     Real64 CompSuctionEnth;
     565              :     Real64 CompSuctionDensity;
     566              :     Real64 CompSuctionSatTemp;
     567              :     Real64 DutyFactor;
     568              :     int IterationCount;
     569              : 
     570              :     Real64 CpSourceSide; // local temporary for fluid specific heat
     571              :     Real64 CpLoadSide;   // local temporary for fluid specific heat
     572              : 
     573            0 :     if (MyLoad < 0.0) {
     574            0 :         this->MustRun = true;
     575            0 :         this->IsOn = true;
     576              :     } else {
     577            0 :         this->MustRun = false;
     578            0 :         this->IsOn = false;
     579              :     }
     580              : 
     581              :     //*******Set flow based on "flowlock" and "run" flags**********
     582              :     // Set flows if the heat pump is not running
     583            0 :     if (!this->MustRun) {
     584            0 :         this->LoadSideWaterMassFlowRate = 0.0;
     585            0 :         PlantUtilities::SetComponentFlowRate(
     586            0 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     587            0 :         this->SourceSideWaterMassFlowRate = 0.0;
     588            0 :         PlantUtilities::SetComponentFlowRate(
     589            0 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     590            0 :         PlantUtilities::PullCompInterconnectTrigger(state,
     591            0 :                                                     this->LoadPlantLoc,
     592            0 :                                                     this->CondMassFlowIndex,
     593            0 :                                                     this->SourcePlantLoc,
     594              :                                                     DataPlant::CriteriaType::MassFlowRate,
     595              :                                                     this->SourceSideWaterMassFlowRate);
     596              :         // now initialize simulation variables for "heat pump off"
     597            0 :         this->QLoad = 0.0;
     598            0 :         this->QSource = 0.0;
     599            0 :         this->Power = 0.0;
     600            0 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     601            0 :         this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     602            0 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     603            0 :         this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     604            0 :         return; // if heat pump is not running return without simulation
     605              : 
     606              :         // Set flows if the heat pump is running
     607              :     } else { // the heat pump must run
     608            0 :         this->LoadSideWaterMassFlowRate = this->LoadSideDesignMassFlow;
     609            0 :         PlantUtilities::SetComponentFlowRate(
     610            0 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     611              : 
     612            0 :         this->SourceSideWaterMassFlowRate = this->SourceSideDesignMassFlow;
     613            0 :         PlantUtilities::SetComponentFlowRate(
     614            0 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     615              :         // get inlet temps
     616            0 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     617            0 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     618              :         // if there's no flow, turn the "heat pump off"
     619            0 :         if (this->LoadSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance ||
     620            0 :             this->SourceSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance) {
     621            0 :             this->LoadSideWaterMassFlowRate = 0.0;
     622            0 :             PlantUtilities::SetComponentFlowRate(
     623            0 :                 state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     624            0 :             this->SourceSideWaterMassFlowRate = 0.0;
     625            0 :             PlantUtilities::SetComponentFlowRate(
     626            0 :                 state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     627            0 :             PlantUtilities::PullCompInterconnectTrigger(state,
     628            0 :                                                         this->LoadPlantLoc,
     629            0 :                                                         this->CondMassFlowIndex,
     630            0 :                                                         this->SourcePlantLoc,
     631              :                                                         DataPlant::CriteriaType::MassFlowRate,
     632              :                                                         this->SourceSideWaterMassFlowRate);
     633            0 :             this->QLoad = 0.0;
     634            0 :             this->QSource = 0.0;
     635            0 :             this->Power = 0.0;
     636            0 :             this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     637            0 :             this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     638            0 :             this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     639            0 :             this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     640            0 :             return;
     641              :         }
     642            0 :         PlantUtilities::PullCompInterconnectTrigger(state,
     643            0 :                                                     this->LoadPlantLoc,
     644            0 :                                                     this->CondMassFlowIndex,
     645            0 :                                                     this->SourcePlantLoc,
     646              :                                                     DataPlant::CriteriaType::MassFlowRate,
     647              :                                                     this->SourceSideWaterMassFlowRate);
     648              :     }
     649              : 
     650              :     //**********BEGIN THE CALCULATION**************
     651              : 
     652              :     // initialize the source and load side heat transfer rates for the simulation
     653            0 :     initialQSource = 0.0;
     654            0 :     initialQLoad = 0.0;
     655            0 :     IterationCount = 0;
     656              : 
     657              :     CpSourceSide =
     658            0 :         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).glycol->getSpecificHeat(state, this->SourceSideWaterInletTemp, RoutineName);
     659              : 
     660            0 :     CpLoadSide = state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).glycol->getSpecificHeat(state, this->LoadSideWaterInletTemp, RoutineName);
     661              : 
     662              :     // Determine effectiveness of Load Side
     663            0 :     LoadSideEffect = 1.0 - std::exp(-this->LoadSideUACoeff / (CpLoadSide * this->LoadSideWaterMassFlowRate));
     664              :     // Determine effectiveness of Source Side
     665            0 :     SourceSideEffect = 1.0 - std::exp(-this->SourceSideUACoeff / (CpSourceSide * this->SourceSideWaterMassFlowRate));
     666              : 
     667              :     // main iteration loop to solve model equations
     668              :     while (true) {
     669            0 :         ++IterationCount;
     670              : 
     671              :         // To determine Load Side temperature
     672            0 :         LoadSideRefridgTemp = this->LoadSideWaterInletTemp - initialQLoad / (LoadSideEffect * CpLoadSide * this->LoadSideWaterMassFlowRate);
     673              : 
     674              :         // Determine Source Side tempertaure
     675            0 :         SourceSideRefridgTemp =
     676            0 :             this->SourceSideWaterInletTemp + initialQSource / (SourceSideEffect * CpSourceSide * this->SourceSideWaterMassFlowRate);
     677              : 
     678              :         // Determine the evaporating and condensing pressures
     679            0 :         SourceSidePressure = this->refrig->getSatPressure(state, SourceSideRefridgTemp, RoutineName);
     680            0 :         LoadSidePressure = this->refrig->getSatPressure(state, LoadSideRefridgTemp, RoutineName);
     681              : 
     682            0 :         if (SourceSidePressure < this->LowPressCutoff) {
     683            0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Source Side Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     684            0 :             ShowContinueError(state,
     685            0 :                               format("Cooling Source Side Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}",
     686              :                                      SourceSidePressure,
     687            0 :                                      this->LowPressCutoff));
     688            0 :             ShowContinueErrorTimeStamp(state, "");
     689            0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     690              :         }
     691              : 
     692            0 :         if (LoadSidePressure > this->HighPressCutoff) {
     693            0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Load Side Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     694            0 :             ShowContinueError(state,
     695            0 :                               format("Cooling Load Side Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}",
     696              :                                      LoadSidePressure,
     697            0 :                                      this->HighPressCutoff));
     698            0 :             ShowContinueErrorTimeStamp(state, "");
     699            0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     700              :         }
     701              :         // Determine Suction Pressure at compressor inlet
     702            0 :         SuctionPr = LoadSidePressure - this->CompSucPressDrop;
     703              :         // Determine Discharge Pressure at compressor exit
     704            0 :         DischargePr = SourceSidePressure + this->CompSucPressDrop;
     705              : 
     706            0 :         if (SuctionPr < this->LowPressCutoff) {
     707            0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Suction Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     708            0 :             ShowContinueError(
     709            0 :                 state, format("Cooling Suction Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}", SuctionPr, this->LowPressCutoff));
     710            0 :             ShowContinueErrorTimeStamp(state, "");
     711            0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     712              :         }
     713              : 
     714            0 :         if (DischargePr > this->HighPressCutoff) {
     715            0 :             ShowSevereError(state, format("{}=\"{}\" Cooling Discharge Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     716            0 :             ShowContinueError(
     717              :                 state,
     718            0 :                 format("Cooling Discharge Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}", DischargePr, this->HighPressCutoff));
     719            0 :             ShowContinueErrorTimeStamp(state, "");
     720            0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     721              :         }
     722              : 
     723              :         // Determine the Source Side Outlet Enthalpy
     724              : 
     725            0 :         qual = 1.0;
     726            0 :         LoadSideOutletEnth = this->refrig->getSatEnthalpy(state, LoadSideRefridgTemp, qual, RoutineNameLoadSideRefridgTemp);
     727              : 
     728            0 :         qual = 0.0;
     729            0 :         SourceSideOutletEnth = this->refrig->getSatEnthalpy(state, SourceSideRefridgTemp, qual, RoutineNameSourceSideRefridgTemp);
     730              : 
     731              :         // Determine Load Side Outlet Enthalpy
     732              :         // Determine superheated temperature of the LoadSide outlet/compressor inlet
     733            0 :         CompressInletTemp = LoadSideRefridgTemp + this->SuperheatTemp;
     734              : 
     735              :         // Determine the enathalpy of the super heated fluid at Source Side outlet
     736            0 :         SuperHeatEnth = this->refrig->getSupHeatEnthalpy(state, CompressInletTemp, LoadSidePressure, RoutineNameCompressInletTemp);
     737              : 
     738              :         // Determining the suction state of the fluid from inlet state involves interation
     739              :         // Method employed...
     740              :         // Determine the saturated temp at suction pressure, shoot out into the superheated region find the enthalpy
     741              :         // check that with the inlet enthalpy ( as suction loss is isenthalpic). Iterate till desired accuracy is reached
     742              : 
     743              :         // this routine was reenginerred from HVACsim + takes pressure in Pascals, tolrance, refrgerant # R22 =6
     744            0 :         CompSuctionSatTemp = this->refrig->getSatTemperature(state, SuctionPr, RoutineNameSuctionPr);
     745              : 
     746            0 :         T110 = CompSuctionSatTemp;
     747              :         //            Shoot into the super heated region
     748            0 :         T111 = CompSuctionSatTemp + 100.0;
     749              :         // Iterate to find the Suction State
     750              :         while (true) {
     751            0 :             CompSuctionTemp = 0.5 * (T110 + T111);
     752              : 
     753            0 :             CompSuctionEnth = this->refrig->getSupHeatEnthalpy(state, CompSuctionTemp, SuctionPr, RoutineNameCompSuctionTemp);
     754              : 
     755            0 :             if (std::abs(CompSuctionEnth - SuperHeatEnth) / SuperHeatEnth < 0.0001) {
     756            0 :                 goto LOOP_exit;
     757              :             }
     758              : 
     759            0 :             if (CompSuctionEnth < SuperHeatEnth) {
     760            0 :                 T110 = CompSuctionTemp;
     761              :             } else {
     762            0 :                 T111 = CompSuctionTemp;
     763              :             }
     764              :         }
     765            0 :     LOOP_exit:;
     766              : 
     767              :         // Determine the Mass flow rate of refrigerant
     768            0 :         CompSuctionDensity = this->refrig->getSupHeatDensity(state, CompSuctionTemp, SuctionPr, RoutineNameCompSuctionTemp);
     769            0 :         MassRef = this->CompPistonDisp * CompSuctionDensity *
     770            0 :                   (1 + this->CompClearanceFactor - this->CompClearanceFactor * std::pow(DischargePr / SuctionPr, 1 / gamma));
     771              : 
     772              :         // Find the Source Side Heat Transfer
     773              : 
     774            0 :         this->QLoad = MassRef * (LoadSideOutletEnth - SourceSideOutletEnth);
     775              : 
     776              :         // Determine the theoretical power
     777            0 :         this->Power = this->PowerLosses + (MassRef * gamma / (gamma - 1) * SuctionPr / CompSuctionDensity / this->LossFactor *
     778            0 :                                            (std::pow(DischargePr / SuctionPr, (gamma - 1) / gamma) - 1));
     779              : 
     780              :         // Determine the Loadside HeatRate (this->QLoad)
     781            0 :         this->QSource = this->Power + this->QLoad;
     782              :         // convergence and iteration limit check
     783            0 :         if (std::abs((this->QSource - initialQSource) / (initialQSource + SmallNum)) < HeatBalTol || IterationCount > IterationLimit) {
     784            0 :             if (IterationCount > IterationLimit) {
     785            0 :                 ShowWarningError(state, "HeatPump:WaterToWater:ParameterEstimation, Cooling did not converge");
     786            0 :                 ShowContinueErrorTimeStamp(state, "");
     787            0 :                 ShowContinueError(state, format("Heatpump Name = {}", this->Name));
     788            0 :                 ShowContinueError(
     789              :                     state,
     790            0 :                     format("Heat Inbalance (%)             = {}", std::abs(100.0 * (this->QSource - initialQSource) / (initialQSource + SmallNum))));
     791            0 :                 ShowContinueError(state, format("Load-side heat transfer rate   = {}", this->QLoad));
     792            0 :                 ShowContinueError(state, format("Source-side heat transfer rate = {}", this->QSource));
     793            0 :                 ShowContinueError(state, format("Source-side mass flow rate     = {}", this->SourceSideWaterMassFlowRate));
     794            0 :                 ShowContinueError(state, format("Load-side mass flow rate       = {}", this->LoadSideWaterMassFlowRate));
     795            0 :                 ShowContinueError(state, format("Source-side inlet temperature  = {}", this->SourceSideWaterInletTemp));
     796            0 :                 ShowContinueError(state, format("Load-side inlet temperature    = {}", this->LoadSideWaterInletTemp));
     797              :             }
     798            0 :             goto LOOPSourceEnth_exit;
     799              : 
     800              :         } else { // update load
     801            0 :             initialQSource += RelaxParam * (this->QSource - initialQSource);
     802            0 :             initialQLoad += RelaxParam * (this->QLoad - initialQLoad);
     803              :         }
     804              :     }
     805            0 : LOOPSourceEnth_exit:;
     806              : 
     807              :     // Control Strategy
     808            0 :     if (std::abs(MyLoad) < this->QLoad) {
     809            0 :         DutyFactor = std::abs(MyLoad) / this->QLoad;
     810            0 :         this->QLoad = std::abs(MyLoad);
     811            0 :         this->Power *= DutyFactor;
     812            0 :         this->QSource *= DutyFactor;
     813              :         // Determine the Exterior fluid temperature at the Load Side oulet and evaporator outlet...
     814            0 :         this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp - this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide); // Chilled water
     815            0 :         this->SourceSideWaterOutletTemp =
     816            0 :             this->SourceSideWaterInletTemp + this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide); // cooling water
     817            0 :         return;
     818              :     }
     819              : 
     820            0 :     this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp - this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide); // Chilled water
     821            0 :     this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp + this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide);
     822            0 :     this->Running = 1;
     823              : }
     824              : 
     825            0 : void GshpPeCoolingSpecs::update(EnergyPlusData &state)
     826              : {
     827              :     // SUBROUTINE INFORMATION:
     828              :     //       AUTHOR:          Dan Fisher
     829              :     //       DATE WRITTEN:    October 1998
     830              : 
     831            0 :     if (!this->MustRun) {
     832              :         // set node temperatures
     833            0 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     834            0 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     835            0 :         this->Power = 0.0;
     836            0 :         this->Energy = 0.0;
     837            0 :         this->QSource = 0.0;
     838            0 :         this->QLoad = 0.0;
     839            0 :         this->QSourceEnergy = 0.0;
     840            0 :         this->QLoadEnergy = 0.0;
     841            0 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     842            0 :         this->SourceSideWaterOutletTemp = state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp;
     843            0 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     844            0 :         this->LoadSideWaterOutletTemp = state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp;
     845              : 
     846              :     } else {
     847              :         // set node temperatures
     848            0 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = this->LoadSideWaterOutletTemp;
     849            0 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = this->SourceSideWaterOutletTemp;
     850              : 
     851              :         // set node flow rates;  for these load based models
     852              :         // assume that the sufficient Source Side flow rate available
     853              : 
     854            0 :         Real64 const ReportingConstant = state.dataHVACGlobal->TimeStepSysSec;
     855              : 
     856            0 :         this->Energy = this->Power * ReportingConstant;
     857            0 :         this->QSourceEnergy = QSource * ReportingConstant;
     858            0 :         this->QLoadEnergy = QLoad * ReportingConstant;
     859            0 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     860            0 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     861              :     }
     862            0 : }
     863            0 : void GshpPeCoolingSpecs::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     864              : {
     865            0 : }
     866            0 : void GshpPeCoolingSpecs::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     867              : {
     868            0 : }
     869              : 
     870              : } // namespace EnergyPlus::HeatPumpWaterToWaterCOOLING
        

Generated by: LCOV version 2.0-1