https://mooseframework.inl.gov
Loading...
Searching...
No Matches
HeliumFluidProperties.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
11#include "GasTransportUtils.h"
12
14
17{
19 params.addClassDescription("Fluid properties for helium");
20 return params;
21}
22
24 : SinglePhaseFluidProperties(parameters), _cv(3117.0), _cp(5195.0)
25{
26}
27
28std::string
30{
31 return "helium";
32}
33
34Real
36{
37 // Initial guess using ideal gas law
38 Real e = p / (_cp / _cv - 1.) / rho;
39 const Real v = 1. / rho;
40
41 Real p_from_props, dp_dv, dp_de;
42 const unsigned int max_its = 10;
43 unsigned int it = 0;
44
45 do
46 {
47 p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
48 const Real & jacobian = dp_de;
49 const Real residual = p_from_props - p;
50
51 if (std::abs(residual) / p < 1e-12)
52 break;
53
54 const Real delta_e = -residual / jacobian;
55 e += delta_e;
56 } while (++it < max_its);
57
58 if (it >= max_its)
59 mooseWarning("The e_from_p_rho iteration failed to converge");
60
61 return e;
62}
63
66{
67 // Initial guess using ideal gas law
68 ADReal e = p / (_cp / _cv - 1.) / rho;
69 const ADReal v = 1. / rho;
70
71 ADReal p_from_props, dp_dv, dp_de;
72 const unsigned int max_its = 10;
73 unsigned int it = 0;
74
75 do
76 {
77 p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
78 const ADReal & jacobian = dp_de;
79 const ADReal residual = p_from_props - p;
80
81 if (std::abs(residual.value()) / p.value() < 1e-12)
82 break;
83
84 const ADReal delta_e = -residual / jacobian;
85 e += delta_e;
86 } while (++it < max_its);
87
88 if (it >= max_its)
89 mooseWarning("The e_from_p_rho iteration failed to converge");
90
91 return e;
92}
93
94Real
96{
97 Real T = T_from_v_e(v, e);
98 return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
99}
100
101ADReal
103{
104 using std::pow;
105 const ADReal T = T_from_v_e(v, e);
106 return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
107}
108
109void
110HeliumFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
111{
112 p = p_from_v_e(v, e);
113
114 Real T, dT_dv, dT_de;
115 T_from_v_e(v, e, T, dT_dv, dT_de);
116
117 Real val = 48.14 * v - 0.4446 / std::pow(T, 0.2);
118 Real dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * std::pow(T, -0.2) / (val * val);
119
120 dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
121 dp_de = dp_dT * dT_de;
122}
123
124void
126 const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
127{
128 using std::pow;
129 p = p_from_v_e(v, e);
130
131 ADReal T, dT_dv, dT_de;
132 T_from_v_e(v, e, T, dT_dv, dT_de);
133
134 auto val = 48.14 * v - 0.4446 / pow(T, 0.2);
135 auto dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * pow(T, -0.2) / (val * val);
136
137 dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
138 dp_de = dp_dT * dT_de;
139}
140
141Real
142HeliumFluidProperties::p_from_T_v(const Real T, const Real v) const
143{
144 // Formula taken from p_from_v_e method
145 return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
146}
147
148ADReal
150{
151 using std::pow;
152 // Formula taken from p_from_v_e method
153 return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
154}
155
156Real
157HeliumFluidProperties::e_from_T_v(const Real T, const Real /*v*/) const
158{
159 // Formula taken from e_from_p_T method
160 return _cv * T;
161}
162
163void
165 const Real T, const Real v, Real & e, Real & de_dT, Real & de_dv) const
166{
167 e = e_from_T_v(T, v);
168 de_dT = _cv;
169 de_dv = 0;
170}
171
172ADReal
174{
175 // Formula taken from e_from_p_T method
176 return _cv * T;
177}
178
179void
181 const ADReal & T, const ADReal & v, ADReal & e, ADReal & de_dT, ADReal & de_dv) const
182{
183 e = e_from_T_v(T, v);
184 de_dT = _cv;
185 de_dv = 0;
186}
187
188Real
189HeliumFluidProperties::T_from_v_e(Real /*v*/, Real e) const
190{
191 return e / _cv;
192}
193
194ADReal
195HeliumFluidProperties::T_from_v_e(const ADReal & /*v*/, const ADReal & e) const
196{
197 return e / _cv;
198}
199
200void
201HeliumFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
202{
203 T = T_from_v_e(v, e);
204 dT_dv = 0.0;
205 dT_de = 1.0 / _cv;
206}
207
208void
210 const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
211{
212 T = SinglePhaseFluidProperties::T_from_v_e(v, e);
213 dT_dv = 0.0;
214 dT_de = 1.0 / _cv;
215}
216
217Real
218HeliumFluidProperties::T_from_p_h(Real /* p */, Real h) const
219{
220 return h / _cp;
221}
222
223ADReal
224HeliumFluidProperties::T_from_p_h(const ADReal & /* p */, const ADReal & h) const
225{
226 return h / _cp;
227}
228
229Real
231{
232 Real p = p_from_v_e(v, e);
233 Real T = T_from_v_e(v, e);
234
235 Real rho, drho_dp, drho_dT;
236 rho_from_p_T(p, T, rho, drho_dp, drho_dT);
237
238 Real c2 = -(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT);
239 return std::sqrt(c2);
240}
241
242void
243HeliumFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
244{
245 using std::sqrt;
246
247 ADReal myv = v;
248 Moose::derivInsert(myv.derivatives(), 0, 1);
249 Moose::derivInsert(myv.derivatives(), 1, 0);
250 ADReal mye = e;
251 Moose::derivInsert(mye.derivatives(), 0, 0);
252 Moose::derivInsert(mye.derivatives(), 1, 1);
253
254 auto p = SinglePhaseFluidProperties::p_from_v_e(myv, mye);
255 auto T = SinglePhaseFluidProperties::T_from_v_e(myv, mye);
256
257 ADReal rho, drho_dp, drho_dT;
258 rho_from_p_T(p, T, rho, drho_dp, drho_dT);
259
260 auto cc = sqrt(-(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT));
261 c = cc.value();
262 dc_dv = cc.derivatives()[0];
263 dc_de = cc.derivatives()[1];
264}
265
266Real
267HeliumFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const
268{
269 return _cp;
270}
271
272void
273HeliumFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
274{
275 cp = cp_from_v_e(v, e);
276 dcp_dv = 0.0;
277 dcp_de = 0.0;
278}
279
280Real
281HeliumFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const
282{
283 return _cv;
284}
285
286void
287HeliumFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
288{
289 cv = cv_from_v_e(v, e);
290 dcv_dv = 0.0;
291 dcv_de = 0.0;
292}
293
294Real
299
300void
301HeliumFluidProperties::mu_from_v_e(Real v, Real e, Real & mu, Real & dmu_dv, Real & dmu_de) const
302{
303 mu = mu_from_v_e(v, e);
304 // The viscosity is proportional to T^0.7
305 const Real dmu_dT = 0.7 * mu / T_from_v_e(v, e);
306 dmu_dv = 0.0; // dmu_dp = 0, dT_dv is zero
307 dmu_de = dmu_dT / _cv; // dmu_dp = 0
308}
309
310Real
312{
313 Real p_in_bar = p_from_v_e(v, e) * 1.0e-5;
314 Real T = T_from_v_e(v, e);
315 return 2.682e-3 * (1.0 + 1.123e-3 * p_in_bar) * std::pow(T, 0.71 * (1.0 - 2.0e-4 * p_in_bar));
316}
317
318void
319HeliumFluidProperties::k_from_v_e(Real v, Real e, Real & k, Real & dk_dv, Real & dk_de) const
320{
321 Real T = 0., p = 0., dT_dv = 0., dT_de = 0., dp_dv = 0., dp_de = 0.;
322 T_from_v_e(v, e, T, dT_dv, dT_de);
323 p_from_v_e(v, e, p, dp_dv, dp_de);
324
325 // b and d scaled by 1e-5 to account for conversion to bar
326 constexpr Real a = 2.682e-3;
327 constexpr Real b = 1.123e-8;
328 constexpr Real c = 0.71;
329 constexpr Real d = 2.0e-9;
330
331 k = a * (1.0 + b * p) * std::pow(T, c * (1.0 - d * p));
332 Real dk_dT = a * c * (1.0 + b * p) * (1.0 - d * p) * std::pow(T, c * (1.0 - d * p) - 1.0);
333 Real dk_dp = a * std::pow(T, c * (1.0 - d * p)) * (b - c * d * (1 + b * p) * std::log(T));
334
335 dk_dv = dk_dp * dp_dv; // dT_dv is zero
336 dk_de = dk_dT * dT_de + dk_dp * dp_de;
337}
338
339Real
340HeliumFluidProperties::beta_from_p_T(Real pressure, Real temperature) const
341{
342 Real rho;
343 Real drho_dT;
344 Real drho_dp;
345 rho_from_p_T(pressure, temperature, rho, drho_dp, drho_dT);
346
347 return -drho_dT / rho;
348}
349
350Real
351HeliumFluidProperties::rho_from_p_T(Real pressure, Real temperature) const
352{
353 Real p_in_bar = pressure * 1.0e-5;
354 return 48.14 * p_in_bar / (temperature + 0.4446 * p_in_bar / std::pow(temperature, 0.2));
355}
356
357void
359 Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
360{
361 rho = rho_from_p_T(pressure, temperature);
362 Real val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2));
363 drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / std::pow(temperature, 0.2));
364 drho_dT =
365 -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / std::pow(temperature, 1.2));
366}
367
368void
370 const ADReal & temperature,
371 ADReal & rho,
372 ADReal & drho_dp,
373 ADReal & drho_dT) const
374{
375 using std::pow;
376 rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
377 auto val = 1.0 / (temperature + 0.4446e-5 * pressure / pow(temperature, 0.2));
378 drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / pow(temperature, 0.2));
379 drho_dT =
380 -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / pow(temperature, 1.2));
381}
382
383Real
384HeliumFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
385{
386 return _cv * temperature;
387}
388
389void
391 Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
392{
393 e = e_from_p_T(pressure, temperature);
394 de_dp = 0.0;
395 de_dT = _cv;
396}
397
398Real
399HeliumFluidProperties::e_from_v_h(Real /*v*/, Real h) const
400{
401 return _cv * (h / _cp);
402}
403
404void
405HeliumFluidProperties::e_from_v_h(Real v, Real h, Real & e, Real & de_dv, Real & de_dh) const
406{
407 e = e_from_v_h(v, h);
408 de_dv = 0.;
409 de_dh = _cv / _cp;
410}
411
412Real
413HeliumFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
414{
415 return _cp * temperature;
416}
417
418void
420 Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
421{
422 h = h_from_p_T(pressure, temperature);
423 dh_dp = 0.0;
424 dh_dT = _cp;
425}
426
427void
429 const ADReal & temperature,
430 ADReal & h,
431 ADReal & dh_dp,
432 ADReal & dh_dT) const
433{
434 h = _cp * temperature;
435 dh_dp = 0.0;
436 dh_dT = _cp;
437}
438
439Real
441{
442 return 4.002602e-3;
443}
444
445Real
446HeliumFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
447{
448 return _cp;
449}
450
451void
453 Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
454{
455 cp = cp_from_p_T(pressure, temperature);
456 dcp_dp = 0.0;
457 dcp_dT = 0.0;
458}
459
460Real
461HeliumFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
462{
463 return _cv;
464}
465
466void
468 Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
469{
470 cv = cv_from_p_T(pressure, temperature);
471 dcv_dp = 0.0;
472 dcv_dT = 0.0;
473}
474
475Real
476HeliumFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
477{
478 return GasTransportUtils::heliumViscosity(temperature);
479}
480
481void
483 Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
484{
485 mu = mu_from_p_T(pressure, temperature);
486 dmu_dp = 0.0;
487 // The viscosity is proportional to T^0.7
488 dmu_dT = 0.7 * mu / temperature;
489}
490
491Real
492HeliumFluidProperties::k_from_p_T(Real pressure, Real temperature) const
493{
494 return 2.682e-3 * (1.0 + 1.123e-8 * pressure) *
495 std::pow(temperature, 0.71 * (1.0 - 2.0e-9 * pressure));
496}
497
498void
500 Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
501{
502 k = k_from_p_T(pressure, temperature);
503
504 Real term = 1.0 + 1.123e-8 * pressure;
505 Real exp = 0.71 * (1.0 - 2.0e-9 * pressure);
506
507 dk_dp = 2.682e-3 * (term * 0.71 * (-2.0e-9) * std::log(temperature) * std::pow(temperature, exp) +
508 std::pow(temperature, exp) * 1.123e-8);
509
510 dk_dT = 2.682e-3 * term * exp * std::pow(temperature, exp - 1.0);
511}
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
const Real p
const double rho
const double T
const double v
registerMooseObject("FluidPropertiesApp", HeliumFluidProperties)
Fluid properties for helium .
Real e_from_p_rho(Real p, Real rho) const override
virtual Real cp_from_v_e(Real v, Real e) const override
Isobaric specific heat from specific volume and specific internal energy.
const Real _cv
specific heat at constant volume
virtual Real molarMass() const override
Molar mass.
virtual Real k_from_p_T(Real p, Real T) const override
Thermal conductivity from pressure and temperature.
virtual Real c_from_v_e(Real v, Real e) const override
Speed of sound from specific volume and specific internal energy.
virtual Real e_from_p_T(Real p, Real T) const override
Specific internal energy from pressure and temperature.
virtual Real beta_from_p_T(Real p, Real T) const override
Thermal expansion coefficient from pressure and temperature.
virtual Real h_from_p_T(Real p, Real T) const override
Specific enthalpy from pressure and temperature.
virtual Real mu_from_p_T(Real p, Real T) const override
Dynamic viscosity from pressure and temperature.
virtual Real cv_from_v_e(Real v, Real e) const override
Isochoric specific heat from specific volume and specific internal energy.
virtual Real cv_from_p_T(Real p, Real T) const override
Isochoric specific heat capacity from pressure and temperature.
Real e_from_T_v(Real T, Real) const override
virtual Real k_from_v_e(Real v, Real e) const override
Thermal conductivity from specific volume and specific internal energy.
virtual Real cp_from_p_T(Real p, Real T) const override
Isobaric specific heat capacity from pressure and temperature.
HeliumFluidProperties(const InputParameters &parameters)
virtual Real T_from_p_h(Real p, Real h) const override
Temperature from pressure and specific enthalpy.
virtual Real e_from_v_h(Real v, Real h) const override
Specific internal energy from specific volume and specific enthalpy.
const Real _cp
specific heat at constant pressure
virtual Real T_from_v_e(Real v, Real e) const override
Temperature from specific volume and specific internal energy.
virtual Real rho_from_p_T(Real p, Real T) const override
Density from pressure and temperature.
static InputParameters validParams()
virtual Real p_from_v_e(Real v, Real e) const override
Pressure from specific volume and specific internal energy.
virtual Real mu_from_v_e(Real v, Real e) const override
Dynamic viscosity from specific volume and specific internal energy.
virtual std::string fluidName() const override
Fluid name.
Real p_from_T_v(Real T, Real v) const override
void addClassDescription(const std::string &doc_string)
void mooseWarning(Args &&... args) const
Common class for single phase fluid properties.
static InputParameters validParams()
e e e e s T T T T T rho v v T e h
CppType heliumViscosity(const CppType &T)
Viscosity of helium [Pa s], from the correlation of Petersen (1970), as in HeliumFluidProperties.
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N > > &derivs, libMesh::dof_id_type index, Real value)