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

Go to the source code of this file.

Functions

 TEST_F (SodiumSaturationFluidPropertiesTest, fluidName)
 Test that the fluid name is correctly returned.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, molarMass)
 Test that the molar mass is correctly returned.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, thermalConductivity)
 Test that the thermal conductivity and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, viscosity)
 Test that the viscosity and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, isobaricSpecificHeat)
 Test that the isobaric specific heat and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, isochoricSpecificHeat)
 Test that the isochoric specific heat and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, density)
 Test that the density and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, specificInternalEnergy)
 Test that the specific internal energy and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, specificEnthalpy)
 Test that the specific enthalpy and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, pressureExtension)
 Test the first-order pressure extension and its thermodynamic derivatives.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, temperatureFromPressureEnthalpy)
 Test inversion of specific enthalpy to temperature.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, specificEntropy)
 Test that the specific entropy and its derivatives are correctly computed.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, PTFromVE)
 Test that the pressure can be computed from the specific volume & energy.
 
 TEST_F (SodiumSaturationFluidPropertiesTest, volumeEnergyAutomaticDifferentiation)
 Test automatic differentiation of the (v,e) properties used by compressible-flow applications.
 

Function Documentation

◆ TEST_F() [1/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
density   
)

Test that the density and its derivatives are correctly computed.

Definition at line 97 of file SodiumSaturationFluidPropertiesTest.C.

98{
99 const Real Tm = 370.98;
100 const Real T = 800.0;
101 const Real Tb = 1156.5;
102 const Real p = 101325;
103
104 // Fink and Leibowitz (1979) list density at 370.98 K is 927.3, so the fit agrees well
105 ABS_TEST(_fp->rho_from_p_T(p, Tm), 923.3571594322216, REL_TOL_SAVED_VALUE);
106 DERIV_TEST(_fp->rho_from_p_T, p, Tm, REL_TOL_DERIVATIVE);
107 ABS_TEST(_fp->v_from_p_T(p, Tm), 0.001083004544649772, REL_TOL_SAVED_VALUE);
108 DERIV_TEST(_fp->v_from_p_T, p, Tm, REL_TOL_DERIVATIVE);
109
110 // Fink and Leibowitz (1979) list density at 800 K is 825.6, so the fit agrees well
111 ABS_TEST(_fp->rho_from_p_T(p, T), 826.04056, REL_TOL_SAVED_VALUE);
112 DERIV_TEST(_fp->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);
113 ABS_TEST(_fp->v_from_p_T(p, T), 0.0012105943078630425, REL_TOL_SAVED_VALUE);
114 DERIV_TEST(_fp->v_from_p_T, p, T, REL_TOL_DERIVATIVE);
115
116 // Fink and Leibowitz (1979) list density at 1156.5 K is 739.4, so the fit agrees well
117 ABS_TEST(_fp->rho_from_p_T(p, Tb), 742.0807106065, REL_TOL_SAVED_VALUE);
118 DERIV_TEST(_fp->rho_from_p_T, p, Tb, REL_TOL_DERIVATIVE);
119 ABS_TEST(_fp->v_from_p_T(p, Tb), 0.0013475623145933863, REL_TOL_SAVED_VALUE);
120 DERIV_TEST(_fp->v_from_p_T, p, Tb, REL_TOL_DERIVATIVE);
121}
const Real p
const double T
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ TEST_F() [2/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
fluidName   
)

Test that the fluid name is correctly returned.

Definition at line 18 of file SodiumSaturationFluidPropertiesTest.C.

19{
20 EXPECT_EQ(_fp->fluidName(), "sodium_sat");
21}

◆ TEST_F() [3/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
isobaricSpecificHeat   
)

Test that the isobaric specific heat and its derivatives are correctly computed.

Definition at line 61 of file SodiumSaturationFluidPropertiesTest.C.

62{
63 const Real T1 = 400.0;
64 const Real T2 = 800.0;
65 const Real p = 1e5;
66
67 // Fink and Leibowitz (1979) show Cp = 1373.6 at 400 K, so the fit agrees well
68 REL_TEST(_fp->cp_from_p_T(p, T1), 1383.985792, REL_TOL_SAVED_VALUE);
69 DERIV_TEST(_fp->cp_from_p_T, 5e5, T1, REL_TOL_DERIVATIVE);
70
71 // Fink and Leibowitz (1979) show Cp = 1263.6 at 800 K, so the fit agrees well
72 REL_TEST(_fp->cp_from_p_T(p, T2), 1260.719872, REL_TOL_SAVED_VALUE);
73 DERIV_TEST(_fp->cp_from_p_T, 5e5, T2, REL_TOL_DERIVATIVE);
74}

◆ TEST_F() [4/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
isochoricSpecificHeat   
)

Test that the isochoric specific heat and its derivatives are correctly computed.

Definition at line 79 of file SodiumSaturationFluidPropertiesTest.C.

80{
81 const Real T1 = 400.0;
82 const Real T2 = 800.0;
83 const Real p = 101325;
84
85 // Fink and Leibowitz (1979) show Cv = 1230.1 at 400 K, so the fit agrees well
86 REL_TEST(_fp->cv_from_p_T(p, T1), 1222.9660159999999, REL_TOL_SAVED_VALUE);
87 DERIV_TEST(_fp->cv_from_p_T, p, T1, REL_TOL_DERIVATIVE);
88
89 // Fink and Leibowitz (1979) show Cv = 982.611 at 800 K, so the fit agrees well
90 REL_TEST(_fp->cv_from_p_T(p, T2), 986.2385279999999, REL_TOL_SAVED_VALUE);
91 DERIV_TEST(_fp->cv_from_p_T, p, T2, REL_TOL_DERIVATIVE);
92}

◆ TEST_F() [5/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
molarMass   
)

Test that the molar mass is correctly returned.

Definition at line 26 of file SodiumSaturationFluidPropertiesTest.C.

27{
28 ABS_TEST(_fp->molarMass(), 22.989769E-3, REL_TOL_SAVED_VALUE);
29}

◆ TEST_F() [6/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
pressureExtension   
)

Test the first-order pressure extension and its thermodynamic derivatives.

Definition at line 158 of file SodiumSaturationFluidPropertiesTest.C.

159{
160 const Real T = 800.0;
161 const Real p0 = 1e5;
162 const Real p = 5e5;
163
164 Real v, dv_dp, dv_dT;
165 _fp->v_from_p_T(p, T, v, dv_dp, dv_dT);
166
167 Real h, dh_dp, dh_dT;
168 _fp->h_from_p_T(p, T, h, dh_dp, dh_dT);
169 const Real h0 = _fp->h_from_p_T(p0, T);
170
171 Real s, ds_dp, ds_dT;
172 _fp->s_from_p_T(p, T, s, ds_dp, ds_dT);
173
174 DERIV_TEST(_fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);
175 REL_TEST(h - h0, (p - p0) * (v - T * dv_dT), REL_TOL_CONSISTENCY);
176 REL_TEST(dh_dp, v - T * dv_dT, REL_TOL_DERIVATIVE);
177 REL_TEST(dh_dT, _fp->cp_from_p_T(p, T), REL_TOL_DERIVATIVE);
178 REL_TEST(ds_dp, (dh_dp - v) / T, REL_TOL_DERIVATIVE);
179 REL_TEST(ds_dT, dh_dT / T, REL_TOL_DERIVATIVE);
180}
const double v

◆ TEST_F() [7/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
PTFromVE   
)

Test that the pressure can be computed from the specific volume & energy.

Definition at line 221 of file SodiumSaturationFluidPropertiesTest.C.

222{
223 // Starting pressure and temperature
224 const Real T = 800.0;
225 const Real p = 5e5;
226
227 // Obtain specific volume and specific energy
228 const Real v = _fp->v_from_p_T(p, T);
229 const Real e = _fp->e_from_p_T(p, T);
230
231 // Verify that the conversion back succeeds
232 ABS_TEST(_fp->T_from_v_e(v, e), T, TOLERANCE);
233 // The pressure inversion contains cancellation between the reference enthalpy and energy;
234 // this tolerance is still sub-millipascal relative to the 500000 Pa state.
235 ABS_TEST(_fp->p_from_v_e(v, e), p, 1e-5);
236
237 // Verify the remaining (v,e) properties required by compressible-flow applications
238 REL_TEST(_fp->c_from_v_e(v, e), 2301.5361599999997, REL_TOL_SAVED_VALUE);
239 REL_TEST(_fp->cp_from_v_e(v, e), _fp->cp_from_p_T(p, T), REL_TOL_CONSISTENCY);
240 REL_TEST(_fp->cv_from_v_e(v, e), _fp->cv_from_p_T(p, T), REL_TOL_CONSISTENCY);
241 REL_TEST(_fp->mu_from_v_e(v, e), _fp->mu_from_p_T(p, T), REL_TOL_CONSISTENCY);
242 REL_TEST(_fp->k_from_v_e(v, e), _fp->k_from_p_T(p, T), REL_TOL_CONSISTENCY);
243 REL_TEST(_fp->e_from_p_rho(p, 1 / v), e, REL_TOL_CONSISTENCY);
244
245 DERIV_TEST(_fp->p_from_v_e, v, e, REL_TOL_DERIVATIVE);
246 DERIV_TEST(_fp->T_from_v_e, v, e, REL_TOL_DERIVATIVE);
247 DERIV_TEST(_fp->c_from_v_e, v, e, REL_TOL_DERIVATIVE);
248 DERIV_TEST(_fp->cp_from_v_e, v, e, REL_TOL_DERIVATIVE);
249 DERIV_TEST(_fp->cv_from_v_e, v, e, REL_TOL_DERIVATIVE);
250 DERIV_TEST(_fp->mu_from_v_e, v, e, REL_TOL_DERIVATIVE);
251 DERIV_TEST(_fp->k_from_v_e, v, e, REL_TOL_DERIVATIVE);
252 DERIV_TEST(_fp->e_from_p_rho, p, 1 / v, REL_TOL_DERIVATIVE);
253}

◆ TEST_F() [8/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
specificEnthalpy   
)

Test that the specific enthalpy and its derivatives are correctly computed.

Definition at line 140 of file SodiumSaturationFluidPropertiesTest.C.

141{
142 const Real T = 800.0;
143 const Real p = 1e5;
144
145 // Fink and Leibowitz (1979) compute enthalpy at 800 K as 768602, so the fit agrees well
146 ABS_TEST(_fp->h_from_p_T(p, T), 767034.6715200001, REL_TOL_SAVED_VALUE);
147 DERIV_TEST(_fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);
148
149 // Fink and Leibowitz (1979) compute enthalpy at 1156.5 K as 1218803, so the fit agrees well
150 const Real T2 = 1156.5;
151 ABS_TEST(_fp->h_from_p_T(p, T2), 1218897.6776327428, REL_TOL_SAVED_VALUE);
152 DERIV_TEST(_fp->h_from_p_T, p, T2, REL_TOL_DERIVATIVE);
153}

◆ TEST_F() [9/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
specificEntropy   
)

Test that the specific entropy and its derivatives are correctly computed.

Definition at line 198 of file SodiumSaturationFluidPropertiesTest.C.

199{
200 const Real reference_T = 370.98;
201 const Real reference_p = 1e5;
202 ABS_TEST(_fp->s_from_p_T(reference_p, reference_T), 0.0, TOLERANCE);
203
204 const Real T = 800.0;
205 const Real p = 5e5;
206 const Real v = _fp->v_from_p_T(p, T);
207 const Real e = _fp->e_from_p_T(p, T);
208 const Real s = _fp->s_from_p_T(p, T);
209 REL_TEST(_fp->s_from_v_e(v, e), s, REL_TOL_CONSISTENCY);
210 REL_TEST(_fp->rho_from_p_s(p, s), 1 / v, REL_TOL_CONSISTENCY);
211
212 DERIV_TEST(_fp->s_from_p_T, p, T, REL_TOL_DERIVATIVE);
213 // Larger perturbations keep the finite differences above cancellation and inversion noise.
214 DERIV_TEST_CUSTOM_PERTURBATION(_fp->s_from_v_e, v, e, REL_TOL_DERIVATIVE, 2e-6);
215 DERIV_TEST_CUSTOM_PERTURBATION(_fp->rho_from_p_s, p, s, REL_TOL_DERIVATIVE, 1e-5);
216}

◆ TEST_F() [10/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
specificInternalEnergy   
)

Test that the specific internal energy and its derivatives are correctly computed.

Definition at line 126 of file SodiumSaturationFluidPropertiesTest.C.

127{
128 const Real T = 800.0;
129 const Real p = 101325;
130
131 ABS_TEST(_fp->e_from_p_T(p, T),
132 _fp->h_from_p_T(p, T) - p * _fp->v_from_p_T(p, T),
133 REL_TOL_SAVED_VALUE);
134 DERIV_TEST(_fp->e_from_p_T, p, T, REL_TOL_DERIVATIVE);
135}

◆ TEST_F() [11/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
temperatureFromPressureEnthalpy   
)

Test inversion of specific enthalpy to temperature.

Definition at line 185 of file SodiumSaturationFluidPropertiesTest.C.

