Skip to content

Commit

Permalink
Use closed shades to model sealed forced-ventilation gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-wacker committed Nov 22, 2022
1 parent e174d7b commit 3e1e6a4
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 161 deletions.
14 changes: 0 additions & 14 deletions src/Tarcog/src/IGU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,22 +534,8 @@ namespace Tarcog
}
if(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer) != nullptr)
{
auto gap = std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer);
if(std::dynamic_pointer_cast<CIGUShadeLayer>(t_Layer->getPreviousLayer())
!= nullptr)
{
auto newLayer = std::make_shared<CIGUVentilatedGapLayer>(gap);
replaceLayer(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer), newLayer);
}
else if(gap->isVentilationForced()
&& std::dynamic_pointer_cast<CIGUSolidLayer>(t_Layer->getPreviousLayer())
!= nullptr
&& std::dynamic_pointer_cast<CIGUShadeLayer>(t_Layer->getPreviousLayer())
== nullptr
&& std::dynamic_pointer_cast<CIGUSolidLayer>(t_Layer->getNextLayer())
!= nullptr
&& std::dynamic_pointer_cast<CIGUShadeLayer>(t_Layer->getNextLayer())
== nullptr)
{
auto newLayer = std::make_shared<CIGUVentilatedGapLayer>(
std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer));
Expand Down
72 changes: 0 additions & 72 deletions src/Tarcog/src/IGUVentilatedGapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
#include <cassert>
#include <stdexcept>

#include "BaseShade.hpp"
#include "TarcogConstants.hpp"
#include "IGUVentilatedGapLayer.hpp"
#include "WCEGases.hpp"
#include "WCECommon.hpp"

using FenestrationCommon::Side;

namespace Tarcog
{
Expand Down Expand Up @@ -159,77 +154,10 @@ namespace Tarcog
CIGUGapLayer::calculateConvectionOrConductionFlow();
if(!isCalculated())
{
if(isVentilationForced() && m_NextLayer != nullptr && m_PreviousLayer != nullptr
&& std::dynamic_pointer_cast<CIGUSolidLayer>(m_PreviousLayer) != nullptr
&& std::dynamic_pointer_cast<CIGUShadeLayer>(m_PreviousLayer) == nullptr
&& std::dynamic_pointer_cast<CIGUSolidLayer>(m_NextLayer) != nullptr
&& std::dynamic_pointer_cast<CIGUShadeLayer>(m_NextLayer) == nullptr)
{
auto previousSolidLayer =
std::dynamic_pointer_cast<CIGUSolidLayer>(m_PreviousLayer);
auto nextSolidLayer = std::dynamic_pointer_cast<CIGUSolidLayer>(m_NextLayer);
calcSealedForcedVentilationGapTemperatures(previousSolidLayer, nextSolidLayer);
}
ventilatedFlow();
}
}

void CIGUVentilatedGapLayer::calcSealedForcedVentilationGapTemperatures(
std::shared_ptr<CIGUSolidLayer> t_PreviousLayer,
std::shared_ptr<CIGUSolidLayer> t_NextLayer)
{
// Inspired by `CIGUShadeLayer::calcEdgeShadeFlow`
double TgapOut = layerTemperature();
double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW;
bool converged = false;
size_t iterationStep = 0;

double tempGap = layerTemperature();
ForcedVentilation forcedVentilation = getForcedVentilation();
setFlowSpeed(forcedVentilation.Speed);
// m_AirSpeed = forcedVentilation.Speed;
double tempPreviousLayer = t_PreviousLayer->getTemperature(Side::Back);
while(!converged)
{
double TavGap = averageTemperature();
// To calculate `beta` we do not invoke `betaCoeff` because
// doing so results in an infinite recursion as it calls
// `calculateLayerHeatFlow`, which calls
// `calculateConvectionOrConductionFlow`, which calls this
// method.
double beta = exp(-m_Height / characteristicHeight());
double alpha = 1 - beta;

double TgapOutOld = TgapOut;

TgapOut = alpha * TavGap + beta * tempPreviousLayer;

setFlowTemperatures(tempPreviousLayer, TgapOut);
// m_inTemperature = tempPreviousLayer;
// m_outTemperature = TgapOut;

tempGap = layerTemperature();

TgapOut = RelaxationParameter * tempGap + (1 - RelaxationParameter) * TgapOutOld;

converged = std::abs(TgapOut - TgapOutOld)
< IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW;

++iterationStep;
if(iterationStep > IterationConstants::NUMBER_OF_STEPS)
{
RelaxationParameter -= IterationConstants::RELAXATION_PARAMETER_AIRFLOW_STEP;
iterationStep = 0;
if(RelaxationParameter == IterationConstants::RELAXATION_PARAMETER_AIRFLOW_MIN)
{
converged = true;
throw std::runtime_error("Airflow iterations fail to converge. "
"Maximum number of iteration steps reached.");
}
}
}
}

