opm-common
Xylene.hpp
Go to the documentation of this file.
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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef OPM_XYLENE_HPP
28 #define OPM_XYLENE_HPP
29 
33 
35 
36 #include <cmath>
37 #include <string_view>
38 
39 namespace Opm {
46 template <class Scalar>
47 class Xylene : public Component<Scalar, Xylene<Scalar> >
48 {
49  typedef Constants<Scalar> Consts;
50  typedef ::Opm::IdealGas<Scalar> IdealGas;
51 
52 public:
56  static std::string_view name()
57  { return "xylene"; }
58 
62  static Scalar molarMass()
63  { return 0.106; }
64 
68  static Scalar criticalTemperature()
69  { return 617.1; }
70 
74  static Scalar criticalPressure()
75  { return 35.4e5; }
76 
80  static Scalar tripleTemperature()
81  { throw std::runtime_error("Not implemented: tripleTemperature for xylene"); }
82 
86  static Scalar triplePressure()
87  { throw std::runtime_error("Not implemented: triplePressure for xylene"); }
88 
95  template <class Evaluation>
96  static Evaluation vaporPressure(const Evaluation& temperature)
97  {
98  const Scalar A = 7.00909;;
99  const Scalar B = 1462.266;;
100  const Scalar C = 215.110;;
101 
102  return 100*1.334*pow(10.0, (A - (B/(temperature - 273.15 + C))));
103  }
104 
113  template <class Evaluation>
114  static Evaluation spHeatCapLiquidPhase(const Evaluation& temperature, const Evaluation& /*pressure*/)
115  {
116  Evaluation CH3,C6H5,H;
117  // after Reid et al. : Missenard group contrib. method (s. example 5-8)
118  // Xylene: C9H12 : 3* CH3 ; 1* C6H5 (phenyl-ring) ; -2* H (this was too much!)
119  // linear interpolation between table values [J/(mol K)]
120 
121  if(temperature < 298.0){ // take care: extrapolation for Temperature<273
122  H = 13.4 + 1.2*(temperature - 273.0)/25.0; // 13.4 + 1.2 = 14.6 = H(T=298K) i.e. interpolation of table values 273<T<298
123  CH3 = 40.0 + 1.6*(temperature - 273.0)/25.0; // 40 + 1.6 = 41.6 = CH3(T=298K)
124  C6H5 = 113.0 + 4.2*(temperature - 273.0)/25.0; // 113 + 4.2 = 117.2 = C6H5(T=298K)
125  }
126  else if(temperature < 323.0){
127  H = 14.6 + 0.9*(temperature - 298.0)/25.0; // i.e. interpolation of table values 298<T<323
128  CH3 = 41.6 + 1.9*(temperature - 298.0)/25.0;
129  C6H5 = 117.2 + 6.2*(temperature - 298.0)/25.0;
130  }
131  else if(temperature < 348.0){
132  H = 15.5 + 1.2*(temperature - 323.0)/25.0; // i.e. interpolation of table values 323<T<348
133  CH3 = 43.5 + 2.3*(temperature - 323.0)/25.0;
134  C6H5 = 123.4 + 6.3*(temperature - 323.0)/25.0;
135  }
136  else {
137  H = 16.7 + 2.1*(temperature - 348.0)/25.0; // i.e. interpolation of table values 348<T<373
138  CH3 = 45.8 + 2.5*(temperature - 348.0)/25.0; // take care: extrapolation for Temperature>373
139  C6H5 = 129.7 + 6.3*(temperature - 348.0)/25.0; // most likely leads to underestimation
140  }
141 
142  return (C6H5 + 2*CH3 - H)/molarMass();// J/(mol K) -> J/(kg K)
143  }
144 
145 
149  template <class Evaluation>
150  static Evaluation liquidEnthalpy(const Evaluation& temperature, const Evaluation& pressure)
151  {
152  // Gauss quadrature rule:
153  // Interval: [0K; temperature (K)]
154  // Gauss-Legendre-Integration with variable transformation:
155  // \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 )
156  // with: n=2, legendre -> x_i = +/- \sqrt(1/3), \apha_i=1
157  // here: a=0, b=actual temperature in Kelvin
158  // \leadsto h(T) = \int_0^T c_p(T) dT
159  // \approx 0.5 T * (cp( (0.5-0.5*\sqrt(1/3)) T) + cp((0.5+0.5*\sqrt(1/3)) T))
160  // = 0.5 T * (cp(0.2113 T) + cp(0.7887 T) )
161 
162  // enthalpy may have arbitrary reference state, but the empirical/fitted heatCapacity function needs Kelvin as input
163  return 0.5*temperature*(spHeatCapLiquidPhase(Evaluation(0.2113*temperature),pressure)
164  + spHeatCapLiquidPhase(Evaluation(0.7887*temperature),pressure));
165  }
166 
170  static Scalar boilingTemperature()
171  { return 412.3; }
172 
181  template <class Evaluation>
182  static Evaluation heatVap(Evaluation temperature,
183  const Evaluation& /*pressure*/)
184  {
185  temperature = min(temperature, criticalTemperature()); // regularization
186  temperature = max(temperature, 0.0); // regularization
187 
188  const Scalar T_crit = criticalTemperature();
189  const Scalar Tr1 = boilingTemperature()/criticalTemperature();
190  const Scalar p_crit = criticalPressure();
191 
192  // Chen method, eq. 7-11.4 (at boiling)
193  const Scalar DH_v_boil = Consts::R * T_crit * Tr1
194  * (3.978 * Tr1 - 3.958 + 1.555*std::log(p_crit * 1e-5 /*Pa->bar*/ ) )
195  / (1.07 - Tr1); /* [J/mol] */
196 
197  /* Variation with temperature according to Watson relation eq 7-12.1*/
198  const Evaluation& Tr2 = temperature/criticalTemperature();
199  const Scalar n = 0.375;
200  const Evaluation& DH_vap = DH_v_boil * pow(((1.0 - Tr2)/(1.0 - Tr1)), n);
201 
202  return (DH_vap/molarMass()); // we need [J/kg]
203  }
204 
211  template <class Evaluation>
212  static Evaluation gasEnthalpy(const Evaluation& temperature, const Evaluation& pressure)
213  {
214  return liquidEnthalpy(temperature, pressure) + heatVap(temperature, pressure);
215  }
216 
220  template <class Evaluation>
221  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
222  {
223  return IdealGas::density(Evaluation(molarMass()), temperature, pressure);
224  }
225 
232  template <class Evaluation>
233  static Evaluation molarGasDensity(const Evaluation& temperature, const Evaluation& pressure)
234  {
235  return gasDensity(temperature, pressure) / molarMass();
236  }
237 
247  template <class Evaluation>
248  static Evaluation molarLiquidDensity(Evaluation temperature, const Evaluation& /*pressure*/)
249  {
250  // saturated molar volume according to Lide, CRC Handbook of
251  // Thermophysical and Thermochemical Data, CRC Press, 1994
252  // valid for 245 < Temperature < 600
253  temperature = min(temperature, 500.0); // regularization
254  temperature = max(temperature, 250.0); // regularization
255 
256  const Scalar A1 = 0.25919; // from table
257  const Scalar A2 = 0.0014569; // from table
258  const Evaluation& expo = 1.0 + pow((1.0 - temperature/criticalTemperature()), (2.0/7.0));
259  return 1.0/(A2*pow(A1, expo));
260  }
261 
265  template <class Evaluation>
266  static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure)
267  { return molarLiquidDensity(temperature, pressure)*molarMass(); }
268 
272  static bool gasIsCompressible()
273  { return true; }
274 
278  static bool gasIsIdeal()
279  { return true; }
280 
284  static bool liquidIsCompressible()
285  { return false; }
286 
290  template <class Evaluation>
291  static Evaluation gasViscosity(Evaluation temperature, const Evaluation& /*pressure*/)
292  {
293  temperature = min(temperature, 500.0); // regularization
294  temperature = max(temperature, 250.0); // regularization
295 
296  const Evaluation& Tr = max(temperature/criticalTemperature(), 1e-10);
297  const Scalar Fp0 = 1.0;
298  const Scalar xi = 0.004623;
299  const Evaluation& eta_xi = Fp0*(0.807*pow(Tr, 0.618)
300  - 0.357*exp(-0.449*Tr)
301  + 0.34*exp(-4.058*Tr)
302  + 0.018);
303  return eta_xi/xi / 1e7; // [Pa s]
304  }
305 
309  template <class Evaluation>
310  static Evaluation liquidViscosity(Evaluation temperature, const Evaluation& /*pressure*/)
311  {
312  temperature = min(temperature, 500.0); // regularization
313  temperature = max(temperature, 250.0); // regularization
314 
315  const Scalar A = -3.82;
316  const Scalar B = 1027.0;
317  const Scalar C = -6.38e-4;
318  const Scalar D = 4.52e-7;
319 
320  return 1e-3*exp(A
321  + B/temperature
322  + C*temperature
323  + D*temperature*temperature); // in [cP]
324  }
325 };
326 
327 } // namespace Opm
328 
329 #endif
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: Xylene.hpp:272
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: Xylene.hpp:278
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
static Scalar criticalTemperature()
Returns the critical temperature of xylene.
Definition: Xylene.hpp:68
Relations valid for an ideal gas.
Abstract base class of a pure chemical species.
Definition: Component.hpp:43
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition: Xylene.hpp:212
static Evaluation vaporPressure(const Evaluation &temperature)
The saturation vapor pressure in of pure xylene at a given temperature according to Antoine after Be...
Definition: Xylene.hpp:96
static Scalar criticalPressure()
Returns the critical pressure of xylene.
Definition: Xylene.hpp:74
static Evaluation spHeatCapLiquidPhase(const Evaluation &temperature, const Evaluation &)
Specific heat cap of liquid xylene .
Definition: Xylene.hpp:114
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density in of the component at a given pressure in and temperature in .
Definition: Xylene.hpp:221
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &)
The dynamic viscosity of the pure component at a given pressure in and temperature in ...
Definition: Xylene.hpp:291
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in liquid.
Definition: Xylene.hpp:150
static Scalar boilingTemperature()
Returns the temperature at xylene&#39;s boiling point (1 atm).
Definition: Xylene.hpp:170
static Scalar tripleTemperature()
Returns the temperature at xylene&#39;s triple point.
Definition: Xylene.hpp:80
Definition: Constants.hpp:41
Abstract base class of a pure chemical species.
static constexpr Scalar R
The ideal gas constant [J/(mol K)].
Definition: Constants.hpp:47
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: Xylene.hpp:284
Relations valid for an ideal gas.
Definition: IdealGas.hpp:38
static std::string_view name()
A human readable name for the xylene.
Definition: Xylene.hpp:56
static Evaluation liquidViscosity(Evaluation temperature, const Evaluation &)
The dynamic liquid viscosity of the pure component.
Definition: Xylene.hpp:310
static Evaluation molarLiquidDensity(Evaluation temperature, const Evaluation &)
The molar density of pure xylene at a given pressure and temperature .
Definition: Xylene.hpp:248
static Scalar molarMass()
The molar mass in of xylene.
Definition: Xylene.hpp:62
static Evaluation heatVap(Evaluation temperature, const Evaluation &)
Latent heat of vaporization for xylene .
Definition: Xylene.hpp:182
Component for Xylene.
Definition: Xylene.hpp:47
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of the liquid component at a given pressure in and temperature in . ...
Definition: Xylene.hpp:266
static OPM_HOST_DEVICE Evaluation density(const Evaluation &avgMolarMass, const Evaluation &temperature, const Evaluation &pressure)
The density of the gas in , depending on pressure, temperature and average molar mass of the gas...
Definition: IdealGas.hpp:49
static Scalar triplePressure()
Returns the pressure at xylene&#39;s triple point.
Definition: Xylene.hpp:86
static Evaluation molarGasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of xylene gas at a given pressure and temperature.
Definition: Xylene.hpp:233