diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index fd3743669..8576c6505 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -235,7 +235,7 @@ namespace Opm { // update VFP properties vfp_properties_ = std::make_unique(sched_state.vfpinj(), sched_state.vfpprod(), - this->prevWellState()); + this->wellState()); this->initializeWellProdIndCalculators(); if (sched_state.events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) { this->runWellPIScaling(timeStepIdx, local_deferredLogger); @@ -340,6 +340,12 @@ namespace Opm { } } + for (auto& well : well_container_) { + if (well->isVFPActive(local_deferredLogger)){ + well->setPrevSurfaceRates(this->wellState(), this->prevWellState()); + } + } + // calculate the well potentials try { updateWellPotentials(reportStepIdx, diff --git a/opm/simulators/wells/SingleWellState.cpp b/opm/simulators/wells/SingleWellState.cpp index a8818c719..f79fd18de 100644 --- a/opm/simulators/wells/SingleWellState.cpp +++ b/opm/simulators/wells/SingleWellState.cpp @@ -44,6 +44,7 @@ SingleWellState::SingleWellState(const std::string& name_, , productivity_index(pu_.num_phases) , surface_rates(pu_.num_phases) , reservoir_rates(pu_.num_phases) + , prev_surface_rates(pu_.num_phases) , perf_data(perf_input.size(), pressure_first_connection, !is_producer, pu_.num_phases) , trivial_target(false) { @@ -84,6 +85,7 @@ void SingleWellState::shut() { this->thp = 0; this->status = Well::Status::SHUT; std::fill(this->surface_rates.begin(), this->surface_rates.end(), 0); + std::fill(this->prev_surface_rates.begin(), this->prev_surface_rates.end(), 0); std::fill(this->reservoir_rates.begin(), this->reservoir_rates.end(), 0); std::fill(this->productivity_index.begin(), this->productivity_index.end(), 0); @@ -296,6 +298,7 @@ bool SingleWellState::operator==(const SingleWellState& rhs) const this->productivity_index == rhs.productivity_index && this->surface_rates == rhs.surface_rates && this->reservoir_rates == rhs.reservoir_rates && + this->prev_surface_rates == rhs.prev_surface_rates && this->trivial_target == rhs.trivial_target && this->segments == rhs.segments && this->events == rhs.events && diff --git a/opm/simulators/wells/SingleWellState.hpp b/opm/simulators/wells/SingleWellState.hpp index 096199018..2935b3e85 100644 --- a/opm/simulators/wells/SingleWellState.hpp +++ b/opm/simulators/wells/SingleWellState.hpp @@ -63,6 +63,7 @@ public: serializer(productivity_index); serializer(surface_rates); serializer(reservoir_rates); + serializer(prev_surface_rates); serializer(trivial_target); serializer(segments); serializer(events); @@ -95,6 +96,7 @@ public: std::vector productivity_index; std::vector surface_rates; std::vector reservoir_rates; + std::vector prev_surface_rates; PerfData perf_data; bool trivial_target; SegmentState segments; diff --git a/opm/simulators/wells/VFPHelpers.cpp b/opm/simulators/wells/VFPHelpers.cpp index b25ff3de7..5ce6c42f4 100644 --- a/opm/simulators/wells/VFPHelpers.cpp +++ b/opm/simulators/wells/VFPHelpers.cpp @@ -348,7 +348,7 @@ VFPEvaluation bhp(const VFPProdTable& table, double flo = detail::getFlo(table, aqua, liquid, vapour); double wfr = detail::getWFR(table, aqua, liquid, vapour); double gfr = detail::getGFR(table, aqua, liquid, vapour); - if (use_vfpexplicit) { + if (use_vfpexplicit || -flo < table.getFloAxis().front()) { wfr = explicit_wfr; gfr = explicit_gfr; } diff --git a/opm/simulators/wells/VFPProdProperties.cpp b/opm/simulators/wells/VFPProdProperties.cpp index 10052b03f..072310410 100644 --- a/opm/simulators/wells/VFPProdProperties.cpp +++ b/opm/simulators/wells/VFPProdProperties.cpp @@ -161,7 +161,7 @@ EvalWell VFPProdProperties::bhp(const int table_id, EvalWell flo = detail::getFlo(table, aqua, liquid, vapour); EvalWell wfr = detail::getWFR(table, aqua, liquid, vapour); EvalWell gfr = detail::getGFR(table, aqua, liquid, vapour); - if (use_expvfp) { + if (use_expvfp || -flo.value() < table.getFloAxis().front()) { wfr = explicit_wfr; gfr = explicit_gfr; } diff --git a/opm/simulators/wells/VFPProperties.hpp b/opm/simulators/wells/VFPProperties.hpp index 6d1fee665..96d1b0d4c 100644 --- a/opm/simulators/wells/VFPProperties.hpp +++ b/opm/simulators/wells/VFPProperties.hpp @@ -72,7 +72,7 @@ public: } double getExplicitWFR(const int table_id, const size_t well_index) const { - const auto& rates = well_state_.well(well_index).surface_rates; + const auto& rates = well_state_.well(well_index).prev_surface_rates; const auto& pu = well_state_.phaseUsage(); const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; const auto& liquid = pu.phase_used[BlackoilPhases::Liquid]? rates[pu.phase_pos[BlackoilPhases::Liquid]]:0.0; @@ -82,7 +82,7 @@ public: } double getExplicitGFR(const int table_id, const size_t well_index) const { - const auto& rates = well_state_.well(well_index).surface_rates; + const auto& rates = well_state_.well(well_index).prev_surface_rates; const auto& pu = well_state_.phaseUsage(); const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; const auto& liquid = pu.phase_used[BlackoilPhases::Liquid]? rates[pu.phase_pos[BlackoilPhases::Liquid]]:0.0; diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index b2dc6a5ad..ef76195e8 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -313,7 +313,7 @@ public: /// to the rates returned by computeCurrentWellRates(). void updateWellStateRates(const Simulator& ebosSimulator, WellState& well_state, - DeferredLogger& deferred_logger) const; + DeferredLogger& deferred_logger) const; void solveWellEquation(const Simulator& ebosSimulator, WellState& well_state, diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index 214e5d7fb..7aac73b38 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -347,6 +347,17 @@ void WellInterfaceGeneric::setVFPProperties(const VFPProperties* vfp_properties_ vfp_properties_ = vfp_properties_arg; } +void WellInterfaceGeneric::setPrevSurfaceRates(WellState& well_state, + const WellState& prev_well_state) const + { + auto& ws = well_state.well(this->index_of_well_); + if (!this->changedToOpenThisStep()){ + ws.prev_surface_rates = prev_well_state.well(this->index_of_well_).surface_rates; + } else { + ws.prev_surface_rates = ws.surface_rates; + } + } + void WellInterfaceGeneric::setGuideRate(const GuideRate* guide_rate_arg) { guide_rate_ = guide_rate_arg; @@ -471,7 +482,7 @@ bool WellInterfaceGeneric::isOperableAndSolvable() const bool WellInterfaceGeneric::useVfpExplicit() const { const auto& wvfpexp = well_ecl_.getWVFPEXP(); - return ((wvfpexp.explicit_lookup() && !changedToOpenThisStep())|| operability_status_.use_vfpexplicit); + return (wvfpexp.explicit_lookup() || operability_status_.use_vfpexplicit); } bool WellInterfaceGeneric::thpLimitViolatedButNotSwitched() const diff --git a/opm/simulators/wells/WellInterfaceGeneric.hpp b/opm/simulators/wells/WellInterfaceGeneric.hpp index 4e9fbd1d8..512e66d86 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.hpp +++ b/opm/simulators/wells/WellInterfaceGeneric.hpp @@ -94,6 +94,7 @@ public: void closeCompletions(const WellTestState& wellTestState); void setVFPProperties(const VFPProperties* vfp_properties_arg); + void setPrevSurfaceRates(WellState& well_state, const WellState& prev_well_state) const; void setGuideRate(const GuideRate* guide_rate_arg); void setWellEfficiencyFactor(const double efficiency_factor); void setRepRadiusPerfLength(); diff --git a/regressionTests.cmake b/regressionTests.cmake index c4b3761cf..4618630e3 100644 --- a/regressionTests.cmake +++ b/regressionTests.cmake @@ -1191,14 +1191,16 @@ add_test_compareECLFiles(CASENAME 01_wgrupcon SIMULATOR flow ABS_TOL ${abs_tol} REL_TOL ${rel_tol} - DIR wgrupcon) + DIR wgrupcon + TEST_ARGS --enable-tuning=true) add_test_compareECLFiles(CASENAME 02_wgrupcon FILENAME 02-WGRUPCON SIMULATOR flow ABS_TOL ${abs_tol} REL_TOL ${rel_tol} - DIR wgrupcon) + DIR wgrupcon + TEST_ARGS --enable-tuning=true) add_test_compareECLFiles(CASENAME winjmult_stdw FILENAME WINJMULT_STDW SIMULATOR flow