Update Injected/Produced Flag When Processing WELOPEN

If a well is entered in WCON{INJE,PROD} as status 'SHUT' but later
activated in WELOPEN, we must take care to record this status change
in the well's internal "has_produced" or "has_injected" flags as
appropriate.  Otherwise, the counts of "abandoned" wells will not be
correct.
This commit is contained in:
Bård Skaflestad
2022-02-21 16:01:28 +01:00
parent 0275a00b0f
commit 4150936e7c

View File

@@ -1245,23 +1245,39 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno)
/* if all records are defaulted or just the status is set, only
* well status is updated
*/
if (conn_defaulted( record )) {
const auto well_status = Well::StatusFromString( status_str );
if (conn_defaulted(record)) {
const auto new_well_status = Well::StatusFromString(status_str);
for (const auto& wname : well_names) {
{
const auto& well = this->getWell(wname, currentStep);
if( well_status == open && !well.canOpen() ) {
auto elapsed = this->snapshots[currentStep].start_time() - this->snapshots[0].start_time();
auto days = std::chrono::duration_cast<std::chrono::hours>(elapsed).count() / 24;
std::string msg = "Well " + wname
+ " where crossflow is banned has zero total rate."
+ " This well is prevented from opening at "
+ std::to_string( days ) + " days";
OpmLog::note(msg);
} else {
this->updateWellStatus( wname, currentStep, well_status);
if (handlerContext.sim_update)
handlerContext.sim_update->affected_wells.insert(wname);
if ((new_well_status == open) && !this->getWell(wname, currentStep).canOpen()) {
auto elapsed = this->snapshots[currentStep].start_time() - this->snapshots[0].start_time();
auto days = std::chrono::duration_cast<std::chrono::hours>(elapsed).count() / 24;
std::string msg = "Well " + wname
+ " where crossflow is banned has zero total rate."
+ " This well is prevented from opening at "
+ std::to_string( days ) + " days";
OpmLog::note(msg);
}
else {
const auto did_update_well_status =
this->updateWellStatus(wname, currentStep, new_well_status);
if (handlerContext.sim_update) {
handlerContext.sim_update->affected_wells.insert(wname);
}
if (did_update_well_status && (new_well_status == open)) {
// Record possible well injection/production status change
auto well2 = this->snapshots[currentStep].wells.get(wname);
const auto did_flow_update =
(well2.isProducer() && well2.updateHasProduced())
||
(well2.isInjector() && well2.updateHasInjected());
if (did_flow_update) {
this->snapshots[currentStep].wells.update(std::move(well2));
}
}
}
}