Restore Guiderate's Nominated Phase From Restart File

This commit is contained in:
Bård Skaflestad
2021-10-07 09:29:24 +02:00
parent 0c8f270723
commit e451babec7
5 changed files with 38 additions and 19 deletions

View File

@@ -90,6 +90,7 @@ struct RstHeader {
int ngroup_udq; int ngroup_udq;
int nfield_udq; int nfield_udq;
int num_action; int num_action;
int guide_rate_nominated_phase;
bool e300_radial; bool e300_radial;
bool e100_radial; bool e100_radial;

View File

@@ -40,6 +40,7 @@ public:
}; };
static Target TargetFromString(const std::string& s); static Target TargetFromString(const std::string& s);
static Target TargetFromRestart(const int nominated_phase);
GuideRateModel(double time_interval_arg, GuideRateModel(double time_interval_arg,
Target target_arg, Target target_arg,

View File

@@ -91,6 +91,7 @@ RstHeader::RstHeader(const Opm::UnitSystem& unit_system, const std::vector<int>&
ngroup_udq(intehead[VI::intehead::NO_GROUP_UDQS]), ngroup_udq(intehead[VI::intehead::NO_GROUP_UDQS]),
nfield_udq(intehead[VI::intehead::NO_FIELD_UDQS]), nfield_udq(intehead[VI::intehead::NO_FIELD_UDQS]),
num_action(intehead[VI::intehead::NOOFACTIONS]), num_action(intehead[VI::intehead::NOOFACTIONS]),
guide_rate_nominated_phase(intehead[VI::intehead::NGRNPH]),
// //
e300_radial(logihead[VI::logihead::E300Radial]), e300_radial(logihead[VI::logihead::E300Radial]),
e100_radial(logihead[VI::logihead::E100Radial]), e100_radial(logihead[VI::logihead::E100Radial]),

View File

@@ -19,6 +19,7 @@
#include <stdexcept> #include <stdexcept>
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <unordered_map>
#include <opm/parser/eclipse/Parser/ParserKeywords/L.hpp> #include <opm/parser/eclipse/Parser/ParserKeywords/L.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateModel.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateModel.hpp>
@@ -277,6 +278,19 @@ GuideRateModel::Target GuideRateModel::TargetFromString(const std::string& s) {
throw std::invalid_argument("Could not convert: " + s + " to a valid Target enum value"); throw std::invalid_argument("Could not convert: " + s + " to a valid Target enum value");
} }
GuideRateModel::Target GuideRateModel::TargetFromRestart(const int nominated_phase) {
static const auto int_to_target = std::unordered_map<int, Target> {
{0, Target::NONE},
{1, Target::OIL },
{3, Target::GAS },
{4, Target::LIQ },
{6, Target::RES },
{9, Target::COMB},
};
auto t = int_to_target.find(nominated_phase);
return (t == int_to_target.end()) ? Target::NONE : t->second;
}
/* /*
The COMB target - which requires parameters from the LINCOM keyword, is not The COMB target - which requires parameters from the LINCOM keyword, is not

View File

@@ -1399,35 +1399,38 @@ namespace {
OpmLog::info(fmt::format("Adding well {} from restart file", rst_well.name)); OpmLog::info(fmt::format("Adding well {} from restart file", rst_well.name));
} }
this->snapshots.back().update_tuning(rst_state.tuning); this->snapshots.back().update_tuning(rst_state.tuning);
this->snapshots.back().events().addEvent( ScheduleEvents::TUNING_CHANGE ); this->snapshots.back().events().addEvent( ScheduleEvents::TUNING_CHANGE );
{ {
const auto& header = rst_state.header; const auto& header = rst_state.header;
bool time_interval = 0; if (GuideRateModel::rst_valid(header.guide_rate_delay,
GuideRateModel::Target target = GuideRateModel::Target::OIL;
bool allow_increase = true;
bool use_free_gas = false;
if (GuideRateModel::rst_valid(time_interval,
header.guide_rate_a, header.guide_rate_a,
header.guide_rate_b, header.guide_rate_b,
header.guide_rate_c, header.guide_rate_c,
header.guide_rate_d, header.guide_rate_d,
header.guide_rate_e, header.guide_rate_e,
header.guide_rate_f, header.guide_rate_f,
header.guide_rate_damping)) { header.guide_rate_damping))
auto guide_rate_model = GuideRateModel(time_interval, {
target, const bool allow_increase = true;
header.guide_rate_a, const bool use_free_gas = false;
header.guide_rate_b,
header.guide_rate_c, const auto guide_rate_model = GuideRateModel {
header.guide_rate_d, header.guide_rate_delay,
header.guide_rate_e, GuideRateModel::TargetFromRestart(header.guide_rate_nominated_phase),
header.guide_rate_f, header.guide_rate_a,
allow_increase, header.guide_rate_b,
header.guide_rate_damping, header.guide_rate_c,
use_free_gas); header.guide_rate_d,
header.guide_rate_e,
header.guide_rate_f,
allow_increase,
header.guide_rate_damping,
use_free_gas
};
this->updateGuideRateModel(guide_rate_model, report_step); this->updateGuideRateModel(guide_rate_model, report_step);
} }
} }
@@ -1469,7 +1472,6 @@ namespace {
this->snapshots.back().udq_active.update( std::move(udq_active) ); this->snapshots.back().udq_active.update( std::move(udq_active) );
} }
if (!rst_state.actions.empty()) { if (!rst_state.actions.empty()) {
auto actions = this->snapshots.back().actions(); auto actions = this->snapshots.back().actions();
for (const auto& rst_action : rst_state.actions) for (const auto& rst_action : rst_state.actions)