double CIGUVentilatedGapLayer::characteristicHeight()
{
const auto aProperties = m_Gas.getGasProperties();
Expand Down
4 changes: 0 additions & 4 deletions src/Tarcog/src/IGUVentilatedGapLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <memory>

#include "BaseShade.hpp"
#include "WCEGases.hpp"
#include "IGUGapLayer.hpp"

Expand Down Expand Up @@ -42,9 +41,6 @@ namespace Tarcog
double characteristicHeight();
double calcImpedance(double t_A) const;
void ventilatedFlow();
void calcSealedForcedVentilationGapTemperatures(
std::shared_ptr<CIGUSolidLayer> t_PreviousLayer,
std::shared_ptr<CIGUSolidLayer> t_NextLayer);

std::shared_ptr<CIGUGapLayer> m_Layer;
Gases::CGas m_ReferenceGas;
Expand Down
16 changes: 16 additions & 0 deletions src/Tarcog/src/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ namespace Tarcog
std::make_shared<CSurface>(backEmissivity, backTransmittance));
}

std::shared_ptr<CIGUShadeLayer> Layers::closedShading(double thickness,
double conductivity,
double frontEmissivity,
double frontTransmittance,
double backEmissivity,
double backTransmittance)
{
return std::make_shared<CIGUShadeLayer>(
thickness,
conductivity,
std::make_shared<CShadeOpenings>(0, 0, 0, 0, 0, 0),
std::make_shared<CSurface>(frontEmissivity, frontTransmittance),
std::make_shared<CSurface>(backEmissivity, backTransmittance));
}


std::shared_ptr<CIGUGapLayer>
Layers::addCircularPillar(const std::shared_ptr<CIGUGapLayer> & gap,
double conductivity,
Expand Down
8 changes: 8 additions & 0 deletions src/Tarcog/src/Layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "EffectiveOpenness.hpp"
#include "LayerInterfaces.hpp"
#include "TarcogConstants.hpp"
#include "BaseShade.hpp"

namespace Tarcog
{
Expand Down Expand Up @@ -40,6 +41,13 @@ namespace Tarcog
double backEmissivity = 0.84,
double backTransmittance = 0.0);

static std::shared_ptr<CIGUShadeLayer> closedShading(double thickness,
double conductivity,
double frontEmissivity = 0.84,
double frontTransmittance = 0.0,
double backEmissivity = 0.84,
double backTransmittance = 0.0);

static std::shared_ptr<CIGUGapLayer> gap(double thickness, double pressure = 101325);
static std::shared_ptr<CIGUGapLayer>
gap(double thickness, const Gases::CGas & gas, double pressure = 101325);
Expand Down
55 changes: 28 additions & 27 deletions src/Tarcog/tst/units/GapLayerSealedForcedVentilation.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class TestGapLayerSealedForcedVentilation : public testing::Test
auto solidLayerThickness = 0.005715; // [m]
auto solidLayerConductance = 1.0;

auto solidLayer1 =
auto solidLayer =
Tarcog::ISO15099::Layers::solid(solidLayerThickness, solidLayerConductance);
ASSERT_TRUE(solidLayer1 != nullptr);
ASSERT_TRUE(solidLayer != nullptr);

auto solidLayer2 =
Tarcog::ISO15099::Layers::solid(solidLayerThickness, solidLayerConductance);
ASSERT_TRUE(solidLayer2 != nullptr);
auto closedShadeLayer =
Tarcog::ISO15099::Layers::closedShading(solidLayerThickness, solidLayerConductance);
ASSERT_TRUE(closedShadeLayer != nullptr);

auto gapThickness = 0.0127;
auto gapAirSpeed = 0.5;
Expand All @@ -54,7 +54,7 @@ class TestGapLayerSealedForcedVentilation : public testing::Test
double windowWidth = 1;
double windowHeight = 1;
Tarcog::ISO15099::CIGU aIGU(windowWidth, windowHeight);
aIGU.addLayers({solidLayer1, gap, solidLayer2});
aIGU.addLayers({solidLayer, gap, closedShadeLayer});

/////////////////////////////////////////////////////////
/// System
Expand All @@ -66,7 +66,7 @@ class TestGapLayerSealedForcedVentilation : public testing::Test
}

public:
std::shared_ptr<Tarcog::ISO15099::CIGUSolidLayer> GetSolidLayer1() const
std::shared_ptr<Tarcog::ISO15099::CIGUSolidLayer> GetSolidLayer() const
{
auto solidLayer = m_TarcogSystem->getSolidLayers()[0];
assert(std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUSolidLayer>(solidLayer) != nullptr);
Expand All @@ -80,11 +80,12 @@ class TestGapLayerSealedForcedVentilation : public testing::Test
return std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUVentilatedGapLayer>(gap);
};

