Skip to content

Commit ffa8e15

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fixIncSolarMultiplier
2 parents f939ed9 + 26e62ca commit ffa8e15

File tree

2 files changed

+112
-7
lines changed

2 files changed

+112
-7
lines changed

src/EnergyPlus/SurfaceGeometry.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,13 +3038,13 @@ namespace SurfaceGeometry {
30383038
// Check if base surface and subsurface have the same normal
30393039
Vectors::CompareTwoVectors(baseSurface.NewellSurfaceNormalVector, subSurface.NewellSurfaceNormalVector, sameSurfNormal, 0.001);
30403040
if (sameSurfNormal) { // copy lcs vectors
3041-
// Prior logic tested for azimuth difference < 30 and then skipped this - this caused large diffs in
3042-
// CmplxGlz_MeasuredDeflectionAndShading Restoring that check here but will require further investigation (MJW Dec 2015)
3043-
if (std::abs(baseSurface.Azimuth - subSurface.Azimuth) > warningTolerance) {
3044-
subSurface.lcsx = baseSurface.lcsx;
3045-
subSurface.lcsy = baseSurface.lcsy;
3046-
subSurface.lcsz = baseSurface.lcsz;
3047-
}
3041+
// Prior logic tested for azimuth difference < 30 and then skipped this - this caused large diffs in
3042+
// CmplxGlz_MeasuredDeflectionAndShading Restoring that check here but will require further investigation (MJW Dec 2015)
3043+
// if (std::abs(baseSurface.Azimuth - subSurface.Azimuth) > warningTolerance) {
3044+
subSurface.lcsx = baseSurface.lcsx;
3045+
subSurface.lcsy = baseSurface.lcsy;
3046+
subSurface.lcsz = baseSurface.lcsz;
3047+
// }
30483048
} else {
30493049
// // Not sure what this does, but keeping for now (MJW Dec 2015)
30503050
// if (std::abs(subSurface.Azimuth - 360.0) < 0.01) {

tst/EnergyPlus/unit/SurfaceGeometry.unit.cc

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11853,3 +11853,108 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_SurroundingSurfacesViewFactorTest)
1185311853
EXPECT_DOUBLE_EQ(0.2, surface_east_wall.ViewFactorGroundIR);
1185411854
EXPECT_DOUBLE_EQ(1.0, surface_east_wall.ViewFactorSrdSurfs + surface_east_wall.ViewFactorSkyIR + surface_east_wall.ViewFactorGroundIR);
1185511855
}
11856+
11857+
TEST_F(EnergyPlusFixture, Fix_checkSubSurfAzTiltNorm_Horizontal_Surf_Random)
11858+
{
11859+
// Unit Test for Pull Request 10104 that addresses a potential illy functioned (or redudant) `if` condition
11860+
SurfaceData BaseSurface;
11861+
SurfaceData SubSurface;
11862+
SurfaceData SubSurface_Same;
11863+
bool surfaceError;
11864+
11865+
// Test Base surf and subsurf normal vectors assignment
11866+
surfaceError = false;
11867+
11868+
BaseSurface.Vertex.dimension(4);
11869+
11870+
BaseSurface.Vertex = {
11871+
DataVectorTypes::Vector(0, 0, 1), DataVectorTypes::Vector(1, 0, 1), DataVectorTypes::Vector(1, 1, 1), DataVectorTypes::Vector(0, 1, 1)};
11872+
Vectors::CreateNewellSurfaceNormalVector(BaseSurface.Vertex, BaseSurface.Vertex.size(), BaseSurface.NewellSurfaceNormalVector);
11873+
Vectors::DetermineAzimuthAndTilt(BaseSurface.Vertex,
11874+
BaseSurface.Azimuth,
11875+
BaseSurface.Tilt,
11876+
BaseSurface.lcsx,
11877+
BaseSurface.lcsy,
11878+
BaseSurface.lcsz,
11879+
BaseSurface.NewellSurfaceNormalVector);
11880+
11881+
SubSurface.Vertex.dimension(4);
11882+
11883+
SubSurface.Vertex = {DataVectorTypes::Vector(0, 0, 1),
11884+
DataVectorTypes::Vector(1, 0, 1),
11885+
DataVectorTypes::Vector(1, 1, 1.0003),
11886+
DataVectorTypes::Vector(0, 1, 1.0003)};
11887+
Vectors::CreateNewellSurfaceNormalVector(SubSurface.Vertex, SubSurface.Vertex.size(), SubSurface.NewellSurfaceNormalVector);
11888+
Vectors::DetermineAzimuthAndTilt(SubSurface.Vertex,
11889+
SubSurface.Azimuth,
11890+
SubSurface.Tilt,
11891+
SubSurface.lcsx,
11892+
SubSurface.lcsy,
11893+
SubSurface.lcsz,
11894+
SubSurface.NewellSurfaceNormalVector);
11895+
11896+
bool sameSurfNormal(false);
11897+
11898+
// This is the sameSurfNormal test used in checkSubSurfAzTiltNorm()
11899+
Vectors::CompareTwoVectors(BaseSurface.NewellSurfaceNormalVector, SubSurface.NewellSurfaceNormalVector, sameSurfNormal, 0.001);
11900+
11901+
// The surface normals are not exactly the same
11902+
EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.y - SubSurface.NewellSurfaceNormalVector.y), 1e-5);
11903+
EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.z - SubSurface.NewellSurfaceNormalVector.z), 1e-10);
11904+
11905+
// But should pass the sameSurfNormal test
11906+
EXPECT_TRUE(sameSurfNormal);
11907+
11908+
checkSubSurfAzTiltNorm(*state, BaseSurface, SubSurface, surfaceError);
11909+
11910+
// These should pass
11911+
EXPECT_FALSE(surfaceError);
11912+
EXPECT_FALSE(has_err_output());
11913+
11914+
// The base and the sub surfaces now should be adjusted to be exactly the same
11915+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.z, SubSurface.lcsz.z);
11916+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.y, SubSurface.lcsz.y);
11917+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.x, SubSurface.lcsz.x);
11918+
11919+
// Now do a test with the same SubSurface but with slightly different (but still valid) vertices input order
11920+
// Then the same test should pass all the same with the PR 10104 fix
11921+
// But it would expect to fail in the original develop branch without RP 10104 fix
11922+
SubSurface_Same.Vertex.dimension(4);
11923+
SubSurface_Same.Vertex = {DataVectorTypes::Vector(1, 0, 1),
11924+
DataVectorTypes::Vector(1, 1, 1.0003),
11925+
DataVectorTypes::Vector(0, 1, 1.0003),
11926+
DataVectorTypes::Vector(0, 0, 1)};
11927+
Vectors::CreateNewellSurfaceNormalVector(SubSurface_Same.Vertex, SubSurface_Same.Vertex.size(), SubSurface_Same.NewellSurfaceNormalVector);
11928+
Vectors::DetermineAzimuthAndTilt(SubSurface_Same.Vertex,
11929+
SubSurface_Same.Azimuth,
11930+
SubSurface_Same.Tilt,
11931+
SubSurface_Same.lcsx,
11932+
SubSurface_Same.lcsy,
11933+
SubSurface_Same.lcsz,
11934+
SubSurface_Same.NewellSurfaceNormalVector);
11935+
11936+
sameSurfNormal = false;
11937+
11938+
// This is the sameSurfNormal test used in checkSubSurfAzTiltNorm()
11939+
Vectors::CompareTwoVectors(BaseSurface.NewellSurfaceNormalVector, SubSurface_Same.NewellSurfaceNormalVector, sameSurfNormal, 0.001);
11940+
11941+
// The surface normals are not exactly the same
11942+
EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.y - SubSurface_Same.NewellSurfaceNormalVector.y), 1e-5);
11943+
EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.z - SubSurface_Same.NewellSurfaceNormalVector.z), 1e-10);
11944+
11945+
// But should pass the sameSurfNormal test
11946+
EXPECT_TRUE(sameSurfNormal);
11947+
11948+
checkSubSurfAzTiltNorm(*state, BaseSurface, SubSurface_Same, surfaceError);
11949+
11950+
// These should pass
11951+
EXPECT_FALSE(surfaceError);
11952+
EXPECT_FALSE(has_err_output());
11953+
11954+
// At least one of the following tests are expected to fail in the original develop branch without PR 10104 fix
11955+
// But with PR 10104 fix they should all pass
11956+
// The base and the sub surfaces now should be adjusted to be exactly the same
11957+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.z, SubSurface_Same.lcsz.z);
11958+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.y, SubSurface_Same.lcsz.y);
11959+
EXPECT_DOUBLE_EQ(BaseSurface.lcsz.x, SubSurface_Same.lcsz.x);
11960+
}

0 commit comments

Comments
 (0)