Add option for wvfpexp item 2 plus minor fixes

This commit is contained in:
Tor Harald Sandve
2022-04-08 10:15:13 +02:00
parent e875849497
commit 9364d4c54b
11 changed files with 35 additions and 33 deletions

View File

@@ -33,6 +33,7 @@
#include <opm/common/utility/TimeService.hpp> #include <opm/common/utility/TimeService.hpp>
#include <opm/simulators/wells/VFPHelpers.hpp> #include <opm/simulators/wells/VFPHelpers.hpp>
#include <opm/core/props/phaseUsageFromDeck.hpp>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@@ -46,23 +47,23 @@ struct Setup
std::unique_ptr<const Schedule> schedule; std::unique_ptr<const Schedule> schedule;
std::unique_ptr<SummaryState> summary_state; std::unique_ptr<SummaryState> summary_state;
std::unique_ptr<VFPProperties> vfp_properties; std::unique_ptr<VFPProperties> vfp_properties;
std::unique_ptr<WellState> well_state;
Setup(const std::string& file) Setup(const std::string& file)
{ {
Parser parser; Parser parser;
auto deck = parser.parseFile(file); auto deck = parser.parseFile(file);
ecl_state.reset(new EclipseState(deck) ); ecl_state.reset(new EclipseState(deck) );
{
const TableManager table( deck ); const TableManager table( deck );
const Runspec runspec(deck); const Runspec runspec(deck);
python = std::make_shared<Python>(); python = std::make_shared<Python>();
schedule.reset( new Schedule(deck, *ecl_state, python)); schedule.reset( new Schedule(deck, *ecl_state, python));
summary_state.reset( new SummaryState(TimeService::from_time_t(schedule->getStartTime()))); summary_state.reset( new SummaryState(TimeService::from_time_t(schedule->getStartTime())));
}
const int step = 0; const int step = 0;
const auto& sched_state = schedule->operator[](step); const auto& sched_state = schedule->operator[](step);
vfp_properties = std::make_unique<VFPProperties>(sched_state.vfpinj(), sched_state.vfpprod(), *well_state); WellState well_state(phaseUsage(runspec.phases()));
vfp_properties = std::make_unique<VFPProperties>(sched_state.vfpinj(), sched_state.vfpprod(), well_state);
}; };
}; };

View File

