Merge pull request #3102 from totto82/validControls2

make sure wells has valid controls
This commit is contained in:
Joakim Hove 2021-03-15 09:43:22 +01:00 committed by GitHub
commit 8adea8c68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 28 deletions

View File

@ -271,26 +271,6 @@ namespace Opm {
well_state_.initWellStateMSWell(wells_ecl_, phase_usage_, &previous_well_state_); well_state_.initWellStateMSWell(wells_ecl_, phase_usage_, &previous_well_state_);
} }
const int nw = wells_ecl_.size();
for (int w = 0; w <nw; ++w) {
const auto& well = wells_ecl_[w];
const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
+ ScheduleEvents::PRODUCTION_UPDATE
+ ScheduleEvents::INJECTION_UPDATE
+ ScheduleEvents::NEW_WELL;
if(!schedule()[timeStepIdx].wellgroup_events().hasEvent(well.name(), effective_events_mask))
continue;
if (well.isProducer()) {
const auto controls = well.productionControls(summaryState);
well_state_.currentProductionControls()[w] = controls.cmode;
}
else {
const auto controls = well.injectionControls(summaryState);
well_state_.currentInjectionControls()[w] = controls.cmode;
}
}
const Group& fieldGroup = schedule().getGroup("FIELD", timeStepIdx); const Group& fieldGroup = schedule().getGroup("FIELD", timeStepIdx);
WellGroupHelpers::setCmodeGroup(fieldGroup, schedule(), summaryState, timeStepIdx, well_state_); WellGroupHelpers::setCmodeGroup(fieldGroup, schedule(), summaryState, timeStepIdx, well_state_);
@ -403,10 +383,11 @@ namespace Opm {
const auto& comm = ebosSimulator_.vanguard().grid().comm(); const auto& comm = ebosSimulator_.vanguard().grid().comm();
WellGroupHelpers::updateGuideRatesForWells(schedule(), phase_usage_, reportStepIdx, simulationTime, well_state_, comm, guideRate_.get()); WellGroupHelpers::updateGuideRatesForWells(schedule(), phase_usage_, reportStepIdx, simulationTime, well_state_, comm, guideRate_.get());
try { try {
// Compute initial well solution for new wells // Compute initial well solution for new wells and injectors that change injection type i.e. WAG.
for (auto& well : well_container_) { for (auto& well : well_container_) {
const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE const uint64_t effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE
+ ScheduleEvents::NEW_WELL; + ScheduleEvents::INJECTION_TYPE_CHANGED
+ ScheduleEvents::NEW_WELL;
const auto& events = schedule()[reportStepIdx].wellgroup_events(); const auto& events = schedule()[reportStepIdx].wellgroup_events();
const bool event = report_step_starts_ && events.hasEvent(well->name(), effective_events_mask); const bool event = report_step_starts_ && events.hasEvent(well->name(), effective_events_mask);

View File

@ -167,6 +167,16 @@ namespace Opm
current_injection_controls_.resize(nw); current_injection_controls_.resize(nw);
current_production_controls_.resize(nw); current_production_controls_.resize(nw);
for (int w = 0; w < nw; ++w) {
if (wells_ecl[w].isProducer()) {
const auto controls = wells_ecl[w].productionControls(summary_state);
currentProductionControls()[w] = controls.cmode;
}
else {
const auto controls = wells_ecl[w].injectionControls(summary_state);
currentInjectionControls()[w] = controls.cmode;
}
}
perfRateSolvent_.clear(); perfRateSolvent_.clear();
perfRateSolvent_.resize(nperf, 0.0); perfRateSolvent_.resize(nperf, 0.0);
@ -196,6 +206,11 @@ namespace Opm
continue; continue;
} }
if (is_producer_[newIndex] != prevState->is_producer_[oldIndex]) {
// Well changed to/from injector from/to producer, do not use its privious values.
continue;
}
// bhp // bhp
bhp()[ newIndex ] = prevState->bhp()[ oldIndex ]; bhp()[ newIndex ] = prevState->bhp()[ oldIndex ];
@ -207,12 +222,8 @@ namespace Opm
// continue; // continue;
//} //}
// if there is no effective control event happens to the well, we use the current_injection/production_controls_ from prevState current_injection_controls_[ newIndex ] = prevState->currentInjectionControls()[ oldIndex ];
// otherwise, we use the control specified in the deck current_production_controls_[ newIndex ] = prevState->currentProductionControls()[ oldIndex ];
if (!effective_events_occurred_[w]) {
current_injection_controls_[ newIndex ] = prevState->currentInjectionControls()[ oldIndex ];
current_production_controls_[ newIndex ] = prevState->currentProductionControls()[ oldIndex ];
}
// wellrates // wellrates
for( int i=0, idx=newIndex*np, oldidx=oldIndex*np; i<np; ++i, ++idx, ++oldidx ) for( int i=0, idx=newIndex*np, oldidx=oldIndex*np; i<np; ++i, ++idx, ++oldidx )