Merge pull request #2648 from joakim-hove/group-has-injection-control

Use Group class to query for  controls
This commit is contained in:
Tor Harald Sandve
2021-09-03 07:32:28 +02:00
committed by GitHub
3 changed files with 95 additions and 16 deletions

View File

@@ -185,7 +185,6 @@ struct InjectionControls {
std::string voidage_group;
double guide_rate;
GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
bool has_control(InjectionCMode control) const;
};
struct GroupProductionProperties {
@@ -241,7 +240,6 @@ struct ProductionControls {
GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
double resv_target = 0;
int production_controls = 0;
bool has_control(ProductionCMode control) const;
};
@@ -296,12 +294,14 @@ struct ProductionControls {
InjectionCMode injection_cmode() const;
Phase injection_phase() const;
bool has_control(ProductionCMode control) const;
bool has_control(InjectionCMode control) const;
bool has_control(Phase phase, InjectionCMode control) const;
bool productionGroupControlAvailable() const;
bool injectionGroupControlAvailable(const Phase phase) const;
const std::optional<GPMaint>& gpmaint() const;
void set_gpmaint(GPMaint gpmaint);
void set_gpmaint();
bool has_gpmaint_control(Phase phase, InjectionCMode cmode) const;
bool has_gpmaint_control(ProductionCMode cmode) const;
bool operator==(const Group& data) const;
const std::optional<Phase>& topup_phase() const;

View File

@@ -456,11 +456,28 @@ const Group::GroupType& Group::getGroupType() const {
}
bool Group::isProductionGroup() const {
return this->hasType(GroupType::PRODUCTION);
if (this->hasType(GroupType::PRODUCTION))
return true;
if (!this->m_gpmaint.has_value())
return false;
auto gpmaint_control = this->m_gpmaint->flow_target();
return (gpmaint_control == GPMaint::FlowTarget::RESV_PROD);
}
bool Group::isInjectionGroup() const {
return this->hasType(GroupType::INJECTION);
if (this->hasType(GroupType::INJECTION))
return true;
if (!this->m_gpmaint.has_value())
return false;
auto gpmaint_control = this->m_gpmaint->flow_target();
if (gpmaint_control == GPMaint::FlowTarget::RESV_PROD)
return false;
return true;
}
void Group::setProductionGroup() {
@@ -637,18 +654,24 @@ Group::ProductionCMode Group::prod_cmode() const {
return this->production_properties.cmode;
}
bool Group::ProductionControls::has_control(Group::ProductionCMode control) const {
return detail::has_control(this->production_controls, control);
}
bool Group::InjectionControls::has_control(InjectionCMode cmode_arg) const {
return detail::has_control(this->injection_controls, cmode_arg);
}
bool Group::has_control(Group::ProductionCMode control) const {
return detail::has_control(production_properties.production_controls, control);
if (detail::has_control(production_properties.production_controls, control))
return true;
return this->has_gpmaint_control(control);
}
bool Group::has_control(Phase phase, Group::InjectionCMode control) const {
auto prop_iter = this->injection_properties.find(phase);
if (prop_iter != this->injection_properties.end()) {
if (detail::has_control(prop_iter->second.injection_controls, control))
return true;
}
return this->has_gpmaint_control(phase, control);
}
const std::optional<GPMaint>& Group::gpmaint() const {
return this->m_gpmaint;
}
@@ -661,6 +684,55 @@ void Group::set_gpmaint() {
this->m_gpmaint = std::nullopt;
}
bool Group::has_gpmaint_control(Phase phase, InjectionCMode control) const {
if (!this->m_gpmaint.has_value())
return false;
auto gpmaint_control = this->m_gpmaint->flow_target();
if (phase == Phase::WATER) {
switch (control) {
case InjectionCMode::RATE:
return gpmaint_control == GPMaint::FlowTarget::SURF_WINJ;
case InjectionCMode::RESV:
return gpmaint_control == GPMaint::FlowTarget::RESV_WINJ;
default:
return false;
}
}
if (phase == Phase::GAS) {
switch (control) {
case InjectionCMode::RATE:
return gpmaint_control == GPMaint::FlowTarget::SURF_GINJ;
case InjectionCMode::RESV:
return gpmaint_control == GPMaint::FlowTarget::RESV_GINJ;
default:
return false;
}
}
if (phase == Phase::OIL) {
switch (control) {
case InjectionCMode::RATE:
return gpmaint_control == GPMaint::FlowTarget::SURF_OINJ;
case InjectionCMode::RESV:
return gpmaint_control == GPMaint::FlowTarget::RESV_OINJ;
default:
return false;
}
}
throw std::logic_error("What the fuck - broken phase?!");
}
bool Group::has_gpmaint_control(ProductionCMode control) const {
if (!this->m_gpmaint.has_value())
return false;
auto gpmaint_control = this->m_gpmaint->flow_target();
return (control == Group::ProductionCMode::RESV && gpmaint_control == GPMaint::FlowTarget::RESV_PROD);
}
const std::string Group::ExceedAction2String( ExceedAction enumValue ) {
switch(enumValue) {

View File

@@ -638,6 +638,7 @@ GRUPTREE
GPMAINT
'PROD' 'WINJ' 2 1* 100 0.25 1.0 /
'C1' 'GINJ' 0 1* 100 0.25 1.0 /
'F1' 'PROD' 1 1 1 1 1 /
/
TSTEP
@@ -679,6 +680,7 @@ GCONPROD
const auto& prod_group = sched.getGroup("PROD", 0);
const auto& plat_group = sched.getGroup("PLAT-A", 0);
const auto& c1_group = sched.getGroup("C1", 0);
const auto& f1_group = sched.getGroup("F1", 0);
const auto& gpm_prod = prod_group.gpmaint();
BOOST_CHECK( gpm_prod );
@@ -694,8 +696,13 @@ GCONPROD
BOOST_CHECK_EQUAL( rate3, (error + 2*error*dt / T) * K + current_rate );
}
// This should be flagged as an injection group because the group is
// under GPMAINT control with WINJ target.
BOOST_CHECK( prod_group.isInjectionGroup() );
BOOST_CHECK( f1_group.isProductionGroup() );
BOOST_CHECK( prod_group.has_control(Phase::WATER, Group::InjectionCMode::RESV) );
BOOST_CHECK( !prod_group.has_control(Phase::GAS, Group::InjectionCMode::RESV) );
BOOST_CHECK( f1_group.has_control(Group::ProductionCMode::RESV) );
auto [name, number] = *gpm_prod->region();
BOOST_CHECK_EQUAL(number, 2);