Skip to content

Conversation

RKStrand
Copy link
Contributor

@RKStrand RKStrand commented Aug 12, 2025

Pull request overview

Description of the purpose of this PR

A user noted that an error message was being produced by EnergyPlus that indicated that some of the input for AirFlowNetwork inputs were not in the correct order. EnergyPlus has always functioned within the concept of the input can be in any order. So, this violated that principle. While there is an internal requirement within AFN that the first encountered Linkage object has a node that is connected to actual E+ HVAC equipment, this can be accommodated without enforcing that the input be in a particular order. This solution fixes the problem by searching throughout the data that has been read from input (now using JSON directly) until it finds an AirLoopNum that pertains to the air flow network. In testing, very tiny differences were noted in some sizing results. A unit test verifies the fix and several existing unit tests that used hard-wired indices for making comparisons were adjusted since the input is read in a slightly different order now.

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

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

The input for AirflowNetwork:Distribution:Linkage objects required that the first instance had a node that was an EnergyPlus node rather than just a node within the AFN.  Thus, the input was order dependent--something that E+ says it's not.  This fix reorders the reading of the input object so that the first one it reads is now one that has an EnergyPlus node.  The user input file that previously received a severe/fatal now runs successfully and has output that matches a version of the input file where the objects didn't violate the order issue.
A unit test was created to test the new integer function that determines the shift in input.  In addition, since the order of the AFN linkage statements is now changed internally, several of the unit tests for AFN had to have hard-wired indices adjusted to reflect the new order.
@RKStrand RKStrand added this to the EnergyPlus 25.2 milestone Aug 12, 2025
@RKStrand RKStrand self-assigned this Aug 12, 2025
@RKStrand RKStrand added the Defect Includes code to repair a defect in EnergyPlus label Aug 12, 2025
Reordering caused some crashes in ci and this revealed that the new subroutine was missing a condition.  This was fixed, the new unit test was modified/strengthened, and the existing unit tests that were changed in the last commit were backed out.
}
}
return shiftResult;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This just looks like it's finding the first AirflowNetwork:Distribution:Linkage that matches one of the AirflowNetwork:Distribution:Node objects and then reading the AirflowNetwork:Distribution:Linkage objects in order. I don't know how that aligns these objects in some manner or how this works for other random orders of AirflowNetwork:Distribution:Linkage objects so I can't comment more. I would ask that @jasondegraw look at this.

Copy link
Member

@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 issue does appear to be legitimate, and this PR does appear to fix the issue, but it's adding additional array-based input processing. I hate to be "that guy", but this really needs to be done with the JSON-based input processing, otherwise it'll have to be redone later.

@RKStrand
Copy link
Contributor Author

@jasondegraw I have a question regarding your comment about this needing to be done in JSON as well. Now, I'll be the first to admit that I'm not 100% up to speed on JSON yet, so if this question is dumb, at least you'll know why. Since this fix does not alter in any way reading the data from JSON or the IDF but simply looks at what was contained in the input file, how will the input file format matter? Isn't the get object routine simply going to one or the other but the data inside E+ is the same? Otherwise, wouldn't every object have two different paths? So, if this fix is simply looking at what has already been read in and then simply choosing to process the already read data into local arrays in a slightly different order, what does it matter whether the data came from a JSON file or an IDF? I understand the concept of not wanting to have to come back and redo this later, but given what I am proposing to do here, I don't comprehend why this would need to be redone later. Of course, I might not understand something about what JSON is doing. Thanks for your feedback.

@Myoldmopar
Copy link
Member

It's a valid request from @jasondegraw and a fine response from @RKStrand . I'll try to clarify a bit.

Right now, EnergyPlus accepts input files in traditional IDF, or JSON (or some binary formats as well). Once inside EnergyPlus, the data is actually processed into a JSON-like object for any processing. Right now input processing routines can either:

  • Read directly off the internal JSON-style key-value representation. You can see various examples of this around the code, and it looks like this:
    this->soil.k = j["soil_thermal_conductivity"].get<Real64>();
    this->soil.rho = j["soil_density"].get<Real64>();
    this->soil.cp = j["soil_specific_heat"].get<Real64>();
  • Read values using some thin worker functions that are very key oriented, like this:
