Merge pull request #1520 from atgeirr/add-group-availability

Add Group::isAvailableForGroupControl() method.
This commit is contained in:
Atgeirr Flø Rasmussen
2020-02-28 10:03:04 +01:00
committed by GitHub
4 changed files with 29 additions and 4 deletions

View File

@@ -173,6 +173,7 @@ struct ProductionControls {
GroupType gtype,
double groupEF,
bool transferGroupEF,
bool availableForGroupControl,
int vfp,
const std::string& parent,
const IOrderSet<std::string>& well,
@@ -205,6 +206,8 @@ struct ProductionControls {
void setInjectionGroup();
double getGroupEfficiencyFactor() const;
bool getTransferGroupEfficiencyFactor() const;
bool isAvailableForGroupControl() const;
void setAvailableForGroupControl(const bool available);
std::size_t numWells() const;
bool addGroup(const std::string& group_name);
@@ -245,6 +248,7 @@ private:
GroupType group_type;
double gefac;
bool transfer_gefac;
bool available_for_group_control;
int vfp_table;
std::string parent_group;

View File

@@ -39,6 +39,7 @@ Group::Group(const std::string& name, std::size_t insert_index_arg, std::size_t
group_type(GroupType::NONE),
gefac(1),
transfer_gefac(true),
available_for_group_control(name == "FIELD" ? false : true),
vfp_table(0)
{
// All groups are initially created as children of the "FIELD" group.
@@ -54,6 +55,7 @@ Group::Group(const std::string& gname,
GroupType gtype,
double groupEF,
bool transferGroupEF,
bool availableForGroupControl,
int vfp,
const std::string& parentName,
const IOrderSet<std::string>& well,
@@ -68,6 +70,7 @@ Group::Group(const std::string& gname,
group_type(gtype),
gefac(groupEF),
transfer_gefac(transferGroupEF),
available_for_group_control(availableForGroupControl),
vfp_table(vfp),
parent_group(parentName),
m_wells(well),
@@ -345,6 +348,14 @@ bool Group::getTransferGroupEfficiencyFactor() const {
return this->transfer_gefac;
}
bool Group::isAvailableForGroupControl() const {
return this->available_for_group_control;
}
void Group::setAvailableForGroupControl(const bool available) {
this->available_for_group_control = available;
}
const std::string& Group::parent() const {
return this->parent_group;
}

View File

@@ -1604,6 +1604,7 @@ std::pair<std::time_t, std::size_t> restart_info(const RestartIO::RstState * rst
if (!record.getItem("VOIDAGE_GROUP").defaultApplied(0))
voidage_group = record.getItem("VOIDAGE_GROUP").getTrimmedString(0);;
bool availableForGroupControl = DeckItem::to_bool(record.getItem("FREE").getTrimmedString(0));
//surfaceInjectionRate = injection::rateToSI(surfaceInjectionRate, phase, section.unitSystem());
{
auto group_ptr = std::make_shared<Group>(this->getGroup(group_name, currentStep));
@@ -1630,7 +1631,9 @@ std::pair<std::time_t, std::size_t> restart_info(const RestartIO::RstState * rst
if (!record.getItem("VOIDAGE_TARGET").defaultApplied(0))
injection.injection_controls += static_cast<int>(Group::InjectionCMode::VREP);
if (group_ptr->updateInjection(injection)) {
const bool must_update_avail = group_ptr->isAvailableForGroupControl() != availableForGroupControl;
if (group_ptr->updateInjection(injection) || must_update_avail) {
group_ptr->setAvailableForGroupControl(availableForGroupControl);
this->updateGroup(std::move(group_ptr), currentStep);
m_events.addEvent( ScheduleEvents::GROUP_INJECTION_UPDATE , currentStep);
this->addWellGroupEvent(group_name, ScheduleEvents::GROUP_INJECTION_UPDATE, currentStep);
@@ -1676,6 +1679,7 @@ std::pair<std::time_t, std::size_t> restart_info(const RestartIO::RstState * rst
}
}
auto resv_target = record.getItem("RESERVOIR_FLUID_TARGET").getSIDouble(0);
bool availableForGroupControl = DeckItem::to_bool(record.getItem("RESPOND_TO_PARENT").getTrimmedString(0));
{
auto group_ptr = std::make_shared<Group>(this->getGroup(group_name, currentStep));
Group::GroupProductionProperties production;
@@ -1712,7 +1716,9 @@ std::pair<std::time_t, std::size_t> restart_info(const RestartIO::RstState * rst
if (!record.getItem("RESERVOIR_FLUID_TARGET").defaultApplied(0))
production.production_controls += static_cast<int>(Group::ProductionCMode::RESV);
if (group_ptr->updateProduction(production)) {
const bool must_update_avail = group_ptr->isAvailableForGroupControl() != availableForGroupControl;
if (group_ptr->updateProduction(production) || must_update_avail) {
group_ptr->setAvailableForGroupControl(availableForGroupControl);
auto new_config = std::make_shared<GuideRateConfig>( this->guideRateConfig(currentStep) );
new_config->update_group(*group_ptr);
this->guide_rate_config.update( currentStep, std::move(new_config) );

View File

@@ -451,8 +451,8 @@ BOOST_AUTO_TEST_CASE(GCONINJE_MULTIPLE_PHASES) {
10 /
GCONINJE
'G2' 'WATER' 1* 1000 /
'G2' 'GAS' 1* 1* 2000 /
'G2' 'WATER' 1* 1000 /
'G2' 'GAS' 1* 1* 2000 2* 'NO' /
'G1' 'GAS' 1* 1000 /
/
@@ -471,6 +471,7 @@ BOOST_AUTO_TEST_CASE(GCONINJE_MULTIPLE_PHASES) {
BOOST_CHECK( g1.hasInjectionControl(Phase::WATER));
BOOST_CHECK( g1.hasInjectionControl(Phase::GAS));
BOOST_CHECK( !g1.hasInjectionControl(Phase::OIL));
BOOST_CHECK( g1.isAvailableForGroupControl() );
g1.injectionControls(Phase::WATER, st);
g1.injectionControls(Phase::GAS, st);
@@ -483,6 +484,7 @@ BOOST_AUTO_TEST_CASE(GCONINJE_MULTIPLE_PHASES) {
const auto& g2 = schedule.getGroup("G2", 0);
BOOST_CHECK(!g2.has_topup_phase());
BOOST_CHECK_THROW(g2.topup_phase(), std::logic_error);
BOOST_CHECK( g2.isAvailableForGroupControl() );
}
// Step 1
{
@@ -490,6 +492,7 @@ BOOST_AUTO_TEST_CASE(GCONINJE_MULTIPLE_PHASES) {
BOOST_CHECK( g2.hasInjectionControl(Phase::WATER));
BOOST_CHECK( g2.hasInjectionControl(Phase::GAS));
BOOST_CHECK( !g2.hasInjectionControl(Phase::OIL));
BOOST_CHECK( !g2.isAvailableForGroupControl() );
g2.injectionControls(Phase::WATER, st);
g2.injectionControls(Phase::GAS, st);
@@ -502,5 +505,6 @@ BOOST_AUTO_TEST_CASE(GCONINJE_MULTIPLE_PHASES) {
const auto& g1 = schedule.getGroup("G1", 1);
BOOST_CHECK(!g1.has_topup_phase());
BOOST_CHECK_THROW(g1.topup_phase(), std::logic_error);
BOOST_CHECK( g1.isAvailableForGroupControl() );
}
}