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

Generated by: LCOV version 2.0-1