Skip to content

Commit 23383dd

Browse files
Fix enthalpy related issues (#2652)
* fixe scalar restart, update psi case * reduce y+ warning * Update SU2_CFD/src/solvers/CTurbSolver.cpp Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com> * fix weakly coupled heat restart * Apply suggestion from @bigfooted * Apply suggestion from @bigfooted * remove unused var * fix mass diffusivity MPI bug * use enthalpy for computing temperature also when energy is off * fix sensible enthalpy * remove temperatureInc * remove unused variable * change viscosity call * fix some regression * fix some regression * nondimensionalize poly-cp * change nondimensionalization of cp and enthalpy * fix polynomial cp * update warning * update easy regression tests * update parallel regressions * update regressions * fix bug in nondimensionalization * update regressions * update regressions * fixing tutorials * fixing tutorials and add relaxation factor * fix typo * Update SU2_CFD/src/solvers/CIncEulerSolver.cpp * Update SU2_CFD/src/solvers/CNSSolver.cpp * Update TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_fluid.cfg * Update TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_solid.cfg * Update TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_fluid.cfg * update some more regressions * update some more regressions * update some more regressions * change regression back --------- Co-authored-by: Cristopher Morales <98025159+Cristopher-Morales@users.noreply.github.com>
1 parent 732a85c commit 23383dd

43 files changed

Lines changed: 265 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Common/include/CConfig.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ class CConfig {
927927
Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */
928928
Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */
929929
Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */
930-
Standard_Ref_Temperature, /*!< \brief Standard reference temperature for multicomponent flows. */
931930
Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */
932931
Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */
933932
unsigned short wallModel_MaxIter; /*!< \brief maximum number of iterations for the Newton method for the wall model */
@@ -1982,12 +1981,6 @@ class CConfig {
19821981
*/
19831982
su2double GetPressure_Thermodynamic(void) const { return Pressure_Thermodynamic; }
19841983

1985-
/*!
1986-
* \brief Get the value of the standard reference temperature for multicomponent flows.
1987-
* \return Standard reference temperature, Non-dimensionalized if it is needed for Non-Dimensional problems.
1988-
*/
1989-
su2double GetStandard_RefTemperatureND(void) const { return Standard_Ref_Temperature / Temperature_Ref; }
1990-
19911984
/*!
19921985
* \brief Get the value of the non-dimensionalized thermodynamic pressure.
19931986
* \return Non-dimensionalized thermodynamic pressure.

Common/include/option_structure.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ constexpr passivedouble UNIVERSAL_GAS_CONSTANT = 8.3144598; /*!< \brief Univer
9696
constexpr passivedouble BOLTZMANN_CONSTANT = 1.3806503E-23; /*!< \brief Boltzmann's constant [J K^-1] */
9797
constexpr passivedouble AVOGAD_CONSTANT = 6.0221415E26; /*!< \brief Avogadro's constant, number of particles in one kmole. */
9898
constexpr passivedouble FUND_ELEC_CHARGE_CGS = 4.8032047E-10; /*!< \brief Fundamental electric charge in CGS units, cm^(3/2) g^(1/2) s^(-1). */
99-
99+
constexpr passivedouble STD_REF_TEMP = 298.15; /*!< \brief Standard reference temperature for enthalpy in Kelvin. */
100100
constexpr passivedouble EPS = 1.0E-16; /*!< \brief Error scale. */
101101
constexpr passivedouble TURB_EPS = 1.0E-16; /*!< \brief Turbulent Error scale. */
102102

Common/src/CConfig.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,6 @@ void CConfig::SetConfig_Options() {
12481248
addDoubleOption("GAMMA_VALUE", Gamma, 1.4);
12491249
/*!\brief THERMODYNAMIC_PRESSURE \n DESCRIPTION: Thermodynamics(operating) Pressure (101325 Pa), only for incompressible flows) \ingroup Config*/
12501250
addDoubleOption("THERMODYNAMIC_PRESSURE", Pressure_Thermodynamic, 101325.0);
1251-
/*!\brief STANDARD_REFERENCE_TEMPERATURE \n DESCRIPTION: Standard reference temperature (298.15K), only for
1252-
* multicomponent incompressible flows) \ingroup Config*/
1253-
addDoubleOption("STANDARD_REFERENCE_TEMPERATURE", Standard_Ref_Temperature, 298.15);
12541251
/*!\brief CP_VALUE \n DESCRIPTION: Specific heat at constant pressure, Cp (1004.703 J/kg*K (air), constant density incompressible fluids only) \ingroup Config*/
12551252
addDoubleListOption("SPECIFIC_HEAT_CP", nSpecific_Heat_Cp, Specific_Heat_Cp);
12561253
/*!\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*/

SU2_CFD/include/fluid/CConstantDensity.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ class CConstantDensity final : public CFluidModel {
3939
/*!
4040
* \brief Constructor of the class.
4141
*/
42-
CConstantDensity(su2double val_Density, su2double val_Cp) {
42+
CConstantDensity(su2double val_Density, su2double val_Cp, su2double val_Temperature_Ref) {
4343
Density = val_Density;
4444
Cp = val_Cp;
4545
Cv = val_Cp;
46+
Std_Ref_Temp_ND = val_Temperature_Ref;
4647
}
4748

4849
/*!
@@ -56,16 +57,19 @@ class CConstantDensity final : public CFluidModel {
5657
decoupled equation. Hence, we update the value.
5758
Note Cp = Cv, (gamma = 1).*/
5859
Temperature = t;
59-
Enthalpy = Cp * Temperature;
60+
Enthalpy = Cp * (Temperature - Std_Ref_Temp_ND); // Sensible enthalpy relative to STD_REF_TEMP
6061
}
6162

6263
/*!
6364
* \brief Set the Dimensionless State using Enthalpy.
6465
* \param[in] val_enthalpy - Enthalpy value at the point.
65-
* \param[in] val_scalars - not used here.
66+
* \param[in] val_scalars - not used here.
6667
*/
6768
void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override {
6869
Enthalpy = val_enthalpy;
69-
Temperature = Enthalpy / Cp;
70+
Temperature = Enthalpy / Cp + Std_Ref_Temp_ND; // Temperature from sensible enthalpy
7071
}
72+
73+
private:
74+
su2double Std_Ref_Temp_ND{0.0}; /*!< \brief Nondimensional standard reference temperature for enthalpy. */
7175
};

SU2_CFD/include/fluid/CFluidModel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class CFluidModel {
279279
/*!
280280
* \brief Set specific heat Cp model.
281281
*/
282-
virtual void SetCpModel(const CConfig* config) {}
282+
virtual void SetCpModel(const CConfig* config, su2double val_Temperature_Ref) {}
283283

284284
/*!
285285
* \brief Set viscosity model.
@@ -372,7 +372,7 @@ class CFluidModel {
372372
/*!
373373
* \brief Virtual member.
374374
* \param[in] val_enthalpy - Enthalpy value at the point.
375-
* \param[in] val_scalars - Scalar mass fractions.
375+
* \param[in] val_scalars - Scalar mass fractions.
376376
*/
377377
virtual void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) {}
378378

SU2_CFD/include/fluid/CFluidScalar.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class CFluidScalar final : public CFluidModel {
4242
const int n_species_mixture; /*!< \brief Number of species in mixture. */
4343
su2double Gas_Constant; /*!< \brief Specific gas constant. */
4444
const su2double Pressure_Thermodynamic; /*!< \brief Constant pressure thermodynamic. */
45-
const su2double Ref_Temperature; /*!< \brief Standard Reference temperature, usually set to 298.15 K. */
4645
const su2double GasConstant_Ref; /*!< \brief Gas constant reference needed for Nondimensional problems. */
46+
const su2double Std_Ref_Temp_ND; /*!< \brief Nondimensional standard reference temperature for enthalpy. */
4747
const su2double Prandtl_Turb_Number; /*!< \brief Prandlt turbulent number.*/
4848
const su2double Schmidt_Turb_Number; /*!< \brief Schmidt turbulent number.*/
4949

@@ -177,7 +177,7 @@ class CFluidScalar final : public CFluidModel {
177177
/*!
178178
* \brief Virtual member.
179179
* \param[in] val_enthalpy - Enthalpy value at the point.
180-
* \param[in] val_scalars - Scalar mass fractions.
180+
* \param[in] val_scalars - Scalar mass fractions.
181181
*/
182182
void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override;
183183
};

SU2_CFD/include/fluid/CIncIdealGas.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CIncIdealGas final : public CFluidModel {
3939
/*!
4040
* \brief Constructor of the class.
4141
*/
42-
CIncIdealGas(su2double val_Cp, su2double val_gas_constant, su2double val_operating_pressure) {
42+
CIncIdealGas(su2double val_Cp, su2double val_gas_constant, su2double val_operating_pressure, su2double val_Temperature_Ref) {
4343
/*--- In the incompressible ideal gas model, the thermodynamic pressure
4444
is decoupled from the governing equations and held constant. The
4545
density is therefore only a function of temperature variations. ---*/
@@ -48,6 +48,7 @@ class CIncIdealGas final : public CFluidModel {
4848
Gamma = 1.0;
4949
Cp = val_Cp;
5050
Cv = Cp;
51+
Std_Ref_Temp_ND = STD_REF_TEMP / val_Temperature_Ref;
5152
}
5253

5354
/*!
@@ -58,7 +59,7 @@ class CIncIdealGas final : public CFluidModel {
5859
/*--- The EoS only depends upon temperature. ---*/
5960
Temperature = t;
6061
Density = Pressure / (Temperature * Gas_Constant);
61-
Enthalpy = Cp * Temperature;
62+
Enthalpy = Cp * (Temperature - Std_Ref_Temp_ND); // Sensible enthalpy relative to REF_TEMP
6263
}
6364

6465
/*!
@@ -67,11 +68,12 @@ class CIncIdealGas final : public CFluidModel {
6768
*/
6869
void SetTDState_h(su2double val_enthalpy, const su2double* val_scalars = nullptr) override {
6970
Enthalpy = val_enthalpy;
70-
Temperature = Enthalpy / Cp;
71+
Temperature = Enthalpy / Cp + Std_Ref_Temp_ND; // Temperature from sensible enthalpy
7172
Density = Pressure / (Temperature * Gas_Constant);
7273
}
7374

7475
private:
7576
su2double Gas_Constant{0.0}; /*!< \brief Gas Constant. */
7677
su2double Gamma{0.0}; /*!< \brief Heat Capacity Ratio. */
78+
su2double Std_Ref_Temp_ND{0.0}; /*!< \brief Nondimensional standard reference temperature for enthalpy. */
7779
};

SU2_CFD/include/fluid/CIncIdealGasPolynomial.hpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
4242
/*!
4343
* \brief Constructor of the class.
4444
*/
45-
CIncIdealGasPolynomial(su2double val_gas_constant, su2double val_operating_pressure) {
45+
CIncIdealGasPolynomial(su2double val_gas_constant, su2double val_operating_pressure, su2double val_Temperature_Ref) {
4646
/* In the incompressible ideal gas model, the thermodynamic pressure is decoupled
4747
from the governing equations and held constant. The density is therefore only a
4848
function of temperature variations. We also use a molecular weight (g/mol) and the
@@ -51,20 +51,17 @@ class CIncIdealGasPolynomial final : public CFluidModel {
5151
Gas_Constant = val_gas_constant;
5252
Pressure = val_operating_pressure;
5353
Gamma = 1.0;
54+
Std_Ref_Temp_ND = val_Temperature_Ref;
5455
}
5556

5657
/*!
5758
* \brief Set the temperature polynomial coefficients for variable Cp.
5859
* \param[in] config - configuration container for the problem.
5960
*/
60-
void SetCpModel(const CConfig* config) override {
61-
const su2double t_ref = config->GetStandard_RefTemperatureND();
62-
Enthalpy_Ref = 0.0;
63-
su2double t_i = 1.0;
61+
void SetCpModel(const CConfig* config, su2double val_Temperature_Ref) override {
6462
for (int i = 0; i < N; ++i) {
65-
t_i *= t_ref;
63+
/*--- Note that we use cp = dh/dt here. ---*/
6664
coeffs_[i] = config->GetCp_PolyCoeffND(i);
67-
Enthalpy_Ref += coeffs_[i] * t_i / (i + 1);
6865
}
6966
Temperature_Min = config->GetTemperatureLimits(0);
7067
}
@@ -80,12 +77,14 @@ class CIncIdealGasPolynomial final : public CFluidModel {
8077

8178
/* Evaluate the new Cp and enthalpy from the coefficients and temperature. */
8279
Cp = coeffs_[0];
83-
Enthalpy = coeffs_[0] * t - Enthalpy_Ref;
80+
Enthalpy = coeffs_[0] * (t - Std_Ref_Temp_ND);
8481
su2double t_i = 1.0;
82+
su2double tref_i = 1.0;
8583
for (int i = 1; i < N; ++i) {
8684
t_i *= t;
85+
tref_i *= Std_Ref_Temp_ND;
8786
Cp += coeffs_[i] * t_i;
88-
Enthalpy += coeffs_[i] * t_i * t / (i + 1);
87+
Enthalpy += coeffs_[i] * (t_i * t - tref_i * Std_Ref_Temp_ND) / (i + 1);
8988
}
9089
Cv = Cp / Gamma;
9190
}
@@ -106,16 +105,18 @@ class CIncIdealGasPolynomial final : public CFluidModel {
106105

107106
int counter = 0;
108107

109-
/*--- Computing temperature given enthalpy using Newton-Raphson. ---*/
108+
/*--- Compute temperature given enthalpy using Newton-Raphson. ---*/
110109
while ((abs(delta_temp_iter) > toll) && (counter++ < counter_limit)) {
111110
/* Evaluate the new Cp and enthalpy from the coefficients and temperature. */
112111
Cp_iter = coeffs_[0];
113-
su2double Enthalpy_iter = coeffs_[0] * temp_iter - Enthalpy_Ref;
112+
su2double Enthalpy_iter = coeffs_[0] * (temp_iter - Std_Ref_Temp_ND);
114113
su2double t_i = 1.0;
114+
su2double tref_i = 1.0;
115115
for (int i = 1; i < N; ++i) {
116116
t_i *= temp_iter;
117+
tref_i *= Std_Ref_Temp_ND;
117118
Cp_iter += coeffs_[i] * t_i;
118-
Enthalpy_iter += coeffs_[i] * t_i * temp_iter / (i + 1);
119+
Enthalpy_iter += coeffs_[i] * (t_i * temp_iter - tref_i * Std_Ref_Temp_ND) / (i + 1);
119120
}
120121

121122
delta_enthalpy_iter = Enthalpy - Enthalpy_iter;
@@ -124,15 +125,16 @@ class CIncIdealGasPolynomial final : public CFluidModel {
124125

125126
temp_iter += delta_temp_iter;
126127
if (temp_iter < Temperature_Min) {
127-
cout << "Warning: Negative temperature has been found during Newton-Raphson" << endl;
128+
cout << "Warning: Negative temperature has been found during Newton-Raphson." << endl;
128129
temp_iter = Temperature_Min;
129130
break;
130131
}
131132
}
133+
132134
Temperature = temp_iter;
133135
Cp = Cp_iter;
134136
if (counter == counter_limit) {
135-
cout << "Warning Newton-Raphson exceed number of max iteration in temperature computation" << endl;
137+
cout << "Warning: Newton-Raphson exceeds max. iterations in temperature computation." << endl;
136138
}
137139
Density = Pressure / (Temperature * Gas_Constant);
138140
Cv = Cp / Gamma;
@@ -141,7 +143,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
141143
private:
142144
su2double Gas_Constant{0.0}; /*!< \brief Specific Gas Constant. */
143145
su2double Gamma{0.0}; /*!< \brief Ratio of specific heats. */
146+
su2double Std_Ref_Temp_ND{0.0}; /*!< \brief Nondimensional standard reference temperature for enthalpy. */
144147
array<su2double, N> coeffs_; /*!< \brief Polynomial coefficients for heat capacity as a function of temperature. */
145-
su2double Enthalpy_Ref; /*!< \brief Enthalpy computed at the reference temperature. */
146148
su2double Temperature_Min; /*!< \brief Minimum temperature value allowed in Newton-Raphson iterations. */
147149
};

SU2_CFD/include/variables/CIncEulerVariable.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class CIncEulerVariable : public CFlowVariable {
7272
VectorType Streamwise_Periodic_RecoveredPressure, /*!< \brief Recovered/Physical pressure [Pa] for streamwise periodic flow. */
7373
Streamwise_Periodic_RecoveredTemperature; /*!< \brief Recovered/Physical temperature [K] for streamwise periodic flow. */
7474
su2double TemperatureLimits[2]; /*!< \brief Temperature limits [K]. */
75-
su2double TemperatureInc = 0.0; /*!< \brief Temperature [K] imposed when energy equation is switch off. */
7675
public:
7776
/*!
7877
* \brief Constructor of the class.

SU2_CFD/src/fluid/CFluidScalar.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ CFluidScalar::CFluidScalar(su2double value_pressure_operating, const CConfig* co
4545
: CFluidModel(),
4646
n_species_mixture(config->GetnSpecies() + 1),
4747
Pressure_Thermodynamic(value_pressure_operating),
48-
Ref_Temperature(config->GetStandard_RefTemperatureND()),
4948
GasConstant_Ref(config->GetGas_Constant_Ref()),
49+
Std_Ref_Temp_ND(STD_REF_TEMP / config->GetTemperature_Ref()),
5050
Prandtl_Turb_Number(config->GetPrandtl_Turb()),
5151
Schmidt_Turb_Number(config->GetSchmidt_Number_Turbulent()),
5252
wilke(config->GetKind_MixingViscosityModel() == MIXINGVISCOSITYMODEL::WILKE),
@@ -219,14 +219,14 @@ su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, co
219219
* depend on temperature, but it does depend on mixture composition, enthalpy is directly computed from
220220
* the expression h_s = Cp(T - T_ref).
221221
*/
222-
su2double val_Enthalpy = Cp * (val_temperature - Ref_Temperature);
222+
su2double val_Enthalpy = Cp * (val_temperature - Std_Ref_Temp_ND);
223223
return val_Enthalpy;
224224
}
225225

226226
void CFluidScalar::GetEnthalpyDiffusivity(su2double* enthalpy_diffusions) const {
227-
const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Ref_Temperature);
227+
const su2double enthalpy_species_N = specificHeat[n_species_mixture - 1] * (Temperature - Std_Ref_Temp_ND);
228228
for (int iVar = 0; iVar < n_species_mixture - 1; iVar++) {
229-
const su2double enthalpy_species_i = specificHeat[iVar] * (Temperature - Ref_Temperature);
229+
const su2double enthalpy_species_i = specificHeat[iVar] * (Temperature - Std_Ref_Temp_ND);
230230
enthalpy_diffusions[iVar] = Density * (enthalpy_species_i * massDiffusivity[iVar] -
231231
enthalpy_species_N * massDiffusivity[n_species_mixture - 1]);
232232
enthalpy_diffusions[iVar] += Mu_Turb * (enthalpy_species_i - enthalpy_species_N) / Schmidt_Turb_Number;
@@ -271,7 +271,7 @@ void CFluidScalar::SetTDState_h(const su2double val_enthalpy, const su2double* v
271271
* depend on temperature, but it does depend on mixture composition, temperature is directly solved from the
272272
* expression h_s = Cp(T - T_ref).
273273
*/
274-
Temperature = val_enthalpy / Cp + Ref_Temperature;
274+
Temperature = val_enthalpy / Cp + Std_Ref_Temp_ND;
275275
Density = Pressure_Thermodynamic / (Temperature * Gas_Constant);
276276
Cv = Cp - Gas_Constant;
277277

@@ -282,4 +282,5 @@ void CFluidScalar::SetTDState_h(const su2double val_enthalpy, const su2double* v
282282
}
283283

284284
Kt = WilkeConductivity(val_scalars);
285+
ComputeMassDiffusivity();
285286
}

0 commit comments

Comments
 (0)