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  const ADReal T = T_from_v_e(v, e);
104  return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
105 }
106 
107 void
108 HeliumFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
109 {
110  p = p_from_v_e(v, e);
111 
112  Real T, dT_dv, dT_de;
113  T_from_v_e(v, e, T, dT_dv, dT_de);
114 
115  Real val = 48.14 * v - 0.4446 / std::pow(T, 0.2);
116  Real dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * std::pow(T, -0.2) / (val * val);
117 
118  dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
119  dp_de = dp_dT * dT_de;
120 }
121 
122 void
124  const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
125 {
126  p = p_from_v_e(v, e);
127 
128  ADReal T, dT_dv, dT_de;
129  T_from_v_e(v, e, T, dT_dv, dT_de);
130 
131  auto val = 48.14 * v - 0.4446 / std::pow(T, 0.2);
132  auto dp_dT = 1.0e5 / val - 0.4446 * 0.2e5 * std::pow(T, -0.2) / (val * val);
133 
134  dp_dv = -48.14e5 * T / (val * val); // taking advantage of dT_dv = 0.0;
135  dp_de = dp_dT * dT_de;
136 }
137 
138 Real
139 HeliumFluidProperties::p_from_T_v(const Real T, const Real v) const
140 {
141  // Formula taken from p_from_v_e method
142  return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
143 }
144 
145 ADReal
147 {
148  // Formula taken from p_from_v_e method
149  return T / (48.14 * v - 0.4446 / std::pow(T, 0.2)) * 1.0e5;
150 }
151 
152 Real
153 HeliumFluidProperties::e_from_T_v(const Real T, const Real /*v*/) const
154 {
155  // Formula taken from e_from_p_T method
156  return _cv * T;
157 }
158 
159 void
161  const Real T, const Real v, Real & e, Real & de_dT, Real & de_dv) const
162 {
163  e = e_from_T_v(T, v);
164  de_dT = _cv;
165  de_dv = 0;
166 }
167 
168 ADReal
169 HeliumFluidProperties::e_from_T_v(const ADReal & T, const ADReal & /*v*/) const
170 {
171  // Formula taken from e_from_p_T method
172  return _cv * T;
173 }
174 
175 void
177  const ADReal & T, const ADReal & v, ADReal & e, ADReal & de_dT, ADReal & de_dv) const
178 {
179  e = e_from_T_v(T, v);
180  de_dT = _cv;
181  de_dv = 0;
182 }
183 
184 Real
185 HeliumFluidProperties::T_from_v_e(Real /*v*/, Real e) const
186 {
187  return e / _cv;
188 }
189 
190 ADReal
191 HeliumFluidProperties::T_from_v_e(const ADReal & /*v*/, const ADReal & e) const
192 {
193  return e / _cv;
194 }
195 
196 void
197 HeliumFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
198 {
199  T = T_from_v_e(v, e);
200  dT_dv = 0.0;
201  dT_de = 1.0 / _cv;
202 }
203 
204 void
206  const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
207 {
208  T = SinglePhaseFluidProperties::T_from_v_e(v, e);
209  dT_dv = 0.0;
210  dT_de = 1.0 / _cv;
211 }
212 
213 Real
214 HeliumFluidProperties::T_from_p_h(Real /* p */, Real h) const
215 {
216  return h / _cp;
217 }
218 
219 Real
221 {
222  Real p = p_from_v_e(v, e);
223  Real T = T_from_v_e(v, e);
224 
225  Real rho, drho_dp, drho_dT;
226  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
227 
228  Real c2 = -(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT);
229  return std::sqrt(c2);
230 }
231 
232 void
233 HeliumFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
234 {
235  ADReal myv = v;
236  Moose::derivInsert(myv.derivatives(), 0, 1);
237  Moose::derivInsert(myv.derivatives(), 1, 0);
238  ADReal mye = e;
239  Moose::derivInsert(mye.derivatives(), 0, 0);
240  Moose::derivInsert(mye.derivatives(), 1, 1);
241 
242  auto p = SinglePhaseFluidProperties::p_from_v_e(myv, mye);
243  auto T = SinglePhaseFluidProperties::T_from_v_e(myv, mye);
244 
245  ADReal rho, drho_dp, drho_dT;
246  rho_from_p_T(p, T, rho, drho_dp, drho_dT);
247 
248  auto cc = std::sqrt(-(p / rho / rho - _cv / drho_dT) / (_cv * drho_dp / drho_dT));
249  c = cc.value();
250  dc_dv = cc.derivatives()[0];
251  dc_de = cc.derivatives()[1];
252 }
253 
254 Real HeliumFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const { return _cp; }
255 
256 void
257 HeliumFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
258 {
259  cp = cp_from_v_e(v, e);
260  dcp_dv = 0.0;
261  dcp_de = 0.0;
262 }
263 
264 Real HeliumFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const { return _cv; }
265 
266 void
267 HeliumFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
268 {
269  cv = cv_from_v_e(v, e);
270  dcv_dv = 0.0;
271  dcv_de = 0.0;
272 }
273 
274 Real
276 {
277  return 3.674e-7 * std::pow(T_from_v_e(v, e), 0.7);
278 }
279 
280 Real
282 {
283  Real p_in_bar = p_from_v_e(v, e) * 1.0e-5;
284  Real T = T_from_v_e(v, e);
285  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));
286 }
287 
288 Real
290 {
291  Real rho;
292  Real drho_dT;
293  Real drho_dp;
294  rho_from_p_T(pressure, temperature, rho, drho_dp, drho_dT);
295 
296  return -drho_dT / rho;
297 }
298 
299 Real
301 {
302  Real p_in_bar = pressure * 1.0e-5;
303  return 48.14 * p_in_bar / (temperature + 0.4446 * p_in_bar / std::pow(temperature, 0.2));
304 }
305 
306 void
308  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
309 {
311  Real val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2));
312  drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / std::pow(temperature, 0.2));
313  drho_dT =
314  -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / std::pow(temperature, 1.2));
315 }
316 
317 void
319  const ADReal & temperature,
320  ADReal & rho,
321  ADReal & drho_dp,
322  ADReal & drho_dT) const
323 {
324  rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
325  auto val = 1.0 / (temperature + 0.4446e-5 * pressure / std::pow(temperature, 0.2));
326  drho_dp = 48.14e-5 * (val - 0.4446e-5 * pressure * val * val / std::pow(temperature, 0.2));
327  drho_dT =
328  -48.14e-5 * pressure * val * val * (1.0 - 0.08892e-5 * pressure / std::pow(temperature, 1.2));
329 }
330 
331 Real
332 HeliumFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
333 {
334  return _cv * temperature;
335 }
336 
337 void
339  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
340 {
342  de_dp = 0.0;
343  de_dT = _cv;
344 }
345 
346 Real
347 HeliumFluidProperties::h_from_p_T(Real /*pressure*/, Real temperature) const
348 {
349  return _cp * temperature;
350 }
351 
352 void
354  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
355 {
357  dh_dp = 0.0;
358  dh_dT = _cp;
359 }
360 
361 Real
363 {
364  return 4.002602e-3;
365 }
366 
367 Real HeliumFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
368 {
369  return _cp;
370 }
371 
372 void
374  Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
375 {
377  dcp_dp = 0.0;
378  dcp_dT = 0.0;
379 }
380 
381 Real HeliumFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
382 {
383  return _cv;
384 }
385 
386 void
388  Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
389 {
391  dcv_dp = 0.0;
392  dcv_dT = 0.0;
393 }
394 
395 Real
396 HeliumFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
397 {
398  return 3.674e-7 * std::pow(temperature, 0.7);
399 }
400 
401 void
403  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
404 {
406  dmu_dp = 0.0;
407  dmu_dT = 3.674e-7 * 0.7 * std::pow(temperature, -0.3);
408 }
409 
410 Real
412 {
413  return 2.682e-3 * (1.0 + 1.123e-8 * pressure) *
414  std::pow(temperature, 0.71 * (1.0 - 2.0e-9 * pressure));
415 }
416 
417 void
419  Real pressure, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
420 {
422 
423  Real term = 1.0 + 1.123e-8 * pressure;
424  Real exp = 0.71 * (1.0 - 2.0e-9 * pressure);
425 
426  dk_dp = 2.682e-3 * (term * 0.71 * (-2.0e-9) * std::log(temperature) * std::pow(temperature, exp) +
427  std::pow(temperature, exp) * 1.123e-8);
428 
429  dk_dT = 2.682e-3 * term * exp * std::pow(temperature, exp - 1.0);
430 }
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.
void mooseWarning(Args &&... args) const
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.
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
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 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.