FIX VREF for groups with both gas and water injectors

This commit is contained in:
Tor Harald Sandve 2023-02-15 08:51:28 +01:00
parent 3dc13c234c
commit 5356dbbaa8

View File

@ -351,32 +351,47 @@ namespace WellGroupHelpers
// accumulate group contribution from sub group // accumulate group contribution from sub group
if (isInjector) { if (isInjector) {
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS}; const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
bool individual_control = false;
int num_group_controlled_wells = 0;
for (Phase phase : all) { for (Phase phase : all) {
const Group::InjectionCMode& currentGroupControl
= group_state.injection_control(subGroup.name(), phase); int phase_pos = -1;
individual_control = individual_control || (currentGroupControl != Group::InjectionCMode::FLD switch (phase) {
&& currentGroupControl != Group::InjectionCMode::NONE); case Phase::GAS:
num_group_controlled_wells if (pu.phase_used[BlackoilPhases::Vapour]) {
+= groupControlledWells(schedule, wellState, group_state, reportStepIdx, subGroupName, "", !isInjector, phase); phase_pos = pu.phase_pos[BlackoilPhases::Vapour];
} }
if (individual_control || num_group_controlled_wells == 0) { break;
for (int phase = 0; phase < np; phase++) { case Phase::OIL:
groupTargetReduction[phase] if (pu.phase_used[BlackoilPhases::Liquid]) {
+= subGroupEfficiency * sumWellSurfaceRates(subGroup, schedule, wellState, reportStepIdx, phase, isInjector); phase_pos = pu.phase_pos[BlackoilPhases::Liquid];
} }
} else { break;
// The subgroup may participate in group control. case Phase::WATER:
bool has_guide_rate = false; if (pu.phase_used[BlackoilPhases::Aqua]) {
for (Phase phase : all) { phase_pos = pu.phase_pos[BlackoilPhases::Aqua];
has_guide_rate = has_guide_rate || guide_rate.has(subGroupName, phase); }
break;
default:
// just to avoid warning
throw std::invalid_argument("unhandled phase enum");
} }
if (!has_guide_rate) { // the phase is not present
if (phase_pos == -1)
continue;
const Group::InjectionCMode& currentGroupControl
= group_state.injection_control(subGroup.name(), phase);
const bool individual_control = (currentGroupControl != Group::InjectionCMode::FLD
&& currentGroupControl != Group::InjectionCMode::NONE);
const int num_group_controlled_wells
= groupControlledWells(schedule, wellState, group_state, reportStepIdx, subGroupName, "", !isInjector, phase);
if (individual_control || num_group_controlled_wells == 0) {
groupTargetReduction[phase_pos]
+= subGroupEfficiency * sumWellSurfaceRates(subGroup, schedule, wellState, reportStepIdx, phase_pos, isInjector);
} else {
// Accumulate from this subgroup only if no group guide rate is set for it. // Accumulate from this subgroup only if no group guide rate is set for it.
for (int phase = 0; phase < np; phase++) { if (!guide_rate.has(subGroupName, phase)) {
groupTargetReduction[phase] += subGroupEfficiency * subGroupTargetReduction[phase]; groupTargetReduction[phase_pos] += subGroupEfficiency * subGroupTargetReduction[phase_pos];
} }
} }
} }