Loading...
Searching...
No Matches
Co2GasPvt.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_GAS_PVT_HPP
#define OPM_CO2_GAS_PVT_HPP
#include <opm/material/Constants.hpp>
#include <opm/common/TimingMacros.hpp>
#include <opm/material/components/CO2.hpp>
#include <opm/material/components/BrineDynamic.hpp>
#include <opm/material/components/SimpleHuDuanH2O.hpp>
#include <opm/material/common/UniformTabulated2DFunction.hpp>
#include <opm/material/binarycoefficients/Brine_CO2.hpp>
#include <opm/input/eclipse/EclipseState/Co2StoreConfig.hpp>
#include <cstddef>
#include <vector>
namespace Opm {
class EclipseState;
class Schedule;
class Co2StoreConfig;
template <class Scalar>
class Co2GasPvt
{
using CO2 = ::Opm::CO2<Scalar>;
using H2O = SimpleHuDuanH2O<Scalar>;
using Brine = ::Opm::BrineDynamic<Scalar, H2O>;
static constexpr bool extrapolate = true;
public:
using BinaryCoeffBrineCO2 = BinaryCoeff::Brine_CO2<Scalar, H2O, CO2>;
explicit Co2GasPvt() = default;
explicit Co2GasPvt(const std::vector<Scalar>& salinity,
int activityModel = 3,
int thermalMixingModel = 1,
Scalar T_ref = 288.71, //(273.15 + 15.56)
Scalar P_ref = 101325);
#if HAVE_ECL_INPUT
void initFromState(const EclipseState& eclState, const Schedule&);
#endif
void setNumRegions(std::size_t numRegions);
void setVapPars(const Scalar, const Scalar)
{
}
void setReferenceDensities(unsigned regionIdx,
Scalar rhoRefBrine,
Scalar rhoRefGas,
Scalar /*rhoRefWater*/);
void setEnableVaporizationWater(bool yesno)
{ enableVaporization_ = yesno; }
void setActivityModelSalt(int activityModel);
void setThermalMixingModel(int thermalMixingModel);
void initEnd()
{
}
unsigned numRegions() const
{ return gasReferenceDensity_.size(); }
Scalar hVap(unsigned ) const
{ return 0.0; }
template <class Evaluation>
Evaluation internalEnergy(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& rv,
const Evaluation& rvw) const
{
OPM_TIMEBLOCK_LOCAL(internalEnergy);
if (gastype_ == Co2StoreConfig::GasMixingType::NONE) {
// use the gasInternalEnergy of CO2
return CO2::gasInternalEnergy(temperature, pressure, extrapolate);
}
assert(gastype_ == Co2StoreConfig::GasMixingType::IDEAL);
// account for H2O in the gas phase
Evaluation result = 0;
// The CO2STORE option both works for GAS/WATER and GAS/OIL systems
// Either rv og rvw should be zero
assert(rv == 0.0 || rvw == 0.0);
const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
result += xBrine * H2O::gasInternalEnergy(temperature, pressure);
result += (1 - xBrine) * CO2::gasInternalEnergy(temperature, pressure, extrapolate);
return result;
}
template <class Evaluation>
Evaluation viscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& /*Rv*/,
const Evaluation& /*Rvw*/) const
{ return saturatedViscosity(regionIdx, temperature, pressure); }
template <class Evaluation>
Evaluation saturatedViscosity(unsigned /*regionIdx*/,
const Evaluation& temperature,
const Evaluation& pressure) const
{
OPM_TIMEBLOCK_LOCAL(saturatedViscosity);
// Neglects impact of vaporized water on the visosity
return CO2::gasViscosity(temperature, pressure, extrapolate);
}
template <class Evaluation>
Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& rv,
const Evaluation& rvw) const
{
OPM_TIMEFUNCTION_LOCAL();
if (!enableVaporization_) {
return CO2::gasDensity(temperature, pressure, extrapolate) /
gasReferenceDensity_[regionIdx];
}
// Use CO2 density for the gas phase.
const auto& rhoCo2 = CO2::gasDensity(temperature, pressure, extrapolate);
//const auto& rhoH2O = H2O::gasDensity(temperature, pressure);
//The CO2STORE option both works for GAS/WATER and GAS/OIL systems
//Either rv og rvw should be zero
//assert(rv == 0.0 || rvw == 0.0);
//const Evaluation xBrine = convertRvwToXgW_(max(rvw,rv),regionIdx);
//const auto rho = 1.0/(xBrine/rhoH2O + (1.0 - xBrine)/rhoCo2);
return rhoCo2 / (gasReferenceDensity_[regionIdx] +
max(rvw,rv) * brineReferenceDensity_[regionIdx]);
}
template <class Evaluation>
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{
OPM_TIMEFUNCTION_LOCAL();
const Evaluation rvw = rvwSat_(regionIdx, temperature, pressure,
Evaluation(salinity_[regionIdx]));
return inverseFormationVolumeFactor(regionIdx, temperature,
pressure, Evaluation(0.0), rvw);
}
template <class Evaluation>
Evaluation saturationPressure(unsigned /*regionIdx*/,
const Evaluation& /*temperature*/,
const Evaluation& /*Rvw*/) const
{ return 0.0; /* not implemented */ }
template <class Evaluation>
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
template <class Evaluation = Scalar>
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& saltConcentration) const
{
OPM_TIMEFUNCTION_LOCAL();
const Evaluation salinity = salinityFromConcentration(temperature, pressure,
saltConcentration);
return rvwSat_(regionIdx, temperature, pressure, salinity);
}
template <class Evaluation>
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& /*oilSaturation*/,
const Evaluation& /*maxOilSaturation*/) const
{ return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
template <class Evaluation>
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ return rvwSat_(regionIdx, temperature, pressure, Evaluation(salinity_[regionIdx])); }
template <class Evaluation>
Evaluation diffusionCoefficient(const Evaluation& temperature,
const Evaluation& pressure,
unsigned /*compIdx*/) const
{
return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure, extrapolate);
}
Scalar gasReferenceDensity(unsigned regionIdx) const
{ return gasReferenceDensity_[regionIdx]; }
Scalar oilReferenceDensity(unsigned regionIdx) const
{ return brineReferenceDensity_[regionIdx]; }
Scalar waterReferenceDensity(unsigned regionIdx) const
{ return brineReferenceDensity_[regionIdx]; }
Scalar salinity(unsigned regionIdx) const
{ return salinity_[regionIdx]; }
void setEzrokhiDenCoeff(const std::vector<EzrokhiTable>& denaqa);
private:
template <class LhsEval>
LhsEval ezrokhiExponent_(const LhsEval& temperature,
const std::vector<Scalar>& ezrokhiCoeff) const
{
const LhsEval& tempC = temperature - 273.15;
return ezrokhiCoeff[0] + tempC * (ezrokhiCoeff[1] + ezrokhiCoeff[2] * tempC);
}
template <class LhsEval>
LhsEval rvwSat_(unsigned regionIdx,
const LhsEval& temperature,
const LhsEval& pressure,
const LhsEval& salinity) const
{
OPM_TIMEFUNCTION_LOCAL();
if (!enableVaporization_) {
return 0.0;
}
// calulate the equilibrium composition for the given
// temperature and pressure.
LhsEval xgH2O;
LhsEval xlCO2;
BinaryCoeffBrineCO2::calculateMoleFractions(temperature,
pressure,
salinity,
/*knownPhaseIdx=*/-1,
xlCO2,
xgH2O,
activityModel_,
extrapolate);
// normalize the phase compositions
xgH2O = max(0.0, min(1.0, xgH2O));
return convertXgWToRvw(convertxgWToXgW(xgH2O, salinity), regionIdx);
}
template <class LhsEval>
LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx) const
{
OPM_TIMEFUNCTION_LOCAL();
Scalar rho_wRef = brineReferenceDensity_[regionIdx];
Scalar rho_gRef = gasReferenceDensity_[regionIdx];
return XgW / (1.0 - XgW) * (rho_gRef / rho_wRef);
}
template <class LhsEval>
LhsEval convertRvwToXgW_(const LhsEval& Rvw, unsigned regionIdx) const
{
OPM_TIMEFUNCTION_LOCAL();
Scalar rho_wRef = brineReferenceDensity_[regionIdx];
Scalar rho_gRef = gasReferenceDensity_[regionIdx];
const LhsEval& rho_wG = Rvw * rho_wRef;
return rho_wG / (rho_gRef + rho_wG);
}
template <class LhsEval>
LhsEval convertxgWToXgW(const LhsEval& xgW, const LhsEval& salinity) const
{
OPM_TIMEFUNCTION_LOCAL();
Scalar M_CO2 = CO2::molarMass();
LhsEval M_Brine = Brine::molarMass(salinity);
return xgW * M_Brine / (xgW * (M_Brine - M_CO2) + M_CO2);
}
template <class LhsEval>
const LhsEval salinityFromConcentration(const LhsEval&T, const LhsEval& P,
const LhsEval& saltConcentration) const
{ return saltConcentration/H2O::liquidDensity(T, P, true); }
std::vector<Scalar> brineReferenceDensity_{};
std::vector<Scalar> gasReferenceDensity_{};
std::vector<Scalar> salinity_{};
std::vector<Scalar> ezrokhiDenNaClCoeff_{};
bool enableEzrokhiDensity_ = false;
bool enableVaporization_ = true;
int activityModel_{};
Co2StoreConfig::GasMixingType gastype_{};
};
} // namespace Opm
#endif
BrineDynamic.hpp
A class for the brine fluid properties.
Brine_CO2.hpp
Binary coefficients for brine and CO2.
CO2.hpp
A class for the CO2 fluid properties.
Constants.hpp
A central place for various physical constants occuring in some equations.
SimpleHuDuanH2O.hpp
A simple version of pure water with density from Hu et al.
UniformTabulated2DFunction.hpp
Implements a scalar function that depends on two variables and which is sampled on an uniform X-Y gri...
Opm::BinaryCoeff::Brine_CO2
Binary coefficients for brine and CO2.
Definition Brine_CO2.hpp:45
Opm::BinaryCoeff::Brine_CO2::calculateMoleFractions
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, const Evaluation &salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O, const int &activityModel, bool extrapolate=false)
Returns the mol (!) fraction of CO2 in the liquid phase and the mol_ (!) fraction of H2O in the gas p...
Definition Brine_CO2.hpp:100
Opm::BinaryCoeff::Brine_CO2::gasDiffCoeff
static Evaluation gasDiffCoeff(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Binary diffusion coefficent [m^2/s] of water in the CO2 phase.
Definition Brine_CO2.hpp:59
Opm::BrineDynamic
A class for the brine fluid properties.
Definition BrineDynamic.hpp:48
Opm::CO2
A class for the CO2 fluid properties.
Definition CO2.hpp:54
Opm::CO2::gasViscosity
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure, bool extrapolate=false)
The dynamic viscosity [Pa s] of CO2.
Definition CO2.hpp:208
Opm::CO2::molarMass
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition CO2.hpp:71
Opm::CO2::gasInternalEnergy
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
Specific internal energy of CO2 [J/kg].
Definition CO2.hpp:180
Opm::CO2::gasDensity
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
Opm::Co2GasPvt
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition Co2GasPvt.hpp:55
Opm::Co2GasPvt::internalEnergy
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &rv, const Evaluation &rvw) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition Co2GasPvt.hpp:133
Opm::Co2GasPvt::saturatedInverseFormationVolumeFactor
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of water saturated gas at given pressure.
Definition Co2GasPvt.hpp:214
Opm::Co2GasPvt::saturatedOilVaporizationFactor
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition Co2GasPvt.hpp:266
Opm::Co2GasPvt::saturatedViscosity
Evaluation saturatedViscosity(unsigned, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of fluid phase at saturated conditions.
Definition Co2GasPvt.hpp:173
Opm::Co2GasPvt::saturatedWaterVaporizationFactor
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition Co2GasPvt.hpp:242
Opm::Co2GasPvt::setReferenceDensities
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefBrine, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition Co2GasPvt.cpp:117
Opm::Co2GasPvt::saturatedOilVaporizationFactor
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition Co2GasPvt.hpp:277
Opm::Co2GasPvt::initEnd
void initEnd()
Finish initializing the co2 phase PVT properties.
Definition Co2GasPvt.hpp:116
Opm::Co2GasPvt::saturatedWaterVaporizationFactor
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the water vaporization factor [m^3/m^3] of water phase.
Definition Co2GasPvt.hpp:251
Opm::Co2GasPvt::saturationPressure
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the brine com...
Definition Co2GasPvt.hpp:233
Opm::Co2GasPvt::setEnableVaporizationWater
void setEnableVaporizationWater(bool yesno)
Specify whether the PVT model should consider that the water component can vaporize in the gas phase.
Definition Co2GasPvt.hpp:100
Opm::Co2GasPvt::numRegions
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition Co2GasPvt.hpp:123
Opm::Co2GasPvt::setThermalMixingModel
void setThermalMixingModel(int thermalMixingModel)
Set thermal mixing model for co2 in brine.
Definition Co2GasPvt.cpp:141
Opm::Co2GasPvt::viscosity
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition Co2GasPvt.hpp:162
Opm::Co2GasPvt::setActivityModelSalt
void setActivityModelSalt(int activityModel)
Set activity coefficient model for salt in solubility model.
Definition Co2GasPvt.cpp:128
Opm::Co2GasPvt::inverseFormationVolumeFactor
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &rv, const Evaluation &rvw) const
Returns the formation volume factor [-] of the fluid phase.
Definition Co2GasPvt.hpp:186
Opm::Component< Scalar, BrineDynamic< Scalar, H2O > >::molarMass
static Scalar molarMass()
The molar mass in of the component.
Definition Component.hpp:93
Opm::EclipseState
Definition EclipseState.hpp:63
Opm::Schedule
Definition Schedule.hpp:89
Opm::SimpleHuDuanH2O
A simple version of pure water with density from Hu et al.
Definition SimpleHuDuanH2O.hpp:65
Opm::SimpleHuDuanH2O::liquidDensity
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The density of pure water at a given pressure and temperature .
Definition SimpleHuDuanH2O.hpp:310
Opm::SimpleHuDuanH2O::gasInternalEnergy
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition SimpleHuDuanH2O.hpp:224
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30