CO2.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) 2012-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef OPM_CO2_HPP
27 #define OPM_CO2_HPP
28 
29 #include <opm/common/Exceptions.hpp>
30 #include <opm/common/ErrorMacros.hpp>
35 
36 #include <cmath>
37 #include <iostream>
38 
39 namespace Opm {
40 
51 template <class Scalar, class CO2Tables>
52 class CO2 : public Component<Scalar, CO2<Scalar, CO2Tables> >
53 {
54  static const Scalar R;
55  static bool warningPrinted;
56 
57 public:
61  static const char *name()
62  { return "CO2"; }
63 
67  static Scalar molarMass()
68  { return 44e-3; }
69 
74  { return 273.15 + 30.95; /* [K] */ }
75 
80  { return 73.8e5; /* [N/m^2] */ }
81 
86  { return 273.15 - 56.35; /* [K] */ }
87 
92  { return 5.11e5; /* [N/m^2] */ }
93 
98  { return CO2Tables::tabulatedEnthalpy.minPress(); /* [N/m^2] */ }
99 
104  { return CO2Tables::tabulatedEnthalpy.maxPress(); /* [N/m^2] */ }
105 
110  { return CO2Tables::tabulatedEnthalpy.minTemp(); /* [N/m^2] */ }
111 
116  { return CO2Tables::tabulatedEnthalpy.maxTemp(); /* [N/m^2] */ }
117 
130  template <class Evaluation>
131  static Evaluation vaporPressure(const Evaluation& T)
132  {
133  typedef MathToolbox<Evaluation> Toolbox;
134 
135  static const Scalar a[4] =
136  { -7.0602087, 1.9391218, -1.6463597, -3.2995634 };
137  static const Scalar t[4] =
138  { 1.0, 1.5, 2.0, 4.0 };
139 
140  // this is on page 1524 of the reference
141  Evaluation exponent = 0;
142  Evaluation Tred = T/criticalTemperature();
143  for (int i = 0; i < 5; ++i)
144  exponent += a[i]*Toolbox::pow(1 - Tred, t[i]);
145  exponent *= 1.0/Tred;
146 
147  return Toolbox::exp(exponent)*criticalPressure();
148  }
149 
150 
154  static bool gasIsCompressible()
155  { return true; }
156 
160  static bool gasIsIdeal()
161  { return false; }
162 
166  template <class Evaluation>
167  static Evaluation gasEnthalpy(const Evaluation& temperature,
168  const Evaluation& pressure)
169  {
170  return CO2Tables::tabulatedEnthalpy.eval(temperature, pressure);
171  }
172 
176  template <class Evaluation>
177  static Evaluation gasInternalEnergy(const Evaluation& temperature,
178  const Evaluation& pressure)
179  {
180  const Evaluation& h = gasEnthalpy(temperature, pressure);
181  const Evaluation& rho = gasDensity(temperature, pressure);
182 
183  return h - (pressure / rho);
184  }
185 
189  template <class Evaluation>
190  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
191  {
192  return CO2Tables::tabulatedDensity.eval(temperature, pressure);
193  }
194 
201  template <class Evaluation>
202  static Evaluation gasViscosity(Evaluation temperature, const Evaluation& pressure)
203  {
204  typedef MathToolbox<Evaluation> Toolbox;
205 
206  const Scalar a0 = 0.235156;
207  const Scalar a1 = -0.491266;
208  const Scalar a2 = 5.211155e-2;
209  const Scalar a3 = 5.347906e-2;
210  const Scalar a4 = -1.537102e-2;
211 
212  const Scalar d11 = 0.4071119e-2;
213  const Scalar d21 = 0.7198037e-4;
214  const Scalar d64 = 0.2411697e-16;
215  const Scalar d81 = 0.2971072e-22;
216  const Scalar d82 = -0.1627888e-22;
217 
218  const Scalar ESP = 251.196;
219 
220  if(temperature < 275.) // regularization
221  temperature = Toolbox::createConstant(275.0);
222  Evaluation TStar = temperature/ESP;
223 
224  // mu0: viscosity in zero-density limit
225  const Evaluation& logTStar = Toolbox::log(TStar);
226  Evaluation SigmaStar = Toolbox::exp(a0 + logTStar*(a1 + logTStar*(a2 + logTStar*(a3 + logTStar*a4))));
227 
228  Evaluation mu0 = 1.00697*Toolbox::sqrt(temperature) / SigmaStar;
229 
230  const Evaluation& rho = gasDensity(temperature, pressure); // CO2 mass density [kg/m^3]
231 
232  // dmu : excess viscosity at elevated density
233  Evaluation dmu =
234  d11*rho
235  + d21*rho*rho
236  + d64*Toolbox::pow(rho, 6.0)/(TStar*TStar*TStar)
237  + d81*Toolbox::pow(rho, 8.0)
238  + d82*Toolbox::pow(rho, 8.0)/TStar;
239 
240  return (mu0 + dmu)/1.0e6; // conversion to [Pa s]
241  }
242 
253  template <class Evaluation>
254  static Evaluation gasHeatCapacity(const Evaluation& temperature, const Evaluation& pressure)
255  {
256  Scalar eps = 1e-6;
257 
258  // use central differences here because one-sided methods do
259  // not come with a performance improvement. (central ones are
260  // more accurate, though...)
261  const Evaluation& h1 = gasEnthalpy(temperature - eps, pressure);
262  const Evaluation& h2 = gasEnthalpy(temperature + eps, pressure);
263 
264  return (h2 - h1) / (2*eps) ;
265  }
266 };
267 
268 template <class Scalar, class CO2Tables>
269 bool CO2<Scalar, CO2Tables>::warningPrinted = false;
270 
271 template <class Scalar, class CO2Tables>
272 const Scalar CO2<Scalar, CO2Tables>::R = Constants<Scalar>::R;
273 
274 } // namespace Opm
275 
276 #endif
Abstract base class of a pure chemical species.
Definition: Component.hpp:42
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: CO2.hpp:160
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure)
The dynamic viscosity [Pa s] of CO2.
Definition: CO2.hpp:202
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of CO2 at a given pressure and temperature [kg/m^3].
Definition: CO2.hpp:190
Scalar Scalar
Definition: Component.hpp:45
Evaluation< Scalar, VarSetTag, numVars > sqrt(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:278
A class for the CO2 fluid properties.
Definition: CO2.hpp:52
static const char * name()
A human readable name for the CO2.
Definition: CO2.hpp:61
static Scalar minTabulatedPressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:97
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in [N/m^2] of pure CO2 at a given temperature.
Definition: CO2.hpp:131
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of gaseous CO2 [J/kg].
Definition: CO2.hpp:167
static Scalar criticalTemperature()
Returns the critical temperature [K] of CO2.
Definition: CO2.hpp:73
static Scalar triplePressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:91
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 gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition: CO2.hpp:254
static Scalar criticalPressure()
Returns the critical pressure [Pa] of CO2.
Definition: CO2.hpp:79
static Scalar minTabulatedTemperature()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:109
Relations valid for an ideal gas.
static Scalar maxTabulatedPressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:103
static Scalar tripleTemperature()
Returns the temperature [K]at CO2's triple point.
Definition: CO2.hpp:85
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:67
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 Scalar maxTabulatedTemperature()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:115
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: CO2.hpp:154
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of CO2 [J/kg].
Definition: CO2.hpp:177
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...