https://mooseframework.inl.gov
Functions
TabulatedBicubicFluidPropertiesTest.C File Reference

Go to the source code of this file.

Functions

 TEST_F (TabulatedBicubicFluidPropertiesTest, unorderedData)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, unequalTemperatures)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, missingColumn)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, unknownColumn)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, missingData)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, fromPTFile)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, fromPTFileToVE)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, fromVEFile)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, derivatives)
 Verify calculation of the derivatives of tabulated properties by comparing with finite differences. More...
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, generateTabulatedData)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, passthrough)
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, fluidName)
 Test that the fluid name is correctly returned. More...
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, molarMass)
 Test that the molar mass is correctly returned. More...
 
 TEST_F (TabulatedBicubicFluidPropertiesTest, combined)
 Verify that the methods that return multiple properties in one call return identical values as the individual methods. More...
 

Function Documentation

◆ TEST_F() [1/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
unorderedData   
)

Definition at line 16 of file TabulatedBicubicFluidPropertiesTest.C.

17 {
18  try
19  {
20  // Must cast away const to call initialSetup(), where the file is
21  // checked for consistency
22  const_cast<TabulatedBicubicFluidProperties *>(_unordered_fp)->initialSetup();
23  FAIL();
24  }
25  catch (const std::exception & err)
26  {
27  std::size_t pos = std::string(err.what())
28  .find("The column data for temperature is not monotonically increasing");
29  ASSERT_TRUE(pos != std::string::npos);
30  }
31 }
OStreamProxy err
Class for fluid properties read from a file.

◆ TEST_F() [2/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
unequalTemperatures   
)

Definition at line 34 of file TabulatedBicubicFluidPropertiesTest.C.

35 {
36  try
37  {
38  const_cast<TabulatedBicubicFluidProperties *>(_unequal_fp)->initialSetup();
39  FAIL();
40  }
41  catch (const std::exception & err)
42  {
43  std::size_t pos = std::string(err.what())
44  .find("temperature values for pressure 2e+06 are not "
45  "identical to values for 1e+06");
46  ASSERT_TRUE(pos != std::string::npos);
47  }
48 }
OStreamProxy err
Class for fluid properties read from a file.

◆ TEST_F() [3/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
missingColumn   
)

Definition at line 51 of file TabulatedBicubicFluidPropertiesTest.C.

52 {
53  try
54  {
55  const auto tow = Moose::_throw_on_warning;
57  const_cast<TabulatedBicubicFluidProperties *>(_missing_col_fp)->initialSetup();
59  FAIL();
60  }
61  catch (const std::exception & err)
62  {
63  std::size_t pos = std::string(err.what())
64  .find("data/csv/missing_col_fluid_props.csv. A "
65  "column named temperature must be present");
66  ASSERT_TRUE(pos != std::string::npos);
67  }
68 }
OStreamProxy err
Class for fluid properties read from a file.
bool _throw_on_warning

◆ TEST_F() [4/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
unknownColumn   
)

Definition at line 71 of file TabulatedBicubicFluidPropertiesTest.C.

72 {
73  try
74  {
75  const_cast<TabulatedBicubicFluidProperties *>(_unknown_col_fp)->initialSetup();
76  FAIL();
77  }
78  catch (const std::exception & err)
79  {
80  std::size_t pos = std::string(err.what())
81  .find("data/csv/unknown_fluid_props.csv tabulation file is not one of "
82  "the properties that TabulatedFluidProperties understands");
83  ASSERT_TRUE(pos != std::string::npos);
84  }
85 }
OStreamProxy err
Class for fluid properties read from a file.

◆ TEST_F() [5/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
missingData   
)

Definition at line 88 of file TabulatedBicubicFluidPropertiesTest.C.

89 {
90  try
91  {
92  const_cast<TabulatedBicubicFluidProperties *>(_missing_data_fp)->initialSetup();
93  FAIL();
94  }
95  catch (const std::exception & err)
96  {
97  std::size_t pos = std::string(err.what())
98  .find("data/csv/missing_data_fluid_props.csv "
99  "is not equal to the number of unique pressure values 3 multiplied "
100  "by the number of unique temperature values 3");
101  ASSERT_TRUE(pos != std::string::npos);
102  }
103 }
OStreamProxy err
Class for fluid properties read from a file.

◆ TEST_F() [6/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
fromPTFile   
)

Definition at line 106 of file TabulatedBicubicFluidPropertiesTest.C.

