-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude air boundaries and non-used constructions in conduction finite difference #8594
Conversation
@LipingWang Please merge in develop to make this branch current. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes seem fine, but the unit test needs work. It looks like the logic is copied from inside EnergyPlus into the unit test, rather than the unit test calling into EnergyPlus. This would defeat the purpose of the unit test because the code inside EnergyPlus could be broken at any time and the new unit test would never reveal that.
If I'm mistaken, please clarify how the unit test works.
ConstructFD(1).Name.allocate(state->dataConstruction->Construct(ConstrNum).TotLayers); | ||
thisTotalLayers = state->dataConstruction->Construct(thisConstructNum).TotLayers; | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is happening here? Where are you calling the E+ code to exercise your changes? It almost looks like you copied the code from inside E+ and put it in here. If that were the case, you'd need to modify this to just call the E+ code instead. If you have trouble calling the E+ code because it requires too much data to be set up prior to calling the function, then just put some of the modified logic into a smaller function that is easier to call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comments. I agree that directly calling the function for unit test is a better choice. The function under modification is ReportFiniteDiffInits(EnergyPlusData &state) for initialization of the finite difference calculation of each construction. I cannot figure out a way to directly call this function. So I put part of the code from the original function to run the test. Please feel free to suggest methods of calling this function or modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take these four lines that are used to determine if a layer should be included or not:
- Create a small method on the construction object named "shouldSkipForFiniteDifference". It performs the same series of checks and returns true if the construction should be skipped.
- In the finite difference manager, replace all those lines with a call to that method on the construction object:
if (state.dataConstruction->Construct(ThisNum).shouldSkipForFiniteDifference()) continue;
- Then your unit test can really just set up a construction object, no input objects required, and call that tiny little worker function under a series of cases and see if it returns true or not.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edwin, after further looking into this, I was able to call and test the original function InitialInitHeatBalFiniteDiff. Please see the updated unit test. Thank you for your comments.
@@ -1293,6 +1294,8 @@ namespace HeatBalFiniteDiffManager { | |||
|
|||
if (state.dataConstruction->Construct(ThisNum).TypeIsWindow) continue; | |||
if (state.dataConstruction->Construct(ThisNum).TypeIsIRT) continue; | |||
if (state.dataConstruction->Construct(ThisNum).TypeIsAirBoundary) continue; | |||
if (!state.dataConstruction->Construct(ThisNum).IsUsed) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic changes seem fine.
state->dataConstruction->Construct(3).IsUsed = true; | ||
|
||
//call the function for initialization of finite difference calculation | ||
InitialInitHeatBalFiniteDiff(*state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better! OK, I'll build locally but this is now on track to go in. Thanks for the quick fix up.
OK, CI is showing a couple of unused variables. I'll clean those up locally, build and then get this merged in. |
@LipingWang OK, I fixed a couple tiny things in this branch, built it with latest develop, and ran the unit test suite. This one is good to go in. Thanks! |
Thanks a lot! |
Pull request overview
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange labelIf structural output changes, add to output rules file and add OutputChange labelIf adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependenciesReviewer
This will not be exhaustively relevant to every PR.