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  Copyright (C) 2009-2013 by Andreas Lauser
5  Copyright (C) 2012 by Vishal Jambhekar
6  Copyright (C) 2010 by Felix Bode
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
22 */
27 #ifndef OPM_XYLENE_HPP
28 #define OPM_XYLENE_HPP
29 
33 
35 
36 #include <cmath>
37 
38 namespace Opm {
45 template <class Scalar>
46 class Xylene : public Component<Scalar, Xylene<Scalar> >
47 {
48  typedef Constants<Scalar> Consts;
50 
51 public:
55  static const char *name()
56  { return "xylene"; }
57 
61  static Scalar molarMass()
62  { return 0.106; }
63 
68  { return 617.1; }
69 
74  { return 35.4e5; }
75 
80  { OPM_THROW(std::runtime_error, "Not implemented: tripleTemperature for xylene"); }
81 
86  { OPM_THROW(std::runtime_error, "Not implemented: triplePressure for xylene"); }
87 
94  template <class Evaluation>
95  static Evaluation vaporPressure(const Evaluation& temperature)
96  {
97  typedef MathToolbox<Evaluation> Toolbox;
98 
99  const Scalar A = 7.00909;;
100  const Scalar B = 1462.266;;
101  const Scalar C = 215.110;;
102 
103  return 100*1.334*Toolbox::pow(10.0, (A - (B/(temperature - 273.15 + C))));
104  }
105 
114  template <class Evaluation>
115  static Evaluation spHeatCapLiquidPhase(const Evaluation& temperature, const Evaluation& /*pressure*/)
116  {
117  Evaluation CH3,C6H5,H;
118  // after Reid et al. : Missenard group contrib. method (s. example 5-8)
119  // Xylene: C9H12 : 3* CH3 ; 1* C6H5 (phenyl-ring) ; -2* H (this was too much!)
120  // linear interpolation between table values [J/(mol K)]
121 
122  if(temperature < 298.0){ // take care: extrapolation for Temperature<273
123  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
124  CH3 = 40.0 + 1.6*(temperature - 273.0)/25.0; // 40 + 1.6 = 41.6 = CH3(T=298K)
125  C6H5 = 113.0 + 4.2*(temperature - 273.0)/25.0; // 113 + 4.2 = 117.2 = C6H5(T=298K)
126  }
127  else if(temperature < 323.0){
128  H = 14.6 + 0.9*(temperature - 298.0)/25.0; // i.e. interpolation of table values 298<T<323
129  CH3 = 41.6 + 1.9*(temperature - 298.0)/25.0;
130  C6H5 = 117.2 + 6.2*(temperature - 298.0)/25.0;
131  }
132  else if(temperature < 348.0){
133  H = 15.5 + 1.2*(temperature - 323.0)/25.0; // i.e. interpolation of table values 323<T<348
134  CH3 = 43.5 + 2.3*(temperature - 323.0)/25.0;
135  C6H5 = 123.4 + 6.3*(temperature - 323.0)/25.0;
136  }
137  else {
138  H = 16.7 + 2.1*(temperature - 348.0)/25.0; // i.e. interpolation of table values 348<T<373
139  CH3 = 45.8 + 2.5*(temperature - 348.0)/25.0; // take care: extrapolation for Temperature>373
140  C6H5 = 129.7 + 6.3*(temperature - 348.0)/25.0; // most likely leads to underestimation
141  }
142 
143  return (C6H5 + 2*CH3 - H)/molarMass();// J/(mol K) -> J/(kg K)
144  }
145 
146 
150  template <class Evaluation>
151  static Evaluation liquidEnthalpy(const Evaluation& temperature, const Evaluation& pressure)
152  {
153  // Gauss quadrature rule:
154  // Interval: [0K; temperature (K)]
155  // Gauss-Legendre-Integration with variable transformation:
156  // \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 )
157  // with: n=2, legendre -> x_i = +/- \sqrt(1/3), \apha_i=1
158  // here: a=0, b=actual temperature in Kelvin
159  // \leadsto h(T) = \int_0^T c_p(T) dT
160  // \approx 0.5 T * (cp( (0.5-0.5*\sqrt(1/3)) T) + cp((0.5+0.5*\sqrt(1/3)) T))
161  // = 0.5 T * (cp(0.2113 T) + cp(0.7887 T) )
162 
163  // enthalpy may have arbitrary reference state, but the empirical/fitted heatCapacity function needs Kelvin as input
164  return 0.5*temperature*(spHeatCapLiquidPhase(0.2113*temperature,pressure)
165  + spHeatCapLiquidPhase(0.7887*temperature,pressure));
166  }
167 
172  { return 412.3; }
173 
182  template <class Evaluation>
183  static Evaluation heatVap(Evaluation temperature,
184  const Evaluation& /*pressure*/)
185  {
186  typedef MathToolbox<Evaluation> Toolbox;
187 
188  temperature = Toolbox::min(temperature, criticalTemperature()); // regularization
189  temperature = Toolbox::max(temperature, 0.0); // regularization
190 
191  const Scalar T_crit = criticalTemperature();
193  const Scalar p_crit = criticalPressure();
194 
195  // Chen method, eq. 7-11.4 (at boiling)
196  const Scalar DH_v_boil = Consts::R * T_crit * Tr1
197  * (3.978 * Tr1 - 3.958 + 1.555*std::log(p_crit * 1e-5 /*Pa->bar*/ ) )
198  / (1.07 - Tr1); /* [J/mol] */
199 
200  /* Variation with temperature according to Watson relation eq 7-12.1*/
201  const Evaluation& Tr2 = temperature/criticalTemperature();
202  const Scalar n = 0.375;
203  const Evaluation& DH_vap = DH_v_boil * Toolbox::pow(((1.0 - Tr2)/(1.0 - Tr1)), n);
204 
205  return (DH_vap/molarMass()); // we need [J/kg]
206  }
207 
214  template <class Evaluation>
215  static Evaluation gasEnthalpy(const Evaluation& temperature, const Evaluation& pressure)
216  {
217  return liquidEnthalpy(temperature, pressure) + heatVap(temperature, pressure);
218  }
219 
223  template <class Evaluation>
224  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
225  {
226  return IdealGas::density(Evaluation(molarMass()), temperature, pressure);
227  }
228 
235  template <class Evaluation>
236  static Evaluation molarGasDensity(const Evaluation& temperature, const Evaluation& pressure)
237  {
238  return gasDensity(temperature, pressure) / molarMass();
239  }
240 
250  template <class Evaluation>
251  static Evaluation molarLiquidDensity(Evaluation temperature, const Evaluation& /*pressure*/)
252  {
253  typedef MathToolbox<Evaluation> Toolbox;
254 
255  // saturated molar volume according to Lide, CRC Handbook of
256  // Thermophysical and Thermochemical Data, CRC Press, 1994
257  // valid for 245 < Temperature < 600
258  temperature = Toolbox::min(temperature, 500.0); // regularization
259  temperature = Toolbox::max(temperature, 250.0); // regularization
260 
261  const Scalar A1 = 0.25919; // from table
262  const Scalar A2 = 0.0014569; // from table
263  const Evaluation& expo = 1.0 + Toolbox::pow((1.0 - temperature/criticalTemperature()), (2.0/7.0));
264  return 1.0/(A2*Toolbox::pow(A1, expo));
265  }
266 
270  template <class Evaluation>
271  static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure)
272  { return molarLiquidDensity(temperature, pressure)*molarMass(); }
273 
277  static bool gasIsCompressible()
278  { return true; }
279 
283  static bool gasIsIdeal()
284  { return true; }
285 
289  static bool liquidIsCompressible()
290  { return false; }
291 
295  template <class Evaluation>
296  static Evaluation gasViscosity(Evaluation temperature, const Evaluation& /*pressure*/)
297  {
298  typedef MathToolbox<Evaluation> Toolbox;
299 
300  temperature = Toolbox::min(temperature, 500.0); // regularization
301  temperature = Toolbox::max(temperature, 250.0); // regularization
302 
303  const Evaluation& Tr = Toolbox::max(temperature/criticalTemperature(), 1e-10);
304  const Scalar Fp0 = 1.0;
305  const Scalar xi = 0.004623;
306  const Evaluation& eta_xi = Fp0*(0.807*Toolbox::pow(Tr, 0.618)
307  - 0.357*Toolbox::exp(-0.449*Tr)
308  + 0.34*Toolbox::exp(-4.058*Tr)
309  + 0.018);
310  return eta_xi/xi / 1e7; // [Pa s]
311  }
312 
316  template <class Evaluation>
317  static Evaluation liquidViscosity(Evaluation temperature, const Evaluation& /*pressure*/)
318  {
319  typedef MathToolbox<Evaluation> Toolbox;
320 
321  temperature = Toolbox::min(temperature, 500.0); // regularization
322  temperature = Toolbox::max(temperature, 250.0); // regularization
323 
324  const Scalar A = -3.82;
325  const Scalar B = 1027.0;
326  const Scalar C = -6.38e-4;
327  const Scalar D = 4.52e-7;
328 
329  return 1e-3*Toolbox::exp(A
330  + B/temperature
331  + C*temperature
332  + D*temperature*temperature); // in [cP]
333  }
334 };
335 
336 } // namespace Opm
337 
338 #endif
Abstract base class of a pure chemical species.
Definition: Component.hpp:42
static const Scalar R
The ideal gas constant [J/(mol K)].
Definition: Constants.hpp:44
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: Xylene.hpp:289
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
static Evaluation molarLiquidDensity(Evaluation temperature, const Evaluation &)
The molar density of pure xylene at a given pressure and temperature .
Definition: Xylene.hpp:251
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in liquid.
Definition: Xylene.hpp:151
Scalar Scalar
Definition: Component.hpp:45
static const char * name()
A human readable name for the xylene.
Definition: Xylene.hpp:55
static Scalar criticalTemperature()
Returns the critical temperature of xylene.
Definition: Xylene.hpp:67
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition: Xylene.hpp:215
Evaluation< Scalar, VarSetTag, numVars > max(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:114
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: Xylene.hpp:277
static Scalar criticalPressure()
Returns the critical pressure of xylene.
Definition: Xylene.hpp:73
static Scalar triplePressure()
Returns the pressure at xylene's triple point.
Definition: Xylene.hpp:85
A central place for various physical constants occuring in some equations.
Evaluation< Scalar, VarSetTag, numVars > log(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:369
Evaluation< Scalar, VarSetTag, numVars > exp(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:295
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:95
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:271
Evaluation< Scalar, VarSetTag, numVars > min(const Evaluation< Scalar, VarSetTag, numVars > &x1, const Evaluation< Scalar, VarSetTag, numVars > &x2)
Definition: Math.hpp:61
static Scalar molarMass()
The molar mass in of xylene.
Definition: Xylene.hpp:61
static Evaluation spHeatCapLiquidPhase(const Evaluation &temperature, const Evaluation &)
Specific heat cap of liquid xylene .
Definition: Xylene.hpp:115
static Evaluation liquidViscosity(Evaluation temperature, const Evaluation &)
The dynamic liquid viscosity of the pure component.
Definition: Xylene.hpp:317
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:224
Relations valid for an ideal gas.
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:296
static Scalar tripleTemperature()
Returns the temperature at xylene's triple point.
Definition: Xylene.hpp:79
Relations valid for an ideal gas.
Definition: IdealGas.hpp:35
Component for Xylene.
Definition: Xylene.hpp:46
Abstract base class of a pure chemical species.
Evaluation< Scalar, VarSetTag, numVars > pow(const Evaluation< Scalar, VarSetTag, numVars > &base, Scalar exp)
Definition: Math.hpp:312
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: Xylene.hpp:283
static 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:46
static Scalar boilingTemperature()
Returns the temperature at xylene's boiling point (1 atm).
Definition: Xylene.hpp:171
static Evaluation molarGasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of xylene gas at a given pressure and temperature.
Definition: Xylene.hpp:236
A central place for various physical constants occuring in some equations.
Definition: Constants.hpp:39
static Evaluation heatVap(Evaluation temperature, const Evaluation &)
Latent heat of vaporization for xylene .
Definition: Xylene.hpp:183
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...