diff --git a/src/EnergyPlus/GroundHeatExchangers.cc b/src/EnergyPlus/GroundHeatExchangers.cc index 798e0d273a0..aa99ccf8a38 100644 --- a/src/EnergyPlus/GroundHeatExchangers.cc +++ b/src/EnergyPlus/GroundHeatExchangers.cc @@ -302,6 +302,9 @@ namespace EnergyPlus::GroundHeatExchangers { this->props = GetVertProps(state, UtilityRoutines::MakeUPPERCase(j["ghe_vertical_properties_object_name"])); this->xLoc = j["x_location"]; this->yLoc = j["y_location"]; + this->dl_i = 0.0; + this->dl_ii = 0.0; + this->dl_j = 0.0; } //****************************************************************************** @@ -649,6 +652,11 @@ namespace EnergyPlus::GroundHeatExchangers { [[maybe_unused]] bool const RunFlag) { + if (this->needToSetupOutputVars) { + this->setupOutput(state); + this->needToSetupOutputVars = false; + } + if (state.dataGlobal->KickOffSimulation) { this->initGLHESimVars(state); } else { @@ -2468,59 +2476,6 @@ namespace EnergyPlus::GroundHeatExchangers { inputProcessor->markObjectAsUsed(currObj, objName); state.dataGroundHeatExchanger->verticalGLHE.emplace_back(state, objNameUC, instance); } - - // Set up report variables - for (int GLHENum = 0; GLHENum < state.dataGroundHeatExchanger->numVerticalGLHEs; ++GLHENum) { - auto &thisGLHE(state.dataGroundHeatExchanger->verticalGLHE[GLHENum]); - SetupOutputVariable(state, - "Ground Heat Exchanger Average Borehole Temperature", - OutputProcessor::Unit::C, - thisGLHE.bhTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Heat Transfer Rate", - OutputProcessor::Unit::W, - thisGLHE.QGLHE, "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Inlet Temperature", - OutputProcessor::Unit::C, - thisGLHE.inletTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Outlet Temperature", - OutputProcessor::Unit::C, - thisGLHE.outletTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Mass Flow Rate", - OutputProcessor::Unit::kg_s, - thisGLHE.massFlowRate, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Average Fluid Temperature", - OutputProcessor::Unit::C, - thisGLHE.aveFluidTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Farfield Ground Temperature", - OutputProcessor::Unit::C, - thisGLHE.tempGround, - "System", - "Average", - thisGLHE.name); - } } // SLINKY GLHE @@ -2694,53 +2649,65 @@ namespace EnergyPlus::GroundHeatExchangers { state.dataGroundHeatExchanger->slinkyGLHE.push_back(thisGLHE); } - - // Set up report variables - for (int GLHENum = 0; GLHENum < state.dataGroundHeatExchanger->numSlinkyGLHEs; ++GLHENum) { - auto &thisGLHE(state.dataGroundHeatExchanger->slinkyGLHE[GLHENum]); - SetupOutputVariable(state, - "Ground Heat Exchanger Average Borehole Temperature", - OutputProcessor::Unit::C, - thisGLHE.bhTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable( - state, "Ground Heat Exchanger Heat Transfer Rate", OutputProcessor::Unit::W, thisGLHE.QGLHE, "System", "Average", thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Inlet Temperature", - OutputProcessor::Unit::C, - thisGLHE.inletTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Outlet Temperature", - OutputProcessor::Unit::C, - thisGLHE.outletTemp, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Mass Flow Rate", - OutputProcessor::Unit::kg_s, - thisGLHE.massFlowRate, - "System", - "Average", - thisGLHE.name); - SetupOutputVariable(state, - "Ground Heat Exchanger Average Fluid Temperature", - OutputProcessor::Unit::C, - thisGLHE.aveFluidTemp, - "System", - "Average", - thisGLHE.name); - } } } //****************************************************************************** + void GLHEBase::setupOutput(EnergyPlusData &state) + { + SetupOutputVariable(state, + "Ground Heat Exchanger Average Borehole Temperature", + OutputProcessor::Unit::C, + this->bhTemp, + "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Heat Transfer Rate", + OutputProcessor::Unit::W, + this->QGLHE, "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Inlet Temperature", + OutputProcessor::Unit::C, + this->inletTemp, + "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Outlet Temperature", + OutputProcessor::Unit::C, + this->outletTemp, + "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Mass Flow Rate", + OutputProcessor::Unit::kg_s, + this->massFlowRate, + "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Average Fluid Temperature", + OutputProcessor::Unit::C, + this->aveFluidTemp, + "System", + "Average", + this->name); + SetupOutputVariable(state, + "Ground Heat Exchanger Farfield Ground Temperature", + OutputProcessor::Unit::C, + this->tempGround, + "System", + "Average", + this->name); + } + + //****************************************************************************** + Real64 GLHEVert::calcBHAverageResistance(EnergyPlusData &state) { // Calculates the average thermal resistance of the borehole using the first-order multipole method. diff --git a/src/EnergyPlus/GroundHeatExchangers.hh b/src/EnergyPlus/GroundHeatExchangers.hh index 0d1c3643279..3c041018db1 100644 --- a/src/EnergyPlus/GroundHeatExchangers.hh +++ b/src/EnergyPlus/GroundHeatExchangers.hh @@ -264,13 +264,14 @@ namespace GroundHeatExchangers { int PrevN; // The saved value of N at previous time step bool updateCurSimTime; // Used to reset the CurSimTime to reset after WarmupFlag bool triggerDesignDayReset; + bool needToSetupOutputVars; GLHEBase() : available(false), on(false), loopNum(0), loopSideNum(0), branchNum(0), compNum(0), inletNodeNum(0), outletNodeNum(0), designFlow(0.0), designMassFlow(0.0), tempGround(0.0), prevHour(1), AGG(0), SubAGG(0), bhTemp(0.0), massFlowRate(0.0), outletTemp(0.0), inletTemp(0.0), aveFluidTemp(0.0), QGLHE(0.0), myFlag(true), myEnvrnFlag(true), gFunctionsExist(false), lastQnSubHr(0.0), HXResistance(0.0), totalTubeLength(0.0), timeSS(0.0), timeSSFactor(0.0), firstTime(true), numErrorCalls(0), ToutNew(19.375), PrevN(1), - updateCurSimTime(true), triggerDesignDayReset(false) + updateCurSimTime(true), triggerDesignDayReset(false), needToSetupOutputVars(true) { } @@ -311,6 +312,8 @@ namespace GroundHeatExchangers { virtual void getAnnualTimeConstant() = 0; virtual void initEnvironment(EnergyPlusData &state, Real64 const &CurTime) = 0; + + void setupOutput(EnergyPlusData &state); }; struct GLHEVert : GLHEBase