ACTIONX will handle WLIST well arguments

This commit is contained in:
Joakim Hove
2020-07-09 07:39:03 +02:00
parent f4f993586a
commit f500adba24
7 changed files with 97 additions and 31 deletions

View File

@@ -39,6 +39,8 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@@ -150,7 +152,8 @@ TSTEP
BOOST_AUTO_TEST_CASE(TestActions) {
Opm::SummaryState st(std::chrono::system_clock::now());
Opm::Action::Context context(st);
Opm::WListManager wlm;
Opm::Action::Context context(st, wlm);
Opm::Action::Actions config;
std::vector<std::string> matching_wells;
auto python = std::make_shared<Opm::Python>();
@@ -204,7 +207,8 @@ BOOST_AUTO_TEST_CASE(TestActions) {
BOOST_AUTO_TEST_CASE(TestContext) {
Opm::SummaryState st(std::chrono::system_clock::now());
st.update_well_var("OP1", "WOPR", 100);
Opm::Action::Context context(st);
Opm::WListManager wlm;
Opm::Action::Context context(st, wlm);
BOOST_REQUIRE_THROW(context.get("func", "arg"), std::out_of_range);
@@ -259,7 +263,8 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_BASIC) {
Action::AST ast2({"WWCT", "OPX", "=", "WWCT", "OPX"});
Action::AST ast3({"WWCT", "OPY", ">", "0.75"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
std::vector<std::string> matching_wells;
context.add("WWCT", "OPX", 100);
@@ -277,7 +282,8 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_OR_AND) {
Action::AST ast_and({"WWCT", "OPX", ">", "0.75", "AND", "WWCT", "OPY", ">", "0.75"});
Action::AST par({"WWCT", "OPX", ">", "0.75", "AND", "(", "WWCT", "OPY", ">", "0.75", "OR", "WWCT", "OPZ", ">", "0.75", ")"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("WWCT", "OPX", 100);
context.add("WWCT", "OPY", -100);
@@ -313,7 +319,8 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_OR_AND) {
BOOST_AUTO_TEST_CASE(DATE) {
Action::AST ast(std::vector<std::string>{"MNTH", ">=", "JUN"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("MNTH", 6);
BOOST_CHECK( ast.eval(context));
@@ -329,7 +336,8 @@ BOOST_AUTO_TEST_CASE(DATE) {
BOOST_AUTO_TEST_CASE(MANUAL1) {
Action::AST ast({"GGPR", "FIELD", ">", "50000", "AND", "WGOR", "PR", ">" ,"GGOR", "FIELD"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("GGPR", "FIELD", 60000 );
context.add("WGOR", "PR" , 300 );
@@ -350,7 +358,8 @@ BOOST_AUTO_TEST_CASE(MANUAL1) {
BOOST_AUTO_TEST_CASE(MANUAL2) {
Action::AST ast({"GWCT", "LIST1", ">", "0.70", "AND", "(", "GWPR", "LIST1", ">", "GWPR", "LIST2", "OR", "GWPR", "LIST1", ">", "GWPR", "LIST3", ")"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("GWCT", "LIST1", 1.0);
context.add("GWPR", "LIST1", 1 );
@@ -386,7 +395,8 @@ BOOST_AUTO_TEST_CASE(MANUAL2) {
BOOST_AUTO_TEST_CASE(MANUAL3) {
Action::AST ast({"MNTH", ".GE.", "MAR", "AND", "MNTH", ".LE.", "OCT", "AND", "GMWL", "HIGH", ".GE.", "4"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("MNTH", 4);
context.add("GMWL", "HIGH", 4);
@@ -409,7 +419,8 @@ BOOST_AUTO_TEST_CASE(MANUAL3) {
BOOST_AUTO_TEST_CASE(MANUAL4) {
Action::AST ast({"GWCT", "FIELD", ">", "0.8", "AND", "DAY", ">", "1", "AND", "MNTH", ">", "JUN", "AND", "YEAR", ">=", "2021"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("MNTH", 7);
context.add("DAY", 2);
@@ -429,7 +440,8 @@ BOOST_AUTO_TEST_CASE(MANUAL4) {
BOOST_AUTO_TEST_CASE(MANUAL5) {
Action::AST ast({"WCG2", "PROD1", ">", "WCG5", "PROD2", "AND", "GCG3", "G1", ">", "GCG7", "G2", "OR", "FCG1", ">", "FCG7"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("WCG2", "PROD1", 100);
context.add("WCG5", "PROD2", 50);
@@ -469,7 +481,8 @@ BOOST_AUTO_TEST_CASE(MANUAL5) {
BOOST_AUTO_TEST_CASE(LGR) {
Action::AST ast({"LWCC" , "OPX", "LOCAL", "1", "2", "3", ">", "100"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
context.add("LWCC", "OPX:LOCAL:1:2:3", 200);
BOOST_CHECK(ast.eval(context));
@@ -482,7 +495,8 @@ BOOST_AUTO_TEST_CASE(LGR) {
BOOST_AUTO_TEST_CASE(Action_ContextTest) {
SummaryState st(std::chrono::system_clock::now());
st.update("WWCT:OP1", 100);
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
BOOST_CHECK_EQUAL(context.get("WWCT", "OP1"), 100);
@@ -498,8 +512,8 @@ BOOST_AUTO_TEST_CASE(Action_ContextTest) {
BOOST_AUTO_TEST_CASE(TestGroupList) {
Action::AST ast({"GWPR", "*", ">", "1.0"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
BOOST_CHECK_THROW( ast.eval(context), std::logic_error );
}
@@ -511,7 +525,8 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells) {
st.update_well_var("OPY", "WOPR", 0.50);
st.update_well_var("OPZ", "WOPR", 2.0);
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
auto res = ast.eval(context);
auto wells = res.wells();
BOOST_CHECK( res);
@@ -520,6 +535,7 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells) {
BOOST_CHECK_EQUAL( wells[0], "OPZ" );
}
BOOST_AUTO_TEST_CASE(TestMatchingWells2) {
Action::AST ast1({"WOPR", "P*", ">", "1.0"});
Action::AST ast2({"WOPR", "*", ">", "1.0"});
@@ -533,7 +549,8 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells2) {
st.update_well_var("IY", "WOPR", 0.50);
st.update_well_var("IZ", "WOPR", 2.0);
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
auto res1 = ast1.eval(context);
auto res2 = ast2.eval(context);
auto wells1 = res1.wells();
@@ -562,7 +579,8 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_AND) {
st.update_well_var("OPY", "WWCT", 0.0); // The WWCT check matches this well.
st.update_well_var("OPZ", "WWCT", 1.0);
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
auto res = ast.eval(context);
BOOST_CHECK(res);
@@ -584,7 +602,8 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_OR) {
st.update_well_var("OPY", "WWCT", 0.0); // The WWCT check matches this well.
st.update_well_var("OPZ", "WWCT", 1.0);
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
auto res = ast.eval(context);
auto wells = res.wells();
BOOST_CHECK(res);
@@ -597,10 +616,38 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_OR) {
BOOST_CHECK( std::find(wells.begin(), wells.end(), "OPY") != wells.end());
}
BOOST_AUTO_TEST_CASE(TestWLIST) {
WListManager wlm;
Action::AST ast({"WOPR", "*LIST1", ">", "1.0"});
SummaryState st(std::chrono::system_clock::now());
st.update_well_var("W1", "WOPR", 2.0);
st.update_well_var("W2", "WOPR", 2.50);
st.update_well_var("W3", "WOPR", 2.0);
st.update_well_var("W4", "WOPR", 2.0);
st.update_well_var("W5", "WOPR", 2.0);
Action::Context context(st, wlm);
auto& wl = wlm.newList("*LIST1");
wl.add("W1");
wl.add("W3");
wl.add("W5");
auto res = ast.eval(context);
auto wells = res.wells();
BOOST_CHECK(res);
BOOST_CHECK_EQUAL( wells.size(), 3);
for (const auto& w : {"W1", "W3", "W5"}) {
auto find_iter = std::find(wells.begin(), wells.end(), w);
BOOST_CHECK( find_iter != wells.end() );
}
}
BOOST_AUTO_TEST_CASE(TestFieldAND) {
Action::AST ast({"FMWPR", ">=", "4", "AND", "WUPR3", "OP*", "=", "1"});
SummaryState st(std::chrono::system_clock::now());
Action::Context context(st);
WListManager wlm;
Action::Context context(st, wlm);
st.update_well_var("OP1", "WUPR3", 3);
st.update_well_var("OP2", "WUPR3", 2);