Skip to content

Commit

Permalink
Add gaps with forced ventilation
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-wacker committed Oct 11, 2022
1 parent 2bf22fb commit 5c13611
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 46 deletions.
95 changes: 51 additions & 44 deletions src/Tarcog/src/BaseShade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,37 +192,41 @@ namespace Tarcog
double tempGap2 = t_Gap2->layerTemperature();
double Tav1 = t_Gap1->averageTemperature();
double Tav2 = t_Gap2->averageTemperature();
if(tempGap1 > tempGap2)
{
t_Gap1->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
}
else
// TODO What if only one ventilation is forced?
if (!(t_Gap1->isVentilationForced() && t_Gap2->isVentilationForced()))
{
t_Gap1->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
if (tempGap1 > tempGap2)
{
t_Gap1->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
}
else
{
t_Gap1->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
}
double drivingPressure = t_Gap1->getAirflowReferencePoint(tempGap2);
double ratio = t_Gap1->getThickness() / t_Gap2->getThickness();
double A1 = t_Gap1->bernoullyPressureTerm() + t_Gap1->pressureLossTerm();
double A2 = t_Gap2->bernoullyPressureTerm() + t_Gap2->pressureLossTerm();
double B1 = t_Gap1->hagenPressureTerm();
double B2 = t_Gap2->hagenPressureTerm();
double A = A1 + pow(ratio, 2) * A2;
double B = B1 + ratio * B2;
double speed1 =
(sqrt(std::abs(pow(B, 2.0) + 4 * A * drivingPressure)) - B) / (2.0 * A);
double speed2 = speed1 / ratio;
t_Gap1->setFlowSpeed(speed1);
t_Gap2->setFlowSpeed(speed2);
}
double drivingPressure = t_Gap1->getAirflowReferencePoint(tempGap2);
double ratio = t_Gap1->getThickness() / t_Gap2->getThickness();
double A1 = t_Gap1->bernoullyPressureTerm() + t_Gap1->pressureLossTerm();
double A2 = t_Gap2->bernoullyPressureTerm() + t_Gap2->pressureLossTerm();
double B1 = t_Gap1->hagenPressureTerm();
double B2 = t_Gap2->hagenPressureTerm();
double A = A1 + pow(ratio, 2) * A2;
double B = B1 + ratio * B2;
double speed1 =
(sqrt(std::abs(pow(B, 2.0) + 4 * A * drivingPressure)) - B) / (2.0 * A);
double speed2 = speed1 / ratio;
t_Gap1->setFlowSpeed(speed1);
t_Gap2->setFlowSpeed(speed2);

double beta1 = t_Gap1->betaCoeff();
double beta2 = t_Gap2->betaCoeff();
Expand Down Expand Up @@ -296,23 +300,26 @@ namespace Tarcog
{
double tempEnvironment = t_Environment->getGasTemperature();
double TavGap = t_Gap->averageTemperature();
if(tempGap > tempEnvironment)
if (!t_Gap->isVentilationForced())
{
t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
}
else
{
t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
if(tempGap > tempEnvironment)
{
t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
m_ShadeOpenings->Aeq_top(),
AirVerticalDirection::Up);
}
else
{
t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
m_ShadeOpenings->Aeq_bot(),
AirVerticalDirection::Down);
}
double drivingPressure = t_Gap->getAirflowReferencePoint(tempEnvironment);
double A = t_Gap->bernoullyPressureTerm() + t_Gap->pressureLossTerm();
double B = t_Gap->hagenPressureTerm();
double speed = (sqrt(std::abs(pow(B, 2) + 4 * A * drivingPressure)) - B) / (2 * A);
t_Gap->setFlowSpeed(speed);
}
double drivingPressure = t_Gap->getAirflowReferencePoint(tempEnvironment);
double A = t_Gap->bernoullyPressureTerm() + t_Gap->pressureLossTerm();
double B = t_Gap->hagenPressureTerm();
double speed = (sqrt(std::abs(pow(B, 2) + 4 * A * drivingPressure)) - B) / (2 * A);
t_Gap->setFlowSpeed(speed);
double beta = t_Gap->betaCoeff();
double alpha = 1 - beta;

Expand Down
23 changes: 21 additions & 2 deletions src/Tarcog/src/IGUGapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@ namespace Tarcog
{
CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure)
CGasLayer(t_Pressure),
m_ForcedVentilation(false)
{}

CIGUGapLayer::CIGUGapLayer(double const t_Thickness,
double const t_Pressure,
const Gases::CGas & t_Gas) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure, t_Gas)
CGasLayer(t_Pressure, t_Gas),
m_ForcedVentilation(false)
{}

CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure, double const t_AirSpeed, AirHorizontalDirection const t_AirHorizontalDirection) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure, t_AirSpeed, t_AirHorizontalDirection),
m_ForcedVentilation(true)
{}

CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure, double const t_AirSpeed, AirVerticalDirection const t_AirVerticalDirection) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure, t_AirSpeed, t_AirVerticalDirection),
m_ForcedVentilation(true)
{}

void CIGUGapLayer::connectToBackSide(std::shared_ptr<CBaseLayer> const & t_Layer)
Expand Down Expand Up @@ -146,6 +160,11 @@ namespace Tarcog
return m_Pressure;
}

bool CIGUGapLayer::isVentilationForced() const
{
return m_ForcedVentilation;
}

std::shared_ptr<CBaseLayer> CIGUGapLayer::clone() const
{
return std::make_shared<CIGUGapLayer>(*this);
Expand Down
5 changes: 5 additions & 0 deletions src/Tarcog/src/IGUGapLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace Tarcog
public:
CIGUGapLayer(double t_Thickness, double t_Pressure);
CIGUGapLayer(double t_Thickness, double t_Pressure, const Gases::CGas & t_Gas);
CIGUGapLayer(double t_Thickness, double t_Pressure, double t_AirSpeed, AirHorizontalDirection const t_AirHorizontalDirection);
CIGUGapLayer(double t_Thickness, double t_Pressure, double t_AirSpeed, AirVerticalDirection const t_AirVerticalDirection);

void connectToBackSide(const std::shared_ptr<CBaseLayer> & t_Layer) override;

Expand All @@ -30,10 +32,13 @@ namespace Tarcog

double getPressure() override;

bool isVentilationForced() const;

std::shared_ptr<CBaseLayer> clone() const override;


protected:
bool m_ForcedVentilation;
void initializeStateVariables() override;
void calculateConvectionOrConductionFlow() override;

Expand Down
12 changes: 12 additions & 0 deletions src/Tarcog/src/IGUVentilatedGapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ namespace Tarcog
double const t_Abot,
AirVerticalDirection const & t_Direction)
{
// TODO Is this what we want?
if (this->m_ForcedVentilation) {
assert(t_Direction == m_AirVerticalDirection);
}
m_AirVerticalDirection = t_Direction;
auto Ain = 0.0;
auto Aout = 0.0;
Expand Down Expand Up @@ -67,6 +71,10 @@ namespace Tarcog
double const t_botTemp,
AirVerticalDirection const & t_Direction)
{
// TODO Is this what we want?
if (this->m_ForcedVentilation) {
assert(t_Direction == m_AirVerticalDirection);
}
m_AirVerticalDirection = t_Direction;
switch(m_AirVerticalDirection)
{
Expand All @@ -90,6 +98,10 @@ namespace Tarcog

void CIGUVentilatedGapLayer::setFlowSpeed(double const t_speed)
{
// TODO Is this what we want?
if (this->m_ForcedVentilation) {
assert(t_speed == m_AirSpeed);
}
m_AirSpeed = t_speed;
resetCalculated();
}
Expand Down
10 changes: 10 additions & 0 deletions src/Tarcog/src/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ namespace Tarcog
return std::make_shared<CIGUGapLayer>(thickness, pressure, gas);
}

std::shared_ptr<CIGUGapLayer> Layers::forced_ventilated_gap(const double thickness, const double airSpeed, AirHorizontalDirection const airHorizontalDirection, const double pressure)
{
return std::make_shared<CIGUGapLayer>(thickness, pressure, airSpeed, airHorizontalDirection);
}

std::shared_ptr<CIGUGapLayer> Layers::forced_ventilated_gap(const double thickness, const double airSpeed, AirVerticalDirection const airVerticalDirection, const double pressure)
{
return std::make_shared<CIGUGapLayer>(thickness, pressure, airSpeed, airVerticalDirection);
}

std::shared_ptr<CIGUSolidLayer> Layers::updateMaterialData(
const std::shared_ptr<CIGUSolidLayer> & layer, double density, double youngsModulus)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Tarcog/src/Layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace Tarcog
static std::shared_ptr<CIGUGapLayer>
gap(double thickness, const Gases::CGas & gas, double pressure = 101325);

static std::shared_ptr<CIGUGapLayer> forced_ventilated_gap(double thickness, double airSpeed, AirHorizontalDirection const t_AirHorizontalDirection, double pressure = 101325);
static std::shared_ptr<CIGUGapLayer> forced_ventilated_gap(double thickness, double airSpeed, AirVerticalDirection const t_AirVerticalDirection, double pressure = 101325);

static std::shared_ptr<CIGUGapLayer>
addCircularPillar(const std::shared_ptr<CIGUGapLayer> & gap,
double conductivity,
Expand Down
125 changes: 125 additions & 0 deletions src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#include <memory>
#include <gtest/gtest.h>

#include "WCETarcog.hpp"

class TestGapLayerInBetweenVentilation : public testing::Test
{
private:
std::shared_ptr<Tarcog::ISO15099::CSingleSystem> m_TarcogSystem;

protected:
void SetUp() override
{
/////////////////////////////////////////////////////////
// Outdoor
/////////////////////////////////////////////////////////
auto airTemperature = 255.15; // Kelvins
auto airSpeed = 5.5; // meters per second
auto tSky = 255.15; // Kelvins
auto solarRadiation = 0.0;

auto Outdoor = Tarcog::ISO15099::Environments::outdoor(
airTemperature, airSpeed, solarRadiation, tSky, Tarcog::ISO15099::SkyModel::AllSpecified);
ASSERT_TRUE(Outdoor != nullptr);
Outdoor->setHCoeffModel(Tarcog::ISO15099::BoundaryConditionsCoeffModel::CalculateH);

/////////////////////////////////////////////////////////
/// Indoor
/////////////////////////////////////////////////////////

auto roomTemperature = 295.15;

auto Indoor = Tarcog::ISO15099::Environments::indoor(roomTemperature);
ASSERT_TRUE(Indoor != nullptr);

// IGU
auto solidLayerThickness = 0.005715; // [m]
auto solidLayerConductance = 1.0;

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

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

auto shadeLayerThickness = 0.01;
auto shadeLayerConductance = 160.0;
auto Atop = 0.1;
auto Abot = 0.1;
auto Aleft = 0.1;
auto Aright = 0.1;
auto Afront = 0.2;

EffectiveLayers::ShadeOpenness openness{Afront, Aleft, Aright, Atop, Abot};

double windowWidth = 1;
double windowHeight = 1;

EffectiveLayers::EffectiveLayerOther effectiveLayer{
windowWidth, windowHeight, shadeLayerThickness, openness};

EffectiveLayers::EffectiveOpenness effOpenness{effectiveLayer.getEffectiveOpenness()};

auto shadeLayer = Tarcog::ISO15099::Layers::shading(
shadeLayerThickness, shadeLayerConductance, effOpenness);

ASSERT_TRUE(shadeLayer != nullptr);

auto gapThickness = 0.0127;
auto gapAirSpeed = 0.5;
auto gapAirHorizontalDirection = Tarcog::ISO15099::AirVerticalDirection::Up;
auto gap1 = Tarcog::ISO15099::Layers::forced_ventilated_gap(
gapThickness, gapAirSpeed, gapAirHorizontalDirection);
ASSERT_TRUE(gap1 != nullptr);

auto gap2 = Tarcog::ISO15099::Layers::forced_ventilated_gap(
gapThickness, gapAirSpeed, gapAirHorizontalDirection);
ASSERT_TRUE(gap2 != nullptr);

Tarcog::ISO15099::CIGU aIGU(windowWidth, windowHeight);
aIGU.addLayers({layer1, gap1, shadeLayer, gap2, layer2});

// Alternative way of adding layers.
// aIGU.addLayer(layer1);
// aIGU.addLayer(gap1);
// aIGU.addLayer(shadeLayer);
// aIGU.addLayer(gap2);
// aIGU.addLayer(layer2);

/////////////////////////////////////////////////////////
/// System
/////////////////////////////////////////////////////////
m_TarcogSystem = std::make_shared<Tarcog::ISO15099::CSingleSystem>(aIGU, Indoor, Outdoor);
ASSERT_TRUE(m_TarcogSystem != nullptr);
}

public:
std::shared_ptr<Tarcog::ISO15099::CBaseIGULayer> GetGap1() const
{
return m_TarcogSystem->getGapLayers()[0];
};

std::shared_ptr<Tarcog::ISO15099::CBaseIGULayer> GetGap2() const
{
return m_TarcogSystem->getGapLayers()[1];
};
};

TEST_F(TestGapLayerInBetweenVentilation, VentilationFlow)
{
SCOPED_TRACE("Begin Test: Test Forced Ventilated Gap Layer - Intial Airflow");

auto aLayer = GetGap1();

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

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

aLayer = GetGap2();
ASSERT_TRUE(aLayer != nullptr);
gainEnergy = aLayer->getGainFlow();
EXPECT_NEAR(-32.988234, gainEnergy, 1e-4);
}

0 comments on commit 5c13611

Please sign in to comment.