Skip to content

Fix Coil:Heating:Water energy balance and loop flow issues with constant flow plant loops - #11060

Open
lymereJ wants to merge 16 commits into
developfrom
recalc_t_wtr_out_cycl
Open

lymereJ wants to merge 16 commits into
developfrom
recalc_t_wtr_out_cycl

Conversation

@lymereJ

@lymereJ lymereJ commented May 16, 2025 •

Copy link
Copy Markdown
Collaborator

Pull request overview

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@lymereJ lymereJ added the Defect Includes code to repair a defect in EnergyPlus label May 16, 2025
@lymereJ lymereJ added this to the EnergyPlus 25.2 IO Freeze milestone May 19, 2025
@lymereJ lymereJ closed this May 20, 2025
@lymereJ lymereJ reopened this May 26, 2025
@Myoldmopar

Copy link
Copy Markdown
Member

(@lymereJ my apologies, I pushed a commit to test something out on a branch that causes diffs. If it's acting funny at all, I'll revert it back out in the morning.)

@mitchute

Copy link
Copy Markdown
Collaborator

@lymereJ Is this ready for a closer look?

@lymereJ

lymereJ commented Oct 22, 2025 •

Copy link
Copy Markdown
Collaborator Author

@mitchute - Short answer, no, It's not complete. I'm not sure if I'll have time to get to it before the upcoming release. If we could keep it open, that would be great.

There's another piece to it that I have not pushed yet (I might create a different issue/PR for it) and I'm not sure that I like the proposed changes even though it addresses the issue.

@mitchute mitchute removed this from the EnergyPlus 25.2 milestone Oct 22, 2025
Comment thread src/EnergyPlus/WaterCoils.cc Outdated
if (CapacitanceWater > 0 &&
state.dataPlnt->PlantLoop(waterCoil.WaterPlantLoc.loopNum).LoopSide(DataPlant::LoopSideLocation::Supply).FlowRequest > 0) {
TempWaterOut = TempWaterIn - HeatingCoilLoad / CapacitanceWater;
}

@rraustad rraustad Nov 21, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is hurting my brain a little bit. The concept of cycling fan is that the outlet condition will be full output and the mass flow rate will be averaged based on PLR. For constant fan mass flow is full flow and outlet conditions are averaged. In both cases energy is conserved. So the question is whether air and water mass flow rate is averaged here for cycling fan. At line 2837 and 2838 you see that the air and water flow rate is bumped up to full flow, for LOCAL variables, but the node data still holds the averaged values. So to also average the water outlet temp means that the impact of PLR is applied twice. Why wasn't this also done for outlet air temperature? I think a simple check of air-side energy versus water side energy will show the correct values (i.e., either this was correct before or it's correct now). I think this change breaks the energy conservation rule. Think about line 2905, it's averaging the coil output because it's cycling fan, and HeatingCoilLoad was calculated at full capacity ... using LOCAL adjusted variables for air and water mass flow rate. The outlet water temp, and air temp, in this case should be full capacity output. Also, what the heck does plant FlowRequest have to do with this calculation?

@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Feb 3, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Feb 3, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2c Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2 Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2 Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2 Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from nrel-bot-2 Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@lymereJ lymereJ changed the title Take PLR into account in the calculation of leaving water temperature of Coil:Heating:Water for cycling operations Fix Coil:Heating:Water energy balance and loop flow issues with constant flow plant loops Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
@NatLabRockies NatLabRockies deleted a comment from github-actions Bot Nov 23, 2026
…des, clamp pump minimum flow, set `MinAvail` demand side of series plants and warn for parallel
@github-actions

Copy link
Copy Markdown

⚠️ Regressions detected on macos-15 for commit 2938edc

Regression Summary
  • EIO: 2
  • ESO Small Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 1
  • MTR Small Diffs: 1

@github-actions

Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 27afc87

Regression Summary
  • EIO: 2
  • ESO Small Diffs: 2
  • Table Small Diffs: 2
  • MTR Small Diffs: 1