107 {
108  Real p = 1.5e6;
109  Real T = 450.0;
110 
111  // Read the data file
112  const_cast<TabulatedBicubicFluidProperties *>(_tab_pT_from_fp)->initialSetup();
113 
114  // Fluid properties
115  REL_TEST(_tab_pT_from_fp->rho_from_p_T(p, T), _co2_fp->rho_from_p_T(p, T), 1.0e-4);
116  REL_TEST(_tab_pT_from_fp->h_from_p_T(p, T), _co2_fp->h_from_p_T(p, T), 1.0e-4);
117  REL_TEST(_tab_pT_from_fp->e_from_p_T(p, T), _co2_fp->e_from_p_T(p, T), 1.0e-4);
118  REL_TEST(_tab_pT_from_fp->mu_from_p_T(p, T), _co2_fp->mu_from_p_T(p, T), 1.0e-4);
119  REL_TEST(_tab_pT_from_fp->k_from_p_T(p, T), _co2_fp->k_from_p_T(p, T), 1.0e-4);
120  REL_TEST(_tab_pT_from_fp->cp_from_p_T(p, T), _co2_fp->cp_from_p_T(p, T), 1.0e-4);
121  REL_TEST(_tab_pT_from_fp->cv_from_p_T(p, T), _co2_fp->cv_from_p_T(p, T), 1.0e-4);
122  REL_TEST(_tab_pT_from_fp->s_from_p_T(p, T), _co2_fp->s_from_p_T(p, T), 1.0e-4);
123 
124  // Fluid properties and derivatives
125  Real rho, drho_dp, drho_dT, rhoc, drhoc_dp, drhoc_dT;
126  _tab_pT_from_fp->rho_from_p_T(p, T, rho, drho_dp, drho_dT);
127  _co2_fp->rho_from_p_T(p, T, rhoc, drhoc_dp, drhoc_dT);
128  REL_TEST(rho, rhoc, 1.0e-4);
129  REL_TEST(drho_dp, drhoc_dp, 1.0e-3);
130  REL_TEST(drho_dT, drhoc_dT, 1.0e-3);
131 
132  Real h, dh_dp, dh_dT, hc, dhc_dp, dhc_dT;
133  _tab_pT_from_fp->h_from_p_T(p, T, h, dh_dp, dh_dT);
134  _co2_fp->h_from_p_T(p, T, hc, dhc_dp, dhc_dT);
135  REL_TEST(h, hc, 1.0e-4);
136  REL_TEST(dh_dp, dhc_dp, 1.0e-3);
137  REL_TEST(dh_dT, dhc_dT, 1.0e-3);
138 
139  Real mu, dmu_dp, dmu_dT, muc, dmuc_dp, dmuc_dT;
140  _tab_pT_from_fp->mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
141  _co2_fp->mu_from_p_T(p, T, muc, dmuc_dp, dmuc_dT);
142  REL_TEST(mu, muc, 1.0e-4);
143  REL_TEST(dmu_dp, dmuc_dp, 1.0e-3);
144  REL_TEST(dmu_dT, dmuc_dT, 1.0e-3);
145 
146  Real e, de_dp, de_dT, ec, dec_dp, dec_dT;
147  _tab_pT_from_fp->e_from_p_T(p, T, e, de_dp, de_dT);
148  _co2_fp->e_from_p_T(p, T, ec, dec_dp, dec_dT);
149  REL_TEST(e, ec, 1.0e-4);
150  REL_TEST(de_dp, dec_dp, 1.0e-3);
151  REL_TEST(de_dT, dec_dT, 1.0e-3);
152 }
static const std::string mu
Definition: NS.h:123
Class for fluid properties read from a file.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [7/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
fromPTFileToVE   
)

Definition at line 155 of file TabulatedBicubicFluidPropertiesTest.C.

