GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/components/ch4.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 1 1 100.0%
Branches: 15 29 51.7%

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-FileCopyrightText: 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 #include <dumux/material/components/shomate.hh>
22
23 namespace Dumux::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 using ShomateMethod = Dumux::ShomateMethod<Scalar, 3>; // three regions
37
38 public:
39 static const ShomateMethod shomateMethod;
40
41 /*!
42 * \brief A human readable name for methane.
43 */
44
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
5 static std::string name()
45
9/17
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ 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 3 not taken.
5 { return "CH4"; }
46
47 /*!
48 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular methane.
49 */
50 static constexpr Scalar molarMass()
51 { return 16.043e-3; /* [kg/mol] */}
52
53 /*!
54 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular methane
55 */
56 static Scalar criticalTemperature()
57 { return 190.4; /* [K] */ }
58
59 /*!
60 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular methane
61 */
62 static Scalar criticalPressure()
63 { return 46e5; /* [Pa] */ }
64
65 /*!
66 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular methane's triple point.
67 */
68 static Scalar tripleTemperature()
69 { return 90.7; /* [K] */ }
70
71 /*!
72 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at molecular methane's triple point.
73 */
74 static Scalar triplePressure()
75 { return 0; /* [Pa] */ }
76
77 /*!
78 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular methane
79 * at a given temperature.
80 *
81 *\param T temperature of component in \f$\mathrm{[K]}\f$
82 */
83 static Scalar vaporPressure(Scalar T)
84 { DUNE_THROW(Dune::NotImplemented, "vaporPressure for CH4"); }
85
86 /*!
87 * \brief Returns true if the gas phase is assumed to be compressible
88 */
89 static constexpr bool gasIsCompressible()
90 { return true; }
91
92 /*!
93 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$CH_4\f$ gas at a given pressure and temperature.
94 *
95 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
96 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
97 */
98 369622 static Scalar gasDensity(Scalar temperature, Scalar pressure)
99 {
100 // Assume an ideal gas
101 369622 return IdealGas::density(molarMass(), temperature, pressure);
102 }
103
104 /*!
105 * \brief The molar density of \f$CH_4\f$ gas in \f$\mathrm{[mol/m^3]}\f$,
106 * depending on pressure and temperature.
107 * \param temperature The temperature of the gas
108 * \param pressure The pressure of the gas
109 */
110 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
111 { return IdealGas::molarDensity(temperature, pressure); }
112
113 /*!
114 * \brief Returns true if the gas phase is assumed to be ideal
115 */
116 static constexpr bool gasIsIdeal()
117 { return true; }
118
119 /*!
120 * \brief The pressure of gaseous \f$CH_4\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
121 *
122 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
123 * \param density density of component in \f$\mathrm{[kg/m^3]}\f$
124 */
125 9 static Scalar gasPressure(Scalar temperature, Scalar density)
126 {
127 // Assume an ideal gas
128 9 return IdealGas::pressure(temperature, density/molarMass());
129 }
130
131 /*!
132 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure methane gas.
133 * Shomate Equation is used for a temperature range of 298K to 6000K.
134 *
135 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
136 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
137 */
138 110 static const Scalar gasEnthalpy(Scalar temperature,
139 Scalar pressure)
140 {
141
1/2
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
110 const auto h = shomateMethod.enthalpy(temperature); // KJ/mol
142 110 return h * 1e3 / molarMass(); // J/kg
143 }
144
145 /*!
146 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure methane gas.
147 *Shomate Equation is used for a temperature range of 298K to 6000K.
148 */
149 110 static Scalar gasHeatCapacity(Scalar T,
150 Scalar pressure)
151 {
152
1/2
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
110 const auto cp = shomateMethod.heatCapacity(T); // J/(mol K)
153 110 return cp / molarMass(); // J/(kg K)
154 }
155
156 /*!
157 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure methane gas.
158 *
159 * Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
160 *
161 * Rearranging for internal energy yields: \f$u = h - pv\f$.
162 *
163 * Exploiting the Ideal Gas assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
164 *
165 * The universal gas constant can only be used in the case of molar formulations.
166 *
167 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
168 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
169 */
170 static const Scalar gasInternalEnergy(Scalar temperature,
171 Scalar pressure)
172 {
173
174 return
175 gasEnthalpy(temperature, pressure) -
176 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
177 IdealGas::R*temperature; // = pressure * spec. volume for an ideal gas
178 }
179
180 /*!
181 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$CH_4\f$ at a given pressure and temperature.
182 *
183 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
184 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
185 *
186 * See:
187 *
188 * See: R. Reid, et al.: The Properties of Gases and Liquids,
189 * 4th edition (1987, pp 396-397, 670) \cite reid1987 <BR>
190 * 5th edition (2001, pp 9.7-9.8 (omega and V_c taken from p. A.5)) \cite poling2001
191 *
192 */
193 369622 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
194 {
195 369622 const Scalar Tc = criticalTemperature();
196 369622 const Scalar Vc = 98.6; // critical specific volume [cm^3/mol]
197 369622 const Scalar omega = 0.011; // accentric factor
198 369622 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
199 369622 const Scalar dipole = 0.0; // dipole moment [debye]
200
201 using std::sqrt;
202 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
203 mu_r4 *= mu_r4;
204 369622 mu_r4 *= mu_r4;
205
206 using std::exp;
207 using std::pow;
208 369622 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
209 369622 Scalar Tstar = 1.2593 * temperature/Tc;
210 369622 Scalar Omega_v =
211 369622 1.16145*pow(Tstar, -0.14874) +
212 369622 0.52487*exp(- 0.77320*Tstar) +
213 369622 2.16178*exp(- 2.43787*Tstar);
214 369622 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
215
216 // conversion from micro poise to Pa s
217 369622 return mu/1e6 / 10;
218 }
219 };
220
221 /*!
222 * \brief Shomate parameters for methane published by NIST \cite NIST
223 * https://webbook.nist.gov/cgi/cbook.cgi?ID=C74828&Units=SI&Mask=1&Type=JANAFG&Table=on#JANAFG
224 * First row defines the temperature ranges, further rows give the parameters (A,B,C,D,E,F,G,H) for the respective temperature ranges.
225 */
226 template <class Scalar>
227 const typename CH4<Scalar>::ShomateMethod CH4<Scalar>::shomateMethod{
228 /*temperature*/{298.0, 1300.0, 6000.0},
229 typename CH4<Scalar>::ShomateMethod::Coefficients{{
230 {-0.703029, 108.4773, -42.52157, 5.862788, 0.678565, -76.84376, 158.7163, -74.87310},
231 {85.81217, 11.26467, -2.114146, 0.138190, -26.42221, -153.5327, 224.4143, -74.87310}
232 }}
233 };
234
235 } // end namespace Dumux::Components
236
237 #endif
238