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 13, 2022
1 parent bc7aed5 commit 57de30c
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 130 deletions.
137 changes: 80 additions & 57 deletions src/Tarcog/src/BaseShade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ 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->setFlowGeometry(m_ShadeOpenings->Aeq_bot(),
// m_ShadeOpenings->Aeq_top(),
// AirVerticalDirection::Up);
// t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_top(),
// m_ShadeOpenings->Aeq_bot(),
// AirVerticalDirection::Down);
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 +213,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 Down Expand Up @@ -262,7 +279,6 @@ namespace Tarcog
gap1Direction = AirVerticalDirection::Down;
gap2Direction = AirVerticalDirection::Up;
}

converged =
std::abs(Tup - TupOld) < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW;
converged =
Expand All @@ -279,17 +295,27 @@ 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,
std::shared_ptr<CIGUVentilatedGapLayer> t_Gap)
{
if(t_Gap->isVentilationForced())
{
ForcedVentilation forcedVentilation = t_Gap->getForcedVentilation();
// t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_bot(), m_ShadeOpenings->Aeq_top(),
// AirVerticalDirection::Up);
t_Gap->setFlowSpeed(forcedVentilation.Speed);
t_Gap->setFlowTemperatures(forcedVentilation.Temperature,
forcedVentilation.Temperature,
AirVerticalDirection::None);
return;
}
double TgapOut = t_Gap->layerTemperature();
double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW;
bool converged = false;
Expand All @@ -300,26 +326,23 @@ namespace Tarcog
{
double tempEnvironment = t_Environment->getGasTemperature();
double TavGap = t_Gap->averageTemperature();
if (!t_Gap->isVentilationForced())
if(tempGap > tempEnvironment)
{
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);
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 beta = t_Gap->betaCoeff();
double alpha = 1 - beta;

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
32 changes: 28 additions & 4 deletions src/Tarcog/src/LayerInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@ namespace Tarcog
m_Pressure(0),
m_AirSpeed(0),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(AirHorizontalDirection::None)
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_IsVentilationForced(false)
{}

CGasLayer::CGasLayer(double const t_Pressure) :
m_Pressure(t_Pressure),
m_AirSpeed(0),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(AirHorizontalDirection::None)
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_IsVentilationForced(false)
{}

CGasLayer::CGasLayer(double const t_Pressure,
Expand All @@ -169,7 +171,8 @@ namespace Tarcog
m_Pressure(t_Pressure),
m_AirSpeed(t_AirSpeed),
m_AirVerticalDirection(t_AirVerticalDirection),
m_AirHorizontalDirection(AirHorizontalDirection::None)
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_IsVentilationForced(false)
{}

CGasLayer::CGasLayer(double const t_Pressure,
Expand All @@ -178,14 +181,25 @@ namespace Tarcog
m_Pressure(t_Pressure),
m_AirSpeed(t_AirSpeed),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(t_AirHorizontalDirection)
m_AirHorizontalDirection(t_AirHorizontalDirection),
m_IsVentilationForced(false)
{}

CGasLayer::CGasLayer(double const t_Pressure,
const ForcedVentilation & t_ForcedVentilation) :
m_Pressure(t_Pressure),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_ForcedVentilation(t_ForcedVentilation),
m_IsVentilationForced(true)
{}

CGasLayer::CGasLayer(double const t_Pressure, const Gases::CGas & t_Gas) :
m_Pressure(t_Pressure),
m_AirSpeed(0),
m_AirVerticalDirection(AirVerticalDirection::None),
m_AirHorizontalDirection(AirHorizontalDirection::None),
m_IsVentilationForced(false),
m_Gas(t_Gas)
{}

Expand All @@ -194,6 +208,16 @@ namespace Tarcog
return m_Pressure;
}

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

bool CGasLayer::isVentilationForced()
{
return m_IsVentilationForced;
}

void CGasLayer::initializeStateVariables()
{
m_Gas.setTemperatureAndPressure(getGasTemperature(), m_Pressure);
Expand Down
18 changes: 12 additions & 6 deletions src/Tarcog/src/LayerInterfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,21 @@ 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 const t_Pressure,
double const t_AirSpeed,
AirVerticalDirection const t_AirVerticalDirection);
CGasLayer(double const t_Pressure,
double const t_AirSpeed,
AirHorizontalDirection const 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 All @@ -113,6 +118,7 @@ namespace Tarcog
AirVerticalDirection m_AirVerticalDirection;
AirHorizontalDirection m_AirHorizontalDirection;
ForcedVentilation m_ForcedVentilation;
bool m_IsVentilationForced;

Gases::CGas m_Gas;
};
Expand Down
Loading

0 comments on commit 57de30c

Please sign in to comment.