https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MethaneFluidProperties.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
11#include "MathUtils.h"
12#include "libmesh/utility.h"
13
15
18{
20 params.addClassDescription("Fluid properties for methane (CH4)");
21 return params;
22}
23
25 : HelmholtzFluidProperties(parameters),
26 _Mch4(16.0425e-3),
27 _p_critical(4.5992e6),
28 _T_critical(190.564),
29 _rho_critical(162.66),
30 _p_triple(1.169e4),
31 _T_triple(90.6941)
32{
33}
34
36
37std::string
39{
40 return "methane";
41}
42
43Real
45{
46 return _Mch4;
47}
48
49Real
54
55Real
60
61Real
66
67Real
72
73Real
78
79Real
80MethaneFluidProperties::mu_from_p_T(Real /*pressure*/, Real temperature) const
81{
82 // Check the temperature is in the range of validity (200 K <= T <= 1000 K)
83 if (temperature <= 200.0 || temperature >= 1000.0)
84 mooseException(
85 "Temperature ", temperature, "K out of range (200K, 1000K) in ", name(), ": mu_from_p_T()");
86
87 Real viscosity = 0.0;
88 for (std::size_t i = 0; i < _a.size(); ++i)
89 viscosity += _a[i] * MathUtils::pow(temperature, i);
90
91 return viscosity * 1.e-6;
92}
93
94void
96 Real pressure, Real temperature, Real & mu, Real & dmu_dp, Real & dmu_dT) const
97{
98
99 mu = this->mu_from_p_T(pressure, temperature);
100 dmu_dp = 0.0;
101
102 Real dmudt = 0.0;
103 for (std::size_t i = 0; i < _a.size(); ++i)
104 dmudt += i * _a[i] * MathUtils::pow(temperature, i) / temperature;
105 dmu_dT = dmudt * 1.e-6;
106}
107
108Real
109MethaneFluidProperties::k_from_p_T(Real /*pressure*/, Real temperature) const
110{
111 // Check the temperature is in the range of validity (200 K <= T <= 1000 K)
112 if (temperature <= 200.0 || temperature >= 1000.0)
113 mooseException(
114 "Temperature ", temperature, "K out of range (200K, 1000K) in ", name(), ": k()");
115
116 Real kt = 0.0;
117 for (std::size_t i = 0; i < _b.size(); ++i)
118 kt += _b[i] * MathUtils::pow(temperature, i);
119
120 return kt;
121}
122
123void
125 Real /*pressure*/, Real temperature, Real & k, Real & dk_dp, Real & dk_dT) const
126{
127 // Check the temperature is in the range of validity (200 K <= T <= 1000 K)
128 if (temperature <= 200.0 || temperature >= 1000.0)
129 mooseException(
130 "Temperature ", temperature, "K out of range (200K, 1000K) in ", name(), ": k()");
131
132 Real kt = 0.0, dkt_dT = 0.0;
133
134 for (std::size_t i = 0; i < _b.size(); ++i)
135 kt += _b[i] * MathUtils::pow(temperature, i);
136
137 for (std::size_t i = 1; i < _b.size(); ++i)
138 dkt_dT += i * _b[i] * MathUtils::pow(temperature, i) / temperature;
139
140 k = kt;
141 dk_dp = 0.0;
142 dk_dT = dkt_dT;
143}
144
145Real
147{
148 if (temperature < _T_triple || temperature > _T_critical)
149 mooseException("Temperature is out of range in ", name(), ": vaporPressure()");
150
151 const Real Tr = temperature / _T_critical;
152 const Real theta = 1.0 - Tr;
153
154 const Real logpressure = (-6.036219 * theta + 1.409353 * std::pow(theta, 1.5) -
155 0.4945199 * Utility::pow<2>(theta) - 1.443048 * std::pow(theta, 4.5)) /
156 Tr;
157
158 return _p_critical * std::exp(logpressure);
159}
160
161void
162MethaneFluidProperties::vaporPressure(Real, Real &, Real &) const
163{
164 mooseError("vaporPressure() is not implemented");
165}
166
167std::vector<Real>
169{
170 return {-10.44708, 4.66491, 12.12986};
171}
172
173Real
175{
176 if (temperature < _T_triple || temperature > _T_critical)
177 mooseException(
178 "Temperature ", temperature, " is out of range in ", name(), ": saturatedLiquidDensity()");
179
180 const Real Tr = temperature / _T_critical;
181 const Real theta = 1.0 - Tr;
182
183 const Real logdensity = 1.9906389 * std::pow(theta, 0.354) - 0.78756197 * std::sqrt(theta) +
184 0.036976723 * std::pow(theta, 2.5);
185
186 return _rho_critical * std::exp(logdensity);
187}
188
189Real
191{
192 if (temperature < _T_triple || temperature > _T_critical)
193 mooseException(
194 "Temperature ", temperature, " is out of range in ", name(), ": saturatedVaporDensity()");
195
196 const Real Tr = temperature / _T_critical;
197 const Real theta = 1.0 - Tr;
198
199 const Real logdensity =
200 -1.880284 * std::pow(theta, 0.354) - 2.8526531 * std::pow(theta, 5.0 / 6.0) -
201 3.000648 * std::pow(theta, 1.5) - 5.251169 * std::pow(theta, 2.5) -
202 13.191859 * std::pow(theta, 25.0 / 6.0) - 37.553961 * std::pow(theta, 47.0 / 6.0);
203
204 return _rho_critical * std::exp(logdensity);
205}
206
207Real
208MethaneFluidProperties::alpha(Real delta, Real tau) const
209{
210 // Ideal gas component of the Helmholtz free energy
211 Real alpha0 = std::log(delta) + 9.91243972 - 6.33270087 * tau + 3.0016 * std::log(tau);
212
213 for (std::size_t i = 0; i < _a0.size(); ++i)
214 alpha0 += _a0[i] * std::log(1.0 - std::exp(-_b0[i] * tau));
215
216 // Residual component of the Helmholtz free energy
217 Real alphar = 0.0;
218
219 for (std::size_t i = 0; i < _t1.size(); ++i)
220 alphar += _N1[i] * MathUtils::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
221
222 for (std::size_t i = 0; i < _t2.size(); ++i)
223 alphar += _N2[i] * MathUtils::pow(delta, _d2[i]) * std::pow(tau, _t2[i]) *
224 std::exp(-MathUtils::pow(delta, _c2[i]));
225
226 for (std::size_t i = 0; i < _t3.size(); ++i)
227 alphar += _N3[i] * MathUtils::pow(delta, _d3[i]) * std::pow(tau, _t3[i]) *
228 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
229 _beta3[i] * Utility::pow<2>(tau - _gamma3[i]));
230
231 // The Helmholtz free energy is the sum of these two
232 return alpha0 + alphar;
233}
234
235Real
236MethaneFluidProperties::dalpha_ddelta(Real delta, Real tau) const
237{
238 // Ideal gas component of the Helmholtz free energy
239 Real dalpha0 = 1.0 / delta;
240
241 // Residual component of the Helmholtz free energy
242 Real dalphar = 0.0;
243
244 for (std::size_t i = 0; i < _t1.size(); ++i)
245 dalphar += _N1[i] * _d1[i] * MathUtils::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
246
247 for (std::size_t i = 0; i < _t2.size(); ++i)
248 dalphar += _N2[i] * MathUtils::pow(delta, _d2[i]) * std::pow(tau, _t2[i]) *
249 std::exp(-MathUtils::pow(delta, _c2[i])) *
250 (_d2[i] - _c2[i] * MathUtils::pow(delta, _c2[i]));
251
252 for (std::size_t i = 0; i < _t3.size(); ++i)
253 dalphar += _N3[i] * MathUtils::pow(delta, _d3[i]) * std::pow(tau, _t3[i]) *
254 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
255 _beta3[i] * Utility::pow<2>(tau - _gamma3[i])) *
256 (_d3[i] - delta * (2.0 * _alpha3[i] * (delta - _D3[i])));
257
258 // The Helmholtz free energy is the sum of these two
259 return dalpha0 + dalphar / delta;
260}
261
262Real
263MethaneFluidProperties::dalpha_dtau(Real delta, Real tau) const
264{
265 // Ideal gas component of the Helmholtz free energy
266 Real dalpha0 = -6.33270087 + 3.0016 / tau;
267
268 for (std::size_t i = 0; i < _a0.size(); ++i)
269 dalpha0 += _a0[i] * _b0[i] * (1.0 / (1.0 - std::exp(-_b0[i] * tau)) - 1.0);
270
271 // Residual component of the Helmholtz free energy
272 Real dalphar = 0.0;
273
274 for (std::size_t i = 0; i < _t1.size(); ++i)
275 dalphar += _N1[i] * _t1[i] * MathUtils::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
276
277 for (std::size_t i = 0; i < _t2.size(); ++i)
278 dalphar += _N2[i] * _t2[i] * MathUtils::pow(delta, _d2[i]) * std::pow(tau, _t2[i]) *
279 std::exp(-MathUtils::pow(delta, _c2[i]));
280
281 for (std::size_t i = 0; i < _t3.size(); ++i)
282 dalphar += _N3[i] * MathUtils::pow(delta, _d3[i]) * std::pow(tau, _t3[i]) *
283 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
284 _beta3[i] * Utility::pow<2>(tau - _gamma3[i])) *
285 (_t3[i] + tau * (2.0 * _beta3[i] * (tau - _gamma3[i])));
286
287 // The Helmholtz free energy is the sum of these two
288 return dalpha0 + dalphar / tau;
289}
290
291Real
293{
294 // Ideal gas component of the Helmholtz free energy
295 Real dalpha0 = -1.0 / delta / delta;
296
297 // Residual component of the Helmholtz free energy
298 Real dalphar = 0.0;
299
300 for (std::size_t i = 0; i < _t1.size(); ++i)
301 dalphar +=
302 _N1[i] * _d1[i] * (_d1[i] - 1.0) * MathUtils::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
303
304 for (std::size_t i = 0; i < _t2.size(); ++i)
305 dalphar += _N2[i] * MathUtils::pow(delta, _d2[i]) * std::pow(tau, _t2[i]) *
306 std::exp(-MathUtils::pow(delta, _c2[i])) *
307 ((_d2[i] - _c2[i] * MathUtils::pow(delta, _c2[i])) *
308 (_d2[i] - 1.0 - _c2[i] * MathUtils::pow(delta, _c2[i])) -
309 _c2[i] * _c2[i] * MathUtils::pow(delta, _c2[i]));
310
311 for (std::size_t i = 0; i < _t3.size(); ++i)
312 dalphar += _N3[i] * std::pow(tau, _t3[i]) *
313 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
314 _beta3[i] * Utility::pow<2>(tau - _gamma3[i])) *
315 (-2.0 * _alpha3[i] * MathUtils::pow(delta, _d3[i] + 2) +
316 4.0 * _alpha3[i] * _alpha3[i] * MathUtils::pow(delta, _d3[i] + 2) *
317 MathUtils::pow(delta - _D3[i], 2) -
318 4.0 * _d3[i] * _alpha3[i] * MathUtils::pow(delta, _d3[i] + 1) * (delta - _D3[i]) +
319 _d3[i] * (_d3[i] - 1) * MathUtils::pow(delta, _d3[i]));
320
321 // The Helmholtz free energy is the sum of these two
322 return dalpha0 + dalphar / delta / delta;
323}
324
325Real
326MethaneFluidProperties::d2alpha_dtau2(Real delta, Real tau) const
327{
328 // Ideal gas component of the Helmholtz free energy
329 Real dalpha0 = -3.0016 / tau / tau;
330
331 for (std::size_t i = 0; i < _a0.size(); ++i)
332 {
333 Real exptau = std::exp(-_b0[i] * tau);
334 dalpha0 -= _a0[i] * (_b0[i] * _b0[i] * exptau / (1.0 - exptau) / (1.0 - exptau));
335 }
336
337 // Residual component of the Helmholtz free energy
338 Real dalphar = 0.0;
339
340 for (std::size_t i = 0; i < _t1.size(); ++i)
341 dalphar +=
342 _N1[i] * _t1[i] * (_t1[i] - 1.0) * MathUtils::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
343
344 for (std::size_t i = 0; i < _t2.size(); ++i)
345 dalphar += _N2[i] * _t2[i] * (_t2[i] - 1.0) * MathUtils::pow(delta, _d2[i]) *
346 std::pow(tau, _t2[i]) * std::exp(-MathUtils::pow(delta, _c2[i]));
347
348 for (std::size_t i = 0; i < _t3.size(); ++i)
349 dalphar += _N3[i] * MathUtils::pow(delta, _d3[i]) * std::pow(tau, _t3[i]) *
350 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
351 _beta3[i] * Utility::pow<2>(tau - _gamma3[i])) *
352 (tau * _t3[i] - _beta3[i] * tau * tau * MathUtils::pow(tau - _gamma3[i], 2) -
353 _t3[i] - 2.0 * tau * tau * _beta3[i]);
354
355 // The Helmholtz free energy is the sum of these two
356 return dalpha0 + dalphar / tau / tau;
357}
358
359Real
361{
362 // Residual component of the Helmholtz free energy
363 Real dalphar = 0.0;
364
365 for (std::size_t i = 0; i < _t1.size(); ++i)
366 dalphar += _N1[i] * _d1[i] * _t1[i] * std::pow(delta, _d1[i]) * std::pow(tau, _t1[i]);
367
368 for (std::size_t i = 0; i < _t2.size(); ++i)
369 dalphar += _N2[i] * _t2[i] * std::pow(delta, _d2[i]) * std::pow(tau, _t2[i]) *
370 std::exp(-MathUtils::pow(delta, _c2[i])) *
371 (_d2[i] - _c2[i] * MathUtils::pow(delta, _c2[i]));
372
373 for (std::size_t i = 0; i < _t3.size(); ++i)
374 dalphar += _N3[i] * std::pow(delta, _d3[i]) * std::pow(tau, _t3[i]) *
375 std::exp(-_alpha3[i] * Utility::pow<2>(delta - _D3[i]) -
376 _beta3[i] * Utility::pow<2>(tau - _gamma3[i])) *
377 (_d3[i] - 2.0 * _alpha3[i] * delta * (delta - _D3[i]) *
378 (_t3[i] - 2.0 * _beta3[i] * tau * (tau - _gamma3[i])));
379
380 // The Helmholtz free energy is the sum of these two
381 return dalphar / delta / tau;
382}
const double mu
registerMooseObject("FluidPropertiesApp", MethaneFluidProperties)
const std::string name
Definition Setup.h:21
Base class equation of state for fluids that use a Helmholtz free energy alpha(delta,...
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
Methane (CH4) fluid properties as a function of pressure (Pa) and temperature (K).
const std::array< Real, 5 > _b0
const std::array< Real, 4 > _beta3
const std::array< Real, 4 > _N3
const Real _T_critical
Critical temperature (K)
virtual Real triplePointTemperature() const override
Triple point temperature.
virtual Real d2alpha_dtau2(Real delta, Real tau) const override
Second derivative of Helmholtz free energy wrt tau.
const std::array< int, 4 > _d3
const std::array< unsigned int, 23 > _d2
const std::array< Real, 23 > _N2
virtual Real vaporPressure(Real temperature) const override
Vapor pressure.
virtual std::string fluidName() const override
Fluid name.
virtual Real criticalTemperature() const override
Critical temperature.
const std::array< unsigned int, 23 > _c2
const Real _rho_critical
Critical density (kg/m^3)
const std::array< Real, 4 > _D3
virtual Real triplePointPressure() const override
Triple point pressure.
const Real _T_triple
Triple point temperature (K)
const std::array< Real, 7 > _b
Coefficients for thermal conductivity.
virtual Real dalpha_ddelta(Real delta, Real tau) const override
Derivative of Helmholtz free energy wrt delta.
virtual Real alpha(Real delta, Real tau) const override
Helmholtz free energy.
static InputParameters validParams()
const std::array< unsigned int, 13 > _d1
const std::array< Real, 4 > _alpha3
virtual Real criticalPressure() const override
Critical pressure.
const Real _p_critical
Critical pressure (Pa)
virtual Real molarMass() const override
Molar mass [kg/mol].
const std::array< Real, 4 > _t3
Real saturatedVaporDensity(Real temperature) const
Saturated vapor density of CH4 Valid for temperatures between the triple point temperature and critic...
const std::array< Real, 6 > _a
Coefficients for viscosity.
virtual Real d2alpha_ddelta2(Real delta, Real tau) const override
Second derivative of Helmholtz free energy wrt delta.
const std::array< Real, 5 > _a0
Coefficients for ideal gas component of the Helmholtz free energy.
const std::array< Real, 4 > _gamma3
const std::array< Real, 13 > _N1
Coefficients for residual component of the Helmholtz free energy.
MethaneFluidProperties(const InputParameters &parameters)
virtual Real dalpha_dtau(Real delta, Real tau) const override
Derivative of Helmholtz free energy wrt tau.
const Real _Mch4
Methane molar mass (kg/mol)
const Real _p_triple
Triple point pressure (Pa)
virtual Real k_from_p_T(Real pressure, Real temperature) const override
virtual Real mu_from_p_T(Real pressure, Real temperature) const override
const std::array< Real, 23 > _t2
Real saturatedLiquidDensity(Real temperature) const
Saturated liquid density of CH4 Valid for temperatures between the triple point temperature and criti...
const std::array< Real, 13 > _t1
virtual Real criticalDensity() const override
Critical density.
virtual std::vector< Real > henryCoefficients() const override
Henry's law coefficients for dissolution in water.
virtual Real d2alpha_ddeltatau(Real delta, Real tau) const override
Second derivative of Helmholtz free energy wrt delta and tau.
void mooseError(Args &&... args) const
T pow(T x, int e)