GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/o2.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 28 40 70.0%
Functions: 2 5 40.0%
Branches: 29 54 53.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-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 oxygen \f$O_2\f$.
11 */
12 #ifndef DUMUX_O2_HH
13 #define DUMUX_O2_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 {
24 namespace Components {
25
26 /*!
27 * \ingroup Components
28 * \brief Properties of pure molecular oxygen \f$O_2\f$.
29 *
30 * \tparam Scalar The type used for scalar values
31 */
32 template <class Scalar>
33 class O2
34 : public Components::Base<Scalar, O2<Scalar> >
35 , public Components::Gas<Scalar, O2<Scalar> >
36 {
37 using IdealGas = Dumux::IdealGas<Scalar>;
38 using ShomateMethod = Dumux::ShomateMethod<Scalar, 3>; // three regions
39
40 public:
41 static const ShomateMethod shomateMethod;
42
43 /*!
44 * \brief A human readable name for the \f$O_2\f$.
45 */
46 static std::string name()
47
22/42
✓ 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.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
34 { return "O2"; }
48
49 /*!
50 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular oxygen.
51 */
52 static constexpr Scalar molarMass()
53 { return 32e-3; }
54
55 /*!
56 * \brief Returns the critical temperature in \f$\mathrm{[K]}\f$ of molecular oxygen.
57 */
58 static constexpr Scalar criticalTemperature()
59 { return 154.581; /* [K] */ }
60
61 /*!
62 * \brief Returns the critical pressure in \f$\mathrm{[Pa]}\f$ of molecular oxygen.
63 */
64 static constexpr Scalar criticalPressure()
65 { return 5.0804e6; /* [N/m^2] */ }
66
67 /*!
68 * \brief Returns the temperature in \f$\mathrm{[K]}\f$ at molecular oxygen's triple point.
69 */
70 static constexpr Scalar tripleTemperature()
71 { return 54.359; /* [K] */ }
72
73 /*!
74 * \brief Returns the pressure in \f$\mathrm{[Pa]}\f$ at molecular oxygen's triple point.
75 */
76 static constexpr Scalar triplePressure()
77 { return 148.0; /* [N/m^2] */ }
78
79 /*!
80 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular oxygen
81 * at a given temperature.
82 *
83 * \param T temperature of component in \f$\mathrm{[K]}\f$
84 *
85 * Taken from:
86 *
87 * R. Prydz (1972, pp. 1-4) \cite prydz1972
88 */
89 3 static Scalar vaporPressure(Scalar T)
90 {
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (T > criticalTemperature())
92 return criticalPressure();
93 if (T < tripleTemperature())
94 return 0; // O2 is solid: We don't take sublimation into account
95
96 // vapor pressure between tripe and critical points. See the
97 // paper of Prydz for a discussion
98 Scalar X =
99 (1 - tripleTemperature()/T) /
100 (1 - tripleTemperature()/criticalTemperature());
101 const Scalar A = 7.568956;
102 const Scalar B = 5.004836;
103 const Scalar C = -2.137460;
104 const Scalar D = 3.454481;
105 const Scalar epsilon = 1.514;
106
107 using std::exp;
108 using std::pow;
109 return triplePressure()*exp(X*(A + X*(B + C*X) + D*pow(1 - X, epsilon)));
110 }
111
112 /*!
113 * \brief Returns true if the gas phase is assumed to be compressible
114 */
115 static constexpr bool gasIsCompressible()
116 { return true; }
117
118 /*!
119 * \brief The density in \f$\mathrm{[kg/m^3]}\f$ of pure \f$O_2\f$ at a given pressure and temperature.
120 *
121 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
122 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
123 *
124 * \todo: density liquid oxygen
125 */
126 static constexpr Scalar gasDensity(Scalar temperature, Scalar pressure)
127 {
128 // Assume an ideal gas
129
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
603656 return IdealGas::density(molarMass(), temperature, pressure);
130 }
131
132 /*!
133 * \brief The molar density of pure \f$O_2\f$ in \f$\mathrm{[mol/m^3]}\f$,
134 * depending on pressure and temperature.
135 * \param temperature The temperature of the gas
136 * \param pressure The pressure of the gas
137 */
138 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
139 603430 { return IdealGas::molarDensity(temperature, pressure); }
140
141 /*!
142 * \brief Returns true if the gas phase is assumed to be ideal
143 */
144 static constexpr bool gasIsIdeal()
145 { return true; }
146
147 /*!
148 * \brief The pressure of gaseous \f$O_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
149 *
150 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
151 * \param density density of component in \f$\mathrm{[kg/m^3]}\f$
152 */
153 static constexpr Scalar gasPressure(Scalar temperature, Scalar density)
154 {
155 // Assume an ideal gas
156 18 return IdealGas::pressure(temperature, density/molarMass());
157 }
158
159 /*!
160 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure oxygen gas.
161 * Shomate Equation is used for a temperature range of 100K to 6000K.
162 *
163 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
164 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
165 */
166 static Scalar gasEnthalpy(Scalar temperature,
167 Scalar pressure)
168 {
169
1/2
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
139517 const auto h = shomateMethod.enthalpy(temperature); // KJ/mol
170 139517 return h * 1e3 / molarMass(); // J/kg
171 }
172
173 /*!
174 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure oxygen gas.
175 * Shomate Equation is used for a temperature range of 100K to 6000K.
176 *
177 * \param T absolute temperature in \f$\mathrm{[K]}\f$
178 * \param pressure of the phase in \f$\mathrm{[Pa]}\f$
179 *
180 * See: R. Reid, et al. (1987, pp 154, 657, 665) \cite reid1987
181 */
182 static Scalar gasHeatCapacity(Scalar T,
183 Scalar pressure)
184 {
185
1/2
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
112 const auto cp = shomateMethod.heatCapacity(T); // J/(mol K)
186 112 return cp / molarMass(); // J/(kg K)
187 }
188
189 /*!
190 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$O_2\f$ at a given pressure and temperature.
191 *
192 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
193 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
194 *
195 * See:
196 *
197 * See: R. Reid, et al. (1987, pp 396-397, 664) \cite reid1987
198 */
199 301825 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
200 {
201 301825 const Scalar Tc = criticalTemperature();
202 301825 const Scalar Vc = 73.4; // critical specific volume [cm^3/mol]
203 301825 const Scalar omega = 0.025; // accentric factor
204 301825 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
205 301825 const Scalar dipole = 0.0; // dipole moment [debye]
206
207 using std::sqrt;
208 301825 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
209 301825 mu_r4 *= mu_r4;
210 301825 mu_r4 *= mu_r4;
211
212 301825 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
213 301825 Scalar Tstar = 1.2593 * temperature/Tc;
214
215 using std::pow;
216 using std::exp;
217 301825 Scalar Omega_v =
218 603650 1.16145*pow(Tstar, -0.14874) +
219 301825 0.52487*exp(- 0.77320*Tstar) +
220 301825 2.16178*exp(- 2.43787*Tstar);
221 301825 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
222
223 // conversion from micro poise to Pa s
224 301825 return mu/1e6 / 10;
225 }
226
227 /*!
228 * \brief Thermal conductivity \f$\mathrm{[[W/(m*K)]}\f$ of nitrogen.
229 *
230 * Isobaric Properties for Nitrogen and Oxygen in: NIST Standard
231 * Reference Database Number 69, Eds. P.J. Linstrom and
232 * W.G. Mallard evaluated at p=.1 MPa, does not
233 * change dramatically with p and can be interpolated linearly with temperature
234 *
235 * \param temperature absolute temperature in \f$\mathrm{[K]}\f$
236 * \param pressure of the phase in \f$\mathrm{[Pa]}\f$
237 */
238 static constexpr Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
239 {
240 139517 return 8.044e-5 * (temperature - 273.15) + 0.024486;
241 }
242 };
243
244 /*!
245 * \brief Shomate parameters for oxygen published by NIST \cite NIST
246 * https://webbook.nist.gov/cgi/cbook.cgi?ID=C7782447&Units=SI&Mask=1&Type=JANAFG&Table=on#JANAFG
247 * First row defines the temperature ranges, further rows give the parameters (A,B,C,D,E,F,G,H) for the respective temperature ranges.
248 */
249 template <class Scalar>
250 const typename O2<Scalar>::ShomateMethod O2<Scalar>::shomateMethod{
251 /*temperature*/{100.0, 700.0, 2000.0, 6000.0},
252 typename O2<Scalar>::ShomateMethod::Coefficients{{
253 {31.32234, -20.23531, 57.86644, -36.50624, -0.007374, -8.903471, 246.7945, 0.0},
254 {30.03235, 8.772972, -3.988133, 0.788313, -0.741599, -11.32468, 236.1663, 0.0},
255 {20.91111, 10.72071, -2.020498, 0.146449, 9.245722, 5.337651, 237.6185, 0.0}
256 }}
257 };
258
259 } // end namespace Components
260 } // end namespace Dumux
261
262 #endif
263