GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/n2.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 28 44 63.6%
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 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 #include <dumux/material/components/shomate.hh>
22
23 namespace Dumux {
24 namespace Components {
25
26 /*!
27 * \ingroup Components
28 * \brief Properties of pure molecular nitrogen \f$N_2\f$.
29 *
30 * \tparam Scalar The type used for scalar values
31 */
32 template <class Scalar>
33 class N2
34 : public Components::Base<Scalar, N2<Scalar> >
35 , public Components::Gas<Scalar, N2<Scalar> >
36 {
37 using IdealGas = Dumux::IdealGas<Scalar>;
38 using ShomateMethod = Dumux::ShomateMethod<Scalar, 3>; // 3 regions
39
40 public:
41 static const ShomateMethod shomateMethod;
42 /*!
43 * \brief A human readable name for nitrogen.
44 */
45 static std::string name()
46
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.
396 { return "N2"; }
47
48 /*!
49 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of molecular nitrogen.
50 */
51 static constexpr Scalar molarMass()
52 { return 28.0134e-3;}
53
54 /*!
55 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of molecular nitrogen
56 */
57 static Scalar criticalTemperature()
58 { return 126.192; /* [K] */ }
59
60 /*!
61 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of molecular nitrogen.
62 */
63 static Scalar criticalPressure()
64 { return 3.39858e6; /* [N/m^2] */ }
65
66 /*!
67 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at molecular nitrogen's triple point.
68 */
69 static Scalar tripleTemperature()
70 { return 63.151; /* [K] */ }
71
72 /*!
73 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at molecular nitrogen's triple point.
74 */
75 static Scalar triplePressure()
76 { return 12.523e3; /* [N/m^2] */ }
77
78 /*!
79 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure molecular nitrogen
80 * at a given temperature.
81 *
82 * \param T temperature of component in \f$\mathrm{[K]}\f$
83 *
84 * Taken from:
85 *
86 * R. Span, E.W. Lemmon, et al. (2000 ,pp. 1361-1433) \cite span2000
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; // N2 is solid: We don't take sublimation into
94 // account
95
96 // note: this is the ancillary equation given on page 1368
97 using std::sqrt;
98 Scalar sigma = Scalar(1.0) - T/criticalTemperature();
99 Scalar sqrtSigma = sqrt(sigma);
100 const Scalar N1 = -6.12445284;
101 const Scalar N2 = 1.26327220;
102 const Scalar N3 = -0.765910082;
103 const Scalar N4 = -1.77570564;
104
105 using std::exp;
106 return
107 criticalPressure() *
108 exp(criticalTemperature()/T*
109 (sigma*(N1 +
110 sqrtSigma*N2 +
111 sigma*(sqrtSigma*N3 +
112 sigma*sigma*sigma*N4))));
113 }
114
115 /*!
116 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of \f$N_2\f$ gas at a given pressure and temperature.
117 *
118 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
119 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
120 */
121 static Scalar gasDensity(Scalar temperature, Scalar pressure)
122 {
123 // Assume an ideal gas
124
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
23878580 return IdealGas::density(molarMass(), temperature, pressure);
125 }
126
127 /*!
128 * \brief The molar density of \f$N_2\f$ gas in \f$\mathrm{[mol/m^3]}\f$ at a given pressure and temperature.
129 *
130 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
131 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
132 *
133 */
134 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
135 23878354 { return IdealGas::molarDensity(temperature, pressure); }
136
137 /*!
138 * \brief Returns true if the gas phase is assumed to be compressible
139 */
140 static constexpr bool gasIsCompressible()
141 { return true; }
142
143 /*!
144 * \brief Returns true if the gas phase is assumed to be ideal
145 */
146 static constexpr bool gasIsIdeal()
147 { return true; }
148
149 /*!
150 * \brief The pressure of gaseous \f$N_2\f$ in \f$\mathrm{[Pa]}\f$ at a given density and temperature.
151 *
152 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
153 * \param density density of component in \f$\mathrm{[kg/m^3]}\f$
154 */
155 static Scalar gasPressure(Scalar temperature, Scalar density)
156 {
157 // Assume an ideal gas
158 18 return IdealGas::pressure(temperature, density/molarMass());
159 }
160
161 /*!
162 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure nitrogen gas.
163 * Shomate Equation is used for a temperature range of 100K to 6000K.
164 *
165 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
166 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
167 */
168 static const Scalar gasEnthalpy(Scalar temperature,
169 Scalar pressure)
170 {
171
1/2
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
21046182 const auto h = shomateMethod.enthalpy(temperature); // KJ/mol
172 21081474 return h * 1e3 / molarMass(); // J/kg
173 }
174
175 /*!
176 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of pure nitrogen gas.
177 *
178 * Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$.
179 *
180 * Rearranging for internal energy yields: \f$u = h - pv\f$.
181 *
182 * Exploiting the Ideal Gas assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$.
183 *
184 * The universal gas constant can only be used in the case of molar formulations.
185 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
186 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
187 */
188 static const Scalar gasInternalEnergy(Scalar temperature,
189 Scalar pressure)
190 {
191 return
192 gasEnthalpy(temperature, pressure) -
193 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
194 IdealGas::R*temperature; // = pressure * spec. volume for an ideal gas
195 }
196
197 /*!
198 * \brief Specific isobaric heat capacity \f$\mathrm{[J/(kg*K)]}\f$ of pure nitrogen gas.
199 * Shomate Equation is used for a temperature range of 100K to 6000K.
200 */
201 static const Scalar gasHeatCapacity(Scalar T,
202 Scalar pressure)
203 {
204
1/2
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
118 const auto cp = shomateMethod.heatCapacity(T); // J/(mol K)
205 118 return cp / molarMass(); // J/(kg K)
206 }
207
208 /*!
209 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of \f$N_2\f$ at a given pressure and temperature.
210 *
211 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
212 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
213 *
214 * See:
215 *
216 * See: R. Reid, et al.: The Properties of Gases and Liquids,
217 * 4th edition (1987, pp 396-397) \cite reid1987 <BR>
218 * 5th edition (2001, pp 9.7-9.8 (omega and V_c taken from p. A.19)) \cite poling2001
219 *
220 */
221 16801757 static Scalar gasViscosity(Scalar temperature, Scalar pressure)
222 {
223 16801757 const Scalar Tc = criticalTemperature();
224 16801757 const Scalar Vc = 90.1; // critical specific volume [cm^3/mol]
225 16801757 const Scalar omega = 0.037; // accentric factor
226 16801757 const Scalar M = molarMass() * 1e3; // molar mas [g/mol]
227 16801757 const Scalar dipole = 0.0; // dipole moment [debye]
228
229 using std::sqrt;
230 16801757 Scalar mu_r4 = 131.3 * dipole / sqrt(Vc * Tc);
231 16801757 mu_r4 *= mu_r4;
232 16801757 mu_r4 *= mu_r4;
233
234 using std::pow;
235 using std::exp;
236 16801757 Scalar Fc = 1 - 0.2756*omega + 0.059035*mu_r4;
237 16801757 Scalar Tstar = 1.2593 * temperature/Tc;
238 16801757 Scalar Omega_v =
239 33603514 1.16145*pow(Tstar, -0.14874) +
240 16801757 0.52487*exp(- 0.77320*Tstar) +
241 16801757 2.16178*exp(- 2.43787*Tstar);
242 16801757 Scalar mu = 40.785*Fc*sqrt(M*temperature)/(pow(Vc, 2./3)*Omega_v);
243
244 // conversion from micro poise to Pa s
245 16801757 return mu/1e6 / 10;
246 }
247
248 /*!
249 * \brief Thermal conductivity \f$\mathrm{[[W/(m*K)]}\f$ of nitrogen.
250 *
251 * Isobaric Properties for Nitrogen and Oxygen in: NIST Standard
252 * Reference Database Number 69, Eds. P.J. Linstrom and
253 * W.G. Mallard evaluated at p=.1 MPa, does not
254 * change dramatically with p and can be interpolated linearly with temperature
255 *
256 * \param temperature absolute temperature in \f$\mathrm{[K]}\f$
257 * \param pressure of the phase in \f$\mathrm{[Pa]}\f$
258 */
259 static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
260 {
261 18031377 return 6.525e-5 * (temperature - 273.15) + 0.024031;
262 }
263 };
264
265 /*!
266 * \brief Shomate parameters for nitrogen published by NIST \cite NIST
267 * https://webbook.nist.gov/cgi/cbook.cgi?ID=C7727379&Units=SI&Mask=1&Type=JANAFG&Table=on#JANAFG
268 * First row defines the temperature ranges, further rows give the parameters (A,B,C,D,E,F,G,H) for the respective temperature ranges.
269 */
270 template <class Scalar>
271 const typename N2<Scalar>::ShomateMethod N2<Scalar>::shomateMethod{
272 /*temperature*/{100.0,500.0,2000.0,6000.0},
273 typename N2<Scalar>::ShomateMethod::Coefficients{{
274 {28.98641, 1.853978, -9.647459, 16.63537, 0.000117, -8.671914, 226.4168, 0.0},
275 {19.50583, 19.88705, -8.598535, 1.369784, 0.527601, -4.935202, 212.39, 0.0},
276 {35.51872, 1.128728, -0.196103, 0.014662, -4.55376, -18.97091, 224.981, 0.0}
277 }}
278 };
279
280 } // end namespace Components
281 } // end namespace Dumux
282
283 #endif
284