Skip to content

Commit 61ba0f2

Browse files
defining enthalpy in each model and reformulating inlet BC
1 parent 91477ee commit 61ba0f2

File tree

10 files changed

+37
-60
lines changed

10 files changed

+37
-60
lines changed

SU2_CFD/include/fluid/CConstantDensity.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ class CConstantDensity final : public CFluidModel {
5656
decoupled equation. Hence, we update the value.
5757
Note Cp = Cv, (gamma = 1).*/
5858
Temperature = t;
59+
Enthalpy = Cp * Temperature;
5960
}
6061
};

SU2_CFD/include/fluid/CIncIdealGas.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class CIncIdealGas final : public CFluidModel {
5858
/*--- The EoS only depends upon temperature. ---*/
5959
Temperature = t;
6060
Density = Pressure / (Temperature * Gas_Constant);
61+
Enthalpy = Cp * Temperature;
6162
}
6263

6364
private:

SU2_CFD/include/fluid/CIncIdealGasPolynomial.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class CIncIdealGasPolynomial final : public CFluidModel {
8080
Cp += coeffs_[i] * t_i;
8181
}
8282
Cv = Cp / Gamma;
83+
Enthalpy = Cp * Temperature;
8384
}
8485

8586
private:

SU2_CFD/src/fluid/CFluidFlamelet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ void CFluidFlamelet::SetTDState_T(su2double val_temperature, const su2double* va
123123
/*--- Add all quantities and their names to the look up vectors. ---*/
124124
EvaluateDataSet(scalars_vector, FLAMELET_LOOKUP_OPS::THERMO, val_vars_TD);
125125

126+
Enthalpy = scalars_vector[1];
126127
Temperature = val_vars_TD[LOOKUP_TD::TEMPERATURE];
127128
Cp = val_vars_TD[LOOKUP_TD::HEATCAPACITY];
128129
Mu = val_vars_TD[LOOKUP_TD::VISCOSITY];

SU2_CFD/src/numerics/flow/convection/centered.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ CNumerics::ResidualType<> CCentLaxInc_Flow::ComputeResidual(const CConfig* confi
9898
DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2];
9999
BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3];
100100
Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7];
101-
if (energy_multicomponent) {
102-
Enthalpy_i = V_i[nDim + 9];
103-
Enthalpy_j = V_j[nDim + 9];
101+
Enthalpy_i = V_i[nDim + 9]; Enthalpy_j = V_j[nDim + 9];
102+
if (energy_multicomponent) {
104103
WorkingVariable_i = Enthalpy_i;
105104
WorkingVariable_j = Enthalpy_j;
106105
} else {
107-
Enthalpy_i = Cp_i * Temperature_i;
108-
Enthalpy_j = Cp_j * Temperature_j;
109106
WorkingVariable_i = Temperature_i;
110107
WorkingVariable_j = Temperature_j;
111108
}
@@ -339,15 +336,11 @@ CNumerics::ResidualType<> CCentJSTInc_Flow::ComputeResidual(const CConfig* confi
339336
Temperature_i = V_i[nDim+1]; Temperature_j = V_j[nDim+1];
340337
DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2];
341338
BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3];
342-
Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7];
339+
Enthalpy_i = V_i[nDim+9]; Enthalpy_j = V_j[nDim+9];
343340
if (energy_multicomponent) {
344-
Enthalpy_i = V_i[nDim + 9];
345-
Enthalpy_j = V_j[nDim + 9];
346341
WorkingVariable_i = Enthalpy_i;
347342
WorkingVariable_j = Enthalpy_j;
348343
} else {
349-
Enthalpy_i = Cp_i * Temperature_i;
350-
Enthalpy_j = Cp_j * Temperature_j;
351344
WorkingVariable_i = Temperature_i;
352345
WorkingVariable_j = Temperature_j;
353346
}

SU2_CFD/src/numerics/flow/convection/fds.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,11 @@ CNumerics::ResidualType<> CUpwFDSInc_Flow::ComputeResidual(const CConfig *config
119119
DensityInc_i = V_i[nDim+2]; DensityInc_j = V_j[nDim+2];
120120
BetaInc2_i = V_i[nDim+3]; BetaInc2_j = V_j[nDim+3];
121121
Cp_i = V_i[nDim+7]; Cp_j = V_j[nDim+7];
122+
Enthalpy_i = V_i[nDim+9]; Enthalpy_j = V_j[nDim+9];
122123
if (energy_multicomponent) {
123-
Enthalpy_i = V_i[nDim + 9];
124-
Enthalpy_j = V_j[nDim + 9];
125124
WorkingVariable_i = Enthalpy_i;
126125
WorkingVariable_j = Enthalpy_j;
127126
} else {
128-
Enthalpy_i = Cp_i * Temperature_i;
129-
Enthalpy_j = Cp_j * Temperature_j;
130127
WorkingVariable_i = Temperature_i;
131128
WorkingVariable_j = Temperature_j;
132129
}

SU2_CFD/src/numerics/flow/flow_sources.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,7 @@ CNumerics::ResidualType<> CSourceIncAxisymmetric_Flow::ComputeResidual(const CCo
264264
DensityInc_i = V_i[nDim+2];
265265
BetaInc2_i = V_i[nDim+3];
266266
Cp_i = V_i[nDim+7];
267-
if (multicomponent && energy) {
268-
Enthalpy_i = V_i[nDim + 9];
269-
} else {
270-
Enthalpy_i = Cp_i * Temp_i;
271-
}
267+
Enthalpy_i = V_i[nDim + 9];
272268

273269
for (iDim = 0; iDim < nDim; iDim++)
274270
Velocity_i[iDim] = V_i[iDim+1];

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry
150150
const bool compressible = config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE;
151151
const bool incompressible = config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE;
152152
const bool energy = config->GetEnergy_Equation();
153-
const bool multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE;
154153
const bool streamwisePeriodic = (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE);
155154
const bool species = config->GetKind_Species_Model() == SPECIES_MODEL::SPECIES_TRANSPORT;
156155
const auto nSpecies = config->GetnSpecies();
@@ -242,11 +241,7 @@ void CFlowOutput::SetAnalyzeSurface(const CSolver* const*solver, const CGeometry
242241
sqrt(config->GetBulk_Modulus()/(flow_nodes->GetDensity(iPoint)));
243242
}
244243
Temperature = flow_nodes->GetTemperature(iPoint);
245-
if (energy && multicomponent) {
246-
Enthalpy = flow_nodes->GetEnthalpy(iPoint);
247-
} else {
248-
Enthalpy = flow_nodes->GetSpecificHeatCp(iPoint) * Temperature;
249-
}
244+
Enthalpy = flow_nodes->GetEnthalpy(iPoint);
250245
TotalTemperature = Temperature + 0.5*Velocity2/flow_nodes->GetSpecificHeatCp(iPoint);
251246
TotalPressure = Pressure + 0.5*Density*Velocity2;
252247
}

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,10 +2118,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo
21182118
Cp = nodes->GetSpecificHeatCp(iPoint);
21192119
oneOverCp = 1.0/Cp;
21202120
Temperature = nodes->GetTemperature(iPoint);
2121-
Enthalpy = Cp * Temperature;
2122-
if (energy && multicomponent) {
2123-
Enthalpy = nodes->GetEnthalpy(iPoint);
2124-
}
2121+
Enthalpy = nodes->GetEnthalpy(iPoint);
21252122

21262123
for (iDim = 0; iDim < nDim; iDim++)
21272124
Velocity[iDim] = nodes->GetVelocity(iPoint,iDim);
@@ -2131,7 +2128,7 @@ void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPo
21312128
law, but in the future, dRhodT should be in the fluid model. ---*/
21322129

21332130
if (variable_density) {
2134-
if (multicomponent && energy){
2131+
if (multicomponent){
21352132
dRhodT = -Density / (Cp * Temperature);
21362133
Cp = oneOverCp = 1.0;
21372134
} else {
@@ -2229,7 +2226,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
22292226

22302227
const bool implicit = config->GetKind_TimeIntScheme() == EULER_IMPLICIT;
22312228
const bool viscous = config->GetViscous();
2232-
const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation();
2229+
const bool species_model = config->GetKind_Species_Model() != SPECIES_MODEL::NONE;
22332230

22342231
su2double Normal[MAXNDIM] = {0.0};
22352232

@@ -2274,14 +2271,12 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
22742271

22752272
V_infty[prim_idx.Temperature()] = GetTemperature_Inf();
22762273

2277-
/*-- Enthalpy at far-field is needed for energy equation in multicomponent and reacting flows. ---*/
2278-
if (energy_multicomponent) {
2279-
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();
2280-
const su2double* scalar_infty = config->GetSpecies_Init();
2281-
auxFluidModel->SetTDState_T(V_infty[prim_idx.Temperature()],
2282-
scalar_infty); // obtain enthalpy from temperature and species mass fractions
2283-
V_infty[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
2284-
}
2274+
/*-- Enthalpy at far-field. ---*/
2275+
const su2double* scalar_infty = nullptr;
2276+
if (species_model) scalar_infty = config->GetSpecies_Init();
2277+
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();
2278+
auxFluidModel->SetTDState_T(V_infty[prim_idx.Temperature()], scalar_infty);
2279+
V_infty[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
22852280

22862281
/*--- Store the density. ---*/
22872282

@@ -2318,7 +2313,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain
23182313

23192314
/*--- Viscous residual contribution ---*/
23202315

2321-
if (!viscous || energy_multicomponent) continue;
2316+
if (!viscous || species_model) continue;
23222317

23232318
/*--- Set transport properties at infinity. ---*/
23242319

@@ -2373,7 +2368,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
23732368

23742369
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
23752370
const bool viscous = config->GetViscous();
2376-
const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation();
2371+
const bool species_model = config->GetKind_Species_Model() != SPECIES_MODEL::NONE;
23772372

23782373
string Marker_Tag = config->GetMarker_All_TagBound(val_marker);
23792374

@@ -2537,13 +2532,12 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
25372532
V_inlet[prim_idx.Pressure()] = nodes->GetPressure(iPoint);
25382533
}
25392534

2540-
/*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/
2541-
if (energy_multicomponent) {
2542-
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();
2543-
const su2double* scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker));
2544-
auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], scalar_inlet);
2545-
V_inlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
2546-
}
2535+
/*-- Enthalpy is needed for energy equation. ---*/
2536+
const su2double* scalar_inlet = nullptr;
2537+
if (species_model) scalar_inlet = config->GetInlet_SpeciesVal(config->GetMarker_All_TagBound(val_marker));
2538+
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();
2539+
auxFluidModel->SetTDState_T(V_inlet[prim_idx.Temperature()], scalar_inlet);
2540+
V_inlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
25472541

25482542
/*--- Access density at the node. This is either constant by
25492543
construction, or will be set fixed implicitly by the temperature
@@ -2582,7 +2576,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
25822576

25832577
/*--- Viscous contribution, commented out because serious convergence problems ---*/
25842578

2585-
if (!viscous || energy_multicomponent) continue;
2579+
if (!viscous || species_model) continue;
25862580

25872581
/*--- Set transport properties at the inlet ---*/
25882582

@@ -2634,7 +2628,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
26342628

26352629
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
26362630
const bool viscous = config->GetViscous();
2637-
const bool energy_multicomponent = config->GetKind_FluidModel() == FLUID_MIXTURE && config->GetEnergy_Equation();
2631+
const bool species_model = config->GetKind_Species_Model() != SPECIES_MODEL::NONE;
26382632
string Marker_Tag = config->GetMarker_All_TagBound(val_marker);
26392633

26402634
su2double Normal[MAXNDIM] = {0.0};
@@ -2761,14 +2755,12 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
27612755

27622756
V_outlet[prim_idx.CpTotal()] = nodes->GetSpecificHeatCp(iPoint);
27632757

2764-
/*-- Enthalpy is needed for energy equation in multicomponent and reacting flows. ---*/
2765-
if (energy_multicomponent) {
2766-
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();;
2767-
const su2double* scalar_outlet = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint);
2768-
auxFluidModel->SetTDState_T(nodes->GetTemperature(iPoint),
2769-
scalar_outlet); // compute total enthalpy from temperature
2770-
V_outlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
2771-
}
2758+
/*-- Enthalpy is needed for energy equation. ---*/
2759+
const su2double* scalar_outlet = nullptr;
2760+
if (species_model) scalar_outlet = solver_container[SPECIES_SOL]->GetNodes()->GetSolution(iPoint);
2761+
CFluidModel* auxFluidModel = solver_container[FLOW_SOL]->GetFluidModel();
2762+
auxFluidModel->SetTDState_T(nodes->GetTemperature(iPoint), scalar_outlet);
2763+
V_outlet[prim_idx.Enthalpy()] = auxFluidModel->GetEnthalpy();
27722764

27732765
/*--- Set various quantities in the solver class ---*/
27742766

@@ -2794,7 +2786,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
27942786

27952787
/*--- Viscous contribution, commented out because serious convergence problems ---*/
27962788

2797-
if (!viscous || energy_multicomponent) continue;
2789+
if (!viscous || species_model) continue;
27982790

27992791
/*--- Set transport properties at the outlet. ---*/
28002792

SU2_CFD/src/variables/CIncNSVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2do
146146

147147
SetSpecificHeatCp(iPoint, FluidModel->GetCp());
148148
SetSpecificHeatCv(iPoint, FluidModel->GetCv());
149-
if (Energy_Multicomponent) SetEnthalpy(iPoint, FluidModel->GetEnthalpy());
149+
SetEnthalpy(iPoint, FluidModel->GetEnthalpy());
150150

151151
return physical;
152152

0 commit comments

Comments
 (0)