Skip to content

Correct bad index for ZoneList Sensible cooling/heating rate/energy reports#11324

Merged
mitchute merged 3 commits intodevelopfrom
11323-zone-index-for-zoneList
Nov 7, 2025
Merged

Correct bad index for ZoneList Sensible cooling/heating rate/energy reports#11324
mitchute merged 3 commits intodevelopfrom
11323-zone-index-for-zoneList

Conversation

@rraustad
Copy link
Collaborator

@rraustad rraustad commented Nov 6, 2025

Pull request overview

Description of the purpose of this PR

Incorrect zone multiplier used for ZoneList reporting. Affected ZoneList reports are:

Zone List Sensible Cooling Rate
Zone List Sensible Heating Rate
Zone List Sensible Cooling Energy
Zone List Sensible Heating Energy

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
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

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

@rraustad rraustad added the Defect Includes code to repair a defect in EnergyPlus label Nov 6, 2025
@rraustad
Copy link
Collaborator Author

rraustad commented Nov 6, 2025

This is ripe for a unit test.


// switch the zone index order in the ZoneList
state->dataHeatBal->ZoneList(1).Zone(1) = 2;
state->dataHeatBal->ZoneList(1).Zone(2) = 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unit test fails, starting here, in develop if 1-line code change in HVACManager is reverted.

@rraustad rraustad changed the title Correct bad index for ZoneList reports Correct bad index for ZoneList ;p0]|reports Nov 7, 2025
@rraustad rraustad changed the title Correct bad index for ZoneList ;p0]|reports Correct bad index for ZoneList total cooling/heating rate/energy reports Nov 7, 2025
for (ZoneNum = 1; ZoneNum <= zoneList.NumOfZones; ++ZoneNum) {
auto const &zoneSysEnergyDemand = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(zoneList.Zone(ZoneNum));
Mult = state.dataHeatBal->Zone(ZoneNum).Multiplier;
Mult = state.dataHeatBal->Zone(zoneList.Zone(ZoneNum)).Multiplier;
Copy link
Collaborator Author

@rraustad rraustad Nov 7, 2025

Choose a reason for hiding this comment

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

ZoneNum is the ZoneList index, not the Zone index. So the zone multiplier was not correctly applied to the corresponding energy delivered to the zones in the ZoneList. Specifically this energy (where the reports apply the zone multiplier in this function):

    // SNLOAD is the single zone load, without Zone Multiplier or Zone List Multiplier
    SNLoad = ZoneEnthalpyIn - (thisSystemNode.MassFlowRate / ZoneMult) * CpAir * thisSystemNode.Temp + this->NonAirSystemResponse / ZoneMult +
             this->SysDepZoneLoadsLagged;

    state.dataZoneEnergyDemand->ZoneSysEnergyDemand(zoneNum).reportZoneAirSystemSensibleLoads(state, SNLoad);

void ZoneSystemSensibleDemand::reportZoneAirSystemSensibleLoads(EnergyPlusData &state, Real64 const SNLoad)
{
    this->airSysHeatRate = max(SNLoad, 0.0);
    this->airSysCoolRate = std::abs(min(SNLoad, 0.0));
    this->airSysHeatEnergy = this->airSysHeatRate * state.dataHVACGlobal->TimeStepSysSec;
    this->airSysCoolEnergy = this->airSysCoolRate * state.dataHVACGlobal->TimeStepSysSec;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

ZoneNum is the ZoneList index, not the Zone index.

I'm curious if there are reasons why they should not be the same?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mind. I see it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

ZoneNum is the ZoneList index, not the Zone index.

I'm curious if there are reasons why they should not be the same?

The naming is poor. The loop index ZoneNum should really be something like ZoneListItemNum . The actual zone numbers are contained in the zoneList.

Another way to fix this is to use a range-based loop.
for (int const ZoneNum : zoneList.Zone) {
That's assuming the zoneList.Zone arrays are right-sized and not padded on the end.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, @mjwitte. May be a good place for a quick tidy-up task.

Copy link
Collaborator Author

@rraustad rraustad Nov 7, 2025

Choose a reason for hiding this comment

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

It's a right sized array.

// List of zones
state.dataHeatBal->ZoneList(ListNum).NumOfZones = NumAlphas - 1;
state.dataHeatBal->ZoneList(ListNum).Zone.allocate(state.dataHeatBal->ZoneList(ListNum).NumOfZones);

ZoneList,
   \extensible:1 - repeat last field, remembering to remove ; from "inner" fields.
A1 , \field Name
   \note Name of the ZoneList.
A2 , \field Zone 1 Name
   \begin-extensible
A3 , \field Zone 2 Name

@mitchute
Copy link
Collaborator

mitchute commented Nov 7, 2025

Looks good. Merging.

@mitchute mitchute merged commit b610acc into develop Nov 7, 2025
11 checks passed
@mitchute mitchute deleted the 11323-zone-index-for-zoneList branch November 7, 2025 20:10
@rraustad rraustad changed the title Correct bad index for ZoneList total cooling/heating rate/energy reports Correct bad index for ZoneList Sensible cooling/heating rate/energy reports Nov 7, 2025
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.

Incorrect zone index used for ZoneList in HVACManager

6 participants