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

Go to the source code of this file.

Functions

 TEST_F (NASA7IdealGasFluidPropertiesTest, cantera)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, consistency)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, derivatives)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, outOfRange)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, inverses)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, energyNearZero)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, inverseDerivatives)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, inverseRange)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, transport)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, steamTransportRange)
 
 TEST_F (NASA7IdealGasFluidPropertiesTest, densityFromEntropy)
 

Function Documentation

◆ TEST_F() [1/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
cantera   
)

Definition at line 52 of file NASA7IdealGasFluidPropertiesTest.C.

53{
54 // The reference values were computed with Cantera 3.2.0 from gri30.yaml. Cantera uses the gas
55 // constant 8.31446261815324 J/(mol K), whereas FluidProperties::_R is 8.3144598 J/(mol K).
56 // Properties proportional to the gas constant are rescaled by the ratio of the two, density by
57 // its inverse, and sound speed by its square root, so that only roundoff separates the results.
58 const Real R_ratio = FluidProperties::_R / 8.31446261815324;
59 const Real tol = 1e-12;
60
61 const auto check =
62 [R_ratio, tol](const NASA7IdealGasFluidProperties & fp, const CanteraState & ref)
63 {
64 REL_TEST(fp.rho_from_p_T(ref.p, ref.T), ref.rho / R_ratio, tol);
65 REL_TEST(fp.e_from_p_T(ref.p, ref.T), ref.e * R_ratio, tol);
66 REL_TEST(fp.h_from_p_T(ref.p, ref.T), ref.h * R_ratio, tol);
67 REL_TEST(fp.s_from_p_T(ref.p, ref.T), ref.s * R_ratio, tol);
68 REL_TEST(fp.cp_from_p_T(ref.p, ref.T), ref.cp * R_ratio, tol);
69 REL_TEST(fp.cv_from_p_T(ref.p, ref.T), ref.cv * R_ratio, tol);
70 REL_TEST(fp.c_from_p_T(ref.p, ref.T), ref.c * std::sqrt(R_ratio), tol);
71 };
72
73 // H2O below the midpoint temperature, at 923.15 K (650 C), a typical operating temperature of
74 // solid oxide cells, and at a pressure other than the reference pressure
75 check(*_fp_h2o,
76 {2e5,
77 923.15,
78 0.46941590772782527,
79 -12580176.509683069,
80 -12154115.107188027,
81 12424.123173583768,
82 2236.055923467166,
83 1774.5259418877467,
84 732.7169706483752});
85
86 // N2 above the midpoint temperature
87 check(*_fp_n2,
88 {1e5,
89 1500.0,
90 0.22462065027779515,
91 925748.8663660923,
92 1370943.9091029332,
93 8635.100537093402,
94 1242.4266981940143,
95 945.6300030361202,
96 764.8036043196926});
97}
const double tol
static const Real _R
Universal gas constant (J/mol/K)
Ideal gas whose heat capacity, enthalpy, and entropy depend on temperature through NASA 7-coefficient...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [2/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
consistency   
)

Definition at line 99 of file NASA7IdealGasFluidPropertiesTest.C.

100{
101 // A low-pressure state below the midpoint temperature and a high-pressure state above it
102 for (const auto * fp : {_fp_h2o, _fp_n2})
103 for (const auto & [p, T] :
104 {std::pair<Real, Real>(1e5, 600.0), std::pair<Real, Real>(3e6, 1500.0)})
105 {
106 const Real rho = fp->rho_from_p_T(p, T);
107 const Real v = 1 / rho;
108 const Real e = fp->e_from_p_T(p, T);
109 const Real h = fp->h_from_p_T(p, T);
110 const Real s = fp->s_from_p_T(p, T);
111 const Real cp = fp->cp_from_p_T(p, T);
112 const Real cv = fp->cv_from_p_T(p, T);
113 const Real gamma = fp->gamma_from_p_T(p, T);
114 const Real c = fp->c_from_p_T(p, T);
115
116 // The other variable sets describe the same state
117 REL_TEST(fp->v_from_p_T(p, T), v, REL_TOL_CONSISTENCY);
118 REL_TEST(fp->p_from_T_v(T, v), p, REL_TOL_CONSISTENCY);
119 REL_TEST(fp->e_from_T_v(T, v), e, REL_TOL_CONSISTENCY);
120 REL_TEST(fp->h_from_T_v(T, v), h, REL_TOL_CONSISTENCY);
121 REL_TEST(fp->s_from_T_v(T, v), s, REL_TOL_CONSISTENCY);
122 REL_TEST(fp->cv_from_T_v(T, v), cv, REL_TOL_CONSISTENCY);
123 REL_TEST(fp->e_from_p_rho(p, rho), e, REL_TOL_CONSISTENCY);
124
125 // Ideal-gas relations: definition of enthalpy, Mayer's relation, and sound speed
126 REL_TEST(h, e + p * v, REL_TOL_CONSISTENCY);
127 REL_TEST(cp - cv, FluidProperties::_R / fp->molarMass(), REL_TOL_CONSISTENCY);
128 REL_TEST(gamma, cp / cv, REL_TOL_CONSISTENCY);
129 REL_TEST(c * c, gamma * p * v, REL_TOL_CONSISTENCY);
130
131 // (dh/dT)_p = cp, (de/dT)_v = cv, (ds/dT)_p = cp/T, and the Maxwell relation
132 // (ds/dp)_T = -(dv/dT)_p = -v/T
133 Real value, d_dp, d_dT, d_dv;
134 fp->h_from_p_T(p, T, value, d_dp, d_dT);
135 REL_TEST(d_dT, cp, REL_TOL_CONSISTENCY);
136 fp->e_from_T_v(T, v, value, d_dT, d_dv);
137 REL_TEST(d_dT, cv, REL_TOL_CONSISTENCY);
138 fp->s_from_p_T(p, T, value, d_dp, d_dT);
139 REL_TEST(d_dT, cp / T, REL_TOL_CONSISTENCY);
140 REL_TEST(d_dp, -v / T, REL_TOL_CONSISTENCY);
141 }
142}
const Real p
const double rho
const double T
const double v
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ TEST_F() [3/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
densityFromEntropy   
)

Definition at line 450 of file NASA7IdealGasFluidPropertiesTest.C.

451{
452 // Invert the entropy of every built-in species at two pressures and at temperatures spread
453 // geometrically from half the lower end of the range of its data to 1.5 times the upper end
454 // 60 geometric intervals place consecutive temperatures about 7% apart
455 const unsigned int n = 60;
456 for (const std::string species : {"H2", "O2", "H2O", "CH4", "CO", "CO2", "N2"})
457 {
458 const auto & fp = buildFluidProperties(species, "entropy_" + species);
459 const auto & data = NASA7::speciesData(species);
460 const Real T_low = data.T_min / 2;
461 const Real T_high = 1.5 * data.T_max;
462 for (const Real p : {1e3, 1e7})
463 for (const auto i : make_range(n + 1))
464 {
465 const Real T = T_low * std::pow(T_high / T_low, Real(i) / n);
466 REL_TEST(
467 fp.rho_from_p_s(p, fp.s_from_p_T(p, T)), fp.rho_from_p_T(p, T), REL_TOL_CONSISTENCY);
468 }
469 }
470
471 // Derivatives on each side of the midpoint temperature
472 for (const auto & [fp, T] : {std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_h2o, 700),
473 std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_n2, 1500)})
474 {
475 const Real p = 2e5;
476 const Real s = fp->s_from_p_T(p, T);
477 DERIV_TEST(fp->rho_from_p_s, p, s, REL_TOL_DERIVATIVE);
478 const ADReal p_ad = p;
479 const ADReal s_ad = s;
480 AD_DERIV_TEST(fp->rho_from_p_s, p_ad, s_ad, REL_TOL_DERIVATIVE);
481
482 // At constant pressure, (dT/ds)_p = T / cp and, for an ideal gas, (drho/dT)_p = -rho / T, so
483 // (drho/ds)_p = -rho / cp
484 Real rho, drho_dp, drho_ds;
485 fp->rho_from_p_s(p, s, rho, drho_dp, drho_ds);
486 REL_TEST(drho_ds, -rho / fp->cp_from_p_T(p, T), REL_TOL_CONSISTENCY);
487 }
488}
DualNumber< Real, DNDerivativeType, true > ADReal
const SpeciesData & speciesData(const std::string &name)
Data of a built-in species.
IntRange< T > make_range(T beg, T end)

◆ TEST_F() [4/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
derivatives   
)

Definition at line 144 of file NASA7IdealGasFluidPropertiesTest.C.

145{
146 // One state on each side of the midpoint temperature
147 for (const auto & [fp, T] : {std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_h2o, 700),
148 std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_n2, 1500)})
149 {
150 const Real p = 2e5;
151 const Real rho = fp->rho_from_p_T(p, T);
152 const Real v = 1 / rho;
153
154 DERIV_TEST(fp->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);
155 DERIV_TEST(fp->v_from_p_T, p, T, REL_TOL_DERIVATIVE);
156 DERIV_TEST(fp->e_from_p_T, p, T, REL_TOL_DERIVATIVE);
157 DERIV_TEST(fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);
158 DERIV_TEST(fp->s_from_p_T, p, T, REL_TOL_DERIVATIVE);
159 DERIV_TEST(fp->cp_from_p_T, p, T, REL_TOL_DERIVATIVE);
160 DERIV_TEST(fp->cv_from_p_T, p, T, REL_TOL_DERIVATIVE);
161 DERIV_TEST(fp->c_from_p_T, p, T, REL_TOL_DERIVATIVE);
162 DERIV_TEST(fp->gamma_from_p_T, p, T, REL_TOL_DERIVATIVE);
163 DERIV_TEST(fp->mu_from_p_T, p, T, REL_TOL_DERIVATIVE);
164 DERIV_TEST(fp->k_from_p_T, p, T, REL_TOL_DERIVATIVE);
165 DERIV_TEST(fp->p_from_T_v, T, v, REL_TOL_DERIVATIVE);
166 DERIV_TEST(fp->e_from_T_v, T, v, REL_TOL_DERIVATIVE);
167 DERIV_TEST(fp->h_from_T_v, T, v, REL_TOL_DERIVATIVE);
168 DERIV_TEST(fp->s_from_T_v, T, v, REL_TOL_DERIVATIVE);
169 DERIV_TEST(fp->cv_from_T_v, T, v, REL_TOL_DERIVATIVE);
170 DERIV_TEST(fp->e_from_p_rho, p, rho, REL_TOL_DERIVATIVE);
171
172 const ADReal p_ad = p;
173 const ADReal T_ad = T;
174 const ADReal v_ad = v;
175 const ADReal rho_ad = rho;
176
177 AD_DERIV_TEST(fp->rho_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
178 AD_DERIV_TEST(fp->v_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
179 AD_DERIV_TEST(fp->e_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
180 AD_DERIV_TEST(fp->h_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
181 AD_DERIV_TEST(fp->s_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
182 AD_DERIV_TEST(fp->cp_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
183 AD_DERIV_TEST(fp->cv_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
184 AD_DERIV_TEST(fp->c_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
185 AD_DERIV_TEST(fp->gamma_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
186 AD_DERIV_TEST(fp->mu_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
187 AD_DERIV_TEST(fp->k_from_p_T, p_ad, T_ad, REL_TOL_DERIVATIVE);
188 AD_DERIV_TEST(fp->p_from_T_v, T_ad, v_ad, REL_TOL_DERIVATIVE);
189 AD_DERIV_TEST(fp->e_from_T_v, T_ad, v_ad, REL_TOL_DERIVATIVE);
190 AD_DERIV_TEST(fp->h_from_T_v, T_ad, v_ad, REL_TOL_DERIVATIVE);
191 AD_DERIV_TEST(fp->s_from_T_v, T_ad, v_ad, REL_TOL_DERIVATIVE);
192 AD_DERIV_TEST(fp->cv_from_T_v, T_ad, v_ad, REL_TOL_DERIVATIVE);
193 AD_DERIV_TEST(fp->e_from_p_rho, p_ad, rho_ad, REL_TOL_DERIVATIVE);
194
195 // The AD overloads carry the derivatives of their arguments: (de/dT)_p = cv
196 DNDerivativeType dT_dT;
197 Moose::derivInsert(dT_dT, 0, 1);
198 const ADReal T_seeded(T, dT_dT);
199 REL_TEST(fp->e_from_p_T(p_ad, T_seeded).derivatives()[0],
200 fp->cv_from_p_T(p, T),
201 REL_TOL_CONSISTENCY);
202 }
203}
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)

◆ TEST_F() [5/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
energyNearZero   
)

Definition at line 288 of file NASA7IdealGasFluidPropertiesTest.C.

289{
290 // The internal energy of N2 includes its enthalpy of formation, zero, and it passes through zero
291 // near 417 K. A convergence test relative to the target energy would demand accuracy below
292 // roundoff there.
293 const Real v = 1;
294 for (const Real e : {-1e-3, 0.0, 1e-3})
295 {
296 const Real T = _fp_n2->T_from_v_e(v, e);
297 ABS_TEST(_fp_n2->e_from_T_v(T, v), e, REL_TOL_CONSISTENCY * _fp_n2->cv_from_T_v(T, v) * T);
298 }
299}

◆ TEST_F() [6/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
inverseDerivatives   
)

Definition at line 301 of file NASA7IdealGasFluidPropertiesTest.C.

302{
303 // One state on each side of the midpoint temperature
304 for (const auto & [fp, T] : {std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_h2o, 700),
305 std::pair<const NASA7IdealGasFluidProperties *, Real>(_fp_n2, 1500)})
306 {
307 const Real p = 2e5;
308 const Real v = fp->v_from_p_T(p, T);
309 const Real e = fp->e_from_p_T(p, T);
310 const Real h = fp->h_from_p_T(p, T);
311 const Real s = fp->s_from_p_T(p, T);
312
313 DERIV_TEST(fp->T_from_v_e, v, e, REL_TOL_DERIVATIVE);
314 DERIV_TEST(fp->p_from_v_e, v, e, REL_TOL_DERIVATIVE);
315 DERIV_TEST(fp->c_from_v_e, v, e, REL_TOL_DERIVATIVE);
316 DERIV_TEST(fp->cp_from_v_e, v, e, REL_TOL_DERIVATIVE);
317 DERIV_TEST(fp->cv_from_v_e, v, e, REL_TOL_DERIVATIVE);
318 DERIV_TEST(fp->gamma_from_v_e, v, e, REL_TOL_DERIVATIVE);
319 DERIV_TEST(fp->s_from_v_e, v, e, REL_TOL_DERIVATIVE);
320 DERIV_TEST(fp->g_from_v_e, v, e, REL_TOL_DERIVATIVE);
321 DERIV_TEST(fp->mu_from_v_e, v, e, REL_TOL_DERIVATIVE);
322 DERIV_TEST(fp->k_from_v_e, v, e, REL_TOL_DERIVATIVE);
323 DERIV_TEST(fp->T_from_p_h, p, h, REL_TOL_DERIVATIVE);
324 DERIV_TEST(fp->s_from_h_p, h, p, REL_TOL_DERIVATIVE);
325 DERIV_TEST(fp->p_from_h_s, h, s, REL_TOL_DERIVATIVE);
326 DERIV_TEST(fp->e_from_v_h, v, h, REL_TOL_DERIVATIVE);
327
328 const ADReal p_ad = p;
329 const ADReal v_ad = v;
330 const ADReal e_ad = e;
331 const ADReal h_ad = h;
332 const ADReal s_ad = s;
333
334 AD_DERIV_TEST(fp->T_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
335 AD_DERIV_TEST(fp->p_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
336 AD_DERIV_TEST(fp->c_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
337 AD_DERIV_TEST(fp->cp_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
338 AD_DERIV_TEST(fp->cv_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
339 AD_DERIV_TEST(fp->gamma_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
340 AD_DERIV_TEST(fp->s_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
341 AD_DERIV_TEST(fp->g_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
342 AD_DERIV_TEST(fp->mu_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
343 AD_DERIV_TEST(fp->k_from_v_e, v_ad, e_ad, REL_TOL_DERIVATIVE);
344 AD_DERIV_TEST(fp->T_from_p_h, p_ad, h_ad, REL_TOL_DERIVATIVE);
345 AD_DERIV_TEST(fp->s_from_h_p, h_ad, p_ad, REL_TOL_DERIVATIVE);
346 AD_DERIV_TEST(fp->p_from_h_s, h_ad, s_ad, REL_TOL_DERIVATIVE);
347 AD_DERIV_TEST(fp->e_from_v_h, v_ad, h_ad, REL_TOL_DERIVATIVE);
348
349 // The AD overloads carry the derivatives of their arguments: (dT/de)_v = 1/cv
350 DNDerivativeType de_de;
351 Moose::derivInsert(de_de, 0, 1);
352 const ADReal e_seeded(e, de_de);
353 REL_TEST(fp->T_from_v_e(v_ad, e_seeded).derivatives()[0],
354 1 / fp->cv_from_p_T(p, T),
355 REL_TOL_CONSISTENCY);
356 }
357}

◆ TEST_F() [7/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
inverseRange   
)

Definition at line 359 of file NASA7IdealGasFluidPropertiesTest.C.

360{
361 // Invert the internal energy and enthalpy of every built-in species at temperatures spread
362 // geometrically from half the lower end of the range of its data to 1.5 times the upper end,
363 // so that the inversion is exercised far from any initial guess and in extrapolation
364 // The internal energy and enthalpy of an ideal gas do not depend on pressure or specific volume
365 const Real p = 1e5;
366 const Real v = 1;
367 // 60 geometric intervals place consecutive temperatures about 7% apart
368 const unsigned int n = 60;
369 for (const std::string species : {"H2", "O2", "H2O", "CH4", "CO", "CO2", "N2"})
370 {
371 const std::string name = "sweep_" + species;
372 const auto & fp = buildFluidProperties(species, name);
373 const auto & data = NASA7::speciesData(species);
374 const Real T_low = data.T_min / 2;
375 const Real T_high = 1.5 * data.T_max;
376 for (const auto i : make_range(n + 1))
377 {
378 const Real T = T_low * std::pow(T_high / T_low, Real(i) / n);
379 REL_TEST(fp.T_from_v_e(v, fp.e_from_T_v(T, v)), T, REL_TOL_CONSISTENCY);
380 REL_TEST(fp.T_from_p_h(p, fp.h_from_p_T(p, T)), T, REL_TOL_CONSISTENCY);
381 }
382 }
383}
const std::string name
Definition Setup.h:21

◆ TEST_F() [8/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
inverses   
)

Definition at line 240 of file NASA7IdealGasFluidPropertiesTest.C.

241{
242 for (const auto * fp : {_fp_h2o, _fp_n2})
243 {
244 // States on each side of the midpoint temperature
245 for (const auto & [p, T] :
246 {std::pair<Real, Real>(1e5, 600.0), std::pair<Real, Real>(3e6, 1500.0)})
247 {
248 const Real v = fp->v_from_p_T(p, T);
249 const Real e = fp->e_from_p_T(p, T);
250 const Real h = fp->h_from_p_T(p, T);
251 const Real s = fp->s_from_p_T(p, T);
252
253 REL_TEST(fp->T_from_v_e(v, e), T, REL_TOL_CONSISTENCY);
254 REL_TEST(fp->p_from_v_e(v, e), p, REL_TOL_CONSISTENCY);
255 REL_TEST(fp->c_from_v_e(v, e), fp->c_from_p_T(p, T), REL_TOL_CONSISTENCY);
256 REL_TEST(fp->cp_from_v_e(v, e), fp->cp_from_p_T(p, T), REL_TOL_CONSISTENCY);
257 REL_TEST(fp->cv_from_v_e(v, e), fp->cv_from_p_T(p, T), REL_TOL_CONSISTENCY);
258 REL_TEST(fp->gamma_from_v_e(v, e), fp->gamma_from_p_T(p, T), REL_TOL_CONSISTENCY);
259 REL_TEST(fp->s_from_v_e(v, e), s, REL_TOL_CONSISTENCY);
260 REL_TEST(fp->g_from_v_e(v, e), h - T * s, REL_TOL_CONSISTENCY);
261 REL_TEST(fp->T_from_p_h(p, h), T, REL_TOL_CONSISTENCY);
262 REL_TEST(fp->s_from_h_p(h, p), s, REL_TOL_CONSISTENCY);
263 REL_TEST(fp->p_from_h_s(h, s), p, REL_TOL_CONSISTENCY);
264 REL_TEST(fp->e_from_v_h(v, h), e, REL_TOL_CONSISTENCY);
265
266 // (ds/dv)_e = p/T, (ds/de)_v = 1/T, (dp/dh)_s = rho, and (dp/ds)_h = -rho T
267 Real value, d_d1, d_d2;
268 fp->s_from_v_e(v, e, value, d_d1, d_d2);
269 REL_TEST(d_d1, p / T, REL_TOL_CONSISTENCY);
270 REL_TEST(d_d2, 1 / T, REL_TOL_CONSISTENCY);
271 fp->p_from_h_s(h, s, value, d_d1, d_d2);
272 REL_TEST(d_d1, 1 / v, REL_TOL_CONSISTENCY);
273 REL_TEST(d_d2, -T / v, REL_TOL_CONSISTENCY);
274 }
275
276 // At the midpoint temperature the two polynomials do not match exactly, and the internal
277 // energy and enthalpy of the low-temperature polynomial are also reached by the
278 // high-temperature polynomial slightly above it, less than 3e-4 K for the built-in species. The
279 // inversion may return either temperature.
280 const Real p = 2e5;
281 const Real T_mid = 1000;
282 const Real v = fp->v_from_p_T(p, T_mid);
283 ABS_TEST(fp->T_from_v_e(v, fp->e_from_p_T(p, T_mid)), T_mid, 1e-3);
284 ABS_TEST(fp->T_from_p_h(p, fp->h_from_p_T(p, T_mid)), T_mid, 1e-3);
285 }
286}

◆ TEST_F() [9/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
outOfRange   
)

Definition at line 205 of file NASA7IdealGasFluidPropertiesTest.C.

206{
207 const Real p = 1e5;
208 const auto warnings = flagCount(*_app, true);
209
210 // 250 K lies inside the range of the H2O data, 200 K to 3500 K, but below that of the N2 data,
211 // 300 K to 5000 K
212 _fp_h2o->cp_from_p_T(p, 250);
213 EXPECT_EQ(flagCount(*_app, true), warnings);
214
215 // Outside the range, the polynomials are extrapolated and each evaluation is counted as a
216 // solution warning
217 const Real cp = _fp_n2->cp_from_p_T(p, 250);
218 EXPECT_EQ(flagCount(*_app, true), warnings + 1);
219 REL_TEST(cp,
220 FluidProperties::_R / _fp_n2->molarMass() *
222 REL_TOL_CONSISTENCY);
223 _fp_h2o->cp_from_p_T(p, 3600);
224 EXPECT_EQ(flagCount(*_app, true), warnings + 2);
225
226 // A temperature found by inverting the internal energy is checked once
227 const Real e = _fp_n2->e_from_p_T(p, 250);
228 const auto warnings_before_inversion = flagCount(*_app, true);
229 REL_TEST(_fp_n2->T_from_v_e(1, e), 250, REL_TOL_CONSISTENCY);
230 EXPECT_EQ(flagCount(*_app, true), warnings_before_inversion + 1);
231
232 // A non-positive or not-a-number temperature is an invalid solution
233 const auto errors = flagCount(*_app, false);
234 _fp_n2->e_from_p_T(p, -10);
235 EXPECT_EQ(flagCount(*_app, false), errors + 1);
236 _fp_n2->e_from_p_T(p, std::numeric_limits<Real>::quiet_NaN());
237 EXPECT_EQ(flagCount(*_app, false), errors + 2);
238}
CppType cpOverR(const SpeciesData &data, const CppType &T)
Standard-state molar isobaric heat capacity divided by the gas constant, cp/R.

◆ TEST_F() [10/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
steamTransportRange   
)

Definition at line 432 of file NASA7IdealGasFluidPropertiesTest.C.

433{
434 // 1500 K lies inside the range of the H2O data, 200 K to 3500 K, but above that of the IAPWS
435 // transport formulations, 273.16 K to 1173.15 K. The viscosity and thermal conductivity of other
436 // species are not limited to that range.
437 const Real p = 1e5;
438 const auto warnings = flagCount(*_app, true);
439 _fp_h2o->mu_from_p_T(p, 1000);
440 _fp_h2o->k_from_p_T(p, 1000);
441 _fp_n2->mu_from_p_T(p, 1500);
442 _fp_n2->k_from_p_T(p, 1500);
443 EXPECT_EQ(flagCount(*_app, true), warnings);
444 _fp_h2o->mu_from_p_T(p, 1500);
445 EXPECT_EQ(flagCount(*_app, true), warnings + 1);
446 _fp_h2o->k_from_p_T(p, 1500);
447 EXPECT_EQ(flagCount(*_app, true), warnings + 2);
448}

◆ TEST_F() [11/11]

TEST_F ( NASA7IdealGasFluidPropertiesTest  ,
transport   
)

Definition at line 385 of file NASA7IdealGasFluidPropertiesTest.C.

386{
387 // Viscosity and thermal conductivity at 1e5 Pa compared with the fluid properties of the real
388 // fluids, which include the small effect of density at this pressure. The tolerances bound the
389 // deviations at these states. The Chapman-Enskog viscosity is within 2.5% for N2, CH4, and CO2,
390 // but the Lennard-Jones parameters of H2 give a viscosity up to 6% low at 900 K. The modified
391 // Eucken conductivity is within 9%. For steam, both objects evaluate the IAPWS low-density
392 // viscosity, whereas Water97FluidProperties evaluates the IAPS 1985 conductivity.
393 const Real p = 1e5;
394 struct Reference
395 {
396 std::string species;
397 std::string type;
398 std::vector<Real> temperatures;
399 Real mu_tol;
400 Real k_tol;
401 };
402 const std::vector<Reference> references = {
403 {"N2", "NitrogenFluidProperties", {300, 600, 900}, 0.015, 0.06},
404 {"H2", "HydrogenFluidProperties", {300, 600, 900}, 0.06, 0.07},
405 {"CH4", "MethaneFluidProperties", {300, 600, 900}, 0.03, 0.08},
406 {"CO2", "CO2FluidProperties", {300, 600, 900}, 0.01, 0.09},
407 {"H2O", "Water97FluidProperties", {400, 700, 1100}, 0.01, 0.02}};
408
409 for (const auto & ref : references)
410 {
411 const auto & fp = buildFluidProperties(ref.species, "transport_" + ref.species);
412 InputParameters params = _factory.getValidParams(ref.type);
413 _fe_problem->addUserObject(ref.type, "reference_" + ref.species, params);
414 const auto & reference =
415 _fe_problem->getUserObject<SinglePhaseFluidProperties>("reference_" + ref.species);
416 for (const auto T : ref.temperatures)
417 {
418 const Real mu = fp.mu_from_p_T(p, T);
419 const Real k = fp.k_from_p_T(p, T);
420 REL_TEST(mu, reference.mu_from_p_T(p, T), ref.mu_tol);
421 REL_TEST(k, reference.k_from_p_T(p, T), ref.k_tol);
422
423 // The (specific volume, internal energy) variable set gives the same values
424 const Real v = fp.v_from_p_T(p, T);
425 const Real e = fp.e_from_p_T(p, T);
426 REL_TEST(fp.mu_from_v_e(v, e), mu, REL_TOL_CONSISTENCY);
427 REL_TEST(fp.k_from_v_e(v, e), k, REL_TOL_CONSISTENCY);
428 }
429 }
430}
const double mu
Common class for single phase fluid properties.