@github-actions

Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 2938edc

Regression Summary
  • EIO: 2
  • ESO Small Diffs: 2
  • Table Small Diffs: 2
  • MTR Small Diffs: 1

@lymereJ lymereJ left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The new proposed changes are much different than what was originally in this PR. They now cover four main topics and are discussed in the code walk-through below.

The proposed changes address the two issues from #11058 as demonstrated in the plots below:

BlrNotMod_IntPump_MinFlow0 BlrCstFlow_IntPump_MinFlow0 BlrCstFlow_ContPump_MinFlow1

Defect files converted to 27.1: defect_files_27.1.zip

Regression show slight convergence diffs for two files, I ran annual simulations locally and do not see any diffs in reported energy use.

Comment on lines +2878 to +2883
// Water outlet state based on the actual water flow rate through the coil
if (HeatingCoilLoad != 0.0 && waterCoil.InletWaterMassFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
TempWaterOut = TempWaterIn - HeatingCoilLoad / (Cp * waterCoil.InletWaterMassFlowRate);
waterCoil.OutletWaterEnthalpy = waterCoil.InletWaterEnthalpy - HeatingCoilLoad / waterCoil.InletWaterMassFlowRate;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The water outlet temperature and enthalpy are now computed from the PLR-scaled coil load and the actual node water flow. With a cycling fan, the outlet water temperature used to be the full-output value. That's only correct if the node flow is the PLR-averaged flow. When the plant pushes more water through the coil, the water side gave up full-capacity heat while the air received PLR × capacity. When the node flow is the PLR-averaged flow, results are the same as before.

Comment thread src/EnergyPlus/Pumps.cc
Comment on lines -1613 to +1614
if (PumpMassFlowRateMin > PumpMassFlowRateMax) { // the demand side wants to operate outside of the pump range
// shut the pump (and the loop) down
PumpMassFlowRateMin = 0.0;
PumpMassFlowRateMax = 0.0;
// Let the user know that his input file is overconstrained
if (PumpMassFlowRateMin > PumpMassFlowRateMax) { // the demand side cannot accept the pump's minimum flow
PumpMassFlowRateMin = PumpMassFlowRateMax;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When the pump minimum flow exceeds the maximum flow the loop can accept, the minimum is now set to that maximum instead of setting both to zero. Previously, any overshoot shut down the pump and the loop for the whole simulation, silently. This includes overshoots caused only by density conversions of the same design volume flow: the pump uses Constant::InitConvTemp (5.05 °C), while AirLoopHVAC:UnitarySystem sets the coil's maximum water flow using Constant::HWInitConvTemp (60 °C). The pump still shuts off when no flow is available (maximum = 0).

mdot = this->HeatCoilWaterFlowRatio * this->MaxHeatCoilFluidFlow;
}
state.dataLoopNodes->Node(this->HeatCoilFluidInletNode).MassFlowRate = mdot;
PlantUtilities::SetComponentFlowRate(state, mdot, this->HeatCoilFluidInletNode, this->HeatCoilFluidOutletNodeNum, this->HeatCoilPlantLoc);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The water flow request is now set through SetComponentFlowRate instead of being written directly to the coil inlet node. The direct write ignored the plant's flow limits (MinAvail/MaxAvail), so the coil could be simulated with a flow it wasn't receiving.

Comment on lines +1294 to +1336
// Supply side flow exceeds the demand side request and the demand side has no bypass
if (this->plantLoc.loopSideNum == DataPlant::LoopSideLocation::Supply) {
auto &loop = state.dataPlnt->PlantLoop(this->plantLoc.loopNum);
auto &demandSide = loop.LoopSide(DataPlant::LoopSideLocation::Demand);
Real64 const excessFlow = ThisLoopSideFlow - demandSide.flowRequestFinal;
if (!demandSide.BypassExists && loop.CommonPipeType == DataPlant::CommonPipeType::No &&
excessFlow > DataBranchAirLoopPlant::MassFlowTolerance) {
if (!demandSide.Splitter.Exists || demandSide.Splitter.TotalOutletNodes == 1) {
// Series demand side: pass the forced flow as MinAvail so components see the flow they receive
auto &outletNode = state.dataLoopNodes->Node(this->NodeNumOut);
outletNode.MassFlowRateMinAvail = max(outletNode.MassFlowRateMinAvail, min(ThisLoopSideFlow, outletNode.MassFlowRateMaxAvail));
} else if (!state.dataGlobal->WarmupFlag) {
// Parallel demand side branches: forced flow is not passed to the components
if (demandSide.errIndex_ForcedDemandFlow == 0) {
ShowWarningError(state,
std::format("{}=\"{}\": the loop flow rate is greater than the flow rate requested by the demand side "
"components,",
DataPlant::loopTypeNames[static_cast<int>(loop.TypeOfLoop)],
loop.Name));
ShowContinueError(state,
"and the demand side has no bypass branch, so the excess flow is forced through the demand side branches.");
ShowContinueError(state,
"This typically happens when supply side equipment operates at a constant flow rate (e.g., Boiler:HotWater "
"with Boiler Flow Mode = ConstantFlow, or a pump with Pump Control Type = Continuous).");
ShowContinueError(state,
"The results of the demand side components may be inaccurate (e.g., the loop demand may not match the "
"energy delivered by the demand side components). Add a bypass branch on the demand side of the loop.");
ShowContinueErrorTimeStamp(state, "");
}
ShowRecurringWarningErrorAtEnd(state,
std::format("{}=\"{}\": the loop flow rate is greater than the flow rate requested by the "
"demand side components, continues...",
DataPlant::loopTypeNames[static_cast<int>(loop.TypeOfLoop)],
loop.Name),
demandSide.errIndex_ForcedDemandFlow,
excessFlow,
excessFlow,
_,
"[kg/s]",
"[kg/s]");
}
}
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When the supply side drives the loop flow above the demand side's request, for example with a ConstantFlow boiler, and the demand side has no bypass:

  • Series demand side (no splitter, or a single-outlet splitter): the loop flow is passed to the demand side as MinAvail, the same mechanism used for a pump's minimum flow. Demand components are then simulated with the flow they actually receive.
  • Parallel demand branches: the excess flow can't be passed to the individual branches, so a warning is issued suggesting a demand-side bypass.

Comment on lines +2000 to +2014
TEST_F(EnergyPlusFixture, WaterCoils_CyclingHeatingCoil_ConstantFlowBoilerWithoutDemandBypass)
{
ASSERT_TRUE(process_idf(hotWaterLoopWithoutDemandBypassIdf(false)));
SimulationManager::ManageSimulation(*state);
checkHotWaterCoilEnergyBalance(*state);
}

TEST_F(EnergyPlusFixture, WaterCoils_CyclingHeatingCoil_ContinuousPumpWithoutDemandBypass)
{
// pump minimum flow rate (5.05 C density) exceeds the coil maximum flow rate set by the unitary system (60 C density)
ASSERT_TRUE(process_idf(hotWaterLoopWithoutDemandBypassIdf(true)));
SimulationManager::ManageSimulation(*state);
EXPECT_GT(state->dataLoopNodes->Node(state->dataPumps->PumpEquip(1).OutletNodeNum).MassFlowRate, 0.0);
checkHotWaterCoilEnergyBalance(*state);
}

@lymereJ lymereJ Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

New unit tests mimicking the defect files, we check for energy balance between loop and coil.

@github-actions

Copy link
Copy Markdown

⚠️ Regressions detected on macos-15 for commit 27afc87

Regression Summary
  • EIO: 2
  • ESO Small Diffs: 2
  • Table Small Diffs: 2
  • Table String Diffs: 1
  • MTR Small Diffs: 1

@lymereJ
lymereJ marked this pull request as ready for review November 24, 2026 01:32

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Energy imbalance in plant loop when changing component Flow Mode

7 participants