From 98339668acd170e21e0f2a6208528426c2dbf0f2 Mon Sep 17 00:00:00 2001 From: Simon Vidanovic Date: Fri, 15 Nov 2024 08:31:21 -0800 Subject: [PATCH] Update to unit tests for curved venetians and unit normals in view factors. --- ...netianDirectional_n_Band_Material.unit.cpp | 18 ++++++++--------- ...ctional_n_Band_Material_Condensed.unit.cpp | 20 +++++++++---------- .../src/VenetianSegments.cpp | 14 +++---------- .../tst/units/VenetianCellCurved55_1.unit.cpp | 4 ++-- .../units/VenetianDirectionalMatrix.unit.cpp | 6 +++--- ...anDirectionalShadeCurvedMinus45_0.unit.cpp | 4 ++-- .../tst/units/VenetianUniformMatrix.unit.cpp | 4 ++-- src/Viewer/tst/units/Segment2D.unit.cpp | 8 ++++---- 8 files changed, 35 insertions(+), 43 deletions(-) diff --git a/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material.unit.cpp b/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material.unit.cpp index ab99945f..7439a858 100644 --- a/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material.unit.cpp +++ b/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material.unit.cpp @@ -329,39 +329,39 @@ TEST_F(MultiPaneBSDF_102_VenetianDirectional_n_Band_Material, TestBSDF1) CMultiPaneBSDF & aLayer = getLayer(); const double tauDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::T); - EXPECT_NEAR(0.358468, tauDiff, 1e-6); + EXPECT_NEAR(0.450879, tauDiff, 1e-6); const double rhoDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::R); - EXPECT_NEAR(0.108058, rhoDiff, 1e-6); + EXPECT_NEAR(0.353426, rhoDiff, 1e-6); const double absDiff1 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 1); - EXPECT_NEAR(0.136506, absDiff1, 1e-6); + EXPECT_NEAR(0.137116, absDiff1, 1e-6); const double absDiff2 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 2); - EXPECT_NEAR(0.058649, absDiff2, 1e-6); + EXPECT_NEAR(0.058579, absDiff2, 1e-6); const double theta = 0; const double phi = 0; const double tauHem = aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi); - EXPECT_NEAR(0.524285, tauHem, 1e-6); + EXPECT_NEAR(0.523116, tauHem, 1e-6); const double tauDir = aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi); - EXPECT_NEAR(0.415503, tauDir, 1e-6); + EXPECT_NEAR(0.415499, tauDir, 1e-6); const double rhoHem = aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi); - EXPECT_NEAR(0.334203, rhoHem, 1e-6); + EXPECT_NEAR(0.334675, rhoHem, 1e-6); const double rhoDir = aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi); EXPECT_NEAR(0.025928, rhoDir, 1e-6); const double abs1 = aLayer.Abs(minLambda, maxLambda, Side::Front, 1, theta, phi); - EXPECT_NEAR(0.082066, abs1, 1e-6); + EXPECT_NEAR(0.082908, abs1, 1e-6); const double abs2 = aLayer.Abs(minLambda, maxLambda, Side::Front, 2, theta, phi); - EXPECT_NEAR(0.059447, abs2, 1e-6); + EXPECT_NEAR(0.059301, abs2, 1e-6); } diff --git a/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed.unit.cpp b/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed.unit.cpp index 7e528bb6..e72c46f4 100644 --- a/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed.unit.cpp +++ b/src/MultiLayerOptics/tst/units/MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed.unit.cpp @@ -351,39 +351,39 @@ TEST_F(MultiPaneBSDF_102_VenetianDirectional_n_Band_Material_Condensed, TestBSDF CMultiPaneBSDF & aLayer = getLayer(); const double tauDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::T); - EXPECT_NEAR(0.700846, tauDiff, 1e-6); + EXPECT_NEAR(0.701633, tauDiff, 1e-6); const double rhoDiff = aLayer.DiffDiff(minLambda, maxLambda, Side::Front, PropertySimple::R); - EXPECT_NEAR(0.130002, rhoDiff, 1e-6); + EXPECT_NEAR(0.136723, rhoDiff, 1e-6); const double absDiff1 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 1); - EXPECT_NEAR(0.071834, absDiff1, 1e-6); + EXPECT_NEAR(0.064227, absDiff1, 1e-6); const double absDiff2 = aLayer.AbsDiff(minLambda, maxLambda, Side::Front, 2); - EXPECT_NEAR(0.097319, absDiff2, 1e-6); + EXPECT_NEAR(0.097417, absDiff2, 1e-6); const double theta = 0; const double phi = 0; const double tauHem = aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi); - EXPECT_NEAR(0.778732, tauHem, 1e-6); + EXPECT_NEAR(0.779177, tauHem, 1e-6); const double tauDir = aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::T, theta, phi); - EXPECT_NEAR(0.778663, tauDir, 1e-6); + EXPECT_NEAR(0.778669, tauDir, 1e-6); const double rhoHem = aLayer.DirHem(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi); - EXPECT_NEAR(0.065530, rhoHem, 1e-6); + EXPECT_NEAR(0.072179, rhoHem, 1e-6); const double rhoDir = aLayer.DirDir(minLambda, maxLambda, Side::Front, PropertySimple::R, theta, phi); - EXPECT_NEAR(0.065426, rhoDir, 1e-6); + EXPECT_NEAR(0.065510, rhoDir, 1e-6); const double abs1 = aLayer.Abs(minLambda, maxLambda, Side::Front, 1, theta, phi); - EXPECT_NEAR(0.067492, abs1, 1e-6); + EXPECT_NEAR(0.060343, abs1, 1e-6); const double abs2 = aLayer.Abs(minLambda, maxLambda, Side::Front, 2, theta, phi); - EXPECT_NEAR(0.088246, abs2, 1e-6); + EXPECT_NEAR(0.088301, abs2, 1e-6); } diff --git a/src/SingleLayerOptics/src/VenetianSegments.cpp b/src/SingleLayerOptics/src/VenetianSegments.cpp index 3c11268f..30017d23 100644 --- a/src/SingleLayerOptics/src/VenetianSegments.cpp +++ b/src/SingleLayerOptics/src/VenetianSegments.cpp @@ -120,7 +120,7 @@ namespace SingleLayerOptics namespace Helper { - // In case of outgoing front and incoming back, unit vector need to be inversed. + // In case of outgoing front and incoming back, unit vector need to be inverse. Viewer::CSegment2D unitVector(const CBeamDirection & t_Direction, const BSDFDirection t_BSDFDirection, const Side t_Side) @@ -156,17 +156,9 @@ namespace SingleLayerOptics double aResult = 0; for(size_t i = 0; i < slatRadiances.size(); ++i) { - const auto & segment = slats[i]; - - auto testRadiance = slatRadiances[i]; - auto testVisibleFraction = visibleFraction[i]; - auto testLength = segment.length(); - auto testSurfaceNormal = segment.surfaceUnitNormal(); - auto testDotProduct = segment.surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint()); - aResult += - visibleFraction[i] * slatRadiances[i] * segment.length() - * std::abs(segment.surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint())); + visibleFraction[i] * slatRadiances[i] * slats[i].length() + * std::abs(slats[i].surfaceUnitNormal().dotProduct(outgoingUnitVector.endPoint())); } return aResult diff --git a/src/SingleLayerOptics/tst/units/VenetianCellCurved55_1.unit.cpp b/src/SingleLayerOptics/tst/units/VenetianCellCurved55_1.unit.cpp index 8380f5b8..0069ba7d 100644 --- a/src/SingleLayerOptics/tst/units/VenetianCellCurved55_1.unit.cpp +++ b/src/SingleLayerOptics/tst/units/VenetianCellCurved55_1.unit.cpp @@ -91,8 +91,8 @@ TEST_F(TestVenetianCellCurved55_1, TestVenetian2) Tdir_dif = aCell->T_dir_dif(aSide, aDirection, outDirection); Rdir_dif = aCell->R_dir_dif(aSide, aDirection, outDirection); - EXPECT_NEAR(0.085068844915552735, Tdir_dif, 1e-6); - EXPECT_NEAR(0.19224309643794207, Rdir_dif, 1e-6); + EXPECT_NEAR(0.074890457852183318, Tdir_dif, 1e-6); + EXPECT_NEAR(0.19781642870300131, Rdir_dif, 1e-6); // Back side aSide = Side::Back; diff --git a/src/SingleLayerOptics/tst/units/VenetianDirectionalMatrix.unit.cpp b/src/SingleLayerOptics/tst/units/VenetianDirectionalMatrix.unit.cpp index eb20e65c..74b4e600 100644 --- a/src/SingleLayerOptics/tst/units/VenetianDirectionalMatrix.unit.cpp +++ b/src/SingleLayerOptics/tst/units/VenetianDirectionalMatrix.unit.cpp @@ -237,7 +237,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments2_Rise TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.1_Slat=0_nSegments=2_Rise=3.csv", - true + false ); } @@ -252,7 +252,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", - true + false ); } @@ -267,7 +267,7 @@ TEST(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Ri TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", - true + false ); } diff --git a/src/SingleLayerOptics/tst/units/VenetianDirectionalShadeCurvedMinus45_0.unit.cpp b/src/SingleLayerOptics/tst/units/VenetianDirectionalShadeCurvedMinus45_0.unit.cpp index c47ce827..5b419a73 100644 --- a/src/SingleLayerOptics/tst/units/VenetianDirectionalShadeCurvedMinus45_0.unit.cpp +++ b/src/SingleLayerOptics/tst/units/VenetianDirectionalShadeCurvedMinus45_0.unit.cpp @@ -64,8 +64,8 @@ TEST_F(TestVenetianDirectionalShadeCurvedMinus45_0, TestVenetian1) BSDFIntegrator aResults = aShade->getResults(); double tauDiff = aResults.DiffDiff(Side::Front, PropertySimple::T); - EXPECT_NEAR(0.51004483165182746, tauDiff, 1e-6); + EXPECT_NEAR(0.395816, tauDiff, 1e-6); double RfDiff = aResults.DiffDiff(Side::Front, PropertySimple::R); - EXPECT_NEAR(0.52127289710024438, RfDiff, 1e-6); + EXPECT_NEAR(0.562219, RfDiff, 1e-6); } diff --git a/src/SingleLayerOptics/tst/units/VenetianUniformMatrix.unit.cpp b/src/SingleLayerOptics/tst/units/VenetianUniformMatrix.unit.cpp index 0f903145..2ec071ae 100644 --- a/src/SingleLayerOptics/tst/units/VenetianUniformMatrix.unit.cpp +++ b/src/SingleLayerOptics/tst/units/VenetianUniformMatrix.unit.cpp @@ -182,7 +182,7 @@ TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise3) TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianUniformMatrixTb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", TEST_DATA_DIR "/data/TestVenetianUniformMatrixRb_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", - true + false ); } @@ -197,7 +197,7 @@ TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Rise TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", TEST_DATA_DIR "/data/TestVenetianUniformMatrixTb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", TEST_DATA_DIR "/data/TestVenetianUniformMatrixRb_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv", - true + false ); } diff --git a/src/Viewer/tst/units/Segment2D.unit.cpp b/src/Viewer/tst/units/Segment2D.unit.cpp index cfdd923d..874f6205 100644 --- a/src/Viewer/tst/units/Segment2D.unit.cpp +++ b/src/Viewer/tst/units/Segment2D.unit.cpp @@ -30,7 +30,7 @@ TEST_F(TestSegment2D, Segment2DTest1) EXPECT_NEAR(0, angle, 1e-6); const auto surfaceNormal{aSegment.surfaceUnitNormal()}; - const CPoint2D correctSurfaceNormal{0.0, -1.0}; + const CPoint2D correctSurfaceNormal{0.0, 1.0}; EXPECT_TRUE(correctSurfaceNormal == surfaceNormal); } @@ -51,7 +51,7 @@ TEST_F(TestSegment2D, Segment2DTest2) EXPECT_NEAR(45, angle, 1e-6); const auto surfaceNormal{aSegment.surfaceUnitNormal()}; - const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476}; + const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476}; EXPECT_TRUE(correctSurfaceNormal == surfaceNormal); } @@ -70,7 +70,7 @@ TEST_F(TestSegment2D, Segment2DTest3) EXPECT_NEAR(45, angle, 1e-6); const auto surfaceNormal{aSegment.surfaceUnitNormal()}; - const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476}; + const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476}; EXPECT_TRUE(correctSurfaceNormal == surfaceNormal); } @@ -89,7 +89,7 @@ TEST_F(TestSegment2D, Segment2DTest4) EXPECT_NEAR(45, angle, 1e-6); const auto surfaceNormal{aSegment.surfaceUnitNormal()}; - const CPoint2D correctSurfaceNormal{0.7071067811865476, -0.7071067811865476}; + const CPoint2D correctSurfaceNormal{-0.7071067811865476, 0.7071067811865476}; EXPECT_TRUE(correctSurfaceNormal == surfaceNormal); } \ No newline at end of file