186{
187 const Real p = 5e5;
188 const Real T = 800.0;
189 const Real h = _fp->h_from_p_T(p, T);
190
191 REL_TEST(_fp->T_from_p_h(p, h), T, REL_TOL_CONSISTENCY);
192 DERIV_TEST(_fp->T_from_p_h, p, h, REL_TOL_DERIVATIVE);
193}

◆ TEST_F() [12/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
thermalConductivity   
)

Test that the thermal conductivity and its derivatives are correctly computed.

Definition at line 35 of file SodiumSaturationFluidPropertiesTest.C.

36{
37 const Real T = 800.0;
38 const Real p = 101325;
39
40 // Fink and Leibowitz (1979) list conductivity as 66.8 at 800 K, so the fit agrees well
41 REL_TEST(_fp->k_from_p_T(p, T), 66.9752096, REL_TOL_SAVED_VALUE);
42 DERIV_TEST(_fp->k_from_p_T, p, T, REL_TOL_DERIVATIVE);
43}

◆ TEST_F() [13/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
viscosity   
)

Test that the viscosity and its derivatives are correctly computed.

Definition at line 48 of file SodiumSaturationFluidPropertiesTest.C.

49{
50 const Real T = 800.0;
51 const Real p = 101325;
52
53 // Fink and Leibowitz (1979) list viscosity as 0.000229 at 800 K, so the fit agrees well
54 REL_TEST(_fp->mu_from_p_T(p, T), 0.00022907910937500003, REL_TOL_SAVED_VALUE);
55 DERIV_TEST(_fp->mu_from_p_T, p, T, REL_TOL_DERIVATIVE);
56}

◆ TEST_F() [14/14]

TEST_F ( SodiumSaturationFluidPropertiesTest  ,
volumeEnergyAutomaticDifferentiation   
)

Test automatic differentiation of the (v,e) properties used by compressible-flow applications.

Definition at line 258 of file SodiumSaturationFluidPropertiesTest.C.

259{
260 const Real p = 5e5;
261 const Real T = 800.0;
262 const Real v = _fp->v_from_p_T(p, T);
263 const Real e = _fp->e_from_p_T(p, T);
264 const auto & fp = static_cast<const SinglePhaseFluidProperties &>(*_fp);
265
268 Moose::derivInsert(dv, 0, 1);
269 Moose::derivInsert(dv, 1, 0);
270 Moose::derivInsert(de, 0, 0);
271 Moose::derivInsert(de, 1, 1);
272 const ADReal v_ad(v, dv);
273 const ADReal e_ad(e, de);
274
275 const auto check_ad_derivatives =
276 [](const ADReal & ad_value, Real value, Real dvalue_dv, Real dvalue_de)
277 {
278 EXPECT_DOUBLE_EQ(ad_value.value(), value);
279 EXPECT_DOUBLE_EQ(ad_value.derivatives()[0], dvalue_dv);
280 EXPECT_DOUBLE_EQ(ad_value.derivatives()[1], dvalue_de);
281 };
282
283 Real value;
284 Real dvalue_dv;
285 Real dvalue_de;
286
287 _fp->p_from_v_e(v, e, value, dvalue_dv, dvalue_de);
288 check_ad_derivatives(fp.p_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
289
290 _fp->T_from_v_e(v, e, value, dvalue_dv, dvalue_de);
291 check_ad_derivatives(fp.T_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
292
293 _fp->c_from_v_e(v, e, value, dvalue_dv, dvalue_de);
294 check_ad_derivatives(fp.c_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
295
296 _fp->cp_from_v_e(v, e, value, dvalue_dv, dvalue_de);
297 check_ad_derivatives(fp.cp_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
298
299 _fp->cv_from_v_e(v, e, value, dvalue_dv, dvalue_de);
300 check_ad_derivatives(fp.cv_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
301
302 _fp->mu_from_v_e(v, e, value, dvalue_dv, dvalue_de);
303 check_ad_derivatives(fp.mu_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
304
305 _fp->k_from_v_e(v, e, value, dvalue_dv, dvalue_de);
306 check_ad_derivatives(fp.k_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
307
308 _fp->s_from_v_e(v, e, value, dvalue_dv, dvalue_de);
309 check_ad_derivatives(fp.s_from_v_e(v_ad, e_ad), value, dvalue_dv, dvalue_de);
310}
DualNumber< Real, DNDerivativeType, true > ADReal
SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< MOOSE_AD_MAX_DOFS_PER_ELEM > > DNDerivativeType
Common class for single phase fluid properties.
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)