Merge pull request #3464 from totto82/fixGEFF

Fixes related to GEFAC
This commit is contained in:
Tor Harald Sandve 2021-08-19 19:06:55 +02:00 committed by GitHub
commit 295f41ba2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 34 deletions

View File

@ -138,7 +138,8 @@ namespace WellGroupHelpers
double rate = 0.0; double rate = 0.0;
for (const std::string& groupName : group.groups()) { for (const std::string& groupName : group.groups()) {
const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx); const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx);
rate += sumWellPhaseRates(rates, groupTmp, schedule, wellState, reportStepIdx, phasePos, injector); const auto& gefac = groupTmp.getGroupEfficiencyFactor();
rate += gefac * sumWellPhaseRates(rates, groupTmp, schedule, wellState, reportStepIdx, phasePos, injector);
} }
const auto& end = wellState.wellMap().end(); const auto& end = wellState.wellMap().end();
@ -169,8 +170,7 @@ namespace WellGroupHelpers
else else
rate -= factor * well_rates[phasePos]; rate -= factor * well_rates[phasePos];
} }
const auto& gefac = group.getGroupEfficiencyFactor(); return rate;
return gefac * rate;
} }
double sumWellRates(const Group& group, double sumWellRates(const Group& group,
@ -204,7 +204,8 @@ namespace WellGroupHelpers
double rate = 0.0; double rate = 0.0;
for (const std::string& groupName : group.groups()) { for (const std::string& groupName : group.groups()) {
const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx); const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx);
rate += sumSolventRates(groupTmp, schedule, wellState, reportStepIdx, injector); const auto& gefac = groupTmp.getGroupEfficiencyFactor();
rate += gefac * sumSolventRates(groupTmp, schedule, wellState, reportStepIdx, injector);
} }
const auto& end = wellState.wellMap().end(); const auto& end = wellState.wellMap().end();
for (const std::string& wellName : group.wells()) { for (const std::string& wellName : group.wells()) {
@ -233,8 +234,7 @@ namespace WellGroupHelpers
else else
rate -= factor * wellState.solventWellRate(well_index); rate -= factor * wellState.solventWellRate(well_index);
} }
const auto& gefac = group.getGroupEfficiencyFactor(); return rate;
return gefac * rate;
} }
void updateGuideRatesForInjectionGroups(const Group& group, void updateGuideRatesForInjectionGroups(const Group& group,
@ -323,6 +323,8 @@ namespace WellGroupHelpers
group_state, group_state,
subGroupTargetReduction); subGroupTargetReduction);
const double subGroupEfficiency = subGroup.getGroupEfficiencyFactor();
// 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};
@ -339,7 +341,7 @@ namespace WellGroupHelpers
if (individual_control || num_group_controlled_wells == 0) { if (individual_control || num_group_controlled_wells == 0) {
for (int phase = 0; phase < np; phase++) { for (int phase = 0; phase < np; phase++) {
groupTargetReduction[phase] groupTargetReduction[phase]
+= sumWellRates(subGroup, schedule, wellStateNupcol, reportStepIdx, phase, isInjector); += subGroupEfficiency * sumWellRates(subGroup, schedule, wellStateNupcol, reportStepIdx, phase, isInjector);
} }
} else { } else {
// The subgroup may participate in group control. // The subgroup may participate in group control.
@ -351,7 +353,7 @@ namespace WellGroupHelpers
if (!has_guide_rate) { if (!has_guide_rate) {
// 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++) { for (int phase = 0; phase < np; phase++) {
groupTargetReduction[phase] += subGroupTargetReduction[phase]; groupTargetReduction[phase] += subGroupEfficiency * subGroupTargetReduction[phase];
} }
} }
} }
@ -364,14 +366,14 @@ namespace WellGroupHelpers
if (individual_control || num_group_controlled_wells == 0) { if (individual_control || num_group_controlled_wells == 0) {
for (int phase = 0; phase < np; phase++) { for (int phase = 0; phase < np; phase++) {
groupTargetReduction[phase] groupTargetReduction[phase]
+= sumWellRates(subGroup, schedule, wellStateNupcol, reportStepIdx, phase, isInjector); += subGroupEfficiency * sumWellRates(subGroup, schedule, wellStateNupcol, reportStepIdx, phase, isInjector);
} }
} else { } else {
// The subgroup may participate in group control. // The subgroup may participate in group control.
if (!guide_rate.has(subGroupName)) { if (!guide_rate.has(subGroupName)) {
// 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++) { for (int phase = 0; phase < np; phase++) {
groupTargetReduction[phase] += subGroupTargetReduction[phase]; groupTargetReduction[phase] += subGroupEfficiency * subGroupTargetReduction[phase];
} }
} }
} }
@ -417,10 +419,6 @@ namespace WellGroupHelpers
} }
} }
} }
const double groupEfficiency = group.getGroupEfficiencyFactor();
for (double& elem : groupTargetReduction) {
elem *= groupEfficiency;
}
if (isInjector) if (isInjector)
group_state.update_injection_reduction_rates(group.name(), groupTargetReduction); group_state.update_injection_reduction_rates(group.name(), groupTargetReduction);
else else
@ -1144,7 +1142,6 @@ namespace WellGroupHelpers
} }
} }
double efficiencyFactorInclGroup = efficiencyFactor * group.getGroupEfficiencyFactor();
double target = orig_target; double target = orig_target;
for (size_t ii = 0; ii < num_ancestors; ++ii) { for (size_t ii = 0; ii < num_ancestors; ++ii) {
if ((ii == 0) || guideRate->has(chain[ii])) { if ((ii == 0) || guideRate->has(chain[ii])) {
@ -1155,7 +1152,7 @@ namespace WellGroupHelpers
// Add my reduction back at the level where it is included in the local reduction // Add my reduction back at the level where it is included in the local reduction
if (local_reduction_level == ii ) if (local_reduction_level == ii )
target += current_rate * efficiencyFactorInclGroup; target += current_rate * efficiencyFactor;
} }
if (ii < num_ancestors - 1) { if (ii < num_ancestors - 1) {
// Not final level. Add sub-level reduction back, if // Not final level. Add sub-level reduction back, if
@ -1174,10 +1171,11 @@ namespace WellGroupHelpers
target *= localFraction(chain[ii + 1]); target *= localFraction(chain[ii + 1]);
} }
// Avoid negative target rates comming from too large local reductions. // Avoid negative target rates comming from too large local reductions.
const double target_rate = std::max(1e-12, target / efficiencyFactorInclGroup); const double target_rate = std::max(1e-12, target / efficiencyFactor);
double scale = 1.0; double scale = 1.0;
if (current_rate > 1e-12) if (current_rate > 1e-12)
scale = target_rate / current_rate; scale = target_rate / current_rate;
return std::make_pair(current_rate > target_rate, scale); return std::make_pair(current_rate > target_rate, scale);
} }
@ -1271,7 +1269,6 @@ namespace WellGroupHelpers
} }
} }
double efficiencyFactorInclGroup = efficiencyFactor * group.getGroupEfficiencyFactor();
double target = orig_target; double target = orig_target;
for (size_t ii = 0; ii < num_ancestors; ++ii) { for (size_t ii = 0; ii < num_ancestors; ++ii) {
if ((ii == 0) || guideRate->has(chain[ii], injectionPhase)) { if ((ii == 0) || guideRate->has(chain[ii], injectionPhase)) {
@ -1282,7 +1279,7 @@ namespace WellGroupHelpers
// Add my reduction back at the level where it is included in the local reduction // Add my reduction back at the level where it is included in the local reduction
if (local_reduction_level == ii ) if (local_reduction_level == ii )
target += current_rate * efficiencyFactorInclGroup; target += current_rate * efficiencyFactor;
} }
if (ii < num_ancestors - 1) { if (ii < num_ancestors - 1) {
// Not final level. Add sub-level reduction back, if // Not final level. Add sub-level reduction back, if
@ -1301,10 +1298,11 @@ namespace WellGroupHelpers
target *= localFraction(chain[ii + 1]); target *= localFraction(chain[ii + 1]);
} }
// Avoid negative target rates comming from too large local reductions. // Avoid negative target rates comming from too large local reductions.
const double target_rate = std::max(1e-12, target / efficiencyFactorInclGroup); const double target_rate = std::max(1e-12, target / efficiencyFactor);
double scale = 1.0; double scale = 1.0;
if (current_rate > 1e-12) if (current_rate > 1e-12)
scale = target_rate / current_rate; scale = target_rate / current_rate;
return std::make_pair(current_rate > target_rate, scale); return std::make_pair(current_rate > target_rate, scale);
} }
@ -1355,8 +1353,12 @@ namespace WellGroupHelpers
&& currentGroupControl != Group::ProductionCMode::NONE) { && currentGroupControl != Group::ProductionCMode::NONE) {
continue; continue;
} }
// Apply group efficiency factor for this goup
auto gefac = groupTmp.getGroupEfficiencyFactor();
for (int phase = 0; phase < np; phase++) { for (int phase = 0; phase < np; phase++) {
pot[phase] += thisPot[phase]; pot[phase] += gefac*thisPot[phase];
} }
} }
@ -1387,13 +1389,6 @@ namespace WellGroupHelpers
} }
} }
// Apply group efficiency factor for this goup
auto gefac = group.getGroupEfficiencyFactor();
for (int phase = 0; phase < np; phase++) {
pot[phase] *= gefac;
}
double oilPot = 0.0; double oilPot = 0.0;
if (pu.phase_used[BlackoilPhases::Liquid]) if (pu.phase_used[BlackoilPhases::Liquid])
oilPot = pot[pu.phase_pos[BlackoilPhases::Liquid]]; oilPot = pot[pu.phase_pos[BlackoilPhases::Liquid]];

