GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/h2.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 28 30 93.3%
Functions: 1 3 33.3%
Branches: 16 32 50.0%

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 pure molecular hydrogen \f$H_2\f$.
11 */
12 #ifndef DUMUX_H2_HH
13 #define DUMUX_H2_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 hydrogen \f$H_2\f$.
28 *
29 * \tparam Scalar The type used for scalar values
30 */
31 template <class Scalar>
32 class H2
33 : public Components::Base<Scalar, H2<Scalar> >
34 , public Components::Gas<Scalar, H2<Scalar> >
35 {
36 using IdealGas = Dumux::IdealGas<Scalar>;
37
38 public:
39 /*!
40 * \brief A human readable name for the \f$H_2\f$.
41 */
42 static std::string name()
43
16/32
✓ 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.
✓ 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.
8 { return "H2"; }
44
45 /*!
46 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular hydrogen.
47 */
48 static constexpr Scalar molarMass()
49 { return 2.01588e-3; }
50
51 /*!
52 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular hydrogen.
53 */
54 static Scalar criticalTemperature()
55 { return 33.2; /* [K] */ }
56
57 /*!
58 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular hydrogen.
59 */
60 static Scalar criticalPressure()
61 { return 13.0e5; /* [N/m^2] */ }
62
63 /*!
64 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular hydrogen's triple point.
65 */
66 static Scalar tripleTemperature()
67 { return 14.0; /* [K] */ }
68
69 /*!
70 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular hydrogen
71 * at a given temperature.
72 *
73 *\param temperature temperature of component in \f$\mathrm{[K]}\f$
74 *
75 * Taken from:
76 *
77 * See: R. Reid, et al. (1987, pp 208-209, 669) \cite reid1987
78 *
79 * \todo implement the Gomez-Thodos approach...
80 */
81 static Scalar vaporPressure(Scalar temperature)
82 {
83 if (temperature > criticalTemperature())
84 return criticalPressure();
85 if (temperature < tripleTemperature())
86 return 0; // H2 is solid: We don't take sublimation into
87 // account
88
89 // antoine equatuion
90 const Scalar A = -7.76451;
91 const Scalar B = 1.45838;
92 const Scalar C = -2.77580;
93
94 using std::exp;
95 return 1e5 * exp(A - B/(temperature + C));
96 }
97
98 /*!
99 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$H_2\f$ at a given pressure and temperature.
100 *
101 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
102 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
103 */
104 static Scalar gasDensity(Scalar temperature, Scalar pressure)
105 {
106 // Assume an ideal gas
107 202 return IdealGas::density(molarMass(), temperature, pressure);
108 }
109
110 /*!
111 * \brief The molar density of \f$H_2\f$ in \f$\mathrm{[mol/m^3]}\f$,
112 * depending on pressure and temperature.
113 * \param temperature The temperature of the gas
114 * \param pressure The pressure of the gas
115 */
116 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
117 { return IdealGas::molarDensity(temperature, pressure); }
118
119 /*!
120 * \brief Returns true if the gas phase is assumed to be compressible
121 */
122 static constexpr bool gasIsCompressible()
123 { return true; }
124
125 /*!
126 * \brief Returns true if the gas phase is assumed to be ideal
127 */
128 static constexpr bool gasIsIdeal()
129 { return true; }
130
131 /*!
132 * \brief The pressure of gaseous \f$H_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
133 *
134 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
135 * \param density density of component in \f$\mathrm{[kg/m^3]}\f$
136 */
137 static Scalar gasPressure(Scalar temperature, Scalar density)
138 {
139 // Assume an ideal gas
140 return IdealGas::pressure(temperature, density/molarMass());
141 }
142
143 /*!
144 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure hydrogen gas.
145 *
146 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
147 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
148 */
149 static const Scalar gasEnthalpy(Scalar temperature,
150 Scalar pressure)
151 {
152 202 return gasHeatCapacity(temperature, pressure) * temperature;
153 }
154
155 /*!
156 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure
157 * hydrogen gas.
158 *
159 * This is equivalent to the partial derivative of the specific
160 * enthalpy to the temperature.
161 * \param T temperature of component in \f$\mathrm{[K]}\f$
162 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
163 *
164 * See: R. Reid, et al. (1987, pp 154, 657, 665) \cite reid1987
165 */
166 static const Scalar gasHeatCapacity(Scalar T,
167 Scalar pressure)
168 {
169 // method of Joback
170 202 const Scalar cpVapA = 27.14;
171 202 const Scalar cpVapB = 9.273e-3;
172 202 const Scalar cpVapC = -1.381e-5;
173 202 const Scalar cpVapD = 7.645e-9;
174
175 return
176 1/molarMass()* // conversion from [J/(mol*K)] to [J/(kg*K)]
177 202 (cpVapA + T*
178 202 (cpVapB/2 + T*
179 202 (cpVapC/3 + T*
180 202 (cpVapD/4))));
181 }
182
183 /*!
184 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$H_2\f$ at a given pressure and temperature.
185 *
186 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
187 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
188 *
189 * See:
190 *
191 * See: R. Reid, et al.: The Properties of Gases and Liquids,
192 * 4th edition (1987, pp 396-397, 667) \cite reid1987 <BR>
193 * 5th edition (2001, pp 9.7-9.8 (omega and V_c taken from p. A.19)) \cite poling2001
194 */
195 101 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
196 {
197 101 const Scalar Tc = criticalTemperature();
198 101 const Scalar Vc = 65.0; // critical specific volume [cm^3/mol]
199 101 const Scalar omega = -0.216; // accentric factor
200 101 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
201 101 const Scalar dipole = 0.0; // dipole moment [debye]
202
203 using std::sqrt;
204 101 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
205 101 mu_r4 *= mu_r4;
206 101 mu_r4 *= mu_r4;
207
208 using std::pow;
209 using std::exp;
210 101 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
211 101 Scalar Tstar = 1.2593 * temperature/Tc;
212 101 Scalar Omega_v =
213 202 1.16145*pow(Tstar, -0.14874) +
214 101 0.52487*exp(- 0.77320*Tstar) +
215 101 2.16178*exp(- 2.43787*Tstar);
216 101 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
217
218 // conversion from micro poise to Pa s
219 101 return mu/1e6 / 10;
220 }
221 };
222
223 } // end namespace Components
224
225 } // end namespace Dumux
226
227 #endif
228