156 {
157  Real p = 1.5e6;
158  Real T = 450.0;
159  Real pert = 1.0e-7;
160 
161  // Read the data file
162  Moose::_throw_on_warning = false;
163  const_cast<TabulatedBicubicFluidProperties *>(_tab_ve_from_pT)->initialSetup();
165 
166  // round trip p,T -> v,e -> p,T
167  {
168  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
169  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
170  Real pp = _tab_ve_from_pT->p_from_v_e(v, e);
171  Real TT = _tab_ve_from_pT->T_from_v_e(v, e);
172  ABS_TEST(T, TT, 1.0);
173  REL_TEST(p, pp, 0.001);
174  }
175 
176  // check computation of fluid props from p, T & v, e
177  {
178  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
179  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
180 
181  // heat capacity at constant pressure
182  Real cp1 = _tab_ve_from_pT->cp_from_p_T(p, T);
183  Real cp2 = _tab_ve_from_pT->cp_from_v_e(v, e);
184  REL_TEST(cp1, cp2, 0.001);
185 
186  // heat capacity at constant volume
187  Real cv1 = _tab_ve_from_pT->cv_from_p_T(p, T);
188  Real cv2 = _tab_ve_from_pT->cv_from_v_e(v, e);
189  REL_TEST(cv1, cv2, 0.001);
190 
191  // viscosity
192  Real mu1 = _tab_ve_from_pT->mu_from_p_T(p, T);
193  Real mu2 = _tab_ve_from_pT->mu_from_v_e(v, e);
194  REL_TEST(mu1, mu2, 0.001);
195 
196  // thermal conductivity
197  Real k1 = _tab_ve_from_pT->k_from_p_T(p, T);
198  Real k2 = _tab_ve_from_pT->k_from_v_e(v, e);
199  REL_TEST(k1, k2, 0.001);
200  }
201 
202  // check computation of fluid props from p, s
203  {
204  Real s = _tab_ve_from_pT->s_from_p_T(p, T);
205 
206  // density
207  Real rho1 = _tab_ve_from_pT->rho_from_p_T(p, T);
208  Real rho2 = _tab_ve_from_pT->rho_from_p_s(p, s);
209  REL_TEST(rho1, rho2, 0.001);
210 
211  // temperature
212  Real Ts = _tab_ve_from_pT->T_from_p_s(p, s);
213  REL_TEST(T, Ts, 0.001);
214  }
215 
216  // check computation of fluids props from p, h
217  {
218  Real T = 450;
219  Real p = 1.5e6;
220  Real h = _tab_ve_from_pT->h_from_p_T(p, T);
221  Real Ts = _tab_ve_from_pT->T_from_p_h(p, h);
222  REL_TEST(T, Ts, 1e-4);
223 
224  // to keep coverage on the default definition in SinglePhaseFP
225  Ts = dynamic_cast<const SinglePhaseFluidProperties *>(_tab_ve_from_pT)->T_from_p_h(p, h);
226  REL_TEST(T, Ts, 1e-4);
227  }
228 
229  // are the two version of functions equivalent
230  {
231  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
232  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
233 
234  Real d1, d2;
235 
236  // speed of sound errors bc co2 props don't
237  // implement enough
238 
239  // heat capacity at constant pressure
240  Real cp1;
241  _tab_ve_from_pT->cp_from_v_e(v, e, cp1, d1, d2);
242  Real cp2 = _tab_ve_from_pT->cp_from_v_e(v, e);
243  REL_TEST(cp1, cp2, 0.001);
244 
245  // heat capacity at constant volume
246  Real cv1;
247  _tab_ve_from_pT->cv_from_v_e(v, e, cv1, d1, d2);
248  Real cv2 = _tab_ve_from_pT->cv_from_v_e(v, e);
249  REL_TEST(cv1, cv2, 0.001);
250 
251  // viscosity
252  Real mu1;
253  _tab_ve_from_pT->mu_from_v_e(v, e, mu1, d1, d2);
254  Real mu2 = _tab_ve_from_pT->mu_from_v_e(v, e);
255  REL_TEST(mu1, mu2, 0.001);
256 
257  // thermal conductivity
258  Real k1;
259  _tab_ve_from_pT->k_from_v_e(v, e, k1, d1, d2);
260  Real k2 = _tab_ve_from_pT->k_from_v_e(v, e);
261  REL_TEST(k1, k2, 0.001);
262  }
263 
264  // check derivatives
265  {
266  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
267  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
268 
269  Real deriv1, deriv2;
270 
271  // pressure
272  Real p1;
273  _tab_ve_from_pT->p_from_v_e(v, e, p1, deriv1, deriv2);
274  Real p2 = _tab_ve_from_pT->p_from_v_e(v, e);
275  REL_TEST(p1, p2, 0.001);
276 
277  // temperature
278  Real T1;
279  _tab_ve_from_pT->T_from_v_e(v, e, T1, deriv1, deriv2);
280  Real T2 = _tab_ve_from_pT->T_from_v_e(v, e);
281  REL_TEST(T1, T2, 0.001);
282 
283  // speed of sound errors bc co2 props don't
284  // implement enough
285 
286  // heat capacity at constant pressure
287  Real cp1;
288  _tab_ve_from_pT->cp_from_v_e(v, e, cp1, deriv1, deriv2);
289  Real cp_0 = _tab_ve_from_pT->cp_from_v_e(v, e);
290  Real cp_1 = _tab_ve_from_pT->cp_from_v_e(v * (1 + pert), e);
291  Real cp_2 = _tab_ve_from_pT->cp_from_v_e(v, e * (1 + pert));
292  REL_TEST(deriv1, (cp_1 - cp_0) / (v * pert), 0.001);
293  REL_TEST(deriv2, (cp_2 - cp_0) / (e * pert), 0.001);
294 
295  // heat capacity at constant volume
296  Real cv1;
297  _tab_ve_from_pT->cv_from_v_e(v, e, cv1, deriv1, deriv2);
298  Real cv_0 = _tab_ve_from_pT->cv_from_v_e(v, e);
299  Real cv_1 = _tab_ve_from_pT->cv_from_v_e(v * (1 + pert), e);
300  Real cv_2 = _tab_ve_from_pT->cv_from_v_e(v, e * (1 + pert));
301  REL_TEST(deriv1, (cv_1 - cv_0) / (v * pert), 0.001);
302  REL_TEST(deriv2, (cv_2 - cv_0) / (e * pert), 0.001);
303 
304  // viscosity
305  Real mu1;
306  _tab_ve_from_pT->mu_from_v_e(v, e, mu1, deriv1, deriv2);
307  Real mu_0 = _tab_ve_from_pT->mu_from_v_e(v, e);
308  Real mu_1 = _tab_ve_from_pT->mu_from_v_e(v * (1 + pert), e);
309  Real mu_2 = _tab_ve_from_pT->mu_from_v_e(v, e * (1 + pert));
310  REL_TEST(deriv1, (mu_1 - mu_0) / (v * pert), 0.001);
311  REL_TEST(deriv2, (mu_2 - mu_0) / (e * pert), 0.001);
312 
313  // thermal conductivity
314  Real k1;
315  _tab_ve_from_pT->k_from_v_e(v, e, k1, deriv1, deriv2);
316  Real k_0 = _tab_ve_from_pT->k_from_v_e(v, e);
317  Real k_1 = _tab_ve_from_pT->k_from_v_e(v * (1 + pert), e);
318  Real k_2 = _tab_ve_from_pT->k_from_v_e(v, e * (1 + pert));
319  REL_TEST(deriv1, (k_1 - k_0) / (v * pert), 0.001);
320  REL_TEST(deriv2, (k_2 - k_0) / (e * pert), 0.001);
321  }
322 
323  // test enthalpy relationships
324  {
325  Real h = _tab_ve_from_pT->h_from_p_T(p, T);
326  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
327  Real e_gold = _tab_ve_from_pT->e_from_p_T(p, T);
328  Real e = _tab_ve_from_pT->e_from_v_h(v, h);
329  REL_TEST(e_gold, e, 0.001);
330 
331  Real e2, de_dv, de_dh;
332  _tab_ve_from_pT->e_from_v_h(v, h, e2, de_dv, de_dh);
333  REL_TEST(e_gold, e2, 0.001);
334  Real e_0 = _tab_ve_from_pT->e_from_v_h(v, h);
335  Real e_1 = _tab_ve_from_pT->e_from_v_h(v * (1 + pert), h);
336  Real e_2 = _tab_ve_from_pT->e_from_v_h(v, h * (1 + pert));
337  REL_TEST(de_dv, (e_1 - e_0) / (v * pert), 0.001);
338  REL_TEST(de_dh, (e_2 - e_0) / (h * pert), 0.001);
339  }
340 
341  // AD p_from_v_e
342  {
343  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
344  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
345  DNDerivativeType dvdx;
346  DNDerivativeType dedx;
347  // set it up so these are the derivatives
348  // w.r.t. to themselves
349  Moose::derivInsert(dvdx, 0, 1);
350  Moose::derivInsert(dvdx, 1, 0);
351  Moose::derivInsert(dedx, 0, 0);
352  Moose::derivInsert(dedx, 1, 1);
353 
354  ADReal v_ad(v, dvdx);
355  ADReal e_ad(e, dedx);
356  ADReal p_ad = _tab_ve_from_pT->p_from_v_e(v_ad, e_ad);
357 
358  Real pp, dp_dv, dp_de;
359  _tab_ve_from_pT->p_from_v_e(v, e, pp, dp_dv, dp_de);
360  REL_TEST(p_ad.derivatives()[0], dp_dv, 0.0001);
361  REL_TEST(p_ad.derivatives()[1], dp_de, 0.0001);
362  }
363 
364  // AD T_from_v_e
365  {
366  Real e = _tab_ve_from_pT->e_from_p_T(p, T);
367  Real v = _tab_ve_from_pT->v_from_p_T(p, T);
368  DNDerivativeType dvdx;
369  DNDerivativeType dedx;
370  // set it up so these are the derivatives
371  // w.r.t. to themselves
372  Moose::derivInsert(dvdx, 0, 1);
373  Moose::derivInsert(dvdx, 1, 0);
374  Moose::derivInsert(dedx, 0, 0);
375  Moose::derivInsert(dedx, 1, 1);
376 
377  ADReal v_ad(v, dvdx);
378  ADReal e_ad(e, dedx);
379  ADReal T_ad = _tab_ve_from_pT->T_from_v_e(v_ad, e_ad);
380 
381  Real TT, dT_dv, dT_de;
382  _tab_ve_from_pT->T_from_v_e(v, e, TT, dT_dv, dT_de);
383  REL_TEST(T_ad.derivatives()[0], dT_dv, 0.0001);
384  REL_TEST(T_ad.derivatives()[1], dT_de, 0.0001);
385  }
386 
387  // cannot test AD c_from_v_e because co2 props do not
388  // implement enough
389 
390  // AD T_from_p_h
391  {
392  Real h = _tab_ve_from_pT->h_from_p_T(p, T);
393  DNDerivativeType dpdx;
394  DNDerivativeType dhdx;
395  // set it up so these are the derivatives
396  // w.r.t. to themselves
397  Moose::derivInsert(dpdx, 0, 1);
398  Moose::derivInsert(dpdx, 1, 0);
399  Moose::derivInsert(dhdx, 0, 0);
400  Moose::derivInsert(dhdx, 1, 1);
401 
402  ADReal p_ad(p, dpdx);
403  ADReal h_ad(h, dhdx);
404  ADReal T_ad = _tab_ve_from_pT->T_from_p_h(p_ad, h_ad);
405 
406  Real TT_1 = _tab_ve_from_pT->T_from_p_h(p * (1 + pert), h);
407  Real TT_2 = _tab_ve_from_pT->T_from_p_h(p, h * (1 + pert));
408  Real dT_dp = (TT_1 - T) / p / pert;
409  Real dT_dh = (TT_2 - T) / h / pert;
410  REL_TEST(T_ad.derivatives()[0], dT_dp, 0.0001);
411  REL_TEST(T_ad.derivatives()[1], dT_dh, 0.0001);
412  }
413 }
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
DualNumber< Real, DNDerivativeType, true > ADReal
Common class for single phase fluid properties.
Class for fluid properties read from a file.
static const Real mu_0
Magnetic permeability of free space in SI units (H/m)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
bool _throw_on_warning
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)

◆ TEST_F() [8/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
fromVEFile   
)

Definition at line 416 of file TabulatedBicubicFluidPropertiesTest.C.

417 {
418  // These values must be within the bounds specified in the header
419  Real p = 1.223e6;
420  Real T = 420.1;
421  Real pert = 1.0e-7;
422 
423  // Read the data file
424  Moose::_throw_on_warning = false;
425  const_cast<TabulatedBicubicFluidProperties *>(_tab_ve_from_fp)->initialSetup();
427 
428  // Use as a reference
429  Real e = _idg_fp->e_from_p_T(p, T);
430  Real v = _idg_fp->v_from_p_T(p, T);
431 
432  // NOTE: direct from (v,e) currently does not support
433  // calls with (p, T), (p, rho), (p, s).
434 
435  // check computation of fluid props from v, e
436  {
437  // heat capacity at constant pressure
438  Real cp1 = _idg_fp->cp_from_v_e(v, e);
439  Real cp2 = _tab_ve_from_fp->cp_from_v_e(v, e);
440  REL_TEST(cp1, cp2, 0.001);
441 
442  // heat capacity at constant volume
443  Real cv1 = _idg_fp->cv_from_v_e(v, e);
444  Real cv2 = _tab_ve_from_fp->cv_from_v_e(v, e);
445  REL_TEST(cv1, cv2, 0.001);
446 
447  // speed of sound
448  Real c1 = _idg_fp->c_from_v_e(v, e);
449  Real c2 = _tab_ve_from_fp->c_from_v_e(v, e);
450  REL_TEST(c1, c2, 0.001);
451 
452  // viscosity
453  Real mu1 = _idg_fp->mu_from_v_e(v, e);
454  Real mu2 = _tab_ve_from_fp->mu_from_v_e(v, e);
455  REL_TEST(mu1, mu2, 0.001);
456 
457  // thermal conductivity
458  Real k1 = _idg_fp->k_from_v_e(v, e);
459  Real k2 = _tab_ve_from_fp->k_from_v_e(v, e);
460  REL_TEST(k1, k2, 0.001);
461  }
462 
463  // are the two version of functions equivalent
464  {
465  Real d1, d2;
466 
467  // pressure
468  Real p1;
469  _tab_ve_from_fp->p_from_v_e(v, e, p1, d1, d2);
470  Real p2 = _tab_ve_from_fp->p_from_v_e(v, e);
471  REL_TEST(p1, p2, 0.001);
472 
473  // temperature
474  Real T1;
475  _tab_ve_from_fp->T_from_v_e(v, e, T1, d1, d2);
476  Real T2 = _tab_ve_from_fp->T_from_v_e(v, e);
477  REL_TEST(T1, T2, 0.001);
478 
479  // heat capacity at constant pressure
480  Real cp1;
481  _tab_ve_from_fp->cp_from_v_e(v, e, cp1, d1, d2);
482  Real cp2 = _tab_ve_from_fp->cp_from_v_e(v, e);
483  REL_TEST(cp1, cp2, 0.001);
484 
485  // heat capacity at constant volume
486  Real cv1;
487  _tab_ve_from_fp->cv_from_v_e(v, e, cv1, d1, d2);
488  Real cv2 = _tab_ve_from_fp->cv_from_v_e(v, e);
489  REL_TEST(cv1, cv2, 0.001);
490 
491  // speed of sound
492  Real c1;
493  _tab_ve_from_fp->c_from_v_e(v, e, c1, d1, d2);
494  Real c2 = _tab_ve_from_fp->c_from_v_e(v, e);
495  REL_TEST(c1, c2, 0.001);
496 
497  // viscosity
498  Real mu1;
499  _tab_ve_from_fp->mu_from_v_e(v, e, mu1, d1, d2);
500  Real mu2 = _tab_ve_from_fp->mu_from_v_e(v, e);
501  REL_TEST(mu1, mu2, 0.001);
502 
503  // thermal conductivity
504  Real k1;
505  _tab_ve_from_fp->k_from_v_e(v, e, k1, d1, d2);
506  Real k2 = _tab_ve_from_fp->k_from_v_e(v, e);
507  REL_TEST(k1, k2, 0.001);
508  }
509 
510  // check derivatives
511  {
512  Real deriv1, deriv2;
513 
514  // speed of sound errors bc co2 props don't
515  // implement enough
516 
517  // heat capacity at constant pressure
518  Real cp1;
519  _tab_ve_from_fp->cp_from_v_e(v, e, cp1, deriv1, deriv2);
520  Real cp_0 = _tab_ve_from_fp->cp_from_v_e(v, e);
521  Real cp_1 = _tab_ve_from_fp->cp_from_v_e(v * (1 + pert), e);
522  Real cp_2 = _tab_ve_from_fp->cp_from_v_e(v, e * (1 + pert));
523  REL_TEST(deriv1, (cp_1 - cp_0) / (v * pert), 0.001);
524  REL_TEST(deriv2, (cp_2 - cp_0) / (e * pert), 0.001);
525 
526  // heat capacity at constant volume
527  Real cv1;
528  _tab_ve_from_fp->cv_from_v_e(v, e, cv1, deriv1, deriv2);
529  Real cv_0 = _tab_ve_from_fp->cv_from_v_e(v, e);
530  Real cv_1 = _tab_ve_from_fp->cv_from_v_e(v * (1 + pert), e);
531  Real cv_2 = _tab_ve_from_fp->cv_from_v_e(v, e * (1 + pert));
532  REL_TEST(deriv1, (cv_1 - cv_0) / (v * pert), 0.001);
533  REL_TEST(deriv2, (cv_2 - cv_0) / (e * pert), 0.001);
534 
535  // viscosity
536  Real mu1;
537  _tab_ve_from_fp->mu_from_v_e(v, e, mu1, deriv1, deriv2);
538  Real mu_0 = _tab_ve_from_fp->mu_from_v_e(v, e);
539  Real mu_1 = _tab_ve_from_fp->mu_from_v_e(v * (1 + pert), e);
540  Real mu_2 = _tab_ve_from_fp->mu_from_v_e(v, e * (1 + pert));
541  REL_TEST(deriv1, (mu_1 - mu_0) / (v * pert), 0.001);
542  REL_TEST(deriv2, (mu_2 - mu_0) / (e * pert), 0.001);
543 
544  // thermal conductivity
545  Real k1;
546  _tab_ve_from_fp->k_from_v_e(v, e, k1, deriv1, deriv2);
547  Real k_0 = _tab_ve_from_fp->k_from_v_e(v, e);
548  Real k_1 = _tab_ve_from_fp->k_from_v_e(v * (1 + pert), e);
549  Real k_2 = _tab_ve_from_fp->k_from_v_e(v, e * (1 + pert));
550  REL_TEST(deriv1, (k_1 - k_0) / (v * pert), 0.001);
551  REL_TEST(deriv2, (k_2 - k_0) / (e * pert), 0.001);
552  }
553 
554  // test enthalpy relationships (v,h)
555  {
556  Moose::_throw_on_warning = false;
557  Real h = _idg_fp->h_from_p_T(p, T);
558  Real v = _idg_fp->v_from_p_T(p, T);
559  Real e_gold = _idg_fp->e_from_p_T(p, T);
560  Real e0 = _tab_ve_from_fp->e_from_v_h(v, h);
561  REL_TEST(e_gold, e0, 0.001);
562 
563  Real e2, de_dv, de_dh;
564  _tab_ve_from_fp->e_from_v_h(v, h, e2, de_dv, de_dh);
565  REL_TEST(e_gold, e2, 0.001);
566  Real e_0 = _tab_ve_from_fp->e_from_v_h(v, h);
567  Real e_1 = _tab_ve_from_fp->e_from_v_h(v * (1 + pert), h);
568  Real e_2 = _tab_ve_from_fp->e_from_v_h(v, h * (1 + pert));
569  REL_TEST(de_dv, (e_1 - e_0) / (v * pert), 0.001);
570  REL_TEST(de_dh, (e_2 - e_0) / (h * pert), 0.001);
572  }
573 
574  // AD p_from_v_e
575  {
576  DNDerivativeType dvdx;
577  DNDerivativeType dedx;
578  // set it up so these are the derivatives
579  // w.r.t. to themselves
580  Moose::derivInsert(dvdx, 0, 1);
581  Moose::derivInsert(dvdx, 1, 0);
582  Moose::derivInsert(dedx, 0, 0);
583  Moose::derivInsert(dedx, 1, 1);
584 
585  ADReal v_ad(v, dvdx);
586  ADReal e_ad(e, dedx);
587  ADReal p_ad = _tab_ve_from_fp->p_from_v_e(v_ad, e_ad);
588 
589  Real pp, dp_dv, dp_de;
590  _tab_ve_from_fp->p_from_v_e(v, e, pp, dp_dv, dp_de);
591  REL_TEST(p_ad.derivatives()[0], dp_dv, 0.0001);
592  REL_TEST(p_ad.derivatives()[1], dp_de, 0.0001);
593  }
594 
595  // AD T_from_v_e
596  {
597  DNDerivativeType dvdx;
598  DNDerivativeType dedx;
599  // set it up so these are the derivatives
600  // w.r.t. to themselves
601  Moose::derivInsert(dvdx, 0, 1);
602  Moose::derivInsert(dvdx, 1, 0);
603  Moose::derivInsert(dedx, 0, 0);
604  Moose::derivInsert(dedx, 1, 1);
605 
606  ADReal v_ad(v, dvdx);
607  ADReal e_ad(e, dedx);
608  ADReal T_ad = _tab_ve_from_fp->T_from_v_e(v_ad, e_ad);
609 
610  Real TT, dT_dv, dT_de;
611  _tab_ve_from_fp->T_from_v_e(v, e, TT, dT_dv, dT_de);
612  REL_TEST(T_ad.derivatives()[0], dT_dv, 0.0001);
613  REL_TEST(T_ad.derivatives()[1], dT_de, 0.0001);
614  }
615 
616  // cannot test AD c_from_v_e because co2 props do not
617  // implement enough
618 }
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
DualNumber< Real, DNDerivativeType, true > ADReal
Class for fluid properties read from a file.
static const Real mu_0
Magnetic permeability of free space in SI units (H/m)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
bool _throw_on_warning
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)

◆ TEST_F() [9/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
derivatives   
)

Verify calculation of the derivatives of tabulated properties by comparing with finite differences.

Definition at line 624 of file TabulatedBicubicFluidPropertiesTest.C.

625 {
626 
627  const Real p = 1.5e6;
628  const Real T = 452.0;
629 
630  {
631  // Read the data file and generate (v,e) to (p,T) interpolations
632  Moose::_throw_on_warning = false;
633  const_cast<TabulatedBicubicFluidProperties *>(_tab_ve_from_pT)->initialSetup();
635  const Real tol = REL_TOL_DERIVATIVE;
636 
637  const Real rho = _tab_ve_from_pT->rho_from_p_T(p, T);
638  const Real v = 1. / rho;
639  const Real e = _tab_ve_from_pT->e_from_p_T(p, T);
640  const Real s = _tab_ve_from_pT->s_from_p_T(p, T);
641 
642  DERIV_TEST(_tab_ve_from_pT->rho_from_p_T, p, T, tol);
643  DERIV_TEST(_tab_ve_from_pT->e_from_p_T, p, T, tol);
644  DERIV_TEST(_tab_ve_from_pT->v_from_p_T, p, T, tol);
645  DERIV_TEST(_tab_ve_from_pT->h_from_p_T, p, T, tol);
646  DERIV_TEST(_tab_ve_from_pT->k_from_p_T, p, T, tol);
647  DERIV_TEST(_tab_ve_from_pT->cp_from_p_T, p, T, tol);
648  DERIV_TEST(_tab_ve_from_pT->cv_from_p_T, p, T, tol);
649  DERIV_TEST(_tab_ve_from_pT->mu_from_p_T, p, T, tol);
650 
651  DERIV_TEST(_tab_ve_from_pT->p_from_v_e, v, e, tol);
652  DERIV_TEST(_tab_ve_from_pT->mu_from_v_e, v, e, tol);
653  DERIV_TEST(_tab_ve_from_pT->k_from_v_e, v, e, tol);
654  DERIV_TEST(_tab_ve_from_pT->T_from_v_e, v, e, tol);
655  DERIV_TEST(_tab_ve_from_pT->cp_from_v_e, v, e, tol);
656  DERIV_TEST(_tab_ve_from_pT->cv_from_v_e, v, e, tol);
657 
658  DERIV_TEST(_tab_ve_from_pT->T_from_p_rho, p, rho, tol);
659  DERIV_TEST(_tab_ve_from_pT->e_from_p_rho, p, rho, tol);
660 
661  DERIV_TEST(_tab_ve_from_pT->T_from_p_s, p, s, tol);
662  DERIV_TEST(_tab_ve_from_pT->rho_from_p_s, p, s, tol);
663  }
664 
665  {
666  // Read the data file with direct to (v,e) interpolations
667  Moose::_throw_on_warning = false;
668  const_cast<TabulatedBicubicFluidProperties *>(_tab_ve_from_fp)->initialSetup();
670  const Real tol = REL_TOL_DERIVATIVE;
671 
672  const Real rho = _tab_ve_from_fp->rho_from_p_T(p, T);
673  const Real v = 1. / rho;
674  const Real e = _tab_ve_from_fp->e_from_p_T(p, T);
675  const Real h = e + p * v;
676 
677  DERIV_TEST(_tab_ve_from_fp->p_from_v_e, v, e, tol);
678  DERIV_TEST(_tab_ve_from_fp->mu_from_v_e, v, e, tol);
679  DERIV_TEST(_tab_ve_from_fp->k_from_v_e, v, e, tol);
680  DERIV_TEST(_tab_ve_from_fp->T_from_v_e, v, e, tol);
681  DERIV_TEST(_tab_ve_from_fp->cp_from_v_e, v, e, tol);
682  DERIV_TEST(_tab_ve_from_fp->cv_from_v_e, v, e, tol);
683 
684  // Jacobian warning and finite differencing in use
685  Moose::_throw_on_warning = false;
686  DERIV_TEST(_tab_ve_from_fp->e_from_v_h, v, h, 100 * tol);
688  }
689 }
const double tol
Class for fluid properties read from a file.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
bool _throw_on_warning

◆ TEST_F() [10/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
generateTabulatedData   
)

Definition at line 692 of file TabulatedBicubicFluidPropertiesTest.C.

693 {
694  Real p = 1.5e6;
695  Real T = 450.0;
696 
697  // Generate the tabulated data
698  const_cast<TabulatedBicubicFluidProperties *>(_tab_gen_fp)->initialSetup();
699 
700  REL_TEST(_tab_gen_fp->rho_from_p_T(p, T), _co2_fp->rho_from_p_T(p, T), 1.0e-4);
701  REL_TEST(_tab_gen_fp->h_from_p_T(p, T), _co2_fp->h_from_p_T(p, T), 1.0e-4);
702  REL_TEST(_tab_gen_fp->e_from_p_T(p, T), _co2_fp->e_from_p_T(p, T), 1.0e-4);
703  REL_TEST(_tab_gen_fp->mu_from_p_T(p, T), _co2_fp->mu_from_p_T(p, T), 1.0e-4);
704  REL_TEST(_tab_gen_fp->k_from_p_T(p, T), _co2_fp->k_from_p_T(p, T), 1.0e-4);
705  REL_TEST(_tab_gen_fp->cp_from_p_T(p, T), _co2_fp->cp_from_p_T(p, T), 1.0e-4);
706  REL_TEST(_tab_gen_fp->cv_from_p_T(p, T), _co2_fp->cv_from_p_T(p, T), 1.0e-4);
707  REL_TEST(_tab_gen_fp->s_from_p_T(p, T), _co2_fp->s_from_p_T(p, T), 1.0e-4);
708 }
Class for fluid properties read from a file.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [11/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
passthrough   
)

Definition at line 712 of file TabulatedBicubicFluidPropertiesTest.C.

713 {
714  Real p = 1.5e6;
715  Real T = 450.0;
716  const Real tol = REL_TOL_SAVED_VALUE;
717 
718  // As the flags for interpolation in TabulatedBicubicFluidProperties default to false,
719  // properties will be passed through to the given fluid properties object
720  ABS_TEST(_tab_pT_from_fp->rho_from_p_T(p, T), _co2_fp->rho_from_p_T(p, T), tol);
721  ABS_TEST(_tab_pT_from_fp->h_from_p_T(p, T), _co2_fp->h_from_p_T(p, T), tol);
722  ABS_TEST(_tab_pT_from_fp->e_from_p_T(p, T), _co2_fp->e_from_p_T(p, T), tol);
723  ABS_TEST(_tab_pT_from_fp->mu_from_p_T(p, T), _co2_fp->mu_from_p_T(p, T), tol);
724  ABS_TEST(_tab_pT_from_fp->k_from_p_T(p, T), _co2_fp->k_from_p_T(p, T), tol);
725  ABS_TEST(_tab_pT_from_fp->cp_from_p_T(p, T), _co2_fp->cp_from_p_T(p, T), tol);
726  ABS_TEST(_tab_pT_from_fp->cv_from_p_T(p, T), _co2_fp->cv_from_p_T(p, T), tol);
727  ABS_TEST(_tab_pT_from_fp->s_from_p_T(p, T), _co2_fp->s_from_p_T(p, T), tol);
728 
729  // These calls are always forwarded to the 'fp' parameter fluid properties because the
730  // tabulations are not implemented
731  ABS_TEST(_tab_pT_from_fp->henryCoefficients()[0], _co2_fp->henryCoefficients()[0], tol);
732  ABS_TEST(_tab_pT_from_fp->henryCoefficients()[1], _co2_fp->henryCoefficients()[1], tol);
733  ABS_TEST(_tab_pT_from_fp->henryCoefficients()[2], _co2_fp->henryCoefficients()[2], tol);
734  ABS_TEST(_tab_pT_from_fp->triplePointPressure(), _co2_fp->triplePointPressure(), tol);
735  ABS_TEST(_tab_pT_from_fp->triplePointTemperature(), _co2_fp->triplePointTemperature(), tol);
736  ABS_TEST(_tab_pT_from_fp->criticalPressure(), _co2_fp->criticalPressure(), tol);
737  ABS_TEST(_tab_pT_from_fp->criticalTemperature(), _co2_fp->criticalTemperature(), tol);
738  ABS_TEST(_tab_pT_from_fp->criticalDensity(), _co2_fp->criticalDensity(), tol);
739 
740  // Use a temperature less than the critical point
741  T = 300.0;
742  ABS_TEST(_tab_pT_from_fp->vaporPressure(T), _co2_fp->vaporPressure(T), tol);
743 
744  // TODO: these properties are not implemented in CO2 fp so we cannot test the pass through
745  // T_from_p_h
746  // vaporPressure with saturation pressure
747  // vaporTemperature
748 }
const double tol
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [12/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
fluidName   
)

