GCC Code Coverage Report


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