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  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 */
28 #ifndef OPM_CO2_HPP
29 #define OPM_CO2_HPP
30 
31 #include <opm/common/Exceptions.hpp>
32 #include <opm/common/ErrorMacros.hpp>
37 
38 #include <cmath>
39 #include <iostream>
40 
41 namespace Opm {
42 
53 template <class Scalar, class CO2Tables>
54 class CO2 : public Component<Scalar, CO2<Scalar, CO2Tables> >
55 {
56  static const Scalar R;
57  static bool warningPrinted;
58 
59 public:
63  static const char* name()
64  { return "CO2"; }
65 
69  static Scalar molarMass()
70  { return 44e-3; }
71 
75  static Scalar criticalTemperature()
76  { return 273.15 + 30.95; /* [K] */ }
77 
81  static Scalar criticalPressure()
82  { return 73.8e5; /* [N/m^2] */ }
83 
87  static Scalar tripleTemperature()
88  { return 273.15 - 56.35; /* [K] */ }
89 
93  static Scalar triplePressure()
94  { return 5.11e5; /* [N/m^2] */ }
95 
99  static Scalar minTabulatedPressure()
100  { return CO2Tables::tabulatedEnthalpy.minPress(); /* [N/m^2] */ }
101 
105  static Scalar maxTabulatedPressure()
106  { return CO2Tables::tabulatedEnthalpy.maxPress(); /* [N/m^2] */ }
107 
111  static Scalar minTabulatedTemperature()
112  { return CO2Tables::tabulatedEnthalpy.minTemp(); /* [N/m^2] */ }
113 
117  static Scalar maxTabulatedTemperature()
118  { return CO2Tables::tabulatedEnthalpy.maxTemp(); /* [N/m^2] */ }
119 
132  template <class Evaluation>
133  static Evaluation vaporPressure(const Evaluation& T)
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]*Opm::pow(1 - Tred, t[i]);
145  exponent *= 1.0/Tred;
146 
147  return Opm::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  const Scalar a0 = 0.235156;
205  const Scalar a1 = -0.491266;
206  const Scalar a2 = 5.211155e-2;
207  const Scalar a3 = 5.347906e-2;
208  const Scalar a4 = -1.537102e-2;
209 
210  const Scalar d11 = 0.4071119e-2;
211  const Scalar d21 = 0.7198037e-4;
212  const Scalar d64 = 0.2411697e-16;
213  const Scalar d81 = 0.2971072e-22;
214  const Scalar d82 = -0.1627888e-22;
215 
216  const Scalar ESP = 251.196;
217 
218  if(temperature < 275.) // regularization
219  temperature = 275.0;
220  Evaluation TStar = temperature/ESP;
221 
222  // mu0: viscosity in zero-density limit
223  const Evaluation& logTStar = Opm::log(TStar);
224  Evaluation SigmaStar = Opm::exp(a0 + logTStar*(a1 + logTStar*(a2 + logTStar*(a3 + logTStar*a4))));
225 
226  Evaluation mu0 = 1.00697*Opm::sqrt(temperature) / SigmaStar;
227 
228  const Evaluation& rho = gasDensity(temperature, pressure); // CO2 mass density [kg/m^3]
229 
230  // dmu : excess viscosity at elevated density
231  Evaluation dmu =
232  d11*rho
233  + d21*rho*rho
234  + d64*Opm::pow(rho, 6.0)/(TStar*TStar*TStar)
235  + d81*Opm::pow(rho, 8.0)
236  + d82*Opm::pow(rho, 8.0)/TStar;
237 
238  return (mu0 + dmu)/1.0e6; // conversion to [Pa s]
239  }
240 
251  template <class Evaluation>
252  static Evaluation gasHeatCapacity(const Evaluation& temperature, const Evaluation& pressure)
253  {
254  Scalar eps = 1e-6;
255 
256  // use central differences here because one-sided methods do
257  // not come with a performance improvement. (central ones are
258  // more accurate, though...)
259  const Evaluation& h1 = gasEnthalpy(temperature - eps, pressure);
260  const Evaluation& h2 = gasEnthalpy(temperature + eps, pressure);
261 
262  return (h2 - h1) / (2*eps) ;
263  }
264 };
265 
266 template <class Scalar, class CO2Tables>
267 bool CO2<Scalar, CO2Tables>::warningPrinted = false;
268 
269 template <class Scalar, class CO2Tables>
270 const Scalar CO2<Scalar, CO2Tables>::R = Constants<Scalar>::R;
271 
272 } // namespace Opm
273 
274 #endif
static Scalar triplePressure()
Returns the pressure [Pa] at CO2&#39;s triple point.
Definition: CO2.hpp:93
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
static Scalar minTabulatedTemperature()
Returns the pressure [Pa] at CO2&#39;s triple point.
Definition: CO2.hpp:111
Relations valid for an ideal gas.
static Scalar criticalTemperature()
Returns the critical temperature [K] of CO2.
Definition: CO2.hpp:75
Abstract base class of a pure chemical species.
Definition: Component.hpp:43
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of gaseous CO2 [J/kg].
Definition: CO2.hpp:167
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of CO2 [J/kg].
Definition: CO2.hpp:177
Definition: Air_Mesitylene.hpp:33
Abstract base class of a pure chemical species.
A class for the CO2 fluid properties.
Definition: CO2.hpp:54
static Scalar maxTabulatedTemperature()
Returns the pressure [Pa] at CO2&#39;s triple point.
Definition: CO2.hpp:117
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition: CO2.hpp:252
static const Scalar R
The ideal gas constant [J/(mol K)].
Definition: Constants.hpp:45
static Scalar criticalPressure()
Returns the critical pressure [Pa] of CO2.
Definition: CO2.hpp:81
static const char * name()
A human readable name for the CO2.
Definition: CO2.hpp:63
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure)
The dynamic viscosity [Pa s] of CO2.
Definition: CO2.hpp:202
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in [N/m^2] of pure CO2 at a given temperature.
Definition: CO2.hpp:133
static Scalar minTabulatedPressure()
Returns the pressure [Pa] at CO2&#39;s triple point.
Definition: CO2.hpp:99
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:69
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
A central place for various physical constants occuring in some equations.
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: CO2.hpp:160
static Scalar tripleTemperature()
Returns the temperature [K]at CO2&#39;s triple point.
Definition: CO2.hpp:87
static Scalar maxTabulatedPressure()
Returns the pressure [Pa] at CO2&#39;s triple point.
Definition: CO2.hpp:105
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: CO2.hpp:154