https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
GasTransportUtilsTest.C File Reference

Go to the source code of this file.

Functions

 TEST_F (GasTransportUtilsTest, canteraViscosity)
 
 TEST_F (GasTransportUtilsTest, canteraDiffusion)
 
 TEST_F (GasTransportUtilsTest, polingExample)
 
 TEST_F (GasTransportUtilsTest, steamZeroDensity)
 
 TEST_F (GasTransportUtilsTest, derivatives)
 

Function Documentation

◆ TEST_F() [1/5]

TEST_F ( GasTransportUtilsTest  ,
canteraDiffusion   
)

Definition at line 62 of file GasTransportUtilsTest.C.

63{
64 // Binary diffusion coefficients at 1e5 Pa computed with Cantera 3.2.0 from gri30.yaml. For pairs
65 // without a dipole moment the two agree within 0.1% from 300 K to 3000 K. Cantera adds a dipole
66 // correction for pairs with H2O, which changes their coefficients by up to 4%.
67 const Real p = 1e5;
68 const Real tol = 2e-3;
69 const Real tol_H2O = 5e-2;
70 struct Reference
71 {
72 Real T;
73 std::string species_i;
74 std::string species_j;
75 Real D;
76 };
77 const std::vector<Reference> references = {{300.0, "N2", "O2", 2.114004397958847e-05},
78 {300.0, "H2", "N2", 7.892785088901448e-05},
79 {300.0, "CH4", "CO2", 1.7394895936669404e-05},
80 {300.0, "H2", "CO", 7.818547081111362e-05},
81 {300.0, "CO", "CO2", 1.58357230065214e-05},
82 {300.0, "H2O", "N2", 2.2961566123205863e-05},
83 {300.0, "H2O", "H2", 8.662561051685164e-05},
84 {1000.0, "N2", "O2", 0.00016508453019480936},
85 {1000.0, "H2", "N2", 0.0005928256767875003},
86 {1000.0, "CH4", "CO2", 0.00014842228814550512},
87 {1000.0, "H2", "CO", 0.0005873361123312881},
88 {1000.0, "CO", "CO2", 0.00013074964295438555},
89 {1000.0, "H2O", "N2", 0.0002111137941842763},
90 {1000.0, "H2O", "H2", 0.000727354808885168},
91 {2500.0, "N2", "O2", 0.0007553835721572624},
92 {2500.0, "H2", "N2", 0.0027020824913847425},
93 {2500.0, "CH4", "CO2", 0.0006888837584287778},
94 {2500.0, "H2", "CO", 0.002677091367171154},
95 {2500.0, "CO", "CO2", 0.0006031661492209093}};
96
97 for (const auto & ref : references)
98 {
100 p,
101 ref.T,
102 molarMass(ref.species_i),
103 molarMass(ref.species_j),
106 REL_TEST(D, ref.D, ref.species_i == "H2O" ? tol_H2O : tol);
107 }
108}
const double tol
const Real p
const double T
CppType binaryDiffusionCoefficient(const CppType &p, const CppType &T, const Real molar_mass_i, const Real molar_mass_j, const LennardJonesParameters &lj_i, const LennardJonesParameters &lj_j)
Chapman-Enskog binary diffusion coefficient of a dilute gas pair [m^2/s], with the Lorentz-Berthelot ...
const LennardJonesParameters & lennardJonesParameters(const std::string &name)
Lennard-Jones parameters of a built-in species.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [2/5]

TEST_F ( GasTransportUtilsTest  ,
canteraViscosity   
)

Definition at line 25 of file GasTransportUtilsTest.C.

26{
27 // Viscosities at 1e5 Pa computed with Cantera 3.2.0 from gri30.yaml for the species without a
28 // dipole moment. Cantera evaluates the collision integrals and fits the viscosity differently,
29 // and the two agree within 0.5% from 300 K to 3000 K.
30 const Real tol = 6e-3;
31 const std::vector<std::pair<Real, std::vector<std::pair<std::string, Real>>>> references = {
32 {300.0,
33 {{"H2", 9.000177310613688e-06},
34 {"O2", 2.065378948167078e-05},
35 {"CH4", 1.1453629801108389e-05},
36 {"CO", 1.777126940240487e-05},
37 {"CO2", 1.5048181672334403e-05},
38 {"N2", 1.80854698821696e-05}}},
39 {1000.0,
40 {{"H2", 1.9676368365578972e-05},
41 {"O2", 4.7911694307285326e-05},
42 {"CH4", 2.7657970234929e-05},
43 {"CO", 4.0801958261007516e-05},
44 {"CO2", 4.09913251119492e-05},
45 {"N2", 4.149814387750264e-05}}},
46 {2500.0,
47 {{"H2", 3.5525956370270646e-05},
48 {"O2", 8.681334277254339e-05},
49 {"CH4", 5.031808575692049e-05},
50 {"CO", 7.387175858990157e-05},
51 {"CO2", 7.612436248107707e-05},
52 {"N2", 7.512886600196423e-05}}}};
53
54 for (const auto & [T, values] : references)
55 for (const auto & [species, mu] : values)
57 T, molarMass(species), GasTransportUtils::lennardJonesParameters(species)),
58 mu,
59 tol);
60}
const double mu
std::array< Real, 2 > values
for(PetscInt i=0;i< nvars;++i)
Transport properties of dilute gases: Lennard-Jones parameters of the NASA 7-coefficient species,...
CppType viscosity(const CppType &T, const Real molar_mass, const LennardJonesParameters &lj)
Chapman-Enskog viscosity of a dilute gas [Pa s].

