diff --git a/src/Common/include/WCECommon.hpp b/src/Common/include/WCECommon.hpp index a27409b7..70c7958b 100644 --- a/src/Common/include/WCECommon.hpp +++ b/src/Common/include/WCECommon.hpp @@ -12,7 +12,6 @@ #include "../src/MatrixSeries.hpp" #include "../src/Series.hpp" #include "../src/SquareMatrix.hpp" -#include "../src/State.hpp" #include "../src/SurfaceCoating.hpp" #include "../src/WavelengthRange.hpp" #include "../src/PolynomialFit.hpp" diff --git a/src/Common/src/State.cpp b/src/Common/src/State.cpp deleted file mode 100644 index 6ad36bf4..00000000 --- a/src/Common/src/State.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "State.hpp" - -namespace FenestrationCommon -{ - ////////////////////////////////////////////////////////////////////////// - // CState - ////////////////////////////////////////////////////////////////////////// - - CState::CState() : m_StateCalculated(false) - {} - - CState::CState(CState const & t_State) : m_StateCalculated(t_State.m_StateCalculated) - {} - - CState & CState::operator=(CState const & t_State) - { - m_StateCalculated = t_State.m_StateCalculated; - - return *this; - } - - void CState::resetCalculated() - { - m_StateCalculated = false; - initializeStateVariables(); - } - - void CState::setCalculated() - { - m_StateCalculated = true; - } - - bool CState::isCalculated() - { - return m_StateCalculated; - } - - void CState::initializeStateVariables() - { - // Action will be needed in inherited classes (where calculation is performed). - } - -} // namespace FenestrationCommon diff --git a/src/Common/src/State.hpp b/src/Common/src/State.hpp deleted file mode 100644 index f713535d..00000000 --- a/src/Common/src/State.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FENESTRATIONCOMMONSTATE_H -#define FENESTRATIONCOMMONSTATE_H - -namespace FenestrationCommon -{ - // class CState is used to keep validity of object state. In some cases calculations do not need - // to be performed before results is requested. - class CState - { - public: - virtual ~CState() = default; - CState(); - CState(CState const & t_State); - CState & operator=(CState const & t_State); - virtual void resetCalculated() final; // to reset state to non-calculated - virtual void - setCalculated() final; // calculations are up to date and set state to valid state - virtual bool isCalculated() final; // check if state have valid results - - protected: - // some intermediate state variables need to pick up new input parameters. - virtual void initializeStateVariables(); - - private: - bool m_StateCalculated; - }; - -} // namespace FenestrationCommon - -#endif diff --git a/src/Common/src/Utility.cpp b/src/Common/src/Utility.cpp index f3917745..56f27a88 100644 --- a/src/Common/src/Utility.cpp +++ b/src/Common/src/Utility.cpp @@ -1,6 +1,8 @@ #include #include + #include "Utility.hpp" +#include "Constants.hpp" namespace FenestrationCommon { @@ -41,4 +43,9 @@ namespace FenestrationCommon static const size_t minNumberOfThreads{1u}; return std::max(minNumberOfThreads, numberOfThreads); } + + bool isVacuum(double pressure) + { + return pressure <= ConstantsData::VACUUMPRESSURE; + } } // namespace FenestrationCommon \ No newline at end of file diff --git a/src/Common/src/Utility.hpp b/src/Common/src/Utility.hpp index 367d9169..000189f5 100644 --- a/src/Common/src/Utility.hpp +++ b/src/Common/src/Utility.hpp @@ -22,4 +22,6 @@ namespace FenestrationCommon && std::equal(lhs.begin(), lhs.end(), rhs.begin()); } + + [[nodiscard]] bool isVacuum(double pressure); } \ No newline at end of file diff --git a/src/Tarcog/include/WCETarcog.hpp b/src/Tarcog/include/WCETarcog.hpp index 950328f1..b83887eb 100644 --- a/src/Tarcog/include/WCETarcog.hpp +++ b/src/Tarcog/include/WCETarcog.hpp @@ -1,8 +1,10 @@ #pragma once -#include "../src/BaseIGULayer.hpp" +#include "../src/AirFlow.hpp" +#include "../src/GasSpecification.hpp" #include "../src/BaseLayer.hpp" #include "../src/BaseShade.hpp" +#include "../src/DeflectionInterface.hpp" #include "../src/Environment.hpp" #include "../src/Environments.hpp" #include "../src/HeatFlowBalance.hpp" diff --git a/src/Tarcog/src/AirFlow.hpp b/src/Tarcog/src/AirFlow.hpp new file mode 100644 index 00000000..55ac5978 --- /dev/null +++ b/src/Tarcog/src/AirFlow.hpp @@ -0,0 +1,32 @@ +#pragma once + +namespace Tarcog::ISO15099 +{ + enum class AirVerticalDirection + { + None, + Up, + Down + }; + + enum class AirHorizontalDirection + { + None, + Leeward, + Windward + }; + + struct AirflowProperties + { + AirflowProperties() = default; + AirflowProperties(double mAirSpeed, + AirVerticalDirection mAirVerticalDirection, + AirHorizontalDirection mAirHorizontalDirection, + bool mIsVentilationForced); + + double m_AirSpeed{0}; + AirVerticalDirection m_AirVerticalDirection{AirVerticalDirection::None}; + AirHorizontalDirection m_AirHorizontalDirection{AirHorizontalDirection::None}; + bool m_IsVentilationForced{false}; + }; +} \ No newline at end of file diff --git a/src/Tarcog/src/Airflow.cpp b/src/Tarcog/src/Airflow.cpp new file mode 100644 index 00000000..4b95d0df --- /dev/null +++ b/src/Tarcog/src/Airflow.cpp @@ -0,0 +1,14 @@ +#include "AirFlow.hpp" + +namespace Tarcog::ISO15099 +{ + AirflowProperties::AirflowProperties(double mAirSpeed, + AirVerticalDirection mAirVerticalDirection, + AirHorizontalDirection mAirHorizontalDirection, + bool mIsVentilationForced) : + m_AirSpeed(mAirSpeed), + m_AirVerticalDirection(mAirVerticalDirection), + m_AirHorizontalDirection(mAirHorizontalDirection), + m_IsVentilationForced(mIsVentilationForced) + {} +} diff --git a/src/Tarcog/src/BaseIGULayer.cpp b/src/Tarcog/src/BaseIGULayer.cpp deleted file mode 100644 index 77ac89b3..00000000 --- a/src/Tarcog/src/BaseIGULayer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -#include "BaseIGULayer.hpp" -#include "Surface.hpp" - -using FenestrationCommon::Side; - -namespace Tarcog -{ - namespace ISO15099 - { - CBaseIGULayer::CBaseIGULayer(double const t_Thickness) : m_Thickness(t_Thickness) - {} - - double CBaseIGULayer::layerTemperature() - { - return (getTemperature(Side::Front) + getTemperature(Side::Back)) / 2; - } - - double CBaseIGULayer::getThickness() const - { - return m_Thickness + getSurface(Side::Front)->getMeanDeflection() - - getSurface(Side::Back)->getMeanDeflection(); - } - - double CBaseIGULayer::getTemperature(Side const t_Position) const - { - return getSurface(t_Position)->getTemperature(); - } - - double CBaseIGULayer::J(Side const t_Position) const - { - return getSurface(t_Position)->J(); - } - - double CBaseIGULayer::getConductivity() - { - return getConductionConvectionCoefficient() * m_Thickness; - } - - double CBaseIGULayer::getEffectiveThermalConductivity() - { - return std::abs(getHeatFlow() * m_Thickness - / (m_Surface.at(FenestrationCommon::Side::Front)->getTemperature() - - m_Surface.at(FenestrationCommon::Side::Back)->getTemperature())); - } - - } // namespace ISO15099 - -} // namespace Tarcog diff --git a/src/Tarcog/src/BaseIGULayer.hpp b/src/Tarcog/src/BaseIGULayer.hpp deleted file mode 100644 index eb71ce4f..00000000 --- a/src/Tarcog/src/BaseIGULayer.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef BASEIGUTARCOGLAYER_H -#define BASEIGUTARCOGLAYER_H - -#include -#include "BaseLayer.hpp" - -namespace FenestrationCommon -{ - enum class Side; -} - -namespace Tarcog -{ - namespace ISO15099 - { - class CBaseIGULayer : public Tarcog::ISO15099::CBaseLayer - { - public: - explicit CBaseIGULayer(double t_Thickness); - - double getThickness() const override; - double getTemperature(FenestrationCommon::Side t_Position) const; - double J(FenestrationCommon::Side t_Position) const; - virtual double getMaxDeflection() const = 0; - virtual double getMeanDeflection() const = 0; - - double getConductivity(); - - double getEffectiveThermalConductivity(); - - protected: - virtual double layerTemperature(); - - double m_Thickness; - }; - } // namespace ISO15099 - -} // namespace Tarcog -#endif diff --git a/src/Tarcog/src/BaseLayer.cpp b/src/Tarcog/src/BaseLayer.cpp index fd2c63e8..bf58e860 100644 --- a/src/Tarcog/src/BaseLayer.cpp +++ b/src/Tarcog/src/BaseLayer.cpp @@ -1,52 +1,104 @@ #include "BaseLayer.hpp" +#include "Surface.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 - { - CBaseLayer::CBaseLayer() : - CState(), - CLayerGeometry(), - CLayerHeatFlow(), - m_PreviousLayer(nullptr), - m_NextLayer(nullptr) - {} - - std::shared_ptr CBaseLayer::getPreviousLayer() const - { - return m_PreviousLayer; - } - - std::shared_ptr CBaseLayer::getNextLayer() const - { - return m_NextLayer; - } - - void CBaseLayer::tearDownConnections() - { - m_PreviousLayer = nullptr; - m_NextLayer = nullptr; - } - - void CBaseLayer::connectToBackSide(const std::shared_ptr & t_Layer) - { - m_NextLayer = t_Layer; - t_Layer->m_PreviousLayer = shared_from_this(); - } - - void CBaseLayer::calculateRadiationFlow() - {} - - double CBaseLayer::getThickness() const - { - return std::numeric_limits::max(); - } - - bool CBaseLayer::isPermeable() const - { - return false; - } - } // namespace ISO15099 - -} // namespace Tarcog + CBaseLayer::CBaseLayer() : HeatFlowLayer(), SurfacesManager() + {} + + CBaseLayer::CBaseLayer(double thickness) : + HeatFlowLayer(), + SurfacesManager(), + m_Thickness(thickness), + m_PreviousLayer(nullptr), + m_NextLayer(nullptr) + {} + + double CBaseLayer::getHeatFlow() + { + return getRadiationFlow() + getConvectionConductionFlow(); + } + + double CBaseLayer::getRadiationFlow() + { + calculateRadiationFlow(); + return J(FenestrationCommon::Side::Back) - J(FenestrationCommon::Side::Front); + } + + double CBaseLayer::getConvectionConductionFlow() + { + return (surfaceTemperature(FenestrationCommon::Side::Back) + - surfaceTemperature(FenestrationCommon::Side::Front)) + * getConductionConvectionCoefficient(); + } + + std::shared_ptr CBaseLayer::getPreviousLayer() const + { + return m_PreviousLayer; + } + + std::shared_ptr CBaseLayer::getNextLayer() const + { + return m_NextLayer; + } + + void CBaseLayer::tearDownConnections() + { + m_PreviousLayer = nullptr; + m_NextLayer = nullptr; + } + + void CBaseLayer::connectToBackSide(const std::shared_ptr & t_Layer) + { + m_NextLayer = t_Layer; + t_Layer->m_PreviousLayer = shared_from_this(); + } + + void CBaseLayer::calculateRadiationFlow() + {} + + double CBaseLayer::getThickness() const + { + return m_Thickness + surfaceDeflectionMean(FenestrationCommon::Side::Front) + - surfaceDeflectionMean(FenestrationCommon::Side::Back); + } + + bool CBaseLayer::isPermeable() const + { + return false; + } + + double CBaseLayer::getSurfaceArea() const + { + return m_Width * m_Height; + } + + void CBaseLayer::setWidth(const double width) + { + m_Width = width; + } + + void CBaseLayer::setHeight(const double height) + { + m_Height = height; + } + + void CBaseLayer::setTilt(const double tilt) + { + m_Tilt = tilt; + } + + double CBaseLayer::getConductivity() + { + return getConductionConvectionCoefficient() * m_Thickness; + } + + double CBaseLayer::getEffectiveThermalConductivity() + { + return std::abs(getHeatFlow() * m_Thickness + / (surfaceTemperature(FenestrationCommon::Side::Front) + - surfaceTemperature(FenestrationCommon::Side::Back))); + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/BaseLayer.hpp b/src/Tarcog/src/BaseLayer.hpp index 06725b34..138e61e2 100644 --- a/src/Tarcog/src/BaseLayer.hpp +++ b/src/Tarcog/src/BaseLayer.hpp @@ -1,58 +1,75 @@ -#ifndef BASELAYER_H -#define BASELAYER_H - -#include "LayerInterfaces.hpp" +#pragma once #include +#include "LayerInterfaces.hpp" +#include "TarcogConstants.hpp" +#include "SurfacesManager.hpp" + namespace FenestrationCommon { enum class Side; } -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + // Base description for any tarcog layer. This includes interior and exterior environments + // as well. It must contain base definition of 2D geometry (Width and Height) and definition + // of heat flow that is divided in three categories (convection, conduction and radiation). + // Every layer can contain only Conduction + Radiation or Convection + Radiation. + class CBaseLayer : public HeatFlowLayer, + public SurfacesManager, + public std::enable_shared_from_this { - // Base description for any tarcog layer. This includes interior and exterior environments - // as well. It must contain base definition of 2D geometry (Width and Height) and definition - // of heat flow that is divided in three categories (convection, conduction and radiation). - // Every layer can contain only Conduction + Radiation or Convection + Radiation. - class CBaseLayer : public CLayerGeometry, - public CLayerHeatFlow, - public std::enable_shared_from_this - { - public: - CBaseLayer(); + public: + CBaseLayer(); + explicit CBaseLayer(double thickness); + virtual ~CBaseLayer() = default; + + std::shared_ptr getPreviousLayer() const; + std::shared_ptr getNextLayer() const; + + virtual void connectToBackSide(std::shared_ptr const & t_Layer); + + void tearDownConnections(); - std::shared_ptr getPreviousLayer() const; - std::shared_ptr getNextLayer() const; + //! Thickness of the layer in current state (including deflection) + double getThickness() const; - virtual void connectToBackSide(std::shared_ptr const & t_Layer); + virtual double getHeatFlow() final; + virtual double getRadiationFlow(); + virtual double getConvectionConductionFlow() final; - void tearDownConnections(); + //! This is to determine if layer is porous and leaking air from gap to the surrounding + //! environment. Layer are non-porous by default. + virtual bool isPermeable() const; - virtual double getThickness() const; + virtual std::shared_ptr clone() const = 0; - // This is to determine if layer is porous and leaking air from gap to the surrounding - // environment. Layer are non-porous by default. - virtual bool isPermeable() const; + //! Some of the layers will require pre-calculation to be done in order to perform + //! main loop calculation. + virtual void precalculateState(){}; - virtual std::shared_ptr clone() const = 0; + double getConductivity(); + double getEffectiveThermalConductivity(); - //! Some of the layers will require pre-calculation to be done in order to perform - //! main loop calculation. - virtual void precalculateState() {}; + void setWidth(double width); + void setHeight(double height); + void setTilt(double tilt); - protected: - void calculateRadiationFlow() override; - void calculateConvectionOrConductionFlow() override = 0; + protected: + void calculateRadiationFlow() override; + void calculateConvectionOrConductionFlow() override = 0; - std::shared_ptr m_PreviousLayer; - std::shared_ptr m_NextLayer; - }; - } // namespace ISO15099 + [[nodiscard]] double getSurfaceArea() const; -} // namespace Tarcog + double m_Width{TarcogConstants::DEFAULT_WINDOW_WIDTH}; + double m_Height{TarcogConstants::DEFAULT_WINDOW_HEIGHT}; + double m_Tilt{TarcogConstants::DEFAULT_TILT}; + double m_Thickness{TarcogConstants::DEFAULT_LAYER_THICKNESS}; -#endif + private: + std::shared_ptr m_PreviousLayer{nullptr}; + std::shared_ptr m_NextLayer{nullptr}; + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/BaseShade.cpp b/src/Tarcog/src/BaseShade.cpp index d802e02e..ef7e7319 100644 --- a/src/Tarcog/src/BaseShade.cpp +++ b/src/Tarcog/src/BaseShade.cpp @@ -1,201 +1,189 @@ #include -#include #include #include "BaseShade.hpp" #include "Surface.hpp" #include "IGUGapLayer.hpp" #include "Environment.hpp" -#include "TarcogConstants.hpp" #include "IGUVentilatedGapLayer.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + //////////////////////////////////////////////////////////////////////////////////////////////// + /// CShadeOpenings + //////////////////////////////////////////////////////////////////////////////////////////////// + + CShadeOpenings::CShadeOpenings(double const t_Atop, + double const t_Abot, + double const t_Aleft, + double const t_Aright, + double const t_Afront, + double const t_FrontPorosity) : + m_Atop(t_Atop), + m_Abot(t_Abot), + m_Aleft(t_Aleft), + m_Aright(t_Aright), + m_Afront(t_Afront), + m_FrontPorosity(t_FrontPorosity) { - //////////////////////////////////////////////////////////////////////////////////////////////// - /// CShadeOpenings - //////////////////////////////////////////////////////////////////////////////////////////////// - - CShadeOpenings::CShadeOpenings(double const t_Atop, - double const t_Abot, - double const t_Aleft, - double const t_Aright, - double const t_Afront, - double const t_FrontPorosity) : - m_Atop(t_Atop), - m_Abot(t_Abot), - m_Aleft(t_Aleft), - m_Aright(t_Aright), - m_Afront(t_Afront), - m_FrontPorosity(t_FrontPorosity) - { - fixForValidity(); - } + fixForValidity(); + } - void CShadeOpenings::fixForValidity() + void CShadeOpenings::fixForValidity() + { + if(m_Atop == 0) { - if(m_Atop == 0) - { - m_Atop = OPENING_TOLERANCE; - } - - if(m_Abot == 0) - { - m_Abot = OPENING_TOLERANCE; - } + m_Atop = OPENING_TOLERANCE; } - double CShadeOpenings::openingMultiplier() const + if(m_Abot == 0) { - return (m_Aleft + m_Aright + m_Afront) / (m_Abot + m_Atop); + m_Abot = OPENING_TOLERANCE; } + } - double CShadeOpenings::Aeq_bot() const - { - return m_Abot + 0.5 * m_Atop * openingMultiplier(); - } + double CShadeOpenings::openingMultiplier() const + { + return (m_Aleft + m_Aright + m_Afront) / (m_Abot + m_Atop); + } - double CShadeOpenings::Aeq_top() const - { - return m_Atop + 0.5 * m_Abot * openingMultiplier(); - } + double CShadeOpenings::Aeq_bot() const + { + return m_Abot + 0.5 * m_Atop * openingMultiplier(); + } - double CShadeOpenings::frontPorositiy() const - { - return m_FrontPorosity; - } + double CShadeOpenings::Aeq_top() const + { + return m_Atop + 0.5 * m_Abot * openingMultiplier(); + } - bool CShadeOpenings::isOpen() const - { - return m_Abot > 0 || m_Atop > 0 || m_Aleft > 0 || m_Aright > 0 || m_Afront > 0; - } + double CShadeOpenings::frontPorosity() const + { + return m_FrontPorosity; + } - void CShadeOpenings::checkAndSetDominantWidth(const double gapWidth) - { - m_Abot = std::min(gapWidth, m_Abot); - m_Atop = std::min(gapWidth, m_Atop); - m_Aleft = std::min(gapWidth, m_Aleft); - m_Aright = std::min(gapWidth, m_Aright); - } + bool CShadeOpenings::isOpen() const + { + return m_Abot > 0 || m_Atop > 0 || m_Aleft > 0 || m_Aright > 0 || m_Afront > 0; + } + + void CShadeOpenings::checkAndSetDominantWidth(const double gapWidth) + { + m_Abot = std::min(gapWidth, m_Abot); + m_Atop = std::min(gapWidth, m_Atop); + m_Aleft = std::min(gapWidth, m_Aleft); + m_Aright = std::min(gapWidth, m_Aright); + } + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// CIGUShadeLayer + //////////////////////////////////////////////////////////////////////////////////////////////// + + CIGUShadeLayer::CIGUShadeLayer( + const double t_Thickness, + const double t_Conductivity, + CShadeOpenings && t_ShadeOpenings, + const std::shared_ptr & t_FrontSurface, + const std::shared_ptr & t_BackSurface) : + CIGUSolidLayer(t_Thickness, t_Conductivity, t_FrontSurface, t_BackSurface), + m_ShadeOpenings(t_ShadeOpenings), + m_MaterialConductivity(t_Conductivity) + {} + + CIGUShadeLayer::CIGUShadeLayer(const std::shared_ptr & t_Layer, + const CShadeOpenings & t_ShadeOpenings) : + CIGUSolidLayer(*t_Layer), + m_ShadeOpenings(t_ShadeOpenings), + m_MaterialConductivity(t_Layer->getConductance()) + {} + + CIGUShadeLayer::CIGUShadeLayer(double t_Thickness, double t_Conductivity) : + CIGUSolidLayer(t_Thickness, t_Conductivity), m_MaterialConductivity(t_Conductivity) + {} + + std::shared_ptr CIGUShadeLayer::clone() const + { + return std::make_shared(*this); + } - //////////////////////////////////////////////////////////////////////////////////////////////// - /// CIGUShadeLayer - //////////////////////////////////////////////////////////////////////////////////////////////// - - CIGUShadeLayer::CIGUShadeLayer( - const double t_Thickness, - const double t_Conductivity, - CShadeOpenings && t_ShadeOpenings, - const std::shared_ptr & t_FrontSurface, - const std::shared_ptr & t_BackSurface) : - CIGUSolidLayer(t_Thickness, t_Conductivity, t_FrontSurface, t_BackSurface), - m_ShadeOpenings(std::move(t_ShadeOpenings)), - m_MaterialConductivity(t_Conductivity) - {} - - CIGUShadeLayer::CIGUShadeLayer(const std::shared_ptr & t_Layer, - const CShadeOpenings & t_ShadeOpenings) : - CIGUSolidLayer(*t_Layer), - m_ShadeOpenings(t_ShadeOpenings), - m_MaterialConductivity(t_Layer->getConductance()) - {} - - CIGUShadeLayer::CIGUShadeLayer(double t_Thickness, double t_Conductivity) : - CIGUSolidLayer(t_Thickness, t_Conductivity), - m_MaterialConductivity(t_Conductivity) - {} - - std::shared_ptr CIGUShadeLayer::clone() const + bool CIGUShadeLayer::isPermeable() const + { + return m_ShadeOpenings.isOpen(); + } + + void CIGUShadeLayer::setDominantAirflowWidth() + { + if(getPreviousLayer() != nullptr) { - return std::make_shared(*this); + m_ShadeOpenings.checkAndSetDominantWidth(getPreviousLayer()->getThickness()); } - - bool CIGUShadeLayer::isPermeable() const + if(getNextLayer() != nullptr) { - return m_ShadeOpenings.isOpen(); + m_ShadeOpenings.checkAndSetDominantWidth(getNextLayer()->getThickness()); } + } - void CIGUShadeLayer::setDominanthAirflowWidth() + void CIGUShadeLayer::calculateConvectionOrConductionFlow() + { + setDominantAirflowWidth(); + m_Conductivity = + equivalentConductivity(m_MaterialConductivity, m_ShadeOpenings.frontPorosity()); + CIGUSolidLayer::calculateConvectionOrConductionFlow(); + assert(getNextLayer() != nullptr); + assert(getPreviousLayer() != nullptr); + + // This must be set here or gap will be constantly calling this routine back throughout + // nextLayer property. + setCalculated(); + + if(std::dynamic_pointer_cast(getPreviousLayer()) != nullptr + && std::dynamic_pointer_cast(getNextLayer()) != nullptr) { - if(m_PreviousLayer != nullptr) - { - m_ShadeOpenings.checkAndSetDominantWidth(m_PreviousLayer->getThickness()); - } - if(m_NextLayer != nullptr) - { - m_ShadeOpenings.checkAndSetDominantWidth(m_NextLayer->getThickness()); - } + auto previousGapLayer = + std::dynamic_pointer_cast(getPreviousLayer()); + auto nextGapLayer = std::dynamic_pointer_cast(getNextLayer()); + calcInBetweenShadeFlow(*previousGapLayer, *nextGapLayer); } - - void CIGUShadeLayer::calculateConvectionOrConductionFlow() + else if(std::dynamic_pointer_cast(getPreviousLayer()) != nullptr + && std::dynamic_pointer_cast(getNextLayer()) != nullptr) { - setDominanthAirflowWidth(); - m_Conductivity = - equivalentConductivity(m_MaterialConductivity, m_ShadeOpenings.frontPorositiy()); - CIGUSolidLayer::calculateConvectionOrConductionFlow(); - assert(m_NextLayer != nullptr); - assert(m_PreviousLayer != nullptr); - - // This must be set here or gap will be constantly calling this routine back throughout - // nextLayer property. - setCalculated(); - - if(std::dynamic_pointer_cast(m_PreviousLayer) != nullptr - && std::dynamic_pointer_cast(m_NextLayer) != nullptr) - { - auto previousGapLayer = - std::dynamic_pointer_cast(m_PreviousLayer); - auto nextGapLayer = std::dynamic_pointer_cast(m_NextLayer); - calcInBetweenShadeFlow(previousGapLayer, nextGapLayer); - } - else if(std::dynamic_pointer_cast(m_PreviousLayer) != nullptr - && std::dynamic_pointer_cast(m_NextLayer) != nullptr) - { - calcEdgeShadeFlow(std::dynamic_pointer_cast(m_PreviousLayer), - std::dynamic_pointer_cast(m_NextLayer)); - } - else if(std::dynamic_pointer_cast(m_PreviousLayer) != nullptr - && std::dynamic_pointer_cast(m_NextLayer) != nullptr) - { - calcEdgeShadeFlow( - std::dynamic_pointer_cast(m_NextLayer), - std::dynamic_pointer_cast(m_PreviousLayer)); - } + calcEdgeShadeFlow(*std::dynamic_pointer_cast(getPreviousLayer()), + *std::dynamic_pointer_cast(getNextLayer())); } - - void CIGUShadeLayer::calcInBetweenShadeFlow(std::shared_ptr t_Gap1, - std::shared_ptr t_Gap2) + else if(std::dynamic_pointer_cast(getPreviousLayer()) != nullptr + && std::dynamic_pointer_cast(getNextLayer()) != nullptr) { - - t_Gap1->setFlowGeometry(m_ShadeOpenings.Aeq_bot(), m_ShadeOpenings.Aeq_top()); - t_Gap2->setFlowGeometry(m_ShadeOpenings.Aeq_top(), m_ShadeOpenings.Aeq_bot()); - - t_Gap1->calculateThermallyDrivenAirflowWithAdjacentGap(*t_Gap2); + calcEdgeShadeFlow(*std::dynamic_pointer_cast(getNextLayer()), + *std::dynamic_pointer_cast(getPreviousLayer())); } + } - void CIGUShadeLayer::calcEdgeShadeFlow(std::shared_ptr t_Environment, - std::shared_ptr t_Gap) - { - t_Gap->setFlowGeometry(m_ShadeOpenings.Aeq_bot(), m_ShadeOpenings.Aeq_top()); - const auto environmentTemperature{t_Environment->getGasTemperature()}; + void CIGUShadeLayer::calcInBetweenShadeFlow(CIGUVentilatedGapLayer & t_Gap1, + CIGUVentilatedGapLayer & t_Gap2) + { + t_Gap1.setFlowGeometry(m_ShadeOpenings.Aeq_bot(), m_ShadeOpenings.Aeq_top()); + t_Gap2.setFlowGeometry(m_ShadeOpenings.Aeq_top(), m_ShadeOpenings.Aeq_bot()); - t_Gap->calculateVentilatedAirflow(environmentTemperature); - } + t_Gap1.calculateThermallyDrivenAirflowWithAdjacentGap(t_Gap2); + } - double CIGUShadeLayer::equivalentConductivity(const double t_Conductivity, - const double permeabilityFactor) - { - const auto standardPressure{101325.0}; // Pa - const auto Tf{m_Surface.at(FenestrationCommon::Side::Front)->getTemperature()}; - const auto Tb{m_Surface.at(FenestrationCommon::Side::Back)->getTemperature()}; - Gases::CGas air; - air.setTemperatureAndPressure((Tf + Tb) / 2, standardPressure); - const auto airThermalConductivity = air.getGasProperties().m_ThermalConductivity; - return airThermalConductivity * permeabilityFactor - + (1 - permeabilityFactor) * t_Conductivity; - } - } // namespace ISO15099 + void CIGUShadeLayer::calcEdgeShadeFlow(CEnvironment & t_Environment, + CIGUVentilatedGapLayer & t_Gap) + { + t_Gap.setFlowGeometry(m_ShadeOpenings.Aeq_bot(), m_ShadeOpenings.Aeq_top()); -} // namespace Tarcog + t_Gap.calculateVentilatedAirflow(t_Environment.getGasTemperature()); + } + + double CIGUShadeLayer::equivalentConductivity(const double t_Conductivity, + const double permeabilityFactor) + { + const auto standardPressure{101325.0}; // Pa + Gases::CGas air; + air.setTemperatureAndPressure(averageSurfaceTemperature(), standardPressure); + const auto airThermalConductivity = air.getGasProperties().m_ThermalConductivity; + return airThermalConductivity * permeabilityFactor + + (1 - permeabilityFactor) * t_Conductivity; + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/BaseShade.hpp b/src/Tarcog/src/BaseShade.hpp index d29bea21..237177b7 100644 --- a/src/Tarcog/src/BaseShade.hpp +++ b/src/Tarcog/src/BaseShade.hpp @@ -35,7 +35,7 @@ namespace Tarcog::ISO15099 [[nodiscard]] double Aeq_bot() const; [[nodiscard]] double Aeq_top() const; - [[nodiscard]] double frontPorositiy() const; + [[nodiscard]] double frontPorosity() const; [[nodiscard]] bool isOpen() const; @@ -74,15 +74,14 @@ namespace Tarcog::ISO15099 bool isPermeable() const override; private: - void setDominanthAirflowWidth(); + void setDominantAirflowWidth(); void calculateConvectionOrConductionFlow() override; - void calcInBetweenShadeFlow(std::shared_ptr t_Gap1, - std::shared_ptr t_Gap2); + void calcInBetweenShadeFlow(CIGUVentilatedGapLayer & t_Gap1, + CIGUVentilatedGapLayer & t_Gap2); - void calcEdgeShadeFlow(std::shared_ptr t_Environment, - std::shared_ptr t_Gap); + void calcEdgeShadeFlow(CEnvironment & t_Environment, CIGUVentilatedGapLayer & t_Gap); double equivalentConductivity(double t_Conductivity, double permeabilityFactor); diff --git a/src/Tarcog/src/DeflectionInterface.hpp b/src/Tarcog/src/DeflectionInterface.hpp new file mode 100644 index 00000000..0ed82728 --- /dev/null +++ b/src/Tarcog/src/DeflectionInterface.hpp @@ -0,0 +1,13 @@ +#pragma once + +namespace Tarcog +{ + class Deflectable + { + public: + virtual ~Deflectable() = default; + + [[nodiscard]] virtual double getMaxDeflection() const = 0; + [[nodiscard]] virtual double getMeanDeflection() const = 0; + }; +} \ No newline at end of file diff --git a/src/Tarcog/src/Environment.cpp b/src/Tarcog/src/Environment.cpp index 5c7ed95d..ba5e77b7 100644 --- a/src/Tarcog/src/Environment.cpp +++ b/src/Tarcog/src/Environment.cpp @@ -2,119 +2,120 @@ #include "TarcogConstants.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + CEnvironment::CEnvironment(double t_Pressure, + double t_AirSpeed, + AirHorizontalDirection t_AirDirection) : + m_DirectSolarRadiation(0), + m_Emissivity(TarcogConstants::DEFAULT_ENV_EMISSIVITY), + m_HInput(0), + m_HCoefficientModel(BoundaryConditionsCoeffModel::CalculateH), + m_IRCalculatedOutside(false) { - CEnvironment::CEnvironment(double t_Pressure, - double t_AirSpeed, - AirHorizontalDirection t_AirDirection) : - CGasLayer(t_Pressure, t_AirSpeed, t_AirDirection), - m_DirectSolarRadiation(0), - m_Emissivity(TarcogConstants::DEFAULT_ENV_EMISSIVITY), - m_HInput(0), - m_HCoefficientModel(BoundaryConditionsCoeffModel::CalculateH), - m_IRCalculatedOutside(false) - { - - } - - CEnvironment::CEnvironment(const CEnvironment & t_Environment) : - CState(t_Environment), - CBaseLayer(t_Environment), - CGasLayer(t_Environment) - { - operator=(t_Environment); - } + gasSpecification.pressure = t_Pressure; + gasSpecification.airflowProperties = + AirflowProperties(t_AirSpeed, AirVerticalDirection::None, t_AirDirection, false); + } - CEnvironment & CEnvironment::operator=(CEnvironment const & t_Environment) - { - CState::operator=(t_Environment); - CBaseLayer::operator=(t_Environment); - CGasLayer::operator=(t_Environment); - m_DirectSolarRadiation = t_Environment.m_DirectSolarRadiation; - m_Emissivity = t_Environment.m_Emissivity; - m_HInput = t_Environment.m_HInput; - m_HCoefficientModel = t_Environment.m_HCoefficientModel; - m_IRCalculatedOutside = t_Environment.m_IRCalculatedOutside; - - return *this; - } - - CEnvironment::~CEnvironment() - { - tearDownConnections(); - } + CEnvironment::~CEnvironment() + { + tearDownConnections(); + } - void CEnvironment::setHCoeffModel(BoundaryConditionsCoeffModel const t_BCModel, - double const t_HCoeff) - { - m_HCoefficientModel = t_BCModel; - m_HInput = t_HCoeff; - resetCalculated(); - } + void CEnvironment::setHCoeffModel(BoundaryConditionsCoeffModel const t_BCModel, + double const t_HCoeff) + { + m_HCoefficientModel = t_BCModel; + m_HInput = t_HCoeff; + resetCalculated(); + gasSpecification.setTemperature(getGasTemperature()); + } - void CEnvironment::setEnvironmentIR(double const t_InfraRed) - { - setIRFromEnvironment(t_InfraRed); - m_IRCalculatedOutside = true; - resetCalculated(); - } + void CEnvironment::setEnvironmentIR(double const t_InfraRed) + { + setIRFromEnvironment(t_InfraRed); + m_IRCalculatedOutside = true; + resetCalculated(); + gasSpecification.setTemperature(getGasTemperature()); + } - void CEnvironment::setEmissivity(double const t_Emissivity) - { - m_Emissivity = t_Emissivity; - resetCalculated(); - } + void CEnvironment::setEmissivity(double const t_Emissivity) + { + m_Emissivity = t_Emissivity; + resetCalculated(); + gasSpecification.setTemperature(getGasTemperature()); + } - double CEnvironment::getEnvironmentIR() - { - calculateLayerHeatFlow(); - return getIRFromEnvironment(); - } + double CEnvironment::getEnvironmentIR() + { + return getIRFromEnvironment(); + } - double CEnvironment::getHc() - { - return getConductionConvectionCoefficient(); - } + double CEnvironment::getHc() + { + return getConductionConvectionCoefficient(); + } - double CEnvironment::getAirTemperature() - { - return getGasTemperature(); - } + double CEnvironment::getAirTemperature() + { + return getGasTemperature(); + } - double CEnvironment::getAmbientTemperature() - { - double hc = getHc(); - double hr = getHr(); - return (hc * getAirTemperature() + hr * getRadiationTemperature()) / (hc + hr); - } + double CEnvironment::getAmbientTemperature() + { + double hc = getHc(); + double hr = getHr(); + return (hc * getAirTemperature() + hr * getRadiationTemperature()) / (hc + hr); + } - double CEnvironment::getDirectSolarRadiation() const - { - return m_DirectSolarRadiation; - } + double CEnvironment::getDirectSolarRadiation() const + { + return m_DirectSolarRadiation; + } - void CEnvironment::connectToIGULayer(std::shared_ptr const &) - { - // - } + void CEnvironment::connectToIGULayer(std::shared_ptr const &) + { + // + } - void CEnvironment::initializeStateVariables() + void CEnvironment::calculateRadiationFlow() + { + // In case of environments, there is no need to calculate radiation + // if radiation is provided from outside calculations + if(!m_IRCalculatedOutside) { - CGasLayer::initializeStateVariables(); + setIRFromEnvironment(calculateIRFromVariables()); } + } - void CEnvironment::calculateRadiationFlow() + void CEnvironment::calculateConvectionOrConductionFlow() + { + switch(m_HCoefficientModel) { - // In case of environments, there is no need to calculate radiation - // if radiation is provided from outside calculations - if(!m_IRCalculatedOutside) - { - setIRFromEnvironment(calculateIRFromVariables()); + case BoundaryConditionsCoeffModel::CalculateH: { + m_ConductiveConvectiveCoeff = calculateHc(); + break; + } + case BoundaryConditionsCoeffModel::HPrescribed: { + const auto hr = getHr(); + m_ConductiveConvectiveCoeff = m_HInput - hr; + break; + } + case BoundaryConditionsCoeffModel::HcPrescribed: { + m_ConductiveConvectiveCoeff = m_HInput; + break; + } + default: { + throw std::runtime_error( + "Incorrect definition for convection model (Indoor/Outdoor environment)."); } } + } - } // namespace ISO15099 + double CEnvironment::getPressure() const + { + return gasSpecification.pressure; + } -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Environment.hpp b/src/Tarcog/src/Environment.hpp index 5cd1b41f..c3672153 100644 --- a/src/Tarcog/src/Environment.hpp +++ b/src/Tarcog/src/Environment.hpp @@ -1,64 +1,63 @@ -#ifndef TARENVIRONMENT_H -#define TARENVIRONMENT_H +#pragma once #include +#include + #include "EnvironmentConfigurations.hpp" #include "BaseLayer.hpp" +#include "GasSpecification.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + class CEnvironment : public CBaseLayer { - class CEnvironment : public Tarcog::ISO15099::CBaseLayer, public CGasLayer - { - public: - CEnvironment(double t_Pressure, - double t_AirSpeed, - AirHorizontalDirection t_AirDirection); - CEnvironment(const CEnvironment & t_Environment); - CEnvironment & operator=(const CEnvironment & t_Environment); - - ~CEnvironment(); - - void setHCoeffModel(BoundaryConditionsCoeffModel t_BCModel, double t_HCoeff = 0); - void setEnvironmentIR(double t_InfraRed); - void setEmissivity(double t_Emissivity); - - double getDirectSolarRadiation() const; - double getEnvironmentIR(); - double getHc(); - virtual double getHr() = 0; - - double getAirTemperature(); - double getAmbientTemperature(); - - virtual void connectToIGULayer(const std::shared_ptr & t_IGULayer); - - virtual std::shared_ptr cloneEnvironment() const = 0; - - protected: - void initializeStateVariables() override; - void calculateRadiationFlow() override; - virtual double calculateIRFromVariables() = 0; - virtual void setIRFromEnvironment(double t_IR) = 0; - virtual double getIRFromEnvironment() const = 0; - virtual double getRadiationTemperature() const = 0; - - double m_DirectSolarRadiation; - double m_Emissivity; // Emissivity from the environment - // double m_InfraredRadiation; // Infrared radiation from environment [W/m2] - // Input convection coefficient which type depends on selected BC model [W/m2*K] - double m_HInput; - // Model used to calculate BC coefficient - BoundaryConditionsCoeffModel m_HCoefficientModel; - - // Keep info if IR radiation is provided (calculated) outside - bool m_IRCalculatedOutside; - }; - - } // namespace ISO15099 - -} // namespace Tarcog - -#endif + public: + CEnvironment(double t_Pressure, double t_AirSpeed, AirHorizontalDirection t_AirDirection); + + ~CEnvironment() override; + + void setHCoeffModel(BoundaryConditionsCoeffModel t_BCModel, double t_HCoeff = 0); + void setEnvironmentIR(double t_InfraRed); + void setEmissivity(double t_Emissivity); + + double getDirectSolarRadiation() const; + double getEnvironmentIR(); + double getHc(); + virtual double calculateHc() = 0; + virtual double getHr() = 0; + + double getAirTemperature(); + double getAmbientTemperature(); + + virtual void connectToIGULayer(const std::shared_ptr & t_IGULayer); + + virtual std::shared_ptr cloneEnvironment() const = 0; + + [[nodiscard]] double getPressure() const; + + virtual double getGasTemperature() = 0; + + protected: + void calculateRadiationFlow() override; + void calculateConvectionOrConductionFlow() override; + virtual double calculateIRFromVariables() = 0; + virtual void setIRFromEnvironment(double t_IR) = 0; + virtual double getIRFromEnvironment() const = 0; + virtual double getRadiationTemperature() const = 0; + + double m_DirectSolarRadiation; + double m_Emissivity; // Emissivity from the environment + + // Input convection coefficient which type depends on selected BC model [W/m2*K] + double m_HInput; + // Model used to calculate BC coefficient + BoundaryConditionsCoeffModel m_HCoefficientModel; + + // Keep info if IR radiation is provided (calculated) outside + bool m_IRCalculatedOutside; + + GasSpecification gasSpecification; + }; + +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/EnvironmentConfigurations.hpp b/src/Tarcog/src/EnvironmentConfigurations.hpp index ce388727..f46fc2d8 100644 --- a/src/Tarcog/src/EnvironmentConfigurations.hpp +++ b/src/Tarcog/src/EnvironmentConfigurations.hpp @@ -1,20 +1,17 @@ #pragma once -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + enum class BoundaryConditionsCoeffModel { - enum class BoundaryConditionsCoeffModel - { - CalculateH, - HPrescribed, - HcPrescribed - }; + CalculateH, + HPrescribed, + HcPrescribed + }; - enum class Environment - { - Indoor, - Outdoor - }; - } // namespace ISO15099 -} // namespace Tarcog + enum class Environment + { + Indoor, + Outdoor + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Environments.cpp b/src/Tarcog/src/Environments.cpp index ad74e375..084eea36 100644 --- a/src/Tarcog/src/Environments.cpp +++ b/src/Tarcog/src/Environments.cpp @@ -2,9 +2,8 @@ #include "OutdoorEnvironment.hpp" #include "IndoorEnvironment.hpp" -namespace Tarcog -{ - namespace ISO15099 + + namespace Tarcog::ISO15099 { std::shared_ptr Tarcog::ISO15099::Environments::indoor(double roomAirTemperature, double roomPressure) @@ -31,5 +30,4 @@ namespace Tarcog pressure, fractionOfClearSky); } - } // namespace ISO15099 -} // namespace Tarcog \ No newline at end of file + } // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Environments.hpp b/src/Tarcog/src/Environments.hpp index 135092d0..8f81bed2 100644 --- a/src/Tarcog/src/Environments.hpp +++ b/src/Tarcog/src/Environments.hpp @@ -1,37 +1,35 @@ #pragma once #include + #include "LayerInterfaces.hpp" #include "TarcogConstants.hpp" +#include "AirFlow.hpp" -namespace Tarcog -{ - namespace ISO15099 - { - class CIndoorEnvironment; - - class COutdoorEnvironment; - enum class SkyModel; - - // Singleton class to create indoor and outdoor environments - class Environments - { - public: - static std::shared_ptr indoor(double roomAirTemperature, - double roomPressure = 101325); - - static std::shared_ptr - outdoor(double airTemperature, - double airSpeed, - double solarRadiation, - double skyTemperature, - SkyModel skyModel, - double pressure = 101325, - AirHorizontalDirection airDirection = AirHorizontalDirection::Windward, - double fractionOfClearSky = TarcogConstants::DEFAULT_FRACTION_OF_CLEAR_SKY); - }; +namespace Tarcog::ISO15099 +{ + class CIndoorEnvironment; + class COutdoorEnvironment; - } // namespace ISO15099 + enum class SkyModel; -} // namespace Tarcog + // Singleton class to create indoor and outdoor environments + class Environments + { + public: + static std::shared_ptr indoor(double roomAirTemperature, + double roomPressure = 101325); + + static std::shared_ptr + outdoor(double airTemperature, + double airSpeed, + double solarRadiation, + double skyTemperature, + SkyModel skyModel, + double pressure = 101325, + AirHorizontalDirection airDirection = AirHorizontalDirection::Windward, + double fractionOfClearSky = TarcogConstants::DEFAULT_FRACTION_OF_CLEAR_SKY); + }; + +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Frame.hpp b/src/Tarcog/src/Frame.hpp index fda7d3d3..a9b3c516 100644 --- a/src/Tarcog/src/Frame.hpp +++ b/src/Tarcog/src/Frame.hpp @@ -3,76 +3,74 @@ #include #include -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + struct FrameData { - struct FrameData - { - FrameData(); - FrameData(double uValue, - double edgeUValue, - double projectedFrameDimension, - double wettedLength, - double absorptance = 0.3); - void splitFrameWidth(); - double UValue{0}; - double EdgeUValue{0}; - double ProjectedFrameDimension{0}; - double WettedLength{0}; - double Absorptance{0}; - [[nodiscard]] double shgc(double hc) const; - }; + FrameData(); + FrameData(double uValue, + double edgeUValue, + double projectedFrameDimension, + double wettedLength, + double absorptance = 0.3); + void splitFrameWidth(); + double UValue{0}; + double EdgeUValue{0}; + double ProjectedFrameDimension{0}; + double WettedLength{0}; + double Absorptance{0}; + [[nodiscard]] double shgc(double hc) const; + }; - enum class FrameSide - { - Left, - Right - }; + enum class FrameSide + { + Left, + Right + }; - //! When building window, frame will be inserted differently which is based on what the - //! frame type is. This is important factor when calculating frame area as well as edge of - //! glass area since interior frames will take less space - enum class FrameType - { - Interior, - Exterior - }; + //! When building window, frame will be inserted differently which is based on what the + //! frame type is. This is important factor when calculating frame area as well as edge of + //! glass area since interior frames will take less space + enum class FrameType + { + Interior, + Exterior + }; - class Frame - { - public: - Frame(double length, - FrameType frameType = FrameType::Exterior, - FrameData frameData = FrameData()); + class Frame + { + public: + Frame(double length, + FrameType frameType = FrameType::Exterior, + FrameData frameData = FrameData()); - [[nodiscard]] FrameType frameType() const; + [[nodiscard]] FrameType frameType() const; - [[nodiscard]] double projectedArea() const; - [[nodiscard]] double wettedArea() const; - void setFrameData(FrameData frameData); - [[nodiscard]] const FrameData & frameData() const; - [[nodiscard]] double edgeOfGlassArea() const; - [[nodiscard]] double projectedFrameDimension() const; + [[nodiscard]] double projectedArea() const; + [[nodiscard]] double wettedArea() const; + void setFrameData(FrameData frameData); + [[nodiscard]] const FrameData & frameData() const; + [[nodiscard]] double edgeOfGlassArea() const; + [[nodiscard]] double projectedFrameDimension() const; - void assignFrame(Frame frame, FrameSide side); + void assignFrame(Frame frame, FrameSide side); - //! Divider area that will be subtracted from the frame - void assignDividerArea(double area, size_t nDividers); - void setFrameType(FrameType type); + //! Divider area that will be subtracted from the frame + void assignDividerArea(double area, size_t nDividers); + void setFrameType(FrameType type); - private: - double m_Length; - FrameType m_FrameType; - FrameData m_FrameData; + private: + double m_Length; + FrameType m_FrameType; + FrameData m_FrameData; - //! Keeping frame information on both sides of the frame. This is needed for geometry - //! calculations. Optional must be used or infinite loop will be created withing Frame - //! constructor (Frame calling itself over and over again) - std::map> m_Frame; + //! Keeping frame information on both sides of the frame. This is needed for geometry + //! calculations. Optional must be used or infinite loop will be created withing Frame + //! constructor (Frame calling itself over and over again) + std::map> m_Frame; - double m_DividerArea{0}; - size_t m_NumberOfDividers{0u}; - }; - } // namespace ISO15099 -} // namespace Tarcog + double m_DividerArea{0}; + size_t m_NumberOfDividers{0u}; + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/GasSpecification.cpp b/src/Tarcog/src/GasSpecification.cpp new file mode 100644 index 00000000..faa6d9fd --- /dev/null +++ b/src/Tarcog/src/GasSpecification.cpp @@ -0,0 +1,9 @@ +#include "GasSpecification.hpp" + +namespace Tarcog::ISO15099 +{ + void GasSpecification::setTemperature(double temperature) + { + gas.setTemperatureAndPressure(temperature, pressure); + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/GasSpecification.hpp b/src/Tarcog/src/GasSpecification.hpp new file mode 100644 index 00000000..31f95e00 --- /dev/null +++ b/src/Tarcog/src/GasSpecification.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "AirFlow.hpp" + +#include + +namespace Tarcog::ISO15099 +{ + struct GasSpecification + { + GasSpecification() = default; + + void setTemperature(double temperature); + + double pressure{Gases::DefaultPressure}; + AirflowProperties airflowProperties{}; + + Gases::CGas gas{Gases::CGas()}; + }; +} // namespace Tarcog::ISO15099 \ No newline at end of file diff --git a/src/Tarcog/src/HeatFlowBalance.cpp b/src/Tarcog/src/HeatFlowBalance.cpp index c01d0fc0..319042a1 100644 --- a/src/Tarcog/src/HeatFlowBalance.cpp +++ b/src/Tarcog/src/HeatFlowBalance.cpp @@ -1,145 +1,178 @@ -#include -#include - #include "HeatFlowBalance.hpp" #include "BaseLayer.hpp" -#include "BaseIGULayer.hpp" #include "IGUSolidLayer.hpp" #include "IGU.hpp" #include "Environment.hpp" #include "Surface.hpp" -#include "WCEGases.hpp" -#include "WCECommon.hpp" using FenestrationCommon::Side; -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + CHeatFlowBalance::CHeatFlowBalance(CIGU & t_IGU) : + m_MatrixA(4 * t_IGU.getNumOfLayers()), m_VectorB(4 * t_IGU.getNumOfLayers()), m_IGU(t_IGU) + {} + + std::vector CHeatFlowBalance::calcBalanceMatrix() + { + auto aSolidLayers = m_IGU.getSolidLayers(); + m_MatrixA.setZeros(); + std::fill(m_VectorB.begin(), m_VectorB.end(), 0); + for(size_t i = 0; i < aSolidLayers.size(); ++i) + { + buildCell(*aSolidLayers[i], i); + } + return FenestrationCommon::CLinearSolver::solveSystem(m_MatrixA, m_VectorB); + } + + double getConductionConvectionCoefficient(const std::shared_ptr & layer) + { + return layer ? layer->getConductionConvectionCoefficient() : 0.0; + } + + double getGainFlow(const std::shared_ptr & layer) + { + return layer ? layer->getGainFlow() : 0.0; + } + + void CHeatFlowBalance::buildBaseCell(size_t sP, + double hgl, + double hgap_prev, + double hgap_next, + double qv_prev, + double qv_next, + double solarRadiation, + const Tarcog::ISO15099::CBaseLayer & solid) + { + // first row + m_MatrixA(sP, sP) = hgap_prev + hgl; + m_MatrixA(sP, sP + 1) = 1; + m_MatrixA(sP, sP + 3) = -hgl; + m_VectorB[sP] += solarRadiation / 2 + qv_prev / 2; + + // second row + m_MatrixA(sP + 1, sP) = solid.emissivePowerTerm(Side::Front); + m_MatrixA(sP + 1, sP + 1) = -1; + + // third row + m_MatrixA(sP + 2, sP + 2) = -1; + m_MatrixA(sP + 2, sP + 3) = solid.emissivePowerTerm(Side::Back); + + // fourth row + m_MatrixA(sP + 3, sP) = hgl; + m_MatrixA(sP + 3, sP + 2) = -1; + m_MatrixA(sP + 3, sP + 3) = -hgap_next - hgl; + m_VectorB[sP + 3] += -solarRadiation / 2 - qv_next / 2; + } + + void CHeatFlowBalance::handleNonEnvironmentPreviousLayer( + size_t sP, double hgap_prev, const Tarcog::ISO15099::CBaseLayer & solid) + { + // first row + m_MatrixA(sP, sP - 1) = -hgap_prev; + m_MatrixA(sP, sP - 2) = solid.transmittance(Side::Front) - 1; + + // second row + m_MatrixA(sP + 1, sP - 2) = solid.reflectance(Side::Front); + + // third row + m_MatrixA(sP + 2, sP - 2) = solid.transmittance(Side::Front); + + // fourth row + m_MatrixA(sP + 3, sP - 2) = solid.transmittance(Side::Front); + } + + void CHeatFlowBalance::handleEnvironmentPreviousLayer( + size_t sP, + const std::shared_ptr & previousEnvironment, + double hgap_prev, + const Tarcog::ISO15099::CBaseLayer & solid) + { + double environmentRadiosity = previousEnvironment->getEnvironmentIR(); + double airTemperature = previousEnvironment->getGasTemperature(); + + m_VectorB[sP] += environmentRadiosity + hgap_prev * airTemperature + - environmentRadiosity * solid.transmittance(Side::Front); + m_VectorB[sP + 1] += -solid.reflectance(Side::Front) * environmentRadiosity; + m_VectorB[sP + 2] += -solid.transmittance(Side::Front) * environmentRadiosity; + m_VectorB[sP + 3] += -solid.transmittance(Side::Front) * environmentRadiosity; + } + + void CHeatFlowBalance::handleNonEnvironmentNextLayer(size_t sP, + double hgap_next, + const Tarcog::ISO15099::CBaseLayer & solid) { - CHeatFlowBalance::CHeatFlowBalance(CIGU & t_IGU) : - m_MatrixA(4 * t_IGU.getNumOfLayers()), - m_VectorB(4 * t_IGU.getNumOfLayers()), - m_IGU(t_IGU) - {} + // first row + m_MatrixA(sP, sP + 5) = -solid.transmittance(Side::Back); - std::vector CHeatFlowBalance::calcBalanceMatrix() + // second row + m_MatrixA(sP + 1, sP + 5) = solid.transmittance(Side::Back); + + // third row + m_MatrixA(sP + 2, sP + 5) = solid.reflectance(Side::Back); + + // fourth row + m_MatrixA(sP + 3, sP + 4) = hgap_next; + m_MatrixA(sP + 3, sP + 5) = 1 - solid.transmittance(Side::Back); + } + + void CHeatFlowBalance::handleEnvironmentNextLayer( + size_t sP, + const std::shared_ptr & nextEnvironment, + double hgap_next, + const Tarcog::ISO15099::CBaseLayer & solid) + { + double environmentRadiosity = nextEnvironment->getEnvironmentIR(); + double airTemperature = nextEnvironment->getGasTemperature(); + + m_VectorB[sP] += solid.transmittance(Side::Back) * environmentRadiosity; + m_VectorB[sP + 1] += -solid.transmittance(Side::Back) * environmentRadiosity; + m_VectorB[sP + 2] += -solid.reflectance(Side::Back) * environmentRadiosity; + m_VectorB[sP + 3] += -environmentRadiosity - hgap_next * airTemperature + + solid.transmittance(Side::Back) * environmentRadiosity; + } + + + void CHeatFlowBalance::buildCell(Tarcog::ISO15099::CBaseLayer & solid, const size_t t_Index) + { + // Routine is used to build matrix "cell" around solid layer. + size_t sP = 4 * t_Index; + + auto next = solid.getNextLayer(); + auto previous = solid.getPreviousLayer(); + + auto hgl = solid.getConductionConvectionCoefficient(); + auto hgap_prev = getConductionConvectionCoefficient(previous); + auto hgap_next = getConductionConvectionCoefficient(next); + auto qv_prev = getGainFlow(previous); + auto qv_next = getGainFlow(next); + auto solarRadiation = solid.getGainFlow(); + + buildBaseCell(sP, hgl, hgap_prev, hgap_next, qv_prev, qv_next, solarRadiation, solid); + + auto previousEnvironment = std::dynamic_pointer_cast(previous); + auto nextEnvironment = std::dynamic_pointer_cast(next); + + if(!previousEnvironment) { - auto aSolidLayers = m_IGU.getSolidLayers(); - m_MatrixA.setZeros(); - std::fill(m_VectorB.begin(), m_VectorB.end(), 0); - for(size_t i = 0; i < aSolidLayers.size(); ++i) - { - buildCell(*aSolidLayers[i], i); - } - return FenestrationCommon::CLinearSolver::solveSystem(m_MatrixA, m_VectorB); + handleNonEnvironmentPreviousLayer(sP, hgap_prev, solid); + } + else + { + handleEnvironmentPreviousLayer(sP, previousEnvironment, hgap_prev, solid); } - void CHeatFlowBalance::buildCell(Tarcog::ISO15099::CBaseLayer & t_Current, - const size_t t_Index) + if(!nextEnvironment) + { + handleNonEnvironmentNextLayer(sP, hgap_next, solid); + } + else { - // Routine is used to build matrix "cell" around solid layer. - - // first determine cell size - size_t sP = 4 * t_Index; - - auto next = t_Current.getNextLayer(); - auto previous = t_Current.getPreviousLayer(); - - // First build base cell - double hgl = t_Current.getConductionConvectionCoefficient(); - const double hgap_prev = previous->getConductionConvectionCoefficient(); - const double hgap_next = next->getConductionConvectionCoefficient(); - std::shared_ptr frontSurface = t_Current.getSurface(Side::Front); - assert(frontSurface != nullptr); - const double emissPowerFront = frontSurface->emissivePowerTerm(); - std::shared_ptr backSurface = t_Current.getSurface(Side::Back); - assert(backSurface != nullptr); - const double emissPowerBack = backSurface->emissivePowerTerm(); - const double qv_prev = previous->getGainFlow(); - const double qv_next = next->getGainFlow(); - const double solarRadiation = t_Current.getGainFlow(); - - // first row - m_MatrixA(sP, sP) = hgap_prev + hgl; - m_MatrixA(sP, sP + 1) = 1; - m_MatrixA(sP, sP + 3) = -hgl; - m_VectorB[sP] += solarRadiation / 2 + qv_prev / 2; - - // second row - m_MatrixA(sP + 1, sP) = emissPowerFront; - m_MatrixA(sP + 1, sP + 1) = -1; - - // third row - m_MatrixA(sP + 2, sP + 2) = -1; - m_MatrixA(sP + 2, sP + 3) = emissPowerBack; - - // fourth row - m_MatrixA(sP + 3, sP) = hgl; - m_MatrixA(sP + 3, sP + 2) = -1; - m_MatrixA(sP + 3, sP + 3) = -hgap_next - hgl; - m_VectorB[sP + 3] += -solarRadiation / 2 - qv_next / 2; - - if(std::dynamic_pointer_cast(previous) == nullptr) - { - // first row - m_MatrixA(sP, sP - 1) = -hgap_prev; - m_MatrixA(sP, sP - 2) = frontSurface->getTransmittance() - 1; - - // second row - m_MatrixA(sP + 1, sP - 2) = frontSurface->getReflectance(); - - // third row - m_MatrixA(sP + 2, sP - 2) = frontSurface->getTransmittance(); - - // fourth row - m_MatrixA(sP + 3, sP - 2) = frontSurface->getTransmittance(); - } - else - { - const double environmentRadiosity = - std::dynamic_pointer_cast(previous)->getEnvironmentIR(); - const double airTemperature = - std::dynamic_pointer_cast(previous)->getGasTemperature(); - - m_VectorB[sP] += environmentRadiosity + hgap_prev * airTemperature - - environmentRadiosity * frontSurface->getTransmittance(); - m_VectorB[sP + 1] += -frontSurface->getReflectance() * environmentRadiosity; - m_VectorB[sP + 2] += -frontSurface->getTransmittance() * environmentRadiosity; - m_VectorB[sP + 3] += -frontSurface->getTransmittance() * environmentRadiosity; - } - - if(std::dynamic_pointer_cast(next) == nullptr) - { - // first row - m_MatrixA(sP, sP + 5) = -backSurface->getTransmittance(); - - // second row - m_MatrixA(sP + 1, sP + 5) = backSurface->getTransmittance(); - - // third row - m_MatrixA(sP + 2, sP + 5) = backSurface->getReflectance(); - - // fourth row - m_MatrixA(sP + 3, sP + 4) = hgap_next; - m_MatrixA(sP + 3, sP + 5) = 1 - backSurface->getTransmittance(); - } - else - { - const double environmentRadiosity = - std::dynamic_pointer_cast(next)->getEnvironmentIR(); - const double airTemperature = - std::dynamic_pointer_cast(next)->getGasTemperature(); - - m_VectorB[sP] += backSurface->getTransmittance() * environmentRadiosity; - m_VectorB[sP + 1] += -backSurface->getTransmittance() * environmentRadiosity; - m_VectorB[sP + 2] += -backSurface->getReflectance() * environmentRadiosity; - m_VectorB[sP + 3] += -environmentRadiosity - hgap_next * airTemperature - + backSurface->getTransmittance() * environmentRadiosity; - } + handleEnvironmentNextLayer(sP, nextEnvironment, hgap_next, solid); } + } - } // namespace ISO15099 -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/HeatFlowBalance.hpp b/src/Tarcog/src/HeatFlowBalance.hpp index 4d46fdc2..058a4e07 100644 --- a/src/Tarcog/src/HeatFlowBalance.hpp +++ b/src/Tarcog/src/HeatFlowBalance.hpp @@ -1,9 +1,10 @@ -#ifndef TARCOGQBALANCE_H -#define TARCOGQBALANCE_H +#pragma once #include #include -#include "WCECommon.hpp" + +#include + #include "IGU.hpp" namespace FenestrationCommon @@ -13,30 +14,49 @@ namespace FenestrationCommon } // namespace FenestrationCommon -namespace Tarcog -{ - namespace ISO15099 - { - class CBaseLayer; - - class CHeatFlowBalance - { - public: - explicit CHeatFlowBalance(CIGU & t_IGU); - - std::vector calcBalanceMatrix(); - private: - void buildCell(Tarcog::ISO15099::CBaseLayer & t_Current, size_t t_Index); - - FenestrationCommon::SquareMatrix m_MatrixA; - std::vector m_VectorB; - - CIGU & m_IGU; - }; - - } // namespace ISO15099 - -} // namespace Tarcog +namespace Tarcog::ISO15099 +{ + class CBaseLayer; + class CEnvironment; -#endif + class CHeatFlowBalance + { + public: + explicit CHeatFlowBalance(CIGU & t_IGU); + + std::vector calcBalanceMatrix(); + + private: + void buildBaseCell(size_t sP, + double hgl, + double hgap_prev, + double hgap_next, + double qv_prev, + double qv_next, + double solarRadiation, + const Tarcog::ISO15099::CBaseLayer & solid); + void handleNonEnvironmentPreviousLayer(size_t sP, + double hgap_prev, + const Tarcog::ISO15099::CBaseLayer & solid); + void + handleEnvironmentPreviousLayer(size_t sP, + const std::shared_ptr & previousEnvironment, + double hgap_prev, + const Tarcog::ISO15099::CBaseLayer & solid); + void handleNonEnvironmentNextLayer(size_t sP, + double hgap_next, + const Tarcog::ISO15099::CBaseLayer & solid); + void handleEnvironmentNextLayer(size_t sP, + const std::shared_ptr & nextEnvironment, + double hgap_next, + const Tarcog::ISO15099::CBaseLayer & solid); + void buildCell(Tarcog::ISO15099::CBaseLayer & solid, size_t t_Index); + + FenestrationCommon::SquareMatrix m_MatrixA; + std::vector m_VectorB; + + CIGU & m_IGU; + }; + +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGU.cpp b/src/Tarcog/src/IGU.cpp index dd9196f1..2fa2b49a 100644 --- a/src/Tarcog/src/IGU.cpp +++ b/src/Tarcog/src/IGU.cpp @@ -8,7 +8,6 @@ #include #include "IGU.hpp" -#include "BaseIGULayer.hpp" #include "IGUSolidLayer.hpp" #include "IGUGapLayer.hpp" #include "Surface.hpp" @@ -20,683 +19,675 @@ using FenestrationCommon::Side; -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + CIGU::CIGU(double const t_Width, double const t_Height, double const t_Tilt) : + m_Width(t_Width), m_Height(t_Height), m_Tilt(t_Tilt) + {} + + CIGU::CIGU(CIGU const & t_IGU) { - CIGU::CIGU(double const t_Width, double const t_Height, double const t_Tilt) : - m_Width(t_Width), - m_Height(t_Height), - m_Tilt(t_Tilt) - {} + operator=(t_IGU); + } - CIGU::CIGU(CIGU const & t_IGU) + CIGU & CIGU::operator=(CIGU const & t_IGU) + { + m_Width = t_IGU.m_Width; + m_Height = t_IGU.m_Height; + m_Tilt = t_IGU.m_Tilt; + m_Layers.clear(); + for(auto & layer : t_IGU.m_Layers) { - operator=(t_IGU); + const auto aLayer{layer->clone()}; + addLayer(aLayer); } - CIGU & CIGU::operator=(CIGU const & t_IGU) - { - m_Width = t_IGU.m_Width; - m_Height = t_IGU.m_Height; - m_Tilt = t_IGU.m_Tilt; - m_Layers.clear(); - for(auto & layer : t_IGU.m_Layers) - { - const auto aLayer{layer->clone()}; - addLayer(aLayer); - } + m_DeflectionFromE1300Curves = t_IGU.m_DeflectionFromE1300Curves; - m_DeflectionFromE1300Curves = t_IGU.m_DeflectionFromE1300Curves; + return *this; + } - return *this; + CIGU::~CIGU() + { + for(std::shared_ptr layer : getSolidLayers()) + { + layer->tearDownConnections(); } + } - CIGU::~CIGU() + void CIGU::addLayer(const std::shared_ptr & t_Layer) + { + // pushes only solid layers to array. Gap layers are connected via linked list + // In case this is first layer then it must be a solid layer in order to create IGU + if(getNumOfLayers() == 0) { - for(std::shared_ptr layer : getSolidLayers()) + if(std::dynamic_pointer_cast(t_Layer) != nullptr) + { + m_Layers.push_back(t_Layer); + } + else { - layer->tearDownConnections(); + throw std::runtime_error("First inserted layer must be a solid layer."); } } - - void CIGU::addLayer(const std::shared_ptr & t_Layer) + else { - // pushes only solid layers to array. Gap layers are connected via linked list - // In case this is first layer then it must be a solid layer in order to create IGU - if(getNumOfLayers() == 0) + auto lastLayer = m_Layers.back(); + if(std::dynamic_pointer_cast(t_Layer) + != std::dynamic_pointer_cast(lastLayer)) { - if(std::dynamic_pointer_cast(t_Layer) != nullptr) - { - m_Layers.push_back(t_Layer); - } - else - { - throw std::runtime_error("First inserted layer must be a solid layer."); - } + m_Layers.push_back(t_Layer); + lastLayer->connectToBackSide(t_Layer); } else { - auto lastLayer = m_Layers.back(); - if(std::dynamic_pointer_cast(t_Layer) - != std::dynamic_pointer_cast(lastLayer)) - { - m_Layers.push_back(t_Layer); - lastLayer->connectToBackSide(t_Layer); - } - else - { - throw std::runtime_error( - "Two adjecent layers in IGU cannot be of same type. " - "IGU must be constructed of array of solid and gap layers."); - } + throw std::runtime_error( + "Two adjecent layers in IGU cannot be of same type. " + "IGU must be constructed of array of solid and gap layers."); } + } - checkForLayerUpgrades(t_Layer); + checkForLayerUpgrades(t_Layer); - t_Layer->setTilt(m_Tilt); - t_Layer->setWidth(m_Width); - t_Layer->setHeight(m_Height); - } + t_Layer->setTilt(m_Tilt); + t_Layer->setWidth(m_Width); + t_Layer->setHeight(m_Height); + } - void CIGU::addLayers(const std::initializer_list> & layers) + void CIGU::addLayers(const std::initializer_list> & layers) + { + for(const auto & layer : layers) { - for(const auto & layer : layers) - { - addLayer(layer); - } + addLayer(layer); } + } - void CIGU::setTilt(double const t_Tilt) + void CIGU::setTilt(double const t_Tilt) + { + for(auto & layer : m_Layers) { - for(auto & layer : m_Layers) - { - layer->setTilt(t_Tilt); - } - m_Tilt = t_Tilt; - - if(m_DeflectionFromE1300Curves.has_value()) - { - m_DeflectionFromE1300Curves->setIGUTilt(t_Tilt); - } + layer->setTilt(t_Tilt); } + m_Tilt = t_Tilt; - void CIGU::setWidth(double const t_Width) + if(m_DeflectionFromE1300Curves.has_value()) { - for(auto & layer : m_Layers) - { - layer->setWidth(t_Width); - } - m_Width = t_Width; - - if(m_DeflectionFromE1300Curves.has_value()) - { - m_DeflectionFromE1300Curves->setDimensions(m_Width, m_Height); - } + m_DeflectionFromE1300Curves->setIGUTilt(t_Tilt); } + } - void CIGU::setHeight(double const t_Height) + void CIGU::setWidth(double const t_Width) + { + for(auto & layer : m_Layers) { - for(auto & layer : m_Layers) - { - layer->setHeight(t_Height); - } - m_Height = t_Height; - - if(m_DeflectionFromE1300Curves.has_value()) - { - m_DeflectionFromE1300Curves->setDimensions(m_Width, m_Height); - } + layer->setWidth(t_Width); } + m_Width = t_Width; - void CIGU::setSolarRadiation(double const t_SolarRadiation) const + if(m_DeflectionFromE1300Curves.has_value()) { - for(auto & layer : getSolidLayers()) - { - layer->setSolarRadiation(t_SolarRadiation); - } + m_DeflectionFromE1300Curves->setDimensions(m_Width, m_Height); } + } - std::shared_ptr CIGU::getEnvironment(Environment t_Environment) const + void CIGU::setHeight(double const t_Height) + { + for(auto & layer : m_Layers) { - std::shared_ptr aLayer = nullptr; - switch(t_Environment) - { - case Environment::Indoor: - aLayer = m_Layers.back(); - break; - case Environment::Outdoor: - aLayer = m_Layers.front(); - break; - } - return aLayer; + layer->setHeight(t_Height); } + m_Height = t_Height; - std::vector CIGU::getState() const + if(m_DeflectionFromE1300Curves.has_value()) { - std::vector aState; - - for(auto & layer : getSolidLayers()) - { - // State must be filled in this exact order. - aState.push_back(layer->getTemperature(Side::Front)); - aState.push_back(layer->J(Side::Front)); - aState.push_back(layer->J(Side::Back)); - aState.push_back(layer->getTemperature(Side::Back)); - } - - return aState; + m_DeflectionFromE1300Curves->setDimensions(m_Width, m_Height); } + } - void CIGU::setState(const std::vector & t_State) const + void CIGU::setSolarRadiation(double const t_SolarRadiation) const + { + for(auto & layer : getSolidLayers()) { - size_t i = 0; - for(const auto & aLayer : getSolidLayers()) - { - const auto Tf = t_State[4 * i]; - const auto Jf = t_State[4 * i + 1]; - const auto Jb = t_State[4 * i + 2]; - const auto Tb = t_State[4 * i + 3]; - aLayer->setLayerState(Tf, Tb, Jf, Jb); - ++i; - } + layer->setSolarRadiation(t_SolarRadiation); } + } - std::vector CIGU::getTemperatures() const + std::shared_ptr CIGU::getEnvironment(Environment t_Environment) const + { + std::shared_ptr aLayer = nullptr; + switch(t_Environment) { - std::vector aTemperatures; - - for(auto const & layer : getSolidLayers()) - { - for(auto aSide : FenestrationCommon::EnumSide()) - { - aTemperatures.push_back(layer->getTemperature(aSide)); - } - } - - return aTemperatures; + case Environment::Indoor: + aLayer = m_Layers.back(); + break; + case Environment::Outdoor: + aLayer = m_Layers.front(); + break; } + return aLayer; + } + + std::vector CIGU::getState() const + { + std::vector aState; - std::vector CIGU::getRadiosities() const + for(auto & layer : getSolidLayers()) { - std::vector aRadiosities; + // State must be filled in this exact order. + aState.push_back(layer->surfaceTemperature(Side::Front)); + aState.push_back(layer->J(Side::Front)); + aState.push_back(layer->J(Side::Back)); + aState.push_back(layer->surfaceTemperature(Side::Back)); + } - for(auto const & layer : getSolidLayers()) - { - for(auto aSide : FenestrationCommon::EnumSide()) - { - aRadiosities.push_back(layer->J(aSide)); - } - } + return aState; + } - return aRadiosities; + void CIGU::setState(const std::vector & t_State) const + { + size_t i = 0; + for(const auto & aLayer : getSolidLayers()) + { + const auto Tf = t_State[4 * i]; + const auto Jf = t_State[4 * i + 1]; + const auto Jb = t_State[4 * i + 2]; + const auto Tb = t_State[4 * i + 3]; + aLayer->setLayerState(Tf, Tb, Jf, Jb); + ++i; } + } - std::vector CIGU::getMaxLayerDeflections() const - { - std::vector aMaxDeflections; + std::vector CIGU::getTemperatures() const + { + std::vector aTemperatures; - for(auto const & layer : getSolidLayers()) + for(auto const & layer : getSolidLayers()) + { + for(auto aSide : FenestrationCommon::EnumSide()) { - aMaxDeflections.push_back(layer->getMaxDeflection()); + aTemperatures.push_back(layer->surfaceTemperature(aSide)); } - - return aMaxDeflections; } - std::vector CIGU::getMeanLayerDeflections() const - { - std::vector aMeanDeflections; - - for(auto const & layer : getSolidLayers()) - { - aMeanDeflections.push_back(layer->getMeanDeflection()); - } + return aTemperatures; + } - return aMeanDeflections; - } + std::vector CIGU::getRadiosities() const + { + std::vector aRadiosities; - std::vector CIGU::getMaxGapWidth() const + for(auto const & layer : getSolidLayers()) { - std::vector aMaxWidths; - - for(auto const & layer : getGapLayers()) + for(auto aSide : FenestrationCommon::EnumSide()) { - aMaxWidths.push_back(layer->getMaxDeflection()); + aRadiosities.push_back(layer->J(aSide)); } - - return aMaxWidths; } - std::vector CIGU::getMeanGapWidth() const - { - std::vector aMeanWidths; + return aRadiosities; + } - for(auto const & layer : getGapLayers()) - { - aMeanWidths.push_back(layer->getMeanDeflection()); - } + std::vector CIGU::getMaxLayerDeflections() const + { + std::vector aMaxDeflections; - return aMeanWidths; + for(auto const & layer : getSolidLayers()) + { + aMaxDeflections.push_back(layer->getMaxDeflection()); } - std::vector CIGU::getGapPressures() const - { - std::vector aPressures; + return aMaxDeflections; + } - for(auto const & layer : getGapLayers()) - { - aPressures.push_back(layer->getPressure()); - } + std::vector CIGU::getMeanLayerDeflections() const + { + std::vector aMeanDeflections; - return aPressures; + for(auto const & layer : getSolidLayers()) + { + aMeanDeflections.push_back(layer->getMeanDeflection()); } - std::vector CIGU::getPanesLoad() - { - std::vector paneLoad(getSolidLayers().size()); + return aMeanDeflections; + } - if(m_DeflectionFromE1300Curves.has_value()) - { - paneLoad = m_DeflectionFromE1300Curves->results().paneLoad; - } + std::vector CIGU::getMaxGapWidth() const + { + std::vector aMaxWidths; - return paneLoad; + for(auto const & layer : getGapLayers()) + { + aMaxWidths.push_back(layer->getMaxDeflection()); } - double CIGU::getThickness() const - { - auto totalWidth = 0.0; + return aMaxWidths; + } - for(auto & layer : m_Layers) - { - totalWidth += layer->getThickness(); - } - - return totalWidth; - } + std::vector CIGU::getMeanGapWidth() const + { + std::vector aMeanWidths; - double CIGU::getTilt() const + for(auto const & layer : getGapLayers()) { - return m_Tilt; + aMeanWidths.push_back(layer->getMeanDeflection()); } - double CIGU::getWidth() const + return aMeanWidths; + } + + std::vector CIGU::getGapPressures() const + { + std::vector aPressures; + + for(auto const & layer : getGapLayers()) { - return m_Width; + aPressures.push_back(layer->getPressure()); } - double CIGU::getHeight() const + return aPressures; + } + + std::vector CIGU::getPanesLoad() + { + std::vector paneLoad(getSolidLayers().size()); + + if(m_DeflectionFromE1300Curves.has_value()) { - return m_Height; + paneLoad = m_DeflectionFromE1300Curves->results().paneLoad; } - size_t CIGU::getNumOfLayers() const + return paneLoad; + } + + double CIGU::getThickness() const + { + auto totalWidth = 0.0; + + for(auto & layer : m_Layers) { - return (m_Layers.size() + 1) / 2; + totalWidth += layer->getThickness(); } - double CIGU::getVentilationFlow(const Environment t_Environment) const + return totalWidth; + } + + double CIGU::getTilt() const + { + return m_Tilt; + } + + double CIGU::getWidth() const + { + return m_Width; + } + + double CIGU::getHeight() const + { + return m_Height; + } + + size_t CIGU::getNumOfLayers() const + { + return (m_Layers.size() + 1) / 2; + } + + double CIGU::getVentilationFlow(const Environment t_Environment) const + { + // This is asking flow from the gap that is connected to the one of the environments. + const auto size = m_Layers.size(); + auto result{0.0}; + if(size > 1u) { - // This is asking flow from the gap that is connected to the one of the environments. - const auto size = m_Layers.size(); - auto result{0.0}; - if(size > 1u) - { - // This is important in order to get correct gap numbering. It will return the gap - // that is connected with the environment. - const std::map envLayer = {{Environment::Indoor, size - 2}, - {Environment::Outdoor, 1}}; + // This is important in order to get correct gap numbering. It will return the gap + // that is connected with the environment. + const std::map envLayer = {{Environment::Indoor, size - 2}, + {Environment::Outdoor, 1}}; - // Need to make sure that solid layer is actually permeable as well - const std::map solidLayerIndex = { - {Environment::Indoor, size - 1}, {Environment::Outdoor, 0}}; + // Need to make sure that solid layer is actually permeable as well + const std::map solidLayerIndex = {{Environment::Indoor, size - 1}, + {Environment::Outdoor, 0}}; - if(m_Layers[solidLayerIndex.at(t_Environment)]->isPermeable()) - { - result = m_Layers[envLayer.at(t_Environment)]->getGainFlow(); - } + if(m_Layers[solidLayerIndex.at(t_Environment)]->isPermeable()) + { + result = m_Layers[envLayer.at(t_Environment)]->getGainFlow(); } - return result; } + return result; + } - void CIGU::setInitialGuess(std::vector const & t_Guess) const + void CIGU::setInitialGuess(std::vector const & t_Guess) const + { + if(2 * getNumOfLayers() != t_Guess.size()) { - if(2 * getNumOfLayers() != t_Guess.size()) - { - std::cout << "Number of temperatures in initial guess cannot fit number of layers." - "Program will use initial guess instead" - << std::endl; - } - else + std::cout << "Number of temperatures in initial guess cannot fit number of layers." + "Program will use initial guess instead" + << std::endl; + } + else + { + size_t Index = 0; + for(auto & aLayer : getSolidLayers()) { - size_t Index = 0; - for(auto & aLayer : getSolidLayers()) + for(auto aSide : FenestrationCommon::EnumSide()) { - for(auto aSide : FenestrationCommon::EnumSide()) - { - auto aSurface = aLayer->getSurface(aSide); - aSurface->initializeStart(t_Guess[Index]); - ++Index; - } + aLayer->initializeStart(aSide, t_Guess[Index]); + ++Index; } } } + } - void CIGU::setDeflectionProperties(const double t_Tini, - const double t_Pini, - const double t_InsidePressure, - const double t_OutsidePressure) + void CIGU::setDeflectionProperties(const double t_Tini, + const double t_Pini, + const double t_InsidePressure, + const double t_OutsidePressure) + { + // m_DeflectionFromE1300Curves must be set when surfaces are in non-deflected state. + // Since user might have called IGU previously with different deflection properties + resetSurfaceDeflections(); + std::vector layerData; + for(const auto & layer : getSolidLayers()) { - // m_DeflectionFromE1300Curves must be set when surfaces are in non-deflected state. - // Since user might have called IGU previously with different deflection properties - resetSurfaceDeflections(); - std::vector layerData; - for(const auto & layer : getSolidLayers()) - { - layerData.emplace_back( - layer->getThickness(), layer->density(), layer->youngsModulus()); - } + layerData.emplace_back(layer->getThickness(), layer->density(), layer->youngsModulus()); + } - std::vector gapData; - for(auto & gap : getGapLayers()) - { - gap->setSealedGapProperties(t_Tini, t_Pini); - gapData.emplace_back(gap->getThickness(), t_Tini, t_Pini); - } + std::vector gapData; + for(auto & gap : getGapLayers()) + { + gap->setSealedGapProperties(t_Tini, t_Pini); + gapData.emplace_back(gap->getThickness(), t_Tini, t_Pini); + } - m_DeflectionFromE1300Curves = Deflection::DeflectionE1300(m_Width, m_Height, layerData, gapData); + m_DeflectionFromE1300Curves = + Deflection::DeflectionE1300(m_Width, m_Height, layerData, gapData); - m_DeflectionFromE1300Curves->setIGUTilt(m_Tilt); - m_DeflectionFromE1300Curves->setInteriorPressure(t_InsidePressure); - m_DeflectionFromE1300Curves->setExteriorPressure(t_OutsidePressure); + m_DeflectionFromE1300Curves->setIGUTilt(m_Tilt); + m_DeflectionFromE1300Curves->setInteriorPressure(t_InsidePressure); + m_DeflectionFromE1300Curves->setExteriorPressure(t_OutsidePressure); - if(m_DeflectionAppliedLoad.size() == layerData.size()) - { - m_DeflectionFromE1300Curves->setAppliedLoad(m_DeflectionAppliedLoad); - } + if(m_DeflectionAppliedLoad.size() == layerData.size()) + { + m_DeflectionFromE1300Curves->setAppliedLoad(m_DeflectionAppliedLoad); } + } - // Purpose of this function is not to convert solid layer twice since it is already - // converted for the measured deflection - CIGUSolidLayerDeflection convertToMeasuredDeflectionLayer(const CIGUSolidLayer & layer) + // Purpose of this function is not to convert solid layer twice since it is already + // converted for the measured deflection + CIGUSolidLayerDeflection convertToMeasuredDeflectionLayer(const CIGUSolidLayer & layer) + { + if(auto deflectionLayer = dynamic_cast(&layer)) { - if(auto deflectionLayer = dynamic_cast(&layer)) - { - return *deflectionLayer; - } - else - { - return CIGUSolidLayerDeflection(layer); - } + return *deflectionLayer; } - - void CIGU::setDeflectionProperties(std::vector const & t_MeasuredDeflections) + else { - // In case user sets the deflection properties as pressure and temperauture and then - // reset this back to measured deflection should delete calculator for the deflection - // from E1300 curves. - m_DeflectionFromE1300Curves = std::nullopt; + return CIGUSolidLayerDeflection(layer); + } + } - if(t_MeasuredDeflections.size() != getNumOfLayers() - 1) - { - throw std::runtime_error( - "Number of measured deflection values must be equal to number of gaps."); - } + void CIGU::setDeflectionProperties(std::vector const & t_MeasuredDeflections) + { + // In case user sets the deflection properties as pressure and temperature and then + // reset this back to measured deflection should delete calculator for the deflection + // from E1300 curves. + m_DeflectionFromE1300Curves = std::nullopt; + + if(t_MeasuredDeflections.size() != getNumOfLayers() - 1) + { + throw std::runtime_error( + "Number of measured deflection values must be equal to number of gaps."); + } - auto deflectionRatio = Ldmean() / Ldmax(); - auto LDefMax = calculateLDefMax(t_MeasuredDeflections); + auto deflectionRatio = Ldmean() / Ldmax(); + auto LDefMax = calculateLDefMax(t_MeasuredDeflections); - for(auto i = 0u; i < getNumOfLayers(); ++i) + for(auto i = 0u; i < getNumOfLayers(); ++i) + { + auto LDefNMean = deflectionRatio * LDefMax[i]; + auto aLayer = getSolidLayers()[i]; + if(dynamic_cast(aLayer.get()) == nullptr) { - auto LDefNMean = deflectionRatio * LDefMax[i]; - auto aLayer = getSolidLayers()[i]; - if(dynamic_cast(aLayer.get()) == nullptr) - { - auto aDefLayer = std::make_shared(*aLayer); - aDefLayer = - std::make_shared(aDefLayer, LDefNMean, LDefMax[i]); - replaceLayer(aLayer, aDefLayer); - } + auto aDefLayer = std::make_shared(*aLayer); + aDefLayer = + std::make_shared(aDefLayer, LDefNMean, LDefMax[i]); + replaceLayer(aLayer, aDefLayer); } } + } - void CIGU::updateDeflectionState() + void CIGU::updateDeflectionState() + { + if(m_DeflectionFromE1300Curves.has_value()) { - if(m_DeflectionFromE1300Curves.has_value()) + const auto gapLayers{getGapLayers()}; + std::vector gapTemperatures(gapLayers.size()); + for(size_t i = 0u; i < gapTemperatures.size(); ++i) { - const auto gapLayers{getGapLayers()}; - std::vector gapTemperatures(gapLayers.size()); - for(size_t i = 0u; i < gapTemperatures.size(); ++i) - { - gapTemperatures[i] = gapLayers[i]->averageTemperature(); - } - m_DeflectionFromE1300Curves->setLoadTemperatures(gapTemperatures); + gapTemperatures[i] = gapLayers[i]->averageLayerTemperature(); + } + m_DeflectionFromE1300Curves->setLoadTemperatures(gapTemperatures); - auto deflectionResults{m_DeflectionFromE1300Curves->results()}; + auto deflectionResults{m_DeflectionFromE1300Curves->results()}; - // This is borrowed from Timschenko. It will be used till E1300 calculations are - // actually doing this. - const auto deflectionRatio = Ldmean() / Ldmax(); + // This is borrowed from Timschenko. It will be used till E1300 calculations are + // actually doing this. + const auto deflectionRatio = Ldmean() / Ldmax(); - auto solidLayers{getSolidLayers()}; + auto solidLayers{getSolidLayers()}; - assert(deflectionResults.deflection.size() == solidLayers.size()); + assert(deflectionResults.deflection.size() == solidLayers.size()); - for(size_t i = 0u; i < deflectionResults.deflection.size(); ++i) - { - auto def{deflectionResults.deflection[i]}; - solidLayers[i]->applyDeflection(deflectionRatio * def, def); - } + for(size_t i = 0u; i < deflectionResults.deflection.size(); ++i) + { + auto def{deflectionResults.deflection[i]}; + solidLayers[i]->applyDeflection(deflectionRatio * def, def); } } + } - void CIGU::replaceLayer(std::shared_ptr const & t_Original, - std::shared_ptr const & t_Replacement) + void CIGU::replaceLayer(const std::shared_ptr & t_Original, + const std::shared_ptr & t_Replacement) + { + size_t index = static_cast(find(m_Layers.begin(), m_Layers.end(), t_Original) + - m_Layers.begin()); + m_Layers[index] = t_Replacement; + if(index > 0) { - size_t index = static_cast(find(m_Layers.begin(), m_Layers.end(), t_Original) - - m_Layers.begin()); - m_Layers[index] = t_Replacement; - if(index > 0) - { - m_Layers[index - 1]->connectToBackSide(t_Replacement); - } - if(index < m_Layers.size() - 1) - { - t_Replacement->connectToBackSide(m_Layers[index + 1]); - } + m_Layers[index - 1]->connectToBackSide(t_Replacement); + } + if(index < m_Layers.size() - 1) + { + t_Replacement->connectToBackSide(m_Layers[index + 1]); } + } - void CIGU::checkForLayerUpgrades(const std::shared_ptr & t_Layer) + void CIGU::checkForLayerUpgrades(const std::shared_ptr & t_Layer) + { + if(std::dynamic_pointer_cast(t_Layer) != nullptr) { - if(std::dynamic_pointer_cast(t_Layer) != nullptr) + if(std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) != nullptr + && std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) + == nullptr) { - if(std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) != nullptr - && std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) - == nullptr) - { - auto newLayer = std::make_shared( - std::dynamic_pointer_cast(t_Layer->getPreviousLayer())); - replaceLayer( - std::dynamic_pointer_cast(t_Layer->getPreviousLayer()), - newLayer); - } + auto newLayer = std::make_shared( + std::dynamic_pointer_cast(t_Layer->getPreviousLayer())); + replaceLayer(std::dynamic_pointer_cast(t_Layer->getPreviousLayer()), + newLayer); } - if(std::dynamic_pointer_cast(t_Layer) != nullptr - && std::dynamic_pointer_cast(t_Layer) == nullptr) + } + if(std::dynamic_pointer_cast(t_Layer) != nullptr + && std::dynamic_pointer_cast(t_Layer) == nullptr) + { + if(std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) != nullptr) { - if(std::dynamic_pointer_cast(t_Layer->getPreviousLayer()) - != nullptr) - { - auto newLayer = std::make_shared( - std::dynamic_pointer_cast(t_Layer)); - replaceLayer(std::dynamic_pointer_cast(t_Layer), newLayer); - } + auto newLayer = std::make_shared( + std::dynamic_pointer_cast(t_Layer)); + replaceLayer(std::dynamic_pointer_cast(t_Layer), newLayer); } } + } - double CIGU::Ldmean() const - { - using ConstantsData::WCE_PI; + double CIGU::Ldmean() const + { + using ConstantsData::WCE_PI; - auto coeff = 16 / (pow(WCE_PI, 6)); - auto totalSum = 0.0; - for(auto m = 1; m <= 5; m += 2) + auto coeff = 16 / (pow(WCE_PI, 6)); + auto totalSum = 0.0; + for(auto m = 1; m <= 5; m += 2) + { + for(auto n = 1; n <= 5; n += 2) { - for(auto n = 1; n <= 5; n += 2) - { - auto nomin = 4.0; - auto denom = m * m * n * n * WCE_PI * WCE_PI - * pow(pow(m / m_Width, 2) + pow(n / m_Height, 2), 2); - totalSum += nomin / denom; - } + auto nomin = 4.0; + auto denom = m * m * n * n * WCE_PI * WCE_PI + * pow(pow(m / m_Width, 2) + pow(n / m_Height, 2), 2); + totalSum += nomin / denom; } - return coeff * totalSum; } + return coeff * totalSum; + } - double CIGU::Ldmax() const - { - using ConstantsData::WCE_PI; + double CIGU::Ldmax() const + { + using ConstantsData::WCE_PI; - auto coeff = 16 / (pow(WCE_PI, 6)); - auto totalSum = 0.0; - for(auto m = 1; m <= 5; m += 2) + auto coeff = 16 / (pow(WCE_PI, 6)); + auto totalSum = 0.0; + for(auto m = 1; m <= 5; m += 2) + { + for(auto n = 1; n <= 5; n += 2) { - for(auto n = 1; n <= 5; n += 2) - { - auto nomin = sin(m * WCE_PI / 2) * sin(n * WCE_PI / 2); - auto denom = m * n * pow(pow(m / m_Width, 2) + pow(n / m_Height, 2), 2); - totalSum += nomin / denom; - } + auto nomin = sin(m * WCE_PI / 2) * sin(n * WCE_PI / 2); + auto denom = m * n * pow(pow(m / m_Width, 2) + pow(n / m_Height, 2), 2); + totalSum += nomin / denom; } - return coeff * totalSum; } + return coeff * totalSum; + } - std::vector> CIGU::getSolidLayers() const + std::vector> CIGU::getSolidLayers() const + { + std::vector> aVect; + for(auto const & aLayer : m_Layers) { - std::vector> aVect; - for(auto const & aLayer : m_Layers) + if(std::dynamic_pointer_cast(aLayer) != nullptr) { - if(std::dynamic_pointer_cast(aLayer) != nullptr) - { - aVect.push_back(std::dynamic_pointer_cast(aLayer)); - } + aVect.push_back(std::dynamic_pointer_cast(aLayer)); } - return aVect; } + return aVect; + } - std::vector> CIGU::getGapLayers() const + std::vector> CIGU::getGapLayers() const + { + std::vector> aVect; + for(auto const & aLayer : m_Layers) { - std::vector> aVect; - for(auto const & aLayer : m_Layers) + if(std::dynamic_pointer_cast(aLayer) != nullptr) { - if(std::dynamic_pointer_cast(aLayer) != nullptr) - { - aVect.push_back(std::dynamic_pointer_cast(aLayer)); - } + aVect.push_back(std::dynamic_pointer_cast(aLayer)); } - return aVect; } + return aVect; + } - std::vector> CIGU::getLayers() const - { - return m_Layers; - } + std::vector> CIGU::getLayers() const + { + return m_Layers; + } - void CIGU::setAbsorptances(const std::vector & absorptances, double solarRadiation) + void CIGU::setAbsorptances(const std::vector & absorptances, double solarRadiation) + { + auto solidLayers = getSolidLayers(); + if(solidLayers.size() != absorptances.size()) { - auto solidLayers = getSolidLayers(); - if(solidLayers.size() != absorptances.size()) - { - throw std::runtime_error( - "Number of absorptances does not match number of solid layers."); - } - for(size_t i = 0; i < solidLayers.size(); ++i) - { - solidLayers[i]->setSolarHeatGain(absorptances[i], solarRadiation); - } + throw std::runtime_error( + "Number of absorptances does not match number of solid layers."); } - - void CIGU::clearDeflection() + for(size_t i = 0; i < solidLayers.size(); ++i) { - m_DeflectionFromE1300Curves = std::nullopt; + solidLayers[i]->setSolarHeatGain(absorptances[i], solarRadiation); } + } + + void CIGU::clearDeflection() + { + m_DeflectionFromE1300Curves = std::nullopt; + } - void CIGU::setAppliedLoad(std::vector t_AppliedLoad) + void CIGU::setAppliedLoad(std::vector t_AppliedLoad) + { + m_DeflectionAppliedLoad = t_AppliedLoad; + if(m_DeflectionFromE1300Curves.has_value()) { - m_DeflectionAppliedLoad = t_AppliedLoad; - if(m_DeflectionFromE1300Curves.has_value()) - { - m_DeflectionFromE1300Curves->setAppliedLoad(std::move(t_AppliedLoad)); - } + m_DeflectionFromE1300Curves->setAppliedLoad(std::move(t_AppliedLoad)); } + } - void CIGU::precalculateLayerStates() + void CIGU::precalculateLayerStates() + { + for(auto & layer : m_Layers) { - for(auto & layer : m_Layers) - { - layer->precalculateState(); - } + layer->precalculateState(); } + } - double CIGU::calculateDeflectionNumerator( - const std::vector & t_MeasuredDeflections) const + double + CIGU::calculateDeflectionNumerator(const std::vector & t_MeasuredDeflections) const + { + auto numerator = 0.0; + for(size_t i = 0; i < t_MeasuredDeflections.size(); ++i) { - auto numerator = 0.0; - for(size_t i = 0; i < t_MeasuredDeflections.size(); ++i) + auto SumL = 0.0; + for(auto j = i; j < t_MeasuredDeflections.size(); ++j) { - auto SumL = 0.0; - for(auto j = i; j < t_MeasuredDeflections.size(); ++j) - { - SumL += getGapLayers()[j]->getThickness() - t_MeasuredDeflections[j]; - } - auto aDefLayer = convertToMeasuredDeflectionLayer(*getSolidLayers()[i]); - numerator += SumL * aDefLayer.flexuralRigidity(); + SumL += getGapLayers()[j]->getThickness() - t_MeasuredDeflections[j]; } - return numerator; + auto aDefLayer = convertToMeasuredDeflectionLayer(*getSolidLayers()[i]); + numerator += SumL * aDefLayer.flexuralRigidity(); } + return numerator; + } - double CIGU::calculateDeflectionDenominator() const + double CIGU::calculateDeflectionDenominator() const + { + auto denominator = 0.0; + for(auto i = 0u; i < getSolidLayers().size(); ++i) { - auto denominator = 0.0; - for(auto i = 0u; i < getSolidLayers().size(); ++i) - { - auto aDefLayer = CIGUSolidLayerDeflection(*getSolidLayers()[i]); - denominator += aDefLayer.flexuralRigidity(); - } - return denominator; + auto aDefLayer = CIGUSolidLayerDeflection(*getSolidLayers()[i]); + denominator += aDefLayer.flexuralRigidity(); } + return denominator; + } - std::vector - CIGU::calculateLDefMax(const std::vector & t_MeasuredDeflections) const - { - auto nominator = calculateDeflectionNumerator(t_MeasuredDeflections); - auto denominator = calculateDeflectionDenominator(); + std::vector + CIGU::calculateLDefMax(const std::vector & t_MeasuredDeflections) const + { + auto nominator = calculateDeflectionNumerator(t_MeasuredDeflections); + auto denominator = calculateDeflectionDenominator(); - auto LDefNMax = nominator / denominator; + auto LDefNMax = nominator / denominator; - std::vector LDefMax; - LDefMax.push_back(LDefNMax); - for(auto i = getNumOfLayers() - 1; i > 0; --i) - { - LDefNMax = - t_MeasuredDeflections[i - 1] - getGapLayers()[i - 1]->getThickness() + LDefNMax; - LDefMax.insert(LDefMax.begin(), LDefNMax); - } - return LDefMax; + std::vector LDefMax; + LDefMax.push_back(LDefNMax); + for(auto i = getNumOfLayers() - 1; i > 0; --i) + { + LDefNMax = + t_MeasuredDeflections[i - 1] - getGapLayers()[i - 1]->getThickness() + LDefNMax; + LDefMax.insert(LDefMax.begin(), LDefNMax); } + return LDefMax; + } - void CIGU::resetSurfaceDeflections() + void CIGU::resetSurfaceDeflections() + { + for(auto const & aLayer : m_Layers) { - for(auto const & aLayer : m_Layers) + if(std::dynamic_pointer_cast(aLayer) != nullptr) { - if(std::dynamic_pointer_cast(aLayer) != nullptr) - { - std::dynamic_pointer_cast(aLayer)->applyDeflection(0, 0); - } + std::dynamic_pointer_cast(aLayer)->applyDeflection(0, 0); } } + } - } // namespace ISO15099 - -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGU.hpp b/src/Tarcog/src/IGU.hpp index 8eaad6b0..3b7c321d 100644 --- a/src/Tarcog/src/IGU.hpp +++ b/src/Tarcog/src/IGU.hpp @@ -5,125 +5,119 @@ #include "DeflectionFromCurves.hpp" -namespace Tarcog -{ - namespace ISO15099 - { - enum class Environment; - class CBaseIGULayer; - class CIGUSolidLayer; - class CIGUGapLayer; - class CBaseLayer; - class CSurface; +namespace Tarcog::ISO15099 +{ + enum class Environment; + class CIGUSolidLayer; + class CIGUGapLayer; + class CBaseLayer; - class CIGU - { - public: - CIGU(double t_Width = 1, double t_Height = 1, double t_Tilt = 90); - CIGU(CIGU const & t_IGU); - CIGU & operator=(CIGU const & t_IGU); - ~CIGU(); - void addLayer(const std::shared_ptr & t_Layer); - void addLayers(const std::initializer_list> & layers); + class CIGU + { + public: + CIGU(double t_Width = 1, double t_Height = 1, double t_Tilt = 90); + CIGU(CIGU const & t_IGU); + CIGU & operator=(CIGU const & t_IGU); + ~CIGU(); - void setAbsorptances(const std::vector & absorptances, double solarRadiation); + void addLayer(const std::shared_ptr & t_Layer); + void addLayers(const std::initializer_list> & layers); - [[nodiscard]] std::vector> getSolidLayers() const; - [[nodiscard]] std::vector> getGapLayers() const; - [[nodiscard]] std::vector> getLayers() const; + void setAbsorptances(const std::vector & absorptances, double solarRadiation); - void setTilt(double t_Tilt); - void setWidth(double t_Width); - void setHeight(double t_Height); + [[nodiscard]] std::vector> getSolidLayers() const; + [[nodiscard]] std::vector> getGapLayers() const; + [[nodiscard]] std::vector> getLayers() const; - void setSolarRadiation(double t_SolarRadiation) const; + void setTilt(double t_Tilt); + void setWidth(double t_Width); + void setHeight(double t_Height); - [[nodiscard]] std::shared_ptr - getEnvironment(Environment t_Environment) const; + void setSolarRadiation(double t_SolarRadiation) const; - [[nodiscard]] std::vector getState() const; - void setState(const std::vector & t_State) const; + [[nodiscard]] std::shared_ptr getEnvironment(Environment t_Environment) const; - [[nodiscard]] std::vector getTemperatures() const; - [[nodiscard]] std::vector getRadiosities() const; + [[nodiscard]] std::vector getState() const; + void setState(const std::vector & t_State) const; - [[nodiscard]] std::vector getMaxLayerDeflections() const; - [[nodiscard]] std::vector getMeanLayerDeflections() const; - [[nodiscard]] std::vector getMaxGapWidth() const; - [[nodiscard]] std::vector getMeanGapWidth() const; + [[nodiscard]] std::vector getTemperatures() const; + [[nodiscard]] std::vector getRadiosities() const; - [[nodiscard]] std::vector getGapPressures() const; + [[nodiscard]] std::vector getMaxLayerDeflections() const; + [[nodiscard]] std::vector getMeanLayerDeflections() const; + [[nodiscard]] std::vector getMaxGapWidth() const; + [[nodiscard]] std::vector getMeanGapWidth() const; - //! Function to return pressure difference on each of the layers when using deflection - //! model - [[nodiscard]] std::vector getPanesLoad(); + [[nodiscard]] std::vector getGapPressures() const; - [[nodiscard]] double getTilt() const; - [[nodiscard]] double getWidth() const; - [[nodiscard]] double getHeight() const; - [[nodiscard]] double getThickness() const; + //! Function to return pressure difference on each of the layers when using deflection + //! model + [[nodiscard]] std::vector getPanesLoad(); - [[nodiscard]] size_t getNumOfLayers() const; + [[nodiscard]] double getTilt() const; + [[nodiscard]] double getWidth() const; + [[nodiscard]] double getHeight() const; + [[nodiscard]] double getThickness() const; - [[nodiscard]] double getVentilationFlow(Environment t_Environment) const; + [[nodiscard]] size_t getNumOfLayers() const; - void setInitialGuess(const std::vector & t_Guess) const; + [[nodiscard]] double getVentilationFlow(Environment t_Environment) const; - void setDeflectionProperties(double t_Tini, - double t_Pini, - double t_InsidePressure = 101325, - double t_OutsidePressure = 101325); + void setInitialGuess(const std::vector & t_Guess) const; - void setDeflectionProperties(const std::vector & t_MeasuredDeflections); + void setDeflectionProperties(double t_Tini, + double t_Pini, + double t_InsidePressure = 101325, + double t_OutsidePressure = 101325); - void setAppliedLoad(std::vector t_AppliedLoad); + void setDeflectionProperties(const std::vector & t_MeasuredDeflections); - void clearDeflection(); + void setAppliedLoad(std::vector t_AppliedLoad); - //! Function that will update layers deflection states based on new temperature data - void updateDeflectionState(); + void clearDeflection(); - void precalculateLayerStates(); + //! Function that will update layers deflection states based on new temperature data + void updateDeflectionState(); - private: - // Replaces layer in existing construction and keeps correct connections in linked list - void replaceLayer(const std::shared_ptr & t_Original, - const std::shared_ptr & t_Replacement); + void precalculateLayerStates(); - // Check if layer needs to be decorated with another object - void checkForLayerUpgrades(const std::shared_ptr & t_Layer); + private: + // Replaces layer in existing construction and keeps correct connections in linked list + void replaceLayer(const std::shared_ptr & t_Original, + const std::shared_ptr & t_Replacement); - [[nodiscard]] double - calculateDeflectionNumerator(const std::vector & t_MeasuredDeflections) const; - [[nodiscard]] double calculateDeflectionDenominator() const; - [[nodiscard]] std::vector - calculateLDefMax(const std::vector & t_MeasuredDeflections) const; + // Check if layer needs to be decorated with another object + void checkForLayerUpgrades(const std::shared_ptr & t_Layer); - std::vector> m_Layers; + [[nodiscard]] double + calculateDeflectionNumerator(const std::vector & t_MeasuredDeflections) const; + [[nodiscard]] double calculateDeflectionDenominator() const; + [[nodiscard]] std::vector + calculateLDefMax(const std::vector & t_MeasuredDeflections) const; - double m_Width; // meters - double m_Height; // meters - double m_Tilt; // degrees + std::vector> m_Layers; - // Reset deflection state of all surfaces back to zero. - void resetSurfaceDeflections(); + double m_Width; // meters + double m_Height; // meters + double m_Tilt; // degrees - // Routines to calculate deflection coefficients - [[nodiscard]] double Ldmean() const; - [[nodiscard]] double Ldmax() const; + // Reset deflection state of all surfaces back to zero. + void resetSurfaceDeflections(); - //! This is by default set to nullptr since deflection is not turn on by default. - //! Setting deflection properties will enable deflection calculations automatically. - std::optional m_DeflectionFromE1300Curves{std::nullopt}; + // Routines to calculate deflection coefficients + [[nodiscard]] double Ldmean() const; + [[nodiscard]] double Ldmax() const; - //! It is possible that user can set applied load before setting initial parameters for - //! the deflection in which case applied load will not be set automatically. This is - //! intermediate variable that keeps applied load so it can be applied later. - std::vector m_DeflectionAppliedLoad; - }; + //! This is by default set to nullptr since deflection is not turn on by default. + //! Setting deflection properties will enable deflection calculations automatically. + std::optional m_DeflectionFromE1300Curves{std::nullopt}; - } // namespace ISO15099 + //! It is possible that user can set applied load before setting initial parameters for + //! the deflection in which case applied load will not be set automatically. This is + //! intermediate variable that keeps applied load so it can be applied later. + std::vector m_DeflectionAppliedLoad; + }; -} // namespace Tarcog \ No newline at end of file +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUConfigurations.hpp b/src/Tarcog/src/IGUConfigurations.hpp index 0db450c4..e0f5259b 100644 --- a/src/Tarcog/src/IGUConfigurations.hpp +++ b/src/Tarcog/src/IGUConfigurations.hpp @@ -2,27 +2,25 @@ #include "EnvironmentConfigurations.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + enum class System { - enum class System - { - Uvalue, - SHGC - }; + Uvalue, + SHGC + }; - class IIGUSystem - { - public: - virtual double getUValue() = 0; - virtual double getSHGC(double t_TotSol) = 0; - virtual double getH(System system, Environment environment) const = 0; - virtual void setWidth(double width) = 0; - virtual void setHeight(double height) = 0; - virtual void setTilt(double tilt) = 0; - virtual void setWidthAndHeight(double width, double height) = 0; - virtual void setInteriorAndExteriorSurfacesHeight(double height) = 0; - }; - } // namespace ISO15099 -} // namespace Tarcog + class IIGUSystem + { + public: + virtual double getUValue() = 0; + virtual double getSHGC(double t_TotSol) = 0; + virtual double getH(System system, Environment environment) const = 0; + virtual void setWidth(double width) = 0; + virtual void setHeight(double height) = 0; + virtual void setTilt(double tilt) = 0; + virtual void setWidthAndHeight(double width, double height) = 0; + virtual void setInteriorAndExteriorSurfacesHeight(double height) = 0; + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUEN673.cpp b/src/Tarcog/src/IGUEN673.cpp index 2ac000f5..145e26a1 100644 --- a/src/Tarcog/src/IGUEN673.cpp +++ b/src/Tarcog/src/IGUEN673.cpp @@ -1,271 +1,254 @@ #include #include +#include + #include "IGUEN673.hpp" -#include "WCECommon.hpp" -namespace Tarcog + +namespace Tarcog::EN673 { - namespace EN673 + Glass::Glass(const double Conductivity, + const double Thickness, + const double emissFront, + const double emissBack, + const double aSol) : + Thickness(Thickness), + Conductivity(Conductivity), + EmissFront(emissFront), + EmissBack(emissBack), + SolarAbsorptance(aSol) + {} + + Gap::Gap(const double Thickness, const double Pressure, const Gases::CGas & tGas) : + Thickness(Thickness), Pressure(Pressure), Gas(tGas) + {} + + IGU::BaseLayer::BaseLayer(const double thickness, const double t1, const double t2) : + m_Thickness(thickness), T1(t1), T2(t2), EmissivityFront(0.84), EmissivityBack(0.84) + {} + + double IGU::BaseLayer::getEmissivityFront() const { - Glass::Glass(const double Conductivity, - const double Thickness, - const double emissFront, - const double emissBack, - const double aSol) : - Thickness(Thickness), - Conductivity(Conductivity), - EmissFront(emissFront), - EmissBack(emissBack), - SolarAbsorptance(aSol) - {} - - Gap::Gap(const double Thickness, const double Pressure, const Gases::CGas & tGas) : - Thickness(Thickness), - Pressure(Pressure), - Gas(tGas) - {} - - IGU::BaseLayer::BaseLayer(const double thickness, const double t1, const double t2) : - m_Thickness(thickness), - T1(t1), - T2(t2), - EmissivityFront(0.84), - EmissivityBack(0.84) - {} - - double IGU::BaseLayer::getEmissivityFront() const - { - return EmissivityFront; - } + return EmissivityFront; + } - void IGU::BaseLayer::setEmissivityFront(double tEmissivityFront) - { - EmissivityFront = tEmissivityFront; - } + void IGU::BaseLayer::setEmissivityFront(double tEmissivityFront) + { + EmissivityFront = tEmissivityFront; + } - double IGU::BaseLayer::getEmissivityBack() const - { - return EmissivityBack; - } + double IGU::BaseLayer::getEmissivityBack() const + { + return EmissivityBack; + } - void IGU::BaseLayer::setEmissivityBack(double tEmissivityBack) - { - EmissivityBack = tEmissivityBack; - } + void IGU::BaseLayer::setEmissivityBack(double tEmissivityBack) + { + EmissivityBack = tEmissivityBack; + } - void IGU::BaseLayer::updateTemperatures(double t1, double t2) - { - T1 = t1; - T2 = t2; - } + void IGU::BaseLayer::updateTemperatures(double t1, double t2) + { + T1 = t1; + T2 = t2; + } - IGU::GapLayer::GapLayer(const Gap & gap, double & t1, double & t2) : - BaseLayer(gap.Thickness, t1, t2), - pressure(gap.Pressure), - m_Gas(gap.Gas) - {} + IGU::GapLayer::GapLayer(const Gap & gap, double & t1, double & t2) : + BaseLayer(gap.Thickness, t1, t2), pressure(gap.Pressure), m_Gas(gap.Gas) + {} - double IGU::GapLayer::thermalConductance() - { - using ConstantsData::STEFANBOLTZMANN; + double IGU::GapLayer::thermalConductance() + { + using ConstantsData::STEFANBOLTZMANN; - const double Tm = (T1 + T2) / 2.0; + const double Tm = (T1 + T2) / 2.0; - m_Gas.setTemperatureAndPressure(Tm, pressure); - const auto prop = m_Gas.getGasProperties(); - const auto convection = prop.m_ThermalConductivity / m_Thickness; - const auto radiation = 4 * STEFANBOLTZMANN * 1 - / (1 / EmissivityFront + 1 / EmissivityBack - 1) - * std::pow(Tm, 3); - return convection + radiation; - } + m_Gas.setTemperatureAndPressure(Tm, pressure); + const auto prop = m_Gas.getGasProperties(); + const auto convection = prop.m_ThermalConductivity / m_Thickness; + const auto radiation = 4 * STEFANBOLTZMANN * 1 + / (1 / EmissivityFront + 1 / EmissivityBack - 1) * std::pow(Tm, 3); + return convection + radiation; + } - IGU::SolidLayer::SolidLayer(const Glass & glass, double & t1, double & t2) : - BaseLayer(glass.Thickness, t1, t2), - m_Conductivity(glass.Conductivity) - {} + IGU::SolidLayer::SolidLayer(const Glass & glass, double & t1, double & t2) : + BaseLayer(glass.Thickness, t1, t2), m_Conductivity(glass.Conductivity) + {} - double IGU::SolidLayer::thermalConductance() - { - return m_Conductivity / m_Thickness; - } + double IGU::SolidLayer::thermalConductance() + { + return m_Conductivity / m_Thickness; + } - Environment::Environment(double Temperature, double filmCoefficient) : - Temperature(Temperature), - filmCoefficient(filmCoefficient) - {} + Environment::Environment(double Temperature, double filmCoefficient) : + Temperature(Temperature), filmCoefficient(filmCoefficient) + {} + + IGU::IGU(const Environment & interior, const Environment & exterior) : + interior(interior), exterior(exterior), numOfSolidLayers(0) + { + // temperature.push_back(exterior.Temperature + 3); + // temperature.push_back(exterior.Temperature + 6); + // layers.emplace_back(new SolidLayer(glass, temperature[0], temperature[1])); + } - IGU::IGU(const Environment & interior, const Environment & exterior) : - interior(interior), - exterior(exterior), - numOfSolidLayers(0) + void IGU::addGlass(const Glass & glass) + { + if(temperature.size() > 0) { - // temperature.push_back(exterior.Temperature + 3); - // temperature.push_back(exterior.Temperature + 6); - // layers.emplace_back(new SolidLayer(glass, temperature[0], temperature[1])); + temperature.push_back(temperature[temperature.size() - 1] + 3); } - - void IGU::addGlass(const Glass & glass) + else { - if(temperature.size() > 0) - { - temperature.push_back(temperature[temperature.size() - 1] + 3); - } - else - { - temperature.push_back(3); - temperature.push_back(exterior.Temperature + 6); - layers.emplace_back(new SolidLayer(glass, temperature[0], temperature[1])); - } - - abs.push_back(glass.SolarAbsorptance); - ++numOfSolidLayers; - - if(layers.size() > 1) - { - auto gap = layers[layers.size() - 1].get(); - if(dynamic_cast(gap)) - { - gap->setEmissivityBack(glass.EmissFront); - layers.emplace_back(new SolidLayer(glass, - temperature[temperature.size() - 2], - temperature[temperature.size() - 1])); - } - else - { - throw std::runtime_error("Cannot put two consecutive glass layers to IGU."); - } - } + temperature.push_back(3); + temperature.push_back(exterior.Temperature + 6); + layers.emplace_back(new SolidLayer(glass, temperature[0], temperature[1])); } - void IGU::addGap(const Gap & gap) + abs.push_back(glass.SolarAbsorptance); + ++numOfSolidLayers; + + if(layers.size() > 1) { - temperature.push_back(temperature[temperature.size() - 1] + 3); - auto solid = layers[layers.size() - 1].get(); - if(dynamic_cast(solid)) + auto gap = layers[layers.size() - 1].get(); + if(dynamic_cast(gap)) { - layers.emplace_back(new GapLayer( - gap, temperature[temperature.size() - 2], temperature[temperature.size() - 1])); - layers[layers.size() - 1]->setEmissivityFront(solid->getEmissivityBack()); + gap->setEmissivityBack(glass.EmissFront); + layers.emplace_back(new SolidLayer( + glass, temperature[temperature.size() - 2], temperature[temperature.size() - 1])); } else { - throw std::runtime_error("Cannot put two consecutive gap layers to IGU."); + throw std::runtime_error("Cannot put two consecutive glass layers to IGU."); } } + } - double IGU::Uvalue() + void IGU::addGap(const Gap & gap) + { + temperature.push_back(temperature[temperature.size() - 1] + 3); + auto solid = layers[layers.size() - 1].get(); + if(dynamic_cast(solid)) { - double condSum = conductanceSums(); - double condSumNew = 0; - double ug = 0; - - while(std::abs(condSum - condSumNew) > 1e-4) - { - condSum = condSumNew; - double intExt = 1 / exterior.filmCoefficient + 1 / interior.filmCoefficient; - auto accumulateFunc = [](double accumulator, - const std::unique_ptr & layer) { - return accumulator + 1 / layer->thermalConductance(); - }; - - ug = 1 / std::accumulate(layers.begin(), layers.end(), intExt, accumulateFunc); - calculateNewTemperatures(ug * (interior.Temperature - exterior.Temperature)); - updateThermalResistances(); - condSumNew = conductanceSums(); - } - - return ug; + layers.emplace_back(new GapLayer( + gap, temperature[temperature.size() - 2], temperature[temperature.size() - 1])); + layers[layers.size() - 1]->setEmissivityFront(solid->getEmissivityBack()); + } + else + { + throw std::runtime_error("Cannot put two consecutive gap layers to IGU."); } + } + + double IGU::Uvalue() + { + double condSum = conductanceSums(); + double condSumNew = 0; + double ug = 0; - double IGU::conductanceSums() const + while(std::abs(condSum - condSumNew) > 1e-4) { + condSum = condSumNew; + double intExt = 1 / exterior.filmCoefficient + 1 / interior.filmCoefficient; auto accumulateFunc = [](double accumulator, const std::unique_ptr & layer) { - return accumulator + layer->thermalConductance(); + return accumulator + 1 / layer->thermalConductance(); }; - return std::accumulate(layers.begin(), layers.end(), 0.0, accumulateFunc); - } - void IGU::calculateNewTemperatures(double scaleFactor) - { - temperature[0] = scaleFactor / exterior.filmCoefficient + exterior.Temperature; - temperature[temperature.size() - 1] = - interior.Temperature - scaleFactor / interior.filmCoefficient; - for(size_t i = 0u; i < layers.size() - 1; ++i) - { - temperature[i + 1] = scaleFactor / layers[i]->thermalConductance() + temperature[i]; - } - updateLayerTemperatures(); + ug = 1 / std::accumulate(layers.begin(), layers.end(), intExt, accumulateFunc); + calculateNewTemperatures(ug * (interior.Temperature - exterior.Temperature)); + updateThermalResistances(); + condSumNew = conductanceSums(); } - void IGU::updateThermalResistances() + return ug; + } + + double IGU::conductanceSums() const + { + auto accumulateFunc = [](double accumulator, const std::unique_ptr & layer) { + return accumulator + layer->thermalConductance(); + }; + return std::accumulate(layers.begin(), layers.end(), 0.0, accumulateFunc); + } + + void IGU::calculateNewTemperatures(double scaleFactor) + { + temperature[0] = scaleFactor / exterior.filmCoefficient + exterior.Temperature; + temperature[temperature.size() - 1] = + interior.Temperature - scaleFactor / interior.filmCoefficient; + for(size_t i = 0u; i < layers.size() - 1; ++i) { - thermalResistance.clear(); - thermalResistance.push_back(1 / exterior.filmCoefficient); - for(auto & layer : layers) - { - thermalResistance.push_back(1 / layer->thermalConductance()); - } - thermalResistance.push_back(1 / interior.filmCoefficient); + temperature[i + 1] = scaleFactor / layers[i]->thermalConductance() + temperature[i]; } + updateLayerTemperatures(); + } - double IGU::shgc(const double totSol) + void IGU::updateThermalResistances() + { + thermalResistance.clear(); + thermalResistance.push_back(1 / exterior.filmCoefficient); + for(auto & layer : layers) { - std::vector lambdaCoeff(numOfSolidLayers - 1, 0); - double cNom{0}; - double cDen{0}; + thermalResistance.push_back(1 / layer->thermalConductance()); + } + thermalResistance.push_back(1 / interior.filmCoefficient); + } - double cAbs{0}; + double IGU::shgc(const double totSol) + { + std::vector lambdaCoeff(numOfSolidLayers - 1, 0); + double cNom{0}; + double cDen{0}; - // Need to set correct thermal resistances and for that Uvalue calculation is needed. - Uvalue(); + double cAbs{0}; - for(size_t i = numOfSolidLayers - 1; i-- > 0;) - { - auto j = 2u * (i + 1u); - double k1{0.5}; - double k2{0.5}; + // Need to set correct thermal resistances and for that Uvalue calculation is needed. + Uvalue(); - cAbs += abs[i]; - - if(i == 0) - { - k1 = 1; - } + for(size_t i = numOfSolidLayers - 1; i-- > 0;) + { + auto j = 2u * (i + 1u); + double k1{0.5}; + double k2{0.5}; - if(i == (numOfSolidLayers - 2)) - { - k2 = 1; - } + cAbs += abs[i]; - lambdaCoeff[i] = 1 - / (k1 * thermalResistance[j - 1] + thermalResistance[j] - + k2 * thermalResistance[j + 1]); + if(i == 0) + { + k1 = 1; + } - cNom += cAbs / lambdaCoeff[i]; - cDen += 1 / lambdaCoeff[i]; + if(i == (numOfSolidLayers - 2)) + { + k2 = 1; } - cAbs += abs[0]; - double flowin = - (cAbs * thermalResistance[0] + cNom) - / (thermalResistance[0] + thermalResistance[2 * numOfSolidLayers] + cDen); + lambdaCoeff[i] = 1 + / (k1 * thermalResistance[j - 1] + thermalResistance[j] + + k2 * thermalResistance[j + 1]); - return flowin + totSol; + cNom += cAbs / lambdaCoeff[i]; + cDen += 1 / lambdaCoeff[i]; } - void IGU::updateLayerTemperatures() - { - for(size_t i = 0u; i < layers.size(); ++i) - { - layers[i]->updateTemperatures(temperature[i], temperature[i + 1]); - } - } + cAbs += abs[0]; + double flowin = (cAbs * thermalResistance[0] + cNom) + / (thermalResistance[0] + thermalResistance[2 * numOfSolidLayers] + cDen); - std::unique_ptr IGU::create(const Environment & interior, const Environment & exterior) + return flowin + totSol; + } + + void IGU::updateLayerTemperatures() + { + for(size_t i = 0u; i < layers.size(); ++i) { - return std::unique_ptr(new IGU(interior, exterior)); + layers[i]->updateTemperatures(temperature[i], temperature[i + 1]); } - } // namespace EN673 -} // namespace Tarcog + } + + std::unique_ptr IGU::create(const Environment & interior, const Environment & exterior) + { + return std::unique_ptr(new IGU(interior, exterior)); + } +} // namespace Tarcog::EN673 diff --git a/src/Tarcog/src/IGUEN673.hpp b/src/Tarcog/src/IGUEN673.hpp index a5012934..0bd68d1f 100644 --- a/src/Tarcog/src/IGUEN673.hpp +++ b/src/Tarcog/src/IGUEN673.hpp @@ -5,117 +5,114 @@ #include "WCEGases.hpp" -namespace Tarcog + +namespace Tarcog::EN673 { - namespace EN673 + struct Glass { - struct Glass - { - Glass(double Conductivity, - double Thickness, - double emissFront, - double emissBack, - double Sol = 0.0); - double Thickness; - double Conductivity; - double EmissFront; - double EmissBack; - double SolarAbsorptance; - }; + Glass(double Conductivity, + double Thickness, + double emissFront, + double emissBack, + double Sol = 0.0); + double Thickness; + double Conductivity; + double EmissFront; + double EmissBack; + double SolarAbsorptance; + }; + + //! Structure to keep data for gap. + struct Gap + { + //! Construction of gap + Gap( + double Thickness, //!< Gap thickness + double Pressure = 101325, //!< Gap pressure (defaulted to 101325 Pa) + const Gases::CGas & tGas = Gases::CGas() //!< Gas content of the gap (defaulted to Air) + ); + double Thickness; + double Pressure; + Gases::CGas Gas; + }; + + struct Environment + { + Environment(double Temperature, double filmCoefficient); + double Temperature; + double filmCoefficient; + }; - //! Structure to keep data for gap. - struct Gap - { - //! Construction of gap - Gap(double Thickness, //!< Gap thickness - double Pressure = 101325, //!< Gap pressure (defaulted to 101325 Pa) - const Gases::CGas & tGas = - Gases::CGas() //!< Gas content of the gap (defaulted to Air) - ); - double Thickness; - double Pressure; - Gases::CGas Gas; - }; + //! \brief Class to handle IGU calculations. + class IGU + { + public: + static std::unique_ptr create(const Environment & interior, + const Environment & exterior); + + void addGlass(const Glass & glass); + void addGap(const Gap & gap); - struct Environment + double Uvalue(); + double shgc(double totSol); + + private: + IGU(const Environment & interior, const Environment & exterior); + + class BaseLayer { - Environment(double Temperature, double filmCoefficient); - double Temperature; - double filmCoefficient; + public: + virtual ~BaseLayer() = default; + explicit BaseLayer(double thickness, double T1, double T2); + + virtual double thermalConductance() = 0; + double getEmissivityFront() const; + void setEmissivityFront(double EmissivityFront); + double getEmissivityBack() const; + void setEmissivityBack(double EmissivityBack); + void updateTemperatures(double t1, double t2); + + protected: + double m_Thickness; + double T1; + double T2; + double EmissivityFront; + double EmissivityBack; }; - //! \brief Class to handle IGU calculations. - class IGU + class GapLayer : public BaseLayer { public: - static std::unique_ptr create(const Environment & interior, - const Environment & exterior); + GapLayer(const Gap & gap, double & t1, double & t2); - void addGlass(const Glass & glass); - void addGap(const Gap & gap); - - double Uvalue(); - double shgc(double totSol); + double thermalConductance() override; private: - IGU(const Environment & interior, const Environment & exterior); - - class BaseLayer - { - public: - virtual ~BaseLayer() = default; - explicit BaseLayer(double thickness, double T1, double T2); - - virtual double thermalConductance() = 0; - double getEmissivityFront() const; - void setEmissivityFront(double EmissivityFront); - double getEmissivityBack() const; - void setEmissivityBack(double EmissivityBack); - void updateTemperatures(double t1, double t2); - - protected: - double m_Thickness; - double T1; - double T2; - double EmissivityFront; - double EmissivityBack; - }; - - class GapLayer : public BaseLayer - { - public: - GapLayer(const Gap & gap, double & t1, double & t2); - - double thermalConductance() override; - - private: - double pressure; - Gases::CGas m_Gas; - }; - - class SolidLayer : public BaseLayer - { - public: - SolidLayer(const Glass & glass, double & t1, double & t2); - double thermalConductance() override; - - private: - double m_Conductivity; - }; - - double conductanceSums() const; - void calculateNewTemperatures(double scaleFactor); - void updateLayerTemperatures(); - void updateThermalResistances(); - std::vector> layers; - std::vector temperature; - std::vector thermalResistance; - std::vector abs; - Environment interior; - Environment exterior; - size_t numOfSolidLayers; + double pressure; + Gases::CGas m_Gas; }; - } // namespace EN673 + class SolidLayer : public BaseLayer + { + public: + SolidLayer(const Glass & glass, double & t1, double & t2); + double thermalConductance() override; + + private: + double m_Conductivity; + }; -} // namespace Tarcog + double conductanceSums() const; + void calculateNewTemperatures(double scaleFactor); + void updateLayerTemperatures(); + void updateThermalResistances(); + std::vector> layers; + std::vector temperature; + std::vector thermalResistance; + std::vector abs; + Environment interior; + Environment exterior; + size_t numOfSolidLayers; + }; + +} // namespace Tarcog::EN673 diff --git a/src/Tarcog/src/IGUGapLayer.cpp b/src/Tarcog/src/IGUGapLayer.cpp index 747a8e6a..b52f361f 100644 --- a/src/Tarcog/src/IGUGapLayer.cpp +++ b/src/Tarcog/src/IGUGapLayer.cpp @@ -1,175 +1,155 @@ #include #include -#include -#include + +#include +#include #include "BaseShade.hpp" #include "IGUGapLayer.hpp" #include "Surface.hpp" #include "NusseltNumber.hpp" -#include "WCEGases.hpp" -#include "WCECommon.hpp" using FenestrationCommon::Side; -namespace Tarcog -{ - namespace ISO15099 - { - CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure) : - CBaseIGULayer(t_Thickness), - 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) - {} +namespace Tarcog::ISO15099 +{ - void CIGUGapLayer::connectToBackSide(std::shared_ptr const & t_Layer) - { - CBaseLayer::connectToBackSide(t_Layer); - m_Surface[Side::Back] = t_Layer->getSurface(Side::Front); - } + bool isStillAir(double airSpeed) + { + return FenestrationCommon::isEqual(airSpeed, 0); + } - void CIGUGapLayer::initializeStateVariables() - { - CGasLayer::initializeStateVariables(); - } + CIGUGapLayer::CIGUGapLayer(double const t_Thickness, double const t_Pressure) : + CBaseLayer(t_Thickness) + { + gasSpecification.pressure = t_Pressure; + } - void CIGUGapLayer::calculateConvectionOrConductionFlow() - { - checkNextLayer(); - if(!isCalculated()) - { - if(FenestrationCommon::isEqual(getThickness(), 0)) - { - throw std::runtime_error("Layer thickness is set to zero."); - } + CIGUGapLayer::CIGUGapLayer(double const t_Thickness, + double const t_Pressure, + const Gases::CGas & t_Gas) : + CBaseLayer(t_Thickness) + { + gasSpecification.pressure = t_Pressure; + gasSpecification.gas = t_Gas; + } - convectiveH(); - } - } + void CIGUGapLayer::connectToBackSide(std::shared_ptr const & t_Layer) + { + CBaseLayer::connectToBackSide(t_Layer); + m_Surface[Side::Back] = t_Layer->getSurface(Side::Front); + } - void CIGUGapLayer::checkNextLayer() const + void CIGUGapLayer::calculateConvectionOrConductionFlow() + { + if(!isCalculated()) { - if(m_NextLayer != nullptr) + if(FenestrationCommon::isEqual(getThickness(), 0)) { - m_NextLayer->getGainFlow(); + throw std::runtime_error("Layer thickness is set to zero."); } - } - double CIGUGapLayer::layerTemperature() - { - return averageTemperature(); + m_ConductiveConvectiveCoeff = convectiveH(); } + } - double CIGUGapLayer::calculateRayleighNumber() + double CIGUGapLayer::calculateRayleighNumber() + { + if(!FenestrationCommon::isVacuum(gasSpecification.pressure)) { using ConstantsData::GRAVITYCONSTANT; + const auto aProperties = gasSpecification.gas.getGasProperties(); + const auto deltaTemp = + std::abs(surfaceTemperature(Side::Back) - surfaceTemperature(Side::Front)); + + return GRAVITYCONSTANT * pow(getThickness(), 3) * deltaTemp * aProperties.m_SpecificHeat + * pow(aProperties.m_Density, 2) + / (averageLayerTemperature() * aProperties.m_Viscosity + * aProperties.m_ThermalConductivity); + } - const auto tGapTemperature = layerTemperature(); - const auto deltaTemp = std::abs(getSurface(Side::Back)->getTemperature() - - getSurface(Side::Front)->getTemperature()); - - const auto aProperties = m_Gas.getGasProperties(); - - double ra = 0; - if(!FenestrationCommon::isEqual(aProperties.m_Viscosity, 0)) - { // if viscosity is zero then it is vacuum - ra = - GRAVITYCONSTANT * pow(getThickness(), 3) * deltaTemp * aProperties.m_SpecificHeat - * pow(aProperties.m_Density, 2) - / (tGapTemperature * aProperties.m_Viscosity * aProperties.m_ThermalConductivity); - } + return 0; + } - return ra; + double CIGUGapLayer::aspectRatio() const + { + if(FenestrationCommon::isEqual(getThickness(), 0)) + { + throw std::runtime_error("Gap thickness is set to zero."); } + return m_Height / getThickness(); + } - double CIGUGapLayer::aspectRatio() const + double CIGUGapLayer::getPressure() + { + if(m_SealedGapProperties.has_value()) { - if(FenestrationCommon::isEqual(getThickness(), 0)) - { - throw std::runtime_error("Gap thickness is set to zero."); - } - return m_Height / getThickness(); + auto Vini = getSurfaceArea() * m_Thickness; + auto modThickness = getThickness(); + auto Vgap = getSurfaceArea() * modThickness; + return m_SealedGapProperties->pressure * Vini * averageLayerTemperature() + / (m_SealedGapProperties->temperature * Vgap); } + return gasSpecification.pressure; + } - double CIGUGapLayer::convectiveH() - { - const auto tGapTemperature = layerTemperature(); - m_Gas.setTemperatureAndPressure(tGapTemperature, getPressure()); - const auto Ra = calculateRayleighNumber(); - const auto Asp = aspectRatio(); - CNusseltNumber nusseltNumber{}; - const auto aProperties = m_Gas.getGasProperties(); - if(!FenestrationCommon::isEqual(aProperties.m_Viscosity, 0)) - { - m_ConductiveConvectiveCoeff = nusseltNumber.calculate(m_Tilt, Ra, Asp) - * aProperties.m_ThermalConductivity / getThickness(); - } - else - { // vacuum state - m_ConductiveConvectiveCoeff = aProperties.m_ThermalConductivity; - } - if(!FenestrationCommon::isEqual(m_AirSpeed, 0)) - { - m_ConductiveConvectiveCoeff = m_ConductiveConvectiveCoeff + 2 * m_AirSpeed; - } + double CIGUGapLayer::getMaxDeflection() const + { + return m_Thickness + surfaceDeflectionMax(Side::Front) - surfaceDeflectionMax(Side::Back); + } - return m_ConductiveConvectiveCoeff; - } + double CIGUGapLayer::getMeanDeflection() const + { + return getThickness(); + } - double CIGUGapLayer::getGasTemperature() - { - return layerTemperature(); - } + std::shared_ptr CIGUGapLayer::clone() const + { + return std::make_shared(*this); + } - double CIGUGapLayer::averageTemperature() const - { - double aveTemp = Gases::DefaultTemperature; - if(areSurfacesInitalized()) - { - aveTemp = (getSurface(Side::Front)->getTemperature() - + getSurface(Side::Back)->getTemperature()) - / 2; - } + void CIGUGapLayer::setSealedGapProperties(double t_Temperature, double t_Pressure) + { + m_SealedGapProperties = SealedGapProperties(t_Temperature, t_Pressure); + } - return aveTemp; - } + void CIGUGapLayer::updateGasSpecifications() + { + gasSpecification.pressure = getPressure(); + gasSpecification.setTemperature(averageLayerTemperature()); + } - double CIGUGapLayer::getPressure() + double CIGUGapLayer::calculateConvectiveConductiveCoefficient() + { + auto gasProperties = gasSpecification.gas.getGasProperties(); + if(!FenestrationCommon::isVacuum(gasSpecification.pressure)) { - if(m_SealedGapProperties.has_value()) - { - auto Vini = m_Width * m_Height * m_Thickness; - auto modThickness = getThickness(); - auto Vgap = m_Width * m_Height * modThickness; - return m_SealedGapProperties->pressure * Vini * layerTemperature() - / (m_SealedGapProperties->temperature * Vgap); - } - return m_Pressure; + CNusseltNumber nusseltNumber{}; + return nusseltNumber.calculate(m_Tilt, calculateRayleighNumber(), aspectRatio()) + * gasProperties.m_ThermalConductivity / getThickness(); } + return gasProperties.m_ThermalConductivity; + } - double CIGUGapLayer::getMaxDeflection() const + double CIGUGapLayer::addAirflowEffect(const double convectiveCoefficient) + { + if(!isStillAir(gasSpecification.airflowProperties.m_AirSpeed)) { - return m_Thickness + getSurface(Side::Front)->getMaxDeflection() - - getSurface(Side::Back)->getMaxDeflection(); + return convectiveCoefficient + 2 * gasSpecification.airflowProperties.m_AirSpeed; } + return convectiveCoefficient; + } - double CIGUGapLayer::getMeanDeflection() const - { - return getThickness(); - } + double CIGUGapLayer::convectiveH() + { + updateGasSpecifications(); - std::shared_ptr CIGUGapLayer::clone() const - { - return std::make_shared(*this); - } + auto coeff{calculateConvectiveConductiveCoefficient()}; + coeff = addAirflowEffect(coeff); - } // namespace ISO15099 + return coeff; + } -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUGapLayer.hpp b/src/Tarcog/src/IGUGapLayer.hpp index 45e0d09c..75510829 100644 --- a/src/Tarcog/src/IGUGapLayer.hpp +++ b/src/Tarcog/src/IGUGapLayer.hpp @@ -1,14 +1,12 @@ -#ifndef TARIGUGAPLAYER_H -#define TARIGUGAPLAYER_H +#pragma once #include -#include "BaseIGULayer.hpp" -#include "WCEGases.hpp" -namespace Gases -{ - class CGas; -} +#include + +#include "BaseLayer.hpp" +#include "DeflectionInterface.hpp" +#include "GasSpecification.hpp" namespace Tarcog { @@ -16,7 +14,20 @@ namespace Tarcog namespace ISO15099 { - class CIGUGapLayer : public CBaseIGULayer, public CGasLayer + // Properties of the gap at time of production + struct SealedGapProperties + { + SealedGapProperties(double t_Temperature, double t_Pressure) : + temperature(t_Temperature), pressure(t_Pressure) + {} + + double temperature; + double pressure; + }; + + [[nodiscard]] bool isStillAir(double airSpeed); + + class CIGUGapLayer : public CBaseLayer, public Tarcog::Deflectable { public: CIGUGapLayer(double t_Thickness, double t_Pressure); @@ -24,34 +35,34 @@ namespace Tarcog void connectToBackSide(const std::shared_ptr & t_Layer) override; - double layerTemperature() override; - - double averageTemperature() const; - - double getPressure() override; + double getPressure(); std::shared_ptr clone() const override; double getMaxDeflection() const override; double getMeanDeflection() const override; + void setSealedGapProperties(double t_Temperature, double t_Pressure); protected: - void initializeStateVariables() override; void calculateConvectionOrConductionFlow() override; + // Gap by default will not be considered to be sealed. If not sealed then + // pressure will be considered to be m_Pressure; + std::optional m_SealedGapProperties{std::nullopt}; + + GasSpecification gasSpecification; + private: double calculateRayleighNumber(); double aspectRatio() const; - double convectiveH(); - double getGasTemperature() override; - - void checkNextLayer() const; + void updateGasSpecifications(); + [[nodiscard]] double calculateConvectiveConductiveCoefficient(); + [[nodiscard]] double addAirflowEffect(double convectiveCoefficient); + double convectiveH(); }; } // namespace ISO15099 -} // namespace Tarcog - -#endif +} // namespace Tarcog \ No newline at end of file diff --git a/src/Tarcog/src/IGUSolidDeflection.cpp b/src/Tarcog/src/IGUSolidDeflection.cpp index 8bdea4ab..039fd0ab 100644 --- a/src/Tarcog/src/IGUSolidDeflection.cpp +++ b/src/Tarcog/src/IGUSolidDeflection.cpp @@ -1,138 +1,68 @@ - #include #include "IGUSolidDeflection.hpp" -#include "WCECommon.hpp" #include "Surface.hpp" #include "TarcogConstants.hpp" using FenestrationCommon::Side; -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 - { - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// CIGUSolidLayerDeflection - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CIGUSolidLayerDeflection::CIGUSolidLayerDeflection(CIGUSolidLayer const & t_SolidLayer) : - CIGUSolidLayer(t_SolidLayer), - m_YoungsModulus(DeflectionConstants::YOUNGSMODULUS), - m_PoisonRatio(DeflectionConstants::POISONRATIO), - m_Density(MaterialConstants::GLASSDENSITY) - {} - - CIGUSolidLayerDeflection::CIGUSolidLayerDeflection(CIGUSolidLayer const & t_SolidLayer, - double const t_YoungsModulus, - double const t_PoisonRatio, - double const t_Density) : - CIGUSolidLayer(t_SolidLayer), - m_YoungsModulus(t_YoungsModulus), - m_PoisonRatio(t_PoisonRatio), - m_Density(t_Density) - {} - - void CIGUSolidLayerDeflection::calculateConvectionOrConductionFlow() - { - CIGUSolidLayer::calculateConvectionOrConductionFlow(); - } - - double CIGUSolidLayerDeflection::flexuralRigidity() const - { - return m_YoungsModulus * pow(m_Thickness, 3) / (12 * (1 - pow(m_PoisonRatio, 2))); - } - - std::shared_ptr CIGUSolidLayerDeflection::clone() const - { - return std::make_shared(*this); - } - - double CIGUSolidLayerDeflection::youngsModulus() const - { - return m_YoungsModulus; - } - - double CIGUSolidLayerDeflection::pressureDifference() const - { - auto P1 = std::dynamic_pointer_cast(m_NextLayer)->getPressure(); - auto P2 = std::dynamic_pointer_cast(m_PreviousLayer)->getPressure(); - return P1 - P2; - } - - bool CIGUSolidLayerDeflection::isDeflected() const - { - return true; - } - double CIGUSolidLayerDeflection::density() const - { - return m_Density; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - //// CIGUDeflectionTempAndPressure - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - - CIGUDeflectionTempAndPressure::CIGUDeflectionTempAndPressure( - std::shared_ptr const & t_SolidLayer, - double const t_MaxDeflectionCoeff, - double const t_MeanDeflectionCoeff) : - CIGUSolidLayerDeflection(*t_SolidLayer), - m_MaxCoeff(t_MaxDeflectionCoeff), - m_MeanCoeff(t_MeanDeflectionCoeff) - {} - - void CIGUDeflectionTempAndPressure::calculateConvectionOrConductionFlow() - { - CIGUSolidLayerDeflection::calculateConvectionOrConductionFlow(); - // Relaxation parameter is low because that will make possible solution to converge. - // Instability in rest of equation is great if using higher relaxation parameter and - // it probaby does not matter what solver is used. - auto const RelaxationParamter = 0.005; - - auto Dp = pressureDifference(); - auto D = flexuralRigidity(); - auto Ld = m_Surface[Side::Front]->getMeanDeflection(); - Ld += LdMean(Dp, D) * RelaxationParamter; - auto Ldmax = m_Surface[Side::Front]->getMaxDeflection(); - Ldmax += LdMax(Dp, D) * RelaxationParamter; - for(auto aSide : FenestrationCommon::EnumSide()) - { - m_Surface[aSide]->applyDeflection(Ld, Ldmax); - } - } - - double CIGUDeflectionTempAndPressure::LdMean(double const t_P, double const t_D) const - { - return m_MeanCoeff * t_P / t_D; - } + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// CIGUSolidLayerDeflection + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + + CIGUSolidLayerDeflection::CIGUSolidLayerDeflection(CIGUSolidLayer const & t_SolidLayer) : + CIGUSolidLayer(t_SolidLayer), + m_YoungsModulus(DeflectionConstants::YOUNGSMODULUS), + m_PoisonRatio(DeflectionConstants::POISONRATIO), + m_Density(MaterialConstants::GLASSDENSITY) + {} + + CIGUSolidLayerDeflection::CIGUSolidLayerDeflection(CIGUSolidLayer const & t_SolidLayer, + double const t_YoungsModulus, + double const t_PoisonRatio, + double const t_Density) : + CIGUSolidLayer(t_SolidLayer), + m_YoungsModulus(t_YoungsModulus), + m_PoisonRatio(t_PoisonRatio), + m_Density(t_Density) + {} + + double CIGUSolidLayerDeflection::flexuralRigidity() const + { + return m_YoungsModulus * pow(m_Thickness, 3) / (12 * (1 - pow(m_PoisonRatio, 2))); + } - double CIGUDeflectionTempAndPressure::LdMax(double const t_P, double const t_D) const - { - return m_MaxCoeff * t_P / t_D; - } + std::shared_ptr CIGUSolidLayerDeflection::clone() const + { + return std::make_shared(*this); + } - std::shared_ptr CIGUDeflectionTempAndPressure::clone() const - { - return std::make_shared(*this); - } + double CIGUSolidLayerDeflection::youngsModulus() const + { + return m_YoungsModulus; + } - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// CIGUDeflectionTempAndPressure - //////////////////////////////////////////////////////////////////////////////////////////////////////////// - CIGUDeflectionMeasuread::CIGUDeflectionMeasuread( - std::shared_ptr & t_Layer, - const double t_MeanDeflection, - const double t_MaxDeflection) : - CIGUSolidLayerDeflection(*t_Layer) + double CIGUSolidLayerDeflection::density() const + { + return m_Density; + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// CIGUDeflectionMeasured + //////////////////////////////////////////////////////////////////////////////////////////////////////////// + CIGUDeflectionMeasured::CIGUDeflectionMeasured( + std::shared_ptr & t_Layer, + const double t_MeanDeflection, + const double t_MaxDeflection) : + CIGUSolidLayerDeflection(*t_Layer) + { + for(Side aSide : FenestrationCommon::EnumSide()) { - for(Side aSide : FenestrationCommon::EnumSide()) - { - m_Surface[aSide]->applyDeflection(t_MeanDeflection, t_MaxDeflection); - } + m_Surface[aSide]->applyDeflection(t_MeanDeflection, t_MaxDeflection); } + } - } // namespace ISO15099 - -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUSolidDeflection.hpp b/src/Tarcog/src/IGUSolidDeflection.hpp index c56c1443..42b70472 100644 --- a/src/Tarcog/src/IGUSolidDeflection.hpp +++ b/src/Tarcog/src/IGUSolidDeflection.hpp @@ -1,79 +1,44 @@ -#ifndef TARIGUSOLIDLAYERDEFLECTION_H -#define TARIGUSOLIDLAYERDEFLECTION_H +#pragma once #include #include "IGUSolidLayer.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + //////////////////////////////////////////////////////////////////////////// + //// CIGUSolidLayerDeflection + //////////////////////////////////////////////////////////////////////////// + class CIGUSolidLayerDeflection : public CIGUSolidLayer { - //////////////////////////////////////////////////////////////////////////// - //// CIGUSolidLayerDeflection - //////////////////////////////////////////////////////////////////////////// - class CIGUSolidLayerDeflection : public CIGUSolidLayer - { - public: - explicit CIGUSolidLayerDeflection(const CIGUSolidLayer & t_SolidLayer); - CIGUSolidLayerDeflection(const CIGUSolidLayer & t_SolidLayer, - double t_YoungsModulus, - double t_PoisonRatio, - double t_Density); - - double flexuralRigidity() const; - bool isDeflected() const override; - - std::shared_ptr clone() const override; - - double youngsModulus() const override; - double density() const override; - - protected: - void calculateConvectionOrConductionFlow() override; - double pressureDifference() const; - - private: - double m_YoungsModulus; - double m_PoisonRatio; - double m_Density; - }; - - //////////////////////////////////////////////////////////////////////////// - //// CIGUDeflectionTempAndPressure - //////////////////////////////////////////////////////////////////////////// - class CIGUDeflectionTempAndPressure : public CIGUSolidLayerDeflection - { - public: - CIGUDeflectionTempAndPressure( - const std::shared_ptr & t_SolidLayer, - double t_MaxDeflectionCoeff, - double t_MeanDeflectionCoeff); - - std::shared_ptr clone() const override; - - protected: - void calculateConvectionOrConductionFlow() override; - - private: - double LdMean(double t_P, double t_D) const; - double LdMax(double t_P, double t_D) const; - - double m_MaxCoeff; - double m_MeanCoeff; - }; - - //////////////////////////////////////////////////////////////////////////// - //// CIGUDeflectionMeasuread - //////////////////////////////////////////////////////////////////////////// - class CIGUDeflectionMeasuread : public CIGUSolidLayerDeflection - { - public: - CIGUDeflectionMeasuread(std::shared_ptr & t_Layer, - const double t_MeanDeflection, - const double t_MaxDeflection); - }; - } // namespace ISO15099 -} // namespace Tarcog - -#endif + public: + explicit CIGUSolidLayerDeflection(const CIGUSolidLayer & t_SolidLayer); + CIGUSolidLayerDeflection(const CIGUSolidLayer & t_SolidLayer, + double t_YoungsModulus, + double t_PoisonRatio, + double t_Density); + + double flexuralRigidity() const; + + std::shared_ptr clone() const override; + + double youngsModulus() const override; + double density() const override; + + private: + double m_YoungsModulus; + double m_PoisonRatio; + double m_Density; + }; + + //////////////////////////////////////////////////////////////////////////// + //// CIGUDeflectionMeasuread + //////////////////////////////////////////////////////////////////////////// + class CIGUDeflectionMeasured : public CIGUSolidLayerDeflection + { + public: + CIGUDeflectionMeasured(std::shared_ptr & t_Layer, + const double t_MeanDeflection, + const double t_MaxDeflection); + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUSolidLayer.cpp b/src/Tarcog/src/IGUSolidLayer.cpp index 4177f861..5b69b408 100644 --- a/src/Tarcog/src/IGUSolidLayer.cpp +++ b/src/Tarcog/src/IGUSolidLayer.cpp @@ -1,188 +1,155 @@ - -#include #include #include #include "IGUSolidLayer.hpp" #include "BaseLayer.hpp" #include "Surface.hpp" -#include "WCECommon.hpp" #include "TarcogConstants.hpp" #include "LayerInterfaces.hpp" using FenestrationCommon::Side; -namespace Tarcog -{ - namespace ISO15099 - { - CIGUSolidLayer::CIGUSolidLayer( - double const t_Thickness, - double const t_Conductivity, - std::shared_ptr const & t_FrontSurface, - std::shared_ptr const & t_BackSurface) : - CBaseIGULayer(t_Thickness), - m_Conductivity(t_Conductivity), - m_SolarAbsorptance(0) - { - if(t_FrontSurface != nullptr && t_BackSurface != nullptr) - { - m_Surface[Side::Front] = t_FrontSurface; - m_Surface[Side::Back] = t_BackSurface; - } - else - { - m_Surface[Side::Front] = std::make_shared(); - m_Surface[Side::Back] = std::make_shared(); - } - } - CIGUSolidLayer::CIGUSolidLayer(double const t_Thickness, - double const t_Conductivity, - double const t_FrontEmissivity, - double const t_FrontIRTransmittance, - double const t_BackEmissivity, - double const t_BackIRTransmittance) : - CBaseIGULayer(t_Thickness), - m_Conductivity(t_Conductivity), - m_SolarAbsorptance(0) +namespace Tarcog::ISO15099 +{ + CIGUSolidLayer::CIGUSolidLayer( + double const t_Thickness, + double const t_Conductivity, + std::shared_ptr const & t_FrontSurface, + std::shared_ptr const & t_BackSurface) : + CBaseLayer(t_Thickness), m_Conductivity(t_Conductivity), m_SolarAbsorptance(0) + { + if(t_FrontSurface != nullptr && t_BackSurface != nullptr) { - m_Surface[Side::Front] = - std::make_shared(t_FrontEmissivity, t_FrontIRTransmittance); - m_Surface[Side::Back] = - std::make_shared(t_BackEmissivity, t_BackIRTransmittance); + m_Surface[Side::Front] = t_FrontSurface; + m_Surface[Side::Back] = t_BackSurface; } - - void CIGUSolidLayer::connectToBackSide(std::shared_ptr const & t_Layer) + else { - CBaseLayer::connectToBackSide(t_Layer); - t_Layer->setSurface(m_Surface.at(Side::Back), Side::Front); + m_Surface[Side::Front] = std::make_shared(); + m_Surface[Side::Back] = std::make_shared(); } + } - double CIGUSolidLayer::getConductance() const - { - return m_Conductivity; - } + CIGUSolidLayer::CIGUSolidLayer(double const t_Thickness, + double const t_Conductivity, + double const t_FrontEmissivity, + double const t_FrontIRTransmittance, + double const t_BackEmissivity, + double const t_BackIRTransmittance) : + CBaseLayer(t_Thickness), m_Conductivity(t_Conductivity), m_SolarAbsorptance(0) + { + m_Surface[Side::Front] = + std::make_shared(t_FrontEmissivity, t_FrontIRTransmittance); + m_Surface[Side::Back] = std::make_shared(t_BackEmissivity, t_BackIRTransmittance); + } - double CIGUSolidLayer::getSolarAbsorptance() const - { - return m_SolarAbsorptance; - } + void CIGUSolidLayer::connectToBackSide(std::shared_ptr const & t_Layer) + { + CBaseLayer::connectToBackSide(t_Layer); + t_Layer->setSurface(m_Surface.at(Side::Back), Side::Front); + } - void CIGUSolidLayer::calculateConvectionOrConductionFlow() - { - if(m_Thickness == 0) - { - throw std::runtime_error("Solid layer thickness is set to zero."); - } + double CIGUSolidLayer::getConductance() const + { + return m_Conductivity; + } - m_ConductiveConvectiveCoeff = m_Conductivity / m_Thickness; - } + double CIGUSolidLayer::getSolarAbsorptance() const + { + return m_SolarAbsorptance; + } - void CIGUSolidLayer::setLayerState(double const t_Tf, - double const t_Tb, - double const t_Jf, - double const t_Jb) + void CIGUSolidLayer::calculateConvectionOrConductionFlow() + { + if(m_Thickness == 0) { - setSurfaceState(t_Tf, t_Jf, Side::Front); - setSurfaceState(t_Tb, t_Jb, Side::Back); - if(m_NextLayer != nullptr) - { - m_NextLayer->resetCalculated(); - } - if(m_PreviousLayer != nullptr) - { - m_PreviousLayer->resetCalculated(); - } + throw std::runtime_error("Solid layer thickness is set to zero."); } - void CIGUSolidLayer::setSurfaceState(double const t_Temperature, - double const t_J, - Side const t_Position) - { - std::shared_ptr aSurface = m_Surface.at(t_Position); - aSurface->setTemperature(t_Temperature); - aSurface->setJ(t_J); - - resetCalculated(); - } + m_ConductiveConvectiveCoeff = m_Conductivity / m_Thickness; + } - void CIGUSolidLayer::setSolarRadiation(double const t_SolarRadiation) + void CIGUSolidLayer::setLayerState(double const t_Tf, + double const t_Tb, + double const t_Jf, + double const t_Jb) + { + setSurfaceState(t_Tf, t_Jf, Side::Front); + setSurfaceState(t_Tb, t_Jb, Side::Back); + resetCalculated(); + if(getNextLayer() != nullptr) { - m_LayerGainFlow = t_SolarRadiation * m_SolarAbsorptance; - resetCalculated(); + getNextLayer()->resetCalculated(); } - - void CIGUSolidLayer::setSolarHeatGain(double const t_SolarAbsorptance, - const double t_SolarRadiation) + if(getPreviousLayer() != nullptr) { - m_SolarAbsorptance = t_SolarAbsorptance; - m_LayerGainFlow = t_SolarRadiation * m_SolarAbsorptance; - resetCalculated(); + getPreviousLayer()->resetCalculated(); } + } - std::shared_ptr CIGUSolidLayer::clone() const - { - return std::make_shared(*this); - } + void CIGUSolidLayer::setSolarRadiation(double const t_SolarRadiation) + { + m_LayerGainFlow = t_SolarRadiation * m_SolarAbsorptance; + resetCalculated(); + } - void CIGUSolidLayer::applyDeflection(double meanDeflection, double maxDeflection) - { - m_IsDeflected = true; - for(auto aSide : FenestrationCommon::EnumSide()) - { - m_Surface[aSide]->applyDeflection(meanDeflection, maxDeflection); - } - } + void CIGUSolidLayer::setSolarHeatGain(double const t_SolarAbsorptance, + const double t_SolarRadiation) + { + m_SolarAbsorptance = t_SolarAbsorptance; + m_LayerGainFlow = t_SolarRadiation * m_SolarAbsorptance; + resetCalculated(); + } - bool CIGUSolidLayer::isDeflected() const - { - return m_IsDeflected; - } + std::shared_ptr CIGUSolidLayer::clone() const + { + return std::make_shared(*this); + } - double CIGUSolidLayer::youngsModulus() const + void CIGUSolidLayer::applyDeflection(double meanDeflection, double maxDeflection) + { + for(auto aSide : FenestrationCommon::EnumSide()) { - static const double defaultYoungsModulus{Tarcog::DeflectionConstants::YOUNGSMODULUS}; - return defaultYoungsModulus; + m_Surface[aSide]->applyDeflection(meanDeflection, maxDeflection); } + } - double CIGUSolidLayer::getMaxDeflection() const - { - assert(getSurface(Side::Front)->getMaxDeflection() - == getSurface(Side::Back)->getMaxDeflection()); - return getSurface(Side::Front)->getMaxDeflection(); - } + double CIGUSolidLayer::youngsModulus() const + { + static const double defaultYoungsModulus{Tarcog::DeflectionConstants::YOUNGSMODULUS}; + return defaultYoungsModulus; + } - double CIGUSolidLayer::getMeanDeflection() const - { - assert(getSurface(Side::Front)->getMeanDeflection() - == getSurface(Side::Back)->getMeanDeflection()); - return getSurface(Side::Front)->getMeanDeflection(); - } + double CIGUSolidLayer::getMaxDeflection() const + { + assert(FenestrationCommon::isEqual(surfaceDeflectionMax(Side::Front), + surfaceDeflectionMax(Side::Back))); + return surfaceDeflectionMax(Side::Front); + } - double CIGUSolidLayer::density() const - { - static const double defaultDensity{Tarcog::MaterialConstants::GLASSDENSITY}; - return defaultDensity; - } + double CIGUSolidLayer::getMeanDeflection() const + { + assert(FenestrationCommon::isEqual(surfaceDeflectionMean(Side::Front), + surfaceDeflectionMean(Side::Back))); + return surfaceDeflectionMean(Side::Front); + } - double CIGUSolidLayer::getRadiationFlow() - { - // Solid layers share surfaces, so actually asking for front surface of previous layer - // will be actual incoming radiation to this surface layer. And vice versa for back - // surface. - const auto frontIncomingRadiation{ - getPreviousLayer()->getSurface(FenestrationCommon::Side::Front)->J()}; - const auto backIncomingRadiation{ - getNextLayer()->getSurface(FenestrationCommon::Side::Back)->J()}; - - const auto frontSurface{m_Surface.at(Side::Front)}; - - const auto tir{frontSurface->getTransmittance()}; - const auto radiationFlow{tir * (backIncomingRadiation - frontIncomingRadiation)}; - return radiationFlow; - } - } // namespace ISO15099 + double CIGUSolidLayer::density() const + { + static const double defaultDensity{Tarcog::MaterialConstants::GLASSDENSITY}; + return defaultDensity; + } -} // namespace Tarcog + double CIGUSolidLayer::getRadiationFlow() + { + // Solid layers share surfaces, so actually asking for front surface of previous layer + // will be actual incoming radiation to this surface layer. And vice versa for back + // surface. + + return transmittance(Side::Front) + * (getNextLayer()->J(FenestrationCommon::Side::Back) + - getPreviousLayer()->J(FenestrationCommon::Side::Front)); + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUSolidLayer.hpp b/src/Tarcog/src/IGUSolidLayer.hpp index b26d4b88..6c980765 100644 --- a/src/Tarcog/src/IGUSolidLayer.hpp +++ b/src/Tarcog/src/IGUSolidLayer.hpp @@ -1,75 +1,62 @@ -#ifndef TARIGUSOLIDLAYER_H -#define TARIGUSOLIDLAYER_H +#pragma once #include -#include "BaseIGULayer.hpp" + +#include "BaseLayer.hpp" +#include "DeflectionInterface.hpp" namespace FenestrationCommon { enum class Side; } -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + class CIGUSolidLayer : public CBaseLayer, public Tarcog::Deflectable { - class CIGUSolidLayer : public CBaseIGULayer - { - public: - CIGUSolidLayer( - double t_Thickness, - double t_Conductivity, - const std::shared_ptr & t_FrontSurface = nullptr, - const std::shared_ptr & t_BackSurface = nullptr); - - CIGUSolidLayer(double t_Thickness, - double t_Conductivity, - double t_FrontEmissivity, - double t_FrontIRTransmittance, - double t_BackEmissivity, - double t_BackIRTransmittance); - - void connectToBackSide(const std::shared_ptr & t_Layer) override; - - double getConductance() const; - double getSolarAbsorptance() const; - - void setLayerState(double t_Tf, double t_Tb, double t_Jf, double t_Jb); - void setSolarRadiation(double t_SolarRadiation); - void setSolarHeatGain(double t_SolarAbsorptance, double t_SolarRadiation); + public: + CIGUSolidLayer(double t_Thickness, + double t_Conductivity, + const std::shared_ptr & t_FrontSurface = nullptr, + const std::shared_ptr & t_BackSurface = nullptr); - // Radiation flow in solid layer should be eliminated - double getRadiationFlow() override; + CIGUSolidLayer(double t_Thickness, + double t_Conductivity, + double t_FrontEmissivity, + double t_FrontIRTransmittance, + double t_BackEmissivity, + double t_BackIRTransmittance); - virtual bool isDeflected() const; - virtual double youngsModulus() const; + void connectToBackSide(const std::shared_ptr & t_Layer) override; - double getMaxDeflection() const override; - double getMeanDeflection() const override; + double getConductance() const; + double getSolarAbsorptance() const; - virtual double density() const; + void setLayerState(double t_Tf, double t_Tb, double t_Jf, double t_Jb); + void setSolarRadiation(double t_SolarRadiation); + void setSolarHeatGain(double t_SolarAbsorptance, double t_SolarRadiation); - std::shared_ptr clone() const override; + double getRadiationFlow() override; - void applyDeflection(double meanDeflection, double maxDeflection); + virtual double youngsModulus() const; - protected: - void calculateConvectionOrConductionFlow() override; + double getMaxDeflection() const override; + double getMeanDeflection() const override; - double m_Conductivity; + virtual double density() const; - private: - void setSurfaceState(double t_Temperature, - double t_J, - FenestrationCommon::Side t_Position); + std::shared_ptr clone() const override; - double m_SolarAbsorptance; + void applyDeflection(double meanDeflection, double maxDeflection); - bool m_IsDeflected{false}; - }; + protected: + void calculateConvectionOrConductionFlow() override; - } // namespace ISO15099 + double m_Conductivity; + private: -} // namespace Tarcog + double m_SolarAbsorptance; + }; -#endif +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUVentilatedGapLayer.cpp b/src/Tarcog/src/IGUVentilatedGapLayer.cpp index 56f68fd4..c7cbbcb5 100644 --- a/src/Tarcog/src/IGUVentilatedGapLayer.cpp +++ b/src/Tarcog/src/IGUVentilatedGapLayer.cpp @@ -1,4 +1,3 @@ - #include #include #include @@ -7,350 +6,356 @@ #include "IGUVentilatedGapLayer.hpp" #include "TarcogConstants.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + VentilatedGapState::VentilatedGapState(double inletTemperature, double outletTemperature) : + inletTemperature(inletTemperature), outletTemperature(outletTemperature) + {} + + ForcedVentilation::ForcedVentilation(double speed, double temperature) : + speed(speed), temperature(temperature) + {} + + Gases::GasProperties getGasPropertiesAtReferenceTemperatureAndPressure(Gases::CGas & gas, + const double temperature, + const double pressure) { - VentilatedGapState::VentilatedGapState(double inletTemperature, double outletTemperature) : - inletTemperature(inletTemperature), outletTemperature(outletTemperature) - {} - - ForcedVentilation::ForcedVentilation(double speed, double temperature) : - speed(speed), temperature(temperature) - {} - - CIGUVentilatedGapLayer::CIGUVentilatedGapLayer( - std::shared_ptr const & t_Layer) : - CIGUGapLayer(*t_Layer), - m_Layer(t_Layer), - m_State(Gases::DefaultTemperature, Gases::DefaultTemperature), - m_Zin(0), - m_Zout(0) - { - m_ReferenceGas = m_Gas; - m_ReferenceGas.setTemperatureAndPressure(ReferenceTemperature, m_Pressure); - } + auto refGas{gas}; + refGas.setTemperatureAndPressure(temperature, pressure); + return refGas.getGasProperties(); + } + + CIGUVentilatedGapLayer::CIGUVentilatedGapLayer(std::shared_ptr const & t_Layer) : + CIGUGapLayer(*t_Layer), + m_Layer(t_Layer), + m_State(Gases::DefaultTemperature, Gases::DefaultTemperature), + m_ReferenceGasProperties(getGasPropertiesAtReferenceTemperatureAndPressure( + gasSpecification.gas, ReferenceTemperature, gasSpecification.pressure)), + m_Zin(0), + m_Zout(0) + {} + + CIGUVentilatedGapLayer::CIGUVentilatedGapLayer(const std::shared_ptr & t_Layer, + double forcedVentilationInletTemperature, + double forcedVentilationInletSpeed) : + CIGUGapLayer(*t_Layer), + m_Layer(t_Layer), + m_State(Gases::DefaultTemperature, Gases::DefaultTemperature), + m_ReferenceGasProperties(getGasPropertiesAtReferenceTemperatureAndPressure( + gasSpecification.gas, ReferenceTemperature, gasSpecification.pressure)), + m_Zin(0), + m_Zout(0), + m_ForcedVentilation( + ForcedVentilation(forcedVentilationInletSpeed, forcedVentilationInletTemperature)) + {} + + double CIGUVentilatedGapLayer::averageLayerTemperature() + { + assert(m_Height != 0); + const auto cHeight = characteristicHeight(); + const auto avTemp = averageSurfaceTemperature(); + return avTemp + - (cHeight / m_Height) * (m_State.outletTemperature - m_State.inletTemperature); + } + + void CIGUVentilatedGapLayer::setFlowGeometry(double const t_Ain, double const t_Aout) + { + m_Zin = calcImpedance(t_Aout); + m_Zout = calcImpedance(t_Ain); + } - CIGUVentilatedGapLayer::CIGUVentilatedGapLayer( - const std::shared_ptr & t_Layer, - double forcedVentilationInletTemperature, - double forcedVentilationInletSpeed) : - CIGUGapLayer(*t_Layer), - m_Layer(t_Layer), - m_State(Gases::DefaultTemperature, Gases::DefaultTemperature), - m_Zin(0), - m_Zout(0), - m_ForcedVentilation( - ForcedVentilation(forcedVentilationInletSpeed, forcedVentilationInletTemperature)) - { - m_ReferenceGas = m_Gas; - m_ReferenceGas.setTemperatureAndPressure(ReferenceTemperature, m_Pressure); - } + void CIGUVentilatedGapLayer::setInletTemperature(double inletTemperature) + { + m_State.inletTemperature = inletTemperature; + resetCalculated(); + gasSpecification.setTemperature(averageLayerTemperature()); + } - double CIGUVentilatedGapLayer::inletTemperature() - { - return m_State.inletTemperature; - } + void CIGUVentilatedGapLayer::setFlowTemperatures(double t_inTemperature, + double t_outTemperature) + { + m_State.inletTemperature = t_inTemperature; + m_State.outletTemperature = t_outTemperature; + resetCalculated(); + gasSpecification.setTemperature(averageLayerTemperature()); + } - double CIGUVentilatedGapLayer::outletTemperature() - { - return m_State.outletTemperature; - } + void CIGUVentilatedGapLayer::setFlowSpeed(double const t_speed) + { + gasSpecification.airflowProperties.m_AirSpeed = t_speed; + resetCalculated(); + gasSpecification.setTemperature(averageLayerTemperature()); + } - double CIGUVentilatedGapLayer::layerTemperature() - { - assert(m_Height != 0); - const auto cHeight = characteristicHeight(); - const auto avTemp = averageTemperature(); - return avTemp - - (cHeight / m_Height) * (m_State.outletTemperature - m_State.inletTemperature); - } + double CIGUVentilatedGapLayer::getDrivingPressure() + { + using ConstantsData::GRAVITYCONSTANT; - void CIGUVentilatedGapLayer::setFlowGeometry(double const t_Ain, double const t_Aout) - { - m_Zin = calcImpedance(t_Aout); - m_Zout = calcImpedance(t_Ain); - } + const auto tiltAngle = FenestrationCommon::radians(m_Tilt - 90); + const auto gapTemperature = averageLayerTemperature(); + const auto temperatureMultiplier = std::abs(gapTemperature - m_State.inletTemperature) + / (gapTemperature * m_State.inletTemperature); + return m_ReferenceGasProperties.m_Density * ReferenceTemperature * GRAVITYCONSTANT * m_Height + * std::abs(cos(tiltAngle)) * temperatureMultiplier; + } - void CIGUVentilatedGapLayer::setInletTemperature(double inletTemperature) - { - m_State.inletTemperature = inletTemperature; - resetCalculated(); - } + double CIGUVentilatedGapLayer::bernoullyPressureTerm() + { + const auto aGasProperties = gasSpecification.gas.getGasProperties(); + return 0.5 * aGasProperties.m_Density; + } - void CIGUVentilatedGapLayer::setFlowTemperatures(double t_inTemperature, - double t_outTemperature) - { - m_State.inletTemperature = t_inTemperature; - m_State.outletTemperature = t_outTemperature; - resetCalculated(); - } + double CIGUVentilatedGapLayer::hagenPressureTerm() + { + const auto aGasProperties = gasSpecification.gas.getGasProperties(); + return 12 * aGasProperties.m_Viscosity * m_Height / pow(getThickness(), 2); + } - void CIGUVentilatedGapLayer::setFlowSpeed(double const t_speed) - { - m_AirSpeed = t_speed; - resetCalculated(); - } + double CIGUVentilatedGapLayer::pressureLossTerm() + { + const auto aGasProperties = gasSpecification.gas.getGasProperties(); + return 0.5 * aGasProperties.m_Density * (m_Zin + m_Zout); + } - double CIGUVentilatedGapLayer::getDrivingPressure() - { - using ConstantsData::GRAVITYCONSTANT; - using ConstantsData::WCE_PI; - - const auto tiltAngle = WCE_PI / 180 * (m_Tilt - 90); - const auto gapTemperature = layerTemperature(); - const auto aProperties = m_ReferenceGas.getGasProperties(); - const auto temperatureMultiplier = std::abs(gapTemperature - m_State.inletTemperature) - / (gapTemperature * m_State.inletTemperature); - return aProperties.m_Density * ReferenceTemperature * GRAVITYCONSTANT * m_Height - * std::abs(cos(tiltAngle)) * temperatureMultiplier; - } + double CIGUVentilatedGapLayer::betaCoeff() + { + return exp(-m_Height / characteristicHeight()); + } - double CIGUVentilatedGapLayer::bernoullyPressureTerm() + void CIGUVentilatedGapLayer::smoothEnergyGain(double const qv1, double const qv2) + { + const auto smooth = (std::abs(qv1) + std::abs(qv2)) / 2; + m_LayerGainFlow = smooth; + if(m_State.inletTemperature < m_State.outletTemperature) { - const auto aGasProperties = m_Gas.getGasProperties(); - return 0.5 * aGasProperties.m_Density; + m_LayerGainFlow = -m_LayerGainFlow; } + } - double CIGUVentilatedGapLayer::hagenPressureTerm() + void CIGUVentilatedGapLayer::calculateConvectionOrConductionFlow() + { + calculateHeatFlowNextLayer(); + CIGUGapLayer::calculateConvectionOrConductionFlow(); + if(!isCalculated()) { - const auto aGasProperties = m_Gas.getGasProperties(); - return 12 * aGasProperties.m_Viscosity * m_Height / pow(getThickness(), 2); + m_LayerGainFlow = ventilatedHeatGain(); } + } - double CIGUVentilatedGapLayer::pressureLossTerm() + void CIGUVentilatedGapLayer::calculateHeatFlowNextLayer() const + { + if(getNextLayer() != nullptr) { - const auto aGasProperties = m_Gas.getGasProperties(); - return 0.5 * aGasProperties.m_Density * (m_Zin + m_Zout); + // In case of thermally driven calculations, it is necessary to initialize gaps around + // shading layer correctly and that initialization is performed by shading layer + getNextLayer()->calculateLayerHeatFlow(); } + } - double CIGUVentilatedGapLayer::betaCoeff() + double CIGUVentilatedGapLayer::characteristicHeight() + { + const auto aProperties = gasSpecification.gas.getGasProperties(); + double cHeight = 0; + // Characteristic height can only be calculated after initialization is performed + if(!FenestrationCommon::isEqual(m_ConductiveConvectiveCoeff, 0)) { - calculateLayerHeatFlow(); - return exp(-m_Height / characteristicHeight()); + cHeight = aProperties.m_Density * aProperties.m_SpecificHeat * getThickness() + * gasSpecification.airflowProperties.m_AirSpeed + / (4 * m_ConductiveConvectiveCoeff); } + return cHeight; + } - void CIGUVentilatedGapLayer::smoothEnergyGain(double const qv1, double const qv2) - { - const auto smooth = (std::abs(qv1) + std::abs(qv2)) / 2; - m_LayerGainFlow = smooth; - if(m_State.inletTemperature < m_State.outletTemperature) - { - m_LayerGainFlow = -m_LayerGainFlow; - } - } + double CIGUVentilatedGapLayer::calcImpedance(double const t_A) const + { + auto impedance = 0.0; - void CIGUVentilatedGapLayer::calculateConvectionOrConductionFlow() + if(!FenestrationCommon::isEqual(t_A, 0)) { - CIGUGapLayer::calculateConvectionOrConductionFlow(); - if(!isCalculated()) - { - ventilatedHeatGain(); - } + impedance = pow(m_Width * getThickness() / (0.6 * t_A) - 1, 2); } - double CIGUVentilatedGapLayer::characteristicHeight() - { - const auto aProperties = m_Gas.getGasProperties(); - double cHeight = 0; - // Characteristic height can only be calculated after initialization is performed - if(!FenestrationCommon::isEqual(m_ConductiveConvectiveCoeff, 0)) - { - cHeight = aProperties.m_Density * aProperties.m_SpecificHeat * getThickness() - * m_AirSpeed / (4 * m_ConductiveConvectiveCoeff); - } - return cHeight; - } + return impedance; + } - double CIGUVentilatedGapLayer::calcImpedance(double const t_A) const - { - auto impedance = 0.0; + double CIGUVentilatedGapLayer::ventilatedHeatGain() + { + const auto aProperties = gasSpecification.gas.getGasProperties(); + return aProperties.m_Density * aProperties.m_SpecificHeat + * gasSpecification.airflowProperties.m_AirSpeed * getThickness() + * (m_State.inletTemperature - m_State.outletTemperature) / m_Height; + } - if(!FenestrationCommon::isEqual(t_A, 0)) - { - impedance = pow(m_Width * getThickness() / (0.6 * t_A) - 1, 2); - } + double CIGUVentilatedGapLayer::calculateThermallyDrivenSpeed() + { + double drivingPressure = getDrivingPressure(); + double A = bernoullyPressureTerm() + pressureLossTerm(); + double B = hagenPressureTerm(); + return (sqrt(std::abs(pow(B, 2) + 4 * A * drivingPressure)) - B) / (2 * A); + } - return impedance; - } + void CIGUVentilatedGapLayer::calculateOutletTemperatureFromAirFlow() + { + // Always use forced ventilation if exists. + gasSpecification.airflowProperties.m_AirSpeed = m_ForcedVentilation.has_value() + ? m_ForcedVentilation->speed + : calculateThermallyDrivenSpeed(); + double beta = betaCoeff(); + double alpha = 1 - beta; + + m_State.outletTemperature = + alpha * averageSurfaceTemperature() + beta * m_State.inletTemperature; + } + + double CIGUVentilatedGapLayer::calculateThermallyDrivenSpeedOfAdjacentGap( + CIGUVentilatedGapLayer & adjacentGap) + { + double ratio = getThickness() / adjacentGap.getThickness(); + double A1 = bernoullyPressureTerm() + adjacentGap.pressureLossTerm(); + double A2 = adjacentGap.bernoullyPressureTerm() + adjacentGap.pressureLossTerm(); + double B1 = hagenPressureTerm(); + double B2 = adjacentGap.hagenPressureTerm(); + double A = A1 + pow(ratio, 2) * A2; + double B = B1 + ratio * B2; + gasSpecification.airflowProperties.m_AirSpeed = + (sqrt(std::abs(pow(B, 2.0) + 4 * A * getDrivingPressure())) - B) / (2.0 * A); + return gasSpecification.airflowProperties.m_AirSpeed / ratio; + } + + VentilatedGapState + CIGUVentilatedGapLayer::calculateInletAndOutletTemperaturesWithTheAdjacentGap( + CIGUVentilatedGapLayer & adjacentGap, + VentilatedGapState current, + VentilatedGapState previous, + double relaxationParameter) + { + VentilatedGapState result; - void CIGUVentilatedGapLayer::ventilatedHeatGain() - { - const auto aProperties = m_Gas.getGasProperties(); - m_LayerGainFlow = aProperties.m_Density * aProperties.m_SpecificHeat * m_AirSpeed - * getThickness() - * (m_State.inletTemperature - m_State.outletTemperature) / m_Height; - } + double tempGap1 = averageLayerTemperature(); + double tempGap2 = adjacentGap.averageLayerTemperature(); + double Tav1 = averageSurfaceTemperature(); + double Tav2 = adjacentGap.averageSurfaceTemperature(); - double CIGUVentilatedGapLayer::calculateThermallyDrivenSpeed() - { - double drivingPressure = getDrivingPressure(); - double A = bernoullyPressureTerm() + pressureLossTerm(); - double B = hagenPressureTerm(); - return (sqrt(std::abs(pow(B, 2) + 4 * A * drivingPressure)) - B) / (2 * A); - } + adjacentGap.setFlowSpeed(calculateThermallyDrivenSpeedOfAdjacentGap(adjacentGap)); - void CIGUVentilatedGapLayer::calculateOutletTemperatureFromAirFlow() - { - // Always use forced ventilation if exists. - m_AirSpeed = m_ForcedVentilation.has_value() ? m_ForcedVentilation->speed - : calculateThermallyDrivenSpeed(); - double beta = betaCoeff(); - double alpha = 1 - beta; - - m_State.outletTemperature = - alpha * averageTemperature() + beta * m_State.inletTemperature; - } + double beta1 = betaCoeff(); + double beta2 = adjacentGap.betaCoeff(); + double alpha1 = 1 - beta1; + double alpha2 = 1 - beta2; - double CIGUVentilatedGapLayer::calculateThermallyDrivenSpeedOfAdjacentGap( - CIGUVentilatedGapLayer & adjacentGap) + if(tempGap1 > tempGap2) { - double ratio = getThickness() / adjacentGap.getThickness(); - double A1 = bernoullyPressureTerm() + adjacentGap.pressureLossTerm(); - double A2 = adjacentGap.bernoullyPressureTerm() + adjacentGap.pressureLossTerm(); - double B1 = hagenPressureTerm(); - double B2 = adjacentGap.hagenPressureTerm(); - double A = A1 + pow(ratio, 2) * A2; - double B = B1 + ratio * B2; - m_AirSpeed = - (sqrt(std::abs(pow(B, 2.0) + 4 * A * getDrivingPressure())) - B) / (2.0 * A); - return m_AirSpeed / ratio; + result.outletTemperature = + (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2); + result.inletTemperature = alpha2 * Tav2 + beta2 * current.outletTemperature; } - - VentilatedGapState - CIGUVentilatedGapLayer::calculateInletAndOutletTemperaturesWithTheAdjecentGap( - CIGUVentilatedGapLayer & adjacentGap, - VentilatedGapState current, - VentilatedGapState previous, - double relaxationParameter) + else { - VentilatedGapState result; + result.inletTemperature = (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2); + result.outletTemperature = alpha2 * Tav2 + beta2 * current.inletTemperature; + } - double tempGap1 = layerTemperature(); - double tempGap2 = adjacentGap.layerTemperature(); - double Tav1 = averageTemperature(); - double Tav2 = adjacentGap.averageTemperature(); + const auto Tup = relaxationParameter * result.outletTemperature + + (1 - relaxationParameter) * previous.outletTemperature; + const auto Tdown = relaxationParameter * result.inletTemperature + + (1 - relaxationParameter) * previous.inletTemperature; - adjacentGap.setFlowSpeed(calculateThermallyDrivenSpeedOfAdjacentGap(adjacentGap)); + setFlowTemperatures(Tup, Tdown); + adjacentGap.setFlowTemperatures(Tdown, Tup); - double beta1 = betaCoeff(); - double beta2 = adjacentGap.betaCoeff(); - double alpha1 = 1 - beta1; - double alpha2 = 1 - beta2; + return result; + } - if(tempGap1 > tempGap2) - { - result.outletTemperature = - (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2); - result.inletTemperature = alpha2 * Tav2 + beta2 * current.outletTemperature; - } - else - { - result.inletTemperature = - (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1 - beta1 * beta2); - result.outletTemperature = alpha2 * Tav2 + beta2 * current.inletTemperature; - } - - const auto Tup = relaxationParameter * result.outletTemperature - + (1 - relaxationParameter) * previous.outletTemperature; - const auto Tdown = relaxationParameter * result.inletTemperature - + (1 - relaxationParameter) * previous.inletTemperature; - - setFlowTemperatures(Tup, Tdown); - adjacentGap.setFlowTemperatures(Tdown, Tup); - - return result; - } + void CIGUVentilatedGapLayer::calculateVentilatedAirflow(double inletTemperature) + { + setInletTemperature(inletTemperature); - void CIGUVentilatedGapLayer::calculateVentilatedAirflow(double inletTemperature) + double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW; + bool converged = false; + size_t iterationStep = 0; + double TgapOut = averageLayerTemperature(); + while(!converged) { - setInletTemperature(inletTemperature); + resetCalculated(); + gasSpecification.setTemperature(averageLayerTemperature()); - double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW; - bool converged = false; - size_t iterationStep = 0; - double TgapOut = layerTemperature(); - while(!converged) - { - resetCalculated(); - double TgapOutOld = TgapOut; + double TgapOutOld = TgapOut; - calculateOutletTemperatureFromAirFlow(); + calculateOutletTemperatureFromAirFlow(); - const auto tempGap = layerTemperature(); + const auto tempGap = averageLayerTemperature(); - TgapOut = RelaxationParameter * tempGap + (1 - RelaxationParameter) * TgapOutOld; + TgapOut = RelaxationParameter * tempGap + (1 - RelaxationParameter) * TgapOutOld; - converged = std::abs(TgapOut - TgapOutOld) - < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; + converged = + std::abs(TgapOut - TgapOutOld) < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; - ++iterationStep; - if(iterationStep > IterationConstants::NUMBER_OF_STEPS) + ++iterationStep; + if(iterationStep > IterationConstants::NUMBER_OF_STEPS) + { + RelaxationParameter -= IterationConstants::RELAXATION_PARAMETER_AIRFLOW_STEP; + iterationStep = 0; + if(RelaxationParameter == IterationConstants::RELAXATION_PARAMETER_AIRFLOW_MIN) { - 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."); - } + converged = true; + throw std::runtime_error("Airflow iterations fail to converge. " + "Maximum number of iteration steps reached."); } } } + } - void CIGUVentilatedGapLayer::calculateThermallyDrivenAirflowWithAdjacentGap( - CIGUVentilatedGapLayer & adjacentGap) + void CIGUVentilatedGapLayer::calculateThermallyDrivenAirflowWithAdjacentGap( + CIGUVentilatedGapLayer & adjacentGap) + { + double Tup = averageLayerTemperature(); + double Tdown = adjacentGap.averageLayerTemperature(); + VentilatedGapState current{Tdown, Tup}; + double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW; + bool converged = false; + size_t iterationStep = 0; + + while(!converged) { - double Tup = layerTemperature(); - double Tdown = adjacentGap.layerTemperature(); - VentilatedGapState current{Tdown, Tup}; - double RelaxationParameter = IterationConstants::RELAXATION_PARAMETER_AIRFLOW; - bool converged = false; - size_t iterationStep = 0; - - while(!converged) - { - setInletTemperature(adjacentGap.layerTemperature()); - adjacentGap.setInletTemperature(layerTemperature()); + setInletTemperature(adjacentGap.averageLayerTemperature()); + adjacentGap.setInletTemperature(averageLayerTemperature()); - VentilatedGapState previous{current}; + VentilatedGapState previous{current}; - current = calculateInletAndOutletTemperaturesWithTheAdjecentGap( - adjacentGap, current, previous, RelaxationParameter); + current = calculateInletAndOutletTemperaturesWithTheAdjacentGap( + adjacentGap, current, previous, RelaxationParameter); - converged = std::abs(current.outletTemperature - previous.outletTemperature) - < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; - converged = converged - && std::abs(current.inletTemperature - previous.inletTemperature) - < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; + converged = std::abs(current.outletTemperature - previous.outletTemperature) + < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; + converged = converged + && std::abs(current.inletTemperature - previous.inletTemperature) + < IterationConstants::CONVERGENCE_TOLERANCE_AIRFLOW; - ++iterationStep; - if(iterationStep > IterationConstants::NUMBER_OF_STEPS) - { - converged = true; - throw std::runtime_error("Airflow iterations fail to converge. Maximum number " - "of iteration steps reached."); - } - double qv1 = getGainFlow(); - double qv2 = adjacentGap.getGainFlow(); - smoothEnergyGain(qv1, qv2); - adjacentGap.smoothEnergyGain(qv1, qv2); + ++iterationStep; + if(iterationStep > IterationConstants::NUMBER_OF_STEPS) + { + converged = true; + throw std::runtime_error("Airflow iterations fail to converge. Maximum number " + "of iteration steps reached."); } + double qv1 = getGainFlow(); + double qv2 = adjacentGap.getGainFlow(); + smoothEnergyGain(qv1, qv2); + adjacentGap.smoothEnergyGain(qv1, qv2); } + } - std::shared_ptr CIGUVentilatedGapLayer::clone() const - { - return std::make_shared(*this); - } + std::shared_ptr CIGUVentilatedGapLayer::clone() const + { + return std::make_shared(*this); + } - void CIGUVentilatedGapLayer::precalculateState() + void CIGUVentilatedGapLayer::precalculateState() + { + if(m_ForcedVentilation.has_value()) { - if(m_ForcedVentilation.has_value()) - { - calculateVentilatedAirflow(m_ForcedVentilation->temperature); - } + calculateVentilatedAirflow(m_ForcedVentilation->temperature); } - } // namespace ISO15099 - -} // namespace Tarcog + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IGUVentilatedGapLayer.hpp b/src/Tarcog/src/IGUVentilatedGapLayer.hpp index 6edb1f1c..8c579a34 100644 --- a/src/Tarcog/src/IGUVentilatedGapLayer.hpp +++ b/src/Tarcog/src/IGUVentilatedGapLayer.hpp @@ -1,106 +1,100 @@ -#ifndef TARIGUVENTILATEDGAPLAYER_H -#define TARIGUVENTILATEDGAPLAYER_H +#pragma once #include -#include "WCEGases.hpp" +#include + #include "IGUGapLayer.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + struct VentilatedGapState + { + VentilatedGapState() = default; + VentilatedGapState(double inletTemperature, double outletTemperature); + double inletTemperature{0}; + double outletTemperature{0}; + }; + + //! @brief Storage for forced ventilation properties. + //! + //! @property speed - Speed at which air is flowing into the gap + //! @property temperature - Temperature at which air will be coming into the gap + struct ForcedVentilation + { + ForcedVentilation(double speed, double temperature); + double speed{0}; + double temperature{0}; + }; + + class CIGUVentilatedGapLayer : public CIGUGapLayer { - struct VentilatedGapState - { - VentilatedGapState() = default; - VentilatedGapState(double inletTemperature, double outletTemperature); - double inletTemperature{0}; - double outletTemperature{0}; - }; - - //! @brief Storage for forced ventilation properties. - //! - //! @property speed - Speed at which air is flowing into the gap - //! @property temperature - Temperature at which air will be coming into the gap - struct ForcedVentilation - { - ForcedVentilation(double speed, double temperature); - double speed{0}; - double temperature{0}; - }; - - class CIGUVentilatedGapLayer : public CIGUGapLayer - { - public: - explicit CIGUVentilatedGapLayer(const std::shared_ptr & t_Layer); - CIGUVentilatedGapLayer(const std::shared_ptr & t_Layer, - double forcedVentilationInletTemperature, - double forcedVentilationInletSpeed); - - double inletTemperature(); - double outletTemperature(); - double layerTemperature() override; - - void setFlowGeometry(double t_Ain, double t_Aout); - - void setInletTemperature(double inletTemperature); - - void setFlowTemperatures(double t_inTemperature, double t_outTemperature); - void setFlowSpeed(double t_speed); - - void smoothEnergyGain(double qv1, double qv2); - - // Calculates airflow properties of the gap given inletTemperature temperature. In case - // inletTemperature temperature is not give, class will use temperature provided in the - // gap constructor. - void calculateVentilatedAirflow(double inletTemperature); - - void - calculateThermallyDrivenAirflowWithAdjacentGap(CIGUVentilatedGapLayer & adjacentGap); - - std::shared_ptr clone() const override; - - private: - void precalculateState() override; - void calculateOutletTemperatureFromAirFlow(); - - VentilatedGapState calculateInletAndOutletTemperaturesWithTheAdjecentGap( - CIGUVentilatedGapLayer & adjacentGap, - VentilatedGapState current, - VentilatedGapState previous, - double relaxationParameter); - - double calculateThermallyDrivenSpeedOfAdjacentGap(CIGUVentilatedGapLayer & adjacentGap); - - double getDrivingPressure(); - - double bernoullyPressureTerm(); - double hagenPressureTerm(); - double pressureLossTerm(); - double betaCoeff(); - void calculateConvectionOrConductionFlow() override; - double characteristicHeight(); - double calcImpedance(double t_A) const; - void ventilatedHeatGain(); - double calculateThermallyDrivenSpeed(); - - std::shared_ptr m_Layer; - Gases::CGas m_ReferenceGas; - - VentilatedGapState m_State; - double m_Zin{0}; - double m_Zout{0}; - - //! Forced ventilation is stored as optional so that it can be decided if airflow - //! calculations will be either thermally driven or forced. Forced ventilation will be - //! used automatically if this value has been populated, otherwise, thermally driven is - //! assumed. - std::optional m_ForcedVentilation; - }; - - } // namespace ISO15099 - -} // namespace Tarcog - -#endif + public: + explicit CIGUVentilatedGapLayer(const std::shared_ptr & t_Layer); + CIGUVentilatedGapLayer(const std::shared_ptr & t_Layer, + double forcedVentilationInletTemperature, + double forcedVentilationInletSpeed); + + double averageLayerTemperature() override; + + void setFlowGeometry(double t_Ain, double t_Aout); + + void setInletTemperature(double inletTemperature); + + void setFlowTemperatures(double t_inTemperature, double t_outTemperature); + void setFlowSpeed(double t_speed); + + void smoothEnergyGain(double qv1, double qv2); + + // Calculates airflow properties of the gap given inletTemperature temperature. In case + // inletTemperature temperature is not give, class will use temperature provided in the + // gap constructor. + void calculateVentilatedAirflow(double inletTemperature); + + void calculateThermallyDrivenAirflowWithAdjacentGap(CIGUVentilatedGapLayer & adjacentGap); + + std::shared_ptr clone() const override; + + private: + void precalculateState() override; + void calculateOutletTemperatureFromAirFlow(); + + VentilatedGapState calculateInletAndOutletTemperaturesWithTheAdjacentGap( + CIGUVentilatedGapLayer & adjacentGap, + VentilatedGapState current, + VentilatedGapState previous, + double relaxationParameter); + + double calculateThermallyDrivenSpeedOfAdjacentGap(CIGUVentilatedGapLayer & adjacentGap); + + double getDrivingPressure(); + + double bernoullyPressureTerm(); + double hagenPressureTerm(); + double pressureLossTerm(); + double betaCoeff(); + void calculateConvectionOrConductionFlow() override; + double characteristicHeight(); + double calcImpedance(double t_A) const; + [[nodiscard]] double ventilatedHeatGain(); + double calculateThermallyDrivenSpeed(); + + void calculateHeatFlowNextLayer() const; + + std::shared_ptr m_Layer; + + const Gases::GasProperties m_ReferenceGasProperties; + + VentilatedGapState m_State; + double m_Zin{0}; + double m_Zout{0}; + + //! Forced ventilation is stored as optional so that it can be decided if airflow + //! calculations will be either thermally driven or forced. Forced ventilation will be + //! used automatically if this value has been populated, otherwise, thermally driven is + //! assumed. + std::optional m_ForcedVentilation; + }; + +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IndoorEnvironment.cpp b/src/Tarcog/src/IndoorEnvironment.cpp index 55d72962..e7e30c1d 100644 --- a/src/Tarcog/src/IndoorEnvironment.cpp +++ b/src/Tarcog/src/IndoorEnvironment.cpp @@ -1,189 +1,140 @@ - #include -#include -#include #include "IndoorEnvironment.hpp" - -#include "WCEGases.hpp" #include "Surface.hpp" -#include "WCECommon.hpp" using FenestrationCommon::Side; -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + // Keep airspeed to zero and airdirection to default windward + CIndoorEnvironment::CIndoorEnvironment(double const t_AirTemperature, double const t_Pressure) : + CEnvironment(t_Pressure, 0, AirHorizontalDirection::Windward) { - // Keep airspeed to zero and airdirection to default windward - CIndoorEnvironment::CIndoorEnvironment(double const t_AirTemperature, - double const t_Pressure) : - CEnvironment(t_Pressure, 0, AirHorizontalDirection::Windward) - { - m_RoomRadiationTemperature = - t_AirTemperature; // Radiation temperature is by default air - m_Surface[Side::Back] = std::make_shared(m_Emissivity, 0); - m_Surface.at(Side::Back)->setTemperature(t_AirTemperature); - } + m_RoomRadiationTemperature = t_AirTemperature; // Radiation temperature is by default air + m_Surface[Side::Back] = std::make_shared(m_Emissivity, 0); + getSurface(Side::Back)->setTemperature(t_AirTemperature); + } - CIndoorEnvironment::CIndoorEnvironment(CIndoorEnvironment const & t_Indoor) : - CState(t_Indoor), - CEnvironment(t_Indoor) - { - operator=(t_Indoor); - } + CIndoorEnvironment::CIndoorEnvironment(CIndoorEnvironment const & t_Indoor) : + CEnvironment(t_Indoor) + { + operator=(t_Indoor); + } - CIndoorEnvironment & CIndoorEnvironment::operator=(CIndoorEnvironment const & t_Environment) - { - this->CState::operator=(t_Environment); - this->CEnvironment::operator=(t_Environment); - m_RoomRadiationTemperature = t_Environment.m_RoomRadiationTemperature; + CIndoorEnvironment & CIndoorEnvironment::operator=(CIndoorEnvironment const & t_Environment) + { + this->CEnvironment::operator=(t_Environment); + m_RoomRadiationTemperature = t_Environment.m_RoomRadiationTemperature; - return *this; - } + return *this; + } - void CIndoorEnvironment::connectToIGULayer(std::shared_ptr const & t_IGULayer) - { - t_IGULayer->connectToBackSide(shared_from_this()); - } + void CIndoorEnvironment::connectToIGULayer(std::shared_ptr const & t_IGULayer) + { + t_IGULayer->connectToBackSide(shared_from_this()); + } - void CIndoorEnvironment::setRoomRadiationTemperature(double const t_RadiationTemperature) - { - m_RoomRadiationTemperature = t_RadiationTemperature; - resetCalculated(); - } + void CIndoorEnvironment::setRoomRadiationTemperature(double const t_RadiationTemperature) + { + m_RoomRadiationTemperature = t_RadiationTemperature; + resetCalculated(); + } - std::shared_ptr CIndoorEnvironment::clone() const - { - return cloneEnvironment(); - } + std::shared_ptr CIndoorEnvironment::clone() const + { + return cloneEnvironment(); + } - std::shared_ptr CIndoorEnvironment::cloneEnvironment() const - { - return std::make_shared(*this); - } + std::shared_ptr CIndoorEnvironment::cloneEnvironment() const + { + return std::make_shared(*this); + } - double CIndoorEnvironment::getGasTemperature() - { - assert(m_Surface.at(Side::Back) != nullptr); - return m_Surface.at(Side::Back)->getTemperature(); - } + double CIndoorEnvironment::getGasTemperature() + { + return surfaceTemperature(Side::Back); + } - double CIndoorEnvironment::calculateIRFromVariables() - { - using ConstantsData::STEFANBOLTZMANN; - return STEFANBOLTZMANN * m_Emissivity * pow(m_RoomRadiationTemperature, 4); - } + double CIndoorEnvironment::calculateIRFromVariables() + { + using ConstantsData::STEFANBOLTZMANN; + return STEFANBOLTZMANN * m_Emissivity * pow(m_RoomRadiationTemperature, 4); + } + + double CIndoorEnvironment::hcFromAirSpeed() + { + return 4 + 4 * gasSpecification.airflowProperties.m_AirSpeed; + } - void CIndoorEnvironment::calculateConvectionOrConductionFlow() + double CIndoorEnvironment::hcThermallyDriven() + { + using ConstantsData::GRAVITYCONSTANT; + + const auto tiltRadians{FenestrationCommon::radians(m_Tilt)}; + auto tMean = + getGasTemperature() + 0.25 * (surfaceTemperature(Side::Front) - getGasTemperature()); + if(tMean < 0) + tMean = 0.1; + const auto deltaTemp = std::abs(surfaceTemperature(Side::Front) - getGasTemperature()); + gasSpecification.setTemperature(tMean); + const auto aProperties = gasSpecification.gas.getGasProperties(); + const auto gr = GRAVITYCONSTANT * pow(m_Height, 3) * deltaTemp + * pow(aProperties.m_Density, 2) / (tMean * pow(aProperties.m_Viscosity, 2)); + const auto RaCrit = 2.5e5 * pow(exp(0.72 * m_Tilt) / sin(tiltRadians), 0.2); + const auto RaL = gr * aProperties.m_PrandlNumber; + auto Gnui = 0.0; + if((0.0 <= m_Tilt) && (m_Tilt < 15.0)) { - // CEnvironment::calculateConvectionOrConductionFlow(); - switch(m_HCoefficientModel) - { - case BoundaryConditionsCoeffModel::CalculateH: - { - calculateHc(); - break; - } - case BoundaryConditionsCoeffModel::HPrescribed: - { - const auto hr = getHr(); - m_ConductiveConvectiveCoeff = m_HInput - hr; - break; - } - case BoundaryConditionsCoeffModel::HcPrescribed: - { - m_ConductiveConvectiveCoeff = m_HInput; - break; - } - default: - { - throw std::runtime_error( - "Incorrect definition for convection model (Indoor environment)."); - } - } + Gnui = 0.13 * pow(RaL, 1 / 3.0); } - - void CIndoorEnvironment::calculateHc() + else if((15.0 <= m_Tilt) && (m_Tilt <= 90.0)) { - if(m_AirSpeed > 0) + if(RaL <= RaCrit) { - m_ConductiveConvectiveCoeff = 4 + 4 * m_AirSpeed; + Gnui = 0.56 * pow(RaL * sin(tiltRadians), 0.25); } else { - using ConstantsData::GRAVITYCONSTANT; - using ConstantsData::WCE_PI; - - assert(m_Surface.at(Side::Front) != nullptr); - assert(m_Surface.at(Side::Back) != nullptr); - - const auto tiltRadians = m_Tilt * WCE_PI / 180; - auto tMean = - getGasTemperature() - + 0.25 * (m_Surface.at(Side::Front)->getTemperature() - getGasTemperature()); - if(tMean < 0) - tMean = 0.1; - const auto deltaTemp = - std::abs(m_Surface.at(Side::Front)->getTemperature() - getGasTemperature()); - m_Gas.setTemperatureAndPressure(tMean, m_Pressure); - const auto aProperties = m_Gas.getGasProperties(); - const auto gr = GRAVITYCONSTANT * pow(m_Height, 3) * deltaTemp - * pow(aProperties.m_Density, 2) - / (tMean * pow(aProperties.m_Viscosity, 2)); - const auto RaCrit = 2.5e5 * pow(exp(0.72 * m_Tilt) / sin(tiltRadians), 0.2); - const auto RaL = gr * aProperties.m_PrandlNumber; - auto Gnui = 0.0; - if((0.0 <= m_Tilt) && (m_Tilt < 15.0)) - { - Gnui = 0.13 * pow(RaL, 1 / 3.0); - } - else if((15.0 <= m_Tilt) && (m_Tilt <= 90.0)) - { - if(RaL <= RaCrit) - { - Gnui = 0.56 * pow(RaL * sin(tiltRadians), 0.25); - } - else - { - Gnui = 0.13 * (pow(RaL, 1 / 3.0) - pow(RaCrit, 1 / 3.0)) - + 0.56 * pow(RaCrit * sin(tiltRadians), 0.25); - } - } - else if((90.0 < m_Tilt) && (m_Tilt <= 179.0)) - { - Gnui = 0.56 * pow(RaL * sin(tiltRadians), 0.25); - } - else if((179.0 < m_Tilt) && (m_Tilt <= 180.0)) - { - Gnui = 0.58 * pow(RaL, 1 / 3.0); - } - m_ConductiveConvectiveCoeff = Gnui * aProperties.m_ThermalConductivity / m_Height; + Gnui = 0.13 * (pow(RaL, 1 / 3.0) - pow(RaCrit, 1 / 3.0)) + + 0.56 * pow(RaCrit * sin(tiltRadians), 0.25); } } - - double CIndoorEnvironment::getHr() + else if((90.0 < m_Tilt) && (m_Tilt <= 179.0)) { - assert(m_Surface.at(Side::Front) != nullptr); - return getRadiationFlow() - / (getRadiationTemperature() - m_Surface.at(Side::Front)->getTemperature()); + Gnui = 0.56 * pow(RaL * sin(tiltRadians), 0.25); } - - void CIndoorEnvironment::setIRFromEnvironment(double const t_IR) + else if((179.0 < m_Tilt) && (m_Tilt <= 180.0)) { - assert(m_Surface.at(Side::Back) != nullptr); - m_Surface.at(Side::Back)->setJ(t_IR); + Gnui = 0.58 * pow(RaL, 1 / 3.0); } + return Gnui * aProperties.m_ThermalConductivity / m_Height; + } - double CIndoorEnvironment::getIRFromEnvironment() const - { - assert(m_Surface.at(Side::Back) != nullptr); - return m_Surface.at(Side::Back)->J(); - } + double CIndoorEnvironment::calculateHc() + { + return (gasSpecification.airflowProperties.m_AirSpeed > 0) ? hcFromAirSpeed() + : hcThermallyDriven(); + } - double CIndoorEnvironment::getRadiationTemperature() const - { - return m_RoomRadiationTemperature; - } - } // namespace ISO15099 -} // namespace Tarcog + double CIndoorEnvironment::getHr() + { + return getRadiationFlow() / (getRadiationTemperature() - surfaceTemperature(Side::Front)); + } + + void CIndoorEnvironment::setIRFromEnvironment(double const t_IR) + { + m_Surface.at(Side::Back)->setJ(t_IR); + } + + double CIndoorEnvironment::getIRFromEnvironment() const + { + return J(Side::Back); + } + + double CIndoorEnvironment::getRadiationTemperature() const + { + return m_RoomRadiationTemperature; + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/IndoorEnvironment.hpp b/src/Tarcog/src/IndoorEnvironment.hpp index 2df99421..d6b5c812 100644 --- a/src/Tarcog/src/IndoorEnvironment.hpp +++ b/src/Tarcog/src/IndoorEnvironment.hpp @@ -1,44 +1,39 @@ -#ifndef TARINDOORENVIRONMENT_H -#define TARINDOORENVIRONMENT_H +#pragma once #include "Environment.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + class CIndoorEnvironment : public CEnvironment { - class CIndoorEnvironment : public CEnvironment - { - public: - CIndoorEnvironment(double t_AirTemperature, double t_Pressure = 101325); - CIndoorEnvironment(const CIndoorEnvironment & t_Indoor); - CIndoorEnvironment & operator=(const CIndoorEnvironment & t_Environment); - - void connectToIGULayer(const std::shared_ptr & t_IGULayer) override; - - void setRoomRadiationTemperature(double t_RadiationTemperature); + public: + CIndoorEnvironment(double t_AirTemperature, double t_Pressure = 101325); + CIndoorEnvironment(const CIndoorEnvironment & t_Indoor); + CIndoorEnvironment & operator=(const CIndoorEnvironment & t_Environment); - std::shared_ptr clone() const override; - std::shared_ptr cloneEnvironment() const override; + void connectToIGULayer(const std::shared_ptr & t_IGULayer) override; - private: - double getGasTemperature() override; - double calculateIRFromVariables() override; - void calculateConvectionOrConductionFlow() override; + void setRoomRadiationTemperature(double t_RadiationTemperature); - void calculateHc(); - double getHr() override; + std::shared_ptr clone() const override; + std::shared_ptr cloneEnvironment() const override; - void setIRFromEnvironment(double t_IR) override; - double getIRFromEnvironment() const override; + private: + double getGasTemperature() override; + double calculateIRFromVariables() override; - double getRadiationTemperature() const override; + [[nodiscard]] double hcFromAirSpeed(); + [[nodiscard]] double hcThermallyDriven(); + [[nodiscard]] double calculateHc() override; + [[nodiscard]] double getHr() override; - double m_RoomRadiationTemperature; - }; + void setIRFromEnvironment(double t_IR) override; + double getIRFromEnvironment() const override; - } // namespace ISO15099 + double getRadiationTemperature() const override; -} // namespace Tarcog + double m_RoomRadiationTemperature{}; + }; -#endif +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/LayerInterfaces.cpp b/src/Tarcog/src/LayerInterfaces.cpp index ab010bf9..a264b74e 100644 --- a/src/Tarcog/src/LayerInterfaces.cpp +++ b/src/Tarcog/src/LayerInterfaces.cpp @@ -1,221 +1,46 @@ -#include -#include - #include "LayerInterfaces.hpp" -#include "Surface.hpp" -#include "TarcogConstants.hpp" -#include "WCEGases.hpp" -#include "WCECommon.hpp" - -using FenestrationCommon::Side; -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 - { - ////////////////////////////////////////////////////////////////////////// - /// CLayerGeometry - ////////////////////////////////////////////////////////////////////////// - - CLayerGeometry::CLayerGeometry() : - m_Width(TarcogConstants::DEFAULT_WINDOW_WIDTH), - m_Height(TarcogConstants::DEFAULT_WINDOW_HEIGHT), - m_Tilt(TarcogConstants::DEFAULT_TILT) - {} - - void CLayerGeometry::setWidth(double const t_Width) - { - m_Width = t_Width; - resetCalculated(); - } - - void CLayerGeometry::setHeight(double const t_Height) - { - m_Height = t_Height; - resetCalculated(); - } - - void CLayerGeometry::setTilt(double const t_Tilt) - { - m_Tilt = t_Tilt; - resetCalculated(); - } - - ////////////////////////////////////////////////////////////////////////// - /// CLayerHeatFlow - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + /// CLayerHeatFlow + ////////////////////////////////////////////////////////////////////////// - CLayerHeatFlow::CLayerHeatFlow() : m_ConductiveConvectiveCoeff(0), m_LayerGainFlow(0) - { - m_Surface[Side::Front] = nullptr; - m_Surface[Side::Back] = nullptr; - } - - CLayerHeatFlow::CLayerHeatFlow(CLayerHeatFlow const & t_Layer) : CState(t_Layer) - { - operator=(t_Layer); - } - - CLayerHeatFlow & CLayerHeatFlow::operator=(CLayerHeatFlow const & t_Layer) - { - this->CState::operator=(t_Layer); - m_ConductiveConvectiveCoeff = t_Layer.m_ConductiveConvectiveCoeff; - m_LayerGainFlow = t_Layer.m_LayerGainFlow; - for(auto aSide : FenestrationCommon::EnumSide()) - { - const auto aSurface = t_Layer.m_Surface.at(aSide); - if(aSurface != nullptr) - { - m_Surface[aSide] = aSurface->clone(); - } - } - - return *this; - } - - double CLayerHeatFlow::getHeatFlow() - { - return getRadiationFlow() + getConvectionConductionFlow(); - } - - double CLayerHeatFlow::getGainFlow() - { - calculateLayerHeatFlow(); - return m_LayerGainFlow; - } + double HeatFlowLayer::getGainFlow() + { + calculateLayerHeatFlow(); + return m_LayerGainFlow; + } - double CLayerHeatFlow::getConductionConvectionCoefficient() - { - calculateLayerHeatFlow(); - return m_ConductiveConvectiveCoeff; - } + double HeatFlowLayer::getConductionConvectionCoefficient() + { + calculateLayerHeatFlow(); + return m_ConductiveConvectiveCoeff; + } - double CLayerHeatFlow::getRadiationFlow() + void HeatFlowLayer::calculateLayerHeatFlow() + { + if(!isCalculated()) { calculateRadiationFlow(); - assert(m_Surface.at(Side::Front) != nullptr); - assert(m_Surface.at(Side::Back) != nullptr); - return m_Surface.at(Side::Back)->J() - m_Surface.at(Side::Front)->J(); + calculateConvectionOrConductionFlow(); } + setCalculated(); + } - double CLayerHeatFlow::getConvectionConductionFlow() - { - calculateLayerHeatFlow(); - assert(m_Surface.at(Side::Front) != nullptr); - assert(m_Surface.at(Side::Back) != nullptr); - return (m_Surface.at(Side::Back)->getTemperature() - - m_Surface.at(Side::Front)->getTemperature()) - * m_ConductiveConvectiveCoeff; - } - - void CLayerHeatFlow::calculateLayerHeatFlow() - { - if(!isCalculated()) - { - calculateRadiationFlow(); - calculateConvectionOrConductionFlow(); - } - setCalculated(); - } - - bool CLayerHeatFlow::areSurfacesInitalized() const - { - auto areInitialized = (m_Surface.size() == 2); - if(areInitialized) - { - areInitialized = - m_Surface.at(Side::Front) != nullptr && m_Surface.at(Side::Back) != nullptr; - } - return areInitialized; - } - - std::shared_ptr CLayerHeatFlow::getSurface(Side const t_Position) const - { - return m_Surface.at(t_Position); - } - - void CLayerHeatFlow::setSurface(std::shared_ptr t_Surface, Side const t_Position) - { - m_Surface[t_Position] = t_Surface; - if(m_Surface.size() == 2) - { - resetCalculated(); - } - } - - SealedGapProperties::SealedGapProperties(double t_Temperature, double t_Pressure) : - temperature(t_Temperature), pressure(t_Pressure) - {} - - ////////////////////////////////////////////////////////////////////////// - /// CGasLayer - ////////////////////////////////////////////////////////////////////////// - - CGasLayer::CGasLayer() : - m_Pressure(0), - m_AirSpeed(0), - m_AirVerticalDirection(AirVerticalDirection::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_IsVentilationForced(false) - {} - - CGasLayer::CGasLayer(double const t_Pressure, - double const t_AirSpeed, - AirVerticalDirection const t_AirVerticalDirection) : - m_Pressure(t_Pressure), - m_AirSpeed(t_AirSpeed), - m_AirVerticalDirection(t_AirVerticalDirection), - m_AirHorizontalDirection(AirHorizontalDirection::None), - m_IsVentilationForced(false) - {} - - 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_IsVentilationForced(false) - {} - - 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) - {} - - double CGasLayer::getPressure() - { - return m_Pressure; - } - - void CGasLayer::setSealedGapProperties(double t_Temperature, double t_Pressure) - { - m_SealedGapProperties = SealedGapProperties(t_Temperature, t_Pressure); - } - - bool CGasLayer::isVentilationForced() const - { - return m_IsVentilationForced; - } + void HeatFlowLayer::resetCalculated() + { + m_IsCalculated = false; + } - void CGasLayer::initializeStateVariables() - { - m_Gas.setTemperatureAndPressure(getGasTemperature(), m_Pressure); - } - } // namespace ISO15099 + void HeatFlowLayer::setCalculated() + { + m_IsCalculated = true; + } -} // namespace Tarcog + bool HeatFlowLayer::isCalculated() + { + return m_IsCalculated; + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/LayerInterfaces.hpp b/src/Tarcog/src/LayerInterfaces.hpp index 8ced6229..f6a19f49 100644 --- a/src/Tarcog/src/LayerInterfaces.hpp +++ b/src/Tarcog/src/LayerInterfaces.hpp @@ -1,128 +1,28 @@ -#ifndef LAYERINTERFACES_H -#define LAYERINTERFACES_H +#pragma once -#include -#include - -#include "WCECommon.hpp" -#include "WCEGases.hpp" - -namespace FenestrationCommon -{ - enum class Side; -} - -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + class HeatFlowLayer { - class Surface; - - class CLayerGeometry : public virtual FenestrationCommon::CState - { - public: - CLayerGeometry(); - - virtual void setWidth(double t_Width) final; - virtual void setHeight(double t_Height) final; - virtual void setTilt(double t_Tilt) final; - - protected: - double m_Width; - double m_Height; - double m_Tilt; - }; - - class CLayerHeatFlow : public virtual FenestrationCommon::CState - { - public: - CLayerHeatFlow(); - - CLayerHeatFlow(const CLayerHeatFlow & t_Layer); - CLayerHeatFlow & operator=(const CLayerHeatFlow & t_Layer); - virtual double getHeatFlow() final; - virtual double getGainFlow() final; - virtual double getConductionConvectionCoefficient() final; - virtual double getRadiationFlow(); - virtual double getConvectionConductionFlow() final; - virtual std::shared_ptr - getSurface(FenestrationCommon::Side t_Position) const final; - virtual void setSurface(std::shared_ptr t_Surface, - FenestrationCommon::Side t_Position) final; - - protected: - virtual void calculateLayerHeatFlow() final; - virtual void calculateRadiationFlow() = 0; - virtual void calculateConvectionOrConductionFlow() = 0; - - protected: - bool areSurfacesInitalized() const; - - std::map> m_Surface; - double m_ConductiveConvectiveCoeff; - double m_LayerGainFlow; - }; - - enum class AirVerticalDirection - { - None, - Up, - Down - }; - - enum class AirHorizontalDirection - { - None, - Leeward, - Windward - }; - - struct SealedGapProperties - { - SealedGapProperties(double t_Temperature, double t_Pressure); - double temperature; - double pressure; - }; - - class CGasLayer : public virtual FenestrationCommon::CState - { - 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 Gases::CGas & t_Gas); - - virtual double getPressure(); - - void setSealedGapProperties(double t_Temperature, double t_Pressure); - - [[nodiscard]] bool isVentilationForced() const; - - virtual double getGasTemperature() = 0; - - protected: - void initializeStateVariables() override; + public: + virtual void calculateLayerHeatFlow() final; - double m_Pressure; - double m_AirSpeed; - AirVerticalDirection m_AirVerticalDirection; - AirHorizontalDirection m_AirHorizontalDirection; - bool m_IsVentilationForced; + virtual double getGainFlow() final; + virtual double getConductionConvectionCoefficient() final; - // Gap by default will not be considered to be sealed. If not sealed then - // pressure will be considered to be m_Pressure; - std::optional m_SealedGapProperties{std::nullopt}; + virtual void resetCalculated() final; + virtual void setCalculated() final; + virtual bool isCalculated() final; - Gases::CGas m_Gas; - }; + protected: + virtual void calculateRadiationFlow() = 0; + virtual void calculateConvectionOrConductionFlow() = 0; - } // namespace ISO15099 + double m_ConductiveConvectiveCoeff{0}; + double m_LayerGainFlow{0}; -} // namespace Tarcog + private: + bool m_IsCalculated{false}; + }; -#endif +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Layers.cpp b/src/Tarcog/src/Layers.cpp index f2a2e14c..efb04ad1 100644 --- a/src/Tarcog/src/Layers.cpp +++ b/src/Tarcog/src/Layers.cpp @@ -8,116 +8,110 @@ #include "EffectiveOpenness.hpp" #include "IGUVentilatedGapLayer.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + std::shared_ptr Layers::solid(const double thickness, + const double conductivity, + const double frontEmissivity, + const double frontIRTransmittance, + const double backEmissivity, + const double backIRTransmittance) { - std::shared_ptr Layers::solid(const double thickness, - const double conductivity, - const double frontEmissivity, - const double frontIRTransmittance, - const double backEmissivity, - const double backIRTransmittance) - { - return std::make_shared( - thickness, - conductivity, - std::make_shared(frontEmissivity, frontIRTransmittance), - std::make_shared(backEmissivity, backIRTransmittance)); - } + return std::make_shared( + thickness, + conductivity, + std::make_shared(frontEmissivity, frontIRTransmittance), + std::make_shared(backEmissivity, backIRTransmittance)); + } - std::shared_ptr Layers::gap(const double thickness, const double pressure) - { - return std::make_shared(thickness, pressure); - } + std::shared_ptr Layers::gap(const double thickness, const double pressure) + { + return std::make_shared(thickness, pressure); + } - std::shared_ptr - Layers::gap(double thickness, const Gases::CGas & gas, double pressure) - { - return std::make_shared(thickness, pressure, gas); - } + std::shared_ptr + Layers::gap(double thickness, const Gases::CGas & gas, double pressure) + { + return std::make_shared(thickness, pressure, gas); + } - std::shared_ptr - Layers::forcedVentilationGap(const std::shared_ptr & gap, - double forcedVentilationAirSpeed, - double forcedVentilationAirTemperature) - { - return std::make_shared( - gap, forcedVentilationAirTemperature, forcedVentilationAirSpeed); - } + std::shared_ptr + Layers::forcedVentilationGap(const std::shared_ptr & gap, + double forcedVentilationAirSpeed, + double forcedVentilationAirTemperature) + { + return std::make_shared( + gap, forcedVentilationAirTemperature, forcedVentilationAirSpeed); + } - std::shared_ptr Layers::updateMaterialData( - const std::shared_ptr & layer, double density, double youngsModulus) + std::shared_ptr Layers::updateMaterialData( + const std::shared_ptr & layer, double density, double youngsModulus) + { + // Deflection cannot be applied to shading layers + if(std::dynamic_pointer_cast(layer) == nullptr) { - // Deflection cannot be applied to shading layers - if(std::dynamic_pointer_cast(layer) == nullptr) - { - static const double poissonRatio{0.22}; - return std::make_shared( - *layer, youngsModulus, poissonRatio, density); - } - else - { - return layer; - } + static const double poissonRatio{0.22}; + return std::make_shared( + *layer, youngsModulus, poissonRatio, density); } - - std::shared_ptr - Layers::shading(double thickness, - double conductivity, - EffectiveLayers::EffectiveOpenness effectiveOpenness, - double frontEmissivity, - double frontIRTransmittance, - double backEmissivity, - double backIRTransmittance) + else { - if(effectiveOpenness.isClosed()) - { - return solid(thickness, - conductivity, - frontEmissivity, - frontIRTransmittance, - backEmissivity, - backIRTransmittance); - } - - return std::make_shared( - thickness, - conductivity, - CShadeOpenings(effectiveOpenness.Atop, - effectiveOpenness.Abot, - effectiveOpenness.Al, - effectiveOpenness.Ar, - effectiveOpenness.Ah, - effectiveOpenness.FrontPorosity), - std::make_shared(frontEmissivity, frontIRTransmittance), - std::make_shared(backEmissivity, backIRTransmittance)); + return layer; } + } - std::shared_ptr Layers::sealedLayer(double thickness, - double conductivity, - double frontEmissivity, - double frontIRTransmittance, - double backEmissivity, - double backIRTransmittance) + std::shared_ptr + Layers::shading(double thickness, + double conductivity, + EffectiveLayers::EffectiveOpenness effectiveOpenness, + double frontEmissivity, + double frontIRTransmittance, + double backEmissivity, + double backIRTransmittance) + { + if(effectiveOpenness.isClosed()) { - return std::make_shared( - thickness, - conductivity, - CShadeOpenings(), - std::make_shared(frontEmissivity, frontIRTransmittance), - std::make_shared(backEmissivity, backIRTransmittance)); + return solid(thickness, + conductivity, + frontEmissivity, + frontIRTransmittance, + backEmissivity, + backIRTransmittance); } - std::shared_ptr - Layers::addCircularPillar(const std::shared_ptr & gap, - double conductivity, - double spacing, - double radius) - { - return std::make_shared(*gap, conductivity, spacing, radius); - } + return std::make_shared( + thickness, + conductivity, + CShadeOpenings(effectiveOpenness.Atop, + effectiveOpenness.Abot, + effectiveOpenness.Al, + effectiveOpenness.Ar, + effectiveOpenness.Ah, + effectiveOpenness.FrontPorosity), + std::make_shared(frontEmissivity, frontIRTransmittance), + std::make_shared(backEmissivity, backIRTransmittance)); + } - } // namespace ISO15099 + std::shared_ptr Layers::sealedLayer(double thickness, + double conductivity, + double frontEmissivity, + double frontIRTransmittance, + double backEmissivity, + double backIRTransmittance) + { + return std::make_shared( + thickness, + conductivity, + CShadeOpenings(), + std::make_shared(frontEmissivity, frontIRTransmittance), + std::make_shared(backEmissivity, backIRTransmittance)); + } + + std::shared_ptr Layers::addCircularPillar( + const std::shared_ptr & gap, double conductivity, double spacing, double radius) + { + return std::make_shared(*gap, conductivity, spacing, radius); + } -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/Layers.hpp b/src/Tarcog/src/Layers.hpp index f4df45d4..9b06b211 100644 --- a/src/Tarcog/src/Layers.hpp +++ b/src/Tarcog/src/Layers.hpp @@ -8,63 +8,59 @@ #include "TarcogConstants.hpp" #include "BaseShade.hpp" -namespace Tarcog -{ - namespace ISO15099 - { - class CIGUSolidLayer; - class CIGUGapLayer; +namespace Tarcog::ISO15099 +{ + class CIGUSolidLayer; - class Layers - { - public: - static std::shared_ptr solid(double thickness, - double conductivity, - double frontEmissivity = 0.84, - double frontIRTransmittance = 0.0, - double backEmissivity = 0.84, - double backIRTransmittance = 0.0); + class CIGUGapLayer; - static std::shared_ptr - updateMaterialData(const std::shared_ptr & layer, - double density = MaterialConstants::GLASSDENSITY, - double youngsModulus = DeflectionConstants::YOUNGSMODULUS); + class Layers + { + public: + static std::shared_ptr solid(double thickness, + double conductivity, + double frontEmissivity = 0.84, + double frontIRTransmittance = 0.0, + double backEmissivity = 0.84, + double backIRTransmittance = 0.0); - static std::shared_ptr - shading(double thickness, - double conductivity, - EffectiveLayers::EffectiveOpenness effectiveOpenness = - EffectiveLayers::EffectiveOpenness(0, 0, 0, 0, 0, 0), - double frontEmissivity = 0.84, - double frontIRTransmittance = 0.0, - double backEmissivity = 0.84, - double backIRTransmittance = 0.0); + static std::shared_ptr + updateMaterialData(const std::shared_ptr & layer, + double density = MaterialConstants::GLASSDENSITY, + double youngsModulus = DeflectionConstants::YOUNGSMODULUS); - static std::shared_ptr - sealedLayer(double thickness, - double conductivity, - double frontEmissivity = 0.84, - double frontIRTransmittance = 0.0, - double backEmissivity = 0.84, - double backIRTransmittance = 0.0); + static std::shared_ptr + shading(double thickness, + double conductivity, + EffectiveLayers::EffectiveOpenness effectiveOpenness = + EffectiveLayers::EffectiveOpenness(0, 0, 0, 0, 0, 0), + double frontEmissivity = 0.84, + double frontIRTransmittance = 0.0, + double backEmissivity = 0.84, + double backIRTransmittance = 0.0); - static std::shared_ptr gap(double thickness, double pressure = 101325); - static std::shared_ptr - gap(double thickness, const Gases::CGas & gas, double pressure = 101325); + static std::shared_ptr sealedLayer(double thickness, + double conductivity, + double frontEmissivity = 0.84, + double frontIRTransmittance = 0.0, + double backEmissivity = 0.84, + double backIRTransmittance = 0.0); - static std::shared_ptr - forcedVentilationGap(const std::shared_ptr & gap, - double forcedVentilationAirSpeed, - double forcedVentilationAirTemperature); + static std::shared_ptr gap(double thickness, double pressure = 101325); + static std::shared_ptr + gap(double thickness, const Gases::CGas & gas, double pressure = 101325); - static std::shared_ptr - addCircularPillar(const std::shared_ptr & gap, - double conductivity, - double spacing, - double radius); - }; + static std::shared_ptr + forcedVentilationGap(const std::shared_ptr & gap, + double forcedVentilationAirSpeed, + double forcedVentilationAirTemperature); - } // namespace ISO15099 + static std::shared_ptr + addCircularPillar(const std::shared_ptr & gap, + double conductivity, + double spacing, + double radius); + }; -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/NonLinearSolver.cpp b/src/Tarcog/src/NonLinearSolver.cpp index 302526a4..0cace09a 100644 --- a/src/Tarcog/src/NonLinearSolver.cpp +++ b/src/Tarcog/src/NonLinearSolver.cpp @@ -2,117 +2,113 @@ #include #include -#include "WCECommon.hpp" +#include #include "NonLinearSolver.hpp" #include "TarcogConstants.hpp" -#include "HeatFlowBalance.hpp" #include "IGU.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + CNonLinearSolver::CNonLinearSolver(CIGU & t_IGU, const size_t numberOfIterations) : + m_IGU(t_IGU), + m_QBalance(m_IGU), + m_Tolerance(IterationConstants::CONVERGENCE_TOLERANCE), + m_Iterations(numberOfIterations), + m_RelaxParam(IterationConstants::RELAXATION_PARAMETER_MAX), + m_SolutionTolerance(0) + {} + + double CNonLinearSolver::calculateTolerance(std::vector const & t_Solution) const { - CNonLinearSolver::CNonLinearSolver(CIGU & t_IGU, const size_t numberOfIterations) : - m_IGU(t_IGU), - m_QBalance(m_IGU), - m_Tolerance(IterationConstants::CONVERGENCE_TOLERANCE), - m_Iterations(numberOfIterations), - m_RelaxParam(IterationConstants::RELAXATION_PARAMETER_MAX), - m_SolutionTolerance(0) - {} - - double CNonLinearSolver::calculateTolerance(std::vector const & t_Solution) const + assert(t_Solution.size() == m_IGUState.size()); + auto aError = std::abs(t_Solution[0] - m_IGUState[0]); + for(size_t i = 1; i < m_IGUState.size(); ++i) { - assert(t_Solution.size() == m_IGUState.size()); - auto aError = std::abs(t_Solution[0] - m_IGUState[0]); - for(size_t i = 1; i < m_IGUState.size(); ++i) - { - aError = std::max(aError, std::abs(t_Solution[i] - m_IGUState[i])); - } - return aError; + aError = std::max(aError, std::abs(t_Solution[i] - m_IGUState[i])); } + return aError; + } - void CNonLinearSolver::estimateNewState(std::vector const & t_Solution) + void CNonLinearSolver::estimateNewState(std::vector const & t_Solution) + { + assert(t_Solution.size() == m_IGUState.size()); + for(size_t i = 0; i < m_IGUState.size(); ++i) { - assert(t_Solution.size() == m_IGUState.size()); - for(size_t i = 0; i < m_IGUState.size(); ++i) - { - m_IGUState[i] = m_RelaxParam * t_Solution[i] + (1 - m_RelaxParam) * m_IGUState[i]; - } + m_IGUState[i] = m_RelaxParam * t_Solution[i] + (1 - m_RelaxParam) * m_IGUState[i]; } + } - void CNonLinearSolver::setTolerance(double const t_Tolerance) - { - m_Tolerance = t_Tolerance; - } + void CNonLinearSolver::setTolerance(double const t_Tolerance) + { + m_Tolerance = t_Tolerance; + } - size_t CNonLinearSolver::getNumOfIterations() const - { - return m_Iterations; - } + size_t CNonLinearSolver::getNumOfIterations() const + { + return m_Iterations; + } - void CNonLinearSolver::solve() - { - m_IGUState = m_IGU.getState(); - std::vector initialState(m_IGUState); - std::vector bestSolution(m_IGUState.size()); - auto achievedTolerance = std::numeric_limits::max(); - m_SolutionTolerance = achievedTolerance; + void CNonLinearSolver::solve() + { + m_IGUState = m_IGU.getState(); + std::vector initialState(m_IGUState); + std::vector bestSolution(m_IGUState.size()); + auto achievedTolerance = std::numeric_limits::max(); + m_SolutionTolerance = achievedTolerance; - m_Iterations = 0; - bool iterate = true; + m_Iterations = 0; + bool iterate = true; - while(iterate) - { - ++m_Iterations; - std::vector aSolution = m_QBalance.calcBalanceMatrix(); + while(iterate) + { + ++m_Iterations; + std::vector aSolution = m_QBalance.calcBalanceMatrix(); - m_IGU.precalculateLayerStates(); - achievedTolerance = calculateTolerance(aSolution); + m_IGU.precalculateLayerStates(); + achievedTolerance = calculateTolerance(aSolution); - estimateNewState(aSolution); + estimateNewState(aSolution); - m_IGU.setState(m_IGUState); + m_IGU.setState(m_IGUState); - m_IGU.updateDeflectionState(); + m_IGU.updateDeflectionState(); - if(achievedTolerance < m_SolutionTolerance) - { - initialState = m_IGUState; - m_SolutionTolerance = std::min(achievedTolerance, m_SolutionTolerance); - bestSolution = m_IGUState; - } + if(achievedTolerance < m_SolutionTolerance) + { + initialState = m_IGUState; + m_SolutionTolerance = std::min(achievedTolerance, m_SolutionTolerance); + bestSolution = m_IGUState; + } - if(m_Iterations > IterationConstants::NUMBER_OF_STEPS) - { - m_Iterations = 0; - m_RelaxParam -= IterationConstants::RELAXATION_PARAMETER_STEP; + if(m_Iterations > IterationConstants::NUMBER_OF_STEPS) + { + m_Iterations = 0; + m_RelaxParam -= IterationConstants::RELAXATION_PARAMETER_STEP; - m_IGU.setState(initialState); - m_IGUState = initialState; - } + m_IGU.setState(initialState); + m_IGUState = initialState; + } - iterate = achievedTolerance > m_Tolerance; + iterate = achievedTolerance > m_Tolerance; - if(m_RelaxParam < IterationConstants::RELAXATION_PARAMETER_MIN) - { - iterate = false; - } + if(m_RelaxParam < IterationConstants::RELAXATION_PARAMETER_MIN) + { + iterate = false; } - m_IGUState = bestSolution; } + m_IGUState = bestSolution; + } - double CNonLinearSolver::solutionTolerance() const - { - return m_SolutionTolerance; - } - - bool CNonLinearSolver::isToleranceAchieved() const - { - return m_SolutionTolerance < m_Tolerance; - } + double CNonLinearSolver::solutionTolerance() const + { + return m_SolutionTolerance; + } - } // namespace ISO15099 + bool CNonLinearSolver::isToleranceAchieved() const + { + return m_SolutionTolerance < m_Tolerance; + } -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/NusseltNumber.cpp b/src/Tarcog/src/NusseltNumber.cpp index 175184a5..e3fc3443 100644 --- a/src/Tarcog/src/NusseltNumber.cpp +++ b/src/Tarcog/src/NusseltNumber.cpp @@ -3,144 +3,135 @@ #include #include #include -#include + +#include #include "NusseltNumber.hpp" -#include "WCEGases.hpp" -#include "WCECommon.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + double CNusseltNumberStrategy::pos(double const t_Value) const + { + return (t_Value + std::abs(t_Value)) / 2; + } + + double CNusseltNumberStrategy::calculate(double const, double const, double const) + { + return 0; + } + + double CNusseltNumber0To60::calculate(double const t_Tilt, double const t_Ra, double const) + { + // if(t_Ra > 1e5) + //{ + // throw std::runtime_error("Rayleigh number out of range in Nusselt num. calc. for " + // "gaps (angle between 0 and 60 deg)."); + //} + + double subNu1 = 1 - 1708 / (t_Ra * cos(t_Tilt)); + subNu1 = pos(subNu1); + const double subNu2 = 1 - (1708 * pow(sin(1.8 * t_Tilt), 1.6)) / (t_Ra * cos(t_Tilt)); + double subNu3 = pow(t_Ra * cos(t_Tilt) / 5830, 1 / 3.0) - 1; + subNu3 = pos(subNu3); + const double gnu = 1 + 1.44 * subNu1 * subNu2 + subNu3; // equation 42 + + return gnu; + } + + double CNusseltNumber60::calculate(double const, double const t_Ra, double const t_Asp) { - double CNusseltNumberStrategy::pos(double const t_Value) const + double G = 0.5 / pow(1 + pow(t_Ra / 3160, 20.6), 0.1); // equation 47 + const double Nu1 = pow(1 + pow(0.0936 * pow(t_Ra, 0.314) / (1 + G), 7), + 0.1428571); // equation 45 + const double Nu2 = (0.104 + 0.175 / t_Asp) * pow(t_Ra, 0.283); // equation 46 + const double gnu = std::max(Nu1, Nu2); // equation 44 + + return gnu; + } + + double + CNusseltNumber60To90::calculate(double const t_Tilt, double const t_Ra, double const t_Asp) + { + using ConstantsData::WCE_PI; + + std::shared_ptr nusselt60 = std::make_shared(); + const double Nu60 = nusselt60->calculate(t_Tilt, t_Ra, t_Asp); + std::shared_ptr nusselt90 = std::make_shared(); + const double Nu90 = nusselt90->calculate(t_Tilt, t_Ra, t_Asp); + + // linear interpolation between 60 and 90 degrees + const double gnu = ((Nu90 - Nu60) / (90.0 - 60.0)) * (t_Tilt * 180 / WCE_PI - 60.0) + Nu60; + + return gnu; + } + + double CNusseltNumber90::calculate(double const, double const t_Ra, double const t_Asp) + { + double Nu1 = 0; + double Nu2 = 0.242 * pow(t_Ra / t_Asp, 0.272); // equation 52 + if(t_Ra > 5e4) { - return (t_Value + std::abs(t_Value)) / 2; + Nu1 = 0.0673838 * pow(t_Ra, 1 / 3.0); // equation 49 } - - double CNusseltNumberStrategy::calculate(double const, double const, double const) + else if((t_Ra > 1e4) && (t_Ra < 5e4)) { - return 0; + Nu1 = 0.028154 * pow(t_Ra, 0.4134); // equation 50 } - - double CNusseltNumber0To60::calculate(double const t_Tilt, double const t_Ra, double const) + else if(t_Ra < 1e4) { - // if(t_Ra > 1e5) - //{ - // throw std::runtime_error("Rayleigh number out of range in Nusselt num. calc. for " - // "gaps (angle between 0 and 60 deg)."); - //} - - double subNu1 = 1 - 1708 / (t_Ra * cos(t_Tilt)); - subNu1 = pos(subNu1); - const double subNu2 = 1 - (1708 * pow(sin(1.8 * t_Tilt), 1.6)) / (t_Ra * cos(t_Tilt)); - double subNu3 = pow(t_Ra * cos(t_Tilt) / 5830, 1 / 3.0) - 1; - subNu3 = pos(subNu3); - const double gnu = 1 + 1.44 * subNu1 * subNu2 + subNu3; // equation 42 - - return gnu; + Nu1 = 1 + 1.7596678e-10 * pow(t_Ra, 2.2984755); // equation 51 } + double gnu = std::max(Nu1, Nu2); // equation 48 - double CNusseltNumber60::calculate(double const, double const t_Ra, double const t_Asp) - { - double G = 0.5 / pow(1 + pow(t_Ra / 3160, 20.6), 0.1); // equation 47 - const double Nu1 = pow(1 + pow(0.0936 * pow(t_Ra, 0.314) / (1 + G), 7), - 0.1428571); // equation 45 - const double Nu2 = (0.104 + 0.175 / t_Asp) * pow(t_Ra, 0.283); // equation 46 - const double gnu = std::max(Nu1, Nu2); // equation 44 + return gnu; + } - return gnu; - } + double + CNusseltNumber90to180::calculate(double const t_Tilt, double const t_Ra, double const t_Asp) + { + std::shared_ptr nusselt90 = std::make_shared(); + const double Nu90 = nusselt90->calculate(t_Tilt, t_Ra, t_Asp); + const double gnu = 1 + (Nu90 - 1) * sin(t_Tilt); // equation 53 - double CNusseltNumber60To90::calculate(double const t_Tilt, - double const t_Ra, - double const t_Asp) - { - using ConstantsData::WCE_PI; + return gnu; + } - std::shared_ptr nusselt60 = std::make_shared(); - const double Nu60 = nusselt60->calculate(t_Tilt, t_Ra, t_Asp); - std::shared_ptr nusselt90 = std::make_shared(); - const double Nu90 = nusselt90->calculate(t_Tilt, t_Ra, t_Asp); + double + CNusseltNumber::calculate(double const t_Tilt, double const t_Ra, double const t_Asp) const + { + using ConstantsData::WCE_PI; - // linear interpolation between 60 and 90 degrees - const double gnu = - ((Nu90 - Nu60) / (90.0 - 60.0)) * (t_Tilt * 180 / WCE_PI - 60.0) + Nu60; + const double tiltRadians = t_Tilt * WCE_PI / 180; + std::unique_ptr nusseltNumber; - return gnu; + if(t_Tilt >= 0 && t_Tilt < 60) + { + nusseltNumber = std::make_unique(); } - - double CNusseltNumber90::calculate(double const, double const t_Ra, double const t_Asp) + else if(t_Tilt == 60) { - double Nu1 = 0; - double Nu2 = 0.242 * pow(t_Ra / t_Asp, 0.272); // equation 52 - if(t_Ra > 5e4) - { - Nu1 = 0.0673838 * pow(t_Ra, 1 / 3.0); // equation 49 - } - else if((t_Ra > 1e4) && (t_Ra < 5e4)) - { - Nu1 = 0.028154 * pow(t_Ra, 0.4134); // equation 50 - } - else if(t_Ra < 1e4) - { - Nu1 = 1 + 1.7596678e-10 * pow(t_Ra, 2.2984755); // equation 51 - } - double gnu = std::max(Nu1, Nu2); // equation 48 - - return gnu; + nusseltNumber = std::make_unique(); } - - double CNusseltNumber90to180::calculate(double const t_Tilt, - double const t_Ra, - double const t_Asp) + else if(t_Tilt > 60 && t_Tilt < 90) { - std::shared_ptr nusselt90 = std::make_shared(); - const double Nu90 = nusselt90->calculate(t_Tilt, t_Ra, t_Asp); - const double gnu = 1 + (Nu90 - 1) * sin(t_Tilt); // equation 53 - - return gnu; + nusseltNumber = std::make_unique(); } - - double CNusseltNumber::calculate(double const t_Tilt, - double const t_Ra, - double const t_Asp) const + else if(t_Tilt == 90) + { + nusseltNumber = std::make_unique(); + } + else if(t_Tilt > 90 && t_Tilt <= 180) + { + nusseltNumber = std::make_unique(); + } + else { - using ConstantsData::WCE_PI; - - const double tiltRadians = t_Tilt * WCE_PI / 180; - std::unique_ptr nusseltNumber; - - if(t_Tilt >= 0 && t_Tilt < 60) - { - nusseltNumber = std::make_unique(); - } - else if(t_Tilt == 60) - { - nusseltNumber = std::make_unique(); - } - else if(t_Tilt > 60 && t_Tilt < 90) - { - nusseltNumber = std::make_unique(); - } - else if(t_Tilt == 90) - { - nusseltNumber = std::make_unique(); - } - else if(t_Tilt > 90 && t_Tilt <= 180) - { - nusseltNumber = std::make_unique(); - } - else - { - std::runtime_error("Window tilt angle is out of range."); - } - - return nusseltNumber->calculate(tiltRadians, t_Ra, t_Asp); + std::runtime_error("Window tilt angle is out of range."); } + return nusseltNumber->calculate(tiltRadians, t_Ra, t_Asp); + } - } // namespace ISO15099 -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/OutdoorEnvironment.cpp b/src/Tarcog/src/OutdoorEnvironment.cpp index a7703729..ad0c1e02 100644 --- a/src/Tarcog/src/OutdoorEnvironment.cpp +++ b/src/Tarcog/src/OutdoorEnvironment.cpp @@ -1,167 +1,128 @@ - #include #include -#include -#include "WCEGases.hpp" +#include + #include "Surface.hpp" #include "TarcogConstants.hpp" #include "OutdoorEnvironment.hpp" -#include "WCECommon.hpp" using FenestrationCommon::Side; -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + COutdoorEnvironment::COutdoorEnvironment(double t_AirTemperature, + double t_AirSpeed, + double t_DirectSolarRadiation, + AirHorizontalDirection t_AirDirection, + double t_SkyTemperature, + SkyModel t_Model, + double t_Pressure, + double t_FractionClearSky) : + CEnvironment(t_Pressure, t_AirSpeed, t_AirDirection), + m_Tsky(t_SkyTemperature), + m_FractionOfClearSky(t_FractionClearSky), + m_SkyModel(t_Model) { - COutdoorEnvironment::COutdoorEnvironment(double t_AirTemperature, - double t_AirSpeed, - double t_DirectSolarRadiation, - AirHorizontalDirection t_AirDirection, - double t_SkyTemperature, - SkyModel t_Model, - double t_Pressure, - double t_FractionClearSky) : - CEnvironment(t_Pressure, t_AirSpeed, t_AirDirection), - m_Tsky(t_SkyTemperature), - m_FractionOfClearSky(t_FractionClearSky), - m_SkyModel(t_Model) - { - m_Surface[Side::Front] = std::make_shared(); - m_Surface.at(Side::Front)->setTemperature(t_AirTemperature); - m_DirectSolarRadiation = t_DirectSolarRadiation; - } + m_Surface[Side::Front] = std::make_shared(); + m_Surface.at(Side::Front)->setTemperature(t_AirTemperature); + m_DirectSolarRadiation = t_DirectSolarRadiation; + } - double COutdoorEnvironment::calculateIRFromVariables() + double COutdoorEnvironment::calculateIRFromVariables() + { + auto aEmissivity = 0.0; + switch(m_SkyModel) { - auto aEmissivity = 0.0; - switch(m_SkyModel) - { - case SkyModel::AllSpecified: - aEmissivity = m_Emissivity * pow(m_Tsky, 4) / pow(getAirTemperature(), 4); - break; - case SkyModel::TSkySpecified: - aEmissivity = pow(m_Tsky, 4) / pow(getAirTemperature(), 4); - break; - case SkyModel::Swinbank: - aEmissivity = 5.31e-13 * pow(getAirTemperature(), 6) - / (ConstantsData::STEFANBOLTZMANN * pow(getAirTemperature(), 4)); - break; - default: - throw std::runtime_error("Incorrect sky model specified."); - } - - auto radiationTemperature = 0.0; - if(m_HCoefficientModel == BoundaryConditionsCoeffModel::HPrescribed) - { - radiationTemperature = getAirTemperature(); - } - else - { - using ConstantsData::WCE_PI; - - auto fSky = (1 + cos(m_Tilt * WCE_PI / 180)) / 2; - auto fGround = 1 - fSky; - auto eZero = fGround + (1 - m_FractionOfClearSky) * fSky - + fSky * m_FractionOfClearSky * aEmissivity; - radiationTemperature = getAirTemperature() * pow(eZero, 0.25); - } - - return ConstantsData::STEFANBOLTZMANN * pow(radiationTemperature, 4); + case SkyModel::AllSpecified: + aEmissivity = m_Emissivity * pow(m_Tsky, 4) / pow(getAirTemperature(), 4); + break; + case SkyModel::TSkySpecified: + aEmissivity = pow(m_Tsky, 4) / pow(getAirTemperature(), 4); + break; + case SkyModel::Swinbank: + aEmissivity = 5.31e-13 * pow(getAirTemperature(), 6) + / (ConstantsData::STEFANBOLTZMANN * pow(getAirTemperature(), 4)); + break; + default: + throw std::runtime_error("Incorrect sky model specified."); } - void COutdoorEnvironment::connectToIGULayer(std::shared_ptr const & t_IGULayer) + auto radiationTemperature = 0.0; + if(m_HCoefficientModel == BoundaryConditionsCoeffModel::HPrescribed) { - this->connectToBackSide(t_IGULayer); - m_Surface[Side::Back] = t_IGULayer->getSurface(Side::Front); + radiationTemperature = getAirTemperature(); } - - std::shared_ptr COutdoorEnvironment::clone() const + else { - return cloneEnvironment(); - } + using ConstantsData::WCE_PI; - std::shared_ptr COutdoorEnvironment::cloneEnvironment() const - { - return std::make_shared(*this); + auto fSky = (1 + cos(m_Tilt * WCE_PI / 180)) / 2; + auto fGround = 1 - fSky; + auto eZero = fGround + (1 - m_FractionOfClearSky) * fSky + + fSky * m_FractionOfClearSky * aEmissivity; + radiationTemperature = getAirTemperature() * pow(eZero, 0.25); } - void COutdoorEnvironment::setSolarRadiation(double const t_SolarRadiation) - { - m_DirectSolarRadiation = t_SolarRadiation; - } + return ConstantsData::STEFANBOLTZMANN * pow(radiationTemperature, 4); + } - double COutdoorEnvironment::getSolarRadiation() const - { - return m_DirectSolarRadiation; - } + void COutdoorEnvironment::connectToIGULayer(std::shared_ptr const & t_IGULayer) + { + this->connectToBackSide(t_IGULayer); + m_Surface[Side::Back] = t_IGULayer->getSurface(Side::Front); + } - double COutdoorEnvironment::getGasTemperature() - { - assert(m_Surface.at(Side::Front) != nullptr); - return m_Surface.at(Side::Front)->getTemperature(); - } + std::shared_ptr COutdoorEnvironment::clone() const + { + return cloneEnvironment(); + } - void COutdoorEnvironment::calculateConvectionOrConductionFlow() - { - switch(m_HCoefficientModel) - { - case BoundaryConditionsCoeffModel::CalculateH: - { - calculateHc(); - break; - } - case BoundaryConditionsCoeffModel::HPrescribed: - { - auto hr = getHr(); - m_ConductiveConvectiveCoeff = m_HInput - hr; - break; - } - case BoundaryConditionsCoeffModel::HcPrescribed: - { - m_ConductiveConvectiveCoeff = m_HInput; - break; - } - default: - { - throw std::runtime_error( - "Incorrect definition for convection model (Outdoor environment)."); - } - } - } + std::shared_ptr COutdoorEnvironment::cloneEnvironment() const + { + return std::make_shared(*this); + } - void COutdoorEnvironment::calculateHc() - { - m_ConductiveConvectiveCoeff = 4 + 4 * m_AirSpeed; - } + void COutdoorEnvironment::setSolarRadiation(double const t_SolarRadiation) + { + m_DirectSolarRadiation = t_SolarRadiation; + } - double COutdoorEnvironment::getHr() - { - assert(m_Surface.at(Side::Back) != nullptr); - assert(m_Surface.at(Side::Front) != nullptr); - return getRadiationFlow() - / (m_Surface.at(Side::Back)->getTemperature() - getRadiationTemperature()); - } + double COutdoorEnvironment::getSolarRadiation() const + { + return m_DirectSolarRadiation; + } - double COutdoorEnvironment::getRadiationTemperature() const - { - assert(m_Surface.at(Side::Front) != nullptr); - return pow(m_Surface.at(Side::Front)->J() / ConstantsData::STEFANBOLTZMANN, 0.25); - } + double COutdoorEnvironment::getGasTemperature() + { + return surfaceTemperature(Side::Front); + } - void COutdoorEnvironment::setIRFromEnvironment(double const t_IR) - { - assert(m_Surface.at(Side::Front) != nullptr); - m_Surface.at(Side::Front)->setJ(t_IR); - } + double COutdoorEnvironment::calculateHc() + { + return 4 + 4 * gasSpecification.airflowProperties.m_AirSpeed; + } - double COutdoorEnvironment::getIRFromEnvironment() const - { - assert(m_Surface.at(Side::Front) != nullptr); - return m_Surface.at(Side::Front)->J(); - } + double COutdoorEnvironment::getHr() + { + return getRadiationFlow() + / (surfaceTemperature(Side::Back) - getRadiationTemperature()); + } - } // namespace ISO15099 + double COutdoorEnvironment::getRadiationTemperature() const + { + return pow(J(Side::Front) / ConstantsData::STEFANBOLTZMANN, 0.25); + } + + void COutdoorEnvironment::setIRFromEnvironment(double const t_IR) + { + m_Surface.at(Side::Front)->setJ(t_IR); + } + + double COutdoorEnvironment::getIRFromEnvironment() const + { + return J(Side::Front); + } -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/OutdoorEnvironment.hpp b/src/Tarcog/src/OutdoorEnvironment.hpp index 44f2ba01..44c4ccb3 100644 --- a/src/Tarcog/src/OutdoorEnvironment.hpp +++ b/src/Tarcog/src/OutdoorEnvironment.hpp @@ -1,59 +1,54 @@ -#ifndef TAROUTDOORENVIRONEMENT_H -#define TAROUTDOORENVIRONEMENT_H +#pragma once + +#include #include "TarcogConstants.hpp" #include "Environment.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + enum class SkyModel + { + AllSpecified, + TSkySpecified, + Swinbank + }; + + class COutdoorEnvironment : public CEnvironment { - enum class SkyModel - { - AllSpecified, - TSkySpecified, - Swinbank - }; - - class COutdoorEnvironment : public CEnvironment - { - public: - COutdoorEnvironment( - double t_AirTemperature, - double t_AirSpeed, - double t_DirectSolarRadiation, - AirHorizontalDirection t_AirDirection, - double t_SkyTemperature, - SkyModel t_Model, - double t_Pressure = 101325, - double t_FractionClearSky = TarcogConstants::DEFAULT_FRACTION_OF_CLEAR_SKY); - - void connectToIGULayer(const std::shared_ptr & t_IGULayer) override; - - std::shared_ptr clone() const override; - std::shared_ptr cloneEnvironment() const override; - - void setSolarRadiation(double t_SolarRadiation); - double getSolarRadiation() const; - - private: - double getGasTemperature() override; - double calculateIRFromVariables() override; - void calculateConvectionOrConductionFlow() override; - - void calculateHc(); - double getHr() override; - double getRadiationTemperature() const override; - - void setIRFromEnvironment(double t_IR) override; - double getIRFromEnvironment() const override; - - double m_Tsky; - double m_FractionOfClearSky; - SkyModel m_SkyModel; - }; - } // namespace ISO15099 - -} // namespace Tarcog - -#endif + public: + COutdoorEnvironment( + double t_AirTemperature, + double t_AirSpeed, + double t_DirectSolarRadiation, + AirHorizontalDirection t_AirDirection, + double t_SkyTemperature, + SkyModel t_Model, + double t_Pressure = 101325, + double t_FractionClearSky = TarcogConstants::DEFAULT_FRACTION_OF_CLEAR_SKY); + + void connectToIGULayer(const std::shared_ptr & t_IGULayer) override; + + std::shared_ptr clone() const override; + std::shared_ptr cloneEnvironment() const override; + + void setSolarRadiation(double t_SolarRadiation); + double getSolarRadiation() const; + + private: + double getGasTemperature() override; + double calculateIRFromVariables() override; + + double calculateHc() override; + double getHr() override; + double getRadiationTemperature() const override; + + void setIRFromEnvironment(double t_IR) override; + double getIRFromEnvironment() const override; + + double m_Tsky; + double m_FractionOfClearSky; + SkyModel m_SkyModel; + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/SingleSystem.cpp b/src/Tarcog/src/SingleSystem.cpp index 82fb8969..54a769c5 100644 --- a/src/Tarcog/src/SingleSystem.cpp +++ b/src/Tarcog/src/SingleSystem.cpp @@ -4,378 +4,368 @@ #include #include "SingleSystem.hpp" -#include "BaseLayer.hpp" -#include "BaseIGULayer.hpp" #include "IGUSolidLayer.hpp" #include "IGUGapLayer.hpp" #include "IGU.hpp" #include "OutdoorEnvironment.hpp" -#include "IndoorEnvironment.hpp" #include "Surface.hpp" #include "NonLinearSolver.hpp" -#include "WCECommon.hpp" using FenestrationCommon::Side; -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + CSingleSystem::CSingleSystem(CIGU & t_IGU, + std::shared_ptr const & t_Indoor, + std::shared_ptr const & t_Outdoor) : + m_IGU(t_IGU) { - CSingleSystem::CSingleSystem(CIGU & t_IGU, - std::shared_ptr const & t_Indoor, - std::shared_ptr const & t_Outdoor) : - m_IGU(t_IGU) + m_Environment[Environment::Indoor] = t_Indoor; + m_Environment[Environment::Outdoor] = t_Outdoor; + + + if(t_Indoor == nullptr) { - m_Environment[Environment::Indoor] = t_Indoor; - m_Environment[Environment::Outdoor] = t_Outdoor; - - - if(t_Indoor == nullptr) - { - throw std::runtime_error( - "Indoor environment has not been assigned to the system. Null value passed."); - } - - if(t_Outdoor == nullptr) - { - throw std::runtime_error( - "Outdoor environment has not been assigned to the system. Null value passed."); - } - - const auto aIndoorLayer = m_IGU.getEnvironment(Environment::Indoor); - auto aIndoor = m_Environment.at(Environment::Indoor); - aIndoor->connectToIGULayer(aIndoorLayer); - aIndoor->setTilt(m_IGU.getTilt()); - aIndoor->setWidth(m_IGU.getWidth()); - aIndoor->setHeight(m_IGU.getHeight()); - - const auto aOutdoorLayer = m_IGU.getEnvironment(Environment::Outdoor); - auto aOutdoor = m_Environment.at(Environment::Outdoor); - aOutdoor->connectToIGULayer(aOutdoorLayer); - aOutdoor->setTilt(m_IGU.getTilt()); - aOutdoor->setWidth(m_IGU.getWidth()); - aOutdoor->setHeight(m_IGU.getHeight()); - - const auto solarRadiation = t_Outdoor->getDirectSolarRadiation(); - m_IGU.setSolarRadiation(solarRadiation); - - initializeStartValues(); - - m_NonLinearSolver = std::make_shared(m_IGU); + throw std::runtime_error( + "Indoor environment has not been assigned to the system. Null value passed."); } - CSingleSystem::CSingleSystem(const CSingleSystem & t_SingleSystem) : - m_IGU(t_SingleSystem.m_IGU) + if(t_Outdoor == nullptr) { - operator=(t_SingleSystem); + throw std::runtime_error( + "Outdoor environment has not been assigned to the system. Null value passed."); } - CSingleSystem & CSingleSystem::operator=(CSingleSystem const & t_SingleSystem) - { - m_IGU = t_SingleSystem.m_IGU; - m_Environment[Environment::Indoor] = - t_SingleSystem.m_Environment.at(Environment::Indoor)->cloneEnvironment(); - const auto aLastLayer = m_IGU.getEnvironment(Environment::Indoor); - m_Environment.at(Environment::Indoor)->connectToIGULayer(aLastLayer); + const auto aIndoorLayer = m_IGU.getEnvironment(Environment::Indoor); + auto aIndoor = m_Environment.at(Environment::Indoor); + aIndoor->connectToIGULayer(aIndoorLayer); + aIndoor->setTilt(m_IGU.getTilt()); + aIndoor->setWidth(m_IGU.getWidth()); + aIndoor->setHeight(m_IGU.getHeight()); - m_Environment[Environment::Outdoor] = - t_SingleSystem.m_Environment.at(Environment::Outdoor)->cloneEnvironment(); - const auto aFirstLayer = m_IGU.getEnvironment(Environment::Outdoor); - m_Environment.at(Environment::Outdoor)->connectToIGULayer(aFirstLayer); + const auto aOutdoorLayer = m_IGU.getEnvironment(Environment::Outdoor); + auto aOutdoor = m_Environment.at(Environment::Outdoor); + aOutdoor->connectToIGULayer(aOutdoorLayer); + aOutdoor->setTilt(m_IGU.getTilt()); + aOutdoor->setWidth(m_IGU.getWidth()); + aOutdoor->setHeight(m_IGU.getHeight()); - // initializeStartValues(); + const auto solarRadiation = t_Outdoor->getDirectSolarRadiation(); + m_IGU.setSolarRadiation(solarRadiation); - m_NonLinearSolver = - std::make_shared(m_IGU, t_SingleSystem.getNumberOfIterations()); + initializeStartValues(); - return *this; - } + m_NonLinearSolver = std::make_shared(m_IGU); + } - std::vector> CSingleSystem::getSolidLayers() const - { - return m_IGU.getSolidLayers(); - } + CSingleSystem::CSingleSystem(const CSingleSystem & t_SingleSystem) : m_IGU(t_SingleSystem.m_IGU) + { + operator=(t_SingleSystem); + } - std::vector> CSingleSystem::getGapLayers() const - { - return m_IGU.getGapLayers(); - } + CSingleSystem & CSingleSystem::operator=(CSingleSystem const & t_SingleSystem) + { + m_IGU = t_SingleSystem.m_IGU; + m_Environment[Environment::Indoor] = + t_SingleSystem.m_Environment.at(Environment::Indoor)->cloneEnvironment(); + const auto aLastLayer = m_IGU.getEnvironment(Environment::Indoor); + m_Environment.at(Environment::Indoor)->connectToIGULayer(aLastLayer); - std::vector CSingleSystem::getTemperatures() const - { - return m_IGU.getTemperatures(); - } + m_Environment[Environment::Outdoor] = + t_SingleSystem.m_Environment.at(Environment::Outdoor)->cloneEnvironment(); + const auto aFirstLayer = m_IGU.getEnvironment(Environment::Outdoor); + m_Environment.at(Environment::Outdoor)->connectToIGULayer(aFirstLayer); - std::vector CSingleSystem::getRadiosities() const - { - return m_IGU.getRadiosities(); - } + // initializeStartValues(); - std::vector CSingleSystem::getMaxLayerDeflections() const - { - return m_IGU.getMaxLayerDeflections(); - } + m_NonLinearSolver = + std::make_shared(m_IGU, t_SingleSystem.getNumberOfIterations()); - std::vector CSingleSystem::getMeanLayerDeflections() const - { - return m_IGU.getMeanLayerDeflections(); - } + return *this; + } - std::vector CSingleSystem::getMaxGapWidth() const - { - return m_IGU.getMaxGapWidth(); - } + std::vector> CSingleSystem::getSolidLayers() const + { + return m_IGU.getSolidLayers(); + } - std::vector CSingleSystem::getMeanGapWidth() const - { - return m_IGU.getMeanGapWidth(); - } + std::vector> CSingleSystem::getGapLayers() const + { + return m_IGU.getGapLayers(); + } - std::vector CSingleSystem::getPanesLoad() - { - return m_IGU.getPanesLoad(); - } + std::vector CSingleSystem::getTemperatures() const + { + return m_IGU.getTemperatures(); + } - void CSingleSystem::setAppliedLoad(std::vector load) - { - m_IGU.setAppliedLoad(std::move(load)); - } + std::vector CSingleSystem::getRadiosities() const + { + return m_IGU.getRadiosities(); + } - std::shared_ptr CSingleSystem::clone() const - { - return std::make_shared(*this); - } + std::vector CSingleSystem::getMaxLayerDeflections() const + { + return m_IGU.getMaxLayerDeflections(); + } - double CSingleSystem::getHeatFlow(Environment const t_Environment) const - { - return m_Environment.at(t_Environment)->getHeatFlow(); - } + std::vector CSingleSystem::getMeanLayerDeflections() const + { + return m_IGU.getMeanLayerDeflections(); + } - double CSingleSystem::getConvectiveHeatFlow(Environment const t_Environment) const - { - return m_Environment.at(t_Environment)->getConvectionConductionFlow(); - } + std::vector CSingleSystem::getMaxGapWidth() const + { + return m_IGU.getMaxGapWidth(); + } - double CSingleSystem::getRadiationHeatFlow(Environment const t_Environment) const - { - return m_Environment.at(t_Environment)->getRadiationFlow(); - } + std::vector CSingleSystem::getMeanGapWidth() const + { + return m_IGU.getMeanGapWidth(); + } - double CSingleSystem::getHc(Environment const t_Environment) const - { - return m_Environment.at(t_Environment)->getHc(); - } + std::vector CSingleSystem::getPanesLoad() + { + return m_IGU.getPanesLoad(); + } - double CSingleSystem::getHr(Environment t_Environment) const - { - return m_Environment.at(t_Environment)->getHr();; - } + void CSingleSystem::setAppliedLoad(std::vector load) + { + m_IGU.setAppliedLoad(std::move(load)); + } - double CSingleSystem::getH(Environment t_Environment) const - { - return getHc(t_Environment) + getHr(t_Environment); - } + std::shared_ptr CSingleSystem::clone() const + { + return std::make_shared(*this); + } - double CSingleSystem::getAirTemperature(Environment const t_Environment) const - { - return m_Environment.at(t_Environment)->getAirTemperature(); - } + double CSingleSystem::getHeatFlow(Environment const t_Environment) const + { + return m_Environment.at(t_Environment)->getHeatFlow(); + } - double CSingleSystem::getVentilationFlow(Environment const t_Environment) const - { - return m_IGU.getVentilationFlow(t_Environment); - } + double CSingleSystem::getConvectiveHeatFlow(Environment const t_Environment) const + { + return m_Environment.at(t_Environment)->getConvectionConductionFlow(); + } - double CSingleSystem::getUValue() const - { - const double interiorAirTemperature = - m_Environment.at(Environment::Indoor)->getAmbientTemperature(); - const double outdoorAirTemperature = - m_Environment.at(Environment::Outdoor)->getAmbientTemperature(); + double CSingleSystem::getRadiationHeatFlow(Environment const t_Environment) const + { + return m_Environment.at(t_Environment)->getRadiationFlow(); + } - const auto ventilatedFlow{getVentilationFlow(Environment::Indoor)}; + double CSingleSystem::getHc(Environment const t_Environment) const + { + return m_Environment.at(t_Environment)->getHc(); + } - return (getHeatFlow(Environment::Indoor) + ventilatedFlow) - / (interiorAirTemperature - outdoorAirTemperature); - } + double CSingleSystem::getHr(Environment t_Environment) const + { + return m_Environment.at(t_Environment)->getHr(); + ; + } - void CSingleSystem::setTolerance(double const t_Tolerance) const - { - assert(m_NonLinearSolver != nullptr); - m_NonLinearSolver->setTolerance(t_Tolerance); - } + double CSingleSystem::getH(Environment t_Environment) const + { + return getHc(t_Environment) + getHr(t_Environment); + } - size_t CSingleSystem::getNumberOfIterations() const - { - assert(m_NonLinearSolver != nullptr); - return m_NonLinearSolver->getNumOfIterations(); - } + double CSingleSystem::getAirTemperature(Environment const t_Environment) const + { + return m_Environment.at(t_Environment)->getAirTemperature(); + } - double CSingleSystem::solutionTolarance() const - { - assert(m_NonLinearSolver != nullptr); - return m_NonLinearSolver->solutionTolerance(); - } + double CSingleSystem::getVentilationFlow(Environment const t_Environment) const + { + return m_IGU.getVentilationFlow(t_Environment); + } - bool CSingleSystem::isToleranceAchieved() const - { - assert(m_NonLinearSolver != nullptr); - return m_NonLinearSolver->isToleranceAchieved(); - } + double CSingleSystem::getUValue() const + { + const double interiorAirTemperature = + m_Environment.at(Environment::Indoor)->getAmbientTemperature(); + const double outdoorAirTemperature = + m_Environment.at(Environment::Outdoor)->getAmbientTemperature(); - void CSingleSystem::solve() const - { - assert(m_NonLinearSolver != nullptr); - m_NonLinearSolver->solve(); - } + const auto ventilatedFlow{getVentilationFlow(Environment::Indoor)}; - void CSingleSystem::initializeStartValues() - { - auto const startX = 0.001; - const auto thickness = m_IGU.getThickness() + startX + 0.01; - const auto tOut = m_Environment.at(Environment::Outdoor)->getGasTemperature(); - const auto tInd = m_Environment.at(Environment::Indoor)->getGasTemperature(); + return (getHeatFlow(Environment::Indoor) + ventilatedFlow) + / (interiorAirTemperature - outdoorAirTemperature); + } - const auto deltaTemp = (tInd - tOut) / thickness; + void CSingleSystem::setTolerance(double const t_Tolerance) const + { + assert(m_NonLinearSolver != nullptr); + m_NonLinearSolver->setTolerance(t_Tolerance); + } - auto aLayers = m_IGU.getLayers(); + size_t CSingleSystem::getNumberOfIterations() const + { + assert(m_NonLinearSolver != nullptr); + return m_NonLinearSolver->getNumOfIterations(); + } - const auto aLayer = aLayers.front(); - auto currentXPosition = startX; - auto aSurface = aLayer->getSurface(Side::Front); - auto curTemp = tOut + currentXPosition * deltaTemp; + double CSingleSystem::solutionTolarance() const + { + assert(m_NonLinearSolver != nullptr); + return m_NonLinearSolver->solutionTolerance(); + } - aSurface->initializeStart(curTemp); + bool CSingleSystem::isToleranceAchieved() const + { + assert(m_NonLinearSolver != nullptr); + return m_NonLinearSolver->isToleranceAchieved(); + } - for(const auto & layer : aLayers) - { - currentXPosition += layer->getThickness(); - curTemp = tOut + currentXPosition * deltaTemp; - aSurface = layer->getSurface(Side::Back); - aSurface->initializeStart(curTemp); - } - } + void CSingleSystem::solve() const + { + assert(m_NonLinearSolver != nullptr); + m_NonLinearSolver->solve(); + } - void CSingleSystem::setInitialGuess(const std::vector & t_Temperatures) const - { - m_IGU.setInitialGuess(t_Temperatures); - } + void CSingleSystem::initializeStartValues() + { + auto const startX = 0.001; + const auto thickness = m_IGU.getThickness() + startX + 0.01; + const auto tOut = m_Environment.at(Environment::Outdoor)->getGasTemperature(); + const auto tInd = m_Environment.at(Environment::Indoor)->getGasTemperature(); - void CSingleSystem::setSolarRadiation(double const t_SolarRadiation) - { - std::dynamic_pointer_cast(m_Environment.at(Environment::Outdoor)) - ->setSolarRadiation(t_SolarRadiation); - m_IGU.setSolarRadiation(t_SolarRadiation); - } + const auto deltaTemp = (tInd - tOut) / thickness; - double CSingleSystem::getSolarRadiation() const - { - return std::dynamic_pointer_cast( - m_Environment.at(Environment::Outdoor)) - ->getSolarRadiation(); - } + auto aLayers = m_IGU.getLayers(); - std::vector CSingleSystem::getSolidEffectiveLayerConductivities() const - { - std::vector results; - for(const auto & layer : getSolidLayers()) - { - results.emplace_back(layer->getEffectiveThermalConductivity()); - } - return results; - } + const auto aLayer = aLayers.front(); + auto currentXPosition = startX; + auto curTemp = tOut + currentXPosition * deltaTemp; - std::vector CSingleSystem::getGapEffectiveLayerConductivities() const - { - std::vector results; - for(const auto & layer : getGapLayers()) - { - results.emplace_back(layer->getEffectiveThermalConductivity()); - } - return results; - } + aLayer->initializeStart(Side::Front, curTemp); - double CSingleSystem::EffectiveConductivity() const + for(const auto & layer : aLayers) { - auto temperatures = getTemperatures(); - const auto deltaTemp = - std::abs(temperatures[0] - temperatures[temperatures.size() - 1]); - return std::abs(thickness() * getHeatFlow(Environment::Indoor) / deltaTemp); + currentXPosition += layer->getThickness(); + curTemp = tOut + currentXPosition * deltaTemp; + layer->initializeStart(Side::Back, curTemp); } + } - double CSingleSystem::thickness() const - { - double thickness{0}; - for(const auto & layer : getSolidLayers()) - { - thickness += layer->getThickness(); - } - for(const auto & gap : getGapLayers()) - { - thickness += gap->getThickness(); - } - return thickness; - } + void CSingleSystem::setInitialGuess(const std::vector & t_Temperatures) const + { + m_IGU.setInitialGuess(t_Temperatures); + } - void CSingleSystem::setAbsorptances(const std::vector & absorptances) - { - m_IGU.setAbsorptances( - absorptances, m_Environment.at(Environment::Outdoor)->getDirectSolarRadiation()); - solve(); - } + void CSingleSystem::setSolarRadiation(double const t_SolarRadiation) + { + std::dynamic_pointer_cast(m_Environment.at(Environment::Outdoor)) + ->setSolarRadiation(t_SolarRadiation); + m_IGU.setSolarRadiation(t_SolarRadiation); + } - void CSingleSystem::setWidth(double width) - { - m_IGU.setWidth(width); - } + double CSingleSystem::getSolarRadiation() const + { + return std::dynamic_pointer_cast( + m_Environment.at(Environment::Outdoor)) + ->getSolarRadiation(); + } - void CSingleSystem::setHeight(double height) + std::vector CSingleSystem::getSolidEffectiveLayerConductivities() const + { + std::vector results; + for(const auto & layer : getSolidLayers()) { - m_IGU.setHeight(height); + results.emplace_back(layer->getEffectiveThermalConductivity()); } + return results; + } - void CSingleSystem::setTilt(const double tilt) + std::vector CSingleSystem::getGapEffectiveLayerConductivities() const + { + std::vector results; + for(const auto & layer : getGapLayers()) { - m_IGU.setTilt(tilt); + results.emplace_back(layer->getEffectiveThermalConductivity()); } + return results; + } - void CSingleSystem::setInteriorAndExteriorSurfacesHeight(double height) - { - for(auto & [key, environment] : m_Environment) - { - std::ignore = key; - environment->setHeight(height); - } - } + double CSingleSystem::EffectiveConductivity() const + { + auto temperatures = getTemperatures(); + const auto deltaTemp = std::abs(temperatures[0] - temperatures[temperatures.size() - 1]); + return std::abs(thickness() * getHeatFlow(Environment::Indoor) / deltaTemp); + } - void CSingleSystem::setDeflectionProperties(const double t_Tini, - const double t_Pini) + double CSingleSystem::thickness() const + { + double thickness{0}; + for(const auto & layer : getSolidLayers()) { - m_IGU.setDeflectionProperties(t_Tini, - t_Pini, - m_Environment.at(Environment::Indoor)->getPressure(), - m_Environment.at(Environment::Outdoor)->getPressure()); - - // Need to throw previous solution off in case someone calculated CSingleSystem without - // deflection and then turns deflection on, iterations will conclude that solution is correct (Simon) - initializeStartValues(); + thickness += layer->getThickness(); } - - void CSingleSystem::setDeflectionProperties(const std::vector & measuredGapWidths) + for(const auto & gap : getGapLayers()) { - m_IGU.setDeflectionProperties(measuredGapWidths); + thickness += gap->getThickness(); } + return thickness; + } - void CSingleSystem::clearDeflection() - { - m_IGU.clearDeflection(); - } + void CSingleSystem::setAbsorptances(const std::vector & absorptances) + { + m_IGU.setAbsorptances(absorptances, + m_Environment.at(Environment::Outdoor)->getDirectSolarRadiation()); + solve(); + } + + void CSingleSystem::setWidth(double width) + { + m_IGU.setWidth(width); + } + + void CSingleSystem::setHeight(double height) + { + m_IGU.setHeight(height); + } + + void CSingleSystem::setTilt(const double tilt) + { + m_IGU.setTilt(tilt); + } - std::vector CSingleSystem::getGapPressures() const + void CSingleSystem::setInteriorAndExteriorSurfacesHeight(double height) + { + for(auto & [key, environment] : m_Environment) { - return m_IGU.getGapPressures(); + std::ignore = key; + environment->setHeight(height); } - } // namespace ISO15099 + } + + void CSingleSystem::setDeflectionProperties(const double t_Tini, const double t_Pini) + { + m_IGU.setDeflectionProperties(t_Tini, + t_Pini, + m_Environment.at(Environment::Indoor)->getPressure(), + m_Environment.at(Environment::Outdoor)->getPressure()); + + // Need to throw previous solution off in case someone calculated CSingleSystem without + // deflection and then turns deflection on, iterations will conclude that solution is + // correct (Simon) + initializeStartValues(); + } + + void CSingleSystem::setDeflectionProperties(const std::vector & measuredGapWidths) + { + m_IGU.setDeflectionProperties(measuredGapWidths); + } -} // namespace Tarcog + void CSingleSystem::clearDeflection() + { + m_IGU.clearDeflection(); + } + + std::vector CSingleSystem::getGapPressures() const + { + return m_IGU.getGapPressures(); + } +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/SingleSystem.hpp b/src/Tarcog/src/SingleSystem.hpp index cae80167..a3b2314d 100644 --- a/src/Tarcog/src/SingleSystem.hpp +++ b/src/Tarcog/src/SingleSystem.hpp @@ -1,5 +1,4 @@ -#ifndef TARCOGSINGLESYSTEM_H -#define TARCOGSINGLESYSTEM_H +#pragma once #include #include @@ -7,104 +6,97 @@ #include "IGU.hpp" -namespace Tarcog -{ - namespace ISO15099 - { - enum class Environment; - - class CBaseIGULayer; - class CIGUSolidLayer; - - class CIGUGapLayer; +namespace Tarcog::ISO15099 +{ + enum class Environment; - class CEnvironment; + class CIGUSolidLayer; - class CNonLinearSolver; + class CIGUGapLayer; - class CSingleSystem - { - public: - CSingleSystem(CIGU & t_IGU, - const std::shared_ptr & t_Indoor, - const std::shared_ptr & t_Outdoor); + class CEnvironment; - CSingleSystem(const CSingleSystem & t_SingleSystem); - CSingleSystem & operator=(const CSingleSystem & t_SingleSystem); + class CNonLinearSolver; - [[nodiscard]] std::vector> getSolidLayers() const; - [[nodiscard]] std::vector> getGapLayers() const; + class CSingleSystem + { + public: + CSingleSystem(CIGU & t_IGU, + const std::shared_ptr & t_Indoor, + const std::shared_ptr & t_Outdoor); - [[nodiscard]] std::vector getSolidEffectiveLayerConductivities() const; - [[nodiscard]] std::vector getGapEffectiveLayerConductivities() const; + CSingleSystem(const CSingleSystem & t_SingleSystem); + CSingleSystem & operator=(const CSingleSystem & t_SingleSystem); - [[nodiscard]] std::vector getTemperatures() const; - [[nodiscard]] std::vector getRadiosities() const; + [[nodiscard]] std::vector> getSolidLayers() const; + [[nodiscard]] std::vector> getGapLayers() const; - [[nodiscard]] std::vector getMaxLayerDeflections() const; - [[nodiscard]] std::vector getMeanLayerDeflections() const; - [[nodiscard]] std::vector getMaxGapWidth() const; - [[nodiscard]] std::vector getMeanGapWidth() const; - [[nodiscard]] std::vector getPanesLoad(); - void setAppliedLoad(std::vector load); + [[nodiscard]] std::vector getSolidEffectiveLayerConductivities() const; + [[nodiscard]] std::vector getGapEffectiveLayerConductivities() const; - [[nodiscard]] std::vector getGapPressures() const; + [[nodiscard]] std::vector getTemperatures() const; + [[nodiscard]] std::vector getRadiosities() const; - [[nodiscard]] std::shared_ptr clone() const; + [[nodiscard]] std::vector getMaxLayerDeflections() const; + [[nodiscard]] std::vector getMeanLayerDeflections() const; + [[nodiscard]] std::vector getMaxGapWidth() const; + [[nodiscard]] std::vector getMeanGapWidth() const; + [[nodiscard]] std::vector getPanesLoad(); + void setAppliedLoad(std::vector load); - [[nodiscard]] double getHeatFlow(Environment t_Environment) const; - [[nodiscard]] double getConvectiveHeatFlow(Environment t_Environment) const; - [[nodiscard]] double getRadiationHeatFlow(Environment t_Environment) const; - [[nodiscard]] double getHc(Environment t_Environment) const; - [[nodiscard]] double getHr(Environment t_Environment) const; - [[nodiscard]] double getH(Environment t_Environment) const; - [[nodiscard]] double getAirTemperature(Environment t_Environment) const; + [[nodiscard]] std::vector getGapPressures() const; - // If interior layer have openings, this will return heat flow from airflow - [[nodiscard]] double getVentilationFlow(Environment t_Environment) const; - [[nodiscard]] double getUValue() const; - [[nodiscard]] size_t getNumberOfIterations() const; - [[nodiscard]] double solutionTolarance() const; - [[nodiscard]] bool isToleranceAchieved() const; + [[nodiscard]] std::shared_ptr clone() const; - [[nodiscard]] double EffectiveConductivity() const; + [[nodiscard]] double getHeatFlow(Environment t_Environment) const; + [[nodiscard]] double getConvectiveHeatFlow(Environment t_Environment) const; + [[nodiscard]] double getRadiationHeatFlow(Environment t_Environment) const; + [[nodiscard]] double getHc(Environment t_Environment) const; + [[nodiscard]] double getHr(Environment t_Environment) const; + [[nodiscard]] double getH(Environment t_Environment) const; + [[nodiscard]] double getAirTemperature(Environment t_Environment) const; - // Set solution tolerance - void setTolerance(double t_Tolerance) const; - // Set intial guess for solution. - void setInitialGuess(const std::vector & t_Temperatures) const; + // If interior layer have openings, this will return heat flow from airflow + [[nodiscard]] double getVentilationFlow(Environment t_Environment) const; + [[nodiscard]] double getUValue() const; + [[nodiscard]] size_t getNumberOfIterations() const; + [[nodiscard]] double solutionTolarance() const; + [[nodiscard]] bool isToleranceAchieved() const; - void setSolarRadiation(double t_SolarRadiation); - [[nodiscard]] double getSolarRadiation() const; + [[nodiscard]] double EffectiveConductivity() const; - void solve() const; + // Set solution tolerance + void setTolerance(double t_Tolerance) const; + // Set intial guess for solution. + void setInitialGuess(const std::vector & t_Temperatures) const; - [[nodiscard]] double thickness() const; + void setSolarRadiation(double t_SolarRadiation); + [[nodiscard]] double getSolarRadiation() const; - void setAbsorptances(const std::vector & absorptances); + void solve() const; - void setWidth(double width); - void setHeight(double height); - void setTilt(double tilt); + [[nodiscard]] double thickness() const; - //! If IGU is part of the window then frame will still count in surface height. - void setInteriorAndExteriorSurfacesHeight(double height); + void setAbsorptances(const std::vector & absorptances); - void setDeflectionProperties(double t_Tini, double t_Pini); - void setDeflectionProperties(const std::vector & measuredGapWidths); + void setWidth(double width); + void setHeight(double height); + void setTilt(double tilt); - void clearDeflection(); + //! If IGU is part of the window then frame will still count in surface height. + void setInteriorAndExteriorSurfacesHeight(double height); - private: - CIGU m_IGU; - std::map> m_Environment; - std::shared_ptr m_NonLinearSolver; - void initializeStartValues(); - }; + void setDeflectionProperties(double t_Tini, double t_Pini); + void setDeflectionProperties(const std::vector & measuredGapWidths); - } // namespace ISO15099 + void clearDeflection(); -} // namespace Tarcog + private: + CIGU m_IGU; + std::map> m_Environment; + std::shared_ptr m_NonLinearSolver; + void initializeStartValues(); + }; -#endif +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/SupportPillar.cpp b/src/Tarcog/src/SupportPillar.cpp index 43a74270..fc5532fa 100644 --- a/src/Tarcog/src/SupportPillar.cpp +++ b/src/Tarcog/src/SupportPillar.cpp @@ -42,9 +42,8 @@ namespace Tarcog { using ConstantsData::WCE_PI; - auto cond1 = - std::dynamic_pointer_cast(m_PreviousLayer)->getConductivity(); - auto cond2 = std::dynamic_pointer_cast(m_NextLayer)->getConductivity(); + auto cond1 = getPreviousLayer()->getConductivity(); + auto cond2 = getNextLayer()->getConductivity(); auto aveCond = (cond1 + cond2) / 2; auto cond = 2 * aveCond * m_Radius / (pow(m_Spacing, 2)); diff --git a/src/Tarcog/src/SurfacesManager.cpp b/src/Tarcog/src/SurfacesManager.cpp new file mode 100644 index 00000000..34548f80 --- /dev/null +++ b/src/Tarcog/src/SurfacesManager.cpp @@ -0,0 +1,98 @@ +#include + +#include "SurfacesManager.hpp" +#include "Surface.hpp" + +namespace Tarcog::ISO15099 +{ + SurfacesManager::SurfacesManager(const SurfacesManager & t_Layer) + { + operator=(t_Layer); + } + + SurfacesManager & SurfacesManager::operator=(const SurfacesManager & t_Layer) + { + for(auto aSide : FenestrationCommon::EnumSide()) + { + const auto aSurface = t_Layer.m_Surface.at(aSide); + if(aSurface != nullptr) + { + m_Surface[aSide] = aSurface->clone(); + } + } + + return *this; + } + + std::shared_ptr + SurfacesManager::getSurface(const FenestrationCommon::Side t_Position) const + { + return m_Surface.at(t_Position); + } + + void SurfacesManager::setSurface(std::shared_ptr t_Surface, + const FenestrationCommon::Side t_Position) + { + m_Surface[t_Position] = t_Surface; + } + + double SurfacesManager::surfaceTemperature(FenestrationCommon::Side t_Position) const + { + return m_Surface.at(t_Position)->getTemperature(); + } + + double SurfacesManager::J(const FenestrationCommon::Side t_Position) const + { + return m_Surface.at(t_Position)->J(); + } + + double SurfacesManager::surfaceDeflectionMax(FenestrationCommon::Side side) const + { + return m_Surface.at(side)->getMaxDeflection(); + } + + double SurfacesManager::surfaceDeflectionMean(FenestrationCommon::Side side) const + { + return m_Surface.at(side)->getMeanDeflection(); + } + + double SurfacesManager::averageLayerTemperature() + { + return averageSurfaceTemperature(); + } + + double SurfacesManager::averageSurfaceTemperature() const + { + return (surfaceTemperature(FenestrationCommon::Side::Front) + + surfaceTemperature(FenestrationCommon::Side::Back)) + / 2; + } + + double SurfacesManager::emissivePowerTerm(FenestrationCommon::Side side) const + { + return m_Surface.at(side)->emissivePowerTerm(); + } + + double SurfacesManager::reflectance(FenestrationCommon::Side side) const + { + return m_Surface.at(side)->getReflectance(); + } + + double SurfacesManager::transmittance(FenestrationCommon::Side side) const + { + return m_Surface.at(side)->getTransmittance(); + } + + void SurfacesManager::initializeStart(FenestrationCommon::Side side, double temperature) + { + m_Surface.at(side)->initializeStart(temperature); + } + + void SurfacesManager::setSurfaceState(double const t_Temperature, + double const t_J, + FenestrationCommon::Side const t_Position) + { + m_Surface.at(t_Position)->setTemperature(t_Temperature); + m_Surface.at(t_Position)->setJ(t_J); + } +} // namespace Tarcog::ISO15099 \ No newline at end of file diff --git a/src/Tarcog/src/SurfacesManager.hpp b/src/Tarcog/src/SurfacesManager.hpp new file mode 100644 index 00000000..61213cd2 --- /dev/null +++ b/src/Tarcog/src/SurfacesManager.hpp @@ -0,0 +1,45 @@ +#pragma once + +#include +#include + +#include + +namespace Tarcog::ISO15099 +{ + class Surface; + + class SurfacesManager + { + public: + SurfacesManager() = default; + SurfacesManager(const SurfacesManager & t_Layer); + SurfacesManager & operator=(const SurfacesManager & t_Layer); + + [[nodiscard]] virtual std::shared_ptr + getSurface(FenestrationCommon::Side t_Position) const final; + virtual void setSurface(std::shared_ptr t_Surface, + FenestrationCommon::Side t_Position) final; + + [[nodiscard]] double surfaceTemperature(FenestrationCommon::Side t_Position) const; + [[nodiscard]] double J(FenestrationCommon::Side t_Position) const; + [[nodiscard]] double surfaceDeflectionMax(FenestrationCommon::Side side) const; + [[nodiscard]] double surfaceDeflectionMean(FenestrationCommon::Side side) const; + + virtual double averageLayerTemperature(); + [[nodiscard]] double averageSurfaceTemperature() const; + + [[nodiscard]] double emissivePowerTerm(FenestrationCommon::Side side) const; + + [[nodiscard]] double reflectance(FenestrationCommon::Side side) const; + [[nodiscard]] double transmittance(FenestrationCommon::Side side) const; + + void initializeStart(FenestrationCommon::Side side, double temperature); + + protected: + void setSurfaceState(double t_Temperature, double t_J, FenestrationCommon::Side t_Position); + + std::map> m_Surface{ + {FenestrationCommon::Side::Front, nullptr}, {FenestrationCommon::Side::Back, nullptr}}; + }; +} // namespace Tarcog::ISO15099 \ No newline at end of file diff --git a/src/Tarcog/src/System.cpp b/src/Tarcog/src/System.cpp index 2f0d401f..4318c8f5 100644 --- a/src/Tarcog/src/System.cpp +++ b/src/Tarcog/src/System.cpp @@ -4,264 +4,260 @@ #include "SingleSystem.hpp" -namespace Tarcog +namespace Tarcog::ISO15099 { - namespace ISO15099 + CSystem::CSystem(CIGU & t_IGU, + std::shared_ptr const & t_Indoor, + std::shared_ptr const & t_Outdoor) { - CSystem::CSystem(CIGU & t_IGU, - std::shared_ptr const & t_Indoor, - std::shared_ptr const & t_Outdoor) - { - m_System[System::SHGC] = std::make_shared(t_IGU, t_Indoor, t_Outdoor); - m_System[System::Uvalue] = std::make_shared( - t_IGU, t_Indoor->cloneEnvironment(), t_Outdoor->cloneEnvironment()); - m_System.at(System::Uvalue)->setSolarRadiation(0); + m_System[System::SHGC] = std::make_shared(t_IGU, t_Indoor, t_Outdoor); + m_System[System::Uvalue] = std::make_shared( + t_IGU, t_Indoor->cloneEnvironment(), t_Outdoor->cloneEnvironment()); + m_System.at(System::Uvalue)->setSolarRadiation(0); - solve(); - } + solve(); + } - std::vector CSystem::getTemperatures(System const t_System) - { - checkSolved(); - return m_System.at(t_System)->getTemperatures(); - } + std::vector CSystem::getTemperatures(System const t_System) + { + checkSolved(); + return m_System.at(t_System)->getTemperatures(); + } - std::vector CSystem::getRadiosities(System const t_System) - { - checkSolved(); - return m_System.at(t_System)->getRadiosities(); - } + std::vector CSystem::getRadiosities(System const t_System) + { + checkSolved(); + return m_System.at(t_System)->getRadiosities(); + } - std::vector CSystem::getMaxLayerDeflections(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getMaxLayerDeflections(); - } + std::vector CSystem::getMaxLayerDeflections(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getMaxLayerDeflections(); + } - std::vector CSystem::getMeanLayerDeflections(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getMeanLayerDeflections(); - } + std::vector CSystem::getMeanLayerDeflections(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getMeanLayerDeflections(); + } - std::vector CSystem::getMaxGapWidth(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getMaxGapWidth(); - } + std::vector CSystem::getMaxGapWidth(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getMaxGapWidth(); + } - std::vector CSystem::getMeanGapWidth(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getMeanGapWidth(); - } + std::vector CSystem::getMeanGapWidth(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getMeanGapWidth(); + } - std::vector CSystem::getPanesLoad(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getPanesLoad(); - } + std::vector CSystem::getPanesLoad(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getPanesLoad(); + } - std::vector CSystem::getGapPressures(System t_System) - { - checkSolved(); - return m_System.at(t_System)->getGapPressures(); - } + std::vector CSystem::getGapPressures(System t_System) + { + checkSolved(); + return m_System.at(t_System)->getGapPressures(); + } - void CSystem::setAppliedLoad(const std::vector & load) + void CSystem::setAppliedLoad(const std::vector & load) + { + m_Solved = false; + for(auto & [key, value] : m_System) { - m_Solved = false; - for(auto & [key, value] : m_System) - { - std::ignore = key; - value->setAppliedLoad(load); - } + std::ignore = key; + value->setAppliedLoad(load); } + } - std::vector> - CSystem::getSolidLayers(System const t_System) const - { - return m_System.at(t_System)->getSolidLayers(); - } + std::vector> + CSystem::getSolidLayers(System const t_System) const + { + return m_System.at(t_System)->getSolidLayers(); + } - double CSystem::getHeatFlow(System const t_System, Environment const t_Environment) - { - checkSolved(); - return m_System.at(t_System)->getHeatFlow(t_Environment); - } + double CSystem::getHeatFlow(System const t_System, Environment const t_Environment) + { + checkSolved(); + return m_System.at(t_System)->getHeatFlow(t_Environment); + } - double CSystem::getUValue() - { - checkSolved(); - return m_System.at(System::Uvalue)->getUValue(); - } + double CSystem::getUValue() + { + checkSolved(); + return m_System.at(System::Uvalue)->getUValue(); + } - double CSystem::getSHGC(double const t_TotSol) - { - checkSolved(); - const auto ventilatedFlowSHGC{ - m_System.at(System::SHGC)->getVentilationFlow(Environment::Indoor)}; - const auto ventilatedFlowU{ - m_System.at(System::Uvalue)->getVentilationFlow(Environment::Indoor)}; - - const auto indoorFlowSHGC{m_System.at(System::SHGC)->getHeatFlow(Environment::Indoor) - + ventilatedFlowSHGC}; - const auto indoorFlowU{m_System.at(System::Uvalue)->getHeatFlow(Environment::Indoor) - + ventilatedFlowU}; - - auto result{m_System.at(System::SHGC)->getSolarRadiation() != 0.0 - ? t_TotSol - - (indoorFlowSHGC - indoorFlowU) - / m_System.at(System::SHGC)->getSolarRadiation() - : 0}; - - return result; - } + double CSystem::getSHGC(double const t_TotSol) + { + checkSolved(); + const auto ventilatedFlowSHGC{ + m_System.at(System::SHGC)->getVentilationFlow(Environment::Indoor)}; + const auto ventilatedFlowU{ + m_System.at(System::Uvalue)->getVentilationFlow(Environment::Indoor)}; + + const auto indoorFlowSHGC{m_System.at(System::SHGC)->getHeatFlow(Environment::Indoor) + + ventilatedFlowSHGC}; + const auto indoorFlowU{m_System.at(System::Uvalue)->getHeatFlow(Environment::Indoor) + + ventilatedFlowU}; + + auto result{m_System.at(System::SHGC)->getSolarRadiation() != 0.0 + ? t_TotSol + - (indoorFlowSHGC - indoorFlowU) + / m_System.at(System::SHGC)->getSolarRadiation() + : 0}; + + return result; + } + + size_t CSystem::getNumberOfIterations(System const t_System) + { + checkSolved(); + return m_System.at(t_System)->getNumberOfIterations(); + } - size_t CSystem::getNumberOfIterations(System const t_System) - { - checkSolved(); - return m_System.at(t_System)->getNumberOfIterations(); - } + std::vector CSystem::getSolidEffectiveLayerConductivities(const System t_System) + { + checkSolved(); + return m_System.at(t_System)->getSolidEffectiveLayerConductivities(); + } - std::vector CSystem::getSolidEffectiveLayerConductivities(const System t_System) - { - checkSolved(); - return m_System.at(t_System)->getSolidEffectiveLayerConductivities(); - } + std::vector CSystem::getGapEffectiveLayerConductivities(const System t_System) + { + checkSolved(); + return m_System.at(t_System)->getGapEffectiveLayerConductivities(); + } - std::vector CSystem::getGapEffectiveLayerConductivities(const System t_System) - { - checkSolved(); - return m_System.at(t_System)->getGapEffectiveLayerConductivities(); - } + double CSystem::getEffectiveSystemConductivity(const System t_System) + { + checkSolved(); + return m_System.at(t_System)->EffectiveConductivity(); + } - double CSystem::getEffectiveSystemConductivity(const System t_System) - { - checkSolved(); - return m_System.at(t_System)->EffectiveConductivity(); - } + double CSystem::thickness(const System t_System) const + { + return m_System.at(t_System)->thickness(); + } - double CSystem::thickness(const System t_System) const - { - return m_System.at(t_System)->thickness(); - } + double CSystem::relativeHeatGain(const double Tsol) + { + return getUValue() * 7.78 + getSHGC(Tsol) / 0.87 * 630.9; + } - double CSystem::relativeHeatGain(const double Tsol) - { - return getUValue() * 7.78 + getSHGC(Tsol) / 0.87 * 630.9; - } + void CSystem::setAbsorptances(const std::vector & absorptances) + { + m_System.at(System::SHGC)->setAbsorptances(absorptances); + m_Solved = false; + } - void CSystem::setAbsorptances(const std::vector & absorptances) + void CSystem::setWidth(double width) + { + for(auto & system : m_System) { - m_System.at(System::SHGC)->setAbsorptances(absorptances); - m_Solved = false; + system.second->setWidth(width); } + m_Solved = false; + } - void CSystem::setWidth(double width) + void CSystem::setHeight(double height) + { + for(auto & [key, system] : m_System) { - for(auto & system : m_System) - { - system.second->setWidth(width); - } - m_Solved = false; + std::ignore = key; + system->setHeight(height); } + m_Solved = false; + } - void CSystem::setHeight(double height) + void CSystem::setTilt(double tilt) + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setHeight(height); - } - m_Solved = false; + std::ignore = key; + system->setTilt(tilt); } + m_Solved = false; + } - void CSystem::setTilt(double tilt) + void CSystem::setWidthAndHeight(double width, double height) + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setTilt(tilt); - } - m_Solved = false; + std::ignore = key; + system->setWidth(width); + system->setHeight(height); } + m_Solved = false; + } - void CSystem::setWidthAndHeight(double width, double height) + void CSystem::setInteriorAndExteriorSurfacesHeight(double height) + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setWidth(width); - system->setHeight(height); - } - m_Solved = false; + std::ignore = key; + system->setInteriorAndExteriorSurfacesHeight(height); } + m_Solved = false; + } - void CSystem::setInteriorAndExteriorSurfacesHeight(double height) + void CSystem::solve() + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setInteriorAndExteriorSurfacesHeight(height); - } - m_Solved = false; + std::ignore = key; + system->solve(); } + m_Solved = true; + } - void CSystem::solve() + void CSystem::checkSolved() + { + if(!m_Solved) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->solve(); - } + solve(); m_Solved = true; } + } - void CSystem::checkSolved() - { - if(!m_Solved) - { - solve(); - m_Solved = true; - } - } - - double CSystem::getH(System sys, Environment environment) const - { - return m_System.at(sys)->getH(environment); - } + double CSystem::getH(System sys, Environment environment) const + { + return m_System.at(sys)->getH(environment); + } - void CSystem::setDeflectionProperties(double t_Tini, double t_Pini) + void CSystem::setDeflectionProperties(double t_Tini, double t_Pini) + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setDeflectionProperties(t_Tini, t_Pini); - } - m_Solved = false; + std::ignore = key; + system->setDeflectionProperties(t_Tini, t_Pini); } + m_Solved = false; + } - void CSystem::setDeflectionProperties(const std::vector & measuredGapWidths) + void CSystem::setDeflectionProperties(const std::vector & measuredGapWidths) + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->setDeflectionProperties(measuredGapWidths); - } - m_Solved = false; + std::ignore = key; + system->setDeflectionProperties(measuredGapWidths); } + m_Solved = false; + } - void CSystem::clearDeflection() + void CSystem::clearDeflection() + { + for(auto & [key, system] : m_System) { - for(auto & [key, system] : m_System) - { - std::ignore = key; - system->clearDeflection(); - } - m_Solved = false; + std::ignore = key; + system->clearDeflection(); } + m_Solved = false; + } - } // namespace ISO15099 - -} // namespace Tarcog +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/TarcogConstants.hpp b/src/Tarcog/src/TarcogConstants.hpp index dc5bc3dd..dff151f5 100644 --- a/src/Tarcog/src/TarcogConstants.hpp +++ b/src/Tarcog/src/TarcogConstants.hpp @@ -1,5 +1,6 @@ -#ifndef TARCOGCONSTANTS_H -#define TARCOGCONSTANTS_H +#pragma once + +#include namespace Tarcog { @@ -7,6 +8,7 @@ namespace Tarcog { const double DEFAULT_WINDOW_WIDTH = 1; const double DEFAULT_WINDOW_HEIGHT = 1; + const double DEFAULT_LAYER_THICKNESS = std::numeric_limits::max(); const double DEFAULT_TILT = 90; const double DEFAULT_ENV_EMISSIVITY = 1; const double DEFAULT_FRACTION_OF_CLEAR_SKY = 1; @@ -37,6 +39,3 @@ namespace Tarcog } // namespace DeflectionConstants } // namespace Tarcog - - -#endif diff --git a/src/Tarcog/src/WholeWindow.hpp b/src/Tarcog/src/WholeWindow.hpp index 9c28b78e..d65986e2 100644 --- a/src/Tarcog/src/WholeWindow.hpp +++ b/src/Tarcog/src/WholeWindow.hpp @@ -3,179 +3,177 @@ #include "WholeWindowConfigurations.hpp" #include "WindowVision.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + //////////////////////////////////////////////// + /// WindowSingleVision + //////////////////////////////////////////////// + + class WindowSingleVision : public IWindow + { + public: + WindowSingleVision() = default; + + WindowSingleVision(double width, + double height, + double tvis, + double tsol, + std::shared_ptr iguSystem); + + [[nodiscard]] double area() const override; + [[nodiscard]] double uValue() const override; + [[nodiscard]] double shgc() const override; + [[nodiscard]] double shgc(double tSol) const override; + [[nodiscard]] double vt() const override; + [[nodiscard]] double vt(double tVis) const override; + [[nodiscard]] double uValueCOG() const; + [[nodiscard]] double shgcCOG() const; + + [[nodiscard]] double uValueCOGAverage() const override; + [[nodiscard]] double shgcCOGAverage() const override; + + void setFrameTop(FrameData frameData); + void setFrameBottom(FrameData frameData); + void setFrameLeft(FrameData frameData); + void setFrameRight(FrameData frameData); + void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); + + + [[nodiscard]] IGUDimensions getIGUDimensions() const override; + + protected: + [[nodiscard]] double visionPercentage() const override; + + private: + WindowVision vision; + }; + + //////////////////////////////////////////////// + /// WindowDualVision + //////////////////////////////////////////////// + + class WindowDualVision : public IWindow + { + public: + WindowDualVision() = default; + + [[nodiscard]] double area() const override; + [[nodiscard]] double uValue() const override; + [[nodiscard]] double shgc() const override; + [[nodiscard]] double shgc(double tSol1, double tSol2) const; + //! Both vision areas have same solar transmittance + [[nodiscard]] double shgc(double tSol) const override; + [[nodiscard]] double vt() const override; + [[nodiscard]] double vt(double tVis1, double tVis2) const; + //! Both vision areas have same visible transmittance + [[nodiscard]] double vt(double tVis) const override; + + [[nodiscard]] double uValueCOGAverage() const override; + [[nodiscard]] double shgcCOGAverage() const override; + + [[nodiscard]] IGUDimensions getIGUDimensions() const override; + + protected: + WindowDualVision(double width, + double height, + double tvis1, + double tsol1, + std::shared_ptr iguSystem1, + double tvis2, + double tsol2, + std::shared_ptr iguSystem2); + + [[nodiscard]] double visionPercentage() const override; + + [[nodiscard]] double uValueCOG1() const; + [[nodiscard]] double uValueCOG2() const; + [[nodiscard]] double shgcCOG1() const; + [[nodiscard]] double shgcCOG2() const; + + WindowVision m_Vision1; + WindowVision m_Vision2; + + private: + //! Makes single convective film coefficient averaged over the both visions + void averageHc(); + }; + + //////////////////////////////////////////////// + /// DualVisionHorizontal + //////////////////////////////////////////////// + + //! Concrete implementation of dual vision horizontal slider + //! Vision1 is the vision on the left side and Vision2 is the vision on the right side. + class DualVisionHorizontal : public WindowDualVision { - //////////////////////////////////////////////// - /// WindowSingleVision - //////////////////////////////////////////////// - - class WindowSingleVision : public IWindow - { - public: - WindowSingleVision() = default; - - WindowSingleVision(double width, - double height, - double tvis, - double tsol, - std::shared_ptr iguSystem); - - [[nodiscard]] double area() const override; - [[nodiscard]] double uValue() const override; - [[nodiscard]] double shgc() const override; - [[nodiscard]] double shgc(double tSol) const override; - [[nodiscard]] double vt() const override; - [[nodiscard]] double vt(double tVis) const override; - [[nodiscard]] double uValueCOG() const; - [[nodiscard]] double shgcCOG() const; - - [[nodiscard]] double uValueCOGAverage() const override; - [[nodiscard]] double shgcCOGAverage() const override; - - void setFrameTop(FrameData frameData); - void setFrameBottom(FrameData frameData); - void setFrameLeft(FrameData frameData); - void setFrameRight(FrameData frameData); - void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); - - - [[nodiscard]] IGUDimensions getIGUDimensions() const override; - - protected: - [[nodiscard]] double visionPercentage() const override; - - private: - WindowVision vision; - }; - - //////////////////////////////////////////////// - /// WindowDualVision - //////////////////////////////////////////////// - - class WindowDualVision : public IWindow - { - public: - WindowDualVision() = default; - - [[nodiscard]] double area() const override; - [[nodiscard]] double uValue() const override; - [[nodiscard]] double shgc() const override; - [[nodiscard]] double shgc(double tSol1, double tSol2) const; - //! Both vision areas have same solar transmittance - [[nodiscard]] double shgc(double tSol) const override; - [[nodiscard]] double vt() const override; - [[nodiscard]] double vt(double tVis1, double tVis2) const; - //! Both vision areas have same visible transmittance - [[nodiscard]] double vt(double tVis) const override; - - [[nodiscard]] double uValueCOGAverage() const override; - [[nodiscard]] double shgcCOGAverage() const override; - - [[nodiscard]] IGUDimensions getIGUDimensions() const override; - - protected: - WindowDualVision(double width, + public: + DualVisionHorizontal() = default; + + DualVisionHorizontal(double width, double height, double tvis1, double tsol1, - std::shared_ptr iguSystem1, + const std::shared_ptr & iguSystem1, double tvis2, double tsol2, - std::shared_ptr iguSystem2); - - [[nodiscard]] double visionPercentage() const override; - - [[nodiscard]] double uValueCOG1() const; - [[nodiscard]] double uValueCOG2() const; - [[nodiscard]] double shgcCOG1() const; - [[nodiscard]] double shgcCOG2() const; - - WindowVision m_Vision1; - WindowVision m_Vision2; - - private: - //! Makes single convective film coefficient averaged over the both visions - void averageHc(); - }; - - //////////////////////////////////////////////// - /// DualVisionHorizontal - //////////////////////////////////////////////// - - //! Concrete implementation of dual vision horizontal slider - //! Vision1 is the vision on the left side and Vision2 is the vision on the right side. - class DualVisionHorizontal : public WindowDualVision - { - public: - DualVisionHorizontal() = default; - - DualVisionHorizontal(double width, - double height, - double tvis1, - double tsol1, - const std::shared_ptr & iguSystem1, - double tvis2, - double tsol2, - const std::shared_ptr & iguSystem2); - - [[nodiscard]] double uValueCOGLeft() const; - [[nodiscard]] double uValueCOGRight() const; - [[nodiscard]] double shgcCOGLeft() const; - [[nodiscard]] double shgcCOGRight() const; - - void setFrameTopLeft(FrameData frameData); - void setFrameTopRight(FrameData frameData); - void setFrameBottomLeft(FrameData frameData); - void setFrameBottomRight(FrameData frameData); - void setFrameLeft(FrameData frameData); - void setFrameRight(FrameData frameData); - void setFrameMeetingRail(FrameData frameData); - - void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); - - void setDividersLeftVision(FrameData frameData, size_t nHorizontal, size_t nVertical); - void setDividersRightVision(FrameData frameData, size_t nHorizontal, size_t nVertical); - }; - - //////////////////////////////////////////////// - /// DualVisionVertical - //////////////////////////////////////////////// - - //! Concrete implementation of dual vision vertical slider - //! Vision1 is the vision on the top and Vision2 is the vision on the bottom. - class DualVisionVertical : public WindowDualVision - { - public: - DualVisionVertical() = default; - - DualVisionVertical(double width, - double height, - double tvis1, - double tsol1, - const std::shared_ptr & iguSystem1, - double tvis2, - double tsol2, - const std::shared_ptr & iguSystem2); - - [[nodiscard]] double uValueCOGTop() const; - [[nodiscard]] double uValueCOGBottom() const; - [[nodiscard]] double shgcCOGTop() const; - [[nodiscard]] double shgcCOGBottom() const; - - void setFrameTop(FrameData frameData); - void setFrameBottom(FrameData frameData); - void setFrameTopLeft(FrameData frameData); - void setFrameTopRight(FrameData frameData); - void setFrameBottomLeft(FrameData frameData); - void setFrameBottomRight(FrameData frameData); - void setFrameMeetingRail(FrameData frameData); - - void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); - - void setDividersTopVision(FrameData frameData, size_t nHorizontal, size_t nVertical); - void setDividersBottomVision(FrameData frameData, size_t nHorizontal, size_t nVertical); - }; - } // namespace ISO15099 -} // namespace Tarcog + const std::shared_ptr & iguSystem2); + + [[nodiscard]] double uValueCOGLeft() const; + [[nodiscard]] double uValueCOGRight() const; + [[nodiscard]] double shgcCOGLeft() const; + [[nodiscard]] double shgcCOGRight() const; + + void setFrameTopLeft(FrameData frameData); + void setFrameTopRight(FrameData frameData); + void setFrameBottomLeft(FrameData frameData); + void setFrameBottomRight(FrameData frameData); + void setFrameLeft(FrameData frameData); + void setFrameRight(FrameData frameData); + void setFrameMeetingRail(FrameData frameData); + + void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); + + void setDividersLeftVision(FrameData frameData, size_t nHorizontal, size_t nVertical); + void setDividersRightVision(FrameData frameData, size_t nHorizontal, size_t nVertical); + }; + + //////////////////////////////////////////////// + /// DualVisionVertical + //////////////////////////////////////////////// + + //! Concrete implementation of dual vision vertical slider + //! Vision1 is the vision on the top and Vision2 is the vision on the bottom. + class DualVisionVertical : public WindowDualVision + { + public: + DualVisionVertical() = default; + + DualVisionVertical(double width, + double height, + double tvis1, + double tsol1, + const std::shared_ptr & iguSystem1, + double tvis2, + double tsol2, + const std::shared_ptr & iguSystem2); + + [[nodiscard]] double uValueCOGTop() const; + [[nodiscard]] double uValueCOGBottom() const; + [[nodiscard]] double shgcCOGTop() const; + [[nodiscard]] double shgcCOGBottom() const; + + void setFrameTop(FrameData frameData); + void setFrameBottom(FrameData frameData); + void setFrameTopLeft(FrameData frameData); + void setFrameTopRight(FrameData frameData); + void setFrameBottomLeft(FrameData frameData); + void setFrameBottomRight(FrameData frameData); + void setFrameMeetingRail(FrameData frameData); + + void setDividers(FrameData frameData, size_t nHorizontal, size_t nVertical); + + void setDividersTopVision(FrameData frameData, size_t nHorizontal, size_t nVertical); + void setDividersBottomVision(FrameData frameData, size_t nHorizontal, size_t nVertical); + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/src/WindowVision.hpp b/src/Tarcog/src/WindowVision.hpp index 7f748e31..fdb1c76f 100644 --- a/src/Tarcog/src/WindowVision.hpp +++ b/src/Tarcog/src/WindowVision.hpp @@ -7,77 +7,75 @@ #include "WholeWindowConfigurations.hpp" #include "Frame.hpp" -namespace Tarcog + +namespace Tarcog::ISO15099 { - namespace ISO15099 + class WindowVision : public IVision { - class WindowVision : public IVision - { - public: - WindowVision() = default; - WindowVision(const WindowVision & vision) = default; - WindowVision(double width, - double height, - double tvis, - double tsol, - std::shared_ptr iguSystem); - [[nodiscard]] double area() const override; - [[nodiscard]] double uValue() const override; - //! Returns solar transmittance for the default IGU solar transmittance. - [[nodiscard]] double shgc() const override; - [[nodiscard]] double shgc(double tSol) const override; - //! Returns visible transmittance for the default IGU visible transmittance - [[nodiscard]] double vt() const override; - [[nodiscard]] double vt(double tVis) const override; - [[nodiscard]] double visionPercentage() const override; - [[nodiscard]] double hc() const override; - [[nodiscard]] double uValueCOG() const; - [[nodiscard]] double shgcCOG() const; - void setHc(double hc) override; - - void setFrameData(FramePosition position, FrameData frameData); - - void setFrameTypes(std::map frameTypes); - - void setDividers(FrameData divider, size_t nHorizontal, size_t nVertical); - - void setInteriorAndExteriorSurfaceHeight(double height); - - [[nodiscard]] double getIGUWidth() const; - [[nodiscard]] double getIGUHeight() const; - - private: - //! Makes connection between frames for correct area calculations. - void connectFrames(); - - //! Resizes IGU according to frames that are currently set in the vision - void resizeIGU(); - - //! Returns total area of dividers assigned to this window vision area - [[nodiscard]] double dividerArea() const; - [[nodiscard]] double dividerEdgeArea() const; - - [[nodiscard]] double frameProjectedArea() const; - [[nodiscard]] double edgeOfGlassArea() const; - - std::shared_ptr m_IGUSystem; - - double m_Width{0}; - double m_Height{0}; - double m_IGUUvalue{0}; - double m_VT{1}; - double m_Tsol{0}; - double m_HExterior{0}; - - //! Exterior surface height is used to calculate exterior film coefficient. - //! Since vision can be part of any construction, this variable is kept internally. - double m_ExteriorSurfaceHeight{0}; - - std::map m_Frame; - - size_t m_NumOfVerticalDividers{0u}; - size_t m_NumOfHorizontalDividers{0u}; - std::optional m_Divider; - }; - } // namespace ISO15099 -} // namespace Tarcog + public: + WindowVision() = default; + WindowVision(const WindowVision & vision) = default; + WindowVision(double width, + double height, + double tvis, + double tsol, + std::shared_ptr iguSystem); + [[nodiscard]] double area() const override; + [[nodiscard]] double uValue() const override; + //! Returns solar transmittance for the default IGU solar transmittance. + [[nodiscard]] double shgc() const override; + [[nodiscard]] double shgc(double tSol) const override; + //! Returns visible transmittance for the default IGU visible transmittance + [[nodiscard]] double vt() const override; + [[nodiscard]] double vt(double tVis) const override; + [[nodiscard]] double visionPercentage() const override; + [[nodiscard]] double hc() const override; + [[nodiscard]] double uValueCOG() const; + [[nodiscard]] double shgcCOG() const; + void setHc(double hc) override; + + void setFrameData(FramePosition position, FrameData frameData); + + void setFrameTypes(std::map frameTypes); + + void setDividers(FrameData divider, size_t nHorizontal, size_t nVertical); + + void setInteriorAndExteriorSurfaceHeight(double height); + + [[nodiscard]] double getIGUWidth() const; + [[nodiscard]] double getIGUHeight() const; + + private: + //! Makes connection between frames for correct area calculations. + void connectFrames(); + + //! Resizes IGU according to frames that are currently set in the vision + void resizeIGU(); + + //! Returns total area of dividers assigned to this window vision area + [[nodiscard]] double dividerArea() const; + [[nodiscard]] double dividerEdgeArea() const; + + [[nodiscard]] double frameProjectedArea() const; + [[nodiscard]] double edgeOfGlassArea() const; + + std::shared_ptr m_IGUSystem; + + double m_Width{0}; + double m_Height{0}; + double m_IGUUvalue{0}; + double m_VT{1}; + double m_Tsol{0}; + double m_HExterior{0}; + + //! Exterior surface height is used to calculate exterior film coefficient. + //! Since vision can be part of any construction, this variable is kept internally. + double m_ExteriorSurfaceHeight{0}; + + std::map m_Frame; + + size_t m_NumOfVerticalDividers{0u}; + size_t m_NumOfHorizontalDividers{0u}; + std::optional m_Divider; + }; +} // namespace Tarcog::ISO15099 diff --git a/src/Tarcog/tst/units/DoubleClearOutdoorShadeAir.unit.cpp b/src/Tarcog/tst/units/DoubleClearOutdoorShadeAir.unit.cpp index f1fff769..9bee1541 100644 --- a/src/Tarcog/tst/units/DoubleClearOutdoorShadeAir.unit.cpp +++ b/src/Tarcog/tst/units/DoubleClearOutdoorShadeAir.unit.cpp @@ -126,7 +126,7 @@ TEST_F(TestDoubleClearOutdoorShadeAir, Test1) } const auto numOfIter = aSystem->getNumberOfIterations(); - EXPECT_EQ(30u, numOfIter); + EXPECT_EQ(36u, numOfIter); const auto ventilatedFlow = aSystem->getVentilationFlow(Tarcog::ISO15099::Environment::Outdoor); EXPECT_NEAR(-24.485269, ventilatedFlow, 1e-6); diff --git a/src/Tarcog/tst/units/DoubleClear_102_102_ForcedVentilation.unit.cpp b/src/Tarcog/tst/units/DoubleClear_102_102_ForcedVentilation.unit.cpp index c9593634..79342886 100644 --- a/src/Tarcog/tst/units/DoubleClear_102_102_ForcedVentilation.unit.cpp +++ b/src/Tarcog/tst/units/DoubleClear_102_102_ForcedVentilation.unit.cpp @@ -143,7 +143,7 @@ TEST_F(TestDoubleClear102_102_ForcedVentilation, WinterSystem) EXPECT_NEAR(0.018796, thickness, Tolerance); auto numOfIter = aSystem->getNumberOfIterations(aRun); - EXPECT_EQ(35u, numOfIter); + EXPECT_EQ(36u, numOfIter); ////////////////////////////////////////////////////////////////////// /// SHGC run @@ -194,7 +194,7 @@ TEST_F(TestDoubleClear102_102_ForcedVentilation, WinterSystem) EXPECT_NEAR(0.018796, thickness, Tolerance); numOfIter = aSystem->getNumberOfIterations(aRun); - EXPECT_EQ(35u, numOfIter); + EXPECT_EQ(36u, numOfIter); ////////////////////////////////////////////////////////////////////// /// General results diff --git a/src/Tarcog/tst/units/DoubleLow-EVacuumCircularPillar.unit.cpp b/src/Tarcog/tst/units/DoubleLow-EVacuumCircularPillar.unit.cpp index 68330fe6..3d8c3184 100644 --- a/src/Tarcog/tst/units/DoubleLow-EVacuumCircularPillar.unit.cpp +++ b/src/Tarcog/tst/units/DoubleLow-EVacuumCircularPillar.unit.cpp @@ -1,9 +1,7 @@ #include -#include #include -#include "WCETarcog.hpp" -#include "WCECommon.hpp" +#include class DoubleLowEVacuumCircularPillar : public testing::Test { @@ -51,7 +49,7 @@ class DoubleLowEVacuumCircularPillar : public testing::Test emissivityBackIR, TransmittanceIR); - solidLayerThickness = 0.003962399904; + solidLayerThickness = 0.0039624; emissivityBackIR = 0.84; auto layer2 = Tarcog::ISO15099::Layers::solid(solidLayerThickness, @@ -79,11 +77,6 @@ class DoubleLowEVacuumCircularPillar : public testing::Test Tarcog::ISO15099::CIGU aIGU(windowWidth, windowHeight); aIGU.addLayers({layer1, pillarGap, layer2}); - // Alternative way to add layers. - // aIGU.addLayer(layer1); - // aIGU.addLayer(pillarGap); - // aIGU.addLayer(layer2); - ///////////////////////////////////////////////////////// /// System ///////////////////////////////////////////////////////// diff --git a/src/Tarcog/tst/units/GapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation.unit.cpp b/src/Tarcog/tst/units/GapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation.unit.cpp index 857b8e6e..f423c6aa 100644 --- a/src/Tarcog/tst/units/GapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation.unit.cpp @@ -187,8 +187,8 @@ TEST_F(TestGapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation, // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(280.81537988946332, frontTemperature, 1e-4); EXPECT_NEAR(281.39944906386245, backTemperature, 1e-4); } @@ -202,10 +202,10 @@ TEST_F(TestGapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation, G // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(281.39944906386245, frontTemperature, 1e-4); EXPECT_NEAR(292.40517817543264, backTemperature, 1e-4); EXPECT_NEAR(292.7187143602813, layerTemperature, 1e-4); @@ -222,8 +222,8 @@ TEST_F(TestGapBetweenDarkGlassPanesForcedVentilationInsideAirWinterValidation, // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(292.40517817543264, frontTemperature, 1e-4); EXPECT_NEAR(292.56452854907945, backTemperature, 1e-4); } diff --git a/src/Tarcog/tst/units/GapBetweenDarkGlassPanesNoVentilationWinterValidation.unit.cpp b/src/Tarcog/tst/units/GapBetweenDarkGlassPanesNoVentilationWinterValidation.unit.cpp index cc2bfbae..993623fa 100644 --- a/src/Tarcog/tst/units/GapBetweenDarkGlassPanesNoVentilationWinterValidation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenDarkGlassPanesNoVentilationWinterValidation.unit.cpp @@ -185,8 +185,8 @@ TEST_F(TestGapBetweenDarkGlassPanesNoVentilationWinterValidation, FirstLayerSurf // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(276.83340353098015, frontTemperature, 1e-4); EXPECT_NEAR(277.11277736659969, backTemperature, 1e-4); } @@ -200,10 +200,10 @@ TEST_F(TestGapBetweenDarkGlassPanesNoVentilationWinterValidation, GapTemperature // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(277.11277736659969, frontTemperature, 1e-4); EXPECT_NEAR(288.37356601094808, backTemperature, 1e-4); EXPECT_NEAR(282.74317168877388, layerTemperature, 1e-4); @@ -219,8 +219,8 @@ TEST_F(TestGapBetweenDarkGlassPanesNoVentilationWinterValidation, SecondLayerSur // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(288.37356601094808, frontTemperature, 1e-4); EXPECT_NEAR(288.65293984656751, backTemperature, 1e-4); } diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir.unit.cpp index 9388c4ab..b8d9245e 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(312.84342610457981, frontTemperature, 1e-4); EXPECT_NEAR(313.12896009393842, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(313.12896009393842, frontTemperature, 1e-4); EXPECT_NEAR(305.04357261282178, backTemperature, 1e-4); EXPECT_NEAR(302.78306814785384, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(305.04357261282178, frontTemperature, 1e-4); EXPECT_NEAR(304.94803305914581, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAir.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAir.unit.cpp index 1400a82f..e3cf035e 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAir.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAir.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAi // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(312.84342610457981, frontTemperature, 1e-4); EXPECT_NEAR(313.12896009393842, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAi // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(313.12896009393842, frontTemperature, 1e-4); EXPECT_NEAR(305.04357261282178, backTemperature, 1e-4); EXPECT_NEAR(302.78306814785384, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedExteriorShadingAndGlassForcedVentilationOutsideAi // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(305.04357261282178, frontTemperature, 1e-4); EXPECT_NEAR(304.94803305914581, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsideAir.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsideAir.unit.cpp index b40b6a7c..0ddeb102 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsideAir.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsideAir.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsid // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(301.83170279362213, frontTemperature, 1e-4); EXPECT_NEAR(301.99678720311624, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsid // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(301.99678720311624, frontTemperature, 1e-4); EXPECT_NEAR(317.82696151543445, backTemperature, 1e-4); EXPECT_NEAR(299.60769752906231, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingFastForcedVentilationInsid // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(317.82696151543445, frontTemperature, 1e-4); EXPECT_NEAR(317.9161383448461, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir.unit.cpp index 922a44ab..10e043c1 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(303.8464948610835, frontTemperature, 1e-4); EXPECT_NEAR(304.13618821843897, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(304.13618821843897, frontTemperature, 1e-4); EXPECT_NEAR(323.52950175138528, backTemperature, 1e-4); EXPECT_NEAR(306.01312318292258, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(323.52950175138528, frontTemperature, 1e-4); EXPECT_NEAR(323.49077676587774, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAirThreeMeterHeight.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAirThreeMeterHeight.unit.cpp index 53dae8aa..ae20a370 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAirThreeMeterHeight.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAirThreeMeterHeight.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(305.33843112508362, frontTemperature, 1e-4); EXPECT_NEAR(305.72081655473085, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(305.72081655473085, frontTemperature, 1e-4); EXPECT_NEAR(326.86352010579054, backTemperature, 1e-4); EXPECT_NEAR(312.6686330843001, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingForcedVentilationInsideAir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(326.86352010579054, frontTemperature, 1e-4); EXPECT_NEAR(326.61372838866049, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection.unit.cpp index bf555d09..7206e007 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection.unit.cpp @@ -154,8 +154,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection, FirstLa // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(304.60903517150138, frontTemperature, 1e-4); EXPECT_NEAR(304.94605922753459, backTemperature, 1e-4); } @@ -169,10 +169,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection, GapTemp // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(304.94605922753459, frontTemperature, 1e-4); EXPECT_NEAR(324.90604783261381, backTemperature, 1e-4); EXPECT_NEAR(309.99149481933722, layerTemperature, 1e-4); @@ -188,8 +188,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection, SecondL // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(324.90604783261381, frontTemperature, 1e-4); EXPECT_NEAR(324.83549933079962, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap.unit.cpp index 63181a31..4b2279e6 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap.unit.cpp @@ -160,8 +160,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap, // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(309.64133477058732, frontTemperature, 1e-4); EXPECT_NEAR(310.29309127306482, backTemperature, 1e-4); } @@ -175,10 +175,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap, G // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(310.29309127306482, frontTemperature, 1e-4); EXPECT_NEAR(317.08493410641256, backTemperature, 1e-4); EXPECT_NEAR(313.68860944014904, layerTemperature, 1e-4); @@ -195,8 +195,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingNaturalConvection1mmGap, // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(317.08493410641256, frontTemperature, 1e-4); EXPECT_NEAR(317.19026784285921, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation.unit.cpp index 7fe1032c..a30d0fb1 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation.unit.cpp @@ -152,8 +152,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation, FirstLa // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(305.77946516003101, frontTemperature, 1e-4); EXPECT_NEAR(306.1893205312183, backTemperature, 1e-4); } @@ -167,10 +167,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation, GapTemp // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(306.1893205312183, frontTemperature, 1e-4); EXPECT_NEAR(326.89421715622797, backTemperature, 1e-4); EXPECT_NEAR(316.54063362165442, layerTemperature, 1e-4); @@ -186,8 +186,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingSealedVentilation, SecondL // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(326.89421715622797, frontTemperature, 1e-4); EXPECT_NEAR(326.80965945509263, backTemperature, 1e-4); } diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation.unit.cpp index 75bcda4f..eb8036a2 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation.unit.cpp @@ -158,8 +158,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation, Fir // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(305.78475961830213, frontTemperature, 1e-4); EXPECT_NEAR(306.1949449487222, backTemperature, 1e-4); } @@ -173,10 +173,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation, Gap // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(306.1949449487222, frontTemperature, 1e-4); EXPECT_NEAR(326.91503360741098, backTemperature, 1e-4); EXPECT_NEAR(316.55498927806661, layerTemperature, 1e-4); @@ -192,8 +192,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation, Sec // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(326.91503360741098, frontTemperature, 1e-4); EXPECT_NEAR(326.79740533508084, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGap.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGap.unit.cpp index 1cf5291a..7d15e8dc 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGap.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGap.unit.cpp @@ -165,8 +165,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGa // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(309.6424482346174, frontTemperature, 1e-4); EXPECT_NEAR(310.29427483885411, backTemperature, 1e-4); } @@ -180,10 +180,10 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGa // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(310.29427483885411, frontTemperature, 1e-4); EXPECT_NEAR(317.08724875308098, backTemperature, 1e-4); EXPECT_NEAR(313.69076179596755, layerTemperature, 1e-4); @@ -200,8 +200,8 @@ TEST_F(TestGapBetweenIrradiatedGlassAndInteriorShadingZeroForcedVentilation1mmGa // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(317.08724875308098, frontTemperature, 1e-4); EXPECT_NEAR(317.19253227148033, backTemperature, 1e-4); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidation.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidation.unit.cpp index 51a0e243..ccfdb4b4 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidation.unit.cpp @@ -193,8 +193,8 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidat // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(310.66416364252655, frontTemperature, 1e-4); EXPECT_NEAR(310.8805621728074, backTemperature, 1e-4); } @@ -209,10 +209,10 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidat // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - auto layerTemperature = aLayer->layerTemperature(); - auto averageTemperature = aLayer->averageTemperature(); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + auto layerTemperature = aLayer->averageLayerTemperature(); + auto averageTemperature = aLayer->averageSurfaceTemperature(); EXPECT_NEAR(310.8805621728074, frontTemperature, 1e-4); EXPECT_NEAR(312.69446809156403, backTemperature, 1e-4); EXPECT_NEAR(304.97929104242945, layerTemperature, 1e-4); @@ -229,8 +229,8 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesForcedVentilationInsideAirSummerValidat // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(312.69446809156403, frontTemperature, 1e-4); EXPECT_NEAR(312.61783661123928, backTemperature, 1e-4); } diff --git a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation.unit.cpp b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation.unit.cpp index 34c21ae9..eee5989b 100644 --- a/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation.unit.cpp +++ b/src/Tarcog/tst/units/GapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation.unit.cpp @@ -3,7 +3,7 @@ #include "WCETarcog.hpp" -using Tarcog::ISO15099::CBaseIGULayer; +using Tarcog::ISO15099::CBaseLayer; using Tarcog::ISO15099::CIGUSolidLayer; using Tarcog::ISO15099::CIGUGapLayer; using Tarcog::ISO15099::CSingleSystem; @@ -97,12 +97,12 @@ class TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation : } public: - [[nodiscard]] CBaseIGULayer * GetGap1() const + [[nodiscard]] CBaseLayer * GetGap1() const { return m_TarcogSystem->getGapLayers()[0].get(); }; - [[nodiscard]] CBaseIGULayer * GetGap2() const + [[nodiscard]] CBaseLayer * GetGap2() const { return m_TarcogSystem->getGapLayers()[1].get(); }; @@ -130,16 +130,14 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, 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(3.7294499418281335, gainEnergy, 1e-4); + EXPECT_NEAR(3.734313, gainEnergy, 1e-6); aLayer = GetGap2(); ASSERT_TRUE(aLayer != nullptr); gainEnergy = aLayer->getGainFlow(); - EXPECT_NEAR(-3.7294499418281335, gainEnergy, 1e-4); + EXPECT_NEAR(-3.734313, gainEnergy, 1e-6); } TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, FirstLayerSurfaceTemperatures) @@ -151,44 +149,23 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, // Airflow iterations are set to 1e-4 and it cannot exceed that precision ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); EXPECT_NEAR(306.04014011835119, frontTemperature, 1e-4); EXPECT_NEAR(307.36367843102033, backTemperature, 1e-4); } -// TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, GapTemperatures) -// { -// SCOPED_TRACE("Begin Test: Test Forced Ventilated Gap Layer At Edge - Gap Temperatures"); - -// auto aLayer = GetGap1(); - -// // Airflow iterations are set to 1e-4 and it cannot exceed that precision - -// ASSERT_TRUE(aLayer != nullptr); -// auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); -// auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); -// auto layerTemperature = aLayer->layerTemperature(); -// auto averageTemperature = aLayer->averageTemperature(); -// EXPECT_NEAR(263.33651241783423, frontTemperature, 1e-4); -// EXPECT_NEAR(282.70879216106016, backTemperature, 1e-4); -// EXPECT_NEAR(285.74858839456721, layerTemperature, 1e-4); -// EXPECT_NEAR(273.02265228944719, averageTemperature, 1e-4); -// } - TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, SecondLayerSurfaceTemperatures) { SCOPED_TRACE("Begin Test: Test Forced Ventilated Gap Layer At Edge - Solid Temperatures"); auto aLayer = GetSecondLayer(); - // Airflow iterations are set to 1e-4 and it cannot exceed that precision - ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - EXPECT_NEAR(334.87586844983286, frontTemperature, 1e-4); - EXPECT_NEAR(334.87882619192641, backTemperature, 1e-4); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + EXPECT_NEAR(334.875464, frontTemperature, 1e-6); + EXPECT_NEAR(334.878421, backTemperature, 1e-6); } TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, ThirdLayerSurfaceTemperatures) @@ -197,11 +174,9 @@ TEST_F(TestGapBetweenIrradiatedGlassPanesWithIntegratedShadingForcedVentilation, auto aLayer = GetThirdLayer(); - // Airflow iterations are set to 1e-4 and it cannot exceed that precision - ASSERT_TRUE(aLayer != nullptr); - auto frontTemperature = aLayer->getTemperature(FenestrationCommon::Side::Front); - auto backTemperature = aLayer->getTemperature(FenestrationCommon::Side::Back); - EXPECT_NEAR(318.08669652857139, frontTemperature, 1e-4); - EXPECT_NEAR(317.23853484124118, backTemperature, 1e-4); + auto frontTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Front); + auto backTemperature = aLayer->surfaceTemperature(FenestrationCommon::Side::Back); + EXPECT_NEAR(318.086476, frontTemperature, 1e-6); + EXPECT_NEAR(317.238326, backTemperature, 1e-6); } diff --git a/src/Tarcog/tst/units/GapLayerInBetweenVentilation.unit.cpp b/src/Tarcog/tst/units/GapLayerInBetweenVentilation.unit.cpp index 05fb7258..07e39f6b 100644 --- a/src/Tarcog/tst/units/GapLayerInBetweenVentilation.unit.cpp +++ b/src/Tarcog/tst/units/GapLayerInBetweenVentilation.unit.cpp @@ -91,12 +91,12 @@ class TestGapLayerInBetweenVentilation : public testing::Test } public: - std::shared_ptr GetGap1() const + [[nodiscard]] std::shared_ptr GetGap1() const { return m_TarcogSystem->getGapLayers()[0]; }; - std::shared_ptr GetGap2() const + [[nodiscard]] std::shared_ptr GetGap2() const { return m_TarcogSystem->getGapLayers()[1]; }; @@ -108,14 +108,12 @@ TEST_F(TestGapLayerInBetweenVentilation, VentilationFlow) 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(34.909058114121649, gainEnergy, 1e-4); + EXPECT_NEAR(34.909799, gainEnergy, 1e-6); aLayer = GetGap2(); ASSERT_TRUE(aLayer != nullptr); gainEnergy = aLayer->getGainFlow(); - EXPECT_NEAR(-34.909058114121649, gainEnergy, 1e-4); + EXPECT_NEAR(-34.909799, gainEnergy, 1e-6); } \ No newline at end of file diff --git a/src/Tarcog/tst/units/InitialTemperatureGuess.unit.cpp b/src/Tarcog/tst/units/InitialTemperatureGuess.unit.cpp index 9ffbbff5..0205540d 100644 --- a/src/Tarcog/tst/units/InitialTemperatureGuess.unit.cpp +++ b/src/Tarcog/tst/units/InitialTemperatureGuess.unit.cpp @@ -86,23 +86,23 @@ TEST_F(TestTemperatureInitialGuess, Test1) auto layer = getLayer1(); - auto temperature = layer->getTemperature(Side::Front); + auto temperature = layer->surfaceTemperature(Side::Front); auto J = layer->J(Side::Front); EXPECT_NEAR(256.282733081615, temperature, 1e-6); EXPECT_NEAR(244.589307222020, J, 1e-6); - temperature = layer->getTemperature(Side::Back); + temperature = layer->surfaceTemperature(Side::Back); J = layer->J(Side::Back); EXPECT_NEAR(262.756302643044, temperature, 1e-6); EXPECT_NEAR(270.254322031419, J, 1e-6); layer = getLayer2(); - temperature = layer->getTemperature(Side::Front); + temperature = layer->surfaceTemperature(Side::Front); J = layer->J(Side::Front); EXPECT_NEAR(276.349099622422, temperature, 1e-6); EXPECT_NEAR(330.668096601357, J, 1e-6); - temperature = layer->getTemperature(Side::Back); + temperature = layer->surfaceTemperature(Side::Back); J = layer->J(Side::Back); EXPECT_NEAR(282.822669183851, temperature, 1e-6); EXPECT_NEAR(362.757956247504, J, 1e-6); diff --git a/src/Tarcog/tst/units/TripleInBetweenShadeAir.unit.cpp b/src/Tarcog/tst/units/TripleInBetweenShadeAir.unit.cpp index 4a9b5b02..29941e63 100644 --- a/src/Tarcog/tst/units/TripleInBetweenShadeAir.unit.cpp +++ b/src/Tarcog/tst/units/TripleInBetweenShadeAir.unit.cpp @@ -108,9 +108,9 @@ TEST_F(TestInBetweenShadeAir, Test1) const auto radiosity = aSystem->getRadiosities(); std::vector correctTemp{ - 257.929448, 258.393538, 271.502301, 271.506687, 283.533797, 283.997887}; + 257.929443, 258.393532, 271.502308, 271.506693, 283.533816, 283.997905}; std::vector correctJ{ - 249.233630, 260.378554, 300.442188, 316.138359, 358.375113, 378.654759}; + 249.233614, 260.378539, 300.442209, 316.138397, 358.375200, 378.654837}; EXPECT_EQ(correctTemp.size(), temperature.size()); EXPECT_EQ(correctJ.size(), radiosity.size()); diff --git a/src/Tarcog/tst/units/TripleInBetweenShadeAirArgon.unit.cpp b/src/Tarcog/tst/units/TripleInBetweenShadeAirArgon.unit.cpp index 50aee5af..f17eae51 100644 --- a/src/Tarcog/tst/units/TripleInBetweenShadeAirArgon.unit.cpp +++ b/src/Tarcog/tst/units/TripleInBetweenShadeAirArgon.unit.cpp @@ -127,7 +127,7 @@ TEST_F(TestInBetweenShadeAirArgon, Test1) const auto Temperature = aSystem->getTemperatures(); std::vector correctTemperature = { - 257.730238, 258.161010, 271.864895, 271.869140, 284.326543, 284.757315}; + 257.730232, 258.161003, 271.864901, 271.869146, 284.326568, 284.757339}; ASSERT_EQ(correctTemperature.size(), Temperature.size()); for(auto i = 0u; i < correctTemperature.size(); ++i) @@ -137,7 +137,7 @@ TEST_F(TestInBetweenShadeAirArgon, Test1) const auto Radiosity = aSystem->getRadiosities(); std::vector correctRadiosity = { - 248.583186, 259.822766, 301.738456, 318.127072, 362.150064, 381.981914}; + 248.583166, 259.822746, 301.738475, 318.127113, 362.150178, 381.982016}; ASSERT_EQ(correctRadiosity.size(), Radiosity.size()); for(auto i = 0u; i < correctRadiosity.size(); ++i)