Merge pull request #1763 from joakim-hove/weltarg-uda

Weltarg uda
This commit is contained in:
Joakim Hove
2020-05-04 11:54:19 +02:00
committed by GitHub
9 changed files with 224 additions and 493 deletions
+1
View File
@@ -65,6 +65,7 @@ public:
bool operator!=(const UDAValue& other) const;
UDAValue& operator=(double value);
UDAValue& operator=(const std::string& value);
void update_value(const UDAValue& other);
bool is_numeric() { return numeric_value; }
@@ -250,7 +250,7 @@ public:
static WellInjectionProperties serializeObject();
void handleWELTARG(WELTARGCMode cmode, double newValue, double SIFactorP);
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);
bool hasInjectionControl(InjectorCMode controlModeArg) const {
@@ -381,7 +381,7 @@ public:
static bool effectiveHistoryProductionControl(ProducerCMode cmode);
void handleWCONPROD( const std::string& well, const DeckRecord& record);
void handleWCONHIST( const DeckRecord& record);
void handleWELTARG( WELTARGCMode cmode, double newValue, double SiFactorP);
void handleWELTARG( WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP);
void resetDefaultBHPLimit();
void clearControls();
ProductionControls controls(const SummaryState& st, double udq_default) const;
+12
View File
@@ -120,6 +120,8 @@ UDAValue& UDAValue::operator=(const std::string& value) {
return *this;
}
template<>
std::string UDAValue::get() const {
if (!this->numeric_value)
@@ -164,6 +166,16 @@ std::ostream& operator<<( std::ostream& stream, const UDAValue& uda_value ) {
return stream;
}
void UDAValue::update_value(const UDAValue& other) {
if (other.is<double>()) {
this->double_value = other.get<double>();
this->numeric_value = true;
} else {
this->string_value = other.get<std::string>();
this->numeric_value = false;
}
}
}
@@ -1616,8 +1616,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
const auto cmode = Well::WELTARGCModeFromString(record.getItem("CMODE").getTrimmedString(0));
double newValue = record.getItem("NEW_VALUE").get< double >(0);
const auto new_arg = record.getItem("NEW_VALUE").get< UDAValue >(0);
const auto well_names = wellNames( wellNamePattern, currentStep );
if( well_names.empty() )
@@ -1630,16 +1629,20 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext&
bool update = false;
if (well2->isProducer()) {
auto prop = std::make_shared<Well::WellProductionProperties>(well2->getProductionProperties());
prop->handleWELTARG(cmode, newValue, SiFactorP);
prop->handleWELTARG(cmode, new_arg, SiFactorP);
update = well2->updateProduction(prop);
if (cmode == Well::WELTARGCMode::GUID)
update |= well2->updateWellGuideRate(newValue);
update |= well2->updateWellGuideRate(new_arg.get<double>());
auto udq = std::make_shared<UDQActive>(this->udqActive(currentStep));
if (prop->updateUDQActive(this->getUDQConfig(currentStep), *udq))
this->updateUDQActive(currentStep, udq);
} else {
auto inj = std::make_shared<Well::WellInjectionProperties>(well2->getInjectionProperties());
inj->handleWELTARG(cmode, newValue, SiFactorP);
inj->handleWELTARG(cmode, new_arg, SiFactorP);
update = well2->updateInjection(inj);
if (cmode == Well::WELTARGCMode::GUID)
update |= well2->updateWellGuideRate(newValue);
update |= well2->updateWellGuideRate(new_arg.get<double>());
}
if (update)
this->updateWell(std::move(well2), currentStep);
@@ -144,6 +144,10 @@ const std::vector<UDQActive::Record>& UDQActive::get_iuad() const {
this->output_data.emplace_back(input_record.udq, input_record.input_index, 0, input_record.wgname, input_record.control);
}
std::sort(this->output_data.begin(), this->output_data.end(),
[](const UDQActive::Record& rec1, const UDQActive::Record& rec2) { return rec1.input_index < rec2.input_index;});
if (!output_data.empty()) {
for (std::size_t index = 1; index < output_data.size(); index++) {
const auto& prev_record = this->output_data[index - 1];
@@ -134,52 +134,39 @@ namespace Opm {
void Well::WellInjectionProperties::handleWELTARG(WELTARGCMode cmode, double newValue, double SiFactorP) {
void Well::WellInjectionProperties::handleWELTARG(WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP) {
if (cmode == Well::WELTARGCMode::BHP){
if (this->predictionMode) {
this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG");
this->BHPTarget = newValue;
this->BHPTarget.update_value( new_arg );
} else
this->bhp_hist_limit = newValue * SiFactorP;
this->bhp_hist_limit = new_arg.get<double>() * SiFactorP;
}
else if (cmode == WELTARGCMode::ORAT){
if(this->injectorType == InjectorType::OIL){
this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG");
this->surfaceInjectionRate = newValue;
}else{
if (this->injectorType == InjectorType::OIL)
this->surfaceInjectionRate.update_value( new_arg );
else
std::invalid_argument("Well type must be OIL to set the oil rate");
}
}
else if (cmode == WELTARGCMode::WRAT){
if (this->injectorType == InjectorType::WATER) {
this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG");
this->surfaceInjectionRate = newValue;
}
if (this->injectorType == InjectorType::WATER)
this->surfaceInjectionRate.update_value( new_arg );
else
std::invalid_argument("Well type must be WATER to set the water rate");
}
else if (cmode == WELTARGCMode::GRAT){
if(this->injectorType == InjectorType::GAS){
this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG");
this->surfaceInjectionRate = newValue;
}else{
if(this->injectorType == InjectorType::GAS)
this->surfaceInjectionRate.update_value( new_arg );
else
std::invalid_argument("Well type must be GAS to set the gas rate");
}
}
else if (cmode == WELTARGCMode::THP){
this->THPTarget.assert_numeric("Can not combine UDA and WELTARG");
this->THPTarget = newValue;
}
else if (cmode == WELTARGCMode::VFP){
this->VFPTableNumber = static_cast<int> (newValue);
}
else if (cmode == WELTARGCMode::RESV){
this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG");
this->reservoirInjectionRate = newValue;
}
else if (cmode != WELTARGCMode::GUID){
else if (cmode == WELTARGCMode::THP)
this->THPTarget.update_value( new_arg );
else if (cmode == WELTARGCMode::VFP)
this->VFPTableNumber = static_cast<int>(new_arg.get<double>());
else if (cmode == WELTARGCMode::RESV)
this->reservoirInjectionRate.update_value( new_arg );
else if (cmode != WELTARGCMode::GUID)
throw std::invalid_argument("Invalid keyword (MODE) supplied");
}
}
@@ -218,47 +218,40 @@ namespace Opm {
void Well::WellProductionProperties::handleWELTARG(Well::WELTARGCMode cmode, double newValue, double SiFactorP) {
void Well::WellProductionProperties::handleWELTARG(Well::WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP) {
if (cmode == WELTARGCMode::ORAT){
this->OilRate.assert_numeric("Can not combine UDA and WELTARG");
this->OilRate = newValue;
this->OilRate.update_value( new_arg );
this->addProductionControl( ProducerCMode::ORAT );
}
else if (cmode == WELTARGCMode::WRAT){
this->WaterRate.assert_numeric("Can not combine UDA and WELTARG");
this->WaterRate = newValue;
this->WaterRate.update_value( new_arg );
this->addProductionControl( ProducerCMode::WRAT );
}
else if (cmode == WELTARGCMode::GRAT){
this->GasRate.assert_numeric("Can not combine UDA and WELTARG");
this->GasRate = newValue;
this->GasRate.update_value( new_arg );
this->addProductionControl( ProducerCMode::GRAT );
}
else if (cmode == WELTARGCMode::LRAT){
this->LiquidRate.assert_numeric("Can not combine UDA and WELTARG");
this->LiquidRate = newValue;
this->LiquidRate.update_value( new_arg );
this->addProductionControl( ProducerCMode::LRAT );
}
else if (cmode == WELTARGCMode::RESV){
this->ResVRate.assert_numeric("Can not combine UDA and WELTARG");
this->ResVRate = newValue;
this->ResVRate.update_value( new_arg );
this->addProductionControl( ProducerCMode::RESV );
}
else if (cmode == WELTARGCMode::BHP){
if (this->predictionMode) {
this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG");
this->BHPTarget = newValue;
} else
this->bhp_hist_limit = newValue * SiFactorP;
if (this->predictionMode)
this->BHPTarget.update_value( new_arg );
else
this->bhp_hist_limit = new_arg.get<double>() * SiFactorP;
this->addProductionControl( ProducerCMode::BHP );
}
else if (cmode == WELTARGCMode::THP){
this->THPTarget.assert_numeric("Can not combine UDA and WELTARG");
this->THPTarget = newValue;
this->THPTarget.update_value( new_arg );
this->addProductionControl( ProducerCMode::THP );
}
else if (cmode == WELTARGCMode::VFP)
this->VFPTableNumber = static_cast<int> (newValue);
this->VFPTableNumber = static_cast<int>(new_arg.get<double>());
else if (cmode != WELTARGCMode::GUID)
throw std::invalid_argument("Invalid keyword (MODE) supplied");
}
@@ -14,7 +14,7 @@
},
{
"name": "NEW_VALUE",
"value_type": "DOUBLE"
"value_type": "UDA"
}
]
}
File diff suppressed because it is too large Load Diff