Skip to content
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

Add ability to automatically detect groups of similar surfaces for efficient heat balance calculations #8739

Merged
merged 27 commits into from
Aug 23, 2021

Conversation

nealkruis
Copy link
Member

@nealkruis nealkruis commented Apr 30, 2021

Pull request overview

One time saving technique used in EnergyPlus models is the use of Window Multipliers to reduce redundant heat balance calculations on multiple window surfaces. However, this practice requires users to modify their building geometry to be substantially different from the actual architectural features they are trying to represent. This work will explore, propose, and implement an approach where these simplifications can be inferred automatically from user input and performed behind-the-scenes so that models with many windows (and other heat transfer surfaces) can benefit from time-saving techniques without sacrificing geometric fidelity.

See the NFP here.

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • 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

This will not be exhaustively relevant to every PR.

  • 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

@nealkruis nealkruis added NewFeature Includes code to add a new feature to EnergyPlus Performance Includes code changes that are directed at improving the runtime performance of EnergyPlus IDDChange Code changes impact the IDD file (cannot be merged after IO freeze) labels Apr 30, 2021
@nealkruis nealkruis added this to the EnergyPlus Future milestone Apr 30, 2021
@nealkruis nealkruis self-assigned this Apr 30, 2021
@nrel-bot-3
Copy link

@nealkruis @lgentile it has been 28 days since this pull request was last updated.

2 similar comments
@nrel-bot-2b
Copy link

@nealkruis @lgentile it has been 28 days since this pull request was last updated.

@nrel-bot-3
Copy link

@nealkruis @lgentile it has been 28 days since this pull request was last updated.

@nealkruis nealkruis marked this pull request as ready for review August 10, 2021 22:57
@nealkruis nealkruis changed the title Add ability to automatically detect groups of similar window surfaces for efficient heat balance calculations Add ability to automatically detect groups of similar surfaces for efficient heat balance calculations Aug 11, 2021
@Myoldmopar
Copy link
Member

@nealkruis IIRC you were going to be doing something else to this branch. Adding/modifying the test file? I'm ready to test/review this just let me know. There appears to be a tiny conflict to resolve, I'm happy to do that, but if you want to pull develop in yourself that's fine too. I'm curious how this will play with the spaces PR....... (FYI @mjwitte)

@nealkruis
Copy link
Member Author

@Myoldmopar yeah, I'll add an example file. I've been chatting with @mjwitte about the inevitable collision of our two PRs and need to make one other minor change to accommodate the fact that spaces can cause surfaces to be in separate enclosures within the same zone. I'll take care of that this morning.

@nealkruis
Copy link
Member Author

@Myoldmopar this should be ready once the CI returns.

@Myoldmopar
Copy link
Member

@nealkruis I'm not sure if you're working this weekend or not, but with spaces in, please go ahead and update this branch as soon as possible so we can do final review and get it merged.

Copy link
Contributor

@mbadams5 mbadams5 left a comment

Choose a reason for hiding this comment

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

Only one minor review comment.
Overall this looks good to me. I'll be curious how the conduction work on the windows improves performance.

// Make hash key for this surface (used to determine uniqueness)
state.dataSurface->Surface(SurfNum).make_hash_key(state, SurfNum);
// Insert surface key into map. If key already exists, it will not be added.
state.dataSurface->RepresentativeSurfaceMap.insert({state.dataSurface->Surface(SurfNum).calcHashKey, SurfNum});
Copy link
Contributor

Choose a reason for hiding this comment

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

Relatively minor in the scheme of the PR, but insert returns a "pair object whose first element is an iterator pointing either to the newly inserted element in the container or to the element whose key is equivalent". This means you can just use that returned iterator below state.dataSurface->Surface(SurfNum).RepresentativeCalcSurfNum = returned_pair.first;, instead of performing a find again.

