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

View File

@ -2690,6 +2690,28 @@ namespace Opm
return; 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 // 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 // during this copy, the only information not copied properly is the well controls
StandardWell<TypeTag> well(*this); StandardWell<TypeTag> well(*this);
@ -2697,8 +2719,7 @@ namespace Opm
// does the well have a THP related constraint? // does the well have a THP related constraint?
const auto& summaryState = ebosSimulator.vanguard().summaryState(); const auto& summaryState = ebosSimulator.vanguard().summaryState();
auto current_control = well_state.currentProductionControl(this->index_of_well_); if (!well.Base::wellHasTHPConstraints(summaryState)) {
if ( !well.Base::wellHasTHPConstraints(summaryState) || current_control == Well::ProducerCMode::BHP ) {
// get the bhp value based on the bhp constraints // get the bhp value based on the bhp constraints
const double bhp = well.mostStrictBhpFromBhpLimits(summaryState); const double bhp = well.mostStrictBhpFromBhpLimits(summaryState);
assert(std::abs(bhp) != std::numeric_limits<double>::max()); assert(std::abs(bhp) != std::numeric_limits<double>::max());