final changes for corretions to IGRP[nwgmax+WInjActiveCMode] and IGRP[nwgmax+GConInjeWInjCMode] plus similar gas inj

This commit is contained in:
Jostein Alvestad 2021-09-24 09:25:17 +02:00
parent b97931ddd5
commit 77b86dfd3b

View File

@ -244,17 +244,24 @@ std::optional<Opm::Group> controlGroup(const Opm::Schedule& sched,
const Opm::Group& group, const Opm::Group& group,
const std::size_t simStep) { const std::size_t simStep) {
auto current = group; auto current = group;
bool isField = false;
double cur_prod_ctrl= 0.; double cur_prod_ctrl= 0.;
while (current.name() != "FIELD") { while (!isField) {
current = sched.getGroup(current.parent(), simStep);
if (current.name() != "FIELD") { if (current.name() != "FIELD") {
cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP", 0); cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP", 0);
} else { } else {
cur_prod_ctrl = sumState.get("FMCTP", 0); cur_prod_ctrl = sumState.get("FMCTP", 0);
} }
if (cur_prod_ctrl > 0) if (cur_prod_ctrl > 0) {
return current; return current;
} }
if (current.name() != "FIELD") {
current = sched.getGroup(current.parent(), simStep);
}
else {
isField = true;
}
}
return {}; return {};
} }
@ -270,13 +277,13 @@ std::optional<Opm::Group> injectionControlGroup(const Opm::Schedule& sched,
// //
{ {
auto current = group; auto current = group;
bool isField = false;
double cur_inj_ctrl = 0.; double cur_inj_ctrl = 0.;
while (current.name() != "FIELD" ) { while (!isField) {
current = sched.getGroup(current.parent(), simStep);
if (current.name() != "FIELD") { if (current.name() != "FIELD") {
cur_inj_ctrl = sumState.get_group_var(current.name(), curGroupInjCtrlKey, 0.); cur_inj_ctrl = sumState.get_group_var(current.name(), curGroupInjCtrlKey, 0.);
} else { } else {
cur_inj_ctrl = sumState.get(curFieldInjCtrlKey, 0); cur_inj_ctrl = sumState.get(curFieldInjCtrlKey, 0.);
} }
if (cur_inj_ctrl > 0) { if (cur_inj_ctrl > 0) {
return current; return current;
@ -287,6 +294,11 @@ std::optional<Opm::Group> injectionControlGroup(const Opm::Schedule& sched,
<< " is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; << " is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl;
} }
#endif // ENABLE_GCNTL_DEBUG_OUTPUT #endif // ENABLE_GCNTL_DEBUG_OUTPUT
if (current.name() != "FIELD") {
current = sched.getGroup(current.parent(), simStep);
} else {
isField = true;
}
} }
return {}; return {};
} // namespace } // namespace
@ -372,7 +384,7 @@ void productionGroup(const Opm::Schedule& sched,
const auto& cgroup = controlGroup(sched, sumState, group, simStep); const auto& cgroup = controlGroup(sched, sumState, group, simStep);
const auto& deck_cmode = group.prod_cmode(); const auto& deck_cmode = group.prod_cmode();
if (cgroup && (group.getGroupType() != Opm::Group::GroupType::NONE)) { if (cgroup && (cgroup->name() != group.name()) && (group.getGroupType() != Opm::Group::GroupType::NONE)) {
auto cgroup_control = (cgroup->name() == "FIELD") ? static_cast<int>(sumState.get("FMCTP", 0)) : static_cast<int>(sumState.get_group_var(cgroup->name(), "GMCTP", 0)); auto cgroup_control = (cgroup->name() == "FIELD") ? static_cast<int>(sumState.get("FMCTP", 0)) : static_cast<int>(sumState.get_group_var(cgroup->name(), "GMCTP", 0));
iGrp[nwgmax + IGroup::ProdActiveCMode] iGrp[nwgmax + IGroup::ProdActiveCMode]
= (prod_guide_rate_def != Opm::Group::GuideRateProdTarget::NO_GUIDE_RATE) ? cgroup_control : 0; = (prod_guide_rate_def != Opm::Group::GuideRateProdTarget::NO_GUIDE_RATE) ? cgroup_control : 0;
@ -426,7 +438,7 @@ void productionGroup(const Opm::Schedule& sched,
break; break;
case Opm::Group::ProductionCMode::FLD: case Opm::Group::ProductionCMode::FLD:
if (cgroup && (prod_guide_rate_def != Opm::Group::GuideRateProdTarget::NO_GUIDE_RATE)) { if (cgroup && (prod_guide_rate_def != Opm::Group::GuideRateProdTarget::NO_GUIDE_RATE)) {
iGrp[nwgmax + IGroup::GuideRateDef] = Value::GuideRateMode::Form; iGrp[nwgmax + IGroup::GuideRateDef] = GuideRateModeFromGuideRateProdTarget(prod_guide_rate_def);
} }
iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4; iGrp[nwgmax + IGroup::ExceedAction] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4;
break; break;
@ -437,7 +449,7 @@ void productionGroup(const Opm::Schedule& sched,
// Start branching for determining iGrp[nwgmax + IGroup::ProdHighLevCtrl] // Start branching for determining iGrp[nwgmax + IGroup::ProdHighLevCtrl]
// use default value if group is not available for group control // use default value if group is not available for group control
if (group.getGroupType() == Opm::Group::GroupType::NONE) { if (group.getGroupType() == Opm::Group::GroupType::NONE || group.getGroupType() == Opm::Group::GroupType::INJECTION) {
if (is_field) { if (is_field) {
iGrp[nwgmax + IGroup::ProdHighLevCtrl] = 0; iGrp[nwgmax + IGroup::ProdHighLevCtrl] = 0;
} else { } else {
@ -447,8 +459,9 @@ void productionGroup(const Opm::Schedule& sched,
return; return;
} }
if (cgroup && cgroup->name() == "FIELD") if (group.name() == "FIELD" ) {
throw std::logic_error("Got cgroup == FIELD - uncertain logic"); iGrp[nwgmax + IGroup::ProdHighLevCtrl] = 0;
} else {
// group is available for higher level control, but is currently constrained by own limits // group is available for higher level control, but is currently constrained by own limits
iGrp[nwgmax + IGroup::ProdHighLevCtrl] = -1; iGrp[nwgmax + IGroup::ProdHighLevCtrl] = -1;
if ((deck_cmode != Opm::Group::ProductionCMode::FLD) && !group.productionGroupControlAvailable()) { if ((deck_cmode != Opm::Group::ProductionCMode::FLD) && !group.productionGroupControlAvailable()) {
@ -480,6 +493,7 @@ void productionGroup(const Opm::Schedule& sched,
} }
} }
} }
}
std::tuple<int, int, int> injectionGroup(const Opm::Schedule& sched, std::tuple<int, int, int> injectionGroup(const Opm::Schedule& sched,
const Opm::Group& group, const Opm::Group& group,
@ -489,7 +503,7 @@ std::tuple<int, int, int> injectionGroup(const Opm::Schedule& sched,
{ {
const bool is_field = group.name() == "FIELD"; const bool is_field = group.name() == "FIELD";
auto group_parent_list = groupParentSeqIndex(sched, group, simStep); auto group_parent_list = groupParentSeqIndex(sched, group, simStep);
int high_level_ctrl; int high_level_ctrl = 0;
int current_cmode = 0; int current_cmode = 0;
int gconinje_cmode = 0; int gconinje_cmode = 0;
@ -499,11 +513,6 @@ std::tuple<int, int, int> injectionGroup(const Opm::Schedule& sched,
// WATER INJECTION GROUP CONTROL // WATER INJECTION GROUP CONTROL
if (group.hasInjectionControl(phase)) { if (group.hasInjectionControl(phase)) {
if (is_field) {
//set value for the group's availability for higher level control for injection
high_level_ctrl = 0;
} else {
const auto& injection_controls = group.injectionControls(phase, sumState); const auto& injection_controls = group.injectionControls(phase, sumState);
const auto& guide_rate_def = injection_controls.guide_rate_def; const auto& guide_rate_def = injection_controls.guide_rate_def;
const auto& cur_inj_ctrl = group.name() == "FIELD" ? static_cast<int>(sumState.get(field_key, -1)) : static_cast<int>(sumState.get_group_var(group.name(), group_key, -1)); const auto& cur_inj_ctrl = group.name() == "FIELD" ? static_cast<int>(sumState.get(field_key, -1)) : static_cast<int>(sumState.get_group_var(group.name(), group_key, -1));
@ -553,19 +562,21 @@ std::tuple<int, int, int> injectionGroup(const Opm::Schedule& sched,
} }
gconinje_cmode = Opm::Group::InjectionCMode2Int(deck_cmode); gconinje_cmode = Opm::Group::InjectionCMode2Int(deck_cmode);
if (cgroup && (group.getGroupType() != Opm::Group::GroupType::NONE)) { if (cgroup && (cgroup->name() != group.name()) && (group.getGroupType() != Opm::Group::GroupType::NONE)) {
auto cgroup_control = (cgroup->name() == "FIELD") ? static_cast<int>(sumState.get(field_key, 0)) : static_cast<int>(sumState.get_group_var(cgroup->name(), group_key, 0)); auto cgroup_control = (cgroup->name() == "FIELD") ? static_cast<int>(sumState.get(field_key, 0)) : static_cast<int>(sumState.get_group_var(cgroup->name(), group_key, 0));
current_cmode = (guide_rate_def != Opm::Group::GuideRateInjTarget::NO_GUIDE_RATE) ? cgroup_control : 0; current_cmode = (guide_rate_def != Opm::Group::GuideRateInjTarget::NO_GUIDE_RATE) ? cgroup_control : 0;
} else { } else {
current_cmode = cur_inj_ctrl; current_cmode = cur_inj_ctrl;
} }
} }
}
else { else {
//set default value for the group's availability for higher level control for water injection for groups with no GCONINJE - WATER //set default value for the group's availability for higher level control for water injection for groups with no GCONINJE - WATER
high_level_ctrl = (groupCurrentlyInjectionControllable(sched, sumState, group, phase, simStep) ) ? 1 : -1; high_level_ctrl = (groupCurrentlyInjectionControllable(sched, sumState, group, phase, simStep) ) ? 1 : -1;
} }
// special treatment of group "FIELD"
if (is_field) high_level_ctrl = 0;
return {high_level_ctrl, current_cmode, gconinje_cmode}; return {high_level_ctrl, current_cmode, gconinje_cmode};
} }