www.mooseframework.org
SimpleFluidProperties.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 SimpleFluidProperties::beta_from_p_T(Real /*pressure*/, Real /*temperature*/) const
71 {
72  return _thermal_expansion;
73 }
74 
75 void
77  Real pressure, Real temperature, Real & beta, Real & dbeta_dp, Real & dbeta_dT) const
78 {
80  dbeta_dp = 0.0;
81  dbeta_dT = 0.0;
82 }
83 
84 Real SimpleFluidProperties::cp_from_p_T(Real /*pressure*/, Real /*temperature*/) const
85 {
86  return _cp;
87 }
88 
89 void
91  Real pressure, Real temperature, Real & cp, Real & dcp_dp, Real & dcp_dT) const
92 {
94  dcp_dp = 0.0;
95  dcp_dT = 0.0;
96 }
97 
98 Real SimpleFluidProperties::cp_from_v_e(Real /*v*/, Real /*e*/) const { return _cp; }
99 
100 void
101 SimpleFluidProperties::cp_from_v_e(Real v, Real e, Real & cp, Real & dcp_dv, Real & dcp_de) const
102 {
103  cp = cp_from_v_e(v, e);
104  dcp_dv = 0.0;
105  dcp_de = 0.0;
106 }
107 
108 Real SimpleFluidProperties::cv_from_p_T(Real /*pressure*/, Real /*temperature*/) const
109 {
110  return _cv;
111 }
112 
113 void
115  Real pressure, Real temperature, Real & cv, Real & dcv_dp, Real & dcv_dT) const
116 {
118  dcv_dp = 0.0;
119  dcv_dT = 0.0;
120 }
121 
122 Real SimpleFluidProperties::cv_from_v_e(Real /*v*/, Real /*e*/) const { return _cv; }
123 
124 void
125 SimpleFluidProperties::cv_from_v_e(Real v, Real e, Real & cv, Real & dcv_dv, Real & dcv_de) const
126 {
127  cv = cv_from_v_e(v, e);
128  dcv_dv = 0.0;
129  dcv_de = 0.0;
130 }
131 
132 Real
134 {
136 }
137 
138 void
140  Real pressure, Real temperature, Real & c, Real & dc_dp, Real & dc_dT) const
141 {
143  dc_dp =
147  dc_dT =
152 }
153 
154 Real
156 {
157  Real T = T_from_v_e(v, e);
158  Real p = p_from_v_e(v, e);
159  return std::sqrt(_bulk_modulus / rho_from_p_T(p, T));
160 }
161 
162 void
163 SimpleFluidProperties::c_from_v_e(Real v, Real e, Real & c, Real & dc_dv, Real & dc_de) const
164 {
165  Real T = T_from_v_e(v, e);
166  Real p = p_from_v_e(v, e);
167 
169 
170  dc_dv = 0.5 * std::sqrt(_bulk_modulus / v);
171  dc_de = 0.0;
172 }
173 
174 Real SimpleFluidProperties::k_from_p_T(Real /*pressure*/, Real /*temperature*/) const
175 {
176  return _thermal_conductivity;
177 }
178 
179 void
181  Real /*pressure*/, Real /*temperature*/, Real & k, Real & dk_dp, Real & dk_dT) const
182 {
184  dk_dp = 0;
185  dk_dT = 0;
186 }
187 
188 Real SimpleFluidProperties::k_from_v_e(Real /*v*/, Real /*e*/) const
189 {
190  return _thermal_conductivity;
191 }
192 
193 void
195  Real /*v*/, Real /*e*/, Real & k, Real & dk_dv, Real & dk_de) const
196 {
198  dk_dv = 0;
199  dk_de = 0;
200 }
201 
202 Real SimpleFluidProperties::s_from_p_T(Real /*pressure*/, Real /*temperature*/) const
203 {
204  return _specific_entropy;
205 }
206 
207 void
209  Real /*p*/, Real /*T*/, Real & s, Real & ds_dp, Real & ds_dT) const
210 {
211  s = _specific_entropy;
212  ds_dp = 0;
213  ds_dT = 0;
214 }
215 
216 Real SimpleFluidProperties::s_from_h_p(Real /*enthalpy*/, Real /*pressure*/) const
217 {
218  return _specific_entropy;
219 }
220 
221 Real SimpleFluidProperties::s_from_v_e(Real /*v*/, Real /*e*/) const { return _specific_entropy; }
222 
223 void
225  Real /*v*/, Real /*e*/, Real & s, Real & ds_dv, Real & ds_de) const
226 {
227  s = _specific_entropy;
228  ds_dv = 0;
229  ds_de = 0;
230 }
231 
232 Real
234 {
236 }
237 
238 void
240  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
241 {
242  rho = this->rho_from_p_T(pressure, temperature);
243  drho_dp = rho / _bulk_modulus;
244  drho_dT = -_thermal_expansion * rho;
245 }
246 
247 void
249  const DualReal & temperature,
250  DualReal & rho,
251  DualReal & drho_dp,
252  DualReal & drho_dT) const
253 {
254  rho = SinglePhaseFluidProperties::rho_from_p_T(pressure, temperature);
255  drho_dp = rho / _bulk_modulus;
256  drho_dT = -_thermal_expansion * rho;
257 }
258 
259 Real
260 SimpleFluidProperties::T_from_v_e(Real /*v*/, Real e) const
261 {
262  // NOTE: while e = _cv * T, h is not equal to _cp * T
263  return e / _cv;
264 }
265 
266 Real
268 {
269  return (std::log(1. / _density0 / v) - h / v / _bulk_modulus) / -_thermal_expansion /
271 }
272 
273 void
274 SimpleFluidProperties::T_from_v_h(Real v, Real h, Real & T, Real & dT_dv, Real & dT_dh) const
275 {
276  T = T_from_v_h(v, h);
277  dT_dv =
278  (1 / -_thermal_expansion) *
279  ((-1. / v + h / v / v / _bulk_modulus) * (1 + _cv / v / _thermal_expansion / _bulk_modulus) -
280  (std::log(1. / _density0 / v) - h / v / _bulk_modulus) *
281  (-_cv / v / v / _thermal_expansion / _bulk_modulus)) /
282  Utility::pow<2>(1 + _cv / v / _thermal_expansion / _bulk_modulus);
283  dT_dh = (-1 / v / _bulk_modulus) / -_thermal_expansion /
285 }
286 
287 void
288 SimpleFluidProperties::T_from_v_e(Real v, Real e, Real & T, Real & dT_dv, Real & dT_de) const
289 {
290  T = T_from_v_e(v, e);
291  dT_dv = 0.0;
292  dT_de = 1.0 / _cv;
293 }
294 
295 void
297  const DualReal & v, const DualReal & e, DualReal & T, DualReal & dT_dv, DualReal & dT_de) const
298 {
299  T = SinglePhaseFluidProperties::T_from_v_e(v, e);
300  dT_dv = 0.0;
301  dT_de = 1.0 / _cv;
302 }
303 
304 Real
305 SimpleFluidProperties::T_from_p_rho(Real p, Real rho) const
306 {
307  mooseAssert(rho > 0, "Density should be positive");
308  return (std::log(rho / _density0) - p / _bulk_modulus) / -_thermal_expansion;
309 }
310 
311 void
312 SimpleFluidProperties::T_from_p_rho(Real p, Real rho, Real & T, Real & dT_dp, Real & dT_drho) const
313 {
314  T = T_from_p_rho(p, rho);
315  dT_dp = 1 / (_thermal_expansion * _bulk_modulus);
316  dT_drho = 1 / (-_thermal_expansion * rho);
317 }
318 
319 Real
321 {
322  // Likely a better guess than user-selected
323  Real T_initial = h / _cp;
324 
325  // exponential dependence in rho and linear dependence in e makes it challenging
326  auto lambda = [&](Real p, Real current_T, Real & new_rho, Real & dh_dp, Real & dh_dT)
327  { h_from_p_T(p, current_T, new_rho, dh_dp, dh_dT); };
329  p, h, T_initial, _tolerance, lambda, name() + "::T_from_p_h")
330  .first;
331 }
332 
333 Real
335 {
337  return _bulk_modulus * (_thermal_expansion * temperature + std::log(1 / (v * _density0)));
338 }
339 
340 void
341 SimpleFluidProperties::p_from_v_e(Real v, Real e, Real & p, Real & dp_dv, Real & dp_de) const
342 {
343  p = p_from_v_e(v, e);
344  dp_dv = -_bulk_modulus / v;
346 }
347 
348 void
350  const DualReal & v, const DualReal & e, DualReal & p, DualReal & dp_dv, DualReal & dp_de) const
351 {
352  p = SinglePhaseFluidProperties::p_from_v_e(v, e);
353  dp_dv = -_bulk_modulus / v;
355 }
356 
357 Real
359 {
360  Real T = T_from_v_h(v, h);
361  return _bulk_modulus * (_thermal_expansion * T + std::log(1 / (v * _density0)));
362 }
363 
364 void
365 SimpleFluidProperties::p_from_v_h(Real v, Real h, Real & p, Real & dp_dv, Real & dp_dh) const
366 {
367  Real T, dT_dv, dT_dh;
368  T_from_v_h(v, h, T, dT_dv, dT_dh);
369  p = _bulk_modulus * (_thermal_expansion * T + std::log(1 / (v * _density0)));
370  dp_dv = _bulk_modulus * (_thermal_expansion * dT_dv - 1. / v);
371  dp_dh = _bulk_modulus * (_thermal_expansion * dT_dh);
372 }
373 
374 Real
375 SimpleFluidProperties::e_from_p_T(Real /*pressure*/, Real temperature) const
376 {
377  return _cv * temperature;
378 }
379 
380 void
382  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
383 {
384  e = this->e_from_p_T(pressure, temperature);
385  de_dp = 0.0;
386  de_dT = _cv;
387 }
388 
389 Real
390 SimpleFluidProperties::e_from_p_rho(Real p, Real rho) const
391 {
392  Real T = T_from_p_rho(p, rho);
393  return e_from_p_T(p, T);
394 }
395 
396 void
397 SimpleFluidProperties::e_from_p_rho(Real p, Real rho, Real & e, Real & de_dp, Real & de_drho) const
398 {
399  // get temperature and derivatives
400  Real T, dT_dp, dT_drho;
401  T_from_p_rho(p, rho, T, dT_dp, dT_drho);
402 
403  // get energy and derivatives
404  Real de_dT;
405  e_from_p_T(p, T, e, de_dp, de_dT);
406  de_dp = de_dT * dT_dp + de_dp;
407  de_drho = de_dT * dT_drho + de_dp * dT_dp;
408 }
409 
410 Real
412 {
413  Real T = T_from_v_h(v, h);
414  Real p = p_from_v_h(v, h);
415  return e_from_p_T(p, T);
416 }
417 
418 void
419 SimpleFluidProperties::e_from_v_h(Real v, Real h, Real & e, Real & de_dv, Real & de_dh) const
420 {
421  Real T, dT_dv, dT_dh;
422  Real p, dp_dv, dp_dh;
423  T_from_v_h(v, h, T, dT_dv, dT_dh);
424  p_from_v_h(v, h, p, dp_dv, dp_dh);
425 
426  Real de_dp, de_dT;
427  e_from_p_T(p, T, e, de_dp, de_dT);
428  de_dv = de_dp * dp_dv + de_dT * dT_dv;
429  de_dh = de_dp * dp_dh + de_dT * dT_dh;
430 }
431 
432 Real SimpleFluidProperties::mu_from_p_T(Real /*pressure*/, Real /*temperature*/) const
433 {
434  return _viscosity;
435 }
436 
437 void
439  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
440 {
441  mu = this->mu_from_p_T(pressure, temperature);
442  dmu_dp = 0.0;
443  dmu_dT = 0.0;
444 }
445 
446 Real SimpleFluidProperties::mu_from_v_e(Real /*v*/, Real /*e*/) const { return _viscosity; }
447 
448 void
449 SimpleFluidProperties::mu_from_v_e(Real v, Real e, Real & mu, Real & dmu_dv, Real & dmu_de) const
450 {
451  mu = this->mu_from_v_e(v, e);
452  dmu_dv = 0.0;
453  dmu_de = 0.0;
454 }
455 
456 Real
458 {
459  return e_from_p_T(pressure, temperature) +
461 }
462 
463 void
465  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
466 {
467  h = this->h_from_p_T(pressure, temperature);
468 
469  Real density, ddensity_dp, ddensity_dT;
470  rho_from_p_T(pressure, temperature, density, ddensity_dp, ddensity_dT);
471 
472  dh_dp = _pp_coeff / density - _pp_coeff * pressure * ddensity_dp / density / density;
473  dh_dT = _cv - _pp_coeff * pressure * ddensity_dT / density / density;
474 }
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:121
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
DualNumber< Real, DNDerivativeType, true > DualReal
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:57
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
virtual Real s_from_h_p(Real h, Real p) const override
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
virtual Real e_from_p_rho(Real pressure, Real rho) const override
static const std::string cp
Definition: NS.h:120
const Real _tolerance
Newton&#39;s method may be used to convert between variable sets _tolerance, _T_initial_guess, and _p_initial_guess are the parameters for these iterative solves.
virtual Real s_from_v_e(Real v, Real e) const override
const Real _thermal_conductivity
thermal conductivity
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:122
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.
e e e e s T T T T T rho v v T h
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:82
virtual Real T_from_p_rho(Real p, Real rho) const
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:124
virtual Real molarMass() const override
Fluid name.
virtual Real cv_from_p_T(Real pressure, Real temperature) const override
virtual Real p_from_v_e(Real v, Real e) const override