My Project
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 
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 constexpr Scalar R = Constants<Scalar>::R;
55 
56 public:
60  static const char* name()
61  { return "CO2"; }
62 
66  static Scalar molarMass()
67  { return 44e-3; }
68 
72  static Scalar criticalTemperature()
73  { return 273.15 + 30.95; /* [K] */ }
74 
78  static Scalar criticalPressure()
79  { return 73.8e5; /* [N/m^2] */ }
80 
84  static Scalar tripleTemperature()
85  { return 273.15 - 56.35; /* [K] */ }
86 
90  static Scalar triplePressure()
91  { return 5.11e5; /* [N/m^2] */ }
92 
96  static Scalar minTabulatedPressure()
97  { return CO2Tables::tabulatedEnthalpy.minPress(); /* [N/m^2] */ }
98 
102  static Scalar maxTabulatedPressure()
103  { return CO2Tables::tabulatedEnthalpy.maxPress(); /* [N/m^2] */ }
104 
108  static Scalar minTabulatedTemperature()
109  { return CO2Tables::tabulatedEnthalpy.minTemp(); /* [N/m^2] */ }
110 
114  static Scalar maxTabulatedTemperature()
115  { return CO2Tables::tabulatedEnthalpy.maxTemp(); /* [N/m^2] */ }
116 
129  template <class Evaluation>
130  static Evaluation vaporPressure(const Evaluation& T)
131  {
132  static constexpr Scalar a[4] =
133  { -7.0602087, 1.9391218, -1.6463597, -3.2995634 };
134  static constexpr Scalar t[4] =
135  { 1.0, 1.5, 2.0, 4.0 };
136 
137  // this is on page 1524 of the reference
138  Evaluation exponent = 0;
139  Evaluation Tred = T/criticalTemperature();
140  for (int i = 0; i < 4; ++i)
141  exponent += a[i]*pow(1 - Tred, t[i]);
142  exponent *= 1.0/Tred;
143 
144  return exp(exponent)*criticalPressure();
145  }
146 
147 
151  static bool gasIsCompressible()
152  { return true; }
153 
157  static bool gasIsIdeal()
158  { return false; }
159 
163  template <class Evaluation>
164  static Evaluation gasEnthalpy(const Evaluation& temperature,
165  const Evaluation& pressure,
166  bool extrapolate = false)
167  {
168  return CO2Tables::tabulatedEnthalpy.eval(temperature, pressure, extrapolate);
169  }
170 
174  template <class Evaluation>
175  static Evaluation gasInternalEnergy(const Evaluation& temperature,
176  const Evaluation& pressure,
177  bool extrapolate = false)
178  {
179  const Evaluation h = gasEnthalpy(temperature, pressure, extrapolate);
180  const Evaluation rho = gasDensity(temperature, pressure, extrapolate);
181 
182  return h - (pressure / rho);
183  }
184 
188  template <class Evaluation>
189  static Evaluation gasDensity(const Evaluation& temperature,
190  const Evaluation& pressure,
191  bool extrapolate = false)
192  {
193  return CO2Tables::tabulatedDensity.eval(temperature, pressure, extrapolate);
194  }
195 
202  template <class Evaluation>
203  static Evaluation gasViscosity(Evaluation temperature,
204  const Evaluation& pressure,
205  bool extrapolate = false)
206  {
207  constexpr Scalar a0 = 0.235156;
208  constexpr Scalar a1 = -0.491266;
209  constexpr Scalar a2 = 5.211155e-2;
210  constexpr Scalar a3 = 5.347906e-2;
211  constexpr Scalar a4 = -1.537102e-2;
212 
213  constexpr Scalar d11 = 0.4071119e-2;
214  constexpr Scalar d21 = 0.7198037e-4;
215  constexpr Scalar d64 = 0.2411697e-16;
216  constexpr Scalar d81 = 0.2971072e-22;
217  constexpr Scalar d82 = -0.1627888e-22;
218 
219  constexpr Scalar ESP = 251.196;
220 
221  if(temperature < 275.) // regularization
222  temperature = 275.0;
223  Evaluation TStar = temperature/ESP;
224 
225  // mu0: viscosity in zero-density limit
226  const Evaluation logTStar = log(TStar);
227  Evaluation SigmaStar = exp(a0 + logTStar*(a1 + logTStar*(a2 + logTStar*(a3 + logTStar*a4))));
228 
229  Evaluation mu0 = 1.00697*sqrt(temperature) / SigmaStar;
230 
231  const Evaluation rho = gasDensity(temperature, pressure, extrapolate); // CO2 mass density [kg/m^3]
232 
233  // dmu : excess viscosity at elevated density
234  Evaluation dmu =
235  d11*rho
236  + d21*rho*rho
237  + d64*pow(rho, 6.0)/(TStar*TStar*TStar)
238  + d81*pow(rho, 8.0)
239  + d82*pow(rho, 8.0)/TStar;
240 
241  return (mu0 + dmu)/1.0e6; // conversion to [Pa s]
242  }
243 
254  template <class Evaluation>
255  static Evaluation gasHeatCapacity(const Evaluation& temperature, const Evaluation& pressure)
256  {
257  constexpr Scalar eps = 1e-6;
258 
259  // use central differences here because one-sided methods do
260  // not come with a performance improvement. (central ones are
261  // more accurate, though...)
262  const Evaluation h1 = gasEnthalpy(temperature - eps, pressure);
263  const Evaluation h2 = gasEnthalpy(temperature + eps, pressure);
264 
265  return (h2 - h1) / (2*eps) ;
266  }
267 };
268 
269 } // namespace Opm
270 
271 #endif
Abstract base class of a pure chemical species.
A central place for various physical constants occuring in some equations.
Relations valid for an ideal gas.
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
A class for the CO2 fluid properties.
Definition: CO2.hpp:53
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition: CO2.hpp:255
static Scalar minTabulatedPressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:96
static Scalar maxTabulatedTemperature()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:114
static Scalar minTabulatedTemperature()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:108
static Scalar criticalTemperature()
Returns the critical temperature [K] of CO2.
Definition: CO2.hpp:72
static const char * name()
A human readable name for the CO2.
Definition: CO2.hpp:60
static Scalar triplePressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:90
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:66
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in [N/m^2] of pure CO2 at a given temperature.
Definition: CO2.hpp:130
static Scalar maxTabulatedPressure()
Returns the pressure [Pa] at CO2's triple point.
Definition: CO2.hpp:102
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition: CO2.hpp:164
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition: CO2.hpp:203
static Scalar criticalPressure()
Returns the critical pressure [Pa] of CO2.
Definition: CO2.hpp:78
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: CO2.hpp:157
static Scalar tripleTemperature()
Returns the temperature [K]at CO2's triple point.
Definition: CO2.hpp:84
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition: CO2.hpp:175
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: CO2.hpp:151
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of CO2 at a given pressure and temperature [kg/m^3].
Definition: CO2.hpp:189
Abstract base class of a pure chemical species.
Definition: Component.hpp:42
A central place for various physical constants occuring in some equations.
Definition: Constants.hpp:41