state.dataSurface->Surface(SurfNum).RepresentativeCalcSurfNum = SurfNum;
// Automatic Surface Multipliers: Assign representative heat transfer surfaces
if (state.dataSurface->UseRepresentativeSurfaceCalculations && state.dataSurface->Surface(SurfNum).HeatTransSurf &&
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneProperty:UserViewFactors:BySurfaceName") == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably shouldn't call this for every surface. Call once and set a flag. Better yet, split this loop into two and only do the second part if UseRepresentativeSurfaceCalculations is true and there are no user defined view factors.

Copy link
Contributor

@mjwitte mjwitte left a comment

Choose a reason for hiding this comment

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

@nealkruis This is an interesting approach. I haven't tested it yet to see what kind of impact it has. Some comments at the top of the PR would be useful if you've found a certain file to show x% speedup or % reduction in surfaces in the radiant enclosures. Nice that the changes are very self-contained.

A few comments/questions. Nothing here is a showstopper for I/O Freeze, any changes can happen after that.

@@ -1089,28 +1089,28 @@ \subsection{PerformancePrecisionTradeoffs}\label{performanceprecisiontradeoffs}

\paragraph{Field: Override Mode}\label{override-mode}

The Override Mode field provides a single field that will override other inputs located in the IDF/epJSON file as well as convergence related values that appear in the remaining fields of the PerformancePrecisionTradeoffs object. The Normal option (default) provides no overrides while the Mode options provide overrides based on the following tables. The Advanced option, allows the remaining fields of the PerformancePrecisionTradeoffs to be used.
The Override Mode field provides a single field that will override other inputs located in the IDF/epJSON file as well as convergence related values that appear in the remaining fields of the PerformancePrecisionTradeoffs object. The Normal option (default) provides no overrides while the Mode options provide overrides based on the following tables. The Advanced option, allows the remaining fields of the PerformancePrecisionTradeoffs to be used.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be more specific now. Only MaxZoneTempDiff and MaxAllowedDelTemp require Override Mode = Advanced. If I'm understanding correctly, the new field for "Use Representative Surfaces for Calculations" isn't affected by Override Mode.


Surface are grouped based on the following criteria for similarity:

\begin{itemize}
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding \tightlist might be nice here (before the first item) to remove the space between each item - nice for short one-liner lists like this.

calcHashKey.TAirRef = state.dataSurface->SurfTAirRef(SurfNum);

auto extBoundCond = state.dataSurface->Surface(SurfNum).ExtBoundCond;
if (extBoundCond > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will add ExtZone and ExtEnclindex to the hash if it's an interzone surface, otherwise these are zero. I see checks later on for OSC and OSCM, but what about these outside boundary conditions:

       \key Outdoors
       \key Foundation
       \key Ground
       \key GroundFCfactorMethod

Unless I'm missing something it looks like these will all have the same hash.

\item WindowProperty:AirflowControl (windows only)
\end{itemize}

Currently, the only calculations performed across all surfaces with a group is the interior radiation exchange, where surfaces within a group are collected into a single area for participating in interior longwave radiation exchange. This will reduce the scale and complexity of the algorithm with minimal impact on accuracy. Additional calculations may be performed for a group of surfaces in future releases.
Copy link
Contributor

Choose a reason for hiding this comment

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

Type - first "with" --> "within"

int enclosureSurfNum = 0;
for (int const spaceNum : thisEnclosure.spaceNums) {
int priorZoneTotEnclSurfs = enclosureSurfNum;
for (int surfNum : state.dataHeatBal->space(spaceNum).surfaces) {
if (state.dataSurface->Surface(surfNum).IsAirBoundarySurf) continue;
++enclosureSurfNum;
thisEnclosure.SurfacePtr(enclosureSurfNum) = surfNum;
// Automatic Surface Multipliers: Only include representative surfaces
Copy link
Contributor

Choose a reason for hiding this comment

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

If this loop only adds representative surfaces, can this for loop be skipped if !UseRepresentativeSurfaceCalculations?
Or maybe it's the next loop that isn't necessary if !UseRepresentativeSurfaceCalculations?
The usage for RepresentativeCalcSurfNum is a bit confusing. When I saw it declared in DataSurfaces, I assumed that RepresentativeCalcSurfNum would be zero for normal calculations, but it appears that's not the case.
If I'm following correctly, if UseRepresentativeSurfaceCalculations is off, then state.dataSurface->Surface(surfNum).RepresentativeCalcSurfNum = surfNum for all surfaces?
Might be worth an extra comment in DataSurfaces.

EXPECT_EQ(state->dataSurface->Surface(2).RepresentativeCalcSurfNum, 2);
EXPECT_EQ(state->dataSurface->Surface(3).RepresentativeCalcSurfNum, 3);
EXPECT_EQ(state->dataSurface->Surface(4).RepresentativeCalcSurfNum, 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

File could use one more return at the end.

@mjwitte
Copy link
Contributor

mjwitte commented Aug 23, 2021

Serial unit tests all pass.

@Myoldmopar
Copy link
Member

This is a great addition. I'm going to merge this in to get us very close to IO freeze, but please open up a ticket right away to address the issues noted by @mjwitte. Thanks @nealkruis !

@Myoldmopar Myoldmopar merged commit 75c5e2b into develop Aug 23, 2021
@Myoldmopar Myoldmopar deleted the auto-window-mult branch August 23, 2021 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDDChange Code changes impact the IDD file (cannot be merged after IO freeze) NewFeature Includes code to add a new feature to EnergyPlus Performance Includes code changes that are directed at improving the runtime performance of EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants