Skip to content

Commit

Permalink
Minor updates to gas properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
vidanovic committed Jun 20, 2024
1 parent aa945dd commit 3a0036c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 39 deletions.
75 changes: 39 additions & 36 deletions src/Gases/src/GasItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,58 @@ namespace Gases
m_Fraction(t_Fraction), m_GasData(t_GasData)
{}

CGasItem::CGasItem(double aFraction, Gases::GasDef def) :
CGasItem(aFraction, getGasData(def))
CGasItem::CGasItem(double aFraction, Gases::GasDef def) : CGasItem(aFraction, getGasData(def))
{}

void CGasItem::fillStandardPressureProperites()
GasProperties CGasItem::fillStandardPressureProperties() const
{
using ConstantsData::UNIVERSALGASCONSTANT;
m_GasProperties.m_ThermalConductivity =
m_GasData.getPropertyValue(CoeffType::cCond, m_Temperature);
m_GasProperties.m_Viscosity = m_GasData.getPropertyValue(CoeffType::cVisc, m_Temperature);
m_GasProperties.m_SpecificHeat = m_GasData.getPropertyValue(CoeffType::cCp, m_Temperature);
m_GasProperties.m_MolecularWeight = m_GasData.getMolecularWeight();
m_GasProperties.m_Density =
m_Pressure * m_GasProperties.m_MolecularWeight / (UNIVERSALGASCONSTANT * m_Temperature);
m_GasProperties.m_PrandlNumber =
calculatePrandtlNumber(m_GasProperties.m_ThermalConductivity,
m_GasProperties.m_SpecificHeat,
m_GasProperties.m_Viscosity,
m_GasProperties.m_Density);

return {
m_GasData.getPropertyValue(CoeffType::cCond, m_Temperature), // m_ThermalConductivity
m_GasData.getPropertyValue(CoeffType::cVisc, m_Temperature), // m_Viscosity
m_GasData.getPropertyValue(CoeffType::cCp, m_Temperature), // m_SpecificHeat
m_Pressure * m_GasData.getMolecularWeight()
/ (UNIVERSALGASCONSTANT * m_Temperature), // m_Density
m_GasData.getMolecularWeight(), // m_MolecularWeight
calculatePrandtlNumber( // m_PrandlNumber
m_GasData.getPropertyValue(CoeffType::cCond, m_Temperature),
m_GasData.getPropertyValue(CoeffType::cCp, m_Temperature),
m_GasData.getPropertyValue(CoeffType::cVisc, m_Temperature),
m_Pressure * m_GasData.getMolecularWeight() / (UNIVERSALGASCONSTANT * m_Temperature)),
true // m_PropertiesCalculated
};
}

void CGasItem::fillVacuumPressureProperties()
GasProperties CGasItem::fillVacuumPressureProperties() const
{
using ConstantsData::UNIVERSALGASCONSTANT;
using ConstantsData::WCE_PI;
auto const alpha1 = 0.79;
auto const alpha2 = 0.79;
auto const alpha = alpha1 * alpha2 / (alpha2 + alpha1 * (1 - alpha2));
auto const specificHeatRatio = m_GasData.getSpecificHeatRatio();

const auto alpha1 = 0.79;
const auto alpha2 = 0.79;
const auto alpha = alpha1 * alpha2 / (alpha2 + alpha1 * (1 - alpha2));
const auto specificHeatRatio = m_GasData.getSpecificHeatRatio();
if(specificHeatRatio == 1)
{
throw std::runtime_error("Specific heat ratio of a gas cannot be equal to one.");
}
auto B = alpha * (specificHeatRatio + 1) / (specificHeatRatio - 1);
B *= sqrt(UNIVERSALGASCONSTANT / (8 * WCE_PI * m_GasData.getMolecularWeight() * m_Temperature));
m_GasProperties.m_ThermalConductivity = B * m_Pressure;
m_GasProperties.m_Viscosity = 0;
m_GasProperties.m_SpecificHeat = 0;
m_GasProperties.m_MolecularWeight = m_GasData.getMolecularWeight();
m_GasProperties.m_Density = 0;
m_GasProperties.m_PrandlNumber = 0;
B *= sqrt(UNIVERSALGASCONSTANT
/ (8 * WCE_PI * m_GasData.getMolecularWeight() * m_Temperature));

return {
B * m_Pressure, // m_ThermalConductivity
0.0, // m_Viscosity
0.0, // m_SpecificHeat
0.0, // m_Density
m_GasData.getMolecularWeight(), // m_MolecularWeight
0.0, // m_PrandlNumber
true // m_PropertiesCalculated
};
}


double CGasItem::fraction() const
{
return m_Fraction;
Expand Down Expand Up @@ -93,15 +102,9 @@ namespace Gases
{
if(!m_GasProperties.m_PropertiesCalculated)
{
if(m_Pressure > CGasSettings::instance().getVacuumPressure())
{
fillStandardPressureProperites();
}
else
{
fillVacuumPressureProperties();
}
m_GasProperties.m_PropertiesCalculated = true;
m_GasProperties = (m_Pressure > CGasSettings::instance().getVacuumPressure())
? fillStandardPressureProperties()
: fillVacuumPressureProperties();
}

return m_GasProperties;
Expand Down
6 changes: 3 additions & 3 deletions src/Gases/src/GasItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Gases
{

double const DefaultPressure = 101325;
double const DefaultPressure = 101325.0;
double const DefaultTemperature = 273.15;
double const DefaultFraction = 1.0;
enum class GasDef;
Expand All @@ -34,8 +34,8 @@ namespace Gases
[[nodiscard]] std::string name() const;

private:
void fillStandardPressureProperites();
void fillVacuumPressureProperties();
[[nodiscard]] GasProperties fillStandardPressureProperties() const;
[[nodiscard]] GasProperties fillVacuumPressureProperties() const;
void resetCalculatedProperties();
double m_Temperature{DefaultTemperature}; // unit in Kelvins
double m_Pressure{DefaultPressure}; // unit in Pa
Expand Down
15 changes: 15 additions & 0 deletions src/Gases/src/GasProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ namespace Gases
equal = equal && m_PropertiesCalculated == t_A.m_PropertiesCalculated;
return equal;
}
GasProperties::GasProperties(double t_ThermalConductivity,
double t_Viscosity,
double t_SpecificHeat,
double t_Density,
double t_MolecularWeight,
double t_PrandlNumber,
bool t_PropertiesCalculated) :
m_ThermalConductivity(t_ThermalConductivity),
m_Viscosity(t_Viscosity),
m_SpecificHeat(t_SpecificHeat),
m_Density(t_Density),
m_MolecularWeight(t_MolecularWeight),
m_PrandlNumber(t_PrandlNumber),
m_PropertiesCalculated(t_PropertiesCalculated)
{}

double calculatePrandtlNumber(double thermalConductivity,
double specificHeat,
Expand Down
7 changes: 7 additions & 0 deletions src/Gases/src/GasProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ namespace Gases
{
GasProperties() = default;
GasProperties(GasProperties const & t_GasProperties);
GasProperties(double t_ThermalConductivity,
double t_Viscosity,
double t_SpecificHeat,
double t_Density,
double t_MolecularWeight,
double t_PrandlNumber,
bool t_PropertiesCalculated);

GasProperties & operator+(const GasProperties & t_A);
GasProperties & operator+=(const GasProperties & t_A);
Expand Down

0 comments on commit 3a0036c

Please sign in to comment.