www.mooseframework.org
MethaneFluidProperties.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<SinglePhaseFluidPropertiesPT>();
15  params.addParam<Real>("beta", 0, "Coefficient of thermal expansion");
16  params.addClassDescription("Fluid properties for methane (CH4)");
17  return params;
18 }
19 
20 MethaneFluidProperties::MethaneFluidProperties(const InputParameters & parameters)
21  : SinglePhaseFluidPropertiesPT(parameters),
22  _Mch4(16.0425e-3),
23  _p_critical(4.5992e6),
24  _T_critical(190.564),
25  _rho_critical(162.66),
26  _beta(getParam<Real>("beta"))
27 {
28 }
29 
31 
32 std::string
34 {
35  return "methane";
36 }
37 
38 Real
40 {
41  return _Mch4;
42 }
43 
44 Real
46 {
47  return _p_critical;
48 }
49 
50 Real
52 {
53  return _T_critical;
54 }
55 
56 Real
58 {
59  return _rho_critical;
60 }
61 
62 Real
64 {
65  return pressure * _Mch4 / (_R * temperature);
66 }
67 
68 void
70  Real pressure, Real temperature, Real & rho, Real & drho_dp, Real & drho_dT) const
71 {
72  rho = this->rho(pressure, temperature);
73  drho_dp = _Mch4 / (_R * temperature);
74  drho_dT = -pressure * _Mch4 / (_R * temperature * temperature);
75 }
76 
77 Real
79 {
80  return h(pressure, temperature) - _R * temperature / _Mch4;
81 }
82 
83 void
85  Real pressure, Real temperature, Real & e, Real & de_dp, Real & de_dT) const
86 {
87  e = this->e(pressure, temperature);
88  Real enthalpy, enthalpy_dp, enthalpy_dT;
89  h_dpT(pressure, temperature, enthalpy, enthalpy_dp, enthalpy_dT);
90  de_dp = enthalpy_dp;
91  de_dT = enthalpy_dT - _R / _Mch4;
92 }
93 
94 void
96  Real temperature,
97  Real & rho,
98  Real & drho_dp,
99  Real & drho_dT,
100  Real & e,
101  Real & de_dp,
102  Real & de_dT) const
103 {
104  Real density, ddensity_dp, ddensity_dT;
105  rho_dpT(pressure, temperature, density, ddensity_dp, ddensity_dT);
106  rho = density;
107  drho_dp = ddensity_dp;
108  drho_dT = ddensity_dT;
109 
110  Real energy, denergy_dp, denergy_dT;
111  e_dpT(pressure, temperature, energy, denergy_dp, denergy_dT);
112  e = energy;
113  de_dp = denergy_dp;
114  de_dT = denergy_dT;
115 }
116 
117 Real
119 {
120  return std::sqrt(gamma(pressure, temperature) * _R * temperature / _Mch4);
121 }
122 
123 Real
124 MethaneFluidProperties::cp(Real /*pressure*/, Real temperature) const
125 {
126  // Check the temperature is in the range of validity (280 K <= T <= 1080 K)
127  if (temperature <= 280.0 || temperature >= 1080.0)
128  mooseError("Temperature ", temperature, "K out of range (280K, 1080K) in ", name(), ": cp()");
129 
130  std::vector<Real> a;
131  if (temperature < 755.0)
132  a = {1.9165258, -1.09269e-3, 8.696605e-6, -5.2291144e-9, 0.0, 0.0, 0.0};
133  else
134  a = {1.04356e1, -4.2025284e-2, 8.849006e-5, -8.4304566e-8, 3.9030203e-11, -7.1345169e-15, 0.0};
135 
136  Real specific_heat = 0.0;
137  for (std::size_t i = 0; i < a.size(); ++i)
138  specific_heat += a[i] * std::pow(temperature, i);
139 
140  // convert to J/kg/K by multiplying by 1000
141  return specific_heat * 1000.0;
142 }
143 
144 Real
146 {
147  return cp(pressure, temperature) - _R / _Mch4;
148 }
149 
150 Real
152 {
153  Real rho = this->rho(pressure, temperature);
154  return this->mu_from_rho_T(rho, temperature);
155 }
156 
157 void
159  Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
160 {
161  Real rho, drho_dp, drho_dT;
162  this->rho_dpT(pressure, temperature, rho, drho_dp, drho_dT);
163  Real dmu_drho;
164  this->mu_drhoT_from_rho_T(rho, temperature, drho_dT, mu, dmu_drho, dmu_dT);
165  dmu_dp = dmu_drho * drho_dp;
166 }
167 
168 Real
170 {
171  // Check the temperature is in the range of validity (200 K <= T <= 1000 K)
172  if (temperature <= 200.0 || temperature >= 1000.0)
173  mooseError("Temperature ",
174  temperature,
175  "K out of range (200K, 1000K) in ",
176  name(),
177  ": mu_from_rho_T()");
178 
179  const std::vector<Real> a{
180  2.968267e-1, 3.711201e-2, 1.218298e-5, -7.02426e-8, 7.543269e-11, -2.7237166e-14};
181 
182  Real viscosity = 0.0;
183  for (std::size_t i = 0; i < a.size(); ++i)
184  viscosity += a[i] * std::pow(temperature, i);
185 
186  return viscosity * 1.e-6;
187 }
188 
189 void
191  Real temperature,
192  Real /*ddensity_dT*/,
193  Real & mu,
194  Real & dmu_drho,
195  Real & dmu_dT) const
196 {
197  const std::vector<Real> a{
198  2.968267e-1, 3.711201e-2, 1.218298e-5, -7.02426e-8, 7.543269e-11, -2.7237166e-14};
199 
200  mu = this->mu_from_rho_T(density, temperature);
201  dmu_drho = 0.0;
202 
203  Real dmudt = 0.0;
204  for (std::size_t i = 0; i < a.size(); ++i)
205  dmudt += i * a[i] * std::pow(temperature, i - 1.0);
206  dmu_dT = dmudt * 1.e-6;
207 }
208 
209 Real
211 {
212  Real rho = this->rho(pressure, temperature);
213  return this->k_from_rho_T(rho, temperature);
214 }
215 
216 void
218  Real /*pressure*/, Real /*temperature*/, Real & /*k*/, Real & /*dk_dp*/, Real & /*dk_dT*/) const
219 {
220  mooseError(name(), ": k_dpT() is not implemented");
221 }
222 
223 Real
225 {
226  // Check the temperature is in the range of validity (200 K <= T <= 1000 K)
227  if (temperature <= 200.0 || temperature >= 1000.0)
228  mooseError("Temperature ", temperature, "K out of range (200K, 1000K) in ", name(), ": k()");
229 
230  const std::vector<Real> a{-1.3401499e-2,
231  3.663076e-4,
232  -1.82248608e-6,
233  5.93987998e-9,
234  -9.1405505e-12,
235  6.7896889e-15,
236  -1.95048736e-18};
237 
238  Real kt = 0.0;
239  for (std::size_t i = 0; i < a.size(); ++i)
240  kt += a[i] * std::pow(temperature, i);
241 
242  return kt;
243 }
244 
245 Real
246 MethaneFluidProperties::s(Real /*pressure*/, Real temperature) const
247 {
248  // Check the temperature is in the range of validity (280 K <= t <= 1080 K)
249  if (temperature <= 280.0 || temperature >= 1080.0)
250  mooseError("Temperature ", temperature, "K out of range (280K, 1080K) in ", name(), ": s()");
251 
252  std::vector<Real> a;
253  if (temperature < 755.0)
254  a = {1.9165258, -1.09269e-3, 8.696605e-6, -5.2291144e-9, 0.0, 0.0, 0.0};
255  else
256  a = {1.04356e1, -4.2025284e-2, 8.849006e-5, -8.4304566e-8, 3.9030203e-11, -7.1345169e-15, 0.0};
257 
258  Real entropy = a[0] * std::log(temperature);
259  for (std::size_t i = 1; i < a.size(); ++i)
260  entropy += a[i] * std::pow(temperature, i) / static_cast<Real>(i);
261 
262  // convert to J/kg/K by multiplying by 1000
263  return entropy * 1000.0;
264 }
265 
266 Real
267 MethaneFluidProperties::h(Real /*pressure*/, Real temperature) const
268 {
269  // Check the temperature is in the range of validity (280 K <= t <= 1080 K)
270  if (temperature <= 280.0 || temperature >= 1080.0)
271  mooseError("Temperature ", temperature, "K out of range (280K, 1080K) in ", name(), ": cp()");
272 
273  std::vector<Real> a;
274  if (temperature < 755.0)
275  a = {1.9165258, -1.09269e-3, 8.696605e-6, -5.2291144e-9, 0.0, 0.0, 0.0};
276  else
277  a = {1.04356e1, -4.2025284e-2, 8.849006e-5, -8.4304566e-8, 3.9030203e-11, -7.1345169e-15, 0.0};
278 
279  Real enthalpy = 0.0;
280  for (std::size_t i = 0; i < a.size(); ++i)
281  enthalpy += a[i] * std::pow(temperature, i + 1) / (i + 1.0);
282 
283  // convert to J/kg by multiplying by 1000
284  return enthalpy * 1000.0;
285 }
286 
287 void
289  Real pressure, Real temperature, Real & h, Real & dh_dp, Real & dh_dT) const
290 {
291  h = this->h(pressure, temperature);
292  // Enthalpy doesn't depend on pressure
293  dh_dp = 0.0;
294 
295  std::vector<Real> a;
296  if (temperature < 755.0)
297  a = {1.9165258, -1.09269e-3, 8.696605e-6, -5.2291144e-9, 0.0, 0.0, 0.0};
298  else
299  a = {1.04356e1, -4.2025284e-2, 8.849006e-5, -8.4304566e-8, 3.9030203e-11, -7.1345169e-15, 0.0};
300 
301  Real dhdt = 0.0;
302  for (std::size_t i = 0; i < a.size(); ++i)
303  dhdt += a[i] * std::pow(temperature, i);
304 
305  // convert to J/kg/K by multiplying by 1000
306  dh_dT = dhdt * 1000.0;
307 }
308 
309 Real MethaneFluidProperties::beta(Real /*pressure*/, Real /*temperature*/) const { return _beta; }
310 
311 Real
313 {
314  return henryConstantIAPWS(temperature, -10.44708, 4.66491, 12.12986);
315 }
316 
317 void
318 MethaneFluidProperties::henryConstant_dT(Real temperature, Real & Kh, Real & dKh_dT) const
319 {
320  henryConstantIAPWS_dT(temperature, Kh, dKh_dT, -10.44708, 4.66491, 12.12986);
321 }
virtual void h_dpT(Real pressure, Real temperature, Real &h, Real &dh_dp, Real &dh_dT) const override
Enthalpy and its derivatives wrt pressure and temperature.
virtual Real beta(Real pressure, Real temperature) const override
Thermal expansion coefficient.
const Real _beta
Coefficient of thermal expansion (1/K)
virtual void mu_dpT(Real pressure, Real temperature, Real &mu, Real &dmu_dp, Real &dmu_dT) const override
virtual void henryConstant_dT(Real temperature, Real &Kh, Real &dKh_dT) const override
Henry&#39;s law constant for dissolution in water and derivative wrt temperature.
virtual Real s(Real pressure, Real temperature) const override
Specific entropy.
virtual void rho_e_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT, Real &e, Real &de_dp, Real &de_dT) const override
Density and internal energy and their derivatives wrt pressure and temperature.
virtual Real k_from_rho_T(Real density, Real temperature) const override
Thermal conductivity as a function of density and temperature.
const std::string density
Definition: NS.h:15
virtual Real e(Real pressure, Real temperature) const override
Internal energy.
const std::string temperature
Definition: NS.h:25
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const override
Dynamic viscosity and its derivatives wrt density and temperature.
const std::string enthalpy
Definition: NS.h:26
InputParameters validParams< MethaneFluidProperties >()
Common class for single phase fluid properties using a pressure and temperature formulation.
double FORTRAN_CALL() viscosity(double &rho, double &T)
virtual Real criticalDensity() const
Methane critical density.
InputParameters validParams< SinglePhaseFluidPropertiesPT >()
virtual Real henryConstant(Real temperature) const override
Henry&#39;s law constant for dissolution in water.
virtual void e_dpT(Real pressure, Real temperature, Real &e, Real &de_dp, Real &de_dT) const override
Internal energy and its derivatives wrt pressure and temperature.
MethaneFluidProperties(const InputParameters &parameters)
virtual std::string fluidName() const override
Fluid name.
virtual Real h(Real pressure, Real temperature) const override
Specific enthalpy.
virtual Real criticalPressure() const
Methane critical pressure.
virtual Real criticalTemperature() const
Methane critical temperature.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual Real gamma(Real pressure, Real temperature) const
Adiabatic index - ratio of specific heats.
virtual Real c(Real pressure, Real temperature) const override
Speed of sound.
virtual Real mu(Real pressure, Real temperature) const override
virtual void henryConstantIAPWS_dT(Real temperature, Real &Kh, Real &dKh_dT, Real A, Real B, Real C) const
IAPWS formulation of Henry&#39;s law constant for dissolution in water and derivative wrt temperature...
const Real _rho_critical
Critical density (kg/m^3)
const Real _T_critical
Critical temperature (K)
virtual Real k(Real pressure, Real temperature) const override
Thermal conductivity.
virtual void k_dpT(Real pressure, Real temperature, Real &k, Real &dk_dp, Real &dk_dT) const override
Thermal conductivity and its derivatives wrt pressure and temperature.
const Real _Mch4
Methane molar mass (kg/mol)
const std::string pressure
Definition: NS.h:24
virtual Real cp(Real pressure, Real temperature) const override
Isobaric specific heat capacity.
virtual Real henryConstantIAPWS(Real temperature, Real A, Real B, Real C) const
IAPWS formulation of Henry&#39;s law constant for dissolution in water From Guidelines on the Henry&#39;s con...
virtual Real mu_from_rho_T(Real density, Real temperature) const override
virtual Real cv(Real pressure, Real temperature) const override
Isochoric specific heat.
virtual Real rho(Real pressure, Real temperature) const override
Density.
const Real _p_critical
Critical pressure (Pa)
virtual Real molarMass() const override
Molar mass.
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const override
Density and its derivatives wrt pressure and temperature.
const Real _R
Universal gas constant (J/mol/K)