-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/SingleLayerOptics/tst/units/HomogeneousDiffuseShade1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#include <memory> | ||
#include <gtest/gtest.h> | ||
|
||
#include "WCESingleLayerOptics.hpp" | ||
|
||
#include "csvHandlers.hpp" | ||
|
||
|
||
using namespace SingleLayerOptics; | ||
using namespace FenestrationCommon; | ||
|
||
class TestHomogenousDiffuseShade1 : public testing::Test | ||
{ | ||
private: | ||
std::shared_ptr<CBSDFLayer> m_Shade; | ||
|
||
protected: | ||
virtual void SetUp() | ||
{ | ||
// create material | ||
double Tmat = 0.1; | ||
double Rfmat = 0.7; | ||
double Rbmat = 0.7; | ||
auto aMaterial = Material::singleBandMaterial(Tmat, Tmat, Rfmat, Rbmat); | ||
|
||
auto aBSDF = BSDFHemisphere::create(BSDFBasis::Quarter); | ||
|
||
m_Shade = CBSDFLayerMaker::getHomogeneousDiffuseLayer(aMaterial, aBSDF); | ||
} | ||
|
||
public: | ||
std::shared_ptr<CBSDFLayer> GetShade() | ||
{ | ||
return m_Shade; | ||
}; | ||
}; | ||
|
||
TEST_F(TestHomogenousDiffuseShade1, TestSolarProperties) | ||
{ | ||
SCOPED_TRACE("Begin Test: Perfect diffuse shade - Solar properties."); | ||
|
||
std::shared_ptr<CBSDFLayer> aShade = GetShade(); | ||
|
||
BSDFIntegrator aResults = aShade->getResults(); | ||
|
||
double tauDiff = aResults.DiffDiff(Side::Front, PropertySimple::T); | ||
EXPECT_NEAR(0.000000000, tauDiff, 1e-6); | ||
|
||
double RfDiff = aResults.DiffDiff(Side::Front, PropertySimple::R); | ||
EXPECT_NEAR(0.550000000, RfDiff, 1e-6); | ||
|
||
auto aT = aResults.getMatrix(Side::Front, PropertySimple::T); | ||
|
||
Helper::writeVectorToCSV(aT.getMatrix(), TEST_DATA_DIR "/data/T.csv"); | ||
|
||
// Test only diagonal of transmittance matrix | ||
const size_t size = aT.size(); | ||
|
||
std::vector<double> correctResults(41, 0); | ||
|
||
std::vector<double> calculatedResults; | ||
for(size_t i = 0; i < size; ++i) | ||
{ | ||
calculatedResults.push_back(aT(i, i)); | ||
} | ||
|
||
EXPECT_EQ(correctResults.size(), calculatedResults.size()); | ||
for(size_t i = 0; i < size; ++i) | ||
{ | ||
EXPECT_NEAR(correctResults[i], calculatedResults[i], 1e-5); | ||
} | ||
|
||
auto aRf = aResults.getMatrix(Side::Front, PropertySimple::R); | ||
|
||
correctResults = {0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, | ||
0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, | ||
0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, | ||
0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, | ||
0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070, | ||
0.175070, 0.175070, 0.175070, 0.175070, 0.175070, 0.175070}; | ||
|
||
calculatedResults.clear(); | ||
for(size_t i = 0; i < size; ++i) | ||
{ | ||
calculatedResults.push_back(aRf(i, i)); | ||
} | ||
|
||
EXPECT_EQ(correctResults.size(), calculatedResults.size()); | ||
for(size_t i = 0; i < size; ++i) | ||
{ | ||
EXPECT_NEAR(correctResults[i], calculatedResults[i], 1e-5); | ||
} | ||
} | ||
|
||
TEST_F(TestHomogenousDiffuseShade1, AtWavelength) | ||
{ | ||
|
||
std::shared_ptr<CBSDFLayer> aShade = GetShade(); | ||
|
||
constexpr size_t wavelengthIndex{0u}; | ||
auto aResults{aShade->getResultsAtWavelength(wavelengthIndex)}; | ||
|
||
const auto correct{0.55}; | ||
const auto result{aResults.DiffDiff(Side::Front, PropertySimple::R)}; | ||
|
||
EXPECT_NEAR(correct, result, 1e-6); | ||
} |