My Project
Loading...
Searching...
No Matches
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#include <opm/common/TimingMacros.hpp>
36
37#include <cmath>
38#include <string_view>
39
40namespace Opm {
41
52template <class Scalar>
53class CO2 : public Component<Scalar, CO2<Scalar>>
54{
55 static constexpr Scalar R = Constants<Scalar>::R;
56 static const UniformTabulated2DFunction<double>& tabulatedEnthalpy;
57 static const UniformTabulated2DFunction<double>& tabulatedDensity;
58
59public:
60 static const Scalar brineSalinity;
61
65 static std::string_view name()
66 { return "CO2"; }
67
71 static Scalar molarMass()
72 { return 44e-3; }
73
77 static Scalar criticalTemperature()
78 { return 273.15 + 30.95; /* [K] */ }
79
83 static Scalar criticalPressure()
84 { return 73.8e5; /* [N/m^2] */ }
85
89 static Scalar tripleTemperature()
90 { return 273.15 - 56.35; /* [K] */ }
91
95 static Scalar triplePressure()
96 { return 5.11e5; /* [N/m^2] */ }
97
101// static Scalar minTabulatedPressure()
102// { return tabulatedEnthalpy.minPress(); /* [N/m^2] */ }
103
107// static Scalar maxTabulatedPressure()
108// { return tabulatedEnthalpy.maxPress(); /* [N/m^2] */ }
109
113// static Scalar minTabulatedTemperature()
114// { return tabulatedEnthalpy.minTemp(); /* [N/m^2] */ }
115
119// static Scalar maxTabulatedTemperature()
120// { return tabulatedEnthalpy.maxTemp(); /* [N/m^2] */ }
121
134 template <class Evaluation>
135 static Evaluation vaporPressure(const Evaluation& T)
136 {
137 static constexpr Scalar a[4] =
138 { -7.0602087, 1.9391218, -1.6463597, -3.2995634 };
139 static constexpr Scalar t[4] =
140 { 1.0, 1.5, 2.0, 4.0 };
141
142 // this is on page 1524 of the reference
143 Evaluation exponent = 0;
144 Evaluation Tred = T/criticalTemperature();
145 for (int i = 0; i < 4; ++i)
146 exponent += a[i]*pow(1 - Tred, t[i]);
147 exponent *= 1.0/Tred;
148
149 return exp(exponent)*criticalPressure();
150 }
151
152
156 static bool gasIsCompressible()
157 { return true; }
158
162 static bool gasIsIdeal()
163 { return false; }
164
168 template <class Evaluation>
169 static Evaluation gasEnthalpy(const Evaluation& temperature,
170 const Evaluation& pressure,
171 bool extrapolate = false)
172 {
173 return tabulatedEnthalpy.eval(temperature, pressure, extrapolate);
174 }
175
179 template <class Evaluation>
180 static Evaluation gasInternalEnergy(const Evaluation& temperature,
181 const Evaluation& pressure,
182 bool extrapolate = false)
183 {
184 const Evaluation h = gasEnthalpy(temperature, pressure, extrapolate);
185 const Evaluation rho = gasDensity(temperature, pressure, extrapolate);
186
187 return h - (pressure / rho);
188 }
189
193 template <class Evaluation>
194 static Evaluation gasDensity(const Evaluation& temperature,
195 const Evaluation& pressure,
196 bool extrapolate = false)
197 {
198 return tabulatedDensity.eval(temperature, pressure, extrapolate);
199 }
200
207 template <class Evaluation>
208 static Evaluation gasViscosity(Evaluation temperature,
209 const Evaluation& pressure,
210 bool extrapolate = false)
211 {
212 OPM_TIMEFUNCTION_LOCAL();
213 constexpr Scalar a0 = 0.235156;
214 constexpr Scalar a1 = -0.491266;
215 constexpr Scalar a2 = 5.211155e-2;
216 constexpr Scalar a3 = 5.347906e-2;
217 constexpr Scalar a4 = -1.537102e-2;
218
219 constexpr Scalar d11 = 0.4071119e-2;
220 constexpr Scalar d21 = 0.7198037e-4;
221 constexpr Scalar d64 = 0.2411697e-16;
222 constexpr Scalar d81 = 0.2971072e-22;
223 constexpr Scalar d82 = -0.1627888e-22;
224
225 constexpr Scalar ESP = 251.196;
226
227 if(temperature < 275.) // regularization
228 temperature = 275.0;
229 Evaluation TStar = temperature/ESP;
230
231 // mu0: viscosity in zero-density limit
232 const Evaluation logTStar = log(TStar);
233 Evaluation SigmaStar = exp(a0 + logTStar*(a1 + logTStar*(a2 + logTStar*(a3 + logTStar*a4))));
234
235 Evaluation mu0 = 1.00697*sqrt(temperature) / SigmaStar;
236
237 const Evaluation rho = gasDensity(temperature, pressure, extrapolate); // CO2 mass density [kg/m^3]
238
239 // dmu : excess viscosity at elevated density
240 Evaluation dmu =
241 d11*rho
242 + d21*rho*rho
243 + d64*pow(rho, 6.0)/(TStar*TStar*TStar)
244 + d81*pow(rho, 8.0)
245 + d82*pow(rho, 8.0)/TStar;
246
247 return (mu0 + dmu)/1.0e6; // conversion to [Pa s]
248 }
249
260 template <class Evaluation>
261 static Evaluation gasHeatCapacity(const Evaluation& temperature, const Evaluation& pressure)
262 {
263 OPM_TIMEFUNCTION_LOCAL();
264 constexpr Scalar eps = 1e-6;
265 // NB!! should be changed to using the derivative from the table (if piecwise linear double derivate is zero).
266 // use central differences here because one-sided methods do
267 // not come with a performance improvement. (central ones are
268 // more accurate, though...)
269 const Evaluation h1 = gasEnthalpy(temperature - eps, pressure);
270 const Evaluation h2 = gasEnthalpy(temperature + eps, pressure);
271
272 return (h2 - h1) / (2*eps) ;
273 }
274};
275
276} // namespace Opm
277
278#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...
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
A class for the CO2 fluid properties.
Definition CO2.hpp:54
static Scalar criticalTemperature()
Returns the critical temperature [K] of CO2.
Definition CO2.hpp:77
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition CO2.hpp:156
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition CO2.hpp:261
static Scalar criticalPressure()
Returns the critical pressure [Pa] of CO2.
Definition CO2.hpp:83
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:208
static std::string_view name()
A human readable name for the CO2.
Definition CO2.hpp:65
static Evaluation vaporPressure(const Evaluation &T)
Returns the pressure [Pa] at CO2's triple point.
Definition CO2.hpp:135
static Scalar triplePressure()
Returns the pressure [Pa] at CO2's triple point.
Definition CO2.hpp:95
static Scalar tripleTemperature()
Returns the temperature [K]at CO2's triple point.
Definition CO2.hpp:89
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition CO2.hpp:169
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition CO2.hpp:162
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:71
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:180
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:194
Abstract base class of a pure chemical species.
Definition Component.hpp:44
A central place for various physical constants occuring in some equations.
Definition Constants.hpp:41
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
Definition UniformTabulated2DFunction.hpp:52
Evaluation eval(const Evaluation &x, const Evaluation &y, bool extrapolate) const
Evaluate the function at a given (x,y) position.
Definition UniformTabulated2DFunction.hpp:196
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30