View File

@ -114,7 +114,6 @@ getGroupInjectionControl(const Group& group,
} }
} }
efficiencyFactor *= group.getGroupEfficiencyFactor();
const auto& well = baseif_.wellEcl(); const auto& well = baseif_.wellEcl();
const auto pu = baseif_.phaseUsage(); const auto pu = baseif_.phaseUsage();
@ -165,7 +164,8 @@ getGroupInjectionControl(const Group& group,
} }
// Avoid negative target rates coming from too large local reductions. // Avoid negative target rates coming from too large local reductions.
const double target_rate = std::max(0.0, target / efficiencyFactor); const double target_rate = std::max(0.0, target / efficiencyFactor);
const auto current_rate = injection_rate; // Switch sign since 'rates' are negative for producers. const auto current_rate = injection_rate;
control_eq = current_rate - target_rate; control_eq = current_rate - target_rate;
} }
@ -207,7 +207,6 @@ getGroupProductionControl(const Group& group,
} }
} }
efficiencyFactor *= group.getGroupEfficiencyFactor();
const auto& well = baseif_.wellEcl(); const auto& well = baseif_.wellEcl();
const auto pu = baseif_.phaseUsage(); const auto pu = baseif_.phaseUsage();

View File

@ -982,7 +982,6 @@ getGroupInjectionTargetRate(const Group& group,
} }
} }
efficiencyFactor *= group.getGroupEfficiencyFactor();
const auto pu = phaseUsage(); const auto pu = phaseUsage();
if (!group.isInjectionGroup()) { if (!group.isInjectionGroup()) {
@ -1027,7 +1026,6 @@ getGroupInjectionTargetRate(const Group& group,
} }
target *= localFraction(chain[ii+1]); target *= localFraction(chain[ii+1]);
} }
// Avoid negative target rates coming from too large local reductions.
return std::max(0.0, target / efficiencyFactor); return std::max(0.0, target / efficiencyFactor);
} }
template<typename FluidSystem> template<typename FluidSystem>
@ -1053,7 +1051,6 @@ getGroupProductionTargetRate(const Group& group,
} }
} }
efficiencyFactor *= group.getGroupEfficiencyFactor();
const auto pu = phaseUsage(); const auto pu = phaseUsage();
if (!group.isProductionGroup()) { if (!group.isProductionGroup()) {