use rates for potentials for pressure controlled (bhp or thp) controled wells

This commit is contained in:
Tor Harald Sandve 2021-05-25 15:24:00 +02:00
parent d83b06c74b
commit cccece4104
2 changed files with 43 additions and 23 deletions

View File

@ -542,32 +542,31 @@ namespace Opm
}
// If the well is pressure controlled the potential equals the rate.
/* {
bool pressure_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;
}
} else {
const Well::ProducerCMode& current = well_state.currentProductionControls()[index_of_well_];
if (current == Well::ProducerCMode::BHP || current == Well::ProducerCMode::THP) {
pressure_controlled_well = true;
}
bool pressure_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 (pressure_controlled_well) {
for (int compIdx = 0; compIdx < num_components_; ++compIdx) {
const EvalWell rate = this->getQs(compIdx);
well_potentials[ebosCompIdxToFlowCompIdx(compIdx)] = rate.value();
}
return;
} 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 (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;
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = sign * well_state.wellRates(index_of_well_)[phase];
}
return;
}
debug_cost_counter_ = 0;
// does the well have a THP related constraint?
const auto& summaryState = ebosSimulator.vanguard().summaryState();
auto current_control = well_state.currentProductionControl(this->index_of_well_);
if ( !Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP) {
if (!Base::wellHasTHPConstraints(summaryState)) {
computeWellRatesAtBhpLimit(ebosSimulator, well_potentials, deferred_logger);
} else {
well_potentials = computeWellPotentialWithTHP(ebosSimulator, deferred_logger);

View File

@ -2690,6 +2690,28 @@ namespace Opm
return;
}
// If the well is pressure controlled the potential equals the rate.
bool pressure_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;
}
} 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 (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;
for (int phase = 0; phase < np; ++phase){
well_potentials[phase] = sign * well_state.wellRates(index_of_well_)[phase];
}
return;
}
// creating a copy of the well itself, to avoid messing up the explicit informations
// during this copy, the only information not copied properly is the well controls
StandardWell<TypeTag> well(*this);
@ -2697,8 +2719,7 @@ namespace Opm
// does the well have a THP related constraint?
const auto& summaryState = ebosSimulator.vanguard().summaryState();
auto current_control = well_state.currentProductionControl(this->index_of_well_);
if ( !well.Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP ) {
if (!well.Base::wellHasTHPConstraints(summaryState)) {
// get the bhp value based on the bhp constraints
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
assert(std::abs(bhp) != std::numeric_limits<double>::max());