Skip to content

Refactor array-based input code to use key-based input (part 2)#11526

Merged
mitchute merged 20 commits intodevelopfrom
no-array-input-part-2
Apr 23, 2026
Merged

Refactor array-based input code to use key-based input (part 2)#11526
mitchute merged 20 commits intodevelopfrom
no-array-input-part-2

Conversation

@jasondegraw
Copy link
Copy Markdown
Member

@jasondegraw jasondegraw commented Apr 14, 2026

Pull request overview

This is a follow-up PR that replaces array-based input code with key-based input code. The first one went well, so full speed ahead. No thought went into the files that were chosen other than to try and limit the scope of changes. The refactor failed in a couple of cases in the sense that the modifications led to numerical diffs (BaseboardElectric) or something went south on a merge (CostEstimateManager), so I yanked those changes back out and will work on them later.

I believe that all of the remaining diffs are related to the order in which things are read in during the input processing. The summary is as follows:

  • MDD: 6
  • MTD: 7
  • Table String Diffs: 5
  • BND: 9
  • RDD: 1
  • EIO: 2

These are the same across the different platforms. Here's a table of the models with the diffs:

Model BND EIO MDD MTD RDD Table String Diffs
5ZoneEndUses
5ZoneGeometryTransform
5ZoneWaterSystems
5ZoneWaterSystems_NoSitePrec
ASHRAE901_OfficeLarge_STD2019_Denver
ASHRAE901_OfficeLarge_STD2019_Denver_Chiller205
ASHRAE901_OfficeLarge_STD2019_Denver_Chiller205_Detailed
ASHRAE901_OfficeLarge_STD2019_Denver_ChillerEIR
AdaptiveThermostatASH55_5Zone_Miami
DOASDualDuctSchool
ExteriorLightsAndEq
HVACTemplate-5ZoneUnitarySystem
HospitalLowEnergy
MicroCogeneration
PCMThermalStorage

Here's the MTD diff for 5ZoneEndUses:

image

and the EIO from MicroCogeneration:

image

All of the items for which a proper diff is included are of this form. The "table string diffs" are nearly the same, except that there isn't enough in the regression download to fully investigate those. Here's a subset of the plain old diff that I did on local runs with this branch versus develop:

image

Same data, different order.

Everything I have checked is the same as these examples. If there's an interest in others I can reproduce them here. One question that came up: why aren't we including more of the table diffs in the download? That would have made checking things out a bit easier.

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
  • 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

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

@jasondegraw jasondegraw added DoNotPublish Includes changes that shouldn't be reported in the changelog Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit d70bfe2

Regression Summary
  • BND: 6

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit d70bfe2

Regression Summary
  • BND: 6

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit c293012

Regression Summary
  • BND: 6

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit c293012

Regression Summary
  • BND: 6

Copy link
Copy Markdown
Collaborator

@amirroth amirroth left a comment

Choose a reason for hiding this comment

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

It's about time we did some of this. Thanks @jasondegraw.

