This commit is contained in:
Tor Harald Sandve 2020-01-23 11:20:06 +01:00
parent 469ffa2cbe
commit e39e327451
5 changed files with 63 additions and 93 deletions

View File

@ -384,7 +384,7 @@ namespace Opm {
void actionOnBrokenConstraints(const Group& group, const Group::ExceedAction& exceed_action, const Group::ProductionCMode& newControl, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
void actionOnBrokenConstraints(const Group& group, const Group::InjectionCMode& newControl, const Phase& topUpPhase, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
void actionOnBrokenConstraints(const Group& group, const Group::InjectionCMode& newControl, const Phase& topUpPhase, const int reportStepIdx, Opm::DeferredLogger& deferred_logger);
WellInterfacePtr getWell(const std::string& well_name) const;

View File

@ -1693,55 +1693,24 @@ namespace Opm {
if (group.isInjectionGroup())
{
const Group::InjectionCMode& currentControl = well_state.currentInjectionGroupControl(group.name());
const auto controls = group.injectionControls(summaryState);
int phasePos;
switch (controls.phase) {
case Phase::WATER:
{
phasePos = phase_usage_.phase_pos[BlackoilPhases::Aqua];
break;
}
case Phase::OIL:
{
phasePos = phase_usage_.phase_pos[BlackoilPhases::Liquid];
break;
}
case Phase::GAS:
{
phasePos = phase_usage_.phase_pos[BlackoilPhases::Vapour];
break;
}
default:
throw("Expected WATER, OIL or GAS as type for group injector: " + group.name());
}
for (int phasePos = 0; phasePos < phase_usage_.num_phases; ++phasePos) {
Phase currentPhase;
if (phasePos == phase_usage_.phase_pos[BlackoilPhases::Aqua]) {
if (!group.hasInjectionControl(Phase::WATER)) {
continue;
}
currentPhase = Phase::WATER;
}
else if (phasePos == phase_usage_.phase_pos[BlackoilPhases::Liquid]) {
if (!group.hasInjectionControl(Phase::OIL)) {
continue;
}
currentPhase = Phase::OIL;
}
else if (phasePos == phase_usage_.phase_pos[BlackoilPhases::Vapour]) {
if (!group.hasInjectionControl(Phase::GAS)) {
continue;
}
currentPhase = Phase::GAS;
} else {
throw("Expected oil, gas or water phase for injector " + group.name());
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
for (Phase phase : all) {
if (!group.hasInjectionControl(phase)) {
continue;
}
const auto& controls = group.injectionControls(currentPhase, summaryState);
int phasePos;
if (phase == Phase::GAS && phase_usage_.phase_used[BlackoilPhases::Vapour] )
phasePos = phase_usage_.phase_pos[BlackoilPhases::Vapour];
else if (phase == Phase::OIL && phase_usage_.phase_used[BlackoilPhases::Liquid])
phasePos = phase_usage_.phase_pos[BlackoilPhases::Liquid];
else if (phase == Phase::WATER && phase_usage_.phase_used[BlackoilPhases::Aqua] )
phasePos = phase_usage_.phase_pos[BlackoilPhases::Aqua];
else
continue;
const auto& controls = group.injectionControls(phase, summaryState);
if (group.has_control(Group::InjectionCMode::RATE))
{
@ -1750,11 +1719,12 @@ namespace Opm {
double current_rate = 0.0;
current_rate += wellGroupHelpers::sumWellRates(group, schedule(), well_state, reportStepIdx, phasePos, /*isInjector*/true);
// sum over all nodes
current_rate = comm.sum(current_rate);
// sum over all nodes
current_rate = comm.sum(current_rate);
if (controls.surface_max_rate < current_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::RATE, currentPhase, reportStepIdx, deferred_logger);
if (controls.surface_max_rate < current_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::RATE, phase, reportStepIdx, deferred_logger);
}
}
}
if (group.has_control(Group::InjectionCMode::RESV))
@ -1766,28 +1736,26 @@ namespace Opm {
// sum over all nodes
current_rate = comm.sum(current_rate);
if (controls.resv_max_rate < current_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::RESV, currentPhase, reportStepIdx, deferred_logger);
} }
if (group.has_control(Group::InjectionCMode::REIN))
{
if (checkCurrentControl || currentControl != Group::InjectionCMode::REIN)
if (controls.resv_max_rate < current_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::RESV, phase, reportStepIdx, deferred_logger);
} }
if (controls.has_control(Group::InjectionCMode::REIN))
{
double production_Rate = 0.0;
const Group& groupRein = schedule().getGroup(controls.reinj_group, reportStepIdx);
production_Rate += wellGroupHelpers::sumWellRates(groupRein, schedule(), well_state, reportStepIdx, phasePos, /*isInjector*/false);
// sum over all nodes
production_Rate = comm.sum(production_Rate);
// sum over all nodes
production_Rate = comm.sum(production_Rate);
double current_rate = 0.0;
current_rate += wellGroupHelpers::sumWellRates(group, schedule(), well_state, reportStepIdx, phasePos, /*isInjector*/true);
double current_rate = 0.0;
current_rate += wellGroupHelpers::sumWellRates(group, schedule(), well_state, reportStepIdx, phasePos, /*isInjector*/true);
// sum over all nodes
current_rate = comm.sum(current_rate);
// sum over all nodes
current_rate = comm.sum(current_rate);
if (controls.target_reinj_fraction*production_Rate < current_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::REIN, currentPhase,reportStepIdx, deferred_logger);
actionOnBrokenConstraints(group, Group::InjectionCMode::REIN, phase,reportStepIdx, deferred_logger);
} }
if (group.has_control(Group::InjectionCMode::VREP))
{
@ -1799,19 +1767,20 @@ namespace Opm {
voidage_rate += wellGroupHelpers::sumWellResRates(groupVoidage, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Liquid], false);
voidage_rate += wellGroupHelpers::sumWellResRates(groupVoidage, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Vapour], false);
// sum over all nodes
voidage_rate = comm.sum(voidage_rate);
// sum over all nodes
voidage_rate = comm.sum(voidage_rate);
double total_rate = 0.0;
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Aqua], true);
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Liquid], true);
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Vapour], true);
double total_rate = 0.0;
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Aqua], true);
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Liquid], true);
total_rate += wellGroupHelpers::sumWellResRates(group, schedule(), well_state, reportStepIdx, phase_usage_.phase_pos[BlackoilPhases::Vapour], true);
// sum over all nodes
total_rate = comm.sum(total_rate);
// sum over all nodes
total_rate = comm.sum(total_rate);
if (controls.target_void_fraction*voidage_rate < total_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::VREP, currentPhase, reportStepIdx, deferred_logger);
if (controls.target_void_fraction*voidage_rate < total_rate) {
actionOnBrokenConstraints(group, Group::InjectionCMode::VREP, phase, reportStepIdx, deferred_logger);
}
}
}
// Handle GCONSALE