thisPLHP.loadSideDesignVolFlowRate = state.dataInputProcessing->inputProcessor->getRealFieldValue(fields, schemaProps, "load_side_reference_flow_rate");
if (thisPLHP.loadSideDesignVolFlowRate == DataSizing::AutoSize) {
  thisPLHP.loadSideDesignVolFlowRateWasAutoSized = true;
}
  • And of course, use the standard GetObjectItem function, and then access fields based off of array index:
thisBoiler.VolFlowRate = s_ipsc->rNumericArgs(3);

So why are you being asked to change this code? Well, we would love to eliminate the GetObjectItem layer, and access everything based off of keys. That requires going through every get input routine and converting it over, pretty much by hand.

One caveat: when you access things directly off of the JSON data structure, you need to explicitly tell EnergyPlus that you have "used" this object instance. Otherwise there would be a warning at the end of the simulation that says "Object XYZ named ABC was not used". It is as simple as:

state.dataInputProcessing->inputProcessor->markObjectAsUsed(cCurrentModuleObject, thisObjectName);

So what to do here? Well, if you were just literally changing a line or an index or something, I would say maybe don't worry about converting it over to a key-value JSON-style input processing function. Since it's a new function entirely, and it's pretty small, I think it's a great lightweight opportunity for you to make the conversion, so that you know how to do it on future work. And it's one less function we have to convert later.....

The previous solution worked for the current version, but with the move to JSON for input, a reviewer expressed concerns that this would have to be fixed when this input was transitioned to JSON.  Since JSON reorders the input, a more comprehensive solution was needed.  This commit converts the AirflowNetwork:Distribution:Linkage input to using JSON directly and the solution should work for any input that includes these objects in any order.  So, conversion to JSON for this object is now complete as part of the solution.
@RKStrand
Copy link
Contributor Author

@jasondegraw @Myoldmopar @rraustad Ok! I believe that I have successfully completed this fix. The input object that was causing the problem (AirflowNetwork:Distribution:Linkage) has been converted to using JSON. The solution is not pretty but it really has to be a bit methodical to make sure the AirLoopNum get propagated throughout the network despite where the "start" of the loop is entered/read into the order. This is a completely different solution than previously done with a new unit test as well. I think this addresses all of the concerns expressed. Please feel free to look through this when you have a chance and let me know if you see any issues. Thanks!

@RKStrand RKStrand removed the request for review from mjwitte August 15, 2025 21:13
Copy link

⚠️ Regressions detected on macos-14 for commit a549634

Regression Summary
  • EIO: 21
  • ESO Big Diffs: 1
  • Table Big Diffs: 9
  • Table String Diffs: 8
  • ESO Small Diffs: 22
  • MTR Small Diffs: 20
  • ERR: 2
  • Table Small Diffs: 13

@RKStrand
Copy link
Contributor Author

RKStrand commented Aug 19, 2025

@Myoldmopar Thanks so much for that explanation! I think I understand much better now and I can see where doing it for this fix would give me a chance to figure this out on a small scale so that in future work I'll be a little more up to speed. I have marked this as "waiting for developer" and will look to implement what @jasondegraw requested. (Oops...this was supposed to go out several days ago, but I forgot to click "Comment")

Update: the work here is done and this was switched back to "Waiting on Reviewer". Hopefully, this adequately addresses the concerns expressed previously.

Copy link
Member

@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.

@RKStrand This will be better long term, thanks for being willing to go back over it.

@Myoldmopar
Copy link
Member

@RKStrand I saw this was conflicted, so I merged in develop and resolved the conflict. I also noticed CI was failing so I made a debug build, and found a divide by zero in the AirflowNetwork_MULTIZONE_House_DuctSizing test file.

The divide by zero is on line Solver.cc:12808, which I don't think you directly modified, but somehow the logic is allowing the SupplyBranchArea variable to be zero at this point.

image

Let me know if you need anything else from me.

@Myoldmopar
Copy link
Member

(Also I just pushed the conflict resolved branch, so make sure to pull before attempting any pushes.)

Copy link

github-actions bot commented Sep 5, 2025

⚠️ Regressions detected on macos-14 for commit 21a1140

Regression Summary
  • EIO: 21
  • ESO Big Diffs: 1
  • Table Big Diffs: 9
  • Table String Diffs: 8
  • ESO Small Diffs: 22
  • MTR Small Diffs: 20
  • ERR: 2
  • Table Small Diffs: 13

@nrel-bot-2c
Copy link

@RKStrand @Myoldmopar it has been 28 days since this pull request was last updated.

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.

Order-dependent input - AirflowNetwork:Distribution:Linkage

6 participants