Skip to content

Commit

Permalink
Uniform diffuse configurations tested agains WINDOW.
Browse files Browse the repository at this point in the history
  • Loading branch information
vidanovic committed Nov 1, 2024
1 parent f89bd82 commit 3a87158
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 41 deletions.

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.

165 changes: 124 additions & 41 deletions src/SingleLayerOptics/tst/units/VenetianUniformShadeMatrix.unit.cpp
Original file line number Diff line number Diff line change
@@ -1,71 +1,154 @@
#include <memory>
#include <gtest/gtest.h>
#include <memory>

#include "WCECommon.hpp"
#include "WCESingleLayerOptics.hpp"

#include "csvHandlers.hpp"
#include "matrixTesting.hpp"

class TestVenetianUniformShadeMatrix : public testing::Test
// Some function names can be identical across different unit tests. This is the purpose of putting
// it under annonymous namespace
namespace
{
private:
std::shared_ptr<SingleLayerOptics::CBSDFLayer> m_Shade;

protected:
void SetUp() override
// Helper function to set up and test a configuration
void runVenetianLayerTest(double Tmat,
double Rfmat,
double Rbmat,
double slatWidth,
double slatSpacing,
double slatTiltAngle,
double curvatureRadius,
size_t numOfSlatSegments,
const std::string & expectedCsvFile)
{
// create material
const auto Tmat = 0.0;
const auto Rfmat = 0.1;
const auto Rbmat = 0.1;
const auto aMaterial =
SingleLayerOptics::Material::singleBandMaterial(Tmat, Tmat, Rfmat, Rbmat);

// make cell geometry
const auto slatWidth = 0.016; // m
const auto slatSpacing = 0.012; // m
const auto slatTiltAngle = 0;
const auto curvatureRadius = 0;
const size_t numOfSlatSegments = 1;

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

// Create BSDF hemisphere
auto bsdf =
SingleLayerOptics::BSDFHemisphere::create(SingleLayerOptics::BSDFBasis::Quarter);

// make layer
m_Shade = SingleLayerOptics::CBSDFLayerMaker::getVenetianLayer(
aMaterial,
aBSDF,
// Create Venetian layer with the configuration parameters
auto shade = SingleLayerOptics::CBSDFLayerMaker::getVenetianLayer(
material,
bsdf,
slatWidth,
slatSpacing,
slatTiltAngle,
curvatureRadius,
numOfSlatSegments,
SingleLayerOptics::DistributionMethod::UniformDiffuse);

auto results = shade->getResults();
auto frontTransmittanceMatrix =
results.getMatrix(FenestrationCommon::Side::Front, FenestrationCommon::PropertySimple::T);

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

public:
SingleLayerOptics::CBSDFLayer & GetShade()
double calculateCurvature(const double t_Rise, const double t_SlatWidth)
{
return *m_Shade;
};
double curvature = 0;

if(t_Rise > 0)
{
double aRise = t_Rise;
if(t_Rise > t_SlatWidth / 2)
{
aRise = t_SlatWidth / 2;
}
curvature = (aRise * aRise + t_SlatWidth * t_SlatWidth / 4) / (2 * aRise);
}
return curvature;
}
} // namespace

class TestVenetianUniformShadeMatrix : public ::testing::Test
{
// Test fixture - no specific setup needed here as each test uses the helper function
};

TEST_F(TestVenetianUniformShadeMatrix, TestVenetianMatrix)
// clang-format off
TEST_F(TestVenetianUniformShadeMatrix, Configuration1_T0_R0_1_Slat0_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, 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/TestVenetianUniformShadeMatrix_T=0_R=0.1_Slat=0_nSegments=1_Rise=0.csv" // Expected results
);
}

TEST_F(TestVenetianUniformShadeMatrix, Configuration2_T0_R0_15_Slat45_Rise0)
{
SCOPED_TRACE("Begin Test: Venetian layer test quarter basis matrix.");
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, 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/TestVenetianUniformShadeMatrix_T=0_R=0.15_Slat=45_nSegments=1_Rise=0.csv"
);
}

auto & aShade = GetShade();
TEST_F(TestVenetianUniformShadeMatrix, Configuration3_T0_R0_2_Slat30_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.2, Slat=30, 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/TestVenetianUniformShadeMatrix_T=0_R=0.2_Slat=30_nSegments=5_Rise=0.csv"
);
}

auto aResults = aShade.getResults();
TEST_F(TestVenetianUniformShadeMatrix, Configuration1_T0_R0_1_Slat0_Rise3)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.1, Slat=0, 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/TestVenetianUniformShadeMatrix_T=0_R=0.1_Slat=0_nSegments=5_Rise=3.csv" // Expected results
);
}

FenestrationCommon::SquareMatrix & aT =
aResults.getMatrix(FenestrationCommon::Side::Front, FenestrationCommon::PropertySimple::T);
TEST_F(TestVenetianUniformShadeMatrix, Configuration2_T0_R0_15_Slat45_Rise5)
{
SCOPED_TRACE("Testing Venetian layer with T=0, R=0.15, Slat=45, 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/TestVenetianUniformShadeMatrix_T=0_R=0.15_Slat=45_nSegments=5_Rise=5.csv"
);
}

const std::string fileName =
TEST_DATA_DIR "/data/TestVenetianUniformShadeMatrix_T=0_R=0.1_Slat=0.csv";
const auto correctResults{Helper::readVectorFromCSV(fileName)};
TEST_F(TestVenetianUniformShadeMatrix, Configuration1_T0_1_R0_1_Slat0_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, 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/TestVenetianUniformShadeMatrix_T=0.1_R=0.1_Slat=0_nSegments=5_Rise=0.csv" // Expected results
);
}

Helper::compareMatrices(correctResults, aT.getMatrix());
TEST_F(TestVenetianUniformShadeMatrix, Configuration1_T0_1_R0_7_Slat0_Rise0)
{
SCOPED_TRACE("Testing Venetian layer with T=0.1, R=0.1, Slat=0, 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/TestVenetianUniformShadeMatrix_T=0.1_R=0.7_Slat=0_nSegments=5_Rise=0.csv" // Expected results
);
}
//clang-format on

// Add more configurations as needed

0 comments on commit 3a87158

Please sign in to comment.