Test that the fluid name is correctly returned.

Definition at line 753 of file TabulatedBicubicFluidPropertiesTest.C.

754 {
755  EXPECT_EQ(_tab_pT_from_fp->fluidName(), "co2");
756 }

◆ TEST_F() [13/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
molarMass   
)

Test that the molar mass is correctly returned.

Definition at line 761 of file TabulatedBicubicFluidPropertiesTest.C.

762 {
763  ABS_TEST(_tab_pT_from_fp->molarMass(), 44.0098e-3, REL_TOL_SAVED_VALUE);
764 }

◆ TEST_F() [14/14]

TEST_F ( TabulatedBicubicFluidPropertiesTest  ,
combined   
)

Verify that the methods that return multiple properties in one call return identical values as the individual methods.

Definition at line 770 of file TabulatedBicubicFluidPropertiesTest.C.

771 {
772  const Real p = 1.0e6;
773  const Real T = 300.0;
774  const Real tol = REL_TOL_CONSISTENCY;
775 
776  // Single property methods
777  Real rho, drho_dp, drho_dT;
778  _tab_pT_from_fp->rho_from_p_T(p, T, rho, drho_dp, drho_dT);
779  Real mu, dmu_dp, dmu_dT;
780  _tab_pT_from_fp->mu_from_p_T(p, T, mu, dmu_dp, dmu_dT);
781  Real e, de_dp, de_dT;
782  _tab_pT_from_fp->e_from_p_T(p, T, e, de_dp, de_dT);
783 
784  // Combined property methods
785  Real rho2, drho2_dp, drho2_dT, mu2, dmu2_dp, dmu2_dT, e2, de2_dp, de2_dT;
786  _tab_pT_from_fp->rho_mu_from_p_T(p, T, rho2, mu2);
787 
788  ABS_TEST(rho, rho2, tol);
789  ABS_TEST(mu, mu2, tol);
790 
791  _tab_pT_from_fp->rho_mu_from_p_T(p, T, rho2, drho2_dp, drho2_dT, mu2, dmu2_dp, dmu2_dT);
792  ABS_TEST(rho, rho2, tol);
793  ABS_TEST(drho_dp, drho2_dp, tol);
794  ABS_TEST(drho_dT, drho2_dT, tol);
795  ABS_TEST(mu, mu2, tol);
796  ABS_TEST(dmu_dp, dmu2_dp, tol);
797  ABS_TEST(dmu_dT, dmu2_dT, tol);
798 
799  _tab_pT_from_fp->rho_e_from_p_T(p, T, rho2, drho2_dp, drho2_dT, e2, de2_dp, de2_dT);
800  ABS_TEST(rho, rho2, tol);
801  ABS_TEST(drho_dp, drho2_dp, tol);
802  ABS_TEST(drho_dT, drho2_dT, tol);
803  ABS_TEST(e, e2, tol);
804  ABS_TEST(de_dp, de2_dp, tol);
805  ABS_TEST(de_dT, de2_dT, tol);
806 }
const double tol
static const std::string mu
Definition: NS.h:123
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real