Skip to content

Commit

Permalink
10065 Var/Const Flow Restructure
Browse files Browse the repository at this point in the history
Created a new subroutine that avoids duplicate code and simplifies slightly the ChillerHeater subroutine.
  • Loading branch information
RKStrand committed Jul 5, 2024
1 parent 8d4db0f commit a19b109
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 55 deletions.
93 changes: 38 additions & 55 deletions src/EnergyPlus/PlantCentralGSHP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2442,34 +2442,8 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state)
// Mode 4 uses all data from the chilled water loop due to no heating demand
if (this->SimulClgDominant || CurrentMode == 3) {
CurrentMode = 3;
Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
CondInletTemp,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
RoutineName);

QCondenser = this->ChillerHeater(ChillerHeaterNum).Report.QCondSimul;

if (this->VariableFlowCH) { // Variable flow
Real64 CondMassFlowRateCalc = QCondenser / CondDeltaTemp / Cp;
if (CondMassFlowRateCalc > CondMassFlowRate) {
CondMassFlowRateCalc = CondMassFlowRate;
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
if (CondDeltaTempCalc > CondDeltaTemp) { // Load to meet should be adjusted
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
}
CondMassFlowRate = CondMassFlowRateCalc;
} else { // Constant flow control
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
Real64 CondOutletTempCalc = CondDeltaTempCalc + CondInletTemp;
if (CondOutletTempCalc > CondOutletTemp) {
CondOutletTempCalc = CondOutletTemp;
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
CondOutletTemp = CondOutletTempCalc;
}

this->adjustChillerHeaterFlowTemp(state, QCondenser, CondMassFlowRate, CondOutletTemp, CondInletTemp, CondDeltaTemp);
} else { // Either Mode 2 or 3 or 5
if (this->SimulHtgDominant) {
CurrentMode = 5;
Expand Down Expand Up @@ -2646,37 +2620,13 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state)
// Set load this chiller heater should meet and temperatures given
QCondenser = min(HeatingLoadToMeet, QCondenser);

Cp = FluidProperties::GetSpecificHeatGlycol(state,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
CondInletTemp,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
RoutineNameElecEIRChiller);

// Calculate temperatures for constant flow and mass flow rate for variable flow
// Limit mass for this chiller heater to the available mass at given temperature conditions
// when mass calculated to meet the load is greater than the maximum available
// Calculate outlet temperature for constant flow and mass flow rate for variable flow
// Limit mass flow rate for this chiller heater to the available mass at given temperature conditions
// when mass flow rate calculated to meet the load is greater than the maximum available
// then recalculate heating load this chiller heater can meet
if (CurrentMode == 2 || this->SimulHtgDominant) {
if (CondMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance && CondDeltaTemp > 0.0) {
if (this->VariableFlowCH) { // Variable flow
Real64 CondMassFlowRateCalc = QCondenser / CondDeltaTemp / Cp;
if (CondMassFlowRateCalc > CondMassFlowRate) {
CondMassFlowRateCalc = CondMassFlowRate;
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
if (CondDeltaTempCalc > CondDeltaTemp) { // Load to meet should be adjusted
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
}
CondMassFlowRate = CondMassFlowRateCalc;
} else { // Constant Flow at a fixed flow rate and capacity
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
Real64 CondOutletTempCalc = CondDeltaTempCalc + CondInletTemp;
if (CondOutletTempCalc > CondOutletTemp) { // Load to meet should be adjusted
CondOutletTempCalc = CondOutletTemp;
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
CondOutletTemp = CondOutletTempCalc;
}
this->adjustChillerHeaterFlowTemp(state, QCondenser, CondMassFlowRate, CondOutletTemp, CondInletTemp, CondDeltaTemp);
} else {
QCondenser = 0.0;
CondOutletTemp = CondInletTemp;
Expand Down Expand Up @@ -2757,6 +2707,39 @@ void WrapperSpecs::CalcChillerHeaterModel(EnergyPlusData &state)
}
}

void WrapperSpecs::adjustChillerHeaterFlowTemp(EnergyPlusData &state, Real64 &QCondenser,
Real64 &CondMassFlowRate, Real64 &CondOutletTemp,
Real64 const CondInletTemp, Real64 const CondDeltaTemp)
{
// Based on whether this is variable or constant flow, adjust either flow or outlet temperature and also the load
static constexpr std::string_view RoutineName("adjustChillerHeaterFlow");
Real64 Cp = FluidProperties::GetSpecificHeatGlycol(state,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidName,
CondInletTemp,
state.dataPlnt->PlantLoop(this->HWPlantLoc.loopNum).FluidIndex,
RoutineName);

if (this->VariableFlowCH) { // Variable Flow (adjust flow and condenser load as needed)
Real64 CondMassFlowRateCalc = QCondenser / CondDeltaTemp / Cp;
if (CondMassFlowRateCalc > CondMassFlowRate) {
CondMassFlowRateCalc = CondMassFlowRate;
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
if (CondDeltaTempCalc > CondDeltaTemp) { // Load to meet should be adjusted
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
}
CondMassFlowRate = CondMassFlowRateCalc;
} else { // Constant Flow (adjust outlet temperature and condenser load as needed)
Real64 CondDeltaTempCalc = QCondenser / CondMassFlowRate / Cp;
Real64 CondOutletTempCalc = CondDeltaTempCalc + CondInletTemp;
if (CondOutletTempCalc > CondOutletTemp) { // Load to meet should be adjusted
CondOutletTempCalc = CondOutletTemp;
QCondenser = CondMassFlowRate * Cp * CondDeltaTemp;
}
CondOutletTemp = CondOutletTempCalc;
}
}

void WrapperSpecs::CalcWrapperModel(EnergyPlusData &state, Real64 &MyLoad, int const LoopNum)
{
// SUBROUTINE INFORMATION:
Expand Down
3 changes: 3 additions & 0 deletions src/EnergyPlus/PlantCentralGSHP.hh
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ namespace PlantCentralGSHP {
void CalcChillerModel(EnergyPlusData &state);

void CalcChillerHeaterModel(EnergyPlusData &state);

void adjustChillerHeaterFlowTemp(EnergyPlusData &state, Real64 &QCondenser, Real64 &CondMassFlowRate,
Real64 &CondOutletTemp, Real64 const CondInletTemp, Real64 const CondDeltaTemp);

void UpdateChillerHeaterRecords(EnergyPlusData &state);

Expand Down

5 comments on commit a19b109

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10065ChillerHeaterMisbehavin (RKStrand) - Win64-Windows-10-VisualStudio-16: OK (2841 of 2841 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10065ChillerHeaterMisbehavin (RKStrand) - x86_64-MacOS-10.18-clang-15.0.0: OK (3630 of 3632 tests passed, 0 test warnings)

Messages:\n

  • 2 tests had: Table big diffs.
  • 2 tests had: Table string diffs.

Failures:\n

regression Test Summary

  • Passed: 788
  • Failed: 2

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10065ChillerHeaterMisbehavin (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3671 of 3673 tests passed, 0 test warnings)

Messages:\n

  • 2 tests had: Table big diffs.
  • 2 tests had: Table string diffs.

Failures:\n

regression Test Summary

  • Passed: 808
  • Failed: 2

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10065ChillerHeaterMisbehavin (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2050 of 2050 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10065ChillerHeaterMisbehavin (RKStrand) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (794 of 794 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.