Merge pull request #3465 from totto82/updateWTS

Make sure potentials are computed in some corner cases
This commit is contained in:
Tor Harald Sandve
2021-08-10 14:15:22 +02:00
committed by GitHub
3 changed files with 54 additions and 23 deletions

View File

@@ -454,7 +454,6 @@ namespace Opm {
well->updateWaterThroughput(dt, this->wellState());
}
}
updateWellTestState(simulationTime, wellTestState_);
// update the rate converter with current averages pressures etc in
rateConverter_->template defineState<ElementContext>(ebosSimulator_);
@@ -470,6 +469,8 @@ namespace Opm {
local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg);
}
updateWellTestState(simulationTime, wellTestState_);
// check group sales limits at the end of the timestep
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
checkGconsaleLimits(fieldGroup, this->wellState(),

View File

@@ -255,31 +255,46 @@ namespace Opm
}
// If the well is pressure controlled the potential equals the rate.
bool pressure_controlled_well = false;
bool thp_controlled_well = false;
bool bhp_controlled_well = false;
if (this->isInjector()) {
const Well::InjectorCMode& current = well_state.currentInjectionControl(index_of_well_);
if (current == Well::InjectorCMode::BHP || current == Well::InjectorCMode::THP) {
pressure_controlled_well = true;
if (current == Well::InjectorCMode::THP) {
thp_controlled_well = true;
}
if (current == Well::InjectorCMode::BHP) {
bhp_controlled_well = true;
}
} else {
const Well::ProducerCMode& current = well_state.currentProductionControl(index_of_well_);
if (current == Well::ProducerCMode::BHP || current == Well::ProducerCMode::THP) {
pressure_controlled_well = true;
if (current == Well::ProducerCMode::THP) {
thp_controlled_well = true;
}
if (current == Well::ProducerCMode::BHP) {
bhp_controlled_well = true;
}
}
if (pressure_controlled_well) {
// initialized the well rates with the potentials i.e. the well rates based on bhp
const double sign = this->well_ecl_.isInjector() ? 1.0 : -1.0;
if (thp_controlled_well || bhp_controlled_well) {
double total_rate = 0.0;
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = sign * well_state.wellRates(index_of_well_)[phase];
total_rate += well_state.wellRates(index_of_well_)[phase];
}
// for pressure controlled wells the well rates are the potentials
// if the rates are trivial we are most probably looking at the newly
// opened well and we therefore make the affort of computing the potentials anyway.
if (std::abs(total_rate) > 0) {
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = well_state.wellRates(index_of_well_)[phase];
}
return;
}
return;
}
debug_cost_counter_ = 0;
// does the well have a THP related constraint?
const auto& summaryState = ebosSimulator.vanguard().summaryState();
if (!Base::wellHasTHPConstraints(summaryState)) {
if (!Base::wellHasTHPConstraints(summaryState) || bhp_controlled_well) {
computeWellRatesAtBhpLimit(ebosSimulator, well_potentials, deferred_logger);
} else {
well_potentials = computeWellPotentialWithTHP(ebosSimulator, deferred_logger);

View File

@@ -1834,25 +1834,40 @@ namespace Opm
}
// If the well is pressure controlled the potential equals the rate.
bool pressure_controlled_well = false;
bool thp_controlled_well = false;
bool bhp_controlled_well = false;
if (this->isInjector()) {
const Well::InjectorCMode& current = well_state.currentInjectionControl(index_of_well_);
if (current == Well::InjectorCMode::BHP || current == Well::InjectorCMode::THP) {
pressure_controlled_well = true;
if (current == Well::InjectorCMode::THP) {
thp_controlled_well = true;
}
if (current == Well::InjectorCMode::BHP) {
bhp_controlled_well = true;
}
} else {
const Well::ProducerCMode& current = well_state.currentProductionControl(index_of_well_);
if (current == Well::ProducerCMode::BHP || current == Well::ProducerCMode::THP) {
pressure_controlled_well = true;
if (current == Well::ProducerCMode::THP) {
thp_controlled_well = true;
}
if (current == Well::ProducerCMode::BHP) {
bhp_controlled_well = true;
}
}
if (pressure_controlled_well) {
// initialized the well rates with the potentials i.e. the well rates based on bhp
const double sign = this->well_ecl_.isInjector() ? 1.0 : -1.0;
if (thp_controlled_well || bhp_controlled_well) {
double total_rate = 0.0;
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = sign * well_state.wellRates(index_of_well_)[phase];
total_rate += well_state.wellRates(index_of_well_)[phase];
}
// for pressure controlled wells the well rates are the potentials
// if the rates are trivial we are most probably looking at the newly
// opened well and we therefore make the affort of computing the potentials anyway.
if (std::abs(total_rate) > 0) {
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = well_state.wellRates(index_of_well_)[phase];
}
return;
}
return;
}
// creating a copy of the well itself, to avoid messing up the explicit informations
@@ -1862,7 +1877,7 @@ namespace Opm
// does the well have a THP related constraint?
const auto& summaryState = ebosSimulator.vanguard().summaryState();
if (!well.Base::wellHasTHPConstraints(summaryState)) {
if (!well.Base::wellHasTHPConstraints(summaryState) || bhp_controlled_well) {
// get the bhp value based on the bhp constraints
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
assert(std::abs(bhp) != std::numeric_limits<double>::max());