View File

@ -2180,6 +2180,7 @@ namespace Opm
return;
}
assert(group.hasInjectionControl(injectionPhase));
const auto& groupcontrols = group.injectionControls(injectionPhase, summaryState);
const std::vector<double>& groupInjectionReductions = well_state.currentInjectionGroupReductionRates(group.name());

View File

@ -1013,7 +1013,6 @@ namespace Opm
default:
throw("Expected WATER, OIL or GAS as type for injectors " + well.name());
}
const auto& groupcontrols = group.injectionControls(injectionPhase, summaryState);
const Group::InjectionCMode& currentGroupControl = well_state.currentInjectionGroupControl(injectionPhase, group.name());
if (currentGroupControl == Group::InjectionCMode::FLD) {
@ -1033,7 +1032,8 @@ namespace Opm
return;
}
assert(group.hasInjectionControl(injectionPhase));
const auto& groupcontrols = group.injectionControls(injectionPhase, summaryState);
const std::vector<double>& groupInjectionReductions = well_state.currentInjectionGroupReductionRates(group.name());

View File

@ -262,14 +262,14 @@ namespace Opm {
for (Phase phase : all) {
const Group::InjectionCMode& currentGroupControl = wellState.currentInjectionGroupControl(phase, groupName);
int phasePos;
if (phase == Phase::GAS)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Vapour] ];
else if (phase == Phase::OIL)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Liquid] ];
else if (phase == Phase::WATER)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Aqua] ];
if (phase == Phase::GAS && pu.phase_used[BlackoilPhases::Vapour] )
phasePos = pu.phase_pos[BlackoilPhases::Vapour];
else if (phase == Phase::OIL && pu.phase_used[BlackoilPhases::Liquid])
phasePos = pu.phase_pos[BlackoilPhases::Liquid];
else if (phase == Phase::WATER && pu.phase_used[BlackoilPhases::Aqua] )
phasePos = pu.phase_pos[BlackoilPhases::Aqua];
else
throw("invalid phase");
continue;
if (currentGroupControl != Group::InjectionCMode::FLD) {
groupTargetReduction[phasePos] += sumWellRates(groupTmp, schedule, wellStateNupcol, reportStepIdx, phasePos, isInjector);
@ -347,14 +347,14 @@ namespace Opm {
continue;
}
int phasePos;
if (phase == Phase::GAS)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Vapour] ];
else if (phase == Phase::OIL)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Liquid] ];
else if (phase == Phase::WATER)
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Aqua] ];
if (phase == Phase::GAS && pu.phase_used[BlackoilPhases::Vapour] )
phasePos = pu.phase_pos[BlackoilPhases::Vapour];
else if (phase == Phase::OIL && pu.phase_used[BlackoilPhases::Liquid])
phasePos = pu.phase_pos[BlackoilPhases::Liquid];
else if (phase == Phase::WATER && pu.phase_used[BlackoilPhases::Aqua] )
phasePos = pu.phase_pos[BlackoilPhases::Aqua];
else
throw("invalid phase");
continue;
pot[phasePos] += thisPot[phasePos];
}
@ -562,14 +562,14 @@ namespace Opm {
double groupTotalGuideRate = 0.0;
const Group& groupParent = schedule.getGroup(group.parent(), reportStepIdx);
int phasePos;
if (injectionPhase == Phase::GAS)
if (injectionPhase == Phase::GAS && pu.phase_used[BlackoilPhases::Vapour] )
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Vapour] ];
else if (injectionPhase == Phase::OIL)
else if (injectionPhase == Phase::OIL && pu.phase_used[BlackoilPhases::Liquid])
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Liquid] ];
else if (injectionPhase == Phase::WATER)
else if (injectionPhase == Phase::WATER && pu.phase_used[BlackoilPhases::Aqua] )
phasePos = pu.phase_pos[ pu.phase_pos[BlackoilPhases::Aqua] ];
else
throw("invalid phase");
throw("this should not happen");
for (const std::string& groupName : groupParent.groups()) {
// only count group under group control from its parent