Add explicit rates to well state

This commit is contained in:
Stein Krogstad 2023-05-21 19:53:47 +02:00
parent a560b06dce
commit 5212d20a96
7 changed files with 37 additions and 4 deletions

View File

@ -235,7 +235,7 @@ namespace Opm {
// update VFP properties // update VFP properties
vfp_properties_ = std::make_unique<VFPProperties>(sched_state.vfpinj(), vfp_properties_ = std::make_unique<VFPProperties>(sched_state.vfpinj(),
sched_state.vfpprod(), sched_state.vfpprod(),
this->prevWellState()); this->wellState());
this->initializeWellProdIndCalculators(); this->initializeWellProdIndCalculators();
if (sched_state.events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) { if (sched_state.events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) {
this->runWellPIScaling(timeStepIdx, local_deferredLogger); 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 // calculate the well potentials
try { try {
updateWellPotentials(reportStepIdx, updateWellPotentials(reportStepIdx,

View File

@ -44,6 +44,7 @@ SingleWellState::SingleWellState(const std::string& name_,
, productivity_index(pu_.num_phases) , productivity_index(pu_.num_phases)
, surface_rates(pu_.num_phases) , surface_rates(pu_.num_phases)
, reservoir_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) , perf_data(perf_input.size(), pressure_first_connection, !is_producer, pu_.num_phases)
, trivial_target(false) , trivial_target(false)
{ {
@ -84,6 +85,7 @@ void SingleWellState::shut() {
this->thp = 0; this->thp = 0;
this->status = Well::Status::SHUT; this->status = Well::Status::SHUT;
std::fill(this->surface_rates.begin(), this->surface_rates.end(), 0); 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->reservoir_rates.begin(), this->reservoir_rates.end(), 0);
std::fill(this->productivity_index.begin(), this->productivity_index.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->productivity_index == rhs.productivity_index &&
this->surface_rates == rhs.surface_rates && this->surface_rates == rhs.surface_rates &&
this->reservoir_rates == rhs.reservoir_rates && this->reservoir_rates == rhs.reservoir_rates &&
this->explicit_surface_rates == rhs.explicit_surface_rates &&
this->trivial_target == rhs.trivial_target && this->trivial_target == rhs.trivial_target &&
this->segments == rhs.segments && this->segments == rhs.segments &&
this->events == rhs.events && this->events == rhs.events &&

View File

@ -63,6 +63,7 @@ public:
serializer(productivity_index); serializer(productivity_index);
serializer(surface_rates); serializer(surface_rates);
serializer(reservoir_rates); serializer(reservoir_rates);
serializer(explicit_surface_rates);
serializer(trivial_target); serializer(trivial_target);
serializer(segments); serializer(segments);
serializer(events); serializer(events);
@ -95,6 +96,7 @@ public:
std::vector<double> productivity_index; std::vector<double> productivity_index;
std::vector<double> surface_rates; std::vector<double> surface_rates;
std::vector<double> reservoir_rates; std::vector<double> reservoir_rates;
std::vector<double> explicit_surface_rates;
PerfData perf_data; PerfData perf_data;
bool trivial_target; bool trivial_target;
SegmentState segments; SegmentState segments;

View File

@ -72,7 +72,7 @@ public:
} }
double getExplicitWFR(const int table_id, const size_t well_index) const { 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& pu = well_state_.phaseUsage();
const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; 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; 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 { 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& pu = well_state_.phaseUsage();
const auto& aqua = pu.phase_used[BlackoilPhases::Aqua]? rates[pu.phase_pos[BlackoilPhases::Aqua]]:0.0; 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; const auto& liquid = pu.phase_used[BlackoilPhases::Liquid]? rates[pu.phase_pos[BlackoilPhases::Liquid]]:0.0;

View File

@ -315,6 +315,9 @@ public:
WellState& well_state, WellState& well_state,
DeferredLogger& deferred_logger) const; DeferredLogger& deferred_logger) const;
void setExplicitSurfaceRates(WellState& well_state,
const WellState& prev_well_state) const;
void solveWellEquation(const Simulator& ebosSimulator, void solveWellEquation(const Simulator& ebosSimulator,
WellState& well_state, WellState& well_state,
const GroupState& group_state, const GroupState& group_state,

View File

@ -471,7 +471,7 @@ bool WellInterfaceGeneric::isOperableAndSolvable() const
bool WellInterfaceGeneric::useVfpExplicit() const bool WellInterfaceGeneric::useVfpExplicit() const
{ {
const auto& wvfpexp = well_ecl_.getWVFPEXP(); 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 bool WellInterfaceGeneric::thpLimitViolatedButNotSwitched() const

View File

@ -1192,6 +1192,25 @@ namespace Opm
} }
} }
template <typename TypeTag>
void
WellInterface<TypeTag>::
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; p<np; ++p){
ws.explicit_surface_rates[p] = prev_well_state.well(this->index_of_well_).surface_rates[p];
}
} else {
for (int p = 0; p<np; ++p){
ws.explicit_surface_rates[p] = ws.surface_rates[p];
}
}
}
template<typename TypeTag> template<typename TypeTag>
typename WellInterface<TypeTag>::Eval typename WellInterface<TypeTag>::Eval
WellInterface<TypeTag>::getPerfCellPressure(const typename WellInterface<TypeTag>::FluidState& fs) const WellInterface<TypeTag>::getPerfCellPressure(const typename WellInterface<TypeTag>::FluidState& fs) const