Skip to content

Commit

Permalink
Merge pull request #144 from ise-bipv/add-gaps-with-forced-ventilation
Browse files Browse the repository at this point in the history
Add gaps with forced ventilation
  • Loading branch information
vidanovic authored Apr 14, 2023
2 parents 981b5b1 + a29f592 commit 8c38b07
Show file tree
Hide file tree
Showing 33 changed files with 3,350 additions and 298 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*.res
*.so
*.so.*
*.vscode*
*~
.directory
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions src/Tarcog/src/BaseLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ namespace Tarcog

virtual std::shared_ptr<CBaseLayer> clone() const = 0;

//! Some of the layers will require pre-calculation to be done in order to perform
//! main loop calculation.
virtual void precalculateState() {};

protected:
void calculateRadiationFlow() override;
void calculateConvectionOrConductionFlow() override = 0;
Expand Down
183 changes: 11 additions & 172 deletions src/Tarcog/src/BaseShade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ namespace Tarcog
}

CShadeOpenings::CShadeOpenings() :
m_Atop(0),
m_Abot(0),
m_Aleft(0),
m_Aright(0),
m_Afront(0)
m_Atop(0), m_Abot(0), m_Aleft(0), m_Aright(0), m_Afront(0)
{
initialize();
}
Expand Down Expand Up @@ -158,9 +154,10 @@ namespace Tarcog
if(std::dynamic_pointer_cast<CIGUGapLayer>(m_PreviousLayer) != nullptr
&& std::dynamic_pointer_cast<CIGUGapLayer>(m_NextLayer) != nullptr)
{
calcInBetweenShadeFlow(
std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(m_PreviousLayer),
std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(m_NextLayer));
auto previousGapLayer =
std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(m_PreviousLayer);
auto nextGapLayer = std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(m_NextLayer);
calcInBetweenShadeFlow(previousGapLayer, nextGapLayer);
}
else if(std::dynamic_pointer_cast<CEnvironment>(m_PreviousLayer) != nullptr
&& std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(m_NextLayer) != nullptr)
Expand All @@ -180,178 +177,20 @@ namespace Tarcog
void CIGUShadeLayer::calcInBetweenShadeFlow(std::shared_ptr<CIGUVentilatedGapLayer> t_Gap1,
std::shared_ptr<CIGUVentilatedGapLayer> t_Gap2)
{
double Tup = t_Gap1->layerTemperature();
double Tdown = t_Gap2->layerTemperature();
double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW;
bool converged = false;
size_t iterationStep = 0;

while(!converged)
{
double tempGap1 = t_Gap1->layerTemperature();
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
{
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();
double alpha1 = 1 - beta1;
double alpha2 = 1 - beta2;

double TupOld = Tup;
double TdownOld = Tdown;

if(tempGap1 > tempGap2)
{
Tup = (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2);
Tdown = alpha2 * Tav2 + beta2 * Tup;
}
else
{
Tdown = (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2);
Tup = alpha2 * Tav2 + beta2 * Tdown;
}

Tup = RelaxationParameter * Tup + (1 - RelaxationParameter) * TupOld;
Tdown = RelaxationParameter * Tdown + (1 - RelaxationParameter) * TdownOld;

AirVerticalDirection gap1Direction = AirVerticalDirection::None;
AirVerticalDirection gap2Direction = AirVerticalDirection::None;
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 =
converged
&& std::abs(Tdown - TdownOld) < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW;

t_Gap1->setFlowTemperatures(Tup, Tdown, gap1Direction);
t_Gap2->setFlowTemperatures(Tup, Tdown, gap2Direction);

++iterationStep;
if(iterationStep > IterationConstants::NUMBER_OF_STEPS)
{
converged = true;
throw std::runtime_error("Airflow iterations fail to converge. Maximum number "
"of iteration steps reached.");
}
}
t_Gap1->setFlowGeometry(m_ShadeOpenings->Aeq_bot(), m_ShadeOpenings->Aeq_top());
t_Gap2->setFlowGeometry(m_ShadeOpenings->Aeq_top(), m_ShadeOpenings->Aeq_bot());

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

void CIGUShadeLayer::calcEdgeShadeFlow(std::shared_ptr<CEnvironment> t_Environment,
std::shared_ptr<CIGUVentilatedGapLayer> t_Gap)
{
double TgapOut = t_Gap->layerTemperature();
double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW;
bool converged = false;
size_t iterationStep = 0;
t_Gap->setFlowGeometry(m_ShadeOpenings->Aeq_bot(), m_ShadeOpenings->Aeq_top());
const auto environmentTemperature{t_Environment->getGasTemperature()};

double tempGap = t_Gap->layerTemperature();
while(!converged)
{
double tempEnvironment = t_Environment->getGasTemperature();
double TavGap = t_Gap->averageTemperature();
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 beta = t_Gap->betaCoeff();
double alpha = 1 - beta;

double TgapOutOld = TgapOut;

TgapOut = alpha * TavGap + beta * tempEnvironment;

AirVerticalDirection gapDirection = AirVerticalDirection::None;
if(TgapOut > tempEnvironment)
{
gapDirection = AirVerticalDirection::Up;
t_Gap->setFlowTemperatures(TgapOut, tempEnvironment, gapDirection);
}
else
{
gapDirection = AirVerticalDirection::Down;
t_Gap->setFlowTemperatures(tempEnvironment, TgapOut, gapDirection);
}

tempGap = t_Gap->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.");
}
}
}
t_Gap->calculateVentilatedAirflow(environmentTemperature);
}

