-
Notifications
You must be signed in to change notification settings - Fork 401
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
TDD surface reordering and bug fixing #8540
Conversation
@mjwitte Would you mind reviewing one more branch? 😀 |
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.
Ran unit tests locally - all OK.
Reviewed results for the defect file and for testfile DaylightingDeviceTubular before and after this fix. Changes look reasonable and dome and diffuser surface temps match each other now (not perfect, but as designed).
Some code comments below.
for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | ||
if (!Surface(SurfNum).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
This if can be deleted.
for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | ||
if (!Surface(SurfNum).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Another if to delete.
@@ -545,7 +545,7 @@ namespace HeatBalanceIntRadExchange { | |||
} | |||
int numEnclosureSurfaces = 0; | |||
for (int zoneNum : thisEnclosure.ZoneNums) { | |||
for (int surfNum = Zone(zoneNum).SurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; surfNum <= surfNum_end; ++surfNum) { | |||
for (int surfNum = Zone(zoneNum).HTSurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; surfNum <= surfNum_end; ++surfNum) { | |||
if (Surface(surfNum).HeatTransSurf) ++numEnclosureSurfaces; |
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 if portion here can be deleted, keep ++numEnclosureSurfaces;
@@ -568,13 +568,13 @@ namespace HeatBalanceIntRadExchange { | |||
int enclosureSurfNum = 0; | |||
for (int const zoneNum : thisEnclosure.ZoneNums) { | |||
int priorZoneTotEnclSurfs = enclosureSurfNum; | |||
for (int surfNum = Zone(zoneNum).SurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; surfNum <= surfNum_end; ++surfNum) { | |||
for (int surfNum = Zone(zoneNum).HTSurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; surfNum <= surfNum_end; ++surfNum) { | |||
if (!Surface(surfNum).HeatTransSurf) 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.
Delete.
if (!Surface(surfNum).HeatTransSurf) continue; | ||
++enclosureSurfNum; | ||
thisEnclosure.SurfacePtr(enclosureSurfNum) = surfNum; | ||
} | ||
// Store SurfaceReportNums to maintain original reporting order | ||
for (int allSurfNum = Zone(zoneNum).SurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; allSurfNum <= surfNum_end; ++allSurfNum) { | ||
for (int allSurfNum = Zone(zoneNum).HTSurfaceFirst, surfNum_end = Zone(zoneNum).SurfaceLast; allSurfNum <= surfNum_end; ++allSurfNum) { | ||
if (!Surface(DataSurfaces::AllSurfaceListReportOrder[allSurfNum - 1]).HeatTransSurf) 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.
Delete?
if (Zone(Loop).SurfaceFirst > 0) { | ||
for (SurfNum = Zone(Loop).SurfaceFirst; SurfNum <= Zone(Loop).SurfaceLast; ++SurfNum) { | ||
if (Zone(Loop).HTSurfaceFirst > 0) { | ||
for (SurfNum = Zone(Loop).HTSurfaceFirst; SurfNum <= Zone(Loop).SurfaceLast; ++SurfNum) { | ||
if (!Surface(SurfNum).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Delete?
@@ -6246,7 +6246,7 @@ namespace ZoneTempPredictorCorrector { | |||
SumSysMCpT /= ZoneMult; | |||
} | |||
// Sum all surface convection: SumHA, SumHATsurf, SumHATref (and additional contributions to SumIntGain) | |||
for (SurfNum = Zone(ZoneNum).SurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | |||
for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | |||
|
|||
if (!Surface(SurfNum).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Delete?
@@ -6542,7 +6542,7 @@ namespace ZoneTempPredictorCorrector { | |||
SumNonAirSystem = NonAirSystemResponse(ZoneNum) + SumConvHTRadSys(ZoneNum) + SumConvPool(ZoneNum); | |||
|
|||
// Sum all surface convection: SumHA, SumHATsurf, SumHATref (and additional contributions to SumIntGain) | |||
for (SurfNum = Zone(ZoneNum).SurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | |||
for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).SurfaceLast; ++SurfNum) { | |||
|
|||
if (!Surface(SurfNum).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Deete?
src/EnergyPlus/SurfaceGeometry.cc
Outdated
@@ -1443,10 +1443,30 @@ namespace SurfaceGeometry { | |||
|
|||
if (SurfaceTmpClassMoved(SubSurfNum)) continue; | |||
if (state.dataSurfaceGeometry->SurfaceTmp(SubSurfNum).Zone != ZoneNum) continue; | |||
if (state.dataSurfaceGeometry->SurfaceTmp(SubSurfNum).ExtBoundCond > 0) continue; // Exterior |
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 comments above starting at line 1318 should describe these new groupings/order.
src/EnergyPlus/DataHeatBalance.hh
Outdated
int SurfaceLast; // Last Heat Transfer Surface in Zone | ||
int NonWindowSurfaceFirst; // First Non-Window Heat Transfer Surface in Zone | ||
int NonWindowSurfaceLast; // Last Non-Window Heat Transfer Surface in Zone | ||
int WindowSurfaceFirst; // First Window Heat Transfer Surface in Zone | ||
int WindowSurfaceLast; // Last Window Heat Transfer Surface in Zone | ||
int NonDomeLast; // Last non TDD Dome Surface in Zone |
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 comments here need to be very clear about what's included in each group since some of these overlap.
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 clarity and self-documentation purposes, I suggest that these things be done in pairs, XFirst/XLast. Even if some combination of XFirst and YFirst or XLast and YLast are redundant, that is better than having to remember which combination of XFirst and YLast corresponds to which subset. The name X can be the descriptive name of the subset.
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.
@xuanluo113 This is a great improvement - loop intent is soooo much clearer now.
I've noted a few things below that can be cleaned up later.
Mac CI looks good, but I'll let Linux finish before merging this today.
int const firstSurf = Zone(zoneNum).HTSurfaceFirst; | ||
int const lastSurf = Zone(zoneNum).NonDomeLast; | ||
int const lastSurf = Zone(zoneNum).OpaqOrWinSurfaceLast; |
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.
HTSurfaceFirst
--> OpaqOrWinSurfaceFirst
int const firstSurf = Zone(zoneNum).HTSurfaceFirst; | ||
int const lastSurf = Zone(zoneNum).NonDomeLast; | ||
int const lastSurf = Zone(zoneNum).OpaqOrWinSurfaceLast; |
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.
Same here.
int const firstSurf = Zone(zoneNum).HTSurfaceFirst; | ||
int const lastSurf = Zone(zoneNum).NonDomeLast; | ||
int const lastSurf = Zone(zoneNum).OpaqOrWinSurfaceLast; |
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.
And here.
@@ -13797,7 +13797,7 @@ namespace EnergyPlus::OutputReportTabular { | |||
Real64 adjFeneSurfNetRadSeq = 0.0; | |||
|
|||
// code from ComputeDelayedComponents starts | |||
for (int jSurf = Zone(zoneIndex).HTSurfaceFirst; jSurf <= Zone(zoneIndex).SurfaceLast; ++jSurf) { | |||
for (int jSurf = Zone(zoneIndex).HTSurfaceFirst; jSurf <= Zone(zoneIndex).HTSurfaceLast; ++jSurf) { | |||
if (!Surface(jSurf).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Delete.
@@ -14011,7 +14011,7 @@ namespace EnergyPlus::OutputReportTabular { | |||
|
|||
// opaque surfaces - must combine individual surfaces by class and other side conditions | |||
delayOpaque = 0.0; | |||
for (int kSurf = Zone(zoneIndex).HTSurfaceFirst; kSurf <= Zone(zoneIndex).SurfaceLast; ++kSurf) { | |||
for (int kSurf = Zone(zoneIndex).HTSurfaceFirst; kSurf <= Zone(zoneIndex).HTSurfaceLast; ++kSurf) { | |||
if (!Surface(kSurf).HeatTransSurf) continue; // Skip non-heat transfer surfaces |
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.
Delete.
src/EnergyPlus/ThermalComfort.cc
Outdated
@@ -1901,7 +1901,7 @@ namespace ThermalComfort { | |||
// Note that area*emissivity needs to be recalculated because of the possibility of changes to the emissivity via the EMS | |||
SumAET = 0.0; | |||
ZoneAESum(ZoneNum) = 0.0; | |||
for (SurfNum2 = Zone(ZoneNum).SurfaceFirst; SurfNum2 <= Zone(ZoneNum).SurfaceLast; ++SurfNum2) { | |||
for (SurfNum2 = Zone(ZoneNum).HTSurfaceFirst; SurfNum2 <= Zone(ZoneNum).SurfaceLast; ++SurfNum2) { | |||
if ((Surface(SurfNum2).HeatTransSurf) && (SurfNum2 != SurfNum)) { |
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.
Delete first part of if
} | ||
|
||
// The window subsurfaces (includes SurfaceClass::TDD_Diffuser) | ||
// The exterior window subsurfaces (includes SurfaceClass::Window and SurfaceClass::GlassDoor) goes next |
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.
Remember to edit the comment block at the top of this function to be current and it should mention the various first/last variables.
src/EnergyPlus/DataHeatBalance.hh
Outdated
int OpaqOrIntMassSurfaceFirst; // First Opaque or Interior Mass Heat Transfer Surface in Zone | ||
int OpaqOrIntMassSurfaceLast; // Last Opaque or Interior Mass Heat Transfer Surface in Zone |
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.
Just be clear, I would add (including doors)
Alright, lots of conflicts, but they were all tiny and easy to resolve as expected. I've got them nearly done and I'll push it up and let CI have another pass tonight. |
@Myoldmopar Thanks. |
Ran all unit and integration tests, they pass. Spot checked regressions, they look similar to what was happening on here. If CI agrees, then I believe this will be ready to go in later. |
@Myoldmopar Thanks. Added a commit of minor updates of some code comments. |
for (IntWin = Zone(ZoneNum).WindowSurfaceFirst; IntWin <= Zone(ZoneNum).WindowSurfaceLast; ++IntWin) { | ||
if (Surface(IntWin).ExtBoundCond >= 1) { | ||
for (IntWin = state.dataHeatBal->Zone(ZoneNum).WindowSurfaceFirst; IntWin <= state.dataHeatBal->Zone(ZoneNum).WindowSurfaceLast; ++IntWin) { | ||
if (Surface(IntWin).ExtBoundCond >= 1) { // in develop this was Surface(IntWin).Class == SurfaceClass::Window && Surface(IntWin).ExtBoundCond >= 1 |
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.
@Myoldmopar Right, the if==Window
is redundant now, because the loop is over just window surfaces.
@@ -2721,8 +2721,8 @@ namespace ZoneTempPredictorCorrector { | |||
|
|||
for (Loop = 1; Loop <= state.dataGlobal->NumOfZones; ++Loop) { | |||
FirstSurfFlag = true; | |||
if (Zone(Loop).HTSurfaceFirst > 0) { | |||
for (SurfNum = Zone(Loop).HTSurfaceFirst; SurfNum <= Zone(Loop).HTSurfaceLast; ++SurfNum) { | |||
if (state.dataHeatBal->Zone(Loop).HTSurfaceFirst > 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.
@xuanluo113 Is this line still necessary?
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.
it's okay to remove.
1 file with diffs, just like before. However, there is one unit test that was failing with an array index problem in the previous commit, unrelated to bringing in develop. @xuanluo113 it looks like it might've been introduced with the "address comments" commit (8b9fde0). That'll need to be addressed before merging this. |
@Myoldmopar I built and ran unit tests here locally. They all ran successfully.
|
Debug also passess
|
OK, so Ci is way too bogged down right now. We're going to take evidence from multiple sources here to get this merged.
I am going to merge this now so we can move on. Thanks @xuanluo113 and @mjwitte |
Linux results finally came through. Performance improvement is 0.2136%. Not huge, but moving in the right direction. |
A couple of things. First, I thought the point of this particular PR was to fix a bug because TDD_dome was being included in the wrong calculations. Second, performance-wise getting one data-driven branch out of a loop is good because you are not hitting branch mispredictions and pipeline flushes as often. But it is not enough to optimizations like vectorization going. You need to get all of these types of branches (and crazy function calls like the I am happy with this PR. |
Pull request overview
This branch includes the following refactoring and bug fixing features.
In particular, for the model
DaylightingDeviceTubular.idf
in the current testfile list, the outside and inside surface temperature of the TDD surfaces are:Before -
After -
We also developed a new test file for tdd surface attached to test the bug fixing. If needed, the new file can be included in the current test suite.
5ZoneWithAttic_DaylightingDeviceDiffuser.idf.txt
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.