https://mooseframework.inl.gov
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 
10 #include "HeliumFluidProperties.h"
11 
12 registerMooseObject("FluidPropertiesApp", HeliumFluidProperties);
13 
16 {
18  params.addClassDescription("Fluid properties for helium");
19  return params;
20 }
21 
23  : SinglePhaseFluidProperties(parameters), _cv(3117.0), _cp(5195.0)
24 {
25 }
26 
27 std::string
29 {
30  return "helium";
31 }
32 
33 Real
34 HeliumFluidProperties::e_from_p_rho(Real p, Real rho) const
35 {
36  // Initial guess using ideal gas law
37  Real e = p / (_cp / _cv - 1.) / rho;
38  const Real v = 1. / rho;
39 
40  Real p_from_props, dp_dv, dp_de;
41  const unsigned int max_its = 10;
42  unsigned int it = 0;
43 
44  do
45  {
46  p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
47  const Real & jacobian = dp_de;
48  const Real residual = p_from_props - p;
49 
50  if (std::abs(residual) / p < 1e-12)
51  break;
52 
53  const Real delta_e = -residual / jacobian;
54  e += delta_e;
55  } while (++it < max_its);
56 
57  if (it >= max_its)
58  mooseWarning("The e_from_p_rho iteration failed to converge");
59 
60  return e;
61 }
62 
63 ADReal
64 HeliumFluidProperties::e_from_p_rho(const ADReal & p, const ADReal & rho) const
65 {
66  // Initial guess using ideal gas law
67  ADReal e = p / (_cp / _cv - 1.) / rho;
68  const ADReal v = 1. / rho;
69 
70  ADReal p_from_props, dp_dv, dp_de;
71  const unsigned int max_its = 10;
72  unsigned int it = 0;
73 
74  do
75  {
76  p_from_v_e(v, e, p_from_props, dp_dv, dp_de);
77  const ADReal & jacobian = dp_de;
78  const ADReal residual = p_from_props - p;
79 
80  if (std::abs(residual.value()) / p.value() < 1e-12)
81  break;
82 
83  const ADReal delta_e = -residual / jacobian;
84  e += delta_e;
85  } while (++it < max_its);
86 
87  if (it >= max_its)
88  mooseWarning("The e_from_p_rho iteration failed to converge");
89 
90  return e;
91 }
92 
93 Real
95 {
96  Real T = T_from_v_e(v, e);
97  return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
98 }
99 
100 ADReal
102 {
103  using std::pow;
104  const ADReal T = T_from_v_e(v, e);
105  return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
106 }
107 
108 void
109 HeliumFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
110 {
111  p = p_from_v_e(v, e);
112 
113  Real T, dT_dv, dT_de;
114  T_from_v_e(v, e, T, dT_dv, dT_de);
115 
116  Real val = 48.14 * v - 0.4446 / std::pow(T, 0.2);
117  Real dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * std::pow(T, -0.2) / (val * val);
118 
119  dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
120  dp_de = dp_dT * dT_de;
121 }
122 
123 void
125  const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
126 {
127  using std::pow;
128  p = p_from_v_e(v, e);
129 
130  ADReal T, dT_dv, dT_de;
131  T_from_v_e(v, e, T, dT_dv, dT_de);
132 
133  auto val = 48.14 * v - 0.4446 / pow(T, 0.2);
134  auto dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * pow(T, -0.2) / (val * val);
135 
136  dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
137  dp_de = dp_dT * dT_de;
138 }
139 
140 Real
141 HeliumFluidProperties::p_from_T_v(const Real T, const Real v) const
142 {
143  // Formula taken from p_from_v_e method
144  return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
145 }
146 
147 ADReal
149 {
150  using std::pow;
151  // Formula taken from p_from_v_e method
152  return T / (48.14 * v - 0.4446 / pow(T, 0.2)) * 1.0e5;
153 }
154 
155 Real
156 HeliumFluidProperties::e_from_T_v(const Real T, const Real /*v*/) const
157 {
158  // Formula taken from e_from_p_T method
159  return _cv * T;
160 }
161 
162 void
164  const Real T, const Real v, Real & e, Real & de_dT, Real & de_dv) const
165 {
166  e = e_from_T_v(T, v);
167  de_dT = _cv;
168  de_dv = 0;
169 }
170 
171 ADReal
172 HeliumFluidProperties::e_from_T_v(const ADReal & T, const ADReal & /*v*/) const
173 {
174  // Formula taken from e_from_p_T method
175  return _cv * T;
176 }
177 
178 void
180  const ADReal & T, const ADReal & v, ADReal & e, ADReal & de_dT, ADReal & de_dv) const
181 {
182  e = e_from_T_v(T, v);
183  de_dT = _cv;
184  de_dv = 0;
185 }
186 
187 Real
188 HeliumFluidProperties::T_from_v_e(Real /*v*/, Real e) const
189 {
190  return e / _cv;
191 }
192 
193 ADReal
194 HeliumFluidProperties::T_from_v_e(const ADReal & /*v*/, const ADReal & e) const
195 {
196  return e / _cv;
197 }
198 
199 void
200 HeliumFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
201 {
202  T = T_from_v_e(v, e);
203  dT_dv = 0.0;
204  dT_de = 1.0 / _cv;
205 }
206 
207 void
209  const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
210 {
211  T = SinglePhaseFluidProperties::T_from_v_e(v, e);
212  dT_dv = 0.0;
213  dT_de = 1.0 / _cv;
214 }
215 
216 Real
217 HeliumFluidProperties::T_from_p_h(Real /* p */, Real h) const
218 {
219  return h / _cp;
220 }
221 
222 ADReal
223 HeliumFluidProperties::T_from_p_h(const ADReal & /* p */, const ADReal & h) const
224 {
225  return h / _cp;
226 }
227 
228 Real
230 {
231  Real p = p_from_v_e(v, e);
232  Real T = T_from_v_e(v, e);
233 
234  Real rho, drho_dp, drho_dT;
235  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
236 
237  Real c2 = -(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT);
238  return std::sqrt(c2);
239 }
240 
241 void
242 HeliumFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
243 {
244  using std::sqrt;
245 
246  ADReal myv = v;
247  Moose::derivInsert(myv.derivatives(), 0, 1);
248  Moose::derivInsert(myv.derivatives(), 1, 0);
249  ADReal mye = e;
250  Moose::derivInsert(mye.derivatives(), 0, 0);
251  Moose::derivInsert(mye.derivatives(), 1, 1);
252 
253  auto p = SinglePhaseFluidProperties::p_from_v_e(myv, mye);
254  auto T = SinglePhaseFluidProperties::T_from_v_e(myv, mye);
255 
256  ADReal rho, drho_dp, drho_dT;
257  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
258 
259  auto cc = sqrt(-(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT));
260  c = cc.value();
261  dc_dv = cc.derivatives()[0];
262  dc_de = cc.derivatives()[1];
263 }
264 
265 Real
266 HeliumFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const
267 {
268  return _cp;
269 }
270 
271 void
272 HeliumFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
273 {
274  cp = cp_from_v_e(v, e);
275  dcp_dv = 0.0;
276  dcp_de = 0.0;
277 }
278 
279 Real
280 HeliumFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const
281 {
282  return _cv;
283 }
284 
285 void
286 HeliumFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
287 {
288  cv = cv_from_v_e(v, e);
289  dcv_dv = 0.0;
290  dcv_de = 0.0;
291 }
292 
293 Real
295 {
296  return 3.674e-7 * std::pow(T_from_v_e(v, e), 0.7);
297 }
298 
299 Real
301 {
302  Real p_in_bar = p_from_v_e(v, e) * 1.0e-5;
303  Real T = T_from_v_e(v, e);
304  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));
305 }
306 
307 Real
309 {
310  Real rho;
311  Real drho_dT;
312  Real drho_dp;
313  rho_from_p_T(pressure, temperature, rho, drho_dp, drho_dT);
314 
315  return -drho_dT / rho;
316 }
317 
318 Real
320 {
321  Real p_in_bar = pressure * 1.0e-5;
322  return 48.14 * p_in_bar / (temperature + 0.4446 * p_in_bar / std::pow(temperature, 0.2));
323 }
324 
325 void
327  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
328 {
330  Real val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2));
331  drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / std::pow(temperature, 0.2));
332  drho_dT =
333  -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / std::pow(temperature, 1.2));
334 }
335 
336 void
338  const ADReal & temperature,
339  ADReal & rho,
340  ADReal & drho_dp,
341  ADReal & drho_dT) const
342 {
343  using std::pow;
344  rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
345  auto val = 1.0 / (temperature + 0.4446e-5 * pressure / pow(temperature, 0.2));
346  drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / pow(temperature, 0.2));
347  drho_dT =
348  -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / pow(temperature, 1.2));
349 }
350 
351 Real
352 HeliumFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
353 {
354  return _cv * temperature;
355 }
356 
357 void
359  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
360 {
362  de_dp = 0.0;
363  de_dT = _cv;
364 }
365 
366 Real
367 HeliumFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
368 {
369  return _cp * temperature;
370 }
371 
372 void
374  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
375 {
377  dh_dp = 0.0;
378  dh_dT = _cp;
379 }
380 
381 Real
383 {
384  return 4.002602e-3;
385 }
386 
387 Real
388 HeliumFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
389 {
390  return _cp;
391 }
392 
393 void
395  Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
396 {
398  dcp_dp = 0.0;
399  dcp_dT = 0.0;
400 }
401 
402 Real
403 HeliumFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
404 {
405  return _cv;
406 }
407 
408 void
410  Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
411 {
413  dcv_dp = 0.0;
414  dcv_dT = 0.0;
415 }
416 
417 Real
418 HeliumFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
419 {
420  return 3.674e-7 * std::pow(temperature, 0.7);
421 }
422 
423 void
425  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
426 {
428  dmu_dp = 0.0;
429  dmu_dT = 3.674e-7 * 0.7 * std::pow(temperature, -0.3);
430 }
431 
432 Real
434 {
435  return 2.682e-3 * (1.0 + 1.123e-8 * pressure) *
436  std::pow(temperature, 0.71 * (1.0 - 2.0e-9 * pressure));
437 }
438 
439 void
441  Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
442 {
444 
445  Real term = 1.0 + 1.123e-8 * pressure;
446  Real exp = 0.71 * (1.0 - 2.0e-9 * pressure);
447 
448  dk_dp = 2.682e-3 * (term * 0.71 * (-2.0e-9) * std::log(temperature) * std::pow(temperature, exp) +
449  std::pow(temperature, exp) * 1.123e-8);
450 
451  dk_dT = 2.682e-3 * term * exp * std::pow(temperature, exp - 1.0);
452 }
Fluid properties for helium .
virtual Real molarMass() const override
Molar mass.
static const std::string cv
Definition: NS.h:122
virtual Real rho_from_p_T(Real p, Real T) const override
Density from pressure and temperature.
auto exp(const T &)
virtual Real p_from_v_e(Real v, Real e) const override
Pressure from specific volume and specific internal energy.
virtual Real T_from_p_h(Real p, Real h) const override
Temperature from pressure and specific enthalpy.
static InputParameters validParams()
const Real _cp
specific heat at constant pressure
virtual Real cv_from_v_e(Real v, Real e) const override
Isochoric specific heat from specific volume and specific internal energy.
virtual Real k_from_v_e(Real v, Real e) const override
Thermal conductivity from specific volume and specific internal energy.
registerMooseObject("FluidPropertiesApp", HeliumFluidProperties)
const Real _cv
specific heat at constant volume
static const std::string temperature
Definition: NS.h:59
virtual Real cp_from_v_e(Real v, Real e) const override
Isobaric specific heat from specific volume and specific internal energy.
Real e_from_T_v(Real T, Real) const override
DualNumber< Real, DNDerivativeType, true > ADReal
Real p_from_T_v(Real T, Real v) const override
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.
HeliumFluidProperties(const InputParameters &parameters)
static const std::string cp
Definition: NS.h:121
e e e e s T T T T T rho v v T e h
virtual Real mu_from_p_T(Real p, Real T) const override
Dynamic viscosity from pressure and temperature.
virtual Real mu_from_v_e(Real v, Real e) const override
Dynamic viscosity from specific volume and specific internal energy.
static const std::string mu
Definition: NS.h:123
Real e_from_p_rho(Real p, Real rho) const override
virtual Real cv_from_p_T(Real p, Real T) const override
Isochoric specific heat capacity from pressure and temperature.
Common class for single phase fluid properties.
virtual Real c_from_v_e(Real v, Real e) const override
Speed of sound from specific volume and specific internal energy.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual Real T_from_v_e(Real v, Real e) const override
Temperature from specific volume and specific internal energy.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
virtual Real h_from_p_T(Real p, Real T) const override
Specific enthalpy from pressure and temperature.
virtual Real cp_from_p_T(Real p, Real T) const override
Isobaric specific heat capacity from pressure and temperature.
static const std::string pressure
Definition: NS.h:56
void mooseWarning(Args &&... args) const
void addClassDescription(const std::string &doc_string)
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
virtual Real k_from_p_T(Real p, Real T) const override
Thermal conductivity from pressure and temperature.
MooseUnits pow(const MooseUnits &, int)
static const std::string k
Definition: NS.h:130
static InputParameters validParams()
virtual std::string fluidName() const override
Fluid name.