double CIGUShadeLayer::equivalentConductivity(const double t_Conductivity,
Expand Down
9 changes: 1 addition & 8 deletions src/Tarcog/src/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace Tarcog
m_HCoefficientModel(BoundaryConditionsCoeffModel::CalculateH),
m_IRCalculatedOutside(false)
{
m_ForcedVentilation =
ForcedVentilation(); // Creates forced ventilation with zero values

}

CEnvironment::CEnvironment(const CEnvironment & t_Environment) :
Expand Down Expand Up @@ -55,12 +54,6 @@ namespace Tarcog
resetCalculated();
}

void CEnvironment::setForcedVentilation(ForcedVentilation const & t_ForcedVentilation)
{
m_ForcedVentilation = t_ForcedVentilation;
resetCalculated();
}

void CEnvironment::setEnvironmentIR(double const t_InfraRed)
{
setIRFromEnvironment(t_InfraRed);
Expand Down
1 change: 0 additions & 1 deletion src/Tarcog/src/Environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace Tarcog
~CEnvironment();

void setHCoeffModel(BoundaryConditionsCoeffModel t_BCModel, double t_HCoeff = 0);
void setForcedVentilation(const ForcedVentilation & t_ForcedVentilation);
void setEnvironmentIR(double t_InfraRed);
void setEmissivity(double t_Emissivity);

Expand Down
15 changes: 13 additions & 2 deletions src/Tarcog/src/IGU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ namespace Tarcog
{
if(std::dynamic_pointer_cast<CIGUShadeLayer>(t_Layer) != nullptr)
{
if(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer->getPreviousLayer()) != nullptr)
if(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer->getPreviousLayer()) != nullptr
&& std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(t_Layer->getPreviousLayer())
== nullptr)
{
auto newLayer = std::make_shared<CIGUVentilatedGapLayer>(
std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer->getPreviousLayer()));
Expand All @@ -532,7 +534,8 @@ namespace Tarcog
newLayer);
}
}
if(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer) != nullptr)
if(std::dynamic_pointer_cast<CIGUGapLayer>(t_Layer) != nullptr
&& std::dynamic_pointer_cast<CIGUVentilatedGapLayer>(t_Layer) == nullptr)
{
if(std::dynamic_pointer_cast<CIGUShadeLayer>(t_Layer->getPreviousLayer())
!= nullptr)
Expand Down Expand Up @@ -640,6 +643,14 @@ namespace Tarcog
}
}

void CIGU::precalculateLayerStates()
{
for(auto & layer: m_Layers)
{
layer->precalculateState();
}
}

} // namespace ISO15099

} // namespace Tarcog
2 changes: 2 additions & 0 deletions src/Tarcog/src/IGU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace Tarcog
//! Function that will update layers deflection states based on new temperature data
void updateDeflectionState();

void precalculateLayerStates();

private:
// Replces layer in existing construction and keeps correct connections in linked list
void replaceLayer(const std::shared_ptr<CBaseIGULayer> & t_Original,
Expand Down
Loading

0 comments on commit 8c38b07

Please sign in to comment.