GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/n2.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 33 49 67.3%
Functions: 2 5 40.0%
Branches: 27 50 54.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 nitrogen \f$N_2\f$.
11 */
12 #ifndef DUMUX_N2_HH
13 #define DUMUX_N2_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 nitrogen \f$N_2\f$.
28 *
29 * \tparam Scalar The type used for scalar values
30 */
31 template <class Scalar>
32 class N2
33 : public Components::Base<Scalar, N2<Scalar> >
34 , public Components::Gas<Scalar, N2<Scalar> >
35 {
36 using IdealGas = Dumux::IdealGas<Scalar>;
37
38 public:
39 /*!
40 * \brief A human readable name for nitrogen.
41 */
42 static std::string name()
43
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.
404 { return "N2"; }
44
45 /*!
46 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular nitrogen.
47 */
48 static constexpr Scalar molarMass()
49 { return 28.0134e-3;}
50
51 /*!
52 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular nitrogen
53 */
54 static Scalar criticalTemperature()
55 { return 126.192; /* [K] */ }
56
57 /*!
58 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular nitrogen.
59 */
60 static Scalar criticalPressure()
61 { return 3.39858e6; /* [N/m^2] */ }
62
63 /*!
64 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular nitrogen's triple point.
65 */
66 static Scalar tripleTemperature()
67 { return 63.151; /* [K] */ }
68
69 /*!
70 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at molecular nitrogen's triple point.
71 */
72 static Scalar triplePressure()
73 { return 12.523e3; /* [N/m^2] */ }
74
75 /*!
76 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular nitrogen
77 * at a given temperature.
78 *
79 * \param T temperature of component in \f$\mathrm{[K]}\f$
80 *
81 * Taken from:
82 *
83 * R. Span, E.W. Lemmon, et al. (2000 ,pp. 1361-1433) \cite span2000
84 */
85 3 static Scalar vaporPressure(Scalar T)
86 {
87
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (T > criticalTemperature())
88 return criticalPressure();
89 if (T < tripleTemperature())
90 return 0; // N2 is solid: We don't take sublimation into
91 // account
92
93 // note: this is the ancillary equation given on page 1368
94 using std::sqrt;
95 Scalar sigma = Scalar(1.0) - T/criticalTemperature();
96 Scalar sqrtSigma = sqrt(sigma);
97 const Scalar N1 = -6.12445284;
98 const Scalar N2 = 1.26327220;
99 const Scalar N3 = -0.765910082;
100 const Scalar N4 = -1.77570564;
101
102 using std::exp;
103 return
104 criticalPressure() *
105 exp(criticalTemperature()/T*
106 (sigma*(N1 +
107 sqrtSigma*N2 +
108 sigma*(sqrtSigma*N3 +
109 sigma*sigma*sigma*N4))));
110 }
111
112 /*!
113 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$N_2\f$ gas at a given pressure and temperature.
114 *
115 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
116 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
117 */
118 static Scalar gasDensity(Scalar temperature, Scalar pressure)
119 {
120 // Assume an ideal gas
121
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
23697846 return IdealGas::density(molarMass(), temperature, pressure);
122 }
123
124 /*!
125 * \brief The molar density of \f$N_2\f$ gas in \f$\mathrm{[mol/m^3]}\f$ at a given pressure and temperature.
126 *
127 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
128 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
129 *
130 */
131 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
132 23697620 { return IdealGas::molarDensity(temperature, pressure); }
133
134 /*!
135 * \brief Returns true if the gas phase is assumed to be compressible
136 */
137 static constexpr bool gasIsCompressible()
138 { return true; }
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$N_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 static Scalar gasPressure(Scalar temperature, Scalar density)
153 {
154 // Assume an ideal gas
155 18 return IdealGas::pressure(temperature, density/molarMass());
156 }
157
158 /*!
159 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure nitrogen gas.
160 *
161 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
162 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
163 */
164 static const Scalar gasEnthalpy(Scalar temperature,
165 Scalar pressure)
166 {
167 42257582 return gasHeatCapacity(temperature, pressure) * temperature;
168 }
169
170 /*!
171 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure nitrogen gas.
172 *
173 * Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
174 *
175 * Rearranging for internal energy yields: \f$u = h - pv\f$.
176 *
177 * Exploiting the Ideal Gas assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
178 *
179 * The universal gas constant can only be used in the case of molar formulations.
180 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
181 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
182 */
183 static const Scalar gasInternalEnergy(Scalar temperature,
184 Scalar pressure)
185 {
186 return
187 gasEnthalpy(temperature, pressure) -
188 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
189 IdealGas::R*temperature; // = pressure * spec. volume for an ideal gas
190 }
191
192 /*!
193 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure
194 * nitrogen gas.
195 *
196 * This is equivalent to the partial derivative of the specific
197 * enthalpy to the temperature.
198 *
199 * See: R. Reid, et al. (1987, pp 154, 657, 665) \cite reid1987
200 */
201 static const Scalar gasHeatCapacity(Scalar T,
202 Scalar pressure)
203 {
204 // method of Joback
205 21128909 const Scalar cpVapA = 31.15;
206 21128909 const Scalar cpVapB = -0.01357;
207 21128909 const Scalar cpVapC = 2.680e-5;
208 21128909 const Scalar cpVapD = -1.168e-8;
209
210 return
211 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
212 21128909 (cpVapA + T*
213 21128909 (cpVapB/2 + T*
214 21128909 (cpVapC/3 + T*
215 21128909 (cpVapD/4))));
216 }
217
218 /*!
219 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$N_2\f$ at a given pressure and temperature.
220 *
221 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
222 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
223 *
224 * See:
225 *
226 * See: R. Reid, et al.: The Properties of Gases and Liquids,
227 * 4th edition (1987, pp 396-397) \cite reid1987 <BR>
228 * 5th edition (2001, pp 9.7-9.8 (omega and V_c taken from p. A.19)) \cite poling2001
229 *
230 */
231 16838318 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
232 {
233 16838318 const Scalar Tc = criticalTemperature();
234 16838318 const Scalar Vc = 90.1; // critical specific volume [cm^3/mol]
235 16838318 const Scalar omega = 0.037; // accentric factor
236 16838318 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
237 16838318 const Scalar dipole = 0.0; // dipole moment [debye]
238
239 using std::sqrt;
240 16838318 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
241 16838318 mu_r4 *= mu_r4;
242 16838318 mu_r4 *= mu_r4;
243
244 using std::pow;
245 using std::exp;
246 16838318 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
247 16838318 Scalar Tstar = 1.2593 * temperature/Tc;
248 16838318 Scalar Omega_v =
249 33676636 1.16145*pow(Tstar, -0.14874) +
250 16838318 0.52487*exp(- 0.77320*Tstar) +
251 16838318 2.16178*exp(- 2.43787*Tstar);
252 16838318 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
253
254 // conversion from micro poise to Pa s
255 16838318 return mu/1e6 / 10;
256 }
257
258 /*!
259 * \brief Thermal conductivity \f$\mathrm{[[W/(m*K)]}\f$ of nitrogen.
260 *
261 * Isobaric Properties for Nitrogen and Oxygen in: NIST Standard
262 * Reference Database Number 69, Eds. P.J. Linstrom and
263 * W.G. Mallard evaluated at p=.1 MPa, does not
264 * change dramatically with p and can be interpolated linearly with temperature
265 *
266 * \param temperature absolute temperature in \f$\mathrm{[K]}\f$
267 * \param pressure of the phase in \f$\mathrm{[Pa]}\f$
268 */
269 static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
270 {
271 18067090 return 6.525e-5 * (temperature - 273.15) + 0.024031;
272 }
273 };
274
275 } // end namespace Components
276
277 } // end namespace Dumux
278
279 #endif
280