std::shared_ptr<Tarcog::ISO15099::CIGUSolidLayer> GetSolidLayer2() const
std::shared_ptr<Tarcog::ISO15099::CIGUShadeLayer> GetClosedShadeLayer() const
{
auto solidLayer = m_TarcogSystem->getSolidLayers()[1];
assert(std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUSolidLayer>(solidLayer) != nullptr);
return std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUSolidLayer>(solidLayer);
auto closedShadeLayer = m_TarcogSystem->getSolidLayers()[1];
assert(std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUShadeLayer>(closedShadeLayer)
!= nullptr);
return std::dynamic_pointer_cast<Tarcog::ISO15099::CIGUShadeLayer>(closedShadeLayer);
};
};

Expand All @@ -98,22 +99,22 @@ TEST_F(TestGapLayerSealedForcedVentilation, GainEnergy)

ASSERT_TRUE(aLayer != nullptr);
auto gainEnergy = aLayer->getGainFlow();
EXPECT_NEAR(-57.193291279467125, gainEnergy, 1e-4);
EXPECT_NEAR(132.26008267306551, gainEnergy, 1e-4);
}

TEST_F(TestGapLayerSealedForcedVentilation, Solid1Temperatures)
TEST_F(TestGapLayerSealedForcedVentilation, SolidTemperatures)
{
SCOPED_TRACE("Begin Test: Test Sealed Forced Ventilated Gap Layer - Solid 1 Temperatures");
SCOPED_TRACE("Begin Test: Test Sealed Forced Ventilated Gap Layer - Solid Temperatures");

auto aLayer = GetSolidLayer1();
auto aLayer = GetSolidLayer();

// Airflow iterations are set to 1e-4 and it cannot exceed that precision

ASSERT_TRUE(aLayer != nullptr);
auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front);
auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back);
EXPECT_NEAR(257.88610911376719, frontTemperature, 1e-4);
EXPECT_NEAR(258.34294987245784, backTemperature, 1e-4);
EXPECT_NEAR(262.13857535301037, frontTemperature, 1e-4);
EXPECT_NEAR(263.30867938548238, backTemperature, 1e-4);
}

TEST_F(TestGapLayerSealedForcedVentilation, GapTemperatures)
Expand All @@ -129,25 +130,25 @@ TEST_F(TestGapLayerSealedForcedVentilation, GapTemperatures)
auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back);
auto layerTemperature = aLayer->layerTemperature();
auto averageTemperature = aLayer->averageTemperature();
EXPECT_NEAR(258.34294987245784, frontTemperature, 1e-4);
EXPECT_NEAR(276.01222466583204, backTemperature, 1e-4);
EXPECT_NEAR(262.42249308270669, layerTemperature, 1e-4);
EXPECT_NEAR(267.17758726914496, averageTemperature, 1e-4);
EXPECT_NEAR(263.30867938548238, frontTemperature, 1e-4);
EXPECT_NEAR(284.72087553180552, backTemperature, 1e-4);
EXPECT_NEAR(284.71692368656022, layerTemperature, 1e-4);
EXPECT_NEAR(274.01477745864395, averageTemperature, 1e-4);
}

TEST_F(TestGapLayerSealedForcedVentilation, Solid2Temperatures)
TEST_F(TestGapLayerSealedForcedVentilation, ClosedShadeTemperatures)
{
SCOPED_TRACE("Begin Test: Test Sealed Forced Ventilated Gap Layer - Solid 2 Temperatures");
SCOPED_TRACE("Begin Test: Test Sealed Forced Ventilated Gap Layer - Closed Shade Temperatures");

auto aLayer = GetSolidLayer2();
auto aLayer = GetClosedShadeLayer();

// Airflow iterations are set to 1e-4 and it cannot exceed that precision

ASSERT_TRUE(aLayer != nullptr);
auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front);
auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back);
EXPECT_NEAR(276.01222466583204, frontTemperature, 1e-4);
EXPECT_NEAR(276.79592508330529, backTemperature, 1e-4);
EXPECT_NEAR(284.72087553180552, frontTemperature, 1e-4);
EXPECT_NEAR(285.13511319074695, backTemperature, 1e-4);
}

TEST_F(TestGapLayerSealedForcedVentilation, AirflowReferencePoint)
Expand All @@ -160,5 +161,5 @@ TEST_F(TestGapLayerSealedForcedVentilation, AirflowReferencePoint)

ASSERT_TRUE(aLayer != nullptr);
auto airflowReferencePoint = aLayer->getAirflowReferencePoint(0.5);
EXPECT_NEAR(6911.4449859804226, airflowReferencePoint, 1e-4);
EXPECT_NEAR(6912.4781021678982, airflowReferencePoint, 1e-4);
}
Loading

0 comments on commit 3e1e6a4

Please sign in to comment.