Merge pull request #3665 from atgeirr/make-wconinjh-invalid-mode-a-warning

Allow invalid WCONINJH control mode
This commit is contained in:
Bård Skaflestad
2023-09-12 13:29:03 +02:00
committed by GitHub
3 changed files with 25 additions and 6 deletions

View File

@@ -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<int>(controlModeArg))
return true;

View File

@@ -1379,7 +1379,7 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno)
auto well2 = this->snapshots.back().wells.get( well_name );
auto injection = std::make_shared<Well::WellInjectionProperties>(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))

View File

@@ -20,6 +20,7 @@
#include <config.h>
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Units/Units.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
@@ -30,6 +31,8 @@
#include "../eval_uda.hpp"
#include <fmt/format.h>
#include <ostream>
#include <string>
#include <vector>
@@ -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<double>() ? std::to_string(sir.get<double>()) : sir.get<std::string>();
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