From 5212d20a96ed5aa6524a278f1023428e48834cab Mon Sep 17 00:00:00 2001 From: Stein Krogstad Date: Sun, 21 May 2023 19:53:47 +0200 Subject: [PATCH] Add explicit rates to well state --- .../wells/BlackoilWellModel_impl.hpp | 8 +++++++- opm/simulators/wells/SingleWellState.cpp | 3 +++ opm/simulators/wells/SingleWellState.hpp | 2 ++ opm/simulators/wells/VFPProperties.hpp | 4 ++-- opm/simulators/wells/WellInterface.hpp | 3 +++ opm/simulators/wells/WellInterfaceGeneric.cpp | 2 +- opm/simulators/wells/WellInterface_impl.hpp | 19 +++++++++++++++++++ 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index fd3743669..1b59efd78 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->setExplicitSurfaceRates(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..4715c0bbc 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) + , explicit_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->explicit_surface_rates.begin(), this->explicit_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->explicit_surface_rates == rhs.explicit_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..4609f497d 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(explicit_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 explicit_surface_rates; PerfData perf_data; bool trivial_target; SegmentState segments; diff --git a/opm/simulators/wells/VFPProperties.hpp b/opm/simulators/wells/VFPProperties.hpp index 6d1fee665..bd24ccc2e 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).explicit_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).explicit_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..be3b034c5 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -315,6 +315,9 @@ public: WellState& well_state, DeferredLogger& deferred_logger) const; + void setExplicitSurfaceRates(WellState& well_state, + const WellState& prev_well_state) const; + void solveWellEquation(const Simulator& ebosSimulator, WellState& well_state, const GroupState& group_state, diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index 214e5d7fb..ef23bd102 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -471,7 +471,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/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 0aeab1e5c..4156b18de 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1192,6 +1192,25 @@ namespace Opm } } + template + void + WellInterface:: + setExplicitSurfaceRates(WellState& well_state, + const WellState& prev_well_state) const + { + const int np = this->number_of_phases_; + auto& ws = well_state.well(this->index_of_well_); + if (!this->changedToOpenThisStep()){ + for (int p = 0; pindex_of_well_).surface_rates[p]; + } + } else { + for (int p = 0; p typename WellInterface::Eval WellInterface::getPerfCellPressure(const typename WellInterface::FluidState& fs) const