From 92a716fa18b23270fd659d79a4bd6d0764140e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 6 Sep 2023 14:58:57 +0200 Subject: [PATCH] Make it a warning instead of an error to specify an invalid control mode in WCONINJH. Motivated by the need to accept deck output that contain this error, that is generated by preprocessing tools. --- opm/input/eclipse/Schedule/Well/Well.hpp | 2 +- .../eclipse/Schedule/KeywordHandlers.cpp | 2 +- .../Schedule/Well/WellInjectionProperties.cpp | 27 ++++++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/opm/input/eclipse/Schedule/Well/Well.hpp b/opm/input/eclipse/Schedule/Well/Well.hpp index 86d683f61..f6b90e7e4 100644 --- a/opm/input/eclipse/Schedule/Well/Well.hpp +++ b/opm/input/eclipse/Schedule/Well/Well.hpp @@ -168,7 +168,7 @@ public: void handleWELTARG(WELTARGCMode cmode, const UDAValue& new_arg, double SIFactorP); void handleWCONINJE(const DeckRecord& record, bool availableForGroupControl, const std::string& well_name); - void handleWCONINJH(const DeckRecord& record, bool is_producer, const std::string& well_name); + void handleWCONINJH(const DeckRecord& record, const bool is_producer, const std::string& well_name, const KeywordLocation& loc); bool hasInjectionControl(InjectorCMode controlModeArg) const { if (injectionControls & static_cast(controlModeArg)) return true; diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index 5021924bc..54543f28f 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -1371,7 +1371,7 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno) auto well2 = this->snapshots.back().wells.get( well_name ); auto injection = std::make_shared(well2.getInjectionProperties()); auto previousInjectorType = injection->injectorType; - injection->handleWCONINJH(record, well2.isProducer(), well_name); + injection->handleWCONINJH(record, well2.isProducer(), well_name, handlerContext.keyword.location()); const bool switching_from_producer = well2.isProducer(); if (well2.updateInjection(injection)) diff --git a/src/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp b/src/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp index e24fb4bda..631244de9 100644 --- a/src/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp +++ b/src/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,8 @@ #include "../eval_uda.hpp" +#include + #include #include #include @@ -177,7 +180,12 @@ namespace Opm { } - void Well::WellInjectionProperties::handleWCONINJH(const DeckRecord& record, bool is_producer, const std::string& well_name) { + void + Well::WellInjectionProperties::handleWCONINJH(const DeckRecord& record, + const bool is_producer, + const std::string& well_name, + const KeywordLocation& loc) + { // convert injection rates to SI const auto& typeItem = record.getItem("TYPE"); if (typeItem.defaultApplied(0)) { @@ -196,11 +204,22 @@ namespace Opm { this->THPH = record.getItem("THP").getSIDouble(0); const std::string& cmodeString = record.getItem("CMODE").getTrimmedString(0); - const InjectorCMode newControlMode = WellInjectorCModeFromString(cmodeString); + InjectorCMode newControlMode = WellInjectorCModeFromString(cmodeString); if ( !(newControlMode == InjectorCMode::RATE || newControlMode == InjectorCMode::BHP) ) { - const std::string msg = "Only RATE and BHP control are allowed for WCONINJH for well " + well_name; - throw std::invalid_argument(msg); + newControlMode = InjectorCMode::RATE; + const auto& sir = this->surfaceInjectionRate; + std::string target = sir.is() ? std::to_string(sir.get()) : sir.get(); + std::string msg = fmt::format("Problem with keyword WCONINJH\n" + "In {} line {}\n" + "Only RATE and BHP controls supported for well {}.\n" + "Selected control {} reset to RATE, with target = {}.", + loc.filename, + loc.lineno, + well_name, + WellInjectorCMode2String(newControlMode), + target); + OpmLog::warning(msg); } // when well is under BHP control, we use its historical BHP value as BHP limit