https://mooseframework.inl.gov
SimpleFluidProperties.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 "SimpleFluidProperties.h"
11 #include "NewtonInversion.h"
12 
13 registerMooseObject("FluidPropertiesApp", SimpleFluidProperties);
14 
17 {
19  params.addParam<Real>("molar_mass", 1.8E-2, "Constant molar mass of the fluid (kg/mol)");
20  params.addParam<Real>(
21  "thermal_expansion", 2.14E-4, "Constant coefficient of thermal expansion (1/K)");
22  params.addParam<Real>(
23  "cv", 4186.0, "Constant specific heat capacity at constant volume (J/kg/K)");
24  params.addParam<Real>(
25  "cp", 4194.0, "Constant specific heat capacity at constant pressure (J/kg/K)");
26  params.addRangeCheckedParam<Real>(
27  "bulk_modulus", 2.0E9, "bulk_modulus>0", "Constant bulk modulus (Pa)");
28  params.addParam<Real>("thermal_conductivity", 0.6, "Constant thermal conductivity (W/m/K)");
29  params.addParam<Real>("specific_entropy", 300.0, "Constant specific entropy (J/kg/K)");
30  params.addParam<Real>("viscosity", 1.0E-3, "Constant dynamic viscosity (Pa.s)");
31  params.addParam<Real>("density0", 1000.0, "Density at zero pressure and zero temperature");
32  params.addParam<Real>("porepressure_coefficient",
33  1.0,
34  "The enthalpy is internal_energy + P / density * "
35  "porepressure_coefficient. Physically this should be 1.0, "
36  "but analytic solutions are simplified when it is zero");
37  params.addClassDescription("Fluid properties for a simple fluid with a constant bulk density");
38  return params;
39 }
40 
42  : SinglePhaseFluidProperties(parameters),
43  _molar_mass(getParam<Real>("molar_mass")),
44  _thermal_expansion(getParam<Real>("thermal_expansion")),
45  _cv(getParam<Real>("cv")),
46  _cp(getParam<Real>("cp")),
47  _bulk_modulus(getParam<Real>("bulk_modulus")),
48  _thermal_conductivity(getParam<Real>("thermal_conductivity")),
49  _specific_entropy(getParam<Real>("specific_entropy")),
50  _viscosity(getParam<Real>("viscosity")),
51  _density0(getParam<Real>("density0")),
52  _pp_coeff(getParam<Real>("porepressure_coefficient"))
53 {
54 }
55 
57 
58 std::string
60 {
61  return "simple_fluid";
62 }
63 
64 Real
66 {
67  return _molar_mass;
68 }
69 
70 Real
71 SimpleFluidProperties::beta_from_p_T(Real /*pressure*/, Real /*temperature*/) const
72 {
73  return _thermal_expansion;
74 }
75 
76 void
78  Real pressure, Real temperature, Real & beta, Real & dbeta_dp, Real & dbeta_dT) const
79 {
81  dbeta_dp = 0.0;
82  dbeta_dT = 0.0;
83 }
84 
85 Real
86 SimpleFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
87 {
88  return _cp;
89 }
90 
91 void
93  Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
94 {
96  dcp_dp = 0.0;
97  dcp_dT = 0.0;
98 }
99 
100 Real
101 SimpleFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const
102 {
103  return _cp;
104 }
105 
106 void
107 SimpleFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
108 {
109  cp = cp_from_v_e(v, e);
110  dcp_dv = 0.0;
111  dcp_de = 0.0;
112 }
113 
114 Real
115 SimpleFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
116 {
117  return _cv;
118 }
119 
120 void
122  Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
123 {
125  dcv_dp = 0.0;
126  dcv_dT = 0.0;
127 }
128 
129 Real
130 SimpleFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const
131 {
132  return _cv;
133 }
134 
135 void
136 SimpleFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
137 {
138  cv = cv_from_v_e(v, e);
139  dcv_dv = 0.0;
140  dcv_de = 0.0;
141 }
142 
143 Real
145 {
146  return std::sqrt(_bulk_modulus / rho_from_p_T(pressure, temperature));
147 }
148 
149 void
151  Real pressure, Real temperature, Real & c, Real & dc_dp, Real & dc_dT) const
152 {
154  dc_dp =
156  std::sqrt(_bulk_modulus *
158  dc_dT =
161  std::sqrt(_bulk_modulus *
163 }
164 
165 Real
166 SimpleFluidProperties::c_from_v_e(Real v, Real /*e*/) const
167 {
168  return std::sqrt(_bulk_modulus * v);
169 }
170 
171 void
172 SimpleFluidProperties::c_from_v_e(Real v, Real /*e*/, Real & c, Real & dc_dv, Real & dc_de) const
173 {
174  c = std::sqrt(_bulk_modulus * v);
175 
176  dc_dv = 0.5 * std::sqrt(_bulk_modulus / v);
177  dc_de = 0.0;
178 }
179 
180 Real
181 SimpleFluidProperties::k_from_p_T(Real /*pressure*/, Real /*temperature*/) const
182 {
183  return _thermal_conductivity;
184 }
185 
186 void
188  Real /*pressure*/, Real /*temperature*/, Real & k, Real & dk_dp, Real & dk_dT) const
189 {
191  dk_dp = 0;
192  dk_dT = 0;
193 }
194 
195 Real
196 SimpleFluidProperties::k_from_v_e(Real /*v*/, Real /*e*/) const
197 {
198  return _thermal_conductivity;
199 }
200 
201 void
203  Real /*v*/, Real /*e*/, Real & k, Real & dk_dv, Real & dk_de) const
204 {
206  dk_dv = 0;
207  dk_de = 0;
208 }
209 
210 Real
211 SimpleFluidProperties::s_from_p_T(Real /*pressure*/, Real /*temperature*/) const
212 {
213  return _specific_entropy;
214 }
215 
216 void
218  Real /*p*/, Real /*T*/, Real & s, Real & ds_dp, Real & ds_dT) const
219 {
220  s = _specific_entropy;
221  ds_dp = 0;
222  ds_dT = 0;
223 }
224 
225 Real
226 SimpleFluidProperties::s_from_h_p(Real /*enthalpy*/, Real /*pressure*/) const
227 {
228  return _specific_entropy;
229 }
230 
231 Real
232 SimpleFluidProperties::s_from_v_e(Real /*v*/, Real /*e*/) const
233 {
234  return _specific_entropy;
235 }
236 
237 void
239  Real /*v*/, Real /*e*/, Real & s, Real & ds_dv, Real & ds_de) const
240 {
241  s = _specific_entropy;
242  ds_dv = 0;
243  ds_de = 0;
244 }
245 
246 Real
248 {
250 }
251 
252 void
254  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
255 {
256  rho = this->rho_from_p_T(pressure, temperature);
257  drho_dp = rho / _bulk_modulus;
258  drho_dT = -_thermal_expansion * rho;
259 }
260 
261 void
263  const ADReal & temperature,
264  ADReal & rho,
265  ADReal & drho_dp,
266  ADReal & drho_dT) const
267 {
268  rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
269  drho_dp = rho / _bulk_modulus;
270  drho_dT = -_thermal_expansion * rho;
271 }
272 
273 Real
274 SimpleFluidProperties::T_from_v_e(Real /*v*/, Real e) const
275 {
276  // NOTE: while e = _cv * T, h is not equal to _cp * T
277  return e / _cv;
278 }
279 
280 Real
282 {
283  return (std::log(1. / _density0 / v) - h / v / _bulk_modulus) / -_thermal_expansion /
285 }
286 
287 void
288 SimpleFluidProperties::T_from_v_h(Real v, Real h, Real & T, Real & dT_dv, Real & dT_dh) const
289 {
290  T = T_from_v_h(v, h);
291  dT_dv =
292  (1 / -_thermal_expansion) *
293  ((-1. / v + h / v / v / _bulk_modulus) * (1 + _cv / v / _thermal_expansion / _bulk_modulus) -
294  (std::log(1. / _density0 / v) - h / v / _bulk_modulus) *
295  (-_cv / v / v / _thermal_expansion / _bulk_modulus)) /
296  Utility::pow<2>(1 + _cv / v / _thermal_expansion / _bulk_modulus);
297  dT_dh = (-1 / v / _bulk_modulus) / -_thermal_expansion /
299 }
300 
301 void
302 SimpleFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
303 {
304  T = T_from_v_e(v, e);
305  dT_dv = 0.0;
306  dT_de = 1.0 / _cv;
307 }
308 
309 void
311  const ADReal & v, const ADReal & e, ADReal & T, ADReal & dT_dv, ADReal & dT_de) const
312 {
313  T = SinglePhaseFluidProperties::T_from_v_e(v, e);
314  dT_dv = 0.0;
315  dT_de = 1.0 / _cv;
316 }
317 
318 Real
319 SimpleFluidProperties::T_from_p_rho(Real p, Real rho) const
320 {
321  mooseAssert(rho > 0, "Density should be positive");
322  return (std::log(rho / _density0) - p / _bulk_modulus) / -_thermal_expansion;
323 }
324 
325 void
326 SimpleFluidProperties::T_from_p_rho(Real p, Real rho, Real & T, Real & dT_dp, Real & dT_drho) const
327 {
328  T = T_from_p_rho(p, rho);
329  dT_dp = 1 / (_thermal_expansion * _bulk_modulus);
330  dT_drho = 1 / (-_thermal_expansion * rho);
331 }
332 
333 Real
335 {
336  // Likely a better guess than user-selected
337  Real T_initial = h / _cp;
338 
339  // exponential dependence in rho and linear dependence in e makes it challenging
340  auto lambda = [&](Real p, Real current_T, Real & new_rho, Real & dh_dp, Real & dh_dT)
341  { h_from_p_T(p, current_T, new_rho, dh_dp, dh_dT); };
343  p, h, T_initial, _tolerance, lambda, name() + "::T_from_p_h", _max_newton_its)
344  .first;
345 }
346 
347 Real
349 {
351  return _bulk_modulus * (_thermal_expansion * temperature + std::log(1 / (v * _density0)));
352 }
353 
354 void
355 SimpleFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
356 {
357  p = p_from_v_e(v, e);
358  dp_dv = -_bulk_modulus / v;
360 }
361 
362 void
364  const ADReal & v, const ADReal & e, ADReal & p, ADReal & dp_dv, ADReal & dp_de) const
365 {
366  p = SinglePhaseFluidProperties::p_from_v_e(v, e);
367  dp_dv = -_bulk_modulus / v;
369 }
370 
371 Real
373 {
374  Real T = T_from_v_h(v, h);
375  return _bulk_modulus * (_thermal_expansion * T + std::log(1 / (v * _density0)));
376 }
377 
378 void
379 SimpleFluidProperties::p_from_v_h(Real v, Real h, Real & p, Real & dp_dv, Real & dp_dh) const
380 {
381  Real T, dT_dv, dT_dh;
382  T_from_v_h(v, h, T, dT_dv, dT_dh);
383  p = _bulk_modulus * (_thermal_expansion * T + std::log(1 / (v * _density0)));
384  dp_dv = _bulk_modulus * (_thermal_expansion * dT_dv - 1. / v);
385  dp_dh = _bulk_modulus * (_thermal_expansion * dT_dh);
386 }
387 
388 Real
389 SimpleFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
390 {
391  return _cv * temperature;
392 }
393 
394 void
396  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
397 {
398  e = this->e_from_p_T(pressure, temperature);
399  de_dp = 0.0;
400  de_dT = _cv;
401 }
402 
403 Real
404 SimpleFluidProperties::e_from_p_rho(Real p, Real rho) const
405 {
406  Real T = T_from_p_rho(p, rho);
407  return e_from_p_T(p, T);
408 }
409 
410 void
411 SimpleFluidProperties::e_from_p_rho(Real p, Real rho, Real & e, Real & de_dp, Real & de_drho) const
412 {
413  // get temperature and derivatives
414  Real T, dT_dp, dT_drho;
415  T_from_p_rho(p, rho, T, dT_dp, dT_drho);
416 
417  // get energy and derivatives
418  Real de_dT;
419  e_from_p_T(p, T, e, de_dp, de_dT);
420  de_dp = de_dT * dT_dp + de_dp;
421  de_drho = de_dT * dT_drho + de_dp * dT_dp;
422 }
423 
424 Real
426 {
427  Real T = T_from_v_h(v, h);
428  Real p = p_from_v_h(v, h);
429  return e_from_p_T(p, T);
430 }
431 
432 void
433 SimpleFluidProperties::e_from_v_h(Real v, Real h, Real & e, Real & de_dv, Real & de_dh) const
434 {
435  Real T, dT_dv, dT_dh;
436  Real p, dp_dv, dp_dh;
437  T_from_v_h(v, h, T, dT_dv, dT_dh);
438  p_from_v_h(v, h, p, dp_dv, dp_dh);
439 
440  Real de_dp, de_dT;
441  e_from_p_T(p, T, e, de_dp, de_dT);
442  de_dv = de_dp * dp_dv + de_dT * dT_dv;
443  de_dh = de_dp * dp_dh + de_dT * dT_dh;
444 }
445 
446 Real
447 SimpleFluidProperties::mu_from_p_T(Real /*pressure*/, Real /*temperature*/) const
448 {
449  return _viscosity;
450 }
451 
452 void
454  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
455 {
456  mu = this->mu_from_p_T(pressure, temperature);
457  dmu_dp = 0.0;
458  dmu_dT = 0.0;
459 }
460 
461 Real
462 SimpleFluidProperties::mu_from_v_e(Real /*v*/, Real /*e*/) const
463 {
464  return _viscosity;
465 }
466 
467 void
468 SimpleFluidProperties::mu_from_v_e(Real v, Real e, Real & mu, Real & dmu_dv, Real & dmu_de) const
469 {
470  mu = this->mu_from_v_e(v, e);
471  dmu_dv = 0.0;
472  dmu_de = 0.0;
473 }
474 
475 Real
477 {
478  return e_from_p_T(pressure, temperature) +
480 }
481 
482 void
484  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
485 {
486  h = this->h_from_p_T(pressure, temperature);
487 
488  Real density, ddensity_dp, ddensity_dT;
489  rho_from_p_T(pressure, temperature, density, ddensity_dp, ddensity_dT);
490 
491  dh_dp = _pp_coeff / density - _pp_coeff * pressure * ddensity_dp / density / density;
492  dh_dT = _cv - _pp_coeff * pressure * ddensity_dT / density / density;
493 }
const Real _thermal_expansion
thermal expansion coefficient
virtual Real k_from_v_e(Real v, Real e) const override
const Real _pp_coeff
Porepressure coefficient: enthalpy = internal_energy + porepressure / density * _pp_coeff.
static const std::string cv
Definition: NS.h:122
virtual Real c_from_v_e(Real v, Real e) const override
virtual Real cv_from_v_e(Real v, Real e) const override
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real h_from_p_T(Real p, Real T) const override
static InputParameters validParams()
const Real _cv
specific heat at constant volume
const Real _specific_entropy
specific entropy
const Real _viscosity
viscosity
virtual Real mu_from_v_e(Real v, Real e) const override
virtual Real c_from_p_T(Real pressure, Real temperature) const override
const Real _bulk_modulus
bulk modulus
static const std::string density
Definition: NS.h:33
virtual Real cp_from_p_T(Real pressure, Real temperature) const override
static const std::string temperature
Definition: NS.h:59
virtual Real s_from_h_p(Real h, Real p) const override
DualNumber< Real, DNDerivativeType, true > ADReal
const Real _molar_mass
molar mass
virtual const std::string & name() const
Fluid properties of a simple, idealised fluid density=density0 * exp(P / bulk_modulus - thermal_expan...
std::pair< T, T > NewtonSolve(const T &x, const T &y, const Real z_initial_guess, const Real tolerance, const Functor &func, const std::string &caller_name, const unsigned int max_its=100)
NewtonSolve does a 1D Newton Solve to solve the equation y = f(x, z) for variable z...
const Real _density0
density at zero pressure and temperature
virtual std::string fluidName() const override
Fluid name.
virtual Real e_from_p_rho(Real pressure, Real rho) const override
static const std::string cp
Definition: NS.h:121
const Real _tolerance
Newton&#39;s method may be used to convert between variable sets.
virtual Real s_from_v_e(Real v, Real e) const override
const Real _thermal_conductivity
thermal conductivity
e e e e s T T T T T rho v v T e h
virtual Real s_from_p_T(Real pressure, Real temperature) const override
virtual Real e_from_p_T(Real pressure, Real temperature) const override
static InputParameters validParams()
virtual Real T_from_p_h(Real p, Real h) const override
static const std::string mu
Definition: NS.h:123
virtual Real mu_from_p_T(Real pressure, Real temperature) const override
virtual Real beta_from_p_T(Real pressure, Real temperature) const override
virtual Real T_from_v_h(Real v, Real h) const
virtual Real e_from_v_h(Real v, Real h) const override
Common class for single phase fluid properties.
virtual Real T_from_v_e(Real v, Real e) const override
registerMooseObject("FluidPropertiesApp", SimpleFluidProperties)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
virtual Real T_from_p_rho(Real p, Real rho) const
const unsigned int _max_newton_its
Maximum number of iterations for the variable conversion newton solves.
virtual Real rho_from_p_T(Real pressure, Real temperature) const override
static const std::string pressure
Definition: NS.h:56
virtual Real cp_from_v_e(Real v, Real e) const override
virtual Real p_from_v_h(Real v, Real h) const
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
SimpleFluidProperties(const InputParameters &parameters)
const Real _cp
specific heat at constant pressure
virtual Real k_from_p_T(Real pressure, Real temperature) const override
static const std::string k
Definition: NS.h:130
virtual Real molarMass() const override
Molar mass [kg/mol].
virtual Real cv_from_p_T(Real pressure, Real temperature) const override
virtual Real p_from_v_e(Real v, Real e) const override