GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/material/components/xylene.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 56 78 71.8%
Functions: 4 8 50.0%
Branches: 54 99 54.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-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 xylene.
11 */
12 #ifndef DUMUX_XYLENE_HH
13 #define DUMUX_XYLENE_HH
14
15 #include <cmath>
16 #include <dumux/material/idealgas.hh>
17 #include <dumux/material/constants.hh>
18
19 #include <dumux/material/components/base.hh>
20 #include <dumux/material/components/liquid.hh>
21 #include <dumux/material/components/gas.hh>
22
23 namespace Dumux {
24 namespace Components {
25
26 /*!
27 * \ingroup Components
28 * \brief Properties of xylene.
29 *
30 * \tparam Scalar The type used for scalar values
31 */
32 template <class Scalar>
33 class Xylene
34 : public Components::Base<Scalar, Xylene<Scalar> >
35 , public Components::Liquid<Scalar, Xylene<Scalar> >
36 , public Components::Gas<Scalar, Xylene<Scalar> >
37 {
38 using Consts = Constants<Scalar>;
39 using IdealGas = Dumux::IdealGas<Scalar>;
40
41 public:
42 /*!
43 * \brief A human readable name for the xylene
44 */
45 static std::string name()
46
34/66
✓ 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.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
32 { return "xylene"; }
47
48 /*!
49 * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of xylene
50 */
51 constexpr static Scalar molarMass()
52 { return 0.106; }
53
54 /*!
55 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of xylene
56 */
57 constexpr static Scalar criticalTemperature()
58 { return 617.1; }
59
60 /*!
61 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of xylene
62 */
63 constexpr static Scalar criticalPressure()
64 { return 35.4e5; }
65
66 /*!
67 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at xylene's boiling point (1 atm).
68 */
69 constexpr static Scalar boilingTemperature()
70 { return 412.3; }
71
72 /*!
73 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at xylene's triple point.
74 */
75 static Scalar tripleTemperature()
76 {
77 DUNE_THROW(Dune::NotImplemented, "tripleTemperature for xylene");
78 }
79
80 /*!
81 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at xylene's triple point.
82 */
83 static Scalar triplePressure()
84 {
85 DUNE_THROW(Dune::NotImplemented, "triplePressure for xylene");
86 }
87
88 /*!
89 * \brief The saturation vapor pressure in \f$\mathrm{[Pa]}\f$ of pure xylene
90 * at a given temperature according to Antoine after Betz 1997 -> Gmehling et al 1980 \cite gmehling1980 <BR>
91 *
92 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
93 */
94 static Scalar vaporPressure(Scalar temperature)
95 {
96 16483292 const Scalar A = 7.00909;
97 16483292 const Scalar B = 1462.266;
98 16483292 const Scalar C = 215.110;
99
100 16483292 Scalar T = temperature - 273.15;
101
102 using std::pow;
103 16483292 Scalar psat = 1.334*pow(10.0, (A - (B/(T + C)))); // in [mbar]
104
3/3
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6593315 times.
✓ Branch 2 taken 6593314 times.
16483292 psat *= 100.0; // in [Pa] (0.001*1.E5)
105
106 return psat;
107 }
108
109 /*!
110 * \brief Specific heat cap of liquid xylene \f$\mathrm{[J/kg]}\f$.
111 *
112 * source : Reid et al. (fourth edition): Missenard group contrib. method (chap 5-7, Table 5-11, s. example 5-8) \cite reid1987 <BR>
113 *
114 * \param temp temperature of component in \f$\mathrm{[K]}\f$
115 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
116 */
117 13187182 static Scalar liquidHeatCapacity(Scalar temp, Scalar pressure)
118 {
119 Scalar CH3,C6H5,H;
120 // after Reid et al. : Missenard group contrib. method (s. example 5-8) \cite reid1987 <BR>
121 // Xylene: C9H12 : 3* CH3 ; 1* C6H5 (phenyl-ring) ; -2* H (this was too much!)
122 // linear interpolation between table values [J/(mol K)]
123
124
2/2
✓ Branch 0 taken 13113087 times.
✓ Branch 1 taken 74095 times.
13187182 if(temp < 298.0){ // take care: extrapolation for Temp<273
125 13113087 H = 13.4 + 1.2*(temp - 273.0)/25.0; // 13.4 + 1.2 = 14.6 = H(T=298K) i.e. interpolation of table values 273<T<298
126 13113087 CH3 = 40.0 + 1.6*(temp - 273.0)/25.0; // 40 + 1.6 = 41.6 = CH3(T=298K)
127 13113087 C6H5 = 113.0 + 4.2*(temp - 273.0)/25.0; // 113 + 4.2 = 117.2 = C6H5(T=298K)
128 }
129
2/2
✓ Branch 0 taken 19754 times.
✓ Branch 1 taken 54341 times.
74095 else if(temp < 323.0){
130 19754 H = 14.6 + 0.9*(temp - 298.0)/25.0; // i.e. interpolation of table values 298<T<323
131 19754 CH3 = 41.6 + 1.9*(temp - 298.0)/25.0;
132 19754 C6H5 = 117.2 + 6.2*(temp - 298.0)/25.0;
133 }
134
2/2
✓ Branch 0 taken 43207 times.
✓ Branch 1 taken 11134 times.
54341 else if(temp < 348.0){
135 43207 H = 15.5 + 1.2*(temp - 323.0)/25.0; // i.e. interpolation of table values 323<T<348
136 43207 CH3 = 43.5 + 2.3*(temp - 323.0)/25.0;
137 43207 C6H5 = 123.4 + 6.3*(temp - 323.0)/25.0;
138 }
139 else {
140 11134 H = 16.7 + 2.1*(temp - 348.0)/25.0; // i.e. interpolation of table values 348<T<373
141 11134 CH3 = 45.8 + 2.5*(temp - 348.0)/25.0; // take care: extrapolation for Temp>373
142 11134 C6H5 = 129.7 + 6.3*(temp - 348.0)/25.0; // most likely leads to underestimation
143 }
144
145 13187182 return (C6H5 + 2*CH3 - H)/molarMass();// J/(mol K) -> J/(kg K)
146 }
147
148
149 /*!
150 * \brief Specific enthalpy of liquid xylene \f$\mathrm{[J/kg]}\f$.
151 *
152 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
153 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
154 */
155 6593536 static Scalar liquidEnthalpy(const Scalar temperature,
156 const Scalar pressure)
157 {
158 // Gauss quadrature rule:
159 // Interval: [0K; temperature (K)]
160 // Gauss-Legendre-Integration with variable transformation:
161 // \int_a^b f(T) dT \approx (b-a)/2 \sum_i=1^n \alpha_i f( (b-a)/2 x_i + (a+b)/2 )
162 // with: n=2, legendre -> x_i = +/- \sqrt(1/3), \apha_i=1
163 // here: a=273.15K, b=actual temperature in Kelvin
164 // \leadsto h(T) = \int_273.15^T c_p(T) dT
165 // \approx 0.5 (T-273.15) * (cp( 0.5(temperature-273.15)sqrt(1/3) ) + cp(0.5(temperature-273.15)(-1)sqrt(1/3))
166
167 // Enthalpy may have arbitrary reference state, but the empirical/fitted heatCapacity function needs Kelvin as input and is
168 // fit over a certain temperature range. This suggests choosing an interval of integration being in the actual fit range.
169 // I.e. choosing T=273.15K as reference point for liquid enthalpy.
170 using std::sqrt;
171 6593536 const Scalar sqrt1over3 = sqrt(1./3.);
172 // evaluation points according to Gauss-Legendre integration
173 6593536 const Scalar TEval1 = 0.5*(temperature-273.15)* sqrt1over3 + 0.5*(273.15+temperature);
174 // evaluation points according to Gauss-Legendre integration
175 6593536 const Scalar TEval2 = 0.5*(temperature-273.15)* (-1)* sqrt1over3 + 0.5*(273.15+temperature);
176
177 6593536 const Scalar h_n = 0.5 * (temperature-273.15) * ( liquidHeatCapacity(TEval1, pressure) + liquidHeatCapacity(TEval2, pressure) );
178
179 6593536 return h_n;
180 }
181
182 /*!
183 * \brief Latent heat of vaporization for xylene \f$\mathrm{[J/kg]}\f$.
184 *
185 * source : Reid et al. (fourth edition): Chen method (chap. 7-11, Delta H_v = Delta H_v (T) according to chap. 7-12) \cite reid1987
186 *
187 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
188 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
189 */
190 static Scalar heatVap(Scalar temperature,
191 const Scalar pressure)
192 {
193 using std::min;
194 using std::max;
195 temperature = min(temperature, criticalTemperature()); // regularization
196 temperature = max(temperature, 0.0); // regularization
197
198 constexpr Scalar T_crit = criticalTemperature();
199 constexpr Scalar Tr1 = boilingTemperature()/criticalTemperature();
200 constexpr Scalar p_crit = criticalPressure();
201
202 // Chen method, eq. 7-11.4 (at boiling)
203 using std::log;
204 const Scalar DH_v_boil = Consts::R * T_crit * Tr1
205 * (3.978 * Tr1 - 3.958 + 1.555*log(p_crit * 1e-5 /*Pa->bar*/ ) )
206 / (1.07 - Tr1); /* [J/mol] */
207
208 /* Variation with temp according to Watson relation eq 7-12.1*/
209 using std::pow;
210 const Scalar Tr2 = temperature/criticalTemperature();
211 const Scalar n = 0.375;
212 const Scalar DH_vap = DH_v_boil * pow(((1.0 - Tr2)/(1.0 - Tr1)), n);
213
214 return (DH_vap/molarMass()); // we need [J/kg]
215 }
216
217 /*!
218 * \brief Specific enthalpy of xylene vapor \f$\mathrm{[J/kg]}\f$.
219 *
220 * This relation is true on the vapor pressure curve, i.e. as long
221 * as there is a liquid phase present.
222 *
223 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
224 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
225 */
226 static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
227 {
228 3296768 return liquidEnthalpy(temperature, pressure) + heatVap(temperature, pressure);
229 }
230
231 /*!
232 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of xylene gas at a given pressure and temperature.
233 *
234 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
235 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
236 */
237 static Scalar gasDensity(Scalar temperature, Scalar pressure)
238 {
239
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
6593542 return IdealGas::density(molarMass(),
240 temperature,
241 pressure);
242 }
243
244 /*!
245 * \brief The molar gas density \f$\mathrm{[mol/m^3]}\f$ of xylene gas at a given pressure and temperature.
246 *
247 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
248 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
249 */
250 static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
251 6593316 { return IdealGas::molarDensity(temperature, pressure); }
252
253 /*!
254 * \brief The molar liquid density of pure xylene at a given pressure and temperature
255 * \f$\mathrm{[mol/m^3]}\f$.
256 *
257 * source : Reid et al. (fourth edition): Modified Racket technique (chap. 3-11, eq. 3-11.9) \cite reid1987 <BR>
258 *
259 * \param temp temperature of component in \f$\mathrm{[K]}\f$
260 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
261 */
262 static Scalar liquidMolarDensity(Scalar temp, Scalar pressure)
263 {
264 // saturated molar volume according to Lide, CRC Handbook of
265 // Thermophysical and Thermochemical Data, CRC Press, 1994
266 // valid for 245 < Temp < 600
267 using std::min;
268 using std::max;
269 temp = min(temp, 500.0); // regularization
270 temp = max(temp, 250.0); // regularization
271
272 using std::pow;
273 const Scalar A1 = 0.25919; // from table
274 const Scalar A2 = 0.0014569; // from table
275 const Scalar expo = 1.0 + pow((1.0 - temp/criticalTemperature()), (2.0/7.0));
276 const Scalar V = A2*pow(A1, expo); // liquid molar volume [m^3/mol]
277
278 return 1.0/V; // molar density [mol/m^3]
279 }
280
281 /*!
282 * \brief The density of pure xylene at a given pressure and temperature \f$\mathrm{[kg/m^3]}\f$.
283 *
284 * \param temperature temperature of component in \f$\mathrm{[K]}\f$
285 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
286 */
287 static Scalar liquidDensity(Scalar temperature, Scalar pressure)
288 {
289
2/2
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 2 times.
3296772 return liquidMolarDensity(temperature, pressure)*molarMass();
290 }
291
292 /*!
293 * \brief Returns true if the gas phase is assumed to be compressible
294 */
295 static constexpr bool gasIsCompressible()
296 { return true; }
297
298 /*!
299 * \brief Returns true if the gas phase is assumed to be ideal
300 */
301 static constexpr bool gasIsIdeal()
302 { return true; }
303
304 /*!
305 * \brief Returns true if the liquid phase is assumed to be compressible
306 */
307 static constexpr bool liquidIsCompressible()
308 { return false; }
309
310 /*!
311 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of xylene vapor
312 *
313 * \param temp temperature of component in \f$\mathrm{[K]}\f$
314 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
315 */
316 3296768 static Scalar gasViscosity(Scalar temp, Scalar pressure)
317 {
318 using std::min;
319 using std::max;
320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296768 times.
3296768 temp = min(temp, 500.0); // regularization
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296768 times.
3296768 temp = max(temp, 250.0); // regularization
322
323 using std::pow;
324 using std::exp;
325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296768 times.
3296768 const Scalar Tr = max(temp/criticalTemperature(), 1e-10);
326 3296768 const Scalar Fp0 = 1.0;
327 3296768 const Scalar xi = 0.004623;
328 6593536 const Scalar eta_xi = Fp0*(0.807*pow(Tr, 0.618)
329 3296768 - 0.357*exp(-0.449*Tr)
330 3296768 + 0.34*exp(-4.058*Tr)
331 + 0.018);
332 3296768 Scalar r = eta_xi/xi; // [1e-6 P]
333 3296768 r /= 1.0e7; // [Pa s]
334
335 3296768 return r;
336 }
337
338 /*!
339 * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of pure xylene.
340 *
341 * \param temp temperature of component in \f$\mathrm{[K]}\f$
342 * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$
343 */
344 3296768 static Scalar liquidViscosity(Scalar temp, Scalar pressure)
345 {
346 using std::min;
347 using std::max;
348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296768 times.
3296768 temp = min(temp, 500.0); // regularization
349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296768 times.
3296768 temp = max(temp, 250.0); // regularization
350
351 3296768 const Scalar A = -3.82;
352 3296768 const Scalar B = 1027.0;
353 3296768 const Scalar C = -6.38e-4;
354 3296768 const Scalar D = 4.52e-7;
355
356 using std::exp;
357 3296768 Scalar r = exp(A + B/temp + C*temp + D*temp*temp); // in [cP]
358 3296768 r *= 1.0e-3; // in [Pa s]
359
360 3296768 return r; // [Pa s]
361 }
362
363 /*!
364 * \brief Thermal conductivity \f$\mathrm{[[W/(m*K)]}\f$ of xylene
365 *
366 * Thermal Conductivity of p-Xylene taken from the Dortmund Data Bank, see:
367 * http://www.ddbst.de/en/EED/PCP/TCN_C176.php
368 *
369 * \param temperature absolute temperature in \f$\mathrm{[K]}\f$
370 * \param pressure of the phase in \f$\mathrm{[Pa]}\f$
371 */
372 static Scalar liquidThermalConductivity( Scalar temperature, Scalar pressure)
373 {
374 return 0.13;
375 }
376 };
377
378 } // end namespace Components
379
380 } // end namespace Dumux
381
382 #endif
383