Skip to content

Commit

Permalink
Creation of uniform and directional matrices for testing with python.
Browse files Browse the repository at this point in the history
  • Loading branch information
vidanovic committed Nov 7, 2024
1 parent 8e544eb commit f26b91b
Show file tree
Hide file tree
Showing 38 changed files with 568 additions and 143 deletions.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

84 changes: 46 additions & 38 deletions src/SingleLayerOptics/tst/units/VenetianDirectionalMatrix.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ namespace
double curvatureRadius,
size_t numOfSlatSegments,
const std::string & expectedCsvFileTransmittance,
const std::string & expectedCsvFileReflectance)
const std::string & expectedCsvFileReflectance,
const bool updateResults = false)
{
constexpr bool updateResults{false};

// Create material with specified properties
auto material = SingleLayerOptics::Material::singleBandMaterial(Tmat, Tmat, Rfmat, Rbmat);

Expand Down Expand Up @@ -102,8 +101,9 @@ TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_Rise0)
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv", // Expected results
true
);
}

Expand All @@ -114,92 +114,100 @@ TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Ri
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat45_Rise0)
TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat45_nSegments1_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=45, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=45, nSegments=1, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 45, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.1_Slat=45_nSegments=1_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.1_Slat=45_nSegments=1_Rise=0.csv" // Expected results
0.016, 0.012, 45, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.1_Slat=45_nSegments=1_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=45_nSegments=1_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_Rise0)
TEST_F(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_nSegments1_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, nSegments=1, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.15, 0.15, // Material properties
0.016, 0.012, 45, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv"
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv",
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration3_T0_R0_2_Slat30_Rise0)
TEST_F(TestVenetianDirectionalMatrix, Configuration3_T0_R0_2_Slat30_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.2, Slat=30, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.2, Slat=30, nSegments5, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.2, 0.2, // Material properties
0.018, 0.014, 30, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv"
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv",
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_Rise3)
TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise3)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, Rise=3 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, nSegments=5, Rise=3 configuration.");
runVenetianLayerTest(
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, calculateCurvature(0.003, 0.016), // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", // Expected results
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_Rise5)
TEST_F(TestVenetianDirectionalMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Rise5)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, Curvature=5 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, nSegments=5, Rise=5 configuration.");
runVenetianLayerTest(
0.0, 0.15, 0.15, // Material properties
0.016, 0.012, 45, calculateCurvature(0.005, 0.016), // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv"
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_1_R0_1_Slat0_Rise0)
TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_1_R0_1_Slat0_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, nSegments=5, Rise=0 configuration.");
runVenetianLayerTest(
0.1, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_1_R0_7_Slat0_Rise0)
TEST_F(TestVenetianDirectionalMatrix, Configuration1_T0_1_R0_7_Slat0_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, nSegments=5, Rise=0 configuration.");
runVenetianLayerTest(
0.1, 0.7, 0.7, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixT_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixR_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixTf_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianDirectionalMatrixRf_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}
//clang-format on
Expand Down
94 changes: 71 additions & 23 deletions src/SingleLayerOptics/tst/units/VenetianUniformMatrix.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ namespace
double slatTiltAngle,
double curvatureRadius,
size_t numOfSlatSegments,
const std::string & expectedCsvFile)
const std::string & expectedCsvTransmittanceFile,
const std::string & expectedCsvReflectanceFile,
const bool updateExpectedResults = false)
{
// Create material with specified properties
auto material = SingleLayerOptics::Material::singleBandMaterial(Tmat, Tmat, Rfmat, Rbmat);
Expand All @@ -44,9 +46,28 @@ namespace
auto frontTransmittanceMatrix =
results.getMatrix(FenestrationCommon::Side::Front, FenestrationCommon::PropertySimple::T);

if(updateExpectedResults)
{
Helper::writeVectorToCSV(frontTransmittanceMatrix.getMatrix(),
expectedCsvTransmittanceFile);
}

// Load expected results from CSV and compare
const auto correctResults = Helper::readVectorFromCSV(expectedCsvFile);
const auto correctResults = Helper::readVectorFromCSV(expectedCsvTransmittanceFile);
Helper::compareMatrices(correctResults, frontTransmittanceMatrix.getMatrix());

auto frontReflectanceMatrix =
results.getMatrix(FenestrationCommon::Side::Front, FenestrationCommon::PropertySimple::R);

if(updateExpectedResults)
{
Helper::writeVectorToCSV(frontReflectanceMatrix.getMatrix(),
expectedCsvReflectanceFile);
}

// Load expected results from CSV and compare
const auto correctResultsReflectance = Helper::readVectorFromCSV(expectedCsvReflectanceFile);
Helper::compareMatrices(correctResultsReflectance, frontReflectanceMatrix.getMatrix());
}

double calculateCurvature(const double t_Rise, const double t_SlatWidth)
Expand All @@ -72,80 +93,107 @@ class TestVenetianUniformMatrix : public ::testing::Test
};

// clang-format off
TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_Rise0)
TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_nSegments1_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, nSegments=1, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, nSegments=1, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_Rise0)
TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_nSegments1_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, nSegments1, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.15, 0.15, // Material properties
0.016, 0.012, 45, 0, // Geometry properties
1, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv"
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv",
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration3_T0_R0_2_Slat30_Rise0)
TEST_F(TestVenetianUniformMatrix, Configuration3_T0_R0_2_Slat30_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.2, Slat=30, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.2, Slat=30, nSegments=5, Rise=0 configuration.");
runVenetianLayerTest(
0.0, 0.2, 0.2, // Material properties
0.018, 0.014, 30, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv"
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv",
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_Rise3)
TEST_F(TestVenetianUniformMatrix, Configuration1_T0_R0_1_Slat0_nSegments5_Rise3)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, Rise=3 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, nSegments5, Rise=3 configuration.");
runVenetianLayerTest(
0.0, 0.1, 0.1, // Material properties
0.016, 0.012, 0, calculateCurvature(0.003, 0.016), // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv", // Expected results
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_Rise5)
TEST_F(TestVenetianUniformMatrix, Configuration2_T0_R0_15_Slat45_nSegments5_Rise5)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, Curvature=5 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, nSegments=5, Curvature=5 configuration.");
runVenetianLayerTest(
0.0, 0.15, 0.15, // Material properties
0.016, 0.012, 45, calculateCurvature(0.005, 0.016), // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv"
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv",
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration1_T0_1_R0_1_Slat0_Rise0)
TEST_F(TestVenetianUniformMatrix, Configuration1_T0_1_R0_1_Slat0_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, nSegments=5, Rise=0 configuration.");
runVenetianLayerTest(
0.1, 0.1, 0.1, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}

TEST_F(TestVenetianUniformMatrix, Configuration1_T0_1_R0_7_Slat0_Rise0)
TEST_F(TestVenetianUniformMatrix, Configuration1_T0_1_R0_7_Slat0_nSegments5_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, Rise=0 configuration.");
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, nSegments=5, Rise=0 configuration.");
runVenetianLayerTest(
0.1, 0.7, 0.7, // Material properties
0.016, 0.012, 0, 0, // Geometry properties
5, // Number of slat segments
TEST_DATA_DIR "/data/TestVenetianUniformMatrix_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv" // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixTf_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv", // Expected results
TEST_DATA_DIR "/data/TestVenetianUniformMatrixRf_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv", // Expected results
true
);
}
//clang-format on
Expand Down

0 comments on commit f26b91b

Please sign in to comment.