Skip to content

[WIP] Preconditioning for multicomponent flows #2426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ca9083e
solving for enthalpy
Cristopher-Morales Oct 22, 2024
0487a68
fixing flux jacobian
Cristopher-Morales Oct 25, 2024
dd369bb
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Oct 26, 2024
5076f9d
fix output error
Cristopher-Morales Oct 26, 2024
09fe6f4
adding enthalpy diffusion
Cristopher-Morales Oct 31, 2024
851b13f
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Oct 31, 2024
f258308
moving enthalpy diffusion terms to CIncNSSolver.cpp
Cristopher-Morales Nov 3, 2024
63a8f37
small fix
Cristopher-Morales Nov 3, 2024
cb1d3ef
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Nov 4, 2024
30d0b88
cleaning and rewritting some functions
Cristopher-Morales Nov 9, 2024
dd22fcd
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Nov 18, 2024
7f92730
axisymetric source term and corrected flux jacobian at the wall
Cristopher-Morales Nov 22, 2024
fdbb9b9
updating BC_ConjugateHeat_Interface for fluid mixture
Cristopher-Morales Nov 30, 2024
c0b10a6
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Dec 9, 2024
911c996
Merge branch 'develop' into feature_preconditioning
Dec 23, 2024
2af10c3
activating muscl, consistent extrapolation for multicomponent
Jan 2, 2025
d0d0221
Merge branch 'develop' into feature_preconditioning
Jan 2, 2025
a1f526c
correct average enthalpy for multicomponent flows output
Jan 10, 2025
c469d32
Merge branch 'develop' into feature_preconditioning
Jan 11, 2025
ef2dc5f
changing boolean names
Jan 11, 2025
94bd0b0
up to date to develop
Jan 11, 2025
1c44044
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Jan 14, 2025
912642b
adding brackets
Cristopher-Morales Jan 18, 2025
a6ce2d4
fixing warning
Cristopher-Morales Jan 18, 2025
e9d1e1f
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Jan 23, 2025
127df29
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Jan 25, 2025
211dda0
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Jan 27, 2025
0655c99
adding standard reference temperature T0=298.15K as default value
Cristopher-Morales Jan 30, 2025
b8b45ef
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Feb 2, 2025
aca6e19
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Feb 13, 2025
5c656bb
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Feb 16, 2025
3f45e1c
reformulating and cleaning
Cristopher-Morales Feb 18, 2025
b1fc9d4
cleaning flow_diffusion.hpp and .cpp
Cristopher-Morales Feb 19, 2025
b23913a
removing spaces
Cristopher-Morales Feb 21, 2025
1961b08
fix description working variable
Cristopher-Morales Feb 21, 2025
02e5eac
update parallel regresion test
Cristopher-Morales Feb 22, 2025
810d2df
fix non-dimensionalization issue
Cristopher-Morales Feb 22, 2025
70ae6ee
updating species Non-Dimensional test case
Cristopher-Morales Feb 22, 2025
e9d3f4c
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 4, 2025
165a9ad
fix parallel_regression.py
Cristopher-Morales Mar 4, 2025
eabaabf
updating regression test cases
Cristopher-Morales Mar 4, 2025
96c6219
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 8, 2025
e1d873b
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 10, 2025
bbb76ae
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 10, 2025
52a1689
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 11, 2025
8d829b2
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 24, 2025
8a6b0f0
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 25, 2025
6a54f9f
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 26, 2025
761a3ac
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Mar 28, 2025
31b6101
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Apr 14, 2025
be00947
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales Apr 28, 2025
ca43883
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales May 7, 2025
f1ddb3c
Merge branch 'develop' into feature_preconditioning
Cristopher-Morales May 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ class CConfig {
Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */
Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */
Standard_Ref_Temperature, /*!< \brief Standard reference temperature for multicomponent flows. */
Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */
Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */
unsigned short wallModel_MaxIter; /*!< \brief maximum number of iterations for the Newton method for the wall model */
Expand Down Expand Up @@ -1902,6 +1903,12 @@ class CConfig {
*/
su2double GetPressure_Thermodynamic(void) const { return Pressure_Thermodynamic; }

/*!
* \brief Get the value of the standard reference temperature for multicomponent flows.
* \return Standard reference temperature, Non-dimensionalized if it is needed for Non-Dimensional problems.
*/
su2double GetStandard_RefTemperatureND(void) const { return Standard_Ref_Temperature / Temperature_Ref; }

/*!
* \brief Get the value of the non-dimensionalized thermodynamic pressure.
* \return Non-dimensionalized thermodynamic pressure.
Expand Down
3 changes: 3 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,9 @@ void CConfig::SetConfig_Options() {
addDoubleOption("GAMMA_VALUE", Gamma, 1.4);
/*!\brief THERMODYNAMIC_PRESSURE \n DESCRIPTION: Thermodynamics(operating) Pressure (101325 Pa), only for incompressible flows) \ingroup Config*/
addDoubleOption("THERMODYNAMIC_PRESSURE", Pressure_Thermodynamic, 101325.0);
/*!\brief STANDARD_REFERENCE_TEMPERATURE \n DESCRIPTION: Standard reference temperature (298.15K), only for
* multicomponent incompressible flows) \ingroup Config*/
addDoubleOption("STANDARD_REFERENCE_TEMPERATURE", Standard_Ref_Temperature, 298.15);
/*!\brief CP_VALUE \n DESCRIPTION: Specific heat at constant pressure, Cp (1004.703 J/kg*K (air), constant density incompressible fluids only) \ingroup Config*/
addDoubleListOption("SPECIFIC_HEAT_CP", nSpecific_Heat_Cp, Specific_Heat_Cp);
/*!\brief THERMAL_EXPANSION_COEFF \n DESCRIPTION: Thermal expansion coefficient (0.00347 K^-1 (air), used for Boussinesq approximation for liquids/non-ideal gases) \ingroup Config*/
Expand Down
23 changes: 23 additions & 0 deletions SU2_CFD/include/fluid/CFluidModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CLookUpTable;
class CFluidModel {
protected:
su2double StaticEnergy{0.0}; /*!< \brief Internal Energy. */
su2double Enthalpy{0.0}; /*!<*\brief Enthalpy. */
su2double Entropy{0.0}; /*!< \brief Entropy. */
su2double Density{0.0}; /*!< \brief Density. */
su2double Pressure{0.0}; /*!< \brief Pressure. */
Expand Down Expand Up @@ -113,6 +114,11 @@ class CFluidModel {
*/
su2double GetStaticEnergy() const { return StaticEnergy; }

/*!
* \brief Get fluid enthalpy.
*/
su2double GetEnthalpy() const { return Enthalpy; }

/*!
* \brief Get fluid density.
*/
Expand Down Expand Up @@ -186,6 +192,16 @@ class CFluidModel {
return mass_diffusivity;
}

/*!
* \brief Get heat diffusivity terms.
*/
virtual void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions = nullptr) {}

/*!
* \brief Get gradient heat diffusivity terms.
*/
virtual void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions = nullptr) {}

/*!
* \brief Get fluid pressure partial derivative.
*/
Expand Down Expand Up @@ -339,6 +355,13 @@ class CFluidModel {
*/
virtual void SetTDState_T(su2double val_Temperature, const su2double* val_scalars = nullptr) {}

/*!
* \brief Virtual member.
* \param[in] val_enthalpy - Enthalpy value at the point.
*/
virtual void ComputeTempFromEnthalpy(su2double val_enthalpy, su2double* val_temperature,
const su2double* val_scalars = nullptr) {}
Comment on lines +358 to +363
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems inconsistent with the SetTDState_* functions.
Should this be SetTDState_h and then you use GetTemperature to get the temperature?

Copy link
Contributor Author

@Cristopher-Morales Cristopher-Morales Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the pull request made by evert regarding preferential diffusion, he also used the same function for the flamelet solver. The only difference is that that function is in the CSpeciesFlameletSolver.cpp and I cannot access to that function when I set the primitives in SetPrimVar in CIncNSVariable.cpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is again to keep an abstract interface.
Evert's function is a private function of a specific solver which is perfectly fine, and it uses the fluid model... If you need a similar function, move it somewhere higher up in the hierarchy to make it accessible. For example the scalar solver. Or even the fluid model but implemented in a way that keeps it useful for all fluids.


/*!
* \brief Set fluid eddy viscosity provided by a turbulence model needed for computing effective thermal conductivity.
*/
Expand Down
22 changes: 22 additions & 0 deletions SU2_CFD/include/fluid/CFluidScalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CFluidScalar final : public CFluidModel {
const int n_species_mixture; /*!< \brief Number of species in mixture. */
su2double Gas_Constant; /*!< \brief Specific gas constant. */
const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */
const su2double Ref_Temperature; /*!< \brief Reference temperature. */
const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */
const su2double Prandtl_Number; /*!< \brief Prandlt number.*/

Expand Down Expand Up @@ -91,6 +92,11 @@ class CFluidScalar final : public CFluidModel {
*/
su2double ComputeMeanSpecificHeatCp(const su2double* val_scalars);

/*!
* \brief Compute Enthalpy given the temperature and scalars.
*/
su2double ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars);

/*!
* \brief Compute gas constant for mixture.
*/
Expand Down Expand Up @@ -137,6 +143,22 @@ class CFluidScalar final : public CFluidModel {
*/
inline su2double GetMassDiffusivity(int ivar) override { return massDiffusivity[ivar]; }

/*!
* \brief Get enthalpy diffusivity terms.
*/
void GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) override;

/*!
* \brief Get gradient enthalpy diffusivity terms.
*/
void GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions) override;

/*!
* \brief Compute Temperature from Enthalpy and scalars.
*/
void ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature,
const su2double* val_scalars) override;

/*!
* \brief Set the Dimensionless State using Temperature.
* \param[in] t - Temperature value at the point.
Expand Down
23 changes: 23 additions & 0 deletions SU2_CFD/include/numerics/CNumerics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class CNumerics {
su2double
Enthalpy_i, /*!< \brief Enthalpy at point i. */
Enthalpy_j; /*!< \brief Enthalpy at point j. */
su2double
WorkingVariable_i, /*!< \brief Working Variable at point i for incompressible solver. */
WorkingVariable_j; /*!< \brief Working Variable at point j for incompressible solver. */
su2double
dist_i, /*!< \brief Distance of point i to the nearest wall. */
dist_j; /*!< \brief Distance of point j to the nearest wall. */
Expand Down Expand Up @@ -130,6 +133,10 @@ class CNumerics {
const su2double
*ScalarVar_i, /*!< \brief Vector of scalar variables at point i. */
*ScalarVar_j; /*!< \brief Vector of scalar variables at point j. */
su2double
HeatFluxDiffusion; /*!< \brief Heat flux due to enthalpy diffusion for multicomponent. */
su2double
Jac_HeatFluxDiffusion; /*!< \brief Heat flux jacobian due to enthalpy diffusion for multicomponent. */
const su2double
*TransVar_i, /*!< \brief Vector of turbulent variables at point i. */
*TransVar_j; /*!< \brief Vector of turbulent variables at point j. */
Expand Down Expand Up @@ -188,6 +195,8 @@ class CNumerics {

bool nemo; /*!< \brief Flag for NEMO problems */

bool energy_multicomponent = false; /*!< \brief Flag for multicomponent and reacting flow */

bool bounded_scalar = false; /*!< \brief Flag for bounded scalar problem */

public:
Expand Down Expand Up @@ -751,6 +760,20 @@ class CNumerics {
Diffusion_Coeff_j = val_diffusioncoeff_j;
}

/*!
* \brief Set the heat flux due to enthalpy diffusion
* \param[in] val_heatfluxdiffusion - Value of the heat flux due to enthalpy diffusion.
*/
inline void SetHeatFluxDiffusion(su2double val_heatfluxdiffusion) { HeatFluxDiffusion = val_heatfluxdiffusion; }

/*!
* \brief Set Jacobian of the heat flux due to enthalpy diffusion
* \param[in] val_jacheatfluxdiffusion - Value of the heat flux jacobian due to enthalpy diffusion.
*/
inline void SetJacHeatFluxDiffusion(su2double val_jac_heatfluxdiffusion) {
Jac_HeatFluxDiffusion = val_jac_heatfluxdiffusion;
}

/*!
* \brief Set the laminar viscosity.
* \param[in] val_laminar_viscosity_i - Value of the laminar viscosity at point i.
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/include/numerics/flow/convection/fds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CUpwFDSInc_Flow final : public CNumerics {
Pressure_j, ProjVelocity,
MeandRhodT, dRhodT_i, dRhodT_j, /*!< \brief Derivative of density w.r.t. temperature (variable density flows). */
Temperature_i, Temperature_j, /*!< \brief Temperature at node 0 and 1. */
MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanEnthalpy, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */
MeanDensity, MeanPressure, MeanSoundSpeed, MeanBetaInc2, MeanWorkingVar, MeanCp, MeanTemperature; /*!< \brief Mean values of primitive variables. */
unsigned short iDim, iVar, jVar, kVar;

su2double* Flux = nullptr; /*!< \brief The flux / residual across the edge. */
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/include/numerics/flow/flow_diffusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class CAvgGrad_Flow final : public CAvgGrad_Base {
class CAvgGradInc_Flow final : public CAvgGrad_Base {
private:
su2double Mean_Thermal_Conductivity; /*!< \brief Mean value of the effective thermal conductivity. */
su2double Mean_Heat_Capacity; /*!< \brief Mean value of the heat capacity. */
bool energy; /*!< \brief computation with the energy equation. */

/*!
Expand Down
3 changes: 2 additions & 1 deletion SU2_CFD/include/numerics/flow/flow_sources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class CSourceGeneralAxisymmetric_Flow final : public CSourceAxisymmetric_Flow {
class CSourceIncAxisymmetric_Flow final : public CSourceBase_Flow {
bool implicit, /*!< \brief Implicit calculation. */
viscous, /*!< \brief Viscous incompressible flows. */
energy; /*!< \brief computation with the energy equation. */
energy, /*!< \brief computation with the energy equation. */
multicomponent; /*!< \brief multicomponent incompressible flows. */

public:
/*!
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/include/output/CFlowIncOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CFlowIncOutput final: public CFlowOutput {
private:
TURB_MODEL turb_model; /*!< \brief The kind of turbulence model*/
bool heat; /*!< \brief Boolean indicating whether have a heat problem*/
bool multicomponent; /*!< \brief Boolean indicating whether have a multicomponent problem*/
bool weakly_coupled_heat; /*!< \brief Boolean indicating whether have a weakly coupled heat equation*/
bool flamelet; /*!< \brief Boolean indicating whether we solve the flamelet equations */
unsigned short streamwisePeriodic; /*!< \brief Boolean indicating whether it is a streamwise periodic simulation. */
Expand Down
3 changes: 2 additions & 1 deletion SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class CFVMFlowSolverBase : public CSolver {
su2double Mach_Inf = 0.0; /*!< \brief Mach number at the infinity. */
su2double Density_Inf = 0.0; /*!< \brief Density at the infinity. */
su2double Energy_Inf = 0.0; /*!< \brief Energy at the infinity. */
su2double Temperature_Inf = 0.0; /*!< \brief Energy at the infinity. */
su2double Temperature_Inf = 0.0; /*!< \brief Temperature at the infinity. */
su2double Enthalpy_Inf = 0.0; /*!< \brief Enthalpy at the infinity. */
su2double Pressure_Inf = 0.0; /*!< \brief Pressure at the infinity. */
su2double* Velocity_Inf = nullptr; /*!< \brief Flow Velocity vector at the infinity. */

Expand Down
13 changes: 13 additions & 0 deletions SU2_CFD/include/solvers/CIncEulerSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,19 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME
CConfig *config,
unsigned short iMesh) final;

/*!
* \brief Recompute the extrapolated quantities, after MUSCL reconstruction,
* in a more thermodynamically consistent way.
* \note This method is static to improve the chances of it being used in a
* thread-safe manner.
* \param[in,out] fluidModel - The fluid model.
* \param[in] nDim - Number of physical dimensions.
* \param[in,out] primitive - Primitive variables.
* \param[in] scalar - scalar variable.
*/
static void ComputeConsistentExtrapolation(CFluidModel* fluidModel, unsigned short nDim, su2double* primitive,
const su2double* scalar);

/*!
* \brief Source term integration.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down
18 changes: 16 additions & 2 deletions SU2_CFD/include/variables/CIncEulerVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
class CIncEulerVariable : public CFlowVariable {
public:
static constexpr size_t MAXNVAR = 12;
static constexpr size_t MAXNVAR = 13;

template <class IndexType>
struct CIndices {
Expand All @@ -59,11 +59,11 @@ class CIncEulerVariable : public CFlowVariable {
inline IndexType ThermalConductivity() const { return nDim+6; }
inline IndexType CpTotal() const { return nDim+7; }
inline IndexType CvTotal() const { return nDim+8; }
inline IndexType Enthalpy() const { return nDim + 9; }

/*--- For compatible interface with NEMO. ---*/
inline IndexType SpeciesDensities() const { return std::numeric_limits<IndexType>::max(); }
inline IndexType Temperature_ve() const { return std::numeric_limits<IndexType>::max(); }
inline IndexType Enthalpy() const { return std::numeric_limits<IndexType>::max(); }
};

protected:
Expand Down Expand Up @@ -121,6 +121,14 @@ class CIncEulerVariable : public CFlowVariable {
return val_temperature <= 0.0;
}

/*!
* \brief Set the value of the enthalpy for multicomponent incompressible flows with energy equation.
* \param[in] iPoint - Point index.
*/
inline void SetEnthalpy(unsigned long iPoint, su2double val_enthalpy) {
Primitive(iPoint, indices.Enthalpy()) = val_enthalpy;
}

/*!
* \brief Set the value of the beta coeffient for incompressible flows.
* \param[in] iPoint - Point index.
Expand Down Expand Up @@ -153,6 +161,12 @@ class CIncEulerVariable : public CFlowVariable {
*/
inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint, indices.Temperature()); }

/*!
* \brief Get the enthalpy of the flow.
* \return Value of the enthalpy of the flow.
*/
inline su2double GetEnthalpy(unsigned long iPoint) const final { return Primitive(iPoint, indices.Enthalpy()); }

/*!
* \brief Get the velocity of the flow.
* \param[in] iDim - Index of the dimension.
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/include/variables/CIncNSVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CIncNSVariable final : public CIncEulerVariable {
private:
VectorType Tau_Wall; /*!< \brief Magnitude of the wall shear stress from a wall function. */
VectorType DES_LengthScale;
bool Energy_Multicomponent = false;

public:
/*!
Expand Down
31 changes: 31 additions & 0 deletions SU2_CFD/src/fluid/CFluidScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CFluidScalar::CFluidScalar(su2double value_pressure_operating, const CConfig* co
: CFluidModel(),
n_species_mixture(config->GetnSpecies() + 1),
Pressure_Thermodynamic(value_pressure_operating),
Ref_Temperature(config->GetStandard_RefTemperatureND()),
GasConstant_Ref(config->GetGas_Constant_Ref()),
Prandtl_Number(config->GetPrandtl_Turb()),
wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE),
Expand Down Expand Up @@ -212,13 +213,43 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars)
return mean_cp;
}

su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){
su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature);
return val_Enthalpy;
}

void CFluidScalar::ComputeTempFromEnthalpy(const su2double val_enthalpy, su2double* val_temperature,
const su2double* val_scalars) {
MassToMoleFractions(val_scalars);
su2double val_cp = ComputeMeanSpecificHeatCp(val_scalars);
*val_temperature = val_enthalpy / val_cp + Ref_Temperature;
}

void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) {
const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Ref_Temperature);
for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) {
const su2double enthalpy_species_i = specificHeat[iVar] * (Temperature - Ref_Temperature);
enthalpy_diffusions[iVar] = Density * (enthalpy_species_i * massDiffusivity[iVar] -
enthalpy_species_N * massDiffusivity[n_species_mixture - 1]);
}
}

void CFluidScalar::GetGradEnthalpyDiffusivity(su2double* grad_enthalpy_diffusions){
for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) {
grad_enthalpy_diffusions[iVar] = Density *
(specificHeat[iVar] * massDiffusivity[iVar] -
specificHeat[n_species_mixture - 1] * massDiffusivity[n_species_mixture - 1]);
}
}

void CFluidScalar::SetTDState_T(const su2double val_temperature, const su2double* val_scalars) {
MassToMoleFractions(val_scalars);
ComputeGasConstant();
Temperature = val_temperature;
Density = Pressure_Thermodynamic / (Temperature * Gas_Constant);
Cp = ComputeMeanSpecificHeatCp(val_scalars);
Cv = Cp - Gas_Constant;
Enthalpy = ComputeEnthalpyFromT(Temperature, val_scalars);

if (wilke) {
Mu = WilkeViscosity(val_scalars);
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/src/numerics/CNumerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar,
Prandtl_Lam = config->GetPrandtl_Lam();
Prandtl_Turb = config->GetPrandtl_Turb();
Gas_Constant = config->GetGas_ConstantND();
energy_multicomponent = ((config->GetKind_FluidModel() == FLUID_MIXTURE) && (config->GetEnergy_Equation()));

tau = new su2double* [nDim];
for (iDim = 0; iDim < nDim; iDim++)
Expand Down
Loading