Add case with literal in scientific form

This commit is contained in:
Joakim Hove
2020-06-29 20:56:16 +02:00
parent f09b534e1d
commit 9fd29db2de
2 changed files with 29 additions and 17 deletions

View File

@@ -150,6 +150,7 @@ UDQDefine::UDQDefine(const UDQParams& udq_params,
if (tokens[0] == "-")
tokens.insert( tokens.begin(), "0" );
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(udq_params, this->m_var_type, this->m_keyword, tokens, parseContext, errors) );
this->string_data = "";
for (std::size_t index = 0; index < deck_data.size(); index++) {

View File

@@ -40,6 +40,24 @@ Copyright 2018 Statoil ASA.
using namespace Opm;
Schedule make_schedule(const std::string& input) {
Parser parser;
auto python = std::make_shared<Python>();
auto deck = parser.parseString(input);
if (deck.hasKeyword("DIMENS")) {
EclipseState es(deck);
return Schedule(deck, es, python);
} else {
EclipseGrid grid(10,10,10);
TableManager table ( deck );
FieldPropsManager fp( deck, Phases{true, true, true}, grid, table);
Runspec runspec (deck);
return Schedule(deck, grid , fp, runspec, python);
}
}
BOOST_AUTO_TEST_CASE(TYPE_COERCION) {
BOOST_CHECK( UDQVarType::SCALAR == UDQ::coerce(UDQVarType::SCALAR, UDQVarType::SCALAR) );
@@ -139,23 +157,6 @@ BOOST_AUTO_TEST_CASE(TEST)
BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", {"BPR", "1","1", "1", "*", "2.0"}), std::logic_error);
}
Schedule make_schedule(const std::string& input) {
Parser parser;
auto python = std::make_shared<Python>();
auto deck = parser.parseString(input);
if (deck.hasKeyword("DIMENS")) {
EclipseState es(deck);
return Schedule(deck, es, python);
} else {
EclipseGrid grid(10,10,10);
TableManager table ( deck );
FieldPropsManager fp( deck, Phases{true, true, true}, grid, table);
Runspec runspec (deck);
return Schedule(deck, grid , fp, runspec, python);
}
}
BOOST_AUTO_TEST_CASE(MIX_SCALAR) {
UDQFunctionTable udqft;
@@ -1647,6 +1648,7 @@ SCHEDULE
UDQ
DEFINE FUMIN0 - 1.5*FWPR /
DEFINE FUMIN1 - 1.5*FWPR*(FGPR + FOPR)^3 - 2*FLPR /
DEFINE FU -2.539E-14 * (FUP1+FUP2)^3 + 1.4464E-8 *(FUP1+FUP2)^2 +0.00028875*(FUP1+FUP2)+2.8541 /
/
)";
@@ -1655,6 +1657,7 @@ UDQ
UDQParams udqp;
auto def0 = udq.definitions()[0];
auto def1 = udq.definitions()[1];
auto def2 = udq.definitions()[2];
SummaryState st(std::chrono::system_clock::now());
UDQFunctionTable udqft(udqp);
UDQContext context(udqft, st);
@@ -1662,14 +1665,22 @@ UDQ
const double fopr = 4;
const double fgpr = 7;
const double flpr = 13;
const double fup1 = 1025;
const double fup2 = 107;
st.update("FWPR", fwpr);
st.update("FOPR", fopr);
st.update("FGPR", fgpr);
st.update("FLPR", flpr);
st.update("FUP1", fup1);
st.update("FUP2", fup2);
auto res0 = def0.eval(context);
BOOST_CHECK_EQUAL( res0[0].value(), -1.5*fwpr);
auto res1 = def1.eval(context);
BOOST_CHECK_EQUAL( res1[0].value(), -1.5*fwpr*std::pow(fgpr+fopr, 3) - 2*flpr );
auto res2 = def2.eval(context);
BOOST_CHECK_CLOSE( res2[0].value(), -2.5394E-14 * std::pow(fup1 + fup2, 3) + 1.4464E-8*std::pow(fup1 + fup2, 2) + 0.00028875*(fup1 + fup2) + 2.8541, 1e-6);
}