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

Refactoring of interpolation functions for blinds Prof and Slat Angle #8591

Merged
merged 30 commits into from
Mar 25, 2021

Conversation

xuanluo113
Copy link
Contributor

@xuanluo113 xuanluo113 commented Mar 6, 2021

Pull request overview

This branch includes the refactoring of the listed functions (e.g. inlining, cache intermediate results, reduce redundant calcs).

  • InterpSw
  • InterBlinds (not used)
  • InterpProfAng
  • InterpSlatAng
  • InterpProfSlatAng
  • BlindBeamBeamTrans

Also, the MACROs in checking shading flag status were converted to constexpr.

The small diffs with the 3 blind related testfiles result from the floating-point error explained here. Previously InterpSlatAng uses * DeltaAng_inv;, while InterpProfSlatAng uses / DeltaAng in state.dataSurface->SurfWinSlatsAngInterpFac(ISurf) calculation. The diffs are less than 10e-15.

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 the Performance Includes code changes that are directed at improving the runtime performance of EnergyPlus label Mar 6, 2021
@xuanluo113 xuanluo113 self-assigned this Mar 6, 2021
{
return Lower + InterpFac * (Upper - Lower);
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm sure declaring this function constexpr vs. just inline doesn't hurt anything, but I doubt any of the arguments will actually be constexpr and enable any compile-time reduction. Same for InterpProfSlat.

@xuanluo113 xuanluo113 added this to the EnergyPlus 9.5.0 milestone Mar 23, 2021
@xuanluo113 xuanluo113 marked this pull request as ready for review March 23, 2021 19:23
@xuanluo113 xuanluo113 requested a review from mjwitte March 23, 2021 21:03
@xuanluo113
Copy link
Contributor Author

@mjwitte This branch is ready for review. Please let me know if you have any availability in reviewing this, or you have some recommendations for reviewers. I also wonder if this could come before the 9.5 release. Thanks!

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 Nice work here. I have a little more testing to do, but looks good so far.

Comment on lines -266 to +264
zone_info.Emissivity(ZoneSurfNum) =
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffShBlindEmiss) +
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffGlassEmiss);
zone_info.Emissivity(ZoneSurfNum) = state.dataHeatBal->ITABSF(SurfNum);
Copy link
Contributor

Choose a reason for hiding this comment

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

So, if I'm following correctly, ITABSF is set in HeatBalanceSurfaceManager::ComputeIntThermalAbsorpFactors (same as before, with some adjustments in this branch) so no need to recompute it here.

@@ -318,8 +314,7 @@ namespace HeatBalanceIntRadExchange {
// and emiss is used here that is a weighted combination of shade/blind and glass temp and emiss.
} else if (ANY_INTERIOR_SHADE_BLIND(state.dataSurface->SurfWinShadingFlag(SurfNum))) {
SurfaceTempRad[ZoneSurfNum] = state.dataSurface->SurfWinEffInsSurfTemp(SurfNum);
SurfaceEmiss[ZoneSurfNum] = InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffShBlindEmiss) +
InterpSlatAng(state.dataSurface->SurfWinSlatAngThisTS(SurfNum), state.dataSurface->SurfWinMovableSlats(SurfNum), surface_window.EffGlassEmiss);
SurfaceEmiss[ZoneSurfNum] = state.dataHeatBal->ITABSF(SurfNum);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, just use ITABSF directly. Ok.

state.dataConstruction->Construct( ConstrNumSh).AbsDiffBlind) *
(SkySolarInc + GndSolarInc);
Real64 AbsDiffBlind;
if (state.dataSurface->SurfWinMovableSlats(SurfNum)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor detail - these if blocks could be combined with the corresponding ones above.

@@ -10762,10 +10988,7 @@ namespace EnergyPlus::SolarShading {

// Accumulate Window and Zone total distributed diffuse solar to check for conservation of energy
// For opaque surfaces all incident diffuse is either absorbed or reflected
// WinDifSolarDistAbsorbedTotl += DifSolarAbsW; // debug [W]
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to clean these out.

@@ -1513,6 +1538,12 @@ struct SurfacesData : BaseGlobalStruct
Array1D<bool> SurfWinSlatAngThisTSDegEMSon; // flag that indicate EMS system is actuating SlatAngThisTSDeg
Array1D<Real64> SurfWinSlatAngThisTSDegEMSValue; // value that EMS sets for slat angle in degrees
Array1D<bool> SurfWinSlatsBlockBeam; // True if blind slats block incident beam solar
Array1D<int> SurfWinSlatsAngIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

6 new SurfWin* arrays to avoid recomputing values.

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 the comments. Since the performance tests don't have any blinds, I dug up the notorious file from last year with 100s of windows with blinds in a large zone. It's still warming up after running for 12 hrs. So, instead I took PurchAirWindowBlind_BlockBeamSolar and ran that for 10yrs and 20yrs with develop and this branch. This branch runs about 10% faster. Nice! Merging.

@mjwitte mjwitte merged commit 7557983 into NREL:develop Mar 25, 2021
@mjwitte mjwitte deleted the inter-slat-ang branch March 25, 2021 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

8 participants