GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/components/o2.hh
Date: 2025-04-19 19:19:10
Exec Total Coverage
Lines: 33 42 78.6%
Functions: 2 2 100.0%
Branches: 23 43 53.5%

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