From 225d6ea26d0d71ff18f450764272cb79916eb308 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 26 Nov 2019 08:52:04 +0100 Subject: [PATCH 1/2] Make GCONSALE an injector --- opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp | 3 ++- src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp b/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp index f2d869117..17f3f6e00 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp @@ -63,7 +63,8 @@ enum class InjectionCMode : int { RESV = 2, REIN = 4, VREP = 8, - FLD = 16 + FLD = 16, + SALE = 32 }; static const std::string InjectionCMode2String( InjectionCMode enumValue ); static InjectionCMode InjectionCModeFromString( const std::string& stringValue ); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 1dba63b82..5ed945b8f 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1629,6 +1629,12 @@ namespace { new_gconsale->add(groupName, sales_target, max_rate, min_rate, procedure); + auto group_ptr = std::make_shared(this->getGroup(groupName, currentStep)); + Group::GroupInjectionProperties injection; + injection.phase = Phase::GAS; + if (group_ptr->updateInjection(injection)) { + this->updateGroup(std::move(group_ptr), currentStep); + } } this->gconsale.update(currentStep, new_gconsale); } From e1029e956b7361341cc4e98933dcee1971257f15 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 26 Nov 2019 11:04:30 +0100 Subject: [PATCH 2/2] convert from UDA to double for GCONSALE and GCONSUMP --- .../EclipseState/Schedule/Group/GConSale.hpp | 16 +++++++++++++++- .../EclipseState/Schedule/Group/GConSump.hpp | 13 ++++++++++++- .../eclipse/EclipseState/Schedule/Schedule.hpp | 4 ++-- .../EclipseState/Schedule/Group/GConSale.cpp | 17 ++++++++++++++++- .../EclipseState/Schedule/Group/GConSump.cpp | 16 +++++++++++++++- .../eclipse/EclipseState/Schedule/Schedule.cpp | 15 +++++++++------ 6 files changed, 69 insertions(+), 12 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp b/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp index 68271ea1d..b9f91d97f 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp @@ -23,6 +23,10 @@ #include #include +#include +#include +#include + namespace Opm { class GConSale { @@ -37,14 +41,24 @@ namespace Opm { UDAValue max_sales_rate; UDAValue min_sales_rate; MaxProcedure max_proc; + double udq_undefined; + UnitSystem unit_system; + }; + + struct GCONSALEGroupProp { + double sales_target; + double max_sales_rate; + double min_sales_rate; + MaxProcedure max_proc; }; GConSale() = default; bool has(const std::string& name) const; const GCONSALEGroup& get(const std::string& name) const; + const GCONSALEGroupProp get(const std::string& name, const SummaryState& st) const; static MaxProcedure stringToProcedure(const std::string& procedure); - void add(const std::string& name, const UDAValue& sales_target, const UDAValue& max_rate, const UDAValue& min_rate, const std::string& procedure); + void add(const std::string& name, const UDAValue& sales_target, const UDAValue& max_rate, const UDAValue& min_rate, const std::string& procedure, double udq_undefined_arg, const UnitSystem& unit_system); size_t size() const; private: diff --git a/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp b/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp index 6d8ade805..65b38db84 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp @@ -24,6 +24,8 @@ #include #include +#include +#include namespace Opm { @@ -35,11 +37,20 @@ namespace Opm { UDAValue consumption_rate; UDAValue import_rate; std::string network_node; + double udq_undefined; + UnitSystem unit_system; + }; + + struct GCONSUMPGroupProp { + double consumption_rate; + double import_rate; + std::string network_node; }; bool has(const std::string& name) const; const GCONSUMPGroup& get(const std::string& name) const; - void add(const std::string& name, const UDAValue& consumption_rate, const UDAValue& import_rate, const std::string network_node); + const GCONSUMPGroupProp get(const std::string& name, const SummaryState& st) const; + void add(const std::string& name, const UDAValue& consumption_rate, const UDAValue& import_rate, const std::string network_node, double udq_undefined_arg, const UnitSystem& unit_system); size_t size() const; private: diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 332a4362d..730ae167e 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -287,8 +287,8 @@ namespace Opm void handleGCONINJE( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); void handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); - void handleGCONSALE( const DeckKeyword& keyword, size_t currentStep); - void handleGCONSUMP( const DeckKeyword& keyword, size_t currentStep); + void handleGCONSALE( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system); + void handleGCONSUMP( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system); void handleGUIDERAT( const DeckKeyword& keyword, size_t currentStep); void handleLINCOM( const DeckKeyword& keyword, size_t currentStep); void handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp index 9c7be5fdc..c736437ba 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include "../eval_uda.hpp" namespace Opm { @@ -36,6 +38,17 @@ const GConSale::GCONSALEGroup& GConSale::get(const std::string& name) const { return it->second; } +const GConSale::GCONSALEGroupProp GConSale::get(const std::string& name, const SummaryState& st) const { + + GCONSALEGroupProp prop; + const GConSale::GCONSALEGroup& group = this->get(name); + prop.sales_target = UDA::eval_group_uda_rate(group.sales_target, name, st, group.udq_undefined, Phase::GAS, group.unit_system); + prop.max_sales_rate = UDA::eval_group_uda_rate(group.max_sales_rate, name, st, group.udq_undefined, Phase::GAS, group.unit_system); + prop.min_sales_rate = UDA::eval_group_uda_rate(group.min_sales_rate, name, st, group.udq_undefined, Phase::GAS, group.unit_system); + prop.max_proc = group.max_proc; + return prop; +} + GConSale::MaxProcedure GConSale::stringToProcedure(const std::string& str_proc) { if (str_proc == "NONE") return MaxProcedure::NONE; @@ -52,12 +65,14 @@ GConSale::MaxProcedure GConSale::stringToProcedure(const std::string& str_proc) return MaxProcedure::NONE; } -void GConSale::add(const std::string& name, const UDAValue& sales_target, const UDAValue& max_rate, const UDAValue& min_rate, const std::string& procedure) { +void GConSale::add(const std::string& name, const UDAValue& sales_target, const UDAValue& max_rate, const UDAValue& min_rate, const std::string& procedure, double udq_undefined_arg, const UnitSystem& unit_system) { GConSale::GCONSALEGroup& group = groups[name]; group.sales_target = sales_target; group.max_sales_rate = max_rate; group.min_sales_rate = min_rate; group.max_proc = stringToProcedure(procedure); + group.udq_undefined = udq_undefined_arg; + group.unit_system = unit_system; } size_t GConSale::size() const { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp index fa9c18447..334edab29 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp @@ -18,6 +18,8 @@ */ #include +#include +#include "../eval_uda.hpp" namespace Opm { @@ -36,13 +38,25 @@ const GConSump::GCONSUMPGroup& GConSump::get(const std::string& name) const { } -void GConSump::add(const std::string& name, const UDAValue& consumption_rate, const UDAValue& import_rate, const std::string network_node) { +const GConSump::GCONSUMPGroupProp GConSump::get(const std::string& name, const SummaryState& st) const { + + GCONSUMPGroupProp prop; + const GConSump::GCONSUMPGroup& group = this->get(name); + prop.consumption_rate = UDA::eval_group_uda_rate(group.consumption_rate, name, st, group.udq_undefined, Phase::GAS, group.unit_system); + prop.import_rate = UDA::eval_group_uda_rate(group.import_rate, name, st, group.udq_undefined, Phase::GAS, group.unit_system); + prop.network_node = group.network_node; + return prop; +} + +void GConSump::add(const std::string& name, const UDAValue& consumption_rate, const UDAValue& import_rate, const std::string network_node, double udq_undefined_arg, const UnitSystem& unit_system) { GConSump::GCONSUMPGroup& group = groups[name]; group.consumption_rate = consumption_rate; group.import_rate = import_rate; group.network_node = network_node; + group.udq_undefined = udq_undefined_arg; + group.unit_system = unit_system; } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 5ed945b8f..7f0b579a0 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -341,10 +341,10 @@ namespace { handleGEFAC(keyword, currentStep, parseContext, errors); else if (keyword.name() == "GCONSALE") - handleGCONSALE(keyword, currentStep); + handleGCONSALE(keyword, currentStep, unit_system); else if (keyword.name() == "GCONSUMP") - handleGCONSUMP(keyword, currentStep); + handleGCONSUMP(keyword, currentStep, unit_system); else if (keyword.name() == "GUIDERAT") handleGUIDERAT(keyword, currentStep); @@ -1617,7 +1617,7 @@ namespace { } } - void Schedule::handleGCONSALE( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleGCONSALE( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system) { const auto& current = *this->gconsale.get(currentStep); std::shared_ptr new_gconsale(new GConSale(current)); for( const auto& record : keyword ) { @@ -1626,8 +1626,9 @@ namespace { auto max_rate = record.getItem("MAX_SALES_RATE").get(0); auto min_rate = record.getItem("MIN_SALES_RATE").get(0); std::string procedure = record.getItem("MAX_PROC").getTrimmedString(0); + auto udqconfig = this->getUDQConfig(currentStep).params().undefinedValue(); - new_gconsale->add(groupName, sales_target, max_rate, min_rate, procedure); + new_gconsale->add(groupName, sales_target, max_rate, min_rate, procedure, udqconfig, unit_system); auto group_ptr = std::make_shared(this->getGroup(groupName, currentStep)); Group::GroupInjectionProperties injection; @@ -1640,7 +1641,7 @@ namespace { } - void Schedule::handleGCONSUMP( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleGCONSUMP( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system) { const auto& current = *this->gconsump.get(currentStep); std::shared_ptr new_gconsump(new GConSump(current)); for( const auto& record : keyword ) { @@ -1653,7 +1654,9 @@ namespace { if (!network_node.defaultApplied(0)) network_node_name = network_node.getTrimmedString(0); - new_gconsump->add(groupName, consumption_rate, import_rate, network_node_name); + auto udqconfig = this->getUDQConfig(currentStep).params().undefinedValue(); + + new_gconsump->add(groupName, consumption_rate, import_rate, network_node_name, udqconfig, unit_system); } this->gconsump.update(currentStep, new_gconsump); }