LCOV - code coverage report
Current view: top level - EnergyPlus - HeatPumpWaterToWaterHEATING.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 324 384 84.4 %
Date: 2024-08-23 23:50:59 Functions: 10 11 90.9 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <cmath>
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/string.functions.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/BranchNodeConnections.hh>
      56             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      57             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      58             : #include <EnergyPlus/DataHVACGlobals.hh>
      59             : #include <EnergyPlus/DataLoopNode.hh>
      60             : #include <EnergyPlus/FluidProperties.hh>
      61             : #include <EnergyPlus/General.hh>
      62             : #include <EnergyPlus/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             : 
      83             : // PURPOSE OF THIS MODULE:
      84             : // This module simulates a water to Water Heat Pump (Heating)
      85             : 
      86             : // METHODOLOGY EMPLOYED:
      87             : // This simulation is based on a set of selected parameters,
      88             : // Which are obtained using Parameter Estimation technique.
      89             : 
      90             : // MODULE PARAMETER DEFINITIONS
      91             : std::string const ModuleCompName("HeatPump:WaterToWater:ParameterEstimation:Heating");
      92             : std::string const ModuleCompNameUC("HEATPUMP:WATERTOWATER:PARAMETERESTIMATION:HEATING");
      93             : std::string const GSHPRefrigerant("R22");
      94             : 
      95           6 : GshpPeHeatingSpecs *GshpPeHeatingSpecs::factory(EnergyPlusData &state, const std::string &objectName)
      96             : {
      97           6 :     if (state.dataHPWaterToWaterHtg->GetWWHPHeatingInput) {
      98           3 :         GetGshpInput(state);
      99           3 :         state.dataHPWaterToWaterHtg->GetWWHPHeatingInput = false;
     100             :     }
     101           6 :     auto thisObj = std::find_if(state.dataHPWaterToWaterHtg->GSHP.begin(),
     102           6 :                                 state.dataHPWaterToWaterHtg->GSHP.end(),
     103           6 :                                 [&objectName](const GshpPeHeatingSpecs &myObj) { return myObj.Name == objectName; });
     104           6 :     if (thisObj != state.dataHPWaterToWaterHtg->GSHP.end()) return thisObj;
     105             :     // If we didn't find it, fatal
     106             :     ShowFatalError(state, format("WWHPHeatingFactory: Error getting inputs for heat pump named: {}", objectName)); // LCOV_EXCL_LINE
     107             :     // Shut up the compiler
     108             :     return nullptr; // LCOV_EXCL_LINE
     109             : }
     110             : 
     111       93022 : void GshpPeHeatingSpecs::simulate(
     112             :     EnergyPlusData &state, const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, [[maybe_unused]] bool RunFlag)
     113             : {
     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::HPWaterEFHeating,
     125             :                                                             this->SourceSideInletNodeNum,
     126             :                                                             this->SourceSideOutletNodeNum,
     127       46511 :                                                             -this->QSource,
     128             :                                                             this->SourceSideWaterInletTemp,
     129             :                                                             this->SourceSideWaterOutletTemp,
     130             :                                                             this->SourceSideWaterMassFlowRate,
     131             :                                                             FirstHVACIteration);
     132             :     } else {
     133           0 :         ShowFatalError(state, format("SimHPWatertoWaterHEATING:: Invalid loop connection {}, Requested Unit={}", ModuleCompName, this->Name));
     134             :     }
     135       93022 : }
     136             : 
     137          30 : void GshpPeHeatingSpecs::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 GshpPeHeatingSpecs::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::HPWaterPEHeating,
     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::HPWaterPEHeating, 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->WWHPPlantType, true);
     170           3 :         this->plantScanFlag = false;
     171             :     }
     172          30 : }
     173             : 
     174             : #pragma clang diagnostic push
     175             : #pragma ide diagnostic ignored "readability-magic-numbers"
     176           3 : void GetGshpInput(EnergyPlusData &state)
     177             : {
     178             :     //       SUBROUTINE INFORMATION:
     179             :     //       DATE WRITTEN:    April 1998
     180             : 
     181             :     // PURPOSE OF THIS SUBROUTINE:
     182             :     // This routine will get the input
     183             :     // required by the GSHP models.  As such
     184             :     // it will interact with the Input Scanner to retrieve
     185             :     // information from the input file, count the number of
     186             :     // GSHPs and begin to fill the
     187             :     // arrays associated with the type GSHP.
     188             : 
     189             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     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.dataHPWaterToWaterHtg->NumGSHPs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ModuleCompName);
     199             : 
     200           3 :     if (state.dataHPWaterToWaterHtg->NumGSHPs <= 0) {
     201           0 :         ShowSevereError(state, format("{}: No Equipment found", ModuleCompName));
     202           0 :         ErrorsFound = true;
     203             :     }
     204             : 
     205             :     // Allocate Arrays
     206           3 :     state.dataHPWaterToWaterHtg->GSHP.allocate(state.dataHPWaterToWaterHtg->NumGSHPs);
     207             : 
     208           6 :     for (int GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterHtg->NumGSHPs; ++GSHPNum) {
     209           3 :         auto &thisGSHP = state.dataHPWaterToWaterHtg->GSHP(GSHPNum);
     210           3 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, ModuleCompNameUC, GSHPNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     211             : 
     212           3 :         thisGSHP.Name = AlphArray(1);
     213             : 
     214           3 :         thisGSHP.WWHPPlantType = DataPlant::PlantEquipmentType::HPWaterPEHeating;
     215             : 
     216           3 :         thisGSHP.COP = NumArray(1);
     217           3 :         if (NumArray(1) == 0.0) {
     218           0 :             ShowSevereError(state, format("{}:COP = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     219           0 :             ErrorsFound = true;
     220             :         }
     221             : 
     222             :         // zero values for NumArray 3 - 6 checked in input - idd
     223           3 :         thisGSHP.NomCap = NumArray(2);
     224             : 
     225           3 :         thisGSHP.MinPartLoadRat = NumArray(3);
     226             : 
     227           3 :         thisGSHP.MaxPartLoadRat = NumArray(4);
     228             : 
     229           3 :         thisGSHP.OptPartLoadRat = NumArray(5);
     230             : 
     231           3 :         thisGSHP.LoadSideVolFlowRate = NumArray(6);
     232           3 :         if (NumArray(6) == 0.0) {
     233           0 :             ShowSevereError(state, format("{}:Load Side Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     234           0 :             ErrorsFound = true;
     235             :         }
     236             : 
     237           3 :         thisGSHP.SourceSideVolFlowRate = NumArray(7);
     238           3 :         if (NumArray(7) == 0.0) {
     239           0 :             ShowSevereError(state, format("{}:Source Side Flow Rate = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     240           0 :             ErrorsFound = true;
     241             :         }
     242             : 
     243           3 :         thisGSHP.LoadSideUACoeff = NumArray(8);
     244           3 :         if (NumArray(8) == 0.0) {
     245           0 :             ShowSevereError(state, format("{}:Load Side Heat Transfer Coeffcient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     246           0 :             ErrorsFound = true;
     247             :         }
     248             : 
     249           3 :         thisGSHP.SourceSideUACoeff = NumArray(9);
     250           3 :         if (NumArray(9) == 0.0) {
     251           0 :             ShowSevereError(state, format("{}:Source Side Heat Transfer Coeffcient = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     252           0 :             ErrorsFound = true;
     253             :         }
     254             : 
     255           3 :         thisGSHP.CompPistonDisp = NumArray(10);
     256           3 :         if (NumArray(10) == 0.0) {
     257           0 :             ShowSevereError(state, format("{}:Compressor Piston displacement/Storke = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     258           0 :             ErrorsFound = true;
     259             :         }
     260             : 
     261           3 :         thisGSHP.CompClearanceFactor = NumArray(11);
     262           3 :         if (NumArray(11) == 0.0) {
     263           0 :             ShowSevereError(state, format("{}:Compressor Clearance Factor = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     264           0 :             ErrorsFound = true;
     265             :         }
     266             : 
     267           3 :         thisGSHP.CompSucPressDrop = NumArray(12);
     268           3 :         if (NumArray(12) == 0.0) {
     269           0 :             ShowSevereError(state, format("{}: Pressure Drop = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     270           0 :             ErrorsFound = true;
     271             :         }
     272             : 
     273           3 :         thisGSHP.SuperheatTemp = NumArray(13);
     274           3 :         if (NumArray(13) == 0.0) {
     275           0 :             ShowSevereError(state, format("{}:Source Side SuperHeat = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     276           0 :             ErrorsFound = true;
     277             :         }
     278             : 
     279           3 :         thisGSHP.PowerLosses = NumArray(14);
     280           3 :         if (NumArray(14) == 0.0) {
     281           0 :             ShowSevereError(state, format("{}:Compressor Power Loss = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     282           0 :             ErrorsFound = true;
     283             :         }
     284           3 :         thisGSHP.LossFactor = NumArray(15);
     285           3 :         if (NumArray(15) == 0.0) {
     286           0 :             ShowSevereError(state, format("{}:Efficiency = 0.0, Heatpump={}", ModuleCompName, thisGSHP.Name));
     287           0 :             ErrorsFound = true;
     288             :         }
     289             : 
     290           3 :         thisGSHP.HighPressCutoff = NumArray(16);
     291           3 :         if (NumArray(16) == 0.0) {
     292           3 :             thisGSHP.HighPressCutoff = 500000000.0;
     293             :         }
     294             : 
     295           3 :         thisGSHP.LowPressCutoff = NumArray(17);
     296           3 :         if (NumArray(17) == 0.0) {
     297           3 :             thisGSHP.LowPressCutoff = 0.0;
     298             :         }
     299             : 
     300           3 :         thisGSHP.SourceSideInletNodeNum = GetOnlySingleNode(state,
     301           3 :                                                             AlphArray(2),
     302             :                                                             ErrorsFound,
     303             :                                                             DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationHeating,
     304           3 :                                                             thisGSHP.Name,
     305             :                                                             DataLoopNode::NodeFluidType::Water,
     306             :                                                             DataLoopNode::ConnectionType::Inlet,
     307             :                                                             NodeInputManager::CompFluidStream::Primary,
     308             :                                                             DataLoopNode::ObjectIsNotParent);
     309             : 
     310           3 :         thisGSHP.SourceSideOutletNodeNum = GetOnlySingleNode(state,
     311           3 :                                                              AlphArray(3),
     312             :                                                              ErrorsFound,
     313             :                                                              DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationHeating,
     314           3 :                                                              thisGSHP.Name,
     315             :                                                              DataLoopNode::NodeFluidType::Water,
     316             :                                                              DataLoopNode::ConnectionType::Outlet,
     317             :                                                              NodeInputManager::CompFluidStream::Primary,
     318             :                                                              DataLoopNode::ObjectIsNotParent);
     319             : 
     320           3 :         thisGSHP.LoadSideInletNodeNum = GetOnlySingleNode(state,
     321           3 :                                                           AlphArray(4),
     322             :                                                           ErrorsFound,
     323             :                                                           DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationHeating,
     324           3 :                                                           thisGSHP.Name,
     325             :                                                           DataLoopNode::NodeFluidType::Water,
     326             :                                                           DataLoopNode::ConnectionType::Inlet,
     327             :                                                           NodeInputManager::CompFluidStream::Secondary,
     328             :                                                           DataLoopNode::ObjectIsNotParent);
     329             : 
     330           3 :         thisGSHP.LoadSideOutletNodeNum = GetOnlySingleNode(state,
     331           3 :                                                            AlphArray(5),
     332             :                                                            ErrorsFound,
     333             :                                                            DataLoopNode::ConnectionObjectType::HeatPumpWaterToWaterParameterEstimationHeating,
     334           3 :                                                            thisGSHP.Name,
     335             :                                                            DataLoopNode::NodeFluidType::Water,
     336             :                                                            DataLoopNode::ConnectionType::Outlet,
     337             :                                                            NodeInputManager::CompFluidStream::Secondary,
     338             :                                                            DataLoopNode::ObjectIsNotParent);
     339             : 
     340             :         // Test node sets
     341           3 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(2), AlphArray(3), "Condenser Water Nodes");
     342           3 :         BranchNodeConnections::TestCompSet(state, ModuleCompNameUC, thisGSHP.Name, AlphArray(4), AlphArray(5), "Hot Water Nodes");
     343             : 
     344             :         // save the design source side flow rate for use by plant loop sizing algorithms
     345           3 :         PlantUtilities::RegisterPlantCompDesignFlow(state, thisGSHP.SourceSideInletNodeNum, 0.5 * thisGSHP.SourceSideVolFlowRate);
     346             :     }
     347             : 
     348           3 :     if (ErrorsFound) {
     349           0 :         ShowFatalError(state, format("Errors Found in getting {} Input", ModuleCompNameUC));
     350             :     }
     351             : 
     352           3 :     state.dataHPWaterToWaterHtg->GSHPRefrigIndex = FluidProperties::GetRefrigNum(state, GSHPRefrigerant);
     353           3 :     if (state.dataHPWaterToWaterHtg->GSHPRefrigIndex == 0) {
     354           0 :         ShowFatalError(state, format("Refrigerant for {} not found, should have been={}", ModuleCompName, GSHPRefrigerant));
     355             :     }
     356             : 
     357             :     // CurrentModuleObject='HeatPump:WaterToWater:ParameterEstimation:Heating'
     358           6 :     for (int GSHPNum = 1; GSHPNum <= state.dataHPWaterToWaterHtg->NumGSHPs; ++GSHPNum) {
     359           3 :         auto &thisGSHP = state.dataHPWaterToWaterHtg->GSHP(GSHPNum);
     360           6 :         SetupOutputVariable(state,
     361             :                             "Heat Pump Electricity Rate",
     362             :                             Constant::Units::W,
     363           3 :                             thisGSHP.Power,
     364             :                             OutputProcessor::TimeStepType::System,
     365             :                             OutputProcessor::StoreType::Average,
     366           3 :                             thisGSHP.Name);
     367           6 :         SetupOutputVariable(state,
     368             :                             "Heat Pump Electricity Energy",
     369             :                             Constant::Units::J,
     370           3 :                             thisGSHP.Energy,
     371             :                             OutputProcessor::TimeStepType::System,
     372             :                             OutputProcessor::StoreType::Sum,
     373           3 :                             thisGSHP.Name,
     374             :                             Constant::eResource::Electricity,
     375             :                             OutputProcessor::Group::Plant,
     376             :                             OutputProcessor::EndUseCat::Heating);
     377             : 
     378           6 :         SetupOutputVariable(state,
     379             :                             "Heat Pump Load Side Heat Transfer Rate",
     380             :                             Constant::Units::W,
     381           3 :                             thisGSHP.QLoad,
     382             :                             OutputProcessor::TimeStepType::System,
     383             :                             OutputProcessor::StoreType::Average,
     384           3 :                             thisGSHP.Name);
     385           6 :         SetupOutputVariable(state,
     386             :                             "Heat Pump Load Side Heat Transfer Energy",
     387             :                             Constant::Units::J,
     388           3 :                             thisGSHP.QLoadEnergy,
     389             :                             OutputProcessor::TimeStepType::System,
     390             :                             OutputProcessor::StoreType::Sum,
     391           3 :                             thisGSHP.Name);
     392             : 
     393           6 :         SetupOutputVariable(state,
     394             :                             "Heat Pump Source Side Heat Transfer Rate",
     395             :                             Constant::Units::W,
     396           3 :                             thisGSHP.QSource,
     397             :                             OutputProcessor::TimeStepType::System,
     398             :                             OutputProcessor::StoreType::Average,
     399           3 :                             thisGSHP.Name);
     400           6 :         SetupOutputVariable(state,
     401             :                             "Heat Pump Source Side Heat Transfer Energy",
     402             :                             Constant::Units::J,
     403           3 :                             thisGSHP.QSourceEnergy,
     404             :                             OutputProcessor::TimeStepType::System,
     405             :                             OutputProcessor::StoreType::Sum,
     406           3 :                             thisGSHP.Name);
     407             : 
     408           6 :         SetupOutputVariable(state,
     409             :                             "Heat Pump Load Side Outlet Temperature",
     410             :                             Constant::Units::C,
     411           3 :                             thisGSHP.LoadSideWaterOutletTemp,
     412             :                             OutputProcessor::TimeStepType::System,
     413             :                             OutputProcessor::StoreType::Average,
     414           3 :                             thisGSHP.Name);
     415           6 :         SetupOutputVariable(state,
     416             :                             "Heat Pump Load Side Inlet Temperature",
     417             :                             Constant::Units::C,
     418           3 :                             thisGSHP.LoadSideWaterInletTemp,
     419             :                             OutputProcessor::TimeStepType::System,
     420             :                             OutputProcessor::StoreType::Average,
     421           3 :                             thisGSHP.Name);
     422           6 :         SetupOutputVariable(state,
     423             :                             "Heat Pump Source Side Outlet Temperature",
     424             :                             Constant::Units::C,
     425           3 :                             thisGSHP.SourceSideWaterOutletTemp,
     426             :                             OutputProcessor::TimeStepType::System,
     427             :                             OutputProcessor::StoreType::Average,
     428           3 :                             thisGSHP.Name);
     429           6 :         SetupOutputVariable(state,
     430             :                             "Heat Pump Source Side Inlet Temperature",
     431             :                             Constant::Units::C,
     432           3 :                             thisGSHP.SourceSideWaterInletTemp,
     433             :                             OutputProcessor::TimeStepType::System,
     434             :                             OutputProcessor::StoreType::Average,
     435           3 :                             thisGSHP.Name);
     436           6 :         SetupOutputVariable(state,
     437             :                             "Heat Pump Load Side Mass Flow Rate",
     438             :                             Constant::Units::kg_s,
     439           3 :                             thisGSHP.LoadSideWaterMassFlowRate,
     440             :                             OutputProcessor::TimeStepType::System,
     441             :                             OutputProcessor::StoreType::Average,
     442           3 :                             thisGSHP.Name);
     443           6 :         SetupOutputVariable(state,
     444             :                             "Heat Pump Source Side Mass Flow Rate",
     445             :                             Constant::Units::kg_s,
     446           3 :                             thisGSHP.SourceSideWaterMassFlowRate,
     447             :                             OutputProcessor::TimeStepType::System,
     448             :                             OutputProcessor::StoreType::Average,
     449           3 :                             thisGSHP.Name);
     450             :     }
     451           3 : }
     452             : #pragma clang diagnostic pop
     453             : 
     454       46511 : void GshpPeHeatingSpecs::initialize(EnergyPlusData &state)
     455             : {
     456             : 
     457             :     // SUBROUTINE INFORMATION:
     458             :     //       AUTHOR:          Dan Fisher
     459             :     //       DATE WRITTEN:    July 2007
     460             : 
     461             :     // SUBROUTINE PARAMETER DEFINITIONS:
     462             :     static constexpr std::string_view RoutineName("InitGshp");
     463             : 
     464             :     // For each new environment
     465       46511 :     if (state.dataGlobal->BeginEnvrnFlag && this->beginEnvironFlag) {
     466          18 :         this->QLoad = 0.0;
     467          18 :         this->QSource = 0.0;
     468          18 :         this->Power = 0.0;
     469          18 :         this->QLoadEnergy = 0.0;
     470          18 :         this->QSourceEnergy = 0.0;
     471          18 :         this->Energy = 0.0;
     472          18 :         this->LoadSideWaterInletTemp = 0.0;
     473          18 :         this->SourceSideWaterInletTemp = 0.0;
     474          18 :         this->LoadSideWaterOutletTemp = 0.0;
     475          18 :         this->SourceSideWaterOutletTemp = 0.0;
     476          18 :         this->SourceSideWaterMassFlowRate = 0.0;
     477          18 :         this->LoadSideWaterMassFlowRate = 0.0;
     478          18 :         this->IsOn = false;
     479          18 :         this->MustRun = true;
     480             : 
     481          18 :         this->beginEnvironFlag = false;
     482          18 :         Real64 rho = FluidProperties::GetDensityGlycol(state,
     483          18 :                                                        state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidName,
     484             :                                                        Constant::CWInitConvTemp,
     485          18 :                                                        state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidIndex,
     486             :                                                        RoutineName);
     487          18 :         this->LoadSideDesignMassFlow = this->LoadSideVolFlowRate * rho;
     488             : 
     489          18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->LoadSideDesignMassFlow, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum);
     490             : 
     491          18 :         rho = FluidProperties::GetDensityGlycol(state,
     492          18 :                                                 state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
     493             :                                                 Constant::CWInitConvTemp,
     494          18 :                                                 state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
     495             :                                                 RoutineName);
     496          18 :         this->SourceSideDesignMassFlow = this->SourceSideVolFlowRate * rho;
     497             : 
     498          18 :         PlantUtilities::InitComponentNodes(state, 0.0, this->SourceSideDesignMassFlow, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum);
     499          18 :         if (state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).TempSetPoint == DataLoopNode::SensedNodeFlagValue)
     500          12 :             state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).TempSetPoint = 0.0;
     501          18 :         state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp = state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).TempSetPoint + 30.0;
     502             :     }
     503             : 
     504       46511 :     if (!state.dataGlobal->BeginEnvrnFlag) this->beginEnvironFlag = true;
     505             : 
     506             :     // On every call
     507       46511 :     this->Running = 0;
     508       46511 :     this->MustRun = true;                    // Reset MustRun Flag to TRUE
     509       46511 :     this->LoadSideWaterMassFlowRate = 0.0;   // Load Side mass flow rate, water side
     510       46511 :     this->SourceSideWaterMassFlowRate = 0.0; // Source Side mass flow rate, water side
     511       46511 :     this->Power = 0.0;                       // power consumption
     512       46511 :     this->QLoad = 0.0;                       // heat rejection from Load Side coil
     513       46511 :     this->QSource = 0.0;
     514       46511 : }
     515             : 
     516       46511 : void GshpPeHeatingSpecs::calculate(EnergyPlusData &state, Real64 &MyLoad)
     517             : {
     518             :     // SUBROUTINE INFORMATION:
     519             :     //       AUTHOR
     520             :     //       DATE WRITTEN   Sept. 1998
     521             :     //       MODIFIED       April 1999
     522             :     //                      September 2002, SJR
     523             :     //       RE-ENGINEERED  Mar2000
     524             : 
     525             :     // SUBROUTINE PARAMETER DEFINITIONS:
     526       46511 :     constexpr Real64 gamma(1.114); // Expansion Coefficient
     527       46511 :     constexpr Real64 HeatBalTol(0.0005);
     528       46511 :     constexpr Real64 RelaxParam(0.6);
     529       46511 :     constexpr Real64 SmallNum(1.0e-20);
     530       46511 :     constexpr int IterationLimit(500);
     531       46511 :     constexpr const char *RoutineName("CalcGshpModel");
     532       46511 :     constexpr const char *RoutineNameLoadSideTemp("CalcGSHPModel:LoadSideTemp");
     533       46511 :     constexpr const char *RoutineNameSourceSideTemp("CalcGSHPModel:SourceSideTemp");
     534       46511 :     constexpr const char *RoutineNameCompressInletTemp("CalcGSHPModel:CompressInletTemp");
     535       46511 :     constexpr const char *RoutineNameSuctionPr("CalcGSHPModel:SuctionPr");
     536       46511 :     constexpr const char *RoutineNameCompSuctionTemp("CalcGSHPModel:CompSuctionTemp");
     537             : 
     538             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     539             :     Real64 CompSuctionTemp;
     540             :     Real64 CompSuctionEnth;
     541             :     Real64 CompSuctionDensity;
     542             :     Real64 CompSuctionSatTemp;
     543             :     Real64 DutyFactor;
     544             : 
     545       46511 :     if (MyLoad > 0.0) {
     546       14824 :         this->MustRun = true;
     547       14824 :         this->IsOn = true;
     548             :     } else {
     549       31687 :         this->MustRun = false;
     550       31687 :         this->IsOn = false;
     551             :     }
     552       46511 :     this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     553       46511 :     this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     554             : 
     555             :     //*******Set flow based on "run" flags**********
     556             :     // Set flows if the heat pump is not running
     557       46511 :     if (!this->MustRun) {
     558       31687 :         this->LoadSideWaterMassFlowRate = 0.0;
     559       31687 :         PlantUtilities::SetComponentFlowRate(
     560       31687 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     561       31687 :         this->SourceSideWaterMassFlowRate = 0.0;
     562       31687 :         PlantUtilities::SetComponentFlowRate(
     563       31687 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     564       31687 :         PlantUtilities::PullCompInterconnectTrigger(state,
     565       31687 :                                                     this->LoadPlantLoc,
     566       31687 :                                                     this->CondMassFlowIndex,
     567       31687 :                                                     this->SourcePlantLoc,
     568             :                                                     DataPlant::CriteriaType::MassFlowRate,
     569             :                                                     this->SourceSideWaterMassFlowRate);
     570             :         // now initialize simulation variables for "heat pump off"
     571       31687 :         this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp;
     572       31687 :         this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp;
     573       31687 :         return; // if heat pump is not running return without simulation, power, Q already zeroed in init
     574             :     } else {    // the heat pump must run, request design flow
     575             : 
     576       14824 :         this->LoadSideWaterMassFlowRate = this->LoadSideDesignMassFlow;
     577       14824 :         PlantUtilities::SetComponentFlowRate(
     578       14824 :             state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     579             : 
     580       14824 :         this->SourceSideWaterMassFlowRate = this->SourceSideDesignMassFlow;
     581       14824 :         PlantUtilities::SetComponentFlowRate(
     582       14824 :             state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     583             :         // if there's no flow, turn the "heat pump off"
     584       14824 :         if (this->LoadSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance ||
     585       14823 :             this->SourceSideWaterMassFlowRate < DataBranchAirLoopPlant::MassFlowTolerance) {
     586           2 :             this->LoadSideWaterMassFlowRate = 0.0;
     587           2 :             PlantUtilities::SetComponentFlowRate(
     588           2 :                 state, this->LoadSideWaterMassFlowRate, this->LoadSideInletNodeNum, this->LoadSideOutletNodeNum, this->LoadPlantLoc);
     589           2 :             this->SourceSideWaterMassFlowRate = 0.0;
     590           2 :             PlantUtilities::SetComponentFlowRate(
     591           2 :                 state, this->SourceSideWaterMassFlowRate, this->SourceSideInletNodeNum, this->SourceSideOutletNodeNum, this->SourcePlantLoc);
     592           2 :             PlantUtilities::PullCompInterconnectTrigger(state,
     593           2 :                                                         this->LoadPlantLoc,
     594           2 :                                                         this->CondMassFlowIndex,
     595           2 :                                                         this->SourcePlantLoc,
     596             :                                                         DataPlant::CriteriaType::MassFlowRate,
     597             :                                                         this->SourceSideWaterMassFlowRate);
     598           2 :             this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp;
     599           2 :             this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp;
     600           2 :             return;
     601             :         }
     602       14822 :         PlantUtilities::PullCompInterconnectTrigger(state,
     603       14822 :                                                     this->LoadPlantLoc,
     604       14822 :                                                     this->CondMassFlowIndex,
     605       14822 :                                                     this->SourcePlantLoc,
     606             :                                                     DataPlant::CriteriaType::MassFlowRate,
     607             :                                                     this->SourceSideWaterMassFlowRate);
     608             :     }
     609             : 
     610             :     //***********BEGIN CALCULATION****************
     611             :     // initialize the source and load side heat transfer rates for the simulation
     612       14822 :     Real64 initialQSource = 0.0;
     613       14822 :     Real64 initialQLoad = 0.0;
     614       14822 :     int IterationCount = 0;
     615             : 
     616       29644 :     Real64 CpSourceSide = FluidProperties::GetSpecificHeatGlycol(state,
     617       14822 :                                                                  state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidName,
     618             :                                                                  this->SourceSideWaterInletTemp,
     619       14822 :                                                                  state.dataPlnt->PlantLoop(this->SourcePlantLoc.loopNum).FluidIndex,
     620             :                                                                  RoutineName);
     621             : 
     622       29644 :     Real64 CpLoadSide = FluidProperties::GetSpecificHeatGlycol(state,
     623       14822 :                                                                state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidName,
     624             :                                                                this->LoadSideWaterInletTemp,
     625       14822 :                                                                state.dataPlnt->PlantLoop(this->LoadPlantLoc.loopNum).FluidIndex,
     626             :                                                                RoutineName);
     627             : 
     628             :     // Determine effectiveness of Source Side (the Evaporator in heating mode)
     629       14822 :     Real64 SourceSideEffect = 1.0 - std::exp(-this->SourceSideUACoeff / (CpSourceSide * this->SourceSideWaterMassFlowRate));
     630             :     // Determine effectiveness of Load Side the condenser in heating mode
     631       14822 :     Real64 LoadSideEffect = 1.0 - std::exp(-this->LoadSideUACoeff / (CpLoadSide * this->LoadSideWaterMassFlowRate));
     632             : 
     633             :     while (true) { // main loop to solve model equations
     634      133398 :         ++IterationCount;
     635             :         // Determine Source Side temperature
     636      133398 :         Real64 SourceSideTemp =
     637      133398 :             this->SourceSideWaterInletTemp - initialQSource / (SourceSideEffect * CpSourceSide * this->SourceSideWaterMassFlowRate);
     638             : 
     639             :         // To determine Load Side temperature condenser
     640      133398 :         Real64 LoadSideTemp = this->LoadSideWaterInletTemp + initialQLoad / (LoadSideEffect * CpLoadSide * this->LoadSideWaterMassFlowRate);
     641             : 
     642             :         // Determine the evaporating and condensing pressures
     643      266796 :         Real64 SourceSidePressure = FluidProperties::GetSatPressureRefrig(
     644      133398 :             state, GSHPRefrigerant, SourceSideTemp, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameSourceSideTemp);
     645      266796 :         Real64 LoadSidePressure = FluidProperties::GetSatPressureRefrig(
     646      133398 :             state, GSHPRefrigerant, LoadSideTemp, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameLoadSideTemp);
     647             : 
     648             :         // check cutoff pressures
     649      133398 :         if (SourceSidePressure < this->LowPressCutoff) {
     650           0 :             ShowSevereError(state, format("{}=\"{}\" Heating Source Side Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     651           0 :             ShowContinueError(
     652             :                 state,
     653           0 :                 format("Source Side Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}", SourceSidePressure, this->LowPressCutoff));
     654           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     655             :         }
     656      133398 :         if (LoadSidePressure > this->HighPressCutoff) {
     657           0 :             ShowSevereError(state, format("{}=\"{}\" Heating Load Side Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     658           0 :             ShowContinueError(
     659             :                 state,
     660           0 :                 format("Load Side Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}", LoadSidePressure, this->HighPressCutoff));
     661           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     662             :         }
     663             : 
     664             :         // Determine Suction Pressure at compressor inlet
     665      133398 :         Real64 SuctionPr = SourceSidePressure - this->CompSucPressDrop;
     666             :         // Determine Discharge Pressure at compressor exit
     667      133398 :         Real64 DischargePr = LoadSidePressure + this->CompSucPressDrop;
     668             :         // check cutoff pressures
     669      133398 :         if (SuctionPr < this->LowPressCutoff) {
     670           0 :             ShowSevereError(state, format("{}=\"{}\" Heating Suction Pressure Less than the Design Minimum", ModuleCompName, this->Name));
     671           0 :             ShowContinueError(
     672           0 :                 state, format("Heating Suction Pressure={:.2T} and user specified Design Minimum Pressure={:.2T}", SuctionPr, this->LowPressCutoff));
     673           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     674             :         }
     675      133398 :         if (DischargePr > this->HighPressCutoff) {
     676           0 :             ShowSevereError(state, format("{}=\"{}\" Heating Discharge Pressure greater than the Design Maximum", ModuleCompName, this->Name));
     677           0 :             ShowContinueError(
     678             :                 state,
     679           0 :                 format("Heating Discharge Pressure={:.2T} and user specified Design Maximum Pressure={:.2T}", DischargePr, this->HighPressCutoff));
     680           0 :             ShowFatalError(state, "Preceding Conditions cause termination.");
     681             :         }
     682             : 
     683             :         // Determine the Source Side Outlet Enthalpy
     684      133398 :         Real64 qualOne = 1.0;
     685      266796 :         Real64 SourceSideOutletEnth = FluidProperties::GetSatEnthalpyRefrig(
     686      133398 :             state, GSHPRefrigerant, SourceSideTemp, qualOne, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameSourceSideTemp);
     687             : 
     688             :         // Determine Load Side Outlet Enthalpy
     689      133398 :         Real64 qualZero = 0.0;
     690      266796 :         Real64 LoadSideOutletEnth = FluidProperties::GetSatEnthalpyRefrig(
     691      133398 :             state, GSHPRefrigerant, LoadSideTemp, qualZero, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameLoadSideTemp);
     692             : 
     693             :         // Determine superheated temperature of the Source Side outlet/compressor inlet
     694      133398 :         Real64 CompressInletTemp = SourceSideTemp + this->SuperheatTemp;
     695             :         // Determine the enathalpy of the super heated fluid at Source Side outlet
     696      266796 :         Real64 SuperHeatEnth = FluidProperties::GetSupHeatEnthalpyRefrig(state,
     697             :                                                                          GSHPRefrigerant,
     698             :                                                                          CompressInletTemp,
     699             :                                                                          SourceSidePressure,
     700      133398 :                                                                          state.dataHPWaterToWaterHtg->GSHPRefrigIndex,
     701             :                                                                          RoutineNameCompressInletTemp);
     702             : 
     703             :         // Determining the suction state of the fluid from inlet state involves interation
     704             :         // Method employed...
     705             :         // Determine the saturated temp at suction pressure, shoot out into the superheated region find the enthalpy
     706             :         // check that with the inlet enthalpy ( as suction loss is isenthalpic). Iterate till desired accuracy is reached
     707             : 
     708      266796 :         CompSuctionSatTemp = FluidProperties::GetSatTemperatureRefrig(
     709      133398 :             state, GSHPRefrigerant, SuctionPr, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameSuctionPr);
     710             : 
     711      133398 :         Real64 T110 = CompSuctionSatTemp;
     712             :         // Shoot into the super heated region
     713      133398 :         Real64 T111 = CompSuctionSatTemp + 80;
     714             : 
     715             :         // Iterate to find the Suction State - given suction pressure and superheat enthalpy
     716             :         while (true) {
     717     1250552 :             CompSuctionTemp = 0.5 * (T110 + T111);
     718             : 
     719     2501104 :             CompSuctionEnth = FluidProperties::GetSupHeatEnthalpyRefrig(
     720     1250552 :                 state, GSHPRefrigerant, CompSuctionTemp, SuctionPr, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameCompSuctionTemp);
     721     1250552 :             if (std::abs(CompSuctionEnth - SuperHeatEnth) / SuperHeatEnth < 0.0001) {
     722      133398 :                 break;
     723             :             }
     724             : 
     725     1117154 :             if (CompSuctionEnth < SuperHeatEnth) {
     726      486246 :                 T110 = CompSuctionTemp;
     727             :             } else {
     728      630908 :                 T111 = CompSuctionTemp;
     729             :             }
     730             :         }
     731             : 
     732             :         // Determine the Mass flow rate of refrigerant
     733      266796 :         CompSuctionDensity = FluidProperties::GetSupHeatDensityRefrig(
     734      133398 :             state, GSHPRefrigerant, CompSuctionTemp, SuctionPr, state.dataHPWaterToWaterHtg->GSHPRefrigIndex, RoutineNameCompSuctionTemp);
     735      133398 :         Real64 MassRef = this->CompPistonDisp * CompSuctionDensity *
     736      133398 :                          (1.0 + this->CompClearanceFactor - this->CompClearanceFactor * std::pow(DischargePr / SuctionPr, 1.0 / gamma));
     737             : 
     738             :         // Find the  Source Side Heat Transfer
     739      133398 :         this->QSource = MassRef * (SourceSideOutletEnth - LoadSideOutletEnth);
     740             : 
     741             :         // Determine the theoretical power
     742      133398 :         this->Power = this->PowerLosses + (MassRef * gamma / (gamma - 1) * SuctionPr / CompSuctionDensity / this->LossFactor *
     743      133398 :                                            (std::pow(DischargePr / SuctionPr, (gamma - 1) / gamma) - 1));
     744             : 
     745             :         // Determine the Loadside HeatRate (QLoad)
     746      133398 :         this->QLoad = this->Power + this->QSource;
     747             : 
     748             :         // convergence and iteration limit check
     749      133398 :         if (std::abs((this->QLoad - initialQLoad) / (initialQLoad + SmallNum)) < HeatBalTol || IterationCount > IterationLimit) {
     750       14822 :             if (IterationCount > IterationLimit) {
     751           0 :                 ShowWarningError(state, format("{} did not converge", ModuleCompName));
     752           0 :                 ShowContinueErrorTimeStamp(state, "");
     753           0 :                 ShowContinueError(state, format("Heatpump Name = {}", this->Name));
     754           0 :                 ShowContinueError(
     755             :                     state,
     756           0 :                     format("Heat Inbalance (%)             = {:S}", std::abs(100.0 * (this->QLoad - initialQLoad) / (initialQLoad + SmallNum))));
     757           0 :                 ShowContinueError(state, format("Load-side heat transfer rate   = {:S}", this->QLoad));
     758           0 :                 ShowContinueError(state, format("Source-side heat transfer rate = {:S}", this->QSource));
     759           0 :                 ShowContinueError(state, format("Source-side mass flow rate     = {:S}", this->SourceSideWaterMassFlowRate));
     760           0 :                 ShowContinueError(state, format("Load-side mass flow rate       = {:S}", this->LoadSideWaterMassFlowRate));
     761           0 :                 ShowContinueError(state, format("Source-side inlet temperature  = {:S}", this->SourceSideWaterInletTemp));
     762           0 :                 ShowContinueError(state, format("Load-side inlet temperature    = {:S}", this->LoadSideWaterInletTemp));
     763             :             }
     764       14822 :             goto LOOPLoadEnth_exit;
     765             : 
     766             :         } else { // update load
     767      118576 :             initialQLoad += RelaxParam * (this->QLoad - initialQLoad);
     768      118576 :             initialQSource += RelaxParam * (this->QSource - initialQSource);
     769             :         }
     770      118576 :     }
     771       14822 : LOOPLoadEnth_exit:;
     772             : 
     773             :     // Control Strategy
     774       14822 :     if (std::abs(MyLoad) < this->QLoad) {
     775       14822 :         DutyFactor = std::abs(MyLoad) / this->QLoad;
     776       14822 :         this->QLoad = std::abs(MyLoad);
     777       14822 :         this->Power *= DutyFactor;
     778       14822 :         this->QSource *= DutyFactor;
     779             : 
     780             :         // Determine the Exterior fluid temperature at the Load Side oulet and eveporator outlet...
     781             :         // Refrigerant = "Steam"
     782       14822 :         this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp + this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide);
     783       14822 :         this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp - this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide);
     784       14822 :         return;
     785             :     }
     786             : 
     787           0 :     this->LoadSideWaterOutletTemp = this->LoadSideWaterInletTemp + this->QLoad / (this->LoadSideWaterMassFlowRate * CpLoadSide);
     788           0 :     this->SourceSideWaterOutletTemp = this->SourceSideWaterInletTemp - this->QSource / (this->SourceSideWaterMassFlowRate * CpSourceSide);
     789             :     // REPORT VAR
     790           0 :     this->Running = 1;
     791             : }
     792             : 
     793       46511 : void GshpPeHeatingSpecs::update(EnergyPlusData &state)
     794             : {
     795             :     // SUBROUTINE INFORMATION:
     796             :     //       AUTHOR:          Dan Fisher
     797             :     //       DATE WRITTEN:    October 1998
     798             : 
     799       46511 :     if (!this->MustRun) {
     800             :         // set node temperatures
     801       31687 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     802       31687 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     803       31687 :         this->Power = 0.0;
     804       31687 :         this->Energy = 0.0;
     805       31687 :         this->QSource = 0.0;
     806       31687 :         this->QLoad = 0.0;
     807       31687 :         this->QSourceEnergy = 0.0;
     808       31687 :         this->QLoadEnergy = 0.0;
     809       31687 :         this->SourceSideWaterInletTemp = state.dataLoopNodes->Node(this->SourceSideInletNodeNum).Temp;
     810       31687 :         this->SourceSideWaterOutletTemp = state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp;
     811       31687 :         this->LoadSideWaterInletTemp = state.dataLoopNodes->Node(this->LoadSideInletNodeNum).Temp;
     812       31687 :         this->LoadSideWaterOutletTemp = state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp;
     813             : 
     814             :     } else {
     815             :         // set node temperatures
     816       14824 :         state.dataLoopNodes->Node(this->LoadSideOutletNodeNum).Temp = this->LoadSideWaterOutletTemp;
     817       14824 :         state.dataLoopNodes->Node(this->SourceSideOutletNodeNum).Temp = this->SourceSideWaterOutletTemp;
     818             : 
     819             :         // set node flow rates;  for these load based models
     820             :         // assume that the sufficient Source Side flow rate available
     821             : 
     822       14824 :         Real64 const ReportingConstant = state.dataHVACGlobal->TimeStepSysSec;
     823             : 
     824       14824 :         this->Energy = this->Power * ReportingConstant;
     825       14824 :         this->QSourceEnergy = QSource * ReportingConstant;
     826       14824 :         this->QLoadEnergy = QLoad * ReportingConstant;
     827             :     }
     828       46511 : }
     829           0 : void GshpPeHeatingSpecs::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     830             : {
     831           0 : }
     832           3 : void GshpPeHeatingSpecs::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     833             : {
     834           3 : }
     835             : 
     836             : } // namespace EnergyPlus::HeatPumpWaterToWaterHEATING

Generated by: LCOV version 1.14