mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3066 from joakim-hove/vfp-warnings
Use class based enums for VFP flow types
This commit is contained in:
commit
d65cb22e69
@ -3606,9 +3606,8 @@ namespace Opm
|
||||
};
|
||||
|
||||
// Make the flo() function.
|
||||
auto flo_type = table.getFloType();
|
||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
||||
auto flo = [&table](const std::vector<double>& rates) {
|
||||
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||
};
|
||||
|
||||
// Make the frates() function.
|
||||
@ -3830,9 +3829,8 @@ namespace Opm
|
||||
};
|
||||
|
||||
// Make the flo() function.
|
||||
auto flo_type = table.getFloType();
|
||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
||||
auto flo = [&table](const std::vector<double>& rates) {
|
||||
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||
};
|
||||
|
||||
// Make the frates() function.
|
||||
|
@ -3726,9 +3726,8 @@ namespace Opm
|
||||
};
|
||||
|
||||
// Make the flo() function.
|
||||
auto flo_type = table.getFloType();
|
||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
||||
auto flo = [&table](const std::vector<double>& rates) {
|
||||
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||
};
|
||||
|
||||
// Make the frates() function.
|
||||
@ -3932,9 +3931,8 @@ namespace Opm
|
||||
};
|
||||
|
||||
// Make the flo() function.
|
||||
auto flo_type = table.getFloType();
|
||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
||||
auto flo = [&table](const std::vector<double>& rates) {
|
||||
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||
};
|
||||
|
||||
// Make the frates() function.
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
|
||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||
#include <opm/material/densead/Math.hpp>
|
||||
#include <opm/material/densead/Evaluation.hpp>
|
||||
|
||||
@ -40,11 +41,14 @@ namespace detail {
|
||||
/**
|
||||
* Returns zero if input value is NaN of INF
|
||||
*/
|
||||
inline double zeroIfNanInf(const double& value) {
|
||||
inline double zeroIfNanInf(const double& value, const std::string& rate, const VFPProdTable& table) {
|
||||
const bool nan_or_inf = std::isnan(value) || std::isinf(value);
|
||||
|
||||
if (nan_or_inf) {
|
||||
OpmLog::warning("NAN_OR_INF_VFP", "NAN or INF value encountered during VFP calculation, the value is set to zero");
|
||||
std::string msg = "Problem with VFPPROD keyword table " + std::to_string(table.getTableNum()) + "\n" +
|
||||
"In " + table.location().filename + " line " + std::to_string(table.location().lineno) + "\n"
|
||||
"Nan or inf encountered while calculating " + rate + " - using zero";
|
||||
OpmLog::warning("NAN_OR_INF_VFP", msg);
|
||||
}
|
||||
|
||||
return nan_or_inf ? 0.0 : value;
|
||||
@ -55,11 +59,14 @@ inline double zeroIfNanInf(const double& value) {
|
||||
* Returns zero if input value is NaN or INF
|
||||
*/
|
||||
template <class EvalWell>
|
||||
inline EvalWell zeroIfNanInf(const EvalWell& value) {
|
||||
inline EvalWell zeroIfNanInf(const EvalWell& value, const std::string& rate, const VFPProdTable& table) {
|
||||
const bool nan_or_inf = std::isnan(value.value()) || std::isinf(value.value());
|
||||
|
||||
if (nan_or_inf) {
|
||||
OpmLog::warning("NAN_OR_INF_VFP_EVAL", "NAN or INF Evalution encountered during VFP calculation, the Evalution is set to zero");
|
||||
std::string msg = "Problem with VFPPROD keyword table " + std::to_string(table.getTableNum()) + "\n" +
|
||||
"In " + table.location().filename + " line " + std::to_string(table.location().lineno) + "\n"
|
||||
"Nan or inf encountered while calculating " + rate + " - using zero";
|
||||
OpmLog::warning("NAN_OR_INF_VFP_EVAL", msg);
|
||||
}
|
||||
|
||||
using Toolbox = MathToolbox<EvalWell>;
|
||||
@ -74,21 +81,20 @@ inline EvalWell zeroIfNanInf(const EvalWell& value) {
|
||||
* @return Production rate of oil, gas or liquid.
|
||||
*/
|
||||
template <typename T>
|
||||
static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
||||
const VFPProdTable::FLO_TYPE& type) {
|
||||
static T getFlo(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||
auto type = table.getFloType();
|
||||
switch (type) {
|
||||
case VFPProdTable::FLO_OIL:
|
||||
//Oil = liquid phase
|
||||
return liquid;
|
||||
case VFPProdTable::FLO_LIQ:
|
||||
//Liquid = aqua + liquid phases
|
||||
return aqua + liquid;
|
||||
case VFPProdTable::FLO_GAS:
|
||||
//Gas = vapor phase
|
||||
return vapour;
|
||||
case VFPProdTable::FLO_INVALID: //Intentional fall-through
|
||||
default:
|
||||
OPM_THROW(std::logic_error, "Invalid FLO_TYPE: '" << type << "'");
|
||||
case VFPProdTable::FLO_TYPE::FLO_OIL:
|
||||
//Oil = liquid phase
|
||||
return liquid;
|
||||
case VFPProdTable::FLO_TYPE::FLO_LIQ:
|
||||
//Liquid = aqua + liquid phases
|
||||
return aqua + liquid;
|
||||
case VFPProdTable::FLO_TYPE::FLO_GAS:
|
||||
//Gas = vapor phase
|
||||
return vapour;
|
||||
default:
|
||||
throw std::logic_error("Invalid FLO_TYPE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,21 +106,20 @@ static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
||||
* @return Production rate of oil, gas or liquid.
|
||||
*/
|
||||
template <typename T>
|
||||
static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
||||
const VFPInjTable::FLO_TYPE& type) {
|
||||
static T getFlo(const VFPInjTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||
auto type = table.getFloType();
|
||||
switch (type) {
|
||||
case VFPInjTable::FLO_OIL:
|
||||
//Oil = liquid phase
|
||||
return liquid;
|
||||
case VFPInjTable::FLO_WAT:
|
||||
//Liquid = aqua phase
|
||||
return aqua;
|
||||
case VFPInjTable::FLO_GAS:
|
||||
//Gas = vapor phase
|
||||
return vapour;
|
||||
case VFPInjTable::FLO_INVALID: //Intentional fall-through
|
||||
default:
|
||||
OPM_THROW(std::logic_error, "Invalid FLO_TYPE: '" << type << "'");
|
||||
case VFPInjTable::FLO_TYPE::FLO_OIL:
|
||||
//Oil = liquid phase
|
||||
return liquid;
|
||||
case VFPInjTable::FLO_TYPE::FLO_WAT:
|
||||
//Liquid = aqua phase
|
||||
return aqua;
|
||||
case VFPInjTable::FLO_TYPE::FLO_GAS:
|
||||
//Gas = vapor phase
|
||||
return vapour;
|
||||
default:
|
||||
throw std::logic_error("Invalid FLO_TYPE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,23 +134,23 @@ static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
||||
* @return Production rate of oil, gas or liquid.
|
||||
*/
|
||||
template <typename T>
|
||||
static T getWFR(const T& aqua, const T& liquid, const T& vapour,
|
||||
const VFPProdTable::WFR_TYPE& type) {
|
||||
static T getWFR(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||
auto type = table.getWFRType();
|
||||
switch(type) {
|
||||
case VFPProdTable::WFR_WOR: {
|
||||
//Water-oil ratio = water / oil
|
||||
T wor = aqua / liquid;
|
||||
return zeroIfNanInf(wor);
|
||||
}
|
||||
case VFPProdTable::WFR_WCT:
|
||||
//Water cut = water / (water + oil)
|
||||
return zeroIfNanInf(aqua / (aqua + liquid));
|
||||
case VFPProdTable::WFR_WGR:
|
||||
//Water-gas ratio = water / gas
|
||||
return zeroIfNanInf(aqua / vapour);
|
||||
case VFPProdTable::WFR_INVALID: //Intentional fall-through
|
||||
default:
|
||||
OPM_THROW(std::logic_error, "Invalid WFR_TYPE: '" << type << "'");
|
||||
case VFPProdTable::WFR_TYPE::WFR_WOR:
|
||||
//Water-oil ratio = water / oil
|
||||
return zeroIfNanInf(aqua/liquid, "WOR", table);
|
||||
|
||||
case VFPProdTable::WFR_TYPE::WFR_WCT:
|
||||
//Water cut = water / (water + oil)
|
||||
return zeroIfNanInf(aqua / (aqua + liquid), "WCT", table);
|
||||
|
||||
case VFPProdTable::WFR_TYPE::WFR_WGR:
|
||||
//Water-gas ratio = water / gas
|
||||
return zeroIfNanInf(aqua / vapour, "WGR", table);
|
||||
|
||||
default:
|
||||
throw std::logic_error("Invalid WFR_TYPE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,21 +164,20 @@ static T getWFR(const T& aqua, const T& liquid, const T& vapour,
|
||||
* @return Production rate of oil, gas or liquid.
|
||||
*/
|
||||
template <typename T>
|
||||
static T getGFR(const T& aqua, const T& liquid, const T& vapour,
|
||||
const VFPProdTable::GFR_TYPE& type) {
|
||||
static T getGFR(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||
auto type = table.getGFRType();
|
||||
switch(type) {
|
||||
case VFPProdTable::GFR_GOR:
|
||||
// Gas-oil ratio = gas / oil
|
||||
return zeroIfNanInf(vapour / liquid);
|
||||
case VFPProdTable::GFR_GLR:
|
||||
// Gas-liquid ratio = gas / (oil + water)
|
||||
return zeroIfNanInf(vapour / (liquid + aqua));
|
||||
case VFPProdTable::GFR_OGR:
|
||||
// Oil-gas ratio = oil / gas
|
||||
return zeroIfNanInf(liquid / vapour);
|
||||
case VFPProdTable::GFR_INVALID: //Intentional fall-through
|
||||
default:
|
||||
OPM_THROW(std::logic_error, "Invalid GFR_TYPE: '" << type << "'");
|
||||
case VFPProdTable::GFR_TYPE::GFR_GOR:
|
||||
// Gas-oil ratio = gas / oil
|
||||
return zeroIfNanInf(vapour / liquid, "GOR", table);
|
||||
case VFPProdTable::GFR_TYPE::GFR_GLR:
|
||||
// Gas-liquid ratio = gas / (oil + water)
|
||||
return zeroIfNanInf(vapour / (liquid + aqua), "GLR", table);
|
||||
case VFPProdTable::GFR_TYPE::GFR_OGR:
|
||||
// Oil-gas ratio = oil / gas
|
||||
return zeroIfNanInf(liquid / vapour, "OGR", table);
|
||||
default:
|
||||
throw std::logic_error("Invalid GFR_TYPE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,9 +514,9 @@ inline VFPEvaluation bhp(const VFPProdTable& table,
|
||||
const double& thp,
|
||||
const double& alq) {
|
||||
//Find interpolation variables
|
||||
double flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
double wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
||||
double gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
||||
double flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||
double wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||
double gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||
|
||||
//First, find the values to interpolate between
|
||||
//Recall that flo is negative in Opm, so switch sign.
|
||||
@ -537,7 +541,7 @@ inline VFPEvaluation bhp(const VFPInjTable& table,
|
||||
const double& vapour,
|
||||
const double& thp) {
|
||||
//Find interpolation variables
|
||||
double flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
double flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||
|
||||
//First, find the values to interpolate between
|
||||
auto flo_i = detail::findInterpData(flo, table.getFloAxis());
|
||||
|
@ -54,7 +54,7 @@ double VFPInjProperties::thp(int table_id,
|
||||
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
||||
|
||||
//Find interpolation variables
|
||||
double flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
double flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||
|
||||
const std::vector<double> thp_array = table.getTHPAxis();
|
||||
int nthp = thp_array.size();
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
EvalWell bhp = 0.0 * aqua;
|
||||
|
||||
//Find interpolation variables
|
||||
EvalWell flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
EvalWell flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||
|
||||
//First, find the values to interpolate between
|
||||
//Value of FLO is negative in OPM for producers, but positive in VFP table
|
||||
|
@ -53,9 +53,9 @@ double VFPProdProperties::thp(int table_id,
|
||||
} else {
|
||||
// The usual case.
|
||||
// Recall that production rate is negative in Opm, so switch the sign.
|
||||
flo = -detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
||||
gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
||||
flo = -detail::getFlo(table, aqua, liquid, vapour);
|
||||
wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||
gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||
}
|
||||
|
||||
const std::vector<double> thp_array = table.getTHPAxis();
|
||||
@ -181,16 +181,16 @@ calculateBhpWithTHPTarget(const std::vector<double>& ipr_a,
|
||||
const double aqua_bhp_limit = rates_bhp_limit[Water];
|
||||
const double liquid_bhp_limit = rates_bhp_limit[Oil];
|
||||
const double vapour_bhp_limit = rates_bhp_limit[Gas];
|
||||
const double flo_bhp_limit = detail::getFlo(aqua_bhp_limit, liquid_bhp_limit, vapour_bhp_limit, table.getFloType() );
|
||||
const double flo_bhp_limit = detail::getFlo(table, aqua_bhp_limit, liquid_bhp_limit, vapour_bhp_limit );
|
||||
|
||||
const double aqua_bhp_middle = rates_bhp_middle[Water];
|
||||
const double liquid_bhp_middle = rates_bhp_middle[Oil];
|
||||
const double vapour_bhp_middle = rates_bhp_middle[Gas];
|
||||
const double flo_bhp_middle = detail::getFlo(aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle, table.getFloType() );
|
||||
const double flo_bhp_middle = detail::getFlo(table, aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle );
|
||||
|
||||
// we use the ratios based on the middle value of bhp_limit and bhp_safe_limit
|
||||
const double wfr = detail::getWFR(aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle, table.getWFRType());
|
||||
const double gfr = detail::getGFR(aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle, table.getGFRType());
|
||||
const double wfr = detail::getWFR(table, aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle);
|
||||
const double gfr = detail::getGFR(table, aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle);
|
||||
|
||||
// we get the flo sampling points from the table,
|
||||
// then extend it with zero and rate under bhp_limit for extrapolation
|
||||
|
@ -74,9 +74,9 @@ public:
|
||||
EvalWell bhp = 0.0 * aqua;
|
||||
|
||||
//Find interpolation variables
|
||||
EvalWell flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
||||
EvalWell wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
||||
EvalWell gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
||||
EvalWell flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||
EvalWell wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||
EvalWell gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||
|
||||
//First, find the values to interpolate between
|
||||
//Value of FLO is negative in OPM for producers, but positive in VFP table
|
||||
|
@ -194,10 +194,10 @@ struct TrivialFixture {
|
||||
inline void initProperties() {
|
||||
table.reset(new Opm::VFPProdTable(1,
|
||||
1000.0,
|
||||
Opm::VFPProdTable::FLO_OIL,
|
||||
Opm::VFPProdTable::WFR_WOR,
|
||||
Opm::VFPProdTable::GFR_GOR,
|
||||
Opm::VFPProdTable::ALQ_UNDEF,
|
||||
Opm::VFPProdTable::FLO_TYPE::FLO_OIL,
|
||||
Opm::VFPProdTable::WFR_TYPE::WFR_WOR,
|
||||
Opm::VFPProdTable::GFR_TYPE::GFR_GOR,
|
||||
Opm::VFPProdTable::ALQ_TYPE::ALQ_UNDEF,
|
||||
flo_axis,
|
||||
thp_axis,
|
||||
wfr_axis,
|
||||
@ -231,7 +231,7 @@ private:
|
||||
int nz;
|
||||
int nu;
|
||||
int nv;
|
||||
Opm::VFPProdTable::array_type data;
|
||||
std::vector<double> data;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user