From 134b9e4390c678e58cc2f91058c56e4b6b98babc Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Wed, 3 Feb 2016 11:05:42 -0600 Subject: [PATCH] Add Vertical GroundHX transition --- src/EnergyPlus/GroundHeatExchangers.cc | 150 ++++--------------------- src/EnergyPlus/GroundHeatExchangers.hh | 21 ++-- src/EnergyPlus/PlantLoopEquip.cc | 21 +--- src/EnergyPlus/PlantManager.cc | 6 +- 4 files changed, 38 insertions(+), 160 deletions(-) diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 7dc7721bab3..f0707f57060 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -189,145 +189,39 @@ namespace GroundHeatExchangers { slinkyGLHE.deallocate(); } - void - SimGroundHeatExchangers( - int const typeNum, - std::string const & name, - int & compIndex, - bool const EP_UNUSED( runFlag ), - bool const EP_UNUSED( firstIteration ), - bool const initLoopEquip - ) - { - // SUBROUTINE INFORMATION: - // AUTHOR: Dan Fisher - // DATE WRITTEN: August, 2000 - // MODIFIED Arun Murugappan - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // mananges the simulation of the vertical closed-loop ground heat - // exchangers (GLHE) model - - // METHODOLOGY EMPLOYED: - - // REFERENCES: - // Eskilson, P. 'Thermal Analysis of Heat Extraction Boreholes' Ph.D. Thesis: - // Dept. of Mathematical Physics, University of Lund, Sweden, June 1987. - // Yavuzturk, C., J.D. Spitler. 1999. 'A Short Time Step Response Factor Model - // for Vertical Ground Loop Heat Exchangers. ASHRAE Transactions. 105(2): 475-485. - - // USE STATEMENTS: - - // Using/Aliasing - using InputProcessor::FindItemInList; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS: - // na - - // DERIVED TYPE DEFINITIONS: - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + void GLHEBase::onInitLoopEquip( const PlantLocation & EP_UNUSED( calledFromLocation ) ) { + this->initGLHESimVars(); + } - int GLHENum; + void GLHEBase::simulate( const PlantLocation & EP_UNUSED(calledFromLocation), bool const EP_UNUSED(FirstHVACIteration), Real64 & EP_UNUSED( CurLoad ) ) { + this->initGLHESimVars(); + this->calcGroundHeatExchanger(); + this->updateGHX(); + } - //GET INPUT + PlantComponent * GLHEBase::factory( int const objectType, std::string objectName ) { if ( GetInput ) { GetGroundHeatExchangerInput(); GetInput = false; } - - if ( typeNum == DataPlant::TypeOf_GrndHtExchgVertical ) { - - // Find the correct GLHE - if ( compIndex == 0 ) { - Array1D< std::string > tmpNames( numVerticalGLHEs ); - for ( int i = 1; i <= numVerticalGLHEs; ++i ) { - tmpNames( i ) = verticalGLHE( i ).Name; - } - GLHENum = FindItemInList( name, tmpNames, numVerticalGLHEs ); - if ( GLHENum == 0 ) { - ShowFatalError( "SimGroundHeatExchangers: Unit not found=" + name ); - } - compIndex = GLHENum; - } else { - GLHENum = compIndex; - if ( GLHENum > numVerticalGLHEs || GLHENum < 1 ) { - ShowFatalError( "SimGroundHeatExchangers: Invalid compIndex passed=" + TrimSigDigits( GLHENum ) + ", Number of Units=" + TrimSigDigits( numVerticalGLHEs ) + ", Entered Unit name=" + name ); - } - if ( checkEquipName( GLHENum ) ) { - if ( name != verticalGLHE( GLHENum ).Name ) { - ShowFatalError( "SimGroundHeatExchangers: Invalid compIndex passed=" + TrimSigDigits( numVerticalGLHEs ) + ", Unit name=" + name + ", stored Unit name for that index=" + verticalGLHE( GLHENum ).Name ); - } - checkEquipName( GLHENum ) = false; + if ( objectType == DataPlant::TypeOf_GrndHtExchgVertical ) { + for ( auto & ghx : verticalGLHE ) { + if ( ghx.Name == objectName ) { + return &ghx; } } - - auto & thisGLHE( verticalGLHE( GLHENum ) ); - - if ( initLoopEquip ) { - thisGLHE.initGLHESimVars(); - return; - } - - // Initialize HX - thisGLHE.initGLHESimVars(); - - // Simulat HX - thisGLHE.calcGroundHeatExchanger(); - - // Update HX Report Vars - thisGLHE.updateGHX(); - - } else if ( typeNum == DataPlant::TypeOf_GrndHtExchgSlinky ) { - - // Find the correct GLHE - if ( compIndex == 0 ) { - Array1D< std::string > tmpNames( numSlinkyGLHEs ); - for ( int i = 1; i <= numSlinkyGLHEs; ++i ) { - tmpNames( i ) = slinkyGLHE( i ).Name; - } - GLHENum = FindItemInList( name, tmpNames, numSlinkyGLHEs ); - if ( GLHENum == 0 ) { - ShowFatalError( "SimGroundHeatExchangers: Unit not found=" + name ); - } - compIndex = GLHENum; - } else { - GLHENum = compIndex; - if ( GLHENum > numSlinkyGLHEs || GLHENum < 1 ) { - ShowFatalError( "SimGroundHeatExchangers: Invalid compIndex passed=" + TrimSigDigits( GLHENum ) + ", Number of Units=" + TrimSigDigits( numSlinkyGLHEs ) + ", Entered Unit name=" + name ); + } else if ( objectType == DataPlant::TypeOf_GrndHtExchgSlinky ) { + for ( auto & ghx : slinkyGLHE ) { + if ( ghx.Name == objectName ) { + return &ghx; } - if ( checkEquipName( GLHENum ) ) { - if ( name != slinkyGLHE( GLHENum ).Name ) { - ShowFatalError( "SimGroundHeatExchangers: Invalid compIndex passed=" + TrimSigDigits( numSlinkyGLHEs ) + ", Unit name=" + name + ", stored Unit name for that index=" + slinkyGLHE( GLHENum ).Name ); - } - checkEquipName( GLHENum ) = false; - } - } - - auto & thisGLHE( slinkyGLHE( GLHENum ) ); - - if ( initLoopEquip ) { - thisGLHE.initGLHESimVars(); - return; } - - // Initialize HX - thisGLHE.initGLHESimVars(); - - // Simulate HX - thisGLHE.calcGroundHeatExchanger(); - - // Update HX Report Vars - thisGLHE.updateGHX(); } + // If we didn't find it, fatal + ShowFatalError( "Ground Heat Exchanger Factory: Error getting inputs for GHX named: " + objectName ); + // Shut up the compiler + return nullptr; } //****************************************************************************** @@ -2245,7 +2139,7 @@ namespace GroundHeatExchangers { InitComponentNodes( 0.0, designMassFlow, inletNodeNum, outletNodeNum, loopNum, loopSideNum, branchNum, compNum ); lastQnSubHr = 0.0; - Node( inletNodeNum ).Temp = this->groundTempModel->getGroundTempAtTimeInSeconds( coilDepth, CurTime ); + Node( inletNodeNum ).Temp = this->groundTempModel->getGroundTempAtTimeInSeconds( coilDepth, CurTime ); Node( outletNodeNum ).Temp = this->groundTempModel->getGroundTempAtTimeInSeconds( coilDepth, CurTime ); // zero out all history arrays diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index c14de602e8e..693b1421605 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -66,6 +66,7 @@ #include #include #include +#include namespace EnergyPlus { @@ -87,10 +88,10 @@ namespace GroundHeatExchangers { // Types - struct GLHEBase + struct GLHEBase : PlantComponent { // Destructor - virtual + virtual ~GLHEBase() {} @@ -210,6 +211,12 @@ namespace GroundHeatExchangers { virtual void getAnnualTimeConstant()=0; + void onInitLoopEquip( const PlantLocation & EP_UNUSED( calledFromLocation ) ); + + void simulate( const PlantLocation & calledFromLocation, bool const FirstHVACIteration, Real64 & CurLoad ); + + static PlantComponent * factory( int const objectType, std::string objectName ); + }; struct GLHEVert:GLHEBase @@ -403,16 +410,6 @@ namespace GroundHeatExchangers { void clear_state(); - void - SimGroundHeatExchangers( - int const GLHETypeNum, - std::string const & name, - int & compIndex, - bool const runFlag, - bool const firstIteration, - bool const initLoopEquip - ); - void GetGroundHeatExchangerInput(); diff --git a/src/EnergyPlus/PlantLoopEquip.cc b/src/EnergyPlus/PlantLoopEquip.cc index 91642ad70ac..f19cddf4973 100644 --- a/src/EnergyPlus/PlantLoopEquip.cc +++ b/src/EnergyPlus/PlantLoopEquip.cc @@ -232,7 +232,6 @@ namespace PlantLoopEquip { using ICEngineElectricGenerator::SimICEPlantHeatRecovery; using CTElectricGenerator::SimCTPlantHeatRecovery; using MicroturbineElectricGenerator::SimMTPlantHeatRecovery; - using SurfaceGroundHeatExchanger::SimSurfaceGroundHeatExchanger; using PondGroundHeatExchanger::SimPondGroundHeatExchanger; using PlantLoadProfile::SimulatePlantProfile; @@ -802,19 +801,10 @@ namespace PlantLoopEquip { } else if ( GeneralEquipType == GenEquipTypes_GroundHeatExchanger ) { if ( EquipTypeNum == TypeOf_GrndHtExchgVertical ) { // 'GROUND HEAT EXCHANGER:VERTICAL' - //sim_component.compPtr->simulate( sim_component_location, FirstHVACIteration, CurLoad ); - GroundHeatExchangers::SimGroundHeatExchangers( sim_component.TypeOf_Num, sim_component.Name, EquipNum, RunFlag, FirstHVACIteration, InitLoopEquip ); //DSU - - if ( InitLoopEquip ) { - sim_component.CompNum = EquipNum; - } + sim_component.compPtr->simulate( sim_component_location, FirstHVACIteration, CurLoad ); } else if ( EquipTypeNum == TypeOf_GrndHtExchgSurface ) { // 'GROUND HEAT EXCHANGER:SURFACE' - SimSurfaceGroundHeatExchanger( sim_component.Name, EquipNum, FirstHVACIteration, RunFlag, InitLoopEquip ); //DSU - - if ( InitLoopEquip ) { - sim_component.CompNum = EquipNum; - } + sim_component.compPtr->simulate( sim_component_location, FirstHVACIteration, CurLoad ); } else if ( EquipTypeNum == TypeOf_GrndHtExchgPond ) { // 'GROUND HEAT EXCHANGER:POND' SimPondGroundHeatExchanger( sim_component.Name, EquipNum, FirstHVACIteration, RunFlag, InitLoopEquip, MaxLoad, MinLoad, OptLoad ); //DSU @@ -835,12 +825,7 @@ namespace PlantLoopEquip { } } else if ( EquipTypeNum == TypeOf_GrndHtExchgSlinky ) { // 'GROUND HEAT EXCHANGER:SLINKY' - //sim_component.compPtr->simulate( sim_component_location, FirstHVACIteration, CurLoad ); - GroundHeatExchangers::SimGroundHeatExchangers( sim_component.TypeOf_Num, sim_component.Name, EquipNum, RunFlag, FirstHVACIteration, InitLoopEquip ); - - if ( InitLoopEquip ) { - sim_component.CompNum = EquipNum; - } + sim_component.compPtr->simulate( sim_component_location, FirstHVACIteration, CurLoad ); } diff --git a/src/EnergyPlus/PlantManager.cc b/src/EnergyPlus/PlantManager.cc index 215abf8b9ec..9874f2a8765 100644 --- a/src/EnergyPlus/PlantManager.cc +++ b/src/EnergyPlus/PlantManager.cc @@ -93,6 +93,7 @@ #include #include #include +#include #include #include @@ -1020,11 +1021,12 @@ namespace PlantManager { this_comp.TypeOf_Num = TypeOf_GrndHtExchgVertical; this_comp.GeneralEquipType = GenEquipTypes_GroundHeatExchanger; this_comp.CurOpSchemeType = UncontrolledOpSchemeType; - //this_comp.compPtr = GroundHeatExchangers::GLHEBase::factory( TypeOf_GrndHtExchgVertical, CompNames( CompNum ) ); + this_comp.compPtr = GroundHeatExchangers::GLHEBase::factory( TypeOf_GrndHtExchgVertical, CompNames( CompNum ) ); } else if ( SameString( this_comp_type, "GroundHeatExchanger:Surface" ) ) { this_comp.TypeOf_Num = TypeOf_GrndHtExchgSurface; this_comp.GeneralEquipType = GenEquipTypes_GroundHeatExchanger; this_comp.CurOpSchemeType = UncontrolledOpSchemeType; + this_comp.compPtr = SurfaceGroundHeatExchanger::SurfaceGroundHeatExchangerData::factory( TypeOf_GrndHtExchgSurface, CompNames( CompNum ) ); } else if ( SameString( this_comp_type, "GroundHeatExchanger:Pond" ) ) { this_comp.TypeOf_Num = TypeOf_GrndHtExchgPond; this_comp.GeneralEquipType = GenEquipTypes_GroundHeatExchanger; @@ -1033,7 +1035,7 @@ namespace PlantManager { this_comp.TypeOf_Num = TypeOf_GrndHtExchgSlinky; this_comp.GeneralEquipType = GenEquipTypes_GroundHeatExchanger; this_comp.CurOpSchemeType = UncontrolledOpSchemeType; - //this_comp.compPtr = GroundHeatExchangers::GLHEBase::factory( TypeOf_GrndHtExchgSlinky, CompNames( CompNum ) ); + this_comp.compPtr = GroundHeatExchangers::GLHEBase::factory( TypeOf_GrndHtExchgSlinky, CompNames( CompNum ) ); } else if ( SameString( this_comp_type, "Chiller:Electric:EIR" ) ) { this_comp.TypeOf_Num = TypeOf_Chiller_ElectricEIR; this_comp.GeneralEquipType = GenEquipTypes_Chiller;