Merge pull request #476 from totto82/extrapolate_co2store

extrapolate co2, brine and h2O properties only when called via CO2STORE  module
This commit is contained in:
Markus Blatt
2021-10-14 14:03:58 +02:00
committed by GitHub
5 changed files with 41 additions and 32 deletions

View File

@@ -247,12 +247,12 @@ public:
* - cited by: Adams & Bachu in Geofluids (2002) 2, 257-271
*/
template <class Evaluation>
static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure)
static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure, bool extrapolate = false)
{
Evaluation tempC = temperature - 273.15;
Evaluation pMPa = pressure/1.0E6;
const Evaluation rhow = H2O::liquidDensity(temperature, pressure, true);
const Evaluation rhow = H2O::liquidDensity(temperature, pressure, extrapolate);
return
rhow +
1000*salinity*(

View File

@@ -162,10 +162,10 @@ public:
*/
template <class Evaluation>
static Evaluation gasEnthalpy(const Evaluation& temperature,
const Evaluation& pressure)
const Evaluation& pressure,
bool extrapolate = false)
{
return CO2Tables::tabulatedEnthalpy.eval(temperature, pressure,
/* extrapolate = */ true);
return CO2Tables::tabulatedEnthalpy.eval(temperature, pressure, extrapolate);
}
/*!
@@ -173,10 +173,11 @@ public:
*/
template <class Evaluation>
static Evaluation gasInternalEnergy(const Evaluation& temperature,
const Evaluation& pressure)
const Evaluation& pressure,
bool extrapolate = false)
{
const Evaluation& h = gasEnthalpy(temperature, pressure);
const Evaluation& rho = gasDensity(temperature, pressure);
const Evaluation& h = gasEnthalpy(temperature, pressure, extrapolate);
const Evaluation& rho = gasDensity(temperature, pressure, extrapolate);
return h - (pressure / rho);
}
@@ -185,10 +186,11 @@ public:
* \brief The density of CO2 at a given pressure and temperature [kg/m^3].
*/
template <class Evaluation>
static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
static Evaluation gasDensity(const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
return CO2Tables::tabulatedDensity.eval(temperature, pressure,
/* extrapolate = */ true);
return CO2Tables::tabulatedDensity.eval(temperature, pressure, extrapolate);
}
/*!
@@ -198,7 +200,9 @@ public:
* - Fenhour etl al., 1998
*/
template <class Evaluation>
static Evaluation gasViscosity(Evaluation temperature, const Evaluation& pressure)
static Evaluation gasViscosity(Evaluation temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
const Scalar a0 = 0.235156;
const Scalar a1 = -0.491266;
@@ -224,7 +228,7 @@ public:
Evaluation mu0 = 1.00697*sqrt(temperature) / SigmaStar;
const Evaluation& rho = gasDensity(temperature, pressure); // CO2 mass density [kg/m^3]
const Evaluation& rho = gasDensity(temperature, pressure, extrapolate); // CO2 mass density [kg/m^3]
// dmu : excess viscosity at elevated density
Evaluation dmu =

View File

@@ -689,9 +689,11 @@ public:
* \param pressure Phase pressure in \f$\mathrm{[Pa]}\f$
*/
template <class Evaluation>
static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure, bool = false)
static Evaluation liquidDensity(const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
if (!Region1::isValid(temperature, pressure))
if (!extrapolate && !Region1::isValid(temperature, pressure))
{
std::ostringstream oss;
oss << "Density of water is only implemented for temperatures below 623.15K and "
@@ -817,9 +819,11 @@ public:
* \param pressure Phase pressure in \f$\mathrm{[Pa]}\f$
*/
template <class Evaluation>
static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& pressure)
static Evaluation liquidViscosity(const Evaluation& temperature,
const Evaluation& pressure,
bool extrapolate = false)
{
if (!Region1::isValid(temperature, pressure))
if (!extrapolate && !Region1::isValid(temperature, pressure))
{
std::ostringstream oss;
oss << "Viscosity of water is only implemented for temperatures below 623.15K and "
@@ -827,7 +831,7 @@ public:
throw NumericalIssue(oss.str());
};
const Evaluation& rho = liquidDensity(temperature, pressure);
const Evaluation& rho = liquidDensity(temperature, pressure, extrapolate);
return Common::viscosity(temperature, rho);
}

View File

@@ -57,7 +57,7 @@ template <class Scalar>
class BrineCo2Pvt
{
typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
static const bool extrapolate = true;
//typedef H2O<Scalar> H2O_IAPWS;
//typedef Brine<Scalar, H2O_IAPWS> Brine_IAPWS;
//typedef TabulatedComponent<Scalar, H2O_IAPWS> H2O_Tabulated;
@@ -117,8 +117,8 @@ public:
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref);
co2ReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref);
brineReferenceDensity_[regionIdx] = Brine::liquidDensity(T_ref, P_ref, extrapolate);
co2ReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
}
#endif
@@ -286,7 +286,7 @@ public:
const Evaluation log_D_H20 = -4.1764 + 712.52 / temperature - 2.5907e5 / (temperature*temperature);
//Diffusion coefficient of CO2 in the brine phase modified following (Ratcliff and Holdcroft,1963 and Al-Rawajfeh, 2004)
const Evaluation& mu_H20 = H2O::liquidViscosity(temperature, pressure, true); // Water viscosity
const Evaluation& mu_H20 = H2O::liquidViscosity(temperature, pressure, extrapolate); // Water viscosity
const Evaluation& mu_Brine = Brine::liquidViscosity(temperature, pressure); // Brine viscosity
const Evaluation log_D_Brine = log_D_H20 - 0.87*log10(mu_Brine / mu_H20);
@@ -323,21 +323,21 @@ private:
Valgrind::CheckDefined(pl);
Valgrind::CheckDefined(xlCO2);
if(T < 273.15) {
if(!extrapolate && T < 273.15) {
std::ostringstream oss;
oss << "Liquid density for Brine and CO2 is only "
"defined above 273.15K (is "<<T<<"K)";
throw NumericalIssue(oss.str());
}
if(pl >= 2.5e8) {
if(!extrapolate && pl >= 2.5e8) {
std::ostringstream oss;
oss << "Liquid density for Brine and CO2 is only "
"defined below 250MPa (is "<<pl<<"Pa)";
throw NumericalIssue(oss.str());
}
const LhsEval& rho_brine = Brine::liquidDensity(T, pl);
const LhsEval& rho_pure = H2O::liquidDensity(T, pl, true);
const LhsEval& rho_brine = Brine::liquidDensity(T, pl, extrapolate);
const LhsEval& rho_pure = H2O::liquidDensity(T, pl, extrapolate);
const LhsEval& rho_lCO2 = liquidDensityWaterCO2_(T, pl, xlCO2);
const LhsEval& contribCO2 = rho_lCO2 - rho_pure;
@@ -353,7 +353,7 @@ private:
Scalar M_H2O = H2O::molarMass();
const LhsEval& tempC = temperature - 273.15; /* tempC : temperature in <20>C */
const LhsEval& rho_pure = H2O::liquidDensity(temperature, pl, true);
const LhsEval& rho_pure = H2O::liquidDensity(temperature, pl, extrapolate);
// calculate the mole fraction of CO2 in the liquid. note that xlH2O is available
// as a function parameter, but in the case of a pure gas phase the value of M_T
// for the virtual liquid phase can become very large
@@ -507,7 +507,7 @@ private:
delta_hCO2 = (-57.4375 + T * 0.1325) * 1000/44;
/* enthalpy contribution of CO2 (kJ/kg) */
hg = CO2::gasEnthalpy(T, p)/1E3 + delta_hCO2;
hg = CO2::gasEnthalpy(T, p, extrapolate)/1E3 + delta_hCO2;
/* Enthalpy of brine with dissolved CO2 */
return (h_ls1 - X_CO2_w*hw + hg*X_CO2_w)*1E3; /*J/kg*/

View File

@@ -55,6 +55,7 @@ class Co2GasPvt
typedef std::vector<std::pair<Scalar, Scalar> > SamplingPoints;
typedef ::Opm::CO2<Scalar, CO2Tables> CO2;
typedef SimpleHuDuanH2O<Scalar> H2O;
static const bool extrapolate = true;
public:
typedef Tabulated1DFunction<Scalar> TabulatedOneDFunction;
@@ -89,7 +90,7 @@ public:
size_t regionIdx = 0;
Scalar T_ref = eclState.getTableManager().stCond().temperature;
Scalar P_ref = eclState.getTableManager().stCond().pressure;
gasReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref);
gasReferenceDensity_[regionIdx] = CO2::gasDensity(T_ref, P_ref, extrapolate);
initEnd();
}
#endif
@@ -134,7 +135,7 @@ public:
const Evaluation& pressure,
const Evaluation&) const
{
return CO2::gasInternalEnergy(temperature, pressure);
return CO2::gasInternalEnergy(temperature, pressure, extrapolate);
}
/*!
@@ -155,7 +156,7 @@ public:
const Evaluation& temperature,
const Evaluation& pressure) const
{
return CO2::gasViscosity(temperature, pressure);
return CO2::gasViscosity(temperature, pressure, extrapolate);
}
/*!
@@ -176,7 +177,7 @@ public:
const Evaluation& temperature,
const Evaluation& pressure) const
{
return CO2::gasDensity(temperature, pressure)/gasReferenceDensity_[regionIdx];
return CO2::gasDensity(temperature, pressure, extrapolate)/gasReferenceDensity_[regionIdx];
}
/*!