18 std::vector<Real>
x = {0.7};
20 const Real
v = 1.38490747936373;
21 const Real
rho = 0.7220698962933115;
22 const Real e = 1.995566878921797e+06;
23 const Real s = 3362.64537354375;
24 const Real
c = 442.127817187648;
25 const Real cp = 1187.64406714542;
26 const Real cv = 841.417197304492;
27 const Real
mu = 1.863687329029527e-05;
28 const Real k = 0.0304142253602899;
30 REL_TEST(_fp_mix->p_from_v_e(
v, e,
x),
p, REL_TOL_SAVED_VALUE);
31 REL_TEST(_fp_mix->T_from_v_e(
v, e,
x),
T, REL_TOL_SAVED_VALUE);
32 REL_TEST(_fp_mix->v_from_p_T(
p,
T,
x),
v, REL_TOL_SAVED_VALUE);
33 REL_TEST(_fp_mix->rho_from_p_T(
p,
T,
x),
rho, REL_TOL_SAVED_VALUE);
34 REL_TEST(_fp_mix->e_from_p_T(
p,
T,
x), e, REL_TOL_SAVED_VALUE);
35 REL_TEST(_fp_mix->e_from_p_rho(
p,
rho,
x), e, REL_TOL_SAVED_VALUE);
36 REL_TEST(_fp_mix->s_from_p_T(
p,
T,
x), s, REL_TOL_SAVED_VALUE);
41 const Real M_steam = 0.01801488;
42 const Real M_nitrogen = 0.028012734746133888;
43 const Real M_mix = 1.0 / ((1.0 -
x[0]) / M_steam +
x[0] / M_nitrogen);
44 const Real psi_steam = (1.0 -
x[0]) * M_mix / M_steam;
45 const Real psi_nitrogen =
x[0] * M_mix / M_nitrogen;
46 const Real s_unmixed =
47 (1.0 -
x[0]) * _fp_steam->s_from_p_T(
p,
T) +
x[0] * _fp_nitrogen->s_from_p_T(
p,
T);
49 (psi_steam * std::log(psi_steam) + psi_nitrogen * std::log(psi_nitrogen));
50 REL_TEST(_fp_mix->s_from_p_T(
p,
T,
x), s_unmixed + s_mixing, REL_TOL_CONSISTENCY);
52 REL_TEST(_fp_mix->c_from_p_T(
p,
T,
x),
c, REL_TOL_SAVED_VALUE);
53 REL_TEST(_fp_mix->cp_from_p_T(
p,
T,
x), cp, REL_TOL_SAVED_VALUE);
54 REL_TEST(_fp_mix->cv_from_p_T(
p,
T,
x), cv, REL_TOL_SAVED_VALUE);
55 REL_TEST(_fp_mix->mu_from_p_T(
p,
T,
x),
mu, REL_TOL_SAVED_VALUE);
56 REL_TEST(_fp_mix->k_from_p_T(
p,
T,
x), k, REL_TOL_SAVED_VALUE);
62 const Real rel_pert = REL_PERTURBATION;
63 const Real fpert1 = 1 + rel_pert;
64 const Real fpert2 = 1 - rel_pert;
66 (_fp_mix->v_from_p_T(
p * fpert1,
T,
x) - _fp_mix->v_from_p_T(
p * fpert2,
T,
x)) /
69 (_fp_mix->v_from_p_T(
p,
T * fpert1,
x) - _fp_mix->v_from_p_T(
p,
T * fpert2,
x)) /
72 (_fp_mix->s_from_p_T(
p * fpert1,
T,
x) - _fp_mix->s_from_p_T(
p * fpert2,
T,
x)) /
75 (_fp_mix->s_from_p_T(
p,
T * fpert1,
x) - _fp_mix->s_from_p_T(
p,
T * fpert2,
x)) /
77 const Real dpdv_s = 1.0 / (dvdp_T - dvdT_p * dsdp_T / dsdT_p);
78 const Real c_gold =
v * std::sqrt(-dpdv_s);
79 REL_TEST(_fp_mix->c_from_p_T(
p,
T,
x), c_gold, REL_TOL_DERIVATIVE);
81 const Real x_steam = 0.3;
82 const Real x_nitrogen = 0.7;
84 const Real M_steam = 0.01801488;
85 const Real M_nitrogen = 0.028012734746133888;
86 const Real
M = 1.0 / (x_steam / M_steam + x_nitrogen / M_nitrogen);
89 REL_TEST(
v, v_gold, REL_TOL_SAVED_VALUE);
114 (
f(
a + ha, b, std::vector<Real>{
x}) -
f(
a - ha, b, std::vector<Real>{
x})) / (2 * ha),
117 (
f(
a, b + hb, std::vector<Real>{
x}) -
f(
a, b - hb, std::vector<Real>{
x})) / (2 * hb),
170 const std::vector<Real>
x = {0.3, 0.7};
171 REL_TEST(_fp_mix->mixtureSpecificHeatRatio(
x),
172 _fp_mix->mixtureSpecificHeatRatio(100000.0, 400.0,
x),
173 REL_TOL_CONSISTENCY);
176 const std::vector<std::string> species = {
"N2",
"O2"};
177 const std::string
name =
"air";
178 const auto & air = buildNASA7Mixture(species,
name);
179 EXPECT_THROW(air.mixtureSpecificHeatRatio(std::vector<Real>{0.767, 0.233}), std::exception);
190 const std::vector<std::string> species = {
"H2O",
"H2",
"CO",
"CO2",
"CH4",
"N2"};
191 const std::string
name =
"reformate";
192 const auto &
fp = buildNASA7Mixture(species,
name);
193 const std::vector<Real>
x = {0.03266496536638716,
198 const Real
p = 1.5e5;
199 const Real
T = 1073.15;
201 const Real
tol = 1e-12;
203 const Real
rho = 0.311262086619508 / R_ratio;
204 const Real e = -7502142.694955811 * R_ratio;
206 REL_TEST(
fp.e_from_p_T(
p,
T,
x), e,
tol);
207 REL_TEST(
fp.cp_from_p_T(
p,
T,
x), 2216.7883592581443 * R_ratio,
tol);
208 REL_TEST(
fp.cv_from_p_T(
p,
T,
x), 1767.7281187454187 * R_ratio,
tol);
209 REL_TEST(
fp.c_from_p_T(
p,
T,
x), 777.386327867082 * std::sqrt(R_ratio),
tol);
212 REL_TEST(
fp.T_from_v_e(1 /
rho, e,
x),
T, REL_TOL_CONSISTENCY);
213 REL_TEST(
fp.p_from_v_e(1 /
rho, e,
x),
p, REL_TOL_CONSISTENCY);
214 REL_TEST(
fp.e_from_p_rho(
p,
rho,
x), e, REL_TOL_CONSISTENCY);
226 const std::vector<Real> &
x,
230 const unsigned int n = 60;
231 for (
const auto i : make_range(n + 1))
233 const Real
T = T_low * std::pow(T_high / T_low, Real(i) / n);
234 REL_TEST(
fp.T_from_v_e(
v,
fp.e_from_p_T(
p,
T,
x),
x),
T, REL_TOL_CONSISTENCY);
240 const std::vector<std::string> reformate_species = {
"H2O",
"H2",
"CO",
"CO2",
"CH4",
"N2"};
241 const std::string reformate_name =
"reformate";
242 const auto & reformate = buildNASA7Mixture(reformate_species, reformate_name);
243 sweep(reformate, {0.033, 0.151, 0.357, 0.043, 0.076}, 150, 5250);
246 const std::vector<std::string> air_species = {
"N2",
"O2"};
247 const std::string air_name =
"air";
248 const auto & air = buildNASA7Mixture(air_species, air_name);
249 const std::vector<Real> x_air = {0.233};
250 sweep(air, x_air, 150, 5250);
254 const std::vector<std::string> methane_nitrogen_species = {
"N2",
"CH4"};
255 const std::string methane_nitrogen_name =
"methane_nitrogen";
256 const auto & methane_nitrogen =
257 buildNASA7Mixture(methane_nitrogen_species, methane_nitrogen_name);
258 sweep(methane_nitrogen, {0.5}, 150, 5250);
263 for (
const Real e : {-1e-3, -1e-6, 0.0, 1e-6, 1e-3})
265 const Real
T = air.T_from_v_e(
v, e, x_air);
267 air.e_from_p_T(
p,
T, x_air), e, REL_TOL_CONSISTENCY * air.cv_from_p_T(
p,
T, x_air) *
T);
273 InputParameters params = _factory.getValidParams(
"NASA7IdealGasFluidProperties");
275 _fe_problem->addUserObject(
"NASA7IdealGasFluidProperties",
"co2", params);
278 InputParameters params = _factory.getValidParams(
"IdealGasMixtureFluidProperties");
279 params.
set<std::vector<UserObjectName>>(
"component_fluid_properties") = {
"fp_nitrogen",
"co2"};
280 _fe_problem->addUserObject(
"IdealGasMixtureFluidProperties",
"nitrogen_co2", params);
304 const std::vector<std::string> species = {
"N2",
"O2",
"H2",
"CO2"};
305 const std::vector<Real> molar_masses = {0.028014, 0.031998, 0.002016, 0.044009};
306 const std::vector<Real> viscosities = {
307 4.149814387750263e-05, 4.791169430728531e-05, 1.967636836557897e-05, 4.099132511194919e-05};
308 const std::vector<Real>
x = {0.1343776247270284, 0.025398958508315132, 0.3696371577355955};
309 const Real mu_mix = 4.1726130812941113e-05;
311 std::vector<UserObjectName> component_names;
312 for (
const auto i : index_range(species))
314 const std::string
name =
"wilke_" + species[i];
315 InputParameters params = _factory.getValidParams(
"IdealGasFluidProperties");
316 params.
set<Real>(
"molar_mass") = molar_masses[i];
317 params.
set<Real>(
"mu") = viscosities[i];
318 _fe_problem->addUserObject(
"IdealGasFluidProperties",
name, params);
319 component_names.push_back(
name);
321 InputParameters params = _factory.getValidParams(
"IdealGasMixtureFluidProperties");
322 params.
set<std::vector<UserObjectName>>(
"component_fluid_properties") = component_names;
323 params.
set<
MooseEnum>(
"transport_mixing_rule") =
"wilke";
324 _fe_problem->addUserObject(
"IdealGasMixtureFluidProperties",
"wilke_mixture", params);
329 REL_TEST(
fp.mu_from_p_T(
p,
T,
x), mu_mix, REL_TOL_SAVED_VALUE);
332 REL_TEST(
fp.mu_from_p_T(
p,
T, {0, 0, 0}), viscosities[0], REL_TOL_SAVED_VALUE);
343 const auto build_mixture = [
this](
const std::string &
name,
344 const std::vector<Real> & molar_masses,
345 const std::vector<Real> & viscosities,
346 const std::vector<Real> & conductivities)
348 std::vector<UserObjectName> component_names;
349 for (
const auto i : index_range(molar_masses))
351 const std::string component_name =
name +
"_" + std::to_string(i);
352 InputParameters params = _factory.getValidParams(
"IdealGasFluidProperties");
353 params.
set<Real>(
"molar_mass") = molar_masses[i];
354 params.
set<Real>(
"mu") = viscosities[i];
355 params.
set<Real>(
"k") = conductivities[i];
356 _fe_problem->addUserObject(
"IdealGasFluidProperties", component_name, params);
357 component_names.push_back(component_name);
359 InputParameters params = _factory.getValidParams(
"IdealGasMixtureFluidProperties");
360 params.
set<std::vector<UserObjectName>>(
"component_fluid_properties") = component_names;
361 params.
set<
MooseEnum>(
"transport_mixing_rule") =
"wilke";
362 _fe_problem->addUserObject(
"IdealGasMixtureFluidProperties",
name, params);
370 const std::vector<Real> molar_masses = {0.028014, 0.031998, 0.002016, 0.044009};
371 const std::vector<Real> viscosities = {4.15e-05, 4.79e-05, 1.97e-05, 4.10e-05};
372 const Real factor = 1500;
373 std::vector<Real> conductivities;
374 for (
const auto mu : viscosities)
375 conductivities.push_back(factor *
mu);
376 const auto * proportional =
377 build_mixture(
"proportional", molar_masses, viscosities, conductivities);
378 const std::vector<Real>
x = {0.13, 0.03, 0.37};
379 REL_TEST(proportional->k_from_p_T(
p,
T,
x),
380 factor * proportional->mu_from_p_T(
p,
T,
x),
381 REL_TOL_CONSISTENCY);
383 const auto * equal = build_mixture(
"equal", {0.028, 0.028}, {4e-5, 4e-5}, {0.06, 0.08});
384 REL_TEST(equal->k_from_p_T(
p,
T, {0.25}), 0.75 * 0.06 + 0.25 * 0.08, REL_TOL_CONSISTENCY);
415 const auto &
fp = buildNASA7Mixture({
"N2",
"O2",
"H2"},
"diffusion");
418 const Real
tol = 2e-3;
419 REL_TEST(
fp.binaryDiffusionCoefficient(
p,
T, 0, 1), 0.00016508453019480936,
tol);
420 REL_TEST(
fp.binaryDiffusionCoefficient(
p,
T, 2, 0), 0.0005928256767875003,
tol);
423 REL_TEST(
fp.binaryDiffusionCoefficient(
p,
T, 0, 2),
424 fp.binaryDiffusionCoefficient(
p,
T, 2, 0),
425 REL_TOL_CONSISTENCY);
433 const Real D =
fp.binaryDiffusionCoefficient(
p,
T, 0, 2);
434 const Real h = REL_PERTURBATION *
T;
435 REL_TEST(D_ad, D, REL_TOL_CONSISTENCY);
436 REL_TEST(D_ad.derivatives()[0], -D /
p, REL_TOL_CONSISTENCY);
437 REL_TEST(D_ad.derivatives()[1],
438 (
fp.binaryDiffusionCoefficient(
p,
T + h, 0, 2) -
439 fp.binaryDiffusionCoefficient(
p,
T - h, 0, 2)) /
444 EXPECT_THROW(_fp_mix->binaryDiffusionCoefficient(
p,
T, 0, 1), std::exception);
458 for (
const auto & [
x,
fp] : {std::pair<Real, const IdealGasFluidProperties *>(0, _fp_steam),
459 std::pair<Real, const IdealGasFluidProperties *>(1, _fp_nitrogen)})
461 Real s, ds_dp, ds_dT;
462 fp->s_from_p_T(
p,
T, s, ds_dp, ds_dT);
463 REL_TEST(_fp_mix->s_from_p_T(
p,
T, {x}), s, REL_TOL_CONSISTENCY);
464 const ADReal s_ad = _fp_mix->s_from_p_T(p_ad, T_ad, std::vector<ADReal>{
ADReal(
x)});
465 REL_TEST(s_ad.derivatives()[0], ds_dp, REL_TOL_CONSISTENCY);
466 REL_TEST(s_ad.derivatives()[1], ds_dT, REL_TOL_CONSISTENCY);