Skip to content

Commit a36e84e

Browse files
committed
add protection for zero electron massfraction for GY
1 parent b43b50c commit a36e84e

4 files changed

Lines changed: 35 additions & 22 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,8 +3936,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
39363936
SU2_MPI::Error("Transport model not available for NEMO solver using SU2TCLIB. Please use the WILKE, SUTHERLAND or GUPTAYOS transport model instead.", CURRENT_FUNCTION);
39373937
}
39383938

3939-
if (Kind_FluidModel == SU2_NONEQ && GasModel == "AIR-7" && Kind_TransCoeffModel != TRANSCOEFFMODEL::GUPTAYOS) {
3940-
SU2_MPI::Error("Only Gupta-Yos transport model available for ionized flows using SU2TCLIB.", CURRENT_FUNCTION);
3939+
if (Kind_Solver == NEMO_NAVIER_STOKES) {
3940+
if (Kind_FluidModel == SU2_NONEQ && GasModel == "AIR-7" && Kind_TransCoeffModel != TRANSCOEFFMODEL::GUPTAYOS) {
3941+
SU2_MPI::Error("Only Gupta-Yos transport model available for ionized flows using SU2TCLIB.", CURRENT_FUNCTION);
3942+
}
39413943
}
39423944

39433945
if (Kind_FluidModel == MUTATIONPP &&

SU2_CFD/src/fluid/CMutationTCLib.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ CMutationTCLib::CMutationTCLib(const CConfig* config, unsigned short val_nDim):
5858
/* Initialize mixture object */
5959
mix.reset(new Mutation::Mixture(opt));
6060

61-
for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) MolarMass[iSpecies] = 1000* mix->speciesMw(iSpecies); // x1000 to have Molar Mass in kg/kmol
61+
// x1000 to have Molar Mass in kg/kmol
62+
for(iSpecies = 0; iSpecies < nSpecies; iSpecies++)
63+
MolarMass[iSpecies] = 1000* mix->speciesMw(iSpecies);
6264

6365
if (mix->hasElectrons()) { nHeavy = nSpecies-1; nEl = 1; }
6466
else { nHeavy = nSpecies; nEl = 0; }

SU2_CFD/src/fluid/CSU2TCLib.cpp

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,21 +1952,23 @@ void CSU2TCLib::DiffusionCoeffGY(){
19521952
DiffusionCoeff[iSpecies] = 0.0;
19531953

19541954
/*--- Calculate molar concentration ---*/
1955-
const su2double Mi = MolarMass[iSpecies];
1955+
const su2double Mi = (MolarMass[iSpecies] + EPS);
19561956
const su2double gam_i = rhos[iSpecies] / (Density*Mi);
19571957
su2double denom = 0.0;
19581958

19591959
for (jSpecies = 0; jSpecies < nSpecies; jSpecies++) {
19601960
if (jSpecies != iSpecies) {
19611961

1962-
const su2double Mj = MolarMass[jSpecies];
1962+
const su2double Mj = (MolarMass[jSpecies] + EPS);
19631963
const su2double gam_j = rhos[jSpecies] / (Density*Mj);
19641964

19651965
const su2double kb = BOLTZMANN_CONSTANT;
19661966

19671967
const su2double T_col = (iSpecies == 0 && ionization) ? Tve : T;
19681968

1969-
const su2double d1_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, true);
1969+
su2double d1_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, true);
1970+
if (d1_ij > 1E16) d1_ij = 1E16;
1971+
19701972
const su2double D_ij = kb*T_col/(Pressure*d1_ij);
19711973
denom += gam_j/D_ij;
19721974
}
@@ -1987,16 +1989,18 @@ void CSU2TCLib::ViscosityGY(){
19871989
su2double denom = 0.0;
19881990

19891991
/*--- Calculate molar concentration ---*/
1990-
const su2double Mi = MolarMass[iSpecies];
1992+
const su2double Mi = (MolarMass[iSpecies] + EPS);
19911993
const su2double gam_i = rhos[iSpecies] / (Density*Mi);
19921994

19931995
for (jSpecies = 0; jSpecies < nSpecies; jSpecies++) {
1994-
const su2double Mj = MolarMass[jSpecies];
1996+
const su2double Mj = (MolarMass[jSpecies] + EPS);
19951997
const su2double gam_j = rhos[jSpecies] / (Density*Mj);
19961998

19971999
const su2double T_col = (iSpecies == 0 && ionization) ? Tve : T;
19982000

1999-
const su2double d2_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, false);
2001+
su2double d2_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, false);
2002+
if (d2_ij > 1E16) d2_ij = 1E16;
2003+
20002004
denom += gam_j*d2_ij;
20012005
}
20022006
/*--- Calculate species laminar viscosity ---*/
@@ -2028,33 +2032,38 @@ void CSU2TCLib::ThermalConductivitiesGY(){
20282032
for (iSpecies = 0; iSpecies < nSpecies; iSpecies++) {
20292033

20302034
/*--- Calculate molar concentration ---*/
2031-
const su2double Mi = MolarMass[iSpecies];
2032-
const su2double mi = Mi/Na;
2033-
const su2double gam_i = rhos[iSpecies] / (Density*Mi);
2035+
const su2double Mi = (MolarMass[iSpecies] + EPS);
2036+
const su2double mi = Mi/Na;
2037+
const su2double gam_i = rhos[iSpecies] / (Density*Mi);
20342038
su2double denom_t = 0.0;
20352039
su2double denom_r = 0.0;
20362040
su2double denom_re = 0.0;
20372041

20382042
for (jSpecies = 0; jSpecies < nSpecies; jSpecies++) {
2039-
const su2double Mj = MolarMass[jSpecies];
2043+
const su2double Mj = (MolarMass[jSpecies] + EPS);
20402044
const su2double mj = Mj/Na;
20412045
const su2double gam_j = rhos[iSpecies] / (Density*Mj);
20422046
const su2double a_ij = 1.0 + (1.0 - mi/mj)*(0.45 - 2.54*mi/mj) / ((1.0 + mi/mj)*(1.0 + mi/mj));
20432047

20442048
const su2double T_col = ((iSpecies == 0 && ionization) || (jSpecies == 0 && ionization)) ? Tve : T;
20452049

2046-
const su2double d1_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, true);
2047-
const su2double d2_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, false);
2048-
2049-
if (jSpecies == 0 && ionization) {
2050-
denom_t += 3.54*gam_j*d2_ij;
2051-
} else {
2052-
denom_t += a_ij*gam_j*d2_ij;
2053-
}
2050+
su2double d1_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, true);
2051+
su2double d2_ij = ComputeCollisionDelta(iSpecies, jSpecies, Mi, Mj, T_col, false);
2052+
if (d1_ij >1E16) d1_ij = 1E16;
2053+
if (d2_ij >1E16) d2_ij = 1E16;
2054+
2055+
if (jSpecies == 0 && ionization) { denom_t += 3.54*gam_j*d2_ij; }
2056+
else { denom_t += a_ij*gam_j*d2_ij; }
2057+
20542058
denom_r += gam_j*d1_ij;
20552059
denom_re += gam_j*d2_ij;
20562060
}
20572061

