-
Notifications
You must be signed in to change notification settings - Fork 394
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
Fix #10302 - CalcEquipmentFlowRates assert failure due to out of bounds std::array indexing #10528
Conversation
TEST_F(EnergyPlusFixture, CalcConvCoeffBetweenPlates) | ||
{ | ||
constexpr Real64 TempSurf1 = 251.0; // temperature of surface 1 | ||
constexpr Real64 TempSurf2 = 26.5; // temperature of surface 2 | ||
|
||
constexpr Real64 Tref = 0.5 * (TempSurf1 + TempSurf2); | ||
|
||
constexpr Real64 maxArrayTemp = 126.85; // This is the max temperature in the `Temps` array that stores the correlation temps | ||
EXPECT_TRUE(Tref > maxArrayTemp); | ||
|
||
// Irrelevant to this test | ||
constexpr Real64 AirGap = 0.05; // characteristic length [m] | ||
constexpr Real64 CosTilt = 0.87; // cosine of surface tilt angle relative to the horizontal | ||
constexpr Real64 SinTilt = 0.80; // sine of surface tilt angle relative to the horizontal | ||
|
||
Real64 hConvCoef = EnergyPlus::SolarCollectors::CollectorData::CalcConvCoeffBetweenPlates(TempSurf1, TempSurf2, AirGap, CosTilt, SinTilt); | ||
EXPECT_FALSE(std::isnan(hConvCoef)); | ||
EXPECT_TRUE(std::isfinite(hConvCoef)); | ||
EXPECT_NEAR(4.71593, hConvCoef, 0.001); | ||
} |
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.
Before fix:
$ Products/energyplus_tests -- --gtest_filter=*CalcConvCoeffBetweenPlates*
Note: Google Test filter = *CalcConvCoeffBetweenPlates*
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from EnergyPlusFixture
[ RUN ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:76: Failure
Value of: std::isfinite(hConvCoef)
Actual: false
Expected: true
/Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:77: Failure
The difference between 4.71593 and hConvCoef is inf, which exceeds 0.001, where
4.71593 evaluates to 4.7159300000000002,
hConvCoef evaluates to -inf, and
0.001 evaluates to 0.001.
[ FAILED ] EnergyPlusFixture.CalcConvCoeffBetweenPlates (69 ms)
[----------] 1 test from EnergyPlusFixture (69 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (69 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] EnergyPlusFixture.CalcConvCoeffBetweenPlates
#include <EnergyPlus/EPVector.hh> | ||
#include <EnergyPlus/EnergyPlus.hh> | ||
#include <EnergyPlus/Plant/DataPlant.hh> |
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.
Missing includes
@@ -1979,7 +1979,7 @@ namespace SolarCollectors { | |||
CondOfAir = Conductivity[Index]; | |||
PrOfAir = Pr[Index]; | |||
DensOfAir = Density[Index]; | |||
} else if (Index > NumOfPropDivisions) { | |||
} else if (Index >= NumOfPropDivisions) { // 0-index, hence MaxIndex = NumOfPropDivisions - 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.
Actual fix
```shell $ Products/energyplus_tests -- --gtest_filter=*CalcConvCoeffBetweenPlates* Note: Google Test filter = *CalcConvCoeffBetweenPlates* [==========] Running 1 test from 1 test suite. [----------] Global test environment set-up. [----------] 1 test from EnergyPlusFixture [ RUN ] EnergyPlusFixture.CalcConvCoeffBetweenPlates /Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:76: Failure Value of: std::isfinite(hConvCoef) Actual: false Expected: true /Users/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/SolarCollectors.unit.cc:77: Failure The difference between 4.71593 and hConvCoef is inf, which exceeds 0.001, where 4.71593 evaluates to 4.7159300000000002, hConvCoef evaluates to -inf, and 0.001 evaluates to 0.001. [ FAILED ] EnergyPlusFixture.CalcConvCoeffBetweenPlates (69 ms) [----------] 1 test from EnergyPlusFixture (69 ms total) [----------] Global test environment tear-down [==========] 1 test from 1 test suite ran. (69 ms total) [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] EnergyPlusFixture.CalcConvCoeffBetweenPlates ```
…ds std::array indexing
6bc2384
to
3f70b49
Compare
…EquipmentFlowRates
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.
Fix looks good. Not sure why there aren't any CI results. Updating with develop and will wait for CI to run.
Pull request overview
DefectFiles: show fix
cd EnergyPlusDevSupport/DefectFiles/10000s/10302
before:
After:
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.