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

View File

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

View File

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

View File

@ -598,7 +598,7 @@ protected:
bool wellStructureChangedDynamically_{false}; bool wellStructureChangedDynamically_{false};
// Store maps of group name and new group controls for output // 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_; std::map<std::pair<std::string, Phase>, std::string> switched_inj_groups_;
// Store map of group name and close offending well for output // Store map of group name and close offending well for output
std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_; 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_) { for (const auto& [name, to] : this->switched_prod_groups_) {
const Group::ProductionCMode& oldControl = this->prevWGState().group_state.production_control(name); const Group::ProductionCMode& oldControl = this->prevWGState().group_state.production_control(name);
std::string from = Group::ProductionCMode2String(oldControl); std::string from = Group::ProductionCMode2String(oldControl);
if (to != from) { if (to.back() != from) {
std::string msg = " Production Group " + name std::string msg = " Production Group " + name
+ " control mode changed from "; + " control mode changed from ";
msg += from; msg += from;
msg += " to " + to; msg += " to " + to.back();
local_deferredLogger.info(msg); local_deferredLogger.info(msg);
} }
} }
@ -2236,10 +2236,14 @@ namespace Opm {
if (changed_well_to_group) { if (changed_well_to_group) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger); updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
changed_well_group = true; changed_well_group = true;
simulator_.gridView().comm());
} }
// Check individual well constraints and communicate. changed_well_to_group = comm.sum(static_cast<int>(changed_well_to_group));
bool changed_well_individual = false; 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. // 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. // We need to communicate the exception thrown to the others and rethrow.
@ -2262,7 +2266,7 @@ namespace Opm {
} }
// update wsolvent fraction for REIN wells // 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()); this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState());
return { changed_well_group, more_network_update }; return { changed_well_group, more_network_update };
@ -2471,6 +2475,16 @@ namespace Opm {
const int reportStepIdx, const int reportStepIdx,
const int iterationIdx) 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 = false;
bool changed_hc = this->checkGroupHigherConstraints( group, deferred_logger, reportStepIdx); bool changed_hc = this->checkGroupHigherConstraints( group, deferred_logger, reportStepIdx);
if (changed_hc) { if (changed_hc) {

View File

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