IOStatus);
if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) {
for (auto const &modeInstance : modeInstances.value().items()) {
auto const modeName = Util::makeUPPER(modeInstance.key());
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.

I'm not a fan of using auto for std::string, but in your defense, at least you are using auto and auto & correctly. 🥇

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 1f7281d

Regression Summary
  • MDD: 6
  • MTD: 6
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 1f7281d

Regression Summary
  • MDD: 6
  • MTD: 6
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 194675b

Regression Summary
  • MDD: 6
  • MTD: 6
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 194675b

Regression Summary
  • MDD: 6
  • MTD: 6
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit ef4ddb0

Regression Summary
  • MDD: 6
  • MTD: 7
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit ef4ddb0

Regression Summary
  • MDD: 6
  • MTD: 7
  • Table String Diffs: 5
  • BND: 6
  • RDD: 1
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 79232b4

Regression Summary
  • MDD: 6
  • MTD: 8
  • Table String Diffs: 5
  • BND: 7
  • RDD: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 79232b4

Regression Summary
  • MDD: 6
  • MTD: 8
  • Table String Diffs: 5
  • BND: 7
  • RDD: 1
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 643c082

Regression Summary
  • ERR: 5
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit e97b666

Regression Summary
  • ERR: 5
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 99765f7

Regression Summary
  • ERR: 5
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 10df166

Regression Summary
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 10df166

Regression Summary
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

Something went wrong with the changes to CostEstimateManager.cc,
git was acting funny and I didn't realize something was up until
after a push. So this is the last attempt to fix this one before
I just revert those changes out.
@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 1fe7ea6

Regression Summary
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 1fe7ea6

Regression Summary
  • Table Big Diffs: 43
  • Table String Diffs: 48
  • MDD: 6
  • MTD: 8
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit 2a50b99

Regression Summary
  • MDD: 6
  • MTD: 8
  • Table String Diffs: 5
  • BND: 9
  • RDD: 1
  • EIO: 2

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit 2a50b99

Regression Summary
  • MDD: 6
  • MTD: 8
  • Table String Diffs: 5
  • BND: 9
  • RDD: 1
  • EIO: 2
  • MTR Small Diffs: 1

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on ubuntu-24.04 for commit b29c2f5

Regression Summary
  • MDD: 6
  • MTD: 7
  • Table String Diffs: 5
  • BND: 9
  • RDD: 1
  • EIO: 2

@github-actions
Copy link
Copy Markdown

⚠️ Regressions detected on macos-14 for commit b29c2f5

Regression Summary
  • MDD: 6
  • MTD: 7
  • Table String Diffs: 5
  • BND: 9
  • RDD: 1
  • EIO: 2

if (dehumidObjects != inputProcessor->epJSON.end()) {
for (auto const &dehumidInstance : dehumidObjects.value().items()) {
auto const &dehumidFields = dehumidInstance.value();
auto const dehumidName = Util::makeUPPER(dehumidInstance.key());
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.

I've said this before, not a fan of using auto for "scalar" types like int, Real64 or std::string.

Copy link
Copy Markdown
Member Author

@jasondegraw jasondegraw left a comment

Choose a reason for hiding this comment

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

The modifications here all pretty much follow the same pattern, with some of the modules being a little more convoluted than others. These files are all pretty straightforward, there are more complex cases in the ~140 or so more to go.


#include <EnergyPlus/Data/EnergyPlusData.hh>
#include <EnergyPlus/DataHeatBalance.hh>
#include <EnergyPlus/DataIPShortCuts.hh>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I'll only do comments on the first one since the pattern is all pretty much the same. If possible, remove the use of DataIPShortCuts.

static constexpr std::string_view routineName = "GetHysteresisData";

auto &s_ipsc = state.dataIPShortCut;
auto &s_ip = state.dataInputProcessing->inputProcessor;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The use of shortcuts is largely preserved, added to in some places, but the refactors should largely follow the original intent of the code at hand.

return;
}

for (auto const &hysteresisInstance : hysteresisObjects.value().items()) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's generally going to be a loop like this, and this is where the order is getting changed. The array-based processing is moving through the values differently than the key-based code, and so will register their membership in things like meters, etc. in a different order.


for (auto const &hysteresisInstance : hysteresisObjects.value().items()) {
auto const &hysteresisFields = hysteresisInstance.value();
auto const materialName = Util::makeUPPER(hysteresisInstance.key());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There are some issues that have cropped up with upper/lower casing, and it would be great if we could drop the case insensitivity at some point. I'll argue that it really most meaningful for hand-editing models.

if (mat->hasPCM) {
ShowSevereCustom(
state, eoh, EnergyPlus::format("Material {} already has {} properties defined.", mat->Name, s_ipsc->cCurrentModuleObject));
ShowSevereCustom(state, eoh, EnergyPlus::format("Material {} already has {} properties defined.", mat->Name, currentModuleObject));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have not checked whether all of these checks are really needed. This one looks like it might be, but there are a lot of things now that are caught by the validator and never make it into the input processing code.

matPC->deltaTempFreezingHigh = s_ipsc->rNumericArgs(11);
matPC->peakTempFreezing = s_ipsc->rNumericArgs(12);
matPC->deltaTempFreezingLow = s_ipsc->rNumericArgs(13);
matPC->totalLatentHeat =
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There's generally a big block of lines where the array mining is replaced with the appropriate convenience getter functions.

@jasondegraw jasondegraw marked this pull request as ready for review April 22, 2026 18:42
@jasondegraw jasondegraw requested a review from mitchute April 22, 2026 19:01
@mitchute
Copy link
Copy Markdown
Collaborator

140 or so more to go

Thanks @jasondegraw. Hang in there :)

This one merges next.

@mitchute
Copy link
Copy Markdown
Collaborator

LGTM. Merging.

@mitchute mitchute merged commit 9e4adbc into develop Apr 23, 2026
11 checks passed
@mitchute mitchute deleted the no-array-input-part-2 branch April 23, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DoNotPublish Includes changes that shouldn't be reported in the changelog Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants