https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CO2FluidPropertiesTest.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
12
16TEST_F(CO2FluidPropertiesTest, fluidName) { EXPECT_EQ(_fp->fluidName(), "co2"); }
17
22{
23 ABS_TEST(_fp->molarMass(), 44.0098e-3, REL_TOL_SAVED_VALUE);
24}
25
29TEST_F(CO2FluidPropertiesTest, criticalProperties)
30{
31 ABS_TEST(_fp->criticalPressure(), 7.3773e6, REL_TOL_SAVED_VALUE);
32 ABS_TEST(_fp->criticalTemperature(), 304.1282, REL_TOL_SAVED_VALUE);
33 ABS_TEST(_fp->criticalDensity(), 467.6, REL_TOL_SAVED_VALUE);
34}
35
39TEST_F(CO2FluidPropertiesTest, triplePointProperties)
40{
41 ABS_TEST(_fp->triplePointPressure(), 0.51795e6, REL_TOL_SAVED_VALUE);
42 ABS_TEST(_fp->triplePointTemperature(), 216.592, REL_TOL_SAVED_VALUE);
43}
44
55{
56 const Real tol = 10.0 * REL_TOL_EXTERNAL_VALUE;
57
58 REL_TEST(_fp->meltingPressure(217.03), 2.57e6, tol);
59 REL_TEST(_fp->meltingPressure(235.29), 95.86e6, tol);
60 REL_TEST(_fp->meltingPressure(266.04), 286.77e6, tol);
61}
62
69{
70 REL_TEST(_fp->sublimationPressure(194.6857), 0.101325e6, REL_TOL_EXTERNAL_VALUE);
71}
72
83{
84 const Real tol = 10.0 * REL_TOL_EXTERNAL_VALUE;
85
86 // Vapor pressure
87 REL_TEST(_fp->vaporPressure(217.0), 0.52747e6, tol);
88 REL_TEST(_fp->vaporPressure(245.0), 1.51887e6, tol);
89 REL_TEST(_fp->vaporPressure(303.8), 7.32029e6, tol);
90
91 // Saturated vapor density
92 REL_TEST(_fp->saturatedVaporDensity(217.0), 14.0017, tol);
93 REL_TEST(_fp->saturatedVaporDensity(245.0), 39.5048, tol);
94 REL_TEST(_fp->saturatedVaporDensity(303.8), 382.30, tol);
95
96 // Saturated liquid density
97 REL_TEST(_fp->saturatedLiquidDensity(217.0), 1177.03, tol);
98 REL_TEST(_fp->saturatedLiquidDensity(245.0), 1067.89, tol);
99 REL_TEST(_fp->saturatedLiquidDensity(303.8), 554.14, tol);
100}
101
111{
112 const Real tol = 50.0 * REL_TOL_EXTERNAL_VALUE;
113
114 REL_TEST(_fp->partialDensity(373.15), 1182.8, tol);
115 REL_TEST(_fp->partialDensity(473.35), 880.0, tol);
116 REL_TEST(_fp->partialDensity(573.15), 593.8, tol);
117}
118
125{
126 const Real tol = REL_TOL_EXTERNAL_VALUE;
127 const std::vector<Real> hc = _fp->henryCoefficients();
128
129 REL_TEST(hc[0], -8.55445, tol);
130 REL_TEST(hc[1], 4.01195, tol);
131 REL_TEST(hc[2], 9.52345, tol);
132}
133
140TEST_F(CO2FluidPropertiesTest, thermalConductivity)
141{
142 const Real tol = REL_TOL_EXTERNAL_VALUE;
143
144 REL_TEST(_fp->k_from_rho_T(23.435, 250.0), 13.45e-3, tol);
145 REL_TEST(_fp->k_from_rho_T(18.579, 300.0), 17.248e-3, tol);
146 REL_TEST(_fp->k_from_rho_T(11.899, 450.0), 29.377e-3, tol);
147
148 REL_TEST(_fp->k_from_p_T(1.0e6, 250.0), 1.34504e-2, tol);
149 REL_TEST(_fp->k_from_p_T(1.0e6, 300.0), 1.72483e-2, tol);
150 REL_TEST(_fp->k_from_p_T(1.0e6, 450.0), 2.93767e-2, tol);
151}
152
159{
160 const Real tol = REL_TOL_EXTERNAL_VALUE;
161
162 REL_TEST(_fp->mu_from_rho_T(20.199, 280.0), 14.15e-6, tol);
163 REL_TEST(_fp->mu_from_rho_T(15.105, 360.0), 17.94e-6, tol);
164 REL_TEST(_fp->mu_from_rho_T(10.664, 500.0), 24.06e-6, tol);
165
166 REL_TEST(_fp->mu_from_p_T(1.0e6, 280.0), 1.41505e-05, tol);
167 REL_TEST(_fp->mu_from_p_T(1.0e6, 360.0), 1.79395e-05, tol);
168 REL_TEST(_fp->mu_from_p_T(1.0e6, 500.0), 2.40643e-05, tol);
169}
170
179{
180 // Pressure = 1 MPa, temperature = 280 K
181 Real p = 1.0e6;
182 Real T = 280.0;
183
184 const Real tol = REL_TOL_EXTERNAL_VALUE;
185
186 REL_TEST(_fp->rho_from_p_T(p, T), 20.199, tol);
187 REL_TEST(_fp->h_from_p_T(p, T), -26.385e3, tol);
188 REL_TEST(_fp->e_from_p_T(p, T), -75.892e3, tol);
189 REL_TEST(_fp->s_from_p_T(p, T), -0.51326e3, tol);
190 REL_TEST(_fp->cp_from_p_T(p, T), 0.92518e3, tol);
191 REL_TEST(_fp->cv_from_p_T(p, T), 0.67092e3, tol);
192 REL_TEST(_fp->c_from_p_T(p, T), 252.33, tol);
193
194 // Pressure = 1 MPa, temperature = 500 K
195 T = 500.0;
196 REL_TEST(_fp->rho_from_p_T(p, T), 10.664, tol);
197 REL_TEST(_fp->h_from_p_T(p, T), 185.60e3, tol);
198 REL_TEST(_fp->e_from_p_T(p, T), 91.829e3, tol);
199 REL_TEST(_fp->s_from_p_T(p, T), 0.04225e3, tol);
200 REL_TEST(_fp->cp_from_p_T(p, T), 1.0273e3, tol);
201 REL_TEST(_fp->cv_from_p_T(p, T), 0.82823e3, tol);
202 REL_TEST(_fp->c_from_p_T(p, T), 339.81, tol);
203
204 // Pressure = 10 MPa, temperature = 500 K
205 p = 10.0e6;
206 REL_TEST(_fp->rho_from_p_T(p, T), 113.07, tol);
207 REL_TEST(_fp->h_from_p_T(p, T), 157.01e3, tol);
208 REL_TEST(_fp->e_from_p_T(p, T), 68.569e3, tol);
209 REL_TEST(_fp->s_from_p_T(p, T), -0.4383e3, tol);
210 REL_TEST(_fp->cp_from_p_T(p, T), 1.1624e3, tol);
211 REL_TEST(_fp->cv_from_p_T(p, T), 0.85516e3, tol);
212 REL_TEST(_fp->c_from_p_T(p, T), 337.45, tol);
213
214 // Verify properties from p, h
215 {
216 Real h1 = _fp->h_from_p_T(p, T);
217 Real T1 = _fp->T_from_p_h(p, h1);
218 REL_TEST(T1, T, REL_TOL_CONSISTENCY);
219 }
220}
221
226TEST_F(CO2FluidPropertiesTest, derivativesNearCritical)
227{
228 const Real tol = REL_TOL_DERIVATIVE;
229
230 // Slightly supercritical state (Tc = 304.1282 K, pc = 7.3773 MPa), where the nonanalytic
231 // terms of the residual Helmholtz free energy contribute significantly
232 const Real p = 7.5e6;
233 const Real T = 305.0;
234
235 // Properties vary steeply this close to the critical point, so the default relative
236 // perturbation of 1e-6 leaves a finite-difference truncation error just above the
237 // tolerance; 1e-7 brings it well below while staying above round-off
238 DERIV_TEST_CUSTOM_PERTURBATION(_fp->rho_from_p_T, p, T, tol, 1e-7);
239 DERIV_TEST_CUSTOM_PERTURBATION(_fp->e_from_p_T, p, T, tol, 1e-7);
240 DERIV_TEST_CUSTOM_PERTURBATION(_fp->h_from_p_T, p, T, tol, 1e-7);
241
242 // The isobaric heat capacity is the temperature derivative of the enthalpy
243 Real h, dh_dp, dh_dT;
244 _fp->h_from_p_T(p, T, h, dh_dp, dh_dT);
245 REL_TEST(_fp->cp_from_p_T(p, T), dh_dT, REL_TOL_CONSISTENCY);
246}
247
249{
250 const Real tol = REL_TOL_DERIVATIVE;
251
252 const Real p = 1.0e6;
253 Real T = 350.0;
254
255 DERIV_TEST(_fp->rho_from_p_T, p, T, tol);
256 DERIV_TEST(_fp->mu_from_p_T, p, T, tol);
257 DERIV_TEST(_fp->e_from_p_T, p, T, tol);
258 DERIV_TEST(_fp->h_from_p_T, p, T, tol);
259 DERIV_TEST(_fp->s_from_p_T, p, T, tol);
260 DERIV_TEST(_fp->k_from_p_T, p, T, tol);
261
262 // Viscosity from density and temperature
263 T = 360.0;
264 const Real drho = 1.0e-4;
265 Real rho, drho_dp, drho_dT;
266 _fp->rho_from_p_T(p, T, rho, drho_dp, drho_dT);
267
268 Real dmu_drho_fd =
269 (_fp->mu_from_rho_T(rho + drho, T) - _fp->mu_from_rho_T(rho - drho, T)) / (2.0 * drho);
270 Real mu = 0.0, dmu_drho = 0.0, dmu_dT = 0.0;
271 _fp->mu_from_rho_T(rho, T, drho_dT, mu, dmu_drho, dmu_dT);
272
273 ABS_TEST(mu, _fp->mu_from_rho_T(rho, T), REL_TOL_CONSISTENCY);
274 REL_TEST(dmu_drho, dmu_drho_fd, tol);
275
276 // To properly test derivative wrt temperature, use p and T and calculate density,
277 // so that the change in density wrt temperature is included
278 const Real dp = 1.0e1;
279 const Real dT = 1.0e-4;
280 _fp->rho_from_p_T(p, T, rho, drho_dp, drho_dT);
281 _fp->mu_from_rho_T(rho, T, drho_dT, mu, dmu_drho, dmu_dT);
282
283 Real dmu_dT_fd = (_fp->mu_from_rho_T(_fp->rho_from_p_T(p, T + dT), T + dT) -
284 _fp->mu_from_rho_T(_fp->rho_from_p_T(p, T - dT), T - dT)) /
285 (2.0 * dT);
286
287 REL_TEST(dmu_dT, dmu_dT_fd, tol);
288
289 Real dmu_dp_fd = (_fp->mu_from_p_T(p + dp, T) - _fp->mu_from_p_T(p - dp, T)) / (2.0 * dp);
290 Real dmu_dp = 0.0;
291 _fp->mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
292
293 ABS_TEST(mu, _fp->mu_from_p_T(p, T), REL_TOL_CONSISTENCY);
294 REL_TEST(dmu_dp, dmu_dp_fd, tol);
295
296 _fp->mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
297 dmu_dT_fd = (_fp->mu_from_p_T(p, T + dT) - _fp->mu_from_p_T(p, T - dT)) / (2.0 * dT);
298
299 REL_TEST(dmu_dT, dmu_dT_fd, tol);
300}
301
307{
308 const Real p = 1.0e6;
309 const Real T = 300.0;
310 const Real tol = REL_TOL_CONSISTENCY;
311
312 // Single property methods
313 Real rho, drho_dp, drho_dT;
314 _fp->rho_from_p_T(p, T, rho, drho_dp, drho_dT);
315 Real mu, dmu_dp, dmu_dT;
316 _fp->mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
317 Real e, de_dp, de_dT;
318 _fp->e_from_p_T(p, T, e, de_dp, de_dT);
319
320 // Combined property methods
321 Real rho2, drho2_dp, drho2_dT, mu2, dmu2_dp, dmu2_dT, e2, de2_dp, de2_dT;
322 _fp->rho_mu_from_p_T(p, T, rho2, mu2);
323
324 ABS_TEST(rho, rho2, tol);
325 ABS_TEST(mu, mu2, tol);
326
327 _fp->rho_mu_from_p_T(p, T, rho2, drho2_dp, drho2_dT, mu2, dmu2_dp, dmu2_dT);
328 ABS_TEST(rho, rho2, tol);
329 ABS_TEST(drho_dp, drho2_dp, tol);
330 ABS_TEST(drho_dT, drho2_dT, tol);
331 ABS_TEST(mu, mu2, tol);
332 ABS_TEST(dmu_dp, dmu2_dp, tol);
333 ABS_TEST(dmu_dT, dmu2_dT, tol);
334
335 _fp->rho_e_from_p_T(p, T, rho2, drho2_dp, drho2_dT, e2, de2_dp, de2_dT);
336 ABS_TEST(rho, rho2, tol);
337 ABS_TEST(drho_dp, drho2_dp, tol);
338 ABS_TEST(drho_dT, drho2_dT, tol);
339 ABS_TEST(e, e2, tol);
340 ABS_TEST(de_dp, de2_dp, tol);
341 ABS_TEST(de_dT, de2_dT, tol);
342}
TEST_F(CO2FluidPropertiesTest, fluidName)
Test that the fluid name is correctly returned.
const double tol
const double mu
const Real p
const double rho
const double T