www.mooseframework.org
StiffenedGasFluidProperties.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<SinglePhaseFluidProperties>();
15  params.addRequiredParam<Real>("gamma", "Heat capacity ratio");
16  params.addRequiredParam<Real>("cv", "Constant volume specific heat");
17  params.addRequiredParam<Real>("q", "Parameter defining zero point of internal energy");
18  params.addRequiredParam<Real>("p_inf", "Stiffness parameter");
19  params.addParam<Real>("q_prime", 0, "Parameter");
20  params.addParam<Real>("mu", 1.e-3, "Dynamic viscosity, Pa.s");
21  params.addParam<Real>("k", 0.6, "Thermal conductivity, W/(m-K)");
22  params.addClassDescription("Fluid properties for a stiffened gas");
23  return params;
24 }
25 
27  : SinglePhaseFluidProperties(parameters),
28  _gamma(getParam<Real>("gamma")),
29  _cv(getParam<Real>("cv")),
30  _q(getParam<Real>("q")),
31  _q_prime(getParam<Real>("q_prime")),
32  _p_inf(getParam<Real>("p_inf")),
33  _mu(getParam<Real>("mu")),
34  _k(getParam<Real>("k"))
35 {
36  if (_cv == 0.0)
37  mooseError(name(), ": cv cannot be zero.");
38  _cp = _cv * _gamma;
39 }
40 
42 
43 Real
45 {
46  return (_gamma - 1.0) * (u - _q) / v - _gamma * _p_inf;
47 }
48 
49 Real
51 {
52  return (1.0 / _cv) * (u - _q - _p_inf * v);
53 }
54 
55 Real
56 StiffenedGasFluidProperties::c(Real v, Real u) const
57 {
58  return std::sqrt(_gamma * (this->pressure(v, u) + _p_inf) * v);
59 }
60 
61 Real StiffenedGasFluidProperties::cp(Real, Real) const { return _cp; }
62 
63 Real StiffenedGasFluidProperties::cv(Real, Real) const { return _cv; }
64 
65 Real StiffenedGasFluidProperties::mu(Real, Real) const { return _mu; }
66 
67 Real StiffenedGasFluidProperties::k(Real, Real) const { return _k; }
68 
69 Real
70 StiffenedGasFluidProperties::s(Real v, Real u) const
71 {
72  Real T = this->temperature(v, u);
73  Real p = this->pressure(v, u);
74  Real n = std::pow(T, _gamma) / std::pow(p + _p_inf, _gamma - 1.0);
75  if (n <= 0.0)
76  mooseError(name(), ": Negative argument in the ln() function.");
77  return _cv * std::log(n) + _q_prime;
78 }
79 
80 void
81 StiffenedGasFluidProperties::s_from_h_p(Real h, Real p, Real & s, Real & ds_dh, Real & ds_dp) const
82 {
83  const Real aux = (p + _p_inf) * std::pow((h - _q) / (_gamma * _cv), -_gamma / (_gamma - 1));
84  if (aux <= 0.0)
85  mooseError(name(), ": Non-positive argument in the ln() function.");
86 
87  const Real daux_dh = (p + _p_inf) *
88  std::pow((h - _q) / (_gamma * _cv), -_gamma / (_gamma - 1) - 1) *
89  (-_gamma / (_gamma - 1)) / (_gamma * _cv);
90  const Real daux_dp = std::pow((h - _q) / (_gamma * _cv), -_gamma / (_gamma - 1));
91 
92  s = _q_prime - (_gamma - 1) * _cv * std::log(aux);
93  ds_dh = -(_gamma - 1) * _cv / aux * daux_dh;
94  ds_dp = -(_gamma - 1) * _cv / aux * daux_dp;
95 }
96 
97 void
99  Real v, Real u, Real & dp_dv, Real & dp_du, Real & dT_dv, Real & dT_du) const
100 {
101  dp_dv = -(_gamma - 1.0) * (u - _q) / v / v;
102  dp_du = (_gamma - 1.0) / v;
103  dT_dv = -_p_inf / _cv;
104  dT_du = 1.0 / _cv;
105 }
106 
107 void
108 StiffenedGasFluidProperties::rho_e_ps(Real pressure, Real entropy, Real & rho, Real & e) const
109 {
110  Real a = (entropy - _q_prime + _cv * std::log(std::pow(pressure + _p_inf, _gamma - 1.0))) / _cv;
111  Real T = std::pow(std::exp(a), 1.0 / _gamma);
112  rho = this->rho(pressure, T);
113  e = this->e(pressure, rho);
114 }
115 
116 void
118  Real entropy,
119  Real & rho,
120  Real & drho_dp,
121  Real & drho_ds,
122  Real & e,
123  Real & de_dp,
124  Real & de_ds) const
125 {
126  // compute rho(p, T(p,s)) and e(p, rho(p, T(p,s)))
127  this->rho_e_ps(pressure, entropy, rho, e);
128 
129  // compute temperature
130  const Real aux =
131  (entropy - _q_prime + _cv * std::log(std::pow(pressure + _p_inf, _gamma - 1.0))) / _cv;
132  const Real T = std::pow(std::exp(aux), 1 / _gamma);
133 
134  // dT/dp
135  const Real dT_dp = 1.0 / _gamma * std::pow(std::exp(aux), 1.0 / _gamma - 1.0) * std::exp(aux) /
136  std::pow(pressure + _p_inf, _gamma - 1.0) * (_gamma - 1.0) *
137  std::pow(pressure + _p_inf, _gamma - 2.0);
138 
139  // dT/ds
140  const Real dT_ds =
141  1.0 / _gamma * std::pow(std::exp(aux), 1.0 / _gamma - 1.0) * std::exp(aux) / _cv;
142 
143  // Drho/Dp = d/dp[rho(p, T(p,s))] = drho/dp + drho/dT * dT/dp
144  Real drho_dp_partial, drho_dT;
145  rho_dpT(pressure, T, rho, drho_dp_partial, drho_dT);
146  drho_dp = drho_dp_partial + drho_dT * dT_dp;
147 
148  // Drho/Ds = d/ds[rho(p, T(p,s))] = drho/dT * dT/ds
149  drho_ds = drho_dT * dT_ds;
150 
151  // De/Dp = d/dp[e(p, rho(p, T(p,s)))] = de/dp + de/drho * Drho/Dp
152  const Real de_dp_partial = 1.0 / ((_gamma - 1.0) * rho);
153  const Real de_drho = -(pressure + _gamma * _p_inf) / ((_gamma - 1.0) * rho * rho);
154  de_dp = de_dp_partial + de_drho * drho_dp;
155 
156  // De/Ds = d/ds[e(p, rho(p, T(p,s)))] = de/drho * Drho/Ds
157  de_ds = de_drho * drho_ds;
158 }
159 
160 Real
162 {
163  // The volumetric thermal expansion coefficient is defined as
164  // 1/v dv/dT)_p
165  // It is the fractional change rate of volume with respect to temperature change
166  // at constant pressure. Here it is coded as
167  // - 1/rho drho/dT)_p
168  // using chain rule with v = v(rho)
169 
170  Real rho, drho_dp, drho_dT;
171  rho_dpT(pressure, temperature, rho, drho_dp, drho_dT);
172  return -drho_dT / rho;
173 }
174 
175 void
177 {
178  rho = this->rho(pressure, temperature);
179  e = this->e(pressure, rho);
180 }
181 
182 Real
184 {
185  mooseAssert(((_gamma - 1.0) * _cv * temperature) != 0.0,
186  "Invalid gamma or cv or temperature detected!");
187  return (pressure + _p_inf) / ((_gamma - 1.0) * _cv * temperature);
188 }
189 
190 void
192  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
193 {
194  mooseAssert(((_gamma - 1.0) * _cv * temperature) != 0.0,
195  "Invalid gamma or cv or temperature detected!");
196  rho = (pressure + _p_inf) / ((_gamma - 1) * _cv * temperature);
197  drho_dp = 1. / ((_gamma - 1.0) * _cv * temperature);
198  drho_dT = -(pressure + _p_inf) / ((_gamma - 1.0) * _cv * temperature * temperature);
199 }
200 
201 void
202 StiffenedGasFluidProperties::e_dpT(Real, Real, Real &, Real &, Real &) const
203 {
204  mooseError(name(), ": e_dpT() not implemented.");
205 }
206 
207 Real
209 {
210  mooseAssert((_gamma - 1.0) * rho != 0., "Invalid gamma or density detected!");
211  return (pressure + _gamma * _p_inf) / ((_gamma - 1.0) * rho) + _q;
212 }
213 
214 void
216  Real pressure, Real rho, Real & e, Real & de_dp, Real & de_drho) const
217 {
218  mooseAssert((_gamma - 1.0) * rho != 0., "Invalid gamma or density detected!");
219  e = this->e(pressure, rho);
220  de_dp = 1.0 / ((_gamma - 1.0) * rho);
221  de_drho = -(pressure + _gamma * _p_inf) / ((_gamma - 1.0) * rho * rho);
222 }
223 
224 Real
226 {
227  return _gamma * _cv * temperature + _q;
228 }
229 
230 void
232  Real, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
233 {
234  h = _gamma * _cv * temperature + _q;
235  dh_dp = 0.0;
236  dh_dT = _gamma * _cv;
237 }
238 
239 Real
241 {
242  return std::pow((h - _q) / (_gamma * _cv), _gamma / (_gamma - 1.0)) *
243  std::exp((_q_prime - s) / ((_gamma - 1.0) * _cv)) -
244  _p_inf;
245 }
246 
247 Real
249 {
250  return _gamma / (_gamma - 1.0) / (_gamma * _cv) *
251  std::pow((h - _q) / (_gamma * _cv), 1.0 / (_gamma - 1.0)) *
252  std::exp((_q_prime - s) / ((_gamma - 1.0) * _cv));
253 }
254 
255 Real
257 {
258  return std::pow((h - _q) / (_gamma * _cv), _gamma / (_gamma - 1)) *
259  std::exp((_q_prime - s) / ((_gamma - 1) * _cv)) / ((1 - _gamma) * _cv);
260 }
261 
262 Real
264 {
265  // g(p,T) for SGEOS is given by Equation (37) in the following reference:
266  //
267  // Ray A. Berry, Richard Saurel, Olivier LeMetayer
268  // The discrete equation method (DEM) for fully compressible, two-phase flows in
269  // ducts of spatially varying cross-section
270  // Nuclear Engineering and Design 240 (2010) p. 3797-3818
271  //
272  const Real p = pressure(v, e);
273  const Real T = temperature(v, e);
274 
275  return (_gamma * _cv - _q_prime) * T -
276  _cv * T * std::log(std::pow(T, _gamma) / std::pow(p + _p_inf, _gamma - 1.0)) + _q;
277 }
278 
279 Real StiffenedGasFluidProperties::gamma(Real, Real) const { return _gamma; }
280 
281 Real
283 {
284  return _gamma * (pressure + _p_inf) / rho;
285 }
virtual void s_from_h_p(Real h, Real p, Real &s, Real &ds_dh, Real &ds_dp) const override
Specific entropy from enthalpy and pressure.
virtual Real g(Real v, Real e) const override
Gibbs free energy.
virtual Real k(Real v, Real u) const override
Thermal conductivity [W / m K].
virtual Real cv(Real v, Real u) const override
Isochoric specific heat.
virtual void e_dpT(Real pressure, Real temperature, Real &e, Real &de_dp, Real &de_dT) const
virtual Real pressure(Real v, Real u) const override
Pressure as a function of specific internal energy and specific volume.
virtual Real mu(Real v, Real u) const override
Dynamic viscosity [Pa s].
virtual Real c(Real v, Real u) const override
Sound speed.
virtual Real temperature(Real v, Real u) const override
Temperature as a function of specific internal energy and specific volume.
virtual void h_dpT(Real pressure, Real temperature, Real &h, Real &dh_dp, Real &dh_dT) const override
Compute enthalpy and its derivatives.
virtual void dp_duv(Real v, Real u, Real &dp_dv, Real &dp_du, Real &dT_dv, Real &dT_du) const override
The derivative of pressure wrt specific volume and specific internal energy.
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const override
Computes density from pressure and temperature and its derivatives w.r.t pressure and temperature...
virtual Real dpdh_from_h_s(Real h, Real s) const override
Derivative of pressure wrt specific enthalpy.
virtual void rho_e_ps(Real pressure, Real entropy, Real &rho, Real &e) const override
Compute internal energy and density from specific entropy and pressure.
virtual void e_dprho(Real pressure, Real rho, Real &e, Real &de_dp, Real &de_drho) const override
Computes internal energy and its derivatives of internal energy w.r.t. pressure and density...
virtual Real p_from_h_s(Real h, Real s) const override
Pressure as a function of specific enthalpy and specific entropy.
virtual Real cp(Real v, Real u) const override
Specific heat.
Common class for single phase fluid properties.
virtual Real beta(Real p, Real T) const override
Thermal expansion coefficient.
virtual Real gamma(Real v, Real u) const override
Compute the ratio of specific heats.
virtual Real c2_from_p_rho(Real pressure, Real rho) const
InputParameters validParams< SinglePhaseFluidProperties >()
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
InputParameters validParams< StiffenedGasFluidProperties >()
virtual Real h(Real pressure, Real temperature) const override
Computes specific enthalpy.
StiffenedGasFluidProperties(const InputParameters &parameters)
virtual Real rho(Real pressure, Real temperature) const override
Computes density from pressure and temperature.
virtual void rho_e(Real pressure, Real temperature, Real &rho, Real &e) const override
Computes density and internal energy from pressure and temperature.
virtual void rho_e_dps(Real pressure, Real entropy, Real &rho, Real &drho_dp, Real &drho_ds, Real &e, Real &de_dp, Real &de_ds) const override
virtual Real dpds_from_h_s(Real h, Real s) const override
Derivative of pressure wrt specific entropy.
virtual Real e(Real pressure, Real rho) const override
Computes internal energy from pressure and density.
virtual Real s(Real v, Real u) const override
Specific entropy [ J / kg K ].