Loading...
Searching...
No Matches
CO2.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_CO2_HPP
#define OPM_CO2_HPP
#include <opm/common/TimingMacros.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/utility/gpuDecorators.hpp>
#include <opm/material/Constants.hpp>
#include <opm/material/IdealGas.hpp>
#include <opm/material/components/Component.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/UniformTabulated2DFunction.hpp>
#include <opm/material/components/CO2Tables.hpp>
#include <cmath>
#include <string_view>
namespace Opm {
template <class Scalar, class ParamsT = Opm::CO2Tables<double, VectorWithDefaultAllocator>>
class CO2 : public Component<Scalar, CO2<Scalar>>
{
public:
using Params = ParamsT;
static constexpr const Scalar brineSalinity = 1.000000000000000e-01;
OPM_HOST_DEVICE static std::string_view name()
{ return "CO2"; }
OPM_HOST_DEVICE static Scalar molarMass()
{ return 44e-3; }
OPM_HOST_DEVICE static Scalar criticalTemperature()
{ return 273.15 + 30.95; /* [K] */ }
OPM_HOST_DEVICE static Scalar criticalPressure()
{ return 73.8e5; /* [N/m^2] */ }
OPM_HOST_DEVICE static Scalar tripleTemperature()
{ return 273.15 - 56.35; /* [K] */ }
OPM_HOST_DEVICE static Scalar triplePressure()
{ return 5.11e5; /* [N/m^2] */ }
// static Scalar minTabulatedPressure()
// { return tabulatedEnthalpy.minPress(); /* [N/m^2] */ }
// static Scalar maxTabulatedPressure()
// { return tabulatedEnthalpy.maxPress(); /* [N/m^2] */ }
// static Scalar minTabulatedTemperature()
// { return tabulatedEnthalpy.minTemp(); /* [N/m^2] */ }
// static Scalar maxTabulatedTemperature()
// { return tabulatedEnthalpy.maxTemp(); /* [N/m^2] */ }
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation vaporPressure(const Evaluation& T)
{
static constexpr Scalar a[4] =
{ -7.0602087, 1.9391218, -1.6463597, -3.2995634 };
static constexpr Scalar t[4] =
{ 1.0, 1.5, 2.0, 4.0 };
// this is on page 1524 of the reference
Evaluation exponent = 0;
Evaluation Tred = T/criticalTemperature();
for (int i = 0; i < 4; ++i)
exponent += a[i]*pow(1 - Tred, t[i]);
exponent *= 1.0/Tred;
return exp(exponent)*criticalPressure();
}
OPM_HOST_DEVICE static bool gasIsCompressible()
{ return true; }
OPM_HOST_DEVICE static bool gasIsIdeal()
{ return false; }
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasEnthalpy(const Params& params,
const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
return params.tabulatedEnthalpy.eval(temperature, pressure, extrapolate);
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasEnthalpy([[maybe_unused]] const Evaluation& temperature,
[[maybe_unused]] const Evaluation& pressure,
[[maybe_unused]] bool extrapolate = false)
{
OPM_THROW(std::runtime_error, "This function should not be called");
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasInternalEnergy(const Params& params,
const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
const Evaluation h = gasEnthalpy(params, temperature, pressure, extrapolate);
const Evaluation rho = gasDensity(params, temperature, pressure, extrapolate);
return h - (pressure / rho);
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasInternalEnergy([[maybe_unused]] const Evaluation& temperature,
[[maybe_unused]] const Evaluation& pressure,
[[maybe_unused]] bool extrapolate = false)
{
OPM_THROW(std::runtime_error, "This function should not be called");
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasDensity(const Params& params,
const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
return params.tabulatedDensity.eval(temperature, pressure, extrapolate);
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasDensity([[maybe_unused]] const Evaluation& temperature,
[[maybe_unused]] const Evaluation& pressure,
[[maybe_unused]] bool extrapolate = false)
{
OPM_THROW(std::runtime_error, "This function should not be called");
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasViscosity(const Params& params,
Evaluation temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
constexpr Scalar a0 = 0.235156;
constexpr Scalar a1 = -0.491266;
constexpr Scalar a2 = 5.211155e-2;
constexpr Scalar a3 = 5.347906e-2;
constexpr Scalar a4 = -1.537102e-2;
constexpr Scalar d11 = 0.4071119e-2;
constexpr Scalar d21 = 0.7198037e-4;
constexpr Scalar d64 = 0.2411697e-16;
constexpr Scalar d81 = 0.2971072e-22;
constexpr Scalar d82 = -0.1627888e-22;
constexpr Scalar ESP = 251.196;
if(temperature < 275.) // regularization
temperature = 275.0;
Evaluation TStar = temperature/ESP;
// mu0: viscosity in zero-density limit
const Evaluation logTStar = log(TStar);
Evaluation SigmaStar = exp(a0 + logTStar*(a1 + logTStar*(a2 + logTStar*(a3 + logTStar*a4))));
Evaluation mu0 = 1.00697*sqrt(temperature) / SigmaStar;
const Evaluation rho = gasDensity(params, temperature, pressure, extrapolate); // CO2 mass density [kg/m^3]
// dmu : excess viscosity at elevated density
Evaluation dmu =
d11*rho
+ d21*rho*rho
+ d64*pow(rho, 6.0)/(TStar*TStar*TStar)
+ d81*pow(rho, 8.0)
+ d82*pow(rho, 8.0)/TStar;
return (mu0 + dmu)/1.0e6; // conversion to [Pa s]
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasViscosity([[maybe_unused]] Evaluation temperature,
[[maybe_unused]] const Evaluation& pressure,
[[maybe_unused]] bool extrapolate = false)
{
OPM_THROW(std::runtime_error, "This function should not be called");
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasHeatCapacity(const Params& params,
const Evaluation& temperature,
const Evaluation& pressure)
{
OPM_TIMEFUNCTION_LOCAL(Subsystem::PvtProps);
constexpr Scalar eps = 1e-6;
// NB!! should be changed to using the derivative from the table (if piecwise linear double derivate is zero).
// use central differences here because one-sided methods do
// not come with a performance improvement. (central ones are
// more accurate, though...)
const Evaluation h1 = gasEnthalpy(params, temperature - eps, pressure);
const Evaluation h2 = gasEnthalpy(params, temperature + eps, pressure);
return (h2 - h1) / (2*eps) ;
}
template <class Evaluation>
OPM_HOST_DEVICE static Evaluation gasHeatCapacity([[maybe_unused]] const Evaluation& temperature, [[maybe_unused]] const Evaluation& pressure)
{
OPM_THROW(std::runtime_error, "This function should not be called");
}
};
} // namespace Opm
#endif
Component.hpp
Abstract base class of a pure chemical species.
Constants.hpp
IdealGas.hpp
Relations valid for an ideal gas.
MathToolbox.hpp
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
UniformTabulated2DFunction.hpp
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
Opm::CO2
A class for the CO2 fluid properties.
Definition CO2.hpp:58
Opm::CO2::name
static OPM_HOST_DEVICE std::string_view name()
A human readable name for the CO2.
Definition CO2.hpp:67
Opm::CO2::tripleTemperature
static OPM_HOST_DEVICE Scalar tripleTemperature()
Returns the temperature [K]at CO2's triple point.
Definition CO2.hpp:91
Opm::CO2::gasDensity
static OPM_HOST_DEVICE 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:235
Opm::CO2::gasDensity
static OPM_HOST_DEVICE Evaluation gasDensity(const Params &params, 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:222
Opm::CO2::criticalPressure
static OPM_HOST_DEVICE Scalar criticalPressure()
Returns the critical pressure [Pa] of CO2.
Definition CO2.hpp:85
Opm::CO2::molarMass
static OPM_HOST_DEVICE Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:73
Opm::CO2::gasIsIdeal
static OPM_HOST_DEVICE bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition CO2.hpp:164
Opm::CO2::gasHeatCapacity
static OPM_HOST_DEVICE Evaluation gasHeatCapacity(const Params &params, const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition CO2.hpp:317
Opm::CO2::criticalTemperature
static OPM_HOST_DEVICE Scalar criticalTemperature()
Returns the critical temperature [K] of CO2.
Definition CO2.hpp:79
Opm::CO2::gasHeatCapacity
static OPM_HOST_DEVICE Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition CO2.hpp:339
Opm::CO2::vaporPressure
static OPM_HOST_DEVICE Evaluation vaporPressure(const Evaluation &T)
Returns the pressure [Pa] at CO2's triple point.
Definition CO2.hpp:137
Opm::CO2::gasInternalEnergy
static OPM_HOST_DEVICE Evaluation gasInternalEnergy(const Params &params, const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:195
Opm::CO2::gasViscosity
static OPM_HOST_DEVICE Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:298
Opm::CO2::gasIsCompressible
static OPM_HOST_DEVICE bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition CO2.hpp:158
Opm::CO2::gasEnthalpy
static OPM_HOST_DEVICE Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition CO2.hpp:184
Opm::CO2::triplePressure
static OPM_HOST_DEVICE Scalar triplePressure()
Returns the pressure [Pa] at CO2's triple point.
Definition CO2.hpp:97
Opm::CO2::gasEnthalpy
static OPM_HOST_DEVICE Evaluation gasEnthalpy(const Params &params, const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific enthalpy of gaseous CO2 [J/kg].
Definition CO2.hpp:171
Opm::CO2::gasViscosity
static OPM_HOST_DEVICE Evaluation gasViscosity(const Params &params, Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:249
Opm::CO2::gasInternalEnergy
static OPM_HOST_DEVICE Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:211
Opm::Component
Abstract base class of a pure chemical species.
Definition Component.hpp:44
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30