Skip to content

Commit

Permalink
Include checking for zero targets from groups where required
Browse files Browse the repository at this point in the history
  • Loading branch information
steink committed Mar 19, 2024
1 parent aa15e2c commit 2355c4c
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 80 deletions.
2 changes: 1 addition & 1 deletion opm/simulators/wells/BlackoilWellModel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ namespace Opm {
// This is done only for producers, as injectors will only have a single
// nonzero phase anyway.
for (auto& well : well_container_) {
const bool zero_target = well->stopppedOrZeroRateTarget(summaryState, this->wellState());
const bool zero_target = well->stoppedOrZeroRateTarget(simulator_, this->wellState(), local_deferredLogger);
if (well->isProducer() && !zero_target) {
well->updateWellStateRates(simulator_, this->wellState(), local_deferredLogger);
}
Expand Down
3 changes: 2 additions & 1 deletion opm/simulators/wells/MultisegmentWellAssemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ assembleControlEq(const WellState& well_state,
const double rho,
const PrimaryVariables& primary_variables,
Equations& eqns1,
const bool stopped_or_zero_target,
DeferredLogger& deferred_logger) const
{
static constexpr int Gas = BlackoilPhases::Vapour;
Expand All @@ -116,7 +117,7 @@ assembleControlEq(const WellState& well_state,
return rates;
};

if (well_.stopppedOrZeroRateTarget(summaryState, well_state)) {
if (stopped_or_zero_target) {
control_eq = primary_variables.getWQTotal();
} else if (well_.isInjector() ) {
// Find scaling factor to get injection rate,
Expand Down
1 change: 1 addition & 0 deletions opm/simulators/wells/MultisegmentWellAssemble.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class MultisegmentWellAssemble
const double rho,
const PrimaryVariables& primary_variables,
Equations& eqns,
const bool stopped_or_zero_target,
DeferredLogger& deferred_logger) const;

//! \brief Assemble piece of the acceleration term
Expand Down
10 changes: 6 additions & 4 deletions opm/simulators/wells/MultisegmentWell_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace Opm
const WellState& well_state,
DeferredLogger& /* deferred_logger */)
{
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
const bool stop_or_zero_rate_target = this->stoppedOrZeroRateTargetIndividual(summary_state, well_state);
this->primary_variables_.update(well_state, stop_or_zero_rate_target);
}

Expand Down Expand Up @@ -684,7 +684,7 @@ namespace Opm

const double dFLimit = this->param_.dwell_fraction_max_;
const double max_pressure_change = this->param_.max_pressure_change_ms_wells_;
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
const bool stop_or_zero_rate_target = this->stoppedOrZeroRateTargetIndividual(summary_state, well_state);
this->primary_variables_.updateNewton(dwells,
relaxation_factor,
dFLimit,
Expand Down Expand Up @@ -1625,7 +1625,7 @@ namespace Opm
const bool allow_open = this->well_ecl_.getStatus() == WellStatus::OPEN &&
well_state.well(this->index_of_well_).status == WellStatus::OPEN;
// don't allow switcing for wells under zero rate target or requested fixed status and control
const bool allow_switching = !this->wellUnderZeroRateTarget(summary_state, well_state) &&
const bool allow_switching = !this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) &&
(!fixed_control || !fixed_status) && allow_open;
bool changed = false;
bool final_check = false;
Expand Down Expand Up @@ -1894,10 +1894,11 @@ namespace Opm
}
}

// the fourth dequation, the pressure drop equation
// the fourth equation, the pressure drop equation
if (seg == 0) { // top segment, pressure equation is the control equation
const auto& summaryState = simulator.vanguard().summaryState();
const Schedule& schedule = simulator.vanguard().schedule();
const bool stopped_or_zero_target = this->stoppedOrZeroRateTarget(simulator, well_state, deferred_logger);
MultisegmentWellAssemble(*this).
assembleControlEq(well_state,
group_state,
Expand All @@ -1908,6 +1909,7 @@ namespace Opm
getRefDensity(),
this->primary_variables_,
this->linSys_,
stopped_or_zero_target,
deferred_logger);
} else {
const UnitSystem& unit_system = simulator.vanguard().eclState().getDeckUnitSystem();
Expand Down
3 changes: 2 additions & 1 deletion opm/simulators/wells/StandardWellAssemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ assembleControlEq(const WellState& well_state,
const PrimaryVariables& primary_variables,
const double rho,
StandardWellEquations<Scalar,Indices::numEq>& eqns1,
const bool stopped_or_zero_target,
DeferredLogger& deferred_logger) const
{
static constexpr int Water = BlackoilPhases::Aqua;
Expand All @@ -119,7 +120,7 @@ assembleControlEq(const WellState& well_state,
return rates;
};

if (well_.stopppedOrZeroRateTarget(summaryState, well_state)) {
if (stopped_or_zero_target) {
control_eq = primary_variables.eval(PrimaryVariables::WQTotal);
} else if (well_.isInjector()) {
// Find injection rate.
Expand Down
1 change: 1 addition & 0 deletions opm/simulators/wells/StandardWellAssemble.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class StandardWellAssemble
const PrimaryVariables& primary_variables,
const double rho,
StandardWellEquations<Scalar,Indices::numEq>& eqns,
const bool stopped_or_zero_target,
DeferredLogger& deferred_logger) const;

//! \brief Assemble injectivity equation.
Expand Down
12 changes: 6 additions & 6 deletions opm/simulators/wells/StandardWell_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,15 @@ namespace Opm

const auto& summaryState = simulator.vanguard().summaryState();
const Schedule& schedule = simulator.vanguard().schedule();
const bool stopped_or_zero_target = this->stoppedOrZeroRateTarget(simulator, well_state, deferred_logger);
StandardWellAssemble<FluidSystem,Indices>(*this).
assembleControlEq(well_state, group_state,
schedule, summaryState,
inj_controls, prod_controls,
this->primary_variables_,
this->connections_.rho(),
this->linSys_,
stopped_or_zero_target,
deferred_logger);


Expand Down Expand Up @@ -692,7 +694,7 @@ namespace Opm
{
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;

const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
const bool stop_or_zero_rate_target = this->stoppedOrZeroRateTargetIndividual(summary_state, well_state);
updatePrimaryVariablesNewton(dwells, stop_or_zero_rate_target, deferred_logger);

updateWellStateFromPrimaryVariables(stop_or_zero_rate_target, well_state, summary_state, deferred_logger);
Expand Down Expand Up @@ -1183,7 +1185,7 @@ namespace Opm
constexpr double stopped_factor = 1.e-4;
// use stricter tolerance for dynamic thp to ameliorate network convergence
constexpr double dynamic_thp_factor = 1.e-1;
if (this->stopppedOrZeroRateTarget(summary_state, well_state)) {
if (this->stoppedOrZeroRateTargetIndividual(summary_state, well_state)) {
tol_wells = tol_wells*stopped_factor;
} else if (this->getDynamicThpLimit()) {
tol_wells = tol_wells*dynamic_thp_factor;
Expand Down Expand Up @@ -1771,7 +1773,7 @@ namespace Opm
{
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;

const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
const bool stop_or_zero_rate_target = this->stoppedOrZeroRateTargetIndividual(summary_state, well_state);
this->primary_variables_.update(well_state, stop_or_zero_rate_target, deferred_logger);

// other primary variables related to polymer injection
Expand Down Expand Up @@ -2357,9 +2359,7 @@ namespace Opm
const bool allow_open = this->well_ecl_.getStatus() == WellStatus::OPEN &&
well_state.well(this->index_of_well_).status == WellStatus::OPEN;
// don't allow switcing for wells under zero rate target or requested fixed status and control
//const bool allow_switching = !this->wellUnderZeroRateTarget(summary_state, well_state) &&
// (!fixed_control || !fixed_status) && allow_open;
const bool allow_switching = !this->wellUnderZeroRateTargetVersion(ebosSimulator, well_state, deferred_logger) &&
const bool allow_switching = !this->wellUnderZeroRateTarget(simulator, well_state, deferred_logger) &&
(!fixed_control || !fixed_status) && allow_open;

bool changed = false;
Expand Down
19 changes: 12 additions & 7 deletions opm/simulators/wells/WellInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,18 @@ class WellInterface : public WellInterfaceIndices<GetPropType<TypeTag, Propertie
std::vector<double>& well_flux,
DeferredLogger& deferred_logger) const = 0;

bool wellUnderZeroRateTargetVersion(const Simulator& ebos_simulator,
const WellState& well_state,
DeferredLogger& deferred_logger) const;

bool stoppedOrZeroRateTargetVersion(const Simulator& ebos_simulator,
const WellState& well_state,
DeferredLogger& deferred_logger) const;
bool wellUnderZeroRateTargetGroup(const Simulator& simulator,
const WellState& well_state,
const GroupState& group_state,
DeferredLogger& deferred_logger) const;

bool wellUnderZeroRateTarget(const Simulator& simulator,
const WellState& well_state,
DeferredLogger& deferred_logger) const;

bool stoppedOrZeroRateTarget(const Simulator& simulator,
const WellState& well_state,
DeferredLogger& deferred_logger) const;

bool updateWellStateWithTHPTargetProd(const Simulator& simulator,
WellState& well_state,
Expand Down
10 changes: 5 additions & 5 deletions opm/simulators/wells/WellInterfaceGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ bool WellInterfaceGeneric::isPressureControlled(const WellState& well_state) con



bool WellInterfaceGeneric::wellUnderZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const
bool WellInterfaceGeneric::wellUnderZeroRateTargetIndividual(const SummaryState& summary_state,
const WellState& well_state) const
{
if (this->isProducer()) { // producers
const auto prod_controls = this->well_ecl_.productionControls(summary_state);
Expand All @@ -563,10 +563,10 @@ bool WellInterfaceGeneric::wellUnderZeroRateTarget(const SummaryState& summary_s
}
}

bool WellInterfaceGeneric::stopppedOrZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const
bool WellInterfaceGeneric::stoppedOrZeroRateTargetIndividual(const SummaryState& summary_state,
const WellState& well_state) const
{
return (this->wellIsStopped() || this->wellUnderZeroRateTarget(summary_state, well_state));
return (this->wellIsStopped() || this->wellUnderZeroRateTargetIndividual(summary_state, well_state));

}

Expand Down
8 changes: 4 additions & 4 deletions opm/simulators/wells/WellInterfaceGeneric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ class WellInterfaceGeneric {

bool isPressureControlled(const WellState& well_state) const;

bool stopppedOrZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const;
bool stoppedOrZeroRateTargetIndividual(const SummaryState& summary_state,
const WellState& well_state) const;

double wellEfficiencyFactor() const
{ return well_efficiency_factor_; }
Expand All @@ -235,8 +235,8 @@ class WellInterfaceGeneric {
int polymerInjTable_() const;
int polymerWaterTable_() const;

bool wellUnderZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const;
bool wellUnderZeroRateTargetIndividual(const SummaryState& summary_state,
const WellState& well_state) const;

std::pair<bool,bool>
computeWellPotentials(std::vector<double>& well_potentials,
Expand Down

0 comments on commit 2355c4c

Please sign in to comment.