LCOV - code coverage report
Current view: top level - EnergyPlus - HeatPumpWaterToWaterHEATING.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 331 392 84.4 %
Date: 2023-01-17 19:17:23 Functions: 11 12 91.7 %

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

Generated by: LCOV version 1.13