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.
|
// Make the flo() function.
|
||||||
auto flo_type = table.getFloType();
|
auto flo = [&table](const std::vector<double>& rates) {
|
||||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
@ -3830,9 +3829,8 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make the flo() function.
|
// Make the flo() function.
|
||||||
auto flo_type = table.getFloType();
|
auto flo = [&table](const std::vector<double>& rates) {
|
||||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
|
@ -3726,9 +3726,8 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make the flo() function.
|
// Make the flo() function.
|
||||||
auto flo_type = table.getFloType();
|
auto flo = [&table](const std::vector<double>& rates) {
|
||||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
@ -3932,9 +3931,8 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Make the flo() function.
|
// Make the flo() function.
|
||||||
auto flo_type = table.getFloType();
|
auto flo = [&table](const std::vector<double>& rates) {
|
||||||
auto flo = [flo_type](const std::vector<double>& rates) {
|
return detail::getFlo(table, rates[Water], rates[Oil], rates[Gas]);
|
||||||
return detail::getFlo(rates[Water], rates[Oil], rates[Gas], flo_type);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Make the frates() function.
|
// Make the frates() function.
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <opm/common/ErrorMacros.hpp>
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.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/Math.hpp>
|
||||||
#include <opm/material/densead/Evaluation.hpp>
|
#include <opm/material/densead/Evaluation.hpp>
|
||||||
|
|
||||||
@ -40,11 +41,14 @@ namespace detail {
|
|||||||
/**
|
/**
|
||||||
* Returns zero if input value is NaN of INF
|
* 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);
|
const bool nan_or_inf = std::isnan(value) || std::isinf(value);
|
||||||
|
|
||||||
if (nan_or_inf) {
|
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;
|
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
|
* Returns zero if input value is NaN or INF
|
||||||
*/
|
*/
|
||||||
template <class EvalWell>
|
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());
|
const bool nan_or_inf = std::isnan(value.value()) || std::isinf(value.value());
|
||||||
|
|
||||||
if (nan_or_inf) {
|
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>;
|
using Toolbox = MathToolbox<EvalWell>;
|
||||||
@ -74,21 +81,20 @@ inline EvalWell zeroIfNanInf(const EvalWell& value) {
|
|||||||
* @return Production rate of oil, gas or liquid.
|
* @return Production rate of oil, gas or liquid.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
static T getFlo(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||||
const VFPProdTable::FLO_TYPE& type) {
|
auto type = table.getFloType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VFPProdTable::FLO_OIL:
|
case VFPProdTable::FLO_TYPE::FLO_OIL:
|
||||||
//Oil = liquid phase
|
//Oil = liquid phase
|
||||||
return liquid;
|
return liquid;
|
||||||
case VFPProdTable::FLO_LIQ:
|
case VFPProdTable::FLO_TYPE::FLO_LIQ:
|
||||||
//Liquid = aqua + liquid phases
|
//Liquid = aqua + liquid phases
|
||||||
return aqua + liquid;
|
return aqua + liquid;
|
||||||
case VFPProdTable::FLO_GAS:
|
case VFPProdTable::FLO_TYPE::FLO_GAS:
|
||||||
//Gas = vapor phase
|
//Gas = vapor phase
|
||||||
return vapour;
|
return vapour;
|
||||||
case VFPProdTable::FLO_INVALID: //Intentional fall-through
|
default:
|
||||||
default:
|
throw std::logic_error("Invalid FLO_TYPE");
|
||||||
OPM_THROW(std::logic_error, "Invalid FLO_TYPE: '" << 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.
|
* @return Production rate of oil, gas or liquid.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T getFlo(const T& aqua, const T& liquid, const T& vapour,
|
static T getFlo(const VFPInjTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||||
const VFPInjTable::FLO_TYPE& type) {
|
auto type = table.getFloType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VFPInjTable::FLO_OIL:
|
case VFPInjTable::FLO_TYPE::FLO_OIL:
|
||||||
//Oil = liquid phase
|
//Oil = liquid phase
|
||||||
return liquid;
|
return liquid;
|
||||||
case VFPInjTable::FLO_WAT:
|
case VFPInjTable::FLO_TYPE::FLO_WAT:
|
||||||
//Liquid = aqua phase
|
//Liquid = aqua phase
|
||||||
return aqua;
|
return aqua;
|
||||||
case VFPInjTable::FLO_GAS:
|
case VFPInjTable::FLO_TYPE::FLO_GAS:
|
||||||
//Gas = vapor phase
|
//Gas = vapor phase
|
||||||
return vapour;
|
return vapour;
|
||||||
case VFPInjTable::FLO_INVALID: //Intentional fall-through
|
default:
|
||||||
default:
|
throw std::logic_error("Invalid FLO_TYPE");
|
||||||
OPM_THROW(std::logic_error, "Invalid FLO_TYPE: '" << 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.
|
* @return Production rate of oil, gas or liquid.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T getWFR(const T& aqua, const T& liquid, const T& vapour,
|
static T getWFR(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||||
const VFPProdTable::WFR_TYPE& type) {
|
auto type = table.getWFRType();
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case VFPProdTable::WFR_WOR: {
|
case VFPProdTable::WFR_TYPE::WFR_WOR:
|
||||||
//Water-oil ratio = water / oil
|
//Water-oil ratio = water / oil
|
||||||
T wor = aqua / liquid;
|
return zeroIfNanInf(aqua/liquid, "WOR", table);
|
||||||
return zeroIfNanInf(wor);
|
|
||||||
}
|
case VFPProdTable::WFR_TYPE::WFR_WCT:
|
||||||
case VFPProdTable::WFR_WCT:
|
//Water cut = water / (water + oil)
|
||||||
//Water cut = water / (water + oil)
|
return zeroIfNanInf(aqua / (aqua + liquid), "WCT", table);
|
||||||
return zeroIfNanInf(aqua / (aqua + liquid));
|
|
||||||
case VFPProdTable::WFR_WGR:
|
case VFPProdTable::WFR_TYPE::WFR_WGR:
|
||||||
//Water-gas ratio = water / gas
|
//Water-gas ratio = water / gas
|
||||||
return zeroIfNanInf(aqua / vapour);
|
return zeroIfNanInf(aqua / vapour, "WGR", table);
|
||||||
case VFPProdTable::WFR_INVALID: //Intentional fall-through
|
|
||||||
default:
|
default:
|
||||||
OPM_THROW(std::logic_error, "Invalid WFR_TYPE: '" << type << "'");
|
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.
|
* @return Production rate of oil, gas or liquid.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T getGFR(const T& aqua, const T& liquid, const T& vapour,
|
static T getGFR(const VFPProdTable& table, const T& aqua, const T& liquid, const T& vapour) {
|
||||||
const VFPProdTable::GFR_TYPE& type) {
|
auto type = table.getGFRType();
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case VFPProdTable::GFR_GOR:
|
case VFPProdTable::GFR_TYPE::GFR_GOR:
|
||||||
// Gas-oil ratio = gas / oil
|
// Gas-oil ratio = gas / oil
|
||||||
return zeroIfNanInf(vapour / liquid);
|
return zeroIfNanInf(vapour / liquid, "GOR", table);
|
||||||
case VFPProdTable::GFR_GLR:
|
case VFPProdTable::GFR_TYPE::GFR_GLR:
|
||||||
// Gas-liquid ratio = gas / (oil + water)
|
// Gas-liquid ratio = gas / (oil + water)
|
||||||
return zeroIfNanInf(vapour / (liquid + aqua));
|
return zeroIfNanInf(vapour / (liquid + aqua), "GLR", table);
|
||||||
case VFPProdTable::GFR_OGR:
|
case VFPProdTable::GFR_TYPE::GFR_OGR:
|
||||||
// Oil-gas ratio = oil / gas
|
// Oil-gas ratio = oil / gas
|
||||||
return zeroIfNanInf(liquid / vapour);
|
return zeroIfNanInf(liquid / vapour, "OGR", table);
|
||||||
case VFPProdTable::GFR_INVALID: //Intentional fall-through
|
default:
|
||||||
default:
|
throw std::logic_error("Invalid GFR_TYPE");
|
||||||
OPM_THROW(std::logic_error, "Invalid GFR_TYPE: '" << type << "'");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,9 +514,9 @@ inline VFPEvaluation bhp(const VFPProdTable& table,
|
|||||||
const double& thp,
|
const double& thp,
|
||||||
const double& alq) {
|
const double& alq) {
|
||||||
//Find interpolation variables
|
//Find interpolation variables
|
||||||
double flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
double flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||||
double wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
double wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||||
double gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
double gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||||
|
|
||||||
//First, find the values to interpolate between
|
//First, find the values to interpolate between
|
||||||
//Recall that flo is negative in Opm, so switch sign.
|
//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& vapour,
|
||||||
const double& thp) {
|
const double& thp) {
|
||||||
//Find interpolation variables
|
//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
|
//First, find the values to interpolate between
|
||||||
auto flo_i = detail::findInterpData(flo, table.getFloAxis());
|
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);
|
const VFPInjTable& table = detail::getTable(m_tables, table_id);
|
||||||
|
|
||||||
//Find interpolation variables
|
//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();
|
const std::vector<double> thp_array = table.getTHPAxis();
|
||||||
int nthp = thp_array.size();
|
int nthp = thp_array.size();
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
EvalWell bhp = 0.0 * aqua;
|
EvalWell bhp = 0.0 * aqua;
|
||||||
|
|
||||||
//Find interpolation variables
|
//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
|
//First, find the values to interpolate between
|
||||||
//Value of FLO is negative in OPM for producers, but positive in VFP table
|
//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 {
|
} else {
|
||||||
// The usual case.
|
// The usual case.
|
||||||
// Recall that production rate is negative in Opm, so switch the sign.
|
// Recall that production rate is negative in Opm, so switch the sign.
|
||||||
flo = -detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
flo = -detail::getFlo(table, aqua, liquid, vapour);
|
||||||
wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||||
gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<double> thp_array = table.getTHPAxis();
|
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 aqua_bhp_limit = rates_bhp_limit[Water];
|
||||||
const double liquid_bhp_limit = rates_bhp_limit[Oil];
|
const double liquid_bhp_limit = rates_bhp_limit[Oil];
|
||||||
const double vapour_bhp_limit = rates_bhp_limit[Gas];
|
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 aqua_bhp_middle = rates_bhp_middle[Water];
|
||||||
const double liquid_bhp_middle = rates_bhp_middle[Oil];
|
const double liquid_bhp_middle = rates_bhp_middle[Oil];
|
||||||
const double vapour_bhp_middle = rates_bhp_middle[Gas];
|
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
|
// 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 wfr = detail::getWFR(table, aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle);
|
||||||
const double gfr = detail::getGFR(aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle, table.getGFRType());
|
const double gfr = detail::getGFR(table, aqua_bhp_middle, liquid_bhp_middle, vapour_bhp_middle);
|
||||||
|
|
||||||
// we get the flo sampling points from the table,
|
// we get the flo sampling points from the table,
|
||||||
// then extend it with zero and rate under bhp_limit for extrapolation
|
// then extend it with zero and rate under bhp_limit for extrapolation
|
||||||
|
@ -74,9 +74,9 @@ public:
|
|||||||
EvalWell bhp = 0.0 * aqua;
|
EvalWell bhp = 0.0 * aqua;
|
||||||
|
|
||||||
//Find interpolation variables
|
//Find interpolation variables
|
||||||
EvalWell flo = detail::getFlo(aqua, liquid, vapour, table.getFloType());
|
EvalWell flo = detail::getFlo(table, aqua, liquid, vapour);
|
||||||
EvalWell wfr = detail::getWFR(aqua, liquid, vapour, table.getWFRType());
|
EvalWell wfr = detail::getWFR(table, aqua, liquid, vapour);
|
||||||
EvalWell gfr = detail::getGFR(aqua, liquid, vapour, table.getGFRType());
|
EvalWell gfr = detail::getGFR(table, aqua, liquid, vapour);
|
||||||
|
|
||||||
//First, find the values to interpolate between
|
//First, find the values to interpolate between
|
||||||
//Value of FLO is negative in OPM for producers, but positive in VFP table
|
//Value of FLO is negative in OPM for producers, but positive in VFP table
|
||||||
|
@ -194,10 +194,10 @@ struct TrivialFixture {
|
|||||||
inline void initProperties() {
|
inline void initProperties() {
|
||||||
table.reset(new Opm::VFPProdTable(1,
|
table.reset(new Opm::VFPProdTable(1,
|
||||||
1000.0,
|
1000.0,
|
||||||
Opm::VFPProdTable::FLO_OIL,
|
Opm::VFPProdTable::FLO_TYPE::FLO_OIL,
|
||||||
Opm::VFPProdTable::WFR_WOR,
|
Opm::VFPProdTable::WFR_TYPE::WFR_WOR,
|
||||||
Opm::VFPProdTable::GFR_GOR,
|
Opm::VFPProdTable::GFR_TYPE::GFR_GOR,
|
||||||
Opm::VFPProdTable::ALQ_UNDEF,
|
Opm::VFPProdTable::ALQ_TYPE::ALQ_UNDEF,
|
||||||
flo_axis,
|
flo_axis,
|
||||||
thp_axis,
|
thp_axis,
|
||||||
wfr_axis,
|
wfr_axis,
|
||||||
@ -231,7 +231,7 @@ private:
|
|||||||
int nz;
|
int nz;
|
||||||
int nu;
|
int nu;
|
||||||
int nv;
|
int nv;
|
||||||
Opm::VFPProdTable::array_type data;
|
std::vector<double> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user