GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/ch4.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 29 31 93.5%
Functions: 1 3 33.3%
Branches: 18 34 52.9%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup Components
10 * \brief Properties of methane \f$CH_4\f$.
11 */
12 #ifndef DUMUX_CH4_HH
13 #define DUMUX_CH4_HH
14
15 #include <dumux/material/idealgas.hh>
16
17 #include <cmath>
18
19 #include <dumux/material/components/base.hh>
20 #include <dumux/material/components/gas.hh>
21
22 namespace Dumux {
23 namespace Components {
24
25 /*!
26 * \ingroup Components
27 * \brief Properties of pure molecular methane \f$CH_4\f$.
28 * \tparam Scalar The type used for scalar values
29 */
30 template <class Scalar>
31 class CH4
32 : public Components::Base<Scalar, CH4<Scalar> >
33 , public Components::Gas<Scalar, CH4<Scalar> >
34 {
35 using IdealGas = Dumux::IdealGas<Scalar>;
36
37 public:
38 /*!
39 * \brief A human readable name for methane.
40 */
41 static std::string name()
42
18/34
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
10 { return "CH4"; }
43
44 /*!
45 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular methane.
46 */
47 static constexpr Scalar molarMass()
48 { return 16.043e-3; /* [kg/mol] */}
49
50 /*!
51 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular methane
52 */
53 static Scalar criticalTemperature()
54 { return 190.4; /* [K] */ }
55
56 /*!
57 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular methane
58 */
59 static Scalar criticalPressure()
60 { return 46e5; /* [Pa] */ }
61
62 /*!
63 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular methane's triple point.
64 */
65 static Scalar tripleTemperature()
66 { return 90.7; /* [K] */ }
67
68 /*!
69 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at molecular methane's triple point.
70 */
71 static Scalar triplePressure()
72 { return 0; /* [Pa] */ }
73
74 /*!
75 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular methane
76 * at a given temperature.
77 *
78 *\param T temperature of component in \f$\mathrm{[K]}\f$
79 */
80 static Scalar vaporPressure(Scalar T)
81 { DUNE_THROW(Dune::NotImplemented, "vaporPressure for CH4"); }
82
83 /*!
84 * \brief Returns true if the gas phase is assumed to be compressible
85 */
86 static constexpr bool gasIsCompressible()
87 { return true; }
88
89 /*!
90 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$CH_4\f$ gas at a given pressure and temperature.
91 *
92 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
93 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
94 */
95 static Scalar gasDensity(Scalar temperature, Scalar pressure)
96 {
97 // Assume an ideal gas
98 739244 return IdealGas::density(molarMass(), temperature, pressure);
99 }
100
101 /*!
102 * \brief The molar density of \f$CH_4\f$ gas in \f$\mathrm{[mol/m^3]}\f$,
103 * depending on pressure and temperature.
104 * \param temperature The temperature of the gas
105 * \param pressure The pressure of the gas
106 */
107 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
108 { return IdealGas::molarDensity(temperature, pressure); }
109
110 /*!
111 * \brief Returns true if the gas phase is assumed to be ideal
112 */
113 static constexpr bool gasIsIdeal()
114 { return true; }
115
116 /*!
117 * \brief The pressure of gaseous \f$CH_4\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
118 *
119 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
120 * \param density density of component in \f$\mathrm{[kg/m^3]}\f$
121 */
122 static Scalar gasPressure(Scalar temperature, Scalar density)
123 {
124 // Assume an ideal gas
125 18 return IdealGas::pressure(temperature, density/molarMass());
126 }
127
128 /*!
129 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure methane gas.
130 *
131 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
132 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
133 */
134 static const Scalar gasEnthalpy(Scalar temperature,
135 Scalar pressure)
136 {
137 220 return gasHeatCapacity(temperature, pressure) * temperature;
138 }
139
140 /*!
141 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure
142 * methane gas.
143 *
144 * This is equivalent to the partial derivative of the specific
145 * enthalpy to the temperature.
146 *
147 * See: R. Reid, et al. (1987, pp 154, 657, 665) \cite reid1987
148 */
149 static Scalar gasHeatCapacity(Scalar T,
150 Scalar pressure)
151 {
152 // method of Joback
153 220 const Scalar cpVapA = 19.25;
154 220 const Scalar cpVapB = 0.05213;
155 220 const Scalar cpVapC = 1.197e-5;
156 220 const Scalar cpVapD = -1.132e-8;
157
158 return
159 1/molarMass()* // conversion from [J/(mol*K)] to [J/(kg*K)]
160 220 (cpVapA + T*
161 220 (cpVapB/2 + T*
162 220 (cpVapC/3 + T*
163 220 (cpVapD/4))));
164 }
165
166 /*!
167 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure methane gas.
168 *
169 * Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
170 *
171 * Rearranging for internal energy yields: \f$u = h - pv\f$.
172 *
173 * Exploiting the Ideal Gas assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
174 *
175 * The universal gas constant can only be used in the case of molar formulations.
176 *
177 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
178 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
179 */
180 static const Scalar gasInternalEnergy(Scalar temperature,
181 Scalar pressure)
182 {
183
184 return
185 gasEnthalpy(temperature, pressure) -
186 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
187 IdealGas::R*temperature; // = pressure * spec. volume for an ideal gas
188 }
189
190 /*!
191 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$CH_4\f$ at a given pressure and temperature.
192 *
193 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
194 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
195 *
196 * See:
197 *
198 * See: R. Reid, et al.: The Properties of Gases and Liquids,
199 * 4th edition (1987, pp 396-397, 670) \cite reid1987 <BR>
200 * 5th edition (2001, pp 9.7-9.8 (omega and V_c taken from p. A.5)) \cite poling2001
201 *
202 */
203 369622 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
204 {
205 369622 const Scalar Tc = criticalTemperature();
206 369622 const Scalar Vc = 98.6; // critical specific volume [cm^3/mol]
207 369622 const Scalar omega = 0.011; // accentric factor
208 369622 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
209 369622 const Scalar dipole = 0.0; // dipole moment [debye]
210
211 using std::sqrt;
212 369622 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
213 369622 mu_r4 *= mu_r4;
214 369622 mu_r4 *= mu_r4;
215
216 using std::exp;
217 using std::pow;
218 369622 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
219 369622 Scalar Tstar = 1.2593 * temperature/Tc;
220 369622 Scalar Omega_v =
221 739244 1.16145*pow(Tstar, -0.14874) +
222 369622 0.52487*exp(- 0.77320*Tstar) +
223 369622 2.16178*exp(- 2.43787*Tstar);
224 369622 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
225
226 // conversion from micro poise to Pa s
227 369622 return mu/1e6 / 10;
228 }
229 };
230
231 } // end namespace Components
232
233 } // end namespace Dumux
234
235 #endif
236