@@ -346,15 +346,15 @@ VFPEvaluation bhp(const VFPProdTable& table,
const double vapour, const double vapour,
const double thp, const double thp,
const double alq, const double alq,
const double explicit_wfr, const double explicit_wfr,
const double explicit_gfr, const double explicit_gfr,
const bool vfpexplicit) const bool use_vfpexplicit)
{ {
//Find interpolation variables //Find interpolation variables
double flo = detail::getFlo(table, aqua, liquid, vapour); double flo = detail::getFlo(table, aqua, liquid, vapour);
double wfr = detail::getWFR(table, aqua, liquid, vapour); double wfr = detail::getWFR(table, aqua, liquid, vapour);
double gfr = detail::getGFR(table, aqua, liquid, vapour); double gfr = detail::getGFR(table, aqua, liquid, vapour);
if (vfpexplicit) { if (use_vfpexplicit) {
wfr = explicit_wfr; wfr = explicit_wfr;
gfr = explicit_gfr; gfr = explicit_gfr;
} }

View File

@@ -139,7 +139,7 @@ VFPEvaluation bhp(const VFPProdTable& table,
const double alq, const double alq,
const double explicit_wfr, const double explicit_wfr,
const double explicit_gfr, const double explicit_gfr,
const bool vfpexplicit); const bool use_vfpexplicit);
VFPEvaluation bhp(const VFPInjTable& table, VFPEvaluation bhp(const VFPInjTable& table,
const double aqua, const double aqua,

View File

@@ -90,10 +90,10 @@ double VFPProdProperties::bhp(int table_id,
const double& alq, const double& alq,
const double& explicit_wfr, const double& explicit_wfr,
const double& explicit_gfr, const double& explicit_gfr,
const bool expvfp) const { const bool use_expvfp) const {
const VFPProdTable& table = detail::getTable(m_tables, table_id); const VFPProdTable& table = detail::getTable(m_tables, table_id);
detail::VFPEvaluation retval = detail::bhp(table, aqua, liquid, vapour, thp_arg, alq, explicit_wfr,explicit_gfr, expvfp); detail::VFPEvaluation retval = detail::bhp(table, aqua, liquid, vapour, thp_arg, alq, explicit_wfr,explicit_gfr, use_expvfp);
return retval.value; return retval.value;
} }
@@ -151,7 +151,7 @@ EvalWell VFPProdProperties::bhp(const int table_id,
const double& alq, const double& alq,
const double& explicit_wfr, const double& explicit_wfr,
const double& explicit_gfr, const double& explicit_gfr,
const bool expvfp) const const bool use_expvfp) const
{ {
//Get the table //Get the table
const VFPProdTable& table = detail::getTable(m_tables, table_id); const VFPProdTable& table = detail::getTable(m_tables, table_id);
@@ -161,7 +161,7 @@ EvalWell VFPProdProperties::bhp(const int table_id,
EvalWell flo = detail::getFlo(table, aqua, liquid, vapour); EvalWell flo = detail::getFlo(table, aqua, liquid, vapour);
EvalWell wfr = detail::getWFR(table, aqua, liquid, vapour); EvalWell wfr = detail::getWFR(table, aqua, liquid, vapour);
EvalWell gfr = detail::getGFR(table, aqua, liquid, vapour); EvalWell gfr = detail::getGFR(table, aqua, liquid, vapour);
if(expvfp) { if (use_expvfp) {
wfr = explicit_wfr; wfr = explicit_wfr;
gfr = explicit_gfr; gfr = explicit_gfr;
} }

View File

@@ -66,9 +66,9 @@ public:
const EvalWell& vapour, const EvalWell& vapour,
const double& thp, const double& thp,
const double& alq, const double& alq,
const double& wfr, const double& explicit_wfr,
const double& gfr, const double& explicit_gfr,
const bool expvfp) const; const bool use_expvfp) const;
/** /**
* Linear interpolation of bhp as a function of the input parameters * Linear interpolation of bhp as a function of the input parameters
@@ -90,7 +90,7 @@ public:
const double& alq, const double& alq,
const double& explicit_wfr, const double& explicit_wfr,
const double& explicit_gfr, const double& explicit_gfr,
const bool expvfp) const; const bool use_expvfp) const;
/** /**
* Linear interpolation of thp as a function of the input parameters * Linear interpolation of thp as a function of the input parameters

View File

@@ -769,7 +769,7 @@ namespace WellGroupHelpers
alq, alq,
0.0, //explicit_wfr 0.0, //explicit_wfr
0.0, //explicit_gfr 0.0, //explicit_gfr
false); //expvfp we dont support explicit lookup false); //use_expvfp we dont support explicit lookup
#define EXTRA_DEBUG_NETWORK 0 #define EXTRA_DEBUG_NETWORK 0
#if EXTRA_DEBUG_NETWORK #if EXTRA_DEBUG_NETWORK
std::ostringstream oss; std::ostringstream oss;

View File

@@ -495,8 +495,8 @@ calculateBhpFromThp(const WellState& well_state,
const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, rho, baseif_.gravity()); const double dp = wellhelpers::computeHydrostaticCorrection(baseif_.refDepth(), vfp_ref_depth, rho, baseif_.gravity());
const auto& wfr = baseif_.vfpProperties()->getExplicitWFR(controls.vfp_table_number, baseif_.indexOfWell()); const auto& wfr = baseif_.vfpProperties()->getExplicitWFR(controls.vfp_table_number, baseif_.indexOfWell());
const auto& gfr = baseif_.vfpProperties()->getExplicitGFR(controls.vfp_table_number, baseif_.indexOfWell()); const auto& gfr = baseif_.vfpProperties()->getExplicitGFR(controls.vfp_table_number, baseif_.indexOfWell());
const bool vfpexp = baseif_.vfpExplicit(); const bool use_vfpexplicit = baseif_.useVfpExplicit();
return baseif_.vfpProperties()->getProd()->bhp(controls.vfp_table_number, aqua, liquid, vapour, baseif_.getTHPConstraint(summaryState), baseif_.getALQ(well_state), wfr, gfr, vfpexp) - dp; return baseif_.vfpProperties()->getProd()->bhp(controls.vfp_table_number, aqua, liquid, vapour, baseif_.getTHPConstraint(summaryState), baseif_.getALQ(well_state), wfr, gfr, use_vfpexplicit) - dp;
} }
else { else {
OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER for well " + baseif_.name(), deferred_logger); OPM_DEFLOG_THROW(std::logic_error, "Expected INJECTOR or PRODUCER for well " + baseif_.name(), deferred_logger);

View File

@@ -414,9 +414,10 @@ bool WellInterfaceGeneric::isOperableAndSolvable() const
return operability_status_.isOperableAndSolvable(); return operability_status_.isOperableAndSolvable();
} }
bool WellInterfaceGeneric::vfpExplicit() const bool WellInterfaceGeneric::useVfpExplicit() const
{ {
return operability_status_.vfpexplicit; const auto& wvfpexp = well_ecl_.getWVFPEXP();
return (wvfpexp.extrapolate() || operability_status_.use_vfpexplicit);
} }
double WellInterfaceGeneric::getALQ(const WellState& well_state) const double WellInterfaceGeneric::getALQ(const WellState& well_state) const
@@ -666,9 +667,9 @@ computeBhpAtThpLimitProdCommon(const std::function<std::vector<double>(const dou
assert(rates.size() == 3); assert(rates.size() == 3);
const auto& wfr = this->vfpProperties()->getExplicitWFR(controls.vfp_table_number, this->indexOfWell()); const auto& wfr = this->vfpProperties()->getExplicitWFR(controls.vfp_table_number, this->indexOfWell());
const auto& gfr = this->vfpProperties()->getExplicitGFR(controls.vfp_table_number, this->indexOfWell()); const auto& gfr = this->vfpProperties()->getExplicitGFR(controls.vfp_table_number, this->indexOfWell());
const bool vfpexp = this->vfpExplicit(); const bool use_vfpexp = this->useVfpExplicit();
return this->vfpProperties()->getProd() return this->vfpProperties()->getProd()
->bhp(controls.vfp_table_number, rates[Water], rates[Oil], rates[Gas], thp_limit, alq_value, wfr, gfr, vfpexp) - dp; ->bhp(controls.vfp_table_number, rates[Water], rates[Oil], rates[Gas], thp_limit, alq_value, wfr, gfr, use_vfpexp) - dp;
}; };
// Make the flo() function. // Make the flo() function.

View File

@@ -88,7 +88,7 @@ public:
// whether the well is operable // whether the well is operable
bool isOperableAndSolvable() const; bool isOperableAndSolvable() const;
bool vfpExplicit () const; bool useVfpExplicit () const;
void initCompletions(); void initCompletions();
void closeCompletions(const WellTestState& wellTestState); void closeCompletions(const WellTestState& wellTestState);
@@ -267,7 +267,7 @@ protected:
//thp limit violated but not switched //thp limit violated but not switched
mutable bool thp_limit_violated_but_not_switched = false; mutable bool thp_limit_violated_but_not_switched = false;
bool vfpexplicit = false; bool use_vfpexplicit = false;
}; };
OperabilityStatus operability_status_; OperabilityStatus operability_status_;

View File

@@ -614,7 +614,7 @@ namespace Opm
updateWellOperability(ebos_simulator, well_state, deferred_logger); updateWellOperability(ebos_simulator, well_state, deferred_logger);
if (!this->operability_status_.isOperableAndSolvable()) { if (!this->operability_status_.isOperableAndSolvable()) {
this->operability_status_.vfpexplicit = true; this->operability_status_.use_vfpexplicit = true;
deferred_logger.debug("EXPLICIT_LOOKUP_VFP", deferred_logger.debug("EXPLICIT_LOOKUP_VFP",
"well not operable, trying with explicit vfp lookup: " + this->name()); "well not operable, trying with explicit vfp lookup: " + this->name());
updateWellOperability(ebos_simulator, well_state, deferred_logger); updateWellOperability(ebos_simulator, well_state, deferred_logger);

View File

@@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(InterpolateZero)
const double v = m / static_cast<double>(n-1); const double v = m / static_cast<double>(n-1);
//Note order of arguments! //Note order of arguments!
sum += properties->bhp(1, v, x, y, z, u, 0, 0, false); sum += properties->bhp(1, v, x, y, z, u, 0.0, 0.0, false);
} }
} }
} }