LCOV - code coverage report
Current view: top level - EnergyPlus - HeatPumpWaterToWaterCOOLING.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 82.9 % 392 325
Test Date: 2025-06-02 07:23:51 Functions: 90.9 % 11 10

            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            6 : GshpPeCoolingSpecs *GshpPeCoolingSpecs::factory(EnergyPlusData &state, const std::string &objectName)
      95              : {
      96            6 :     if (state.dataHPWaterToWaterClg->GetWWHPCoolingInput) {
      97            3 :         GetGshpInput(state);
      98            3 :         state.dataHPWaterToWaterClg->GetWWHPCoolingInput = false;
      99              :     }
     100            6 :     auto thisObj = std::find_if(state.dataHPWaterToWaterClg->GSHP.begin(),
     101            6 :                                 state.dataHPWaterToWaterClg->GSHP.end(),
     102            6 :                                 [&objectName](const GshpPeCoolingSpecs &myObj) { return myObj.Name == objectName; });
     103            6 :     if (thisObj != state.dataHPWaterToWaterClg->GSHP.end()) {
     104            6 :         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        93022 : 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        93022 :     if (calledFromLocation.loopNum == this->LoadPlantLoc.loopNum) { // chilled water loop
     117        46511 :         this->initialize(state);
     118        46511 :         this->calculate(state, CurLoad);
     119        46511 :         this->update(state);
     120        46511 :     } else if (calledFromLocation.loopNum == this->SourcePlantLoc.loopNum) { // condenser loop
     121        46511 :         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        93022 : }
     136              : 
     137           30 : void GshpPeCoolingSpecs::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     138              :                                              [[maybe_unused]] const PlantLocation &calledFromLocation,
     139              :                                              Real64 &MaxLoad,
     140              :                                              Real64 &MinLoad,
     141              :                                              Real64 &OptLoad)
     142              : {
     143           30 :     MinLoad = this->NomCap * this->MinPartLoadRat;
     144           30 :     MaxLoad = this->NomCap * this->MaxPartLoadRat;
     145           30 :     OptLoad = this->NomCap * this->OptPartLoadRat;
     146           30 : }
     147              : 
     148           30 : void GshpPeCoolingSpecs::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
     149              : {
     150           30 :     if (this->plantScanFlag) {
     151              :         // Locate the heating on the plant loops for later usage
     152            3 :         bool errFlag = false;
     153            9 :         PlantUtilities::ScanPlantLoopsForObject(state,
     154              :                                                 this->Name,
     155              :                                                 DataPlant::PlantEquipmentType::HPWaterPECooling,
     156            3 :                                                 this->SourcePlantLoc,
     157              :                                                 errFlag,
     158              :                                                 _,
     159              :                                                 _,
     160              :                                                 _,
     161            3 :                                                 this->SourceSideInletNodeNum,
     162              :                                                 _);
     163            9 :         PlantUtilities::ScanPlantLoopsForObject(
     164            6 :             state, this->Name, DataPlant::PlantEquipmentType::HPWaterPECooling, this->LoadPlantLoc, errFlag, _, _, _, this->LoadSideInletNodeNum, _);
     165            3 :         if (errFlag) {
     166            0 :             ShowFatalError(state, "InitGshp: Program terminated due to previous condition(s).");
     167              :         }
     168              : 
     169            3 :         PlantUtilities::InterConnectTwoPlantLoopSides(state, this->LoadPlantLoc, this->SourcePlantLoc, this->WWHPPlantTypeOfNum, true);
     170            3 :         this->plantScanFlag = false;
     171              :     }
     172           30 : }
     173              : 
     174            3 : 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            3 :     Array1D_string AlphArray(5);  // character string data
     194            3 :     Array1D<Real64> NumArray(23); // numeric data
     195              : 
     196            3 :     bool ErrorsFound(false);
     197              : 
     198            3 :     state.dataHPWaterToWaterClg->NumGSHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ModuleCompNameUC);
     199              : 
     200            3 :     if (state.dataHPWaterToWaterClg->NumGSHPs <= 0) {
     201            0 :         ShowSevereError(state, "No Equipment found in SimGshp");
     202            0 :         ErrorsFound = true;
     203              :     }
     204              : 
     205              :     // Allocate Arrays
     206            3 :     state.dataHPWaterToWaterClg->GSHP.allocate(state.dataHPWaterToWaterClg->NumGSHPs);
     207              : 
     208            6 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     209            3 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     210            3 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, ModuleCompNameUC, GSHPNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     211              : 
     212            3 :         ErrorObjectHeader eoh{routineName, ModuleCompNameUC, AlphArray(1)};
     213              : 
     214            3 :         thisGSHP.Name = AlphArray(1);
     215              : 
     216            3 :         thisGSHP.WWHPPlantTypeOfNum = DataPlant::PlantEquipmentType::HPWaterPECooling;
     217              : 
     218            3 :         thisGSHP.COP = NumArray(1);
     219            3 :         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            3 :         thisGSHP.NomCap = NumArray(2);
     227              : 
     228            3 :         thisGSHP.MinPartLoadRat = NumArray(3);
     229              : 
     230            3 :         thisGSHP.MaxPartLoadRat = NumArray(4);
     231              : 
     232            3 :         thisGSHP.OptPartLoadRat = NumArray(5);
     233              : 
     234            3 :         thisGSHP.LoadSideVolFlowRate = NumArray(6);
     235            3 :         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            3 :         thisGSHP.SourceSideVolFlowRate = NumArray(7);
     241            3 :         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            3 :         thisGSHP.LoadSideUACoeff = NumArray(8);
     247            3 :         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            3 :         thisGSHP.SourceSideUACoeff = NumArray(9);
     253            3 :         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            3 :         thisGSHP.CompPistonDisp = NumArray(10);
     259            3 :         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            3 :         thisGSHP.CompClearanceFactor = NumArray(11);
     265            3 :         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            3 :         thisGSHP.CompSucPressDrop = NumArray(12);
     271            3 :         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            3 :         thisGSHP.SuperheatTemp = NumArray(13);
     277            3 :         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            3 :         thisGSHP.PowerLosses = NumArray(14);
     283            3 :         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            3 :         thisGSHP.LossFactor = NumArray(15);
     288            3 :         if (NumArray(15) == 0.0) {
     289            0 :             ShowSevereError(state, format("{}:Efficiency = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     290            0 :             ErrorsFound = true;
     291              :         }
     292              : 
     293            3 :         thisGSHP.HighPressCutoff = NumArray(16);
     294            3 :         if (NumArray(16) == 0.0) {
     295            3 :             thisGSHP.HighPressCutoff = 500000000.0;
     296              :         }
     297              : 
     298            3 :         thisGSHP.LowPressCutoff = NumArray(17);
     299            3 :         if (NumArray(17) == 0.0) {
     300            3 :             thisGSHP.LowPressCutoff = 0.0;
     301              :         }
     302              : 
     303            3 :         thisGSHP.SourceSideInletNodeNum = GetOnlySingleNode(state,
     304            3 :                                                             AlphArray(2),
     305              :                                                             ErrorsFound,
     306              :                                                             DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     307            3 :                                                             thisGSHP.Name,
     308              :                                                             DataLoopNode::NodeFluidType::Water,
     309              :                                                             DataLoopNode::ConnectionType::Inlet,
     310              :                                                             NodeInputManager::CompFluidStream::Primary,
     311              :                                                             DataLoopNode::ObjectIsNotParent);
     312              : 
     313            3 :         thisGSHP.SourceSideOutletNodeNum = GetOnlySingleNode(state,
     314            3 :                                                              AlphArray(3),
     315              :                                                              ErrorsFound,
     316              :                                                              DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     317            3 :                                                              thisGSHP.Name,
     318              :                                                              DataLoopNode::NodeFluidType::Water,
     319              :                                                              DataLoopNode::ConnectionType::Outlet,
     320              :                                                              NodeInputManager::CompFluidStream::Primary,
     321              :                                                              DataLoopNode::ObjectIsNotParent);
     322              : 
     323            3 :         thisGSHP.LoadSideInletNodeNum = GetOnlySingleNode(state,
     324            3 :                                                           AlphArray(4),
     325              :                                                           ErrorsFound,
     326              :                                                           DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     327            3 :                                                           thisGSHP.Name,
     328              :                                                           DataLoopNode::NodeFluidType::Water,
     329              :                                                           DataLoopNode::ConnectionType::Inlet,
     330              :                                                           NodeInputManager::CompFluidStream::Secondary,
     331              :                                                           DataLoopNode::ObjectIsNotParent);
     332              : 
     333            6 :         thisGSHP.LoadSideOutletNodeNum = GetOnlySingleNode(state,
     334            3 :                                                            AlphArray(5),
     335              :                                                            ErrorsFound,
     336              :                                                            DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationCooling,
     337            3 :                                                            thisGSHP.Name,
     338              :                                                            DataLoopNode::NodeFluidType::Water,
     339              :                                                            DataLoopNode::ConnectionType::Outlet,
     340              :                                                            NodeInputManager::CompFluidStream::Secondary,
     341              :                                                            DataLoopNode::ObjectIsNotParent);
     342              : 
     343              :         // Test node sets
     344            6 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(2), AlphArray(3), "Condenser Water Nodes");
     345            3 :         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            3 :         PlantUtilities::RegisterPlantCompDesignFlow(state, thisGSHP.SourceSideInletNodeNum, 0.5 * thisGSHP.SourceSideVolFlowRate);
     349              : 
     350            3 :         thisGSHP.QLoad = 0.0;
     351            3 :         thisGSHP.QSource = 0.0;
     352            3 :         thisGSHP.Power = 0.0;
     353            3 :         thisGSHP.LoadSideWaterInletTemp = 0.0;
     354            3 :         thisGSHP.SourceSideWaterInletTemp = 0.0;
     355            3 :         thisGSHP.LoadSideWaterOutletTemp = 0.0;
     356            3 :         thisGSHP.SourceSideWaterOutletTemp = 0.0;
     357            3 :         thisGSHP.SourceSideWaterMassFlowRate = 0.0;
     358            3 :         thisGSHP.LoadSideWaterMassFlowRate = 0.0;
     359            3 :         thisGSHP.IsOn = false;
     360            3 :         thisGSHP.MustRun = true;
     361              : 
     362            3 :         if ((thisGSHP.refrig = Fluid::GetRefrig(state, GSHPRefrigerant)) == nullptr) {
     363            0 :             ShowSevereItemNotFound(state, eoh, "Refrigerant", GSHPRefrigerant);
     364            0 :             ErrorsFound = true;
     365              :         }
     366              :     }
     367              : 
     368            3 :     if (ErrorsFound) {
     369            0 :         ShowFatalError(state, "Errors Found in getting Gshp input");
     370              :     }
     371              : 
     372              :     // CurrentModuleObject='HeatPump:WaterToWater:ParameterEstimation:Cooling'
     373            6 :     for (GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterClg->NumGSHPs; ++GSHPNum) {
     374            3 :         auto &thisGSHP = state.dataHPWaterToWaterClg->GSHP(GSHPNum);
     375            6 :         SetupOutputVariable(state,
     376              :                             "Heat Pump Electricity Rate",
     377              :                             Constant::Units::W,
     378            3 :                             thisGSHP.Power,
     379              :                             OutputProcessor::TimeStepType::System,
     380              :                             OutputProcessor::StoreType::Average,
     381            3 :                             thisGSHP.Name);
     382            6 :         SetupOutputVariable(state,
     383              :                             "Heat Pump Electricity Energy",
     384              :                             Constant::Units::J,
     385            3 :                             thisGSHP.Energy,
     386              :                             OutputProcessor::TimeStepType::System,
     387              :                             OutputProcessor::StoreType::Sum,
     388            3 :                             thisGSHP.Name,
     389              :                             Constant::eResource::Electricity,
     390              :                             OutputProcessor::Group::Plant,
     391              :                             OutputProcessor::EndUseCat::Cooling);
     392              : 
     393            6 :         SetupOutputVariable(state,
     394              :                             "Heat Pump Load Side Heat Transfer Rate",
     395              :                             Constant::Units::W,
     396            3 :                             thisGSHP.QLoad,
     397              :                             OutputProcessor::TimeStepType::System,
     398              :                             OutputProcessor::StoreType::Average,
     399            3 :                             thisGSHP.Name);
     400            6 :         SetupOutputVariable(state,
     401              :                             "Heat Pump Load Side Heat Transfer Energy",
     402              :                             Constant::Units::J,
     403            3 :                             thisGSHP.QLoadEnergy,
     404              :                             OutputProcessor::TimeStepType::System,
     405              :                             OutputProcessor::StoreType::Sum,
     406            3 :                             thisGSHP.Name);
     407              : 
     408            6 :         SetupOutputVariable(state,
     409              :                             "Heat Pump Source Side Heat Transfer Rate",
     410              :                             Constant::Units::W,
     411            3 :                             thisGSHP.QSource,
     412              :                             OutputProcessor::TimeStepType::System,
     413              :                             OutputProcessor::StoreType::Average,
     414            3 :                             thisGSHP.Name);
     415            6 :         SetupOutputVariable(state,
     416              :                             "Heat Pump Source Side Heat Transfer Energy",
     417              :                             Constant::Units::J,
     418            3 :                             thisGSHP.QSourceEnergy,
     419              :                             OutputProcessor::TimeStepType::System,
     420              :                             OutputProcessor::StoreType::Sum,
     421            3 :                             thisGSHP.Name);
     422              : 
     423            6 :         SetupOutputVariable(state,
     424              :                             "Heat Pump Load Side Outlet Temperature",
     425              :                             Constant::Units::C,
     426            3 :                             thisGSHP.LoadSideWaterOutletTemp,
     427              :                             OutputProcessor::TimeStepType::System,
     428              :                             OutputProcessor::StoreType::Average,
     429            3 :                             thisGSHP.Name);
     430            6 :         SetupOutputVariable(state,
     431              :                             "Heat Pump Load Side Inlet Temperature",
     432              :                             Constant::Units::C,
     433            3 :                             thisGSHP.LoadSideWaterInletTemp,
     434              :                             OutputProcessor::TimeStepType::System,
     435              :                             OutputProcessor::StoreType::Average,
     436            3 :                             thisGSHP.Name);
     437            6 :         SetupOutputVariable(state,
     438              :                             "Heat Pump Source Side Outlet Temperature",
     439              :                             Constant::Units::C,
     440            3 :                             thisGSHP.SourceSideWaterOutletTemp,
     441              :                             OutputProcessor::TimeStepType::System,
     442              :                             OutputProcessor::StoreType::Average,
     443            3 :                             thisGSHP.Name);
     444            6 :         SetupOutputVariable(state,
     445              :                             "Heat Pump Source Side Inlet Temperature",
     446              :                             Constant::Units::C,
     447            3 :                             thisGSHP.SourceSideWaterInletTemp,
     448              :                             OutputProcessor::TimeStepType::System,
     449              :                             OutputProcessor::StoreType::Average,
     450            3 :                             thisGSHP.Name);
     451            6 :         SetupOutputVariable(state,
     452              :                             "Heat Pump Load Side Mass Flow Rate",
     453              :                             Constant::Units::kg_s,
     454            3 :                             thisGSHP.LoadSideWaterMassFlowRate,
     455              :                             OutputProcessor::TimeStepType::System,
     456              :                             OutputProcessor::StoreType::Average,
     457            3 :                             thisGSHP.Name);
     458            6 :         SetupOutputVariable(state,
     459              :                             "Heat Pump Source Side Mass Flow Rate",
     460              :                             Constant::Units::kg_s,
     461            3 :                             thisGSHP.SourceSideWaterMassFlowRate,
     462              :                             OutputProcessor::TimeStepType::System,
     463              :                             OutputProcessor::StoreType::Average,
     464            3 :                             thisGSHP.Name);
     465              :     }
     466            3 : }
     467              : 
     468        46511 : 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        46511 :     if (state.dataGlobal->BeginEnvrnFlag && this->beginEnvironFlag) {
     480           18 :         this->QLoad = 0.0;
     481           18 :         this->QSource = 0.0;
     482           18 :         this->Power = 0.0;
     483           18 :         this->QLoadEnergy = 0.0;
     484           18 :         this->QSourceEnergy = 0.0;
     485           18 :         this->Energy = 0.0;
     486           18 :         this->LoadSideWaterInletTemp = 0.0;
     487           18 :         this->SourceSideWaterInletTemp = 0.0;
     488           18 :         this->LoadSideWaterOutletTemp = 0.0;
     489           18 :         this->SourceSideWaterOutletTemp = 0.0;
     490           18 :         this->SourceSideWaterMassFlowRate = 0.0;
     491           18 :         this->LoadSideWaterMassFlowRate = 0.0;
     492           18 :         this->IsOn = false;
     493           18 :         this->MustRun = true;
     494              : 
     495           18 :         this->beginEnvironFlag = false;
     496           18 :         Real64 rho = state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
     497           18 :         this->LoadSideDesignMassFlow = this->LoadSideVolFlowRate * rho;
     498              : 
     499           18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->LoadSideDesignMassFlow, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum);
     500              : 
     501           18 :         rho = state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).glycol->getDensity(state, Constant::CWInitConvTemp, RoutineName);
     502           18 :         this->SourceSideDesignMassFlow = this->SourceSideVolFlowRate * rho;
     503              : 
     504           18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->SourceSideDesignMassFlow, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum);
     505              : 
     506           18 :         state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp = 35.0;
     507              :     }
     508              : 
     509        46511 :     if (!state.dataGlobal->BeginEnvrnFlag) {
     510        46184 :         this->beginEnvironFlag = true;
     511              :     }
     512              : 
     513              :     // Init more variables
     514              : 
     515              :     // On every call
     516        46511 :     this->Running = 0;
     517              : 
     518        46511 :     this->MustRun = true; // Reset MustRun Flag to TRUE
     519              : 
     520        46511 :     this->LoadSideWaterMassFlowRate = 0.0;   // Load Side mass flow rate, water side
     521        46511 :     this->SourceSideWaterMassFlowRate = 0.0; // Source Side mass flow rate, water side
     522        46511 :     this->Power = 0.0;                       // power consumption
     523        46511 :     this->QLoad = 0.0;                       // heat rejection from Load Side coil
     524        46511 :     this->QSource = 0.0;
     525        46511 : }
     526              : 
     527        46511 : 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        46511 :     Real64 constexpr gamma(1.114); // Expnasion Coefficient
     537        46511 :     Real64 constexpr HeatBalTol(0.0005);
     538        46511 :     Real64 constexpr RelaxParam(0.6);
     539        46511 :     Real64 constexpr SmallNum(1.0e-20);
     540        46511 :     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        46511 :     if (MyLoad < 0.0) {
     578        35242 :         this->MustRun = true;
     579        35242 :         this->IsOn = true;
     580              :     } else {
     581        11269 :         this->MustRun = false;
     582        11269 :         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        46511 :     if (!this->MustRun) {
     588        11269 :         this->LoadSideWaterMassFlowRate = 0.0;
     589        11269 :         PlantUtilities::SetComponentFlowRate(
     590        11269 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     591        11269 :         this->SourceSideWaterMassFlowRate = 0.0;
     592        11269 :         PlantUtilities::SetComponentFlowRate(
     593        11269 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     594        11269 :         PlantUtilities::PullCompInterconnectTrigger(state,
     595        11269 :                                                     this->LoadPlantLoc,
     596        11269 :                                                     this->CondMassFlowIndex,
     597        11269 :                                                     this->SourcePlantLoc,
     598              :                                                     DataPlant::CriteriaType::MassFlowRate,
     599              :                                                     this->SourceSideWaterMassFlowRate);
     600              :         // now initialize simulation variables for "heat pump off"
     601        11269 :         this->QLoad = 0.0;
     602        11269 :         this->QSource = 0.0;
     603        11269 :         this->Power = 0.0;
     604        11269 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     605        11269 :         this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     606        11269 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     607        11269 :         this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     608        46511 :         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        35242 :         this->LoadSideWaterMassFlowRate = this->LoadSideDesignMassFlow;
     613        35242 :         PlantUtilities::SetComponentFlowRate(
     614        35242 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     615              : 
     616        35242 :         this->SourceSideWaterMassFlowRate = this->SourceSideDesignMassFlow;
     617        35242 :         PlantUtilities::SetComponentFlowRate(
     618        35242 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     619              :         // get inlet temps
     620        35242 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     621        35242 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     622              :         // if there's no flow, turn the "heat pump off"
     623        35242 :         if (this->LoadSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance ||
     624        35235 :             this->SourceSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance) {
     625           14 :             this->LoadSideWaterMassFlowRate = 0.0;
     626           14 :             PlantUtilities::SetComponentFlowRate(
     627           14 :                 state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     628           14 :             this->SourceSideWaterMassFlowRate = 0.0;
     629           14 :             PlantUtilities::SetComponentFlowRate(
     630           14 :                 state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     631           14 :             PlantUtilities::PullCompInterconnectTrigger(state,
     632           14 :                                                         this->LoadPlantLoc,
     633           14 :                                                         this->CondMassFlowIndex,
     634           14 :                                                         this->SourcePlantLoc,
     635              :                                                         DataPlant::CriteriaType::MassFlowRate,
     636              :                                                         this->SourceSideWaterMassFlowRate);
     637           14 :             this->QLoad = 0.0;
     638           14 :             this->QSource = 0.0;
     639           14 :             this->Power = 0.0;
     640           14 :             this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     641           14 :             this->LoadSideWaterOutletTemp = LoadSideWaterInletTemp;
     642           14 :             this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     643           14 :             this->SourceSideWaterOutletTemp = SourceSideWaterInletTemp;
     644           14 :             return;
     645              :         }
     646        35228 :         PlantUtilities::PullCompInterconnectTrigger(state,
     647        35228 :                                                     this->LoadPlantLoc,
     648        35228 :                                                     this->CondMassFlowIndex,
     649        35228 :                                                     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        35228 :     initialQSource = 0.0;
     658        35228 :     initialQLoad = 0.0;
     659        35228 :     IterationCount = 0;
     660              : 
     661              :     CpSourceSide =
     662        35228 :         state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).glycol->getSpecificHeat(state, this->SourceSideWaterInletTemp, RoutineName);
     663              : 
     664        35228 :     CpLoadSide = state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).glycol->getSpecificHeat(state, this->LoadSideWaterInletTemp, RoutineName);
     665              : 
     666              :     // Determine effectiveness of Load Side
     667        35228 :     LoadSideEffect = 1.0 - std::exp(-this->LoadSideUACoeff / (CpLoadSide * this->LoadSideWaterMassFlowRate));
     668              :     // Determine effectiveness of Source Side
     669        35228 :     SourceSideEffect = 1.0 - std::exp(-this->SourceSideUACoeff / (CpSourceSide * this->SourceSideWaterMassFlowRate));
     670              : 
     671              :     // main iteration loop to solve model equations
     672              :     while (true) {
     673       317108 :         ++IterationCount;
     674              : 
     675              :         // To determine Load Side temperature
     676       317108 :         LoadSideRefridgTemp = this->LoadSideWaterInletTemp - initialQLoad / (LoadSideEffect * CpLoadSide * this->LoadSideWaterMassFlowRate);
     677              : 
     678              :         // Determine Source Side tempertaure
     679       317108 :         SourceSideRefridgTemp =
     680       317108 :             this->SourceSideWaterInletTemp + initialQSource / (SourceSideEffect * CpSourceSide * this->SourceSideWaterMassFlowRate);
     681              : 
     682              :         // Determine the evaporating and condensing pressures
     683       317108 :         SourceSidePressure = this->refrig->getSatPressure(state, SourceSideRefridgTemp, RoutineName);
     684       317108 :         LoadSidePressure = this->refrig->getSatPressure(state, LoadSideRefridgTemp, RoutineName);
     685              : 
     686       317108 :         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       317108 :         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       317108 :         SuctionPr = LoadSidePressure - this->CompSucPressDrop;
     707              :         // Determine Discharge Pressure at compressor exit
     708       317108 :         DischargePr = SourceSidePressure + this->CompSucPressDrop;
     709              : 
     710       317108 :         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       317108 :         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       317108 :         qual = 1.0;
     730       317108 :         LoadSideOutletEnth = this->refrig->getSatEnthalpy(state, LoadSideRefridgTemp, qual, RoutineNameLoadSideRefridgTemp);
     731              : 
     732       317108 :         qual = 0.0;
     733       317108 :         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       317108 :         CompressInletTemp = LoadSideRefridgTemp + this->SuperheatTemp;
     738              : 
     739              :         // Determine the enathalpy of the super heated fluid at Source Side outlet
     740       317108 :         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       317108 :         CompSuctionSatTemp = this->refrig->getSatTemperature(state, SuctionPr, RoutineNameSuctionPr);
     749              : 
     750       317108 :         T110 = CompSuctionSatTemp;
     751              :         //            Shoot into the super heated region
     752       317108 :         T111 = CompSuctionSatTemp + 100.0;
     753              :         // Iterate to find the Suction State
     754              :         while (true) {
     755      2789264 :             CompSuctionTemp = 0.5 * (T110 + T111);
     756              : 
     757      2789264 :             CompSuctionEnth = this->refrig->getSupHeatEnthalpy(state, CompSuctionTemp, SuctionPr, RoutineNameCompSuctionTemp);
     758              : 
     759      2789264 :             if (std::abs(CompSuctionEnth - SuperHeatEnth) / SuperHeatEnth < 0.0001) {
     760       317108 :                 goto LOOP_exit;
     761              :             }
     762              : 
     763      2472156 :             if (CompSuctionEnth < SuperHeatEnth) {
     764       729406 :                 T110 = CompSuctionTemp;
     765              :             } else {
     766      1742750 :                 T111 = CompSuctionTemp;
     767              :             }
     768              :         }
     769       317108 :     LOOP_exit:;
     770              : 
     771              :         // Determine the Mass flow rate of refrigerant
     772       317108 :         CompSuctionDensity = this->refrig->getSupHeatDensity(state, CompSuctionTemp, SuctionPr, RoutineNameCompSuctionTemp);
     773       317108 :         MassRef = this->CompPistonDisp * CompSuctionDensity *
     774       317108 :                   (1 + this->CompClearanceFactor - this->CompClearanceFactor * std::pow(DischargePr / SuctionPr, 1 / gamma));
     775              : 
     776              :         // Find the Source Side Heat Transfer
     777              : 
     778       317108 :         this->QLoad = MassRef * (LoadSideOutletEnth - SourceSideOutletEnth);
     779              : 
     780              :         // Determine the theoretical power
     781       317108 :         this->Power = this->PowerLosses + (MassRef * gamma / (gamma - 1) * SuctionPr / CompSuctionDensity / this->LossFactor *
     782       317108 :                                            (std::pow(DischargePr / SuctionPr, (gamma - 1) / gamma) - 1));
     783              : 
     784              :         // Determine the Loadside HeatRate (this->QLoad)
     785       317108 :         this->QSource = this->Power + this->QLoad;
     786              :         // convergence and iteration limit check
     787       317108 :         if (std::abs((this->QSource - initialQSource) / (initialQSource + SmallNum)) < HeatBalTol || IterationCount > IterationLimit) {
     788        35228 :             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        35228 :             goto LOOPSourceEnth_exit;
     803              : 
     804              :         } else { // update load
     805       281880 :             initialQSource += RelaxParam * (this->QSource - initialQSource);
     806       281880 :             initialQLoad += RelaxParam * (this->QLoad - initialQLoad);
     807              :         }
     808              :     }
     809        35228 : LOOPSourceEnth_exit:;
     810              : 
     811              :     // Control Strategy
     812        35228 :     if (std::abs(MyLoad) < this->QLoad) {
     813        35228 :         DutyFactor = std::abs(MyLoad) / this->QLoad;
     814        35228 :         this->QLoad = std::abs(MyLoad);
     815        35228 :         this->Power *= DutyFactor;
     816        35228 :         this->QSource *= DutyFactor;
     817              :         // Determine the Exterior fluid temperature at the Load Side oulet and evaporator outlet...
     818        35228 :         this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp - this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide); // Chilled water
     819        35228 :         this->SourceSideWaterOutletTemp =
     820        35228 :             this->SourceSideWaterInletTemp + this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide); // cooling water
     821        35228 :         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        46511 : void GshpPeCoolingSpecs::update(EnergyPlusData &state)
     830              : {
     831              :     // SUBROUTINE INFORMATION:
     832              :     //       AUTHOR:          Dan Fisher
     833              :     //       DATE WRITTEN:    October 1998
     834              : 
     835        46511 :     if (!this->MustRun) {
     836              :         // set node temperatures
     837        11269 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     838        11269 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     839        11269 :         this->Power = 0.0;
     840        11269 :         this->Energy = 0.0;
     841        11269 :         this->QSource = 0.0;
     842        11269 :         this->QLoad = 0.0;
     843        11269 :         this->QSourceEnergy = 0.0;
     844        11269 :         this->QLoadEnergy = 0.0;
     845        11269 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     846        11269 :         this->SourceSideWaterOutletTemp = state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp;
     847        11269 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     848        11269 :         this->LoadSideWaterOutletTemp = state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp;
     849              : 
     850              :     } else {
     851              :         // set node temperatures
     852        35242 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = this->LoadSideWaterOutletTemp;
     853        35242 :         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        35242 :         Real64 const ReportingConstant = state.dataHVACGlobal->TimeStepSysSec;
     859              : 
     860        35242 :         this->Energy = this->Power * ReportingConstant;
     861        35242 :         this->QSourceEnergy = QSource * ReportingConstant;
     862        35242 :         this->QLoadEnergy = QLoad * ReportingConstant;
     863        35242 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     864        35242 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     865              :     }
     866        46511 : }
     867            0 : void GshpPeCoolingSpecs::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     868              : {
     869            0 : }
     870            3 : void GshpPeCoolingSpecs::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     871              : {
     872            3 : }
     873              : 
     874              : } // namespace EnergyPlus::HeatPumpWaterToWaterCOOLING
        

Generated by: LCOV version 2.0-1