-
Notifications
You must be signed in to change notification settings - Fork 388
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
Profiling based refactoring in heat balance functions #8949
Conversation
…gyPlus into surf-wind-speed
@nealkruis @mjwitte @JasonGlazer I'll stop making more changes to this branch and mark it ready for review, in case it continues to stepping on other branches. Still waiting for the CI, but previous (washed out) CI results were normal. Wonder if you can help to review this. The main changes are explained in the PR overview. Thanks! |
@@ -661,8 +588,28 @@ void SurfaceData::set_representative_surface(EnergyPlusData &state, const int Su | |||
|
|||
void SetSurfaceOutBulbTempAt(EnergyPlusData &state) | |||
{ | |||
for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; SurfNum++) { | |||
SetOutBulbTempAt(state, SurfNum); | |||
if (state.dataEnvrn->SiteTempGradient == 0.0) { |
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.
Are these needed for all surfaces or just exterior surfaces? Does it make sense to create a vector of all exterior surfaces and just iterate over that?
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.
// Calculate Heat Index and Humidex. | ||
// The heat index equation set is fit to Fahrenheit units, so the zone air temperature values are first convert to F, | ||
// then heat index is calculated and converted back to C. | ||
if (state.dataHeatBalSurfMgr->reportVarHeatIndex || state.dataOutRptTab->displayThermalResilienceSummary) { | ||
// Constance for heat index regression equation of Rothfusz. | ||
Real64 const c1 = -42.379; |
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.
Not sure if it actually makes a difference given the scope, but can probably make these constexpr
.
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.
Okay. Done.
} | ||
for (int Meter = 1; Meter <= op->NumEnergyMeters; ++Meter) { | ||
op->MeterValue(Meter) = 0.0; // Ready for next update | ||
} |
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.
Nice!!
@xuanluo113 There are big diffs in SurfaceZonePropTest_LocalEnv that need fixing or explanation. |
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.
For the updated functions, have you looked at how often consecutive calls use the same argument values? If this happens fairly often, it might make sense to store the previous call argument values and result and check if the new call uses the same argument values.
The Neal reference doesn't ring a bell. I still think the way to do this is to create a vector of vectors of surface indices where each list contains surfaces of "roughly" the same height, then calculate wind speed once for each interior list and assign to all surfaces within that list. What percentage of runtime does this part of the code take right now? Trying to determine if that is worth doing ... |
@amirroth I don't remember where I got that idea then. It may not be worth it for the surface outdoor condition calculation (run time 0.5% for |
Yeah, that's borderline. There's probably more impactful things for us to look us. Put a pin in this for now. |
@xuanluo0113 it might be worth just testing for the the same value on consecutive calls. A lot of models get defined floor by floor so it might end up being common that the height is the same for consecutive surfaces. I'm not sure but it might be worth checking. |
@xuanluo0113 Now there are eso diffs in 3 files: ConvectionAdaptiveSmallOffice, SurfaceZonePropTest_LocalEnv, ZoneCoupledKivaConvectionAdaptiveSmallOffice. This branch is behind develop, but these results are from 12 hours ago, and nothing was merged between your commit and 12 hrs ago (I think). |
That's odd. Testing locally the diff does not reproduce. I think the diff is caused by the change to convective coefficient calculations of the other PR, which was, by the last commit, not merged into this PR. |
The convection diffs are likely due to #9035 if you haven't updated recently. |
Well, that's what I thought, but #9035 was merged at 9:38am CDT and the CI results claim to be from 5:23am. I hate to trigger another round of CI, but I need to know. |
@mitchute Thanks for confirming, Matt. |
@JasonGlazer I tested the methods of skipping consecutive calls with the same surface centroid z in the loop. See the commented-out code at the latest commit. I used a highrise-apartment building to test, and although the condition checks were able to filter out 90% of the |
@xuanluo0113 thanks for trying out saving the last value. I'm surprised it wasn't much faster but it is more assignments. |
It is weird that you are having an issue with two of the files in the CI that I am also having issues with: ConvectionAdaptiveSmallOffice, ZoneCoupledKivaConvectionAdaptiveSmallOffice on #9024. I have also merged develop recently and am still having the same issue but only on the Linux and MacOS tests not on Windows. Please let me know if you or @mjwitte see what is causing this. |
This is the eso diff summary for ConvectionAdaptiveSmallOffice.
The possible values are:
An absolute diff of 985080.0 in the first timestep of the winter day says this variable isn't getting initialized. |
Right. So the key to effective caching (which is essentially what this is) is for cache lookup and update to be significantly faster than the uncached calculation. Creating lists of (exterior) surfaces that have roughly the same centroid will not have this problem because you will not incur the overhead of the matching checks. But it may still not be worth pursuing given the overall contribution of this piece of code to runtime. Your call. |
999 is a valid |
That's a divide by zero indicator. MathDiff might even have logic to write that explicitly if the base value is zero. |
I just deleted the commented-out code for testing the caching. And if the CI turns green this time, this is ready for another review. Further investigations of caching and naming conventions of the reportable Q variable will go to the next PR. |
CI is happy here, merging. |
🎉 |
Pull request overview
SetWindSpeedAt
,SetSurfacetempAt
at surface level.ReportSurfaceHeatBalance
andCalcThermalResilience
.InitSurfaceHeatBalance
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.