Skip to content

Commit

Permalink
Use existing ForcedVentilation member of CGasLayer declared in `L…
Browse files Browse the repository at this point in the history
…ayerInterfaces`
  • Loading branch information
simon-wacker committed Oct 12, 2022
1 parent bc7aed5 commit f7d6c6e
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 129 deletions.
108 changes: 59 additions & 49 deletions src/Tarcog/src/BaseShade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ namespace Tarcog
void CIGUShadeLayer::calcInBetweenShadeFlow(std::shared_ptr<CIGUVentilatedGapLayer> t_Gap1,
std::shared_ptr<CIGUVentilatedGapLayer> t_Gap2)
{
// TODO What if only one ventilation is forced?
if(t_Gap1->isVentilationForced() && t_Gap2->isVentilationForced())
{
ForcedVentilation forcedVentilation1 = t_Gap1->getForcedVentilation();
ForcedVentilation forcedVentilation2 = t_Gap2->getForcedVentilation();
t_Gap1->setFlowSpeed(forcedVentilation1.Speed);
t_Gap2->setFlowSpeed(forcedVentilation2.Speed);
t_Gap1->setFlowTemperatures(forcedVentilation1.Temperature,
forcedVentilation1.Temperature,
AirVerticalDirection::None);
t_Gap2->setFlowTemperatures(forcedVentilation2.Temperature,
forcedVentilation2.Temperature,
AirVerticalDirection::None);
return;
}
double Tup = t_Gap1->layerTemperature();
double Tdown = t_Gap2->layerTemperature();
double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW;
Expand All @@ -192,41 +207,37 @@ namespace Tarcog
double tempGap2 = t_Gap2->layerTemperature();
double Tav1 = t_Gap1->averageTemperature();
double Tav2 = t_Gap2->averageTemperature();
// TODO What if only one ventilation is forced?
if (!(t_Gap1->isVentilationForced() && t_Gap2->isVentilationForced()))
if(tempGap1 > tempGap2)
{
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);
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 beta1 = t_Gap1->betaCoeff();
double beta2 = t_Gap2->betaCoeff();
Expand All @@ -252,17 +263,17 @@ namespace Tarcog

AirVerticalDirection gap1Direction = AirVerticalDirection::None;
AirVerticalDirection gap2Direction = AirVerticalDirection::None;
if(tempGap1 > tempGap2)
{
gap1Direction = AirVerticalDirection::Up;
gap2Direction = AirVerticalDirection::Down;
}
else
{
gap1Direction = AirVerticalDirection::Down;
gap2Direction = AirVerticalDirection::Up;
}

if(!(t_Gap1->isVentilationForced() && t_Gap2->isVentilationForced()))
if(tempGap1 > tempGap2)
{
gap1Direction = AirVerticalDirection::Up;
gap2Direction = AirVerticalDirection::Down;
}
else
{
gap1Direction = AirVerticalDirection::Down;
gap2Direction = AirVerticalDirection::Up;
}
converged =
std::abs(Tup - TupOld) < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW;
converged =
Expand All @@ -279,12 +290,11 @@ namespace Tarcog
throw std::runtime_error("Airflow iterations fail to converge. Maximum number "
"of iteration steps reached.");
}
double qv1 = t_Gap1->getGainFlow();
double qv2 = t_Gap2->getGainFlow();
t_Gap1->smoothEnergyGain(qv1, qv2);
t_Gap2->smoothEnergyGain(qv1, qv2);
}

double qv1 = t_Gap1->getGainFlow();
double qv2 = t_Gap2->getGainFlow();
t_Gap1->smoothEnergyGain(qv1, qv2);
t_Gap2->smoothEnergyGain(qv1, qv2);
}

void CIGUShadeLayer::calcEdgeShadeFlow(std::shared_ptr<CEnvironment> t_Environment,
Expand Down
24 changes: 6 additions & 18 deletions src/Tarcog/src/IGUGapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,21 @@ namespace Tarcog
{
CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure),
m_ForcedVentilation(false)
CGasLayer(t_Pressure)
{}

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

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) :
CIGUGapLayer::CIGUGapLayer(double const t_Thickness,
double const t_Pressure,
const ForcedVentilation & t_ForcedVentilation) :
CBaseIGULayer(t_Thickness),
CGasLayer(t_Pressure, t_AirSpeed, t_AirVerticalDirection),
m_ForcedVentilation(true)
CGasLayer(t_Pressure, t_ForcedVentilation)
{}

