diff --git a/src/Tarcog/src/BaseShade.cpp b/src/Tarcog/src/BaseShade.cpp index f611edc2..0c88350f 100644 --- a/src/Tarcog/src/BaseShade.cpp +++ b/src/Tarcog/src/BaseShade.cpp @@ -180,6 +180,27 @@ namespace Tarcog void CIGUShadeLayer::calcInBetweenShadeFlow(std::shared_ptr t_Gap1, std::shared_ptr 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; @@ -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(); @@ -262,7 +279,6 @@ namespace Tarcog gap1Direction = AirVerticalDirection::Down; gap2Direction = AirVerticalDirection::Up; } - converged = std::abs(Tup - TupOld) < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; converged = @@ -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 t_Environment, std::shared_ptr 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; @@ -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; diff --git a/src/Tarcog/src/IGUGapLayer.cpp b/src/Tarcog/src/IGUGapLayer.cpp index aa8bd07f..49de6cbd 100644 --- a/src/Tarcog/src/IGUGapLayer.cpp +++ b/src/Tarcog/src/IGUGapLayer.cpp @@ -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 const & t_Layer) @@ -160,11 +153,6 @@ namespace Tarcog return m_Pressure; } - bool CIGUGapLayer::isVentilationForced() const - { - return m_ForcedVentilation; - } - std::shared_ptr CIGUGapLayer::clone() const { return std::make_shared(*this); diff --git a/src/Tarcog/src/IGUGapLayer.hpp b/src/Tarcog/src/IGUGapLayer.hpp index b0fae6f6..6a2f80a1 100644 --- a/src/Tarcog/src/IGUGapLayer.hpp +++ b/src/Tarcog/src/IGUGapLayer.hpp @@ -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 & t_Layer) override; @@ -32,13 +33,10 @@ namespace Tarcog double getPressure() override; - bool isVentilationForced() const; - std::shared_ptr clone() const override; protected: - bool m_ForcedVentilation; void initializeStateVariables() override; void calculateConvectionOrConductionFlow() override; diff --git a/src/Tarcog/src/IGUVentilatedGapLayer.cpp b/src/Tarcog/src/IGUVentilatedGapLayer.cpp index 523c2c76..376c869e 100644 --- a/src/Tarcog/src/IGUVentilatedGapLayer.cpp +++ b/src/Tarcog/src/IGUVentilatedGapLayer.cpp @@ -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; @@ -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) { @@ -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(); } diff --git a/src/Tarcog/src/LayerInterfaces.cpp b/src/Tarcog/src/LayerInterfaces.cpp index 233a2550..6c74407a 100644 --- a/src/Tarcog/src/LayerInterfaces.cpp +++ b/src/Tarcog/src/LayerInterfaces.cpp @@ -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, @@ -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, @@ -178,7 +181,17 @@ 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) : @@ -186,6 +199,7 @@ namespace Tarcog m_AirSpeed(0), m_AirVerticalDirection(AirVerticalDirection::None), m_AirHorizontalDirection(AirHorizontalDirection::None), + m_IsVentilationForced(false), m_Gas(t_Gas) {} @@ -194,6 +208,16 @@ namespace Tarcog return m_Pressure; } + ForcedVentilation CGasLayer::getForcedVentilation() const + { + return m_ForcedVentilation; + } + + bool CGasLayer::isVentilationForced() const + { + return m_IsVentilationForced; + } + void CGasLayer::initializeStateVariables() { m_Gas.setTemperatureAndPressure(getGasTemperature(), m_Pressure); diff --git a/src/Tarcog/src/LayerInterfaces.hpp b/src/Tarcog/src/LayerInterfaces.hpp index d11ef010..bbc7f3b1 100644 --- a/src/Tarcog/src/LayerInterfaces.hpp +++ b/src/Tarcog/src/LayerInterfaces.hpp @@ -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() const; + + bool isVentilationForced() const; + virtual double getGasTemperature() = 0; protected: @@ -113,6 +118,7 @@ namespace Tarcog AirVerticalDirection m_AirVerticalDirection; AirHorizontalDirection m_AirHorizontalDirection; ForcedVentilation m_ForcedVentilation; + bool m_IsVentilationForced; Gases::CGas m_Gas; }; diff --git a/src/Tarcog/src/Layers.cpp b/src/Tarcog/src/Layers.cpp index ed4e6393..82de0bcc 100644 --- a/src/Tarcog/src/Layers.cpp +++ b/src/Tarcog/src/Layers.cpp @@ -38,22 +38,10 @@ namespace Tarcog std::shared_ptr Layers::forcedVentilationGap(const double thickness, - const double airSpeed, - AirHorizontalDirection const airHorizontalDirection, + const ForcedVentilation & forcedVentilation, const double pressure) { - return std::make_shared( - thickness, pressure, airSpeed, airHorizontalDirection); - } - - std::shared_ptr - Layers::forcedVentilationGap(const double thickness, - const double airSpeed, - AirVerticalDirection const airVerticalDirection, - const double pressure) - { - return std::make_shared( - thickness, pressure, airSpeed, airVerticalDirection); + return std::make_shared(thickness, pressure, forcedVentilation); } std::shared_ptr Layers::updateMaterialData( diff --git a/src/Tarcog/src/Layers.hpp b/src/Tarcog/src/Layers.hpp index 6b473a4e..dc320956 100644 --- a/src/Tarcog/src/Layers.hpp +++ b/src/Tarcog/src/Layers.hpp @@ -46,13 +46,7 @@ namespace Tarcog static std::shared_ptr forcedVentilationGap(double thickness, - double airSpeed, - AirHorizontalDirection const airHorizontalDirection, - double pressure = 101325); - static std::shared_ptr - forcedVentilationGap(double thickness, - double airSpeed, - AirVerticalDirection const airVerticalDirection, + const ForcedVentilation & forcedVentilation, double pressure = 101325); static std::shared_ptr diff --git a/src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp b/src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp index 7cdf7859..3e6dce55 100644 --- a/src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp +++ b/src/Tarcog/tst/units/GapLayerInBetweenForcedVentilation.unit.cpp @@ -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); @@ -116,10 +116,10 @@ TEST_F(TestGapLayerInBetweenForcedVentilation, VentilationFlow) ASSERT_TRUE(aLayer != nullptr); auto gainEnergy = aLayer->getGainFlow(); - EXPECT_NEAR(32.988234, gainEnergy, 1e-4); + EXPECT_NEAR(0.0, gainEnergy, 1e-4); aLayer = GetGap2(); ASSERT_TRUE(aLayer != nullptr); gainEnergy = aLayer->getGainFlow(); - EXPECT_NEAR(-32.988234, gainEnergy, 1e-4); + EXPECT_NEAR(-0.0, gainEnergy, 1e-4); }