Maximum allowed oscillation for groups part 1

This commit is contained in:
Tor Harald Sandve 2024-11-18 13:29:03 +01:00
parent b6f23f6fe5
commit 73a28a7abb
6 changed files with 25 additions and 12 deletions

View File

@ -562,7 +562,7 @@ bool BlackoilWellModelConstraints<Scalar>::
updateGroupIndividualControl(const Group& group,
const int reportStepIdx,
std::map<std::pair<std::string,Phase>,std::string>& switched_inj,
std::map<std::string, std::string>& switched_prod,
std::map<std::string, std::vector<std::string>>& switched_prod,
std::map<std::string, std::pair<std::string, std::string>>& closed_offending_wells,
GroupState<Scalar>& group_state,
WellState<Scalar>& well_state,
@ -612,7 +612,7 @@ updateGroupIndividualControl(const Group& group,
group_state, deferred_logger);
if(changed) {
switched_prod.insert_or_assign(group.name(),
switched_prod[group.name()].push_back(
Group::ProductionCMode2String(changed_this.first));
WellGroupHelpers<Scalar>::updateWellRatesFromGroupTargetScale(changed_this.second,
group,

View File

@ -74,7 +74,7 @@ public:
bool updateGroupIndividualControl(const Group& group,
const int reportStepIdx,
std::map<std::pair<std::string,Phase>,std::string>& switched_inj,
std::map<std::string, std::string>& switched_prod,
std::map<std::string, std::vector<std::string>>& switched_prod,
std::map<std::string, std::pair<std::string, std::string>>& closed_offending_wells,
GroupState<Scalar>& group_state,
WellState<Scalar>& well_state,

View File

@ -714,8 +714,7 @@ checkGroupHigherConstraints(const Group& group,
deferred_logger);
if (changed) {
switched_prod_groups_.insert_or_assign(group.name(),
Group::ProductionCMode2String(Group::ProductionCMode::FLD));
switched_prod_groups_[group.name()].push_back(Group::ProductionCMode2String(Group::ProductionCMode::FLD));
WellGroupHelpers<Scalar>::updateWellRatesFromGroupTargetScale(scaling_factor,
group,
schedule(),

View File

@ -598,7 +598,7 @@ protected:
bool wellStructureChangedDynamically_{false};
// Store maps of group name and new group controls for output
std::map<std::string, std::string> switched_prod_groups_;
std::map<std::string, std::vector<std::string>> switched_prod_groups_;
std::map<std::pair<std::string, Phase>, std::string> switched_inj_groups_;
// Store map of group name and close offending well for output
std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;

View File

@ -752,11 +752,11 @@ namespace Opm {
for (const auto& [name, to] : this->switched_prod_groups_) {
const Group::ProductionCMode& oldControl = this->prevWGState().group_state.production_control(name);
std::string from = Group::ProductionCMode2String(oldControl);
if (to != from) {
if (to.back() != from) {
std::string msg = " Production Group " + name
+ " control mode changed from ";
msg += from;
msg += " to " + to;
msg += " to " + to.back();
local_deferredLogger.info(msg);
}
}
@ -2236,10 +2236,14 @@ namespace Opm {
if (changed_well_to_group) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
changed_well_group = true;
simulator_.gridView().comm());
}
// Check individual well constraints and communicate.
bool changed_well_individual = false;
changed_well_to_group = comm.sum(static_cast<int>(changed_well_to_group));
if (changed_well_to_group) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
changed_well_group = true;
}
{
// For MS Wells a linear solve is performed below and the matrix might be singular.
// We need to communicate the exception thrown to the others and rethrow.
@ -2262,7 +2266,7 @@ namespace Opm {
}
// update wsolvent fraction for REIN wells
const Group& fieldGroup = this->schedule().getGroup("FIELD", episodeIdx);
//const Group& fieldGroup = this->schedule().getGroup("FIELD", episodeIdx);
this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState());
return { changed_well_group, more_network_update };
@ -2471,6 +2475,16 @@ namespace Opm {
const int reportStepIdx,
const int iterationIdx)
{
if (this->switched_prod_groups_.count(group.name()) > 0) {
for (const auto& key : this->switched_prod_groups_[group.name()]) {
if (std::count(this->switched_prod_groups_[group.name()].begin(), this->switched_prod_groups_[group.name()].end(), key) >= 3) {
std::cout << "group control osccilating " << group.name() << " keep at " << key << std::endl;
return false;
}
}
}
bool changed = false;
bool changed_hc = this->checkGroupHigherConstraints( group, deferred_logger, reportStepIdx);
if (changed_hc) {

View File

@ -332,7 +332,7 @@ public:
last_valid_wgstate_ = WGState<double>::serializationTestObject(dummy);
nupcol_wgstate_ = WGState<double>::serializationTestObject(dummy);
last_glift_opt_time_ = 5.0;
switched_prod_groups_ = {{"test4", "test5"}};
switched_prod_groups_ = {{"test4", {"test5", "test6"}}};
switched_inj_groups_ = {{{"test4", Phase::SOLVENT}, "test5"}};
closed_offending_wells_ = {{"test4", {"test5", "test6"}}};
}