GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/components/mesitylene.hh
Date: 2025-04-19 19:19:10
Exec Total Coverage
Lines: 72 76 94.7%
Functions: 7 7 100.0%
Branches: 48 84 57.1%

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