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

Surface Window data struct & heat balance routines refactoring #8257

Merged
merged 47 commits into from
Oct 12, 2020

Conversation

xuanluo113
Copy link
Contributor

@xuanluo113 xuanluo113 commented Sep 7, 2020

Pull request overview

This branch includes refactoring of the HB related data structures and scope reduction in InitSolarHeatGains. In detail, the changes include:

  • Refactoring – naming convention (var name prefix)
    e.g. Surf (for all surfaces), SurfWin, SurfOpaq
  • Reduce the scope of function level local variables.
    e.g. Surface(SurfNum).FrameDivider > 0
  • Reduce scope of loops (Separating into shading loops, opaq surface loops and window surface loops)
  • Reduce redundant branches
    e.g. CalcSolRefl
  • Move branches out of the loop applying MCCF
    e.g. TDD diffusers and TDD shelves

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

@xuanluo113 xuanluo113 added NotIDDChange Code does not impact IDD (can be merged after IO freeze) Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring labels Sep 12, 2020
@xuanluo113 xuanluo113 added this to the EnergyPlus Future milestone Sep 12, 2020
@mjwitte mjwitte marked this pull request as ready for review October 5, 2020 19:45
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.

@xuanluo113 I've merged in develop, resolved some minor conflicts and updated this branch.

Unit tests run locally all pass.

CI is looking good so far. In general, this all looks good - variable naming clarifications and loop variable scope reductions. A few comments/questions:

@@ -257,6 +257,7 @@ namespace DataGlobals {
std::function<void(EnergyPlus::Error e, const std::string &)> errorCallback;

bool eplusRunningViaAPI;
double timer_1(0.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you intend to keep this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Left by mistake. Just deleted these.

Comment on lines 229 to 230
Array1D<Real64> ZoneVMULT; // 1/(Sum Of A Zone's Inside Surfaces Area*Absorptance)
Array1D<Real64> ZoneVCONV; // Fraction Of Short-Wave Radiation From Lights Converted To Convection
Copy link
Contributor

Choose a reason for hiding this comment

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

These (and others) are really enclosure variables, not zone, indexed on enclosureNum (or similar). Also, solar and radiant enclosures can be different. Seems like we should use different prefixes for enclosures? SolEncl... RadEncl... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed ZoneVMULT and QD's to use SolEnclprefix. I realizedQC, QDVandVCONV` are allocated but not used anymore, so I deleted them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this now, I realize that this should be EnclSol to match the pattern of SurfOpaq SurfWin etc. It's your call whether to change that in this branch or in your next phase. Sorry I didn't see that before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I renamed it at the latest commit.

src/EnergyPlus/DataSurfaces.cc Outdated Show resolved Hide resolved
src/EnergyPlus/HeatBalanceSurfaceManager.cc Outdated Show resolved Hide resolved
Comment on lines +2722 to +2724
if (BuildingShadingCount || FixedShadingCount || AttachedShadingCount) {
for (int SurfNum = 1; SurfNum <= TotSurfaces; ++SurfNum) {
if (!Surface(SurfNum).ShadowingSurf) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since all shading surfaces are at the top of the surface list, we should be able to add a new variable for TotShadingSurfaces (or ShadingSurfaceLast or similar name) and loop here from 1 to TotShadingSurfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually working on this at the other branch, but haven't fully tested this piece yet. Do we want to pull that piece in this one? I was hoping this can go first so I'm not blocking Matt.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is ok here. It can wait for your next phase.

src/EnergyPlus/HeatBalanceSurfaceManager.cc Outdated Show resolved Hide resolved
src/EnergyPlus/HeatBalanceSurfaceManager.cc Show resolved Hide resolved
// for reporting (W)
Array1D<Real64> TempSurfOut; // Temperature of the Outside Surface for each heat transfer surface
Array1D<Real64> SurfTempSurfOut; // Temperature of the Outside Surface for each heat transfer surface
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but names like this which already have Surf in them could simply be SurfTempOut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this globally.

third_party/ObjexxFCL/src/ObjexxFCL/Array1.hh Outdated Show resolved Hide resolved
@mjwitte
Copy link
Contributor

mjwitte commented Oct 9, 2020

@xuanluo113 Also, please edit the PR description at the top with a brief summary of the changes.

@xuanluo113
Copy link
Contributor Author

@mjwitte Thanks for the review. I address them and updated the PR overview.

@xuanluo113 xuanluo113 added the Performance Includes code changes that are directed at improving the runtime performance of EnergyPlus label Oct 10, 2020
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.

@xuanluo113 Thanks for addressing my comments.

@Myoldmopar I'm finished reviewing this. Let me know if you want to review before merging.

@Myoldmopar
Copy link
Member

Let it go in, I don't have anything further.

@mjwitte mjwitte merged commit ed7cef8 into NREL:develop Oct 12, 2020
@xuanluo113
Copy link
Contributor Author

@mjwitte @Myoldmopar thanks!

@xuanluo113 xuanluo113 deleted the window-struct branch October 14, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NotIDDChange Code does not impact IDD (can be merged after IO freeze) Performance Includes code changes that are directed at improving the runtime performance of EnergyPlus 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.

8 participants