re-compute potentials for pressure controlled wells with trivial rates

This commit is contained in:
Tor Harald Sandve 2021-08-09 13:33:08 +02:00
parent cf61417b6d
commit 5cb81d36c9
2 changed files with 52 additions and 22 deletions

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

@ -1536,25 +1536,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
@ -1564,7 +1579,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());