www.mooseframework.org
IdealGasFluidProperties.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", "gamma value (cp/cv)");
16  params.addRequiredParam<Real>("R", "Gas constant");
17  params.addParam<Real>("beta", 0, "Coefficient of thermal expansion");
18  params.addParam<Real>("mu", 0, "Dynamic viscosity, Pa.s");
19  params.addParam<Real>("k", 0, "Thermal conductivity, W/(m-K)");
20  params.addClassDescription("Fluid properties for an ideal gas");
21  return params;
22 }
23 
24 IdealGasFluidProperties::IdealGasFluidProperties(const InputParameters & parameters)
25  : SinglePhaseFluidProperties(parameters),
26  _gamma(getParam<Real>("gamma")),
27  _R(getParam<Real>("R")),
28  _beta(getParam<Real>("beta")),
29  _mu(getParam<Real>("mu")),
30  _k(getParam<Real>("k"))
31 {
32  _cp = _gamma * _R / (_gamma - 1.0);
33  _cv = _cp / _gamma;
34 }
35 
37 
38 Real
39 IdealGasFluidProperties::pressure(Real v, Real u) const
40 {
41  if (v == 0.0)
42  mooseError(name(), ": Invalid value of specific volume detected (v = ", v, ").");
43 
44  // The std::max function serves as a hard limiter, which will guarantee non-negative pressure
45  // when resolving strongly nonlinear waves
46  return std::max(1.0e-8, (_gamma - 1.0) * u / v);
47 }
48 
49 Real
50 IdealGasFluidProperties::temperature(Real /*v*/, Real u) const
51 {
52  return u / _cv;
53 }
54 
55 Real
56 IdealGasFluidProperties::c(Real v, Real u) const
57 {
58  Real temp = temperature(v, u);
59  // The std::max function serves as a hard limiter, which will guarantee non-negative speed of
60  // sound when resolving strongly nonlinear waves
61  return std::sqrt(std::max(1.0e-8, _gamma * _R * temp));
62 }
63 
64 Real IdealGasFluidProperties::cp(Real, Real) const { return _cp; }
65 
66 Real IdealGasFluidProperties::cv(Real, Real) const { return _cv; }
67 
68 Real IdealGasFluidProperties::gamma(Real, Real) const { return _gamma; }
69 
70 Real IdealGasFluidProperties::mu(Real, Real) const { return _mu; }
71 
72 Real IdealGasFluidProperties::k(Real, Real) const { return _k; }
73 
74 Real IdealGasFluidProperties::s(Real, Real) const { mooseError(name(), ": s() not implemented."); }
75 
76 void
77 IdealGasFluidProperties::s_from_h_p(Real h, Real p, Real & s, Real & ds_dh, Real & ds_dp) const
78 {
79  const Real aux = p * std::pow(h / (_gamma * _cv), -_gamma / (_gamma - 1));
80  if (aux <= 0.0)
81  mooseError(name(), ": Non-positive argument in the ln() function.");
82 
83  const Real daux_dh = p * std::pow(h / (_gamma * _cv), -_gamma / (_gamma - 1) - 1) *
84  (-_gamma / (_gamma - 1)) / (_gamma * _cv);
85  const Real daux_dp = std::pow(h / (_gamma * _cv), -_gamma / (_gamma - 1));
86 
87  s = -(_gamma - 1) * _cv * std::log(aux);
88  ds_dh = -(_gamma - 1) * _cv / aux * daux_dh;
89  ds_dp = -(_gamma - 1) * _cv / aux * daux_dp;
90 }
91 
92 void
94  Real v, Real u, Real & dp_dv, Real & dp_du, Real & dT_dv, Real & dT_du) const
95 {
96  dp_dv = -(_gamma - 1.0) * u / v / v;
97  dp_du = (_gamma - 1.0) / v;
98  dT_dv = 0.0;
99  dT_du = 1.0 / _cv;
100 }
101 
102 void
103 IdealGasFluidProperties::rho_e_ps(Real, Real, Real &, Real &) const
104 {
105  mooseError(name(), ": rho_e_ps() not implemented.");
106 }
107 
108 void
109 IdealGasFluidProperties::rho_e_dps(Real, Real, Real &, Real &, Real &, Real &, Real &, Real &) const
110 {
111  mooseError(name(), ": rho_e_dps() not implemented.");
112 }
113 
114 Real IdealGasFluidProperties::beta(Real, Real) const { return _beta; }
115 
116 void
117 IdealGasFluidProperties::rho_e(Real pressure, Real temperature, Real & rho, Real & e) const
118 {
119  rho = this->rho(pressure, temperature);
120  e = temperature * _cv;
121 }
122 
123 Real
125 {
126  if ((_gamma - 1.0) * pressure == 0.0)
127  mooseError(name(),
128  ": Invalid gamma or pressure detected in rho(pressure = ",
129  pressure,
130  ", gamma = ",
131  _gamma,
132  ")");
133 
134  return pressure / (_gamma - 1.0) / _cv / temperature;
135 }
136 
137 void
139  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
140 {
141  Real temp2 = temperature * temperature;
142  rho = pressure / (_gamma - 1.0) / _cv / temperature;
143  drho_dp = 1.0 / (_gamma - 1.0) / _cv / temperature;
144  drho_dT = -pressure / (_gamma - 1.0) / _cv / temp2;
145 }
146 
147 void
148 IdealGasFluidProperties::e_dpT(Real, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
149 {
150  e = temperature * _cv;
151  de_dp = 0.0;
152  de_dT = _cv;
153 }
154 
155 Real
157 {
158  return pressure / (_gamma - 1.0) / rho;
159 }
160 
161 void
163  Real pressure, Real rho, Real & e, Real & de_dp, Real & de_drho) const
164 {
165  e = this->e(pressure, rho);
166  de_dp = 1.0 / (_gamma - 1.0) / rho;
167  de_drho = -pressure / (_gamma - 1.0) / rho / rho;
168 }
169 
170 Real
172 {
173  Real rho = this->rho(pressure, temperature);
174  Real e = temperature * _cv;
175  return e + pressure / rho;
176 }
177 
178 void
180  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
181 {
182  h = this->h(pressure, temperature);
183  Real rho = this->rho(pressure, temperature);
184  dh_dp = 0.0;
185  dh_dT = _cv + pressure / rho / temperature;
186 }
187 
188 Real IdealGasFluidProperties::p_from_h_s(Real /*h*/, Real /*s*/) const
189 {
190  mooseError(name(), ": p_from_h_s() not implemented.");
191 }
192 
193 Real IdealGasFluidProperties::dpdh_from_h_s(Real /*h*/, Real /*s*/) const
194 {
195  mooseError(name(), ": dpdh_from_h_s() not implemented.");
196 }
197 
198 Real IdealGasFluidProperties::dpds_from_h_s(Real /*h*/, Real /*s*/) const
199 {
200  mooseError(name(), ": dpds_from_h_s() not implemented.");
201 }
202 
203 Real
204 IdealGasFluidProperties::g(Real v, Real e) const
205 {
206  // g(p,T) for SGEOS is given by Equation (37) in the following reference:
207  //
208  // Ray A. Berry, Richard Saurel, Olivier LeMetayer
209  // The discrete equation method (DEM) for fully compressible, two-phase flows in
210  // ducts of spatially varying cross-section
211  // Nuclear Engineering and Design 240 (2010) p. 3797-3818
212  //
213  const Real p = pressure(v, e);
214  const Real T = temperature(v, e);
215 
216  return _gamma * _cv * T - _cv * T * std::log(std::pow(T, _gamma) / std::pow(p, _gamma - 1.0));
217 }
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 Real k(Real v, Real u) const override
Thermal conductivity [W / m K].
virtual Real dpdh_from_h_s(Real h, Real s) const override
Derivative of pressure wrt specific enthalpy.
virtual Real g(Real v, Real e) const override
Gibbs free energy.
virtual Real h(Real pressure, Real temperature) const override
Computes specific enthalpy.
InputParameters validParams< IdealGasFluidProperties >()
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 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 Real s(Real v, Real u) const override
Specific entropy [ J / kg K ].
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 cv(Real v=0., Real u=0.) const override
Isochoric specific heat.
IdealGasFluidProperties(const InputParameters &parameters)
virtual Real cp(Real v=0., Real u=0.) const override
Specific heat.
virtual Real p_from_h_s(Real h, Real s) const override
Pressure as a function of specific enthalpy and specific entropy.
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 c(Real v, Real u) const override
Sound speed.
Common class for single phase fluid properties.
virtual void h_dpT(Real pressure, Real temperature, Real &h, Real &dh_dp, Real &dh_dT) const override
Compute enthalpy and its derivatives.
virtual Real beta(Real p, Real T) const override
Thermal expansion coefficient.
virtual void e_dpT(Real pressure, Real temperature, Real &e, Real &de_dp, Real &de_dT) const
virtual Real temperature(Real v, Real u) const override
Temperature as a function of specific internal energy and specific volume.
InputParameters validParams< SinglePhaseFluidProperties >()
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual Real gamma(Real v=0., Real u=0.) const override
Compute the ratio of specific heats.
virtual Real mu(Real v, Real u) const override
Dynamic viscosity [Pa s].
virtual Real pressure(Real v, Real u) const override
Pressure as a function of specific internal energy and specific volume.
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 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...