void CIGUGapLayer::connectToBackSide(std::shared_ptr<CBaseLayer> const & t_Layer)
Expand Down Expand Up @@ -160,11 +153,6 @@ 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
8 changes: 3 additions & 5 deletions src/Tarcog/src/IGUGapLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ 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);
CIGUGapLayer(double t_Thickness,
double t_Pressure,
const ForcedVentilation & t_ForcedVentilation);

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

Expand All @@ -32,13 +33,10 @@ 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: 0 additions & 12 deletions src/Tarcog/src/IGUVentilatedGapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ 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 @@ -71,10 +67,6 @@ 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 @@ -98,10 +90,6 @@ 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
26 changes: 13 additions & 13 deletions src/Tarcog/src/LayerInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,11 @@ namespace Tarcog
{}

CGasLayer::CGasLayer(double const t_Pressure,
double const t_AirSpeed,
AirVerticalDirection const t_AirVerticalDirection) :
const ForcedVentilation & t_ForcedVentilation) :
m_Pressure(t_Pressure),
m_AirSpeed(t_AirSpeed),
m_AirVerticalDirection(t_AirVerticalDirection),
m_AirHorizontalDirection(AirHorizontalDirection::None)
{}

CGasLayer::CGasLayer(double const t_Pressure,
double const t_AirSpeed,
AirHorizontalDirection const t_AirHorizontalDirection) :
m_Pressure(t_Pressure),
m_AirSpeed(t_AirSpeed),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(t_AirHorizontalDirection)
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_ForcedVentilation(t_ForcedVentilation)
{}

CGasLayer::CGasLayer(double const t_Pressure, const Gases::CGas & t_Gas) :
Expand All @@ -194,6 +184,16 @@ namespace Tarcog
return m_Pressure;
}

ForcedVentilation CGasLayer::getForcedVentilation()
{
return m_ForcedVentilation;
}

bool CGasLayer::isVentilationForced()
{
return m_ForcedVentilation.Speed != 0 || m_ForcedVentilation.Temperature != 0;
}

void CGasLayer::initializeStateVariables()
{
m_Gas.setTemperatureAndPressure(getGasTemperature(), m_Pressure);
Expand Down
11 changes: 5 additions & 6 deletions src/Tarcog/src/LayerInterfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,15 @@ namespace Tarcog
public:
CGasLayer();
explicit CGasLayer(double t_Pressure);
CGasLayer(double t_Pressure,
double t_AirSpeed,
AirVerticalDirection t_AirVerticalDirection);
CGasLayer(double t_Pressure,
double t_AirSpeed,
AirHorizontalDirection t_AirHorizontalDirection);
CGasLayer(double t_Pressure, const ForcedVentilation & t_ForcedVentilation);
CGasLayer(double t_Pressure, const Gases::CGas & t_Gas);

virtual double getPressure();

ForcedVentilation getForcedVentilation();

bool isVentilationForced();

virtual double getGasTemperature() = 0;

protected:
Expand Down
16 changes: 2 additions & 14 deletions src/Tarcog/src/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,10 @@ namespace Tarcog

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

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

std::shared_ptr<CIGUSolidLayer> Layers::updateMaterialData(
Expand Down
8 changes: 1 addition & 7 deletions src/Tarcog/src/Layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ namespace Tarcog

static std::shared_ptr<CIGUGapLayer>
forcedVentilationGap(double thickness,
double airSpeed,
AirHorizontalDirection const airHorizontalDirection,
double pressure = 101325);
static std::shared_ptr<CIGUGapLayer>
forcedVentilationGap(double thickness,
double airSpeed,
AirVerticalDirection const airVerticalDirection,
const ForcedVentilation & forcedVentilation,
double pressure = 101325);

static std::shared_ptr<CIGUGapLayer>
Expand Down
10 changes: 5 additions & 5 deletions src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class TestGapLayerInBetweenForcedVentilation : public testing::Test

auto gapThickness = 0.0127;
auto gapAirSpeed = 0.5;
auto gapAirHorizontalDirection = Tarcog::ISO15099::AirVerticalDirection::Up;
auto gap1 = Tarcog::ISO15099::Layers::forcedVentilationGap(
gapThickness, gapAirSpeed, gapAirHorizontalDirection);
auto gapAirTemperature = 0.5;
// auto gapAirHorizontalDirection = Tarcog::ISO15099::AirVerticalDirection::Up;
Tarcog::ISO15099::ForcedVentilation forcedVentilation = {gapAirSpeed, gapAirTemperature};
auto gap1 = Tarcog::ISO15099::Layers::forcedVentilationGap(gapThickness, forcedVentilation);
ASSERT_TRUE(gap1 != nullptr);

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

Tarcog::ISO15099::CIGU aIGU(windowWidth, windowHeight);
Expand Down

0 comments on commit f7d6c6e

Please sign in to comment.