◆ TEST_F() [3/5]

TEST_F ( GasTransportUtilsTest  ,
derivatives   
)

Definition at line 137 of file GasTransportUtilsTest.C.

138{
139 // Derivatives from automatic differentiation with respect to temperature (index 0) and pressure
140 // (index 1) agree with central differences
141 const Real T = 800;
142 const Real p = 2e5;
143 DNDerivativeType dT_dT, dp_dp;
144 Moose::derivInsert(dT_dT, 0, 1);
145 Moose::derivInsert(dp_dp, 1, 1);
146 const ADReal T_ad(T, dT_dT);
147 const ADReal p_ad(p, dp_dp);
148 const Real h = REL_PERTURBATION * T;
149
150 const auto lj_H2 = GasTransportUtils::lennardJonesParameters("H2");
151 const auto lj_N2 = GasTransportUtils::lennardJonesParameters("N2");
152 const auto mu = [&lj_N2](const auto & T)
153 { return GasTransportUtils::viscosity(T, molarMass("N2"), lj_N2); };
154 const auto D = [&lj_H2, &lj_N2](const auto & p, const auto & T)
155 {
157 p, T, molarMass("H2"), molarMass("N2"), lj_H2, lj_N2);
158 };
159
160 REL_TEST(mu(T_ad).derivatives()[0], (mu(T + h) - mu(T - h)) / (2 * h), REL_TOL_DERIVATIVE);
161 REL_TEST(
162 D(p_ad, T_ad).derivatives()[0], (D(p, T + h) - D(p, T - h)) / (2 * h), REL_TOL_DERIVATIVE);
163 // The diffusion coefficient is inversely proportional to pressure
164 REL_TEST(D(p_ad, T_ad).derivatives()[1], -D(p, T) / p, REL_TOL_CONSISTENCY);
165 REL_TEST(GasTransportUtils::steamViscosityZeroDensity(T_ad).derivatives()[0],
168 (2 * h),
169 REL_TOL_DERIVATIVE);
170 REL_TEST(GasTransportUtils::steamConductivityZeroDensity(T_ad).derivatives()[0],
173 (2 * h),
174 REL_TOL_DERIVATIVE);
175}
DualNumber< Real, DNDerivativeType, true > ADReal
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
CppType steamViscosityZeroDensity(const CppType &T)
Viscosity of steam in the limit of zero density [Pa s], from the IAPWS 2008 formulation,...
CppType steamConductivityZeroDensity(const CppType &T)
Thermal conductivity of steam in the limit of zero density [W/(m K)], from the IAPWS 2011 formulation...
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)

◆ TEST_F() [4/5]

TEST_F ( GasTransportUtilsTest  ,
polingExample   
)

Definition at line 110 of file GasTransportUtilsTest.C.

111{
112 // Example 11-1 of Poling et al. (2001): N2 and CO2 at 590 K and 1 bar, with the Lennard-Jones
113 // parameters and molar masses of that example. It reports 0.52 cm^2/s after rounding.
114 const GasTransportUtils::LennardJonesParameters n2{3.798e-10, 71.4};
115 const GasTransportUtils::LennardJonesParameters co2{3.941e-10, 195.2};
116 const Real p = 1e5;
117 const Real T = 590;
118 ABS_TEST(GasTransportUtils::binaryDiffusionCoefficient(p, T, 28.014e-3, 44.010e-3, n2, co2),
119 0.52e-4,
120 0.005e-4);
121}
Parameters of the Lennard-Jones (12-6) potential of a species.

◆ TEST_F() [5/5]

TEST_F ( GasTransportUtilsTest  ,
steamZeroDensity   
)

Definition at line 123 of file GasTransportUtilsTest.C.

124{
125 // Water97FluidProperties evaluates the same low-density viscosity times a factor that tends to
126 // one with the density. At 1e-10 kg/m^3 that factor differs from one by about 4e-12.
127 const Real rho = 1e-10;
128 for (const Real T : {300.0, 600.0, 900.0, 1200.0})
129 REL_TEST(GasTransportUtils::steamViscosityZeroDensity(T), _water->mu_from_rho_T(rho, T), 1e-10);
130
131 // Verification values of the thermal conductivity at zero density from the IAPWS 2011 release,
132 // given to nine significant digits in mW/(m K)
133 REL_TEST(GasTransportUtils::steamConductivityZeroDensity(298.15), 18.4341883e-3, 1e-8);
134 REL_TEST(GasTransportUtils::steamConductivityZeroDensity(873.15), 79.1034659e-3, 1e-8);
135}
const double rho