2062+
/*--- Prevent divide by 0 ---*/
2063+
if (denom_t == 0.0) denom_t = EPS;
2064+
if (denom_r == 0.0) denom_r = EPS;
2065+
if (denom_re == 0.0) denom_re = EPS;
2066+
20582067
/*--- Translational contribution to thermal conductivity ---*/
20592068
if (!(ionization && iSpecies == 0)) ThermalCond_tr += ((15.0/4.0)*kb*gam_i/denom_t);
20602069

TestCases/parallel_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def main():
188188
ion_gy.cfg_dir = "nonequilibrium/visc_cylinder"
189189
ion_gy.cfg_file = "cyl_ion_gy.cfg"
190190
ion_gy.test_iter = 10
191-
ion_gy.test_vals = [-11.629871, -4.156742, -4.692113, -4.949447, -5.146196, -4.991664, -6.893329, 5.990109, 5.990004, -0.014849, 0.000000, 90090.000000]
191+
ion_gy.test_vals = [-11.629873, -4.165563, -4.702662, -4.950351, -5.146155, -4.993878, -6.893332, 5.990109, 5.990004, -0.014849, 0.000000, 90090.000000]
192192
ion_gy.su2_exec = "mpirun -n 2 SU2_CFD"
193193
ion_gy.timeout = 1600
194194
ion_gy.new_output = True

0 commit comments

Comments
 (0)