UDQ ASSIGN keywords will appear in Summary output

This commit is contained in:
Joakim Hove
2019-02-21 10:44:47 +01:00
parent 6bf64b18fe
commit 010dd03c6d
3 changed files with 86 additions and 3 deletions

View File

@@ -1119,8 +1119,22 @@ bool is_udq(const std::string& keyword) {
return (keyword.size() > 1 && keyword[1] == 'U');
}
void eval_udq(const UDQInput& udq, const UDQContext& context, SummaryState& st)
void eval_udq(const Schedule& schedule, std::size_t sim_step, SummaryState& st)
{
const UDQInput& udq = schedule.getUDQConfig(sim_step);
std::vector<std::string> wells;
for (const auto* well : schedule.getWells())
wells.push_back(well->name());
for (const auto& assign : udq.assignments(UDQVarType::WELL_VAR)) {
auto ws = assign.eval_wells(wells);
for (const auto& well : wells) {
const auto& udq_value = ws[well];
if (udq_value)
st.add_well_var(well, ws.name(), udq_value.value());
}
}
}
@@ -1489,8 +1503,7 @@ void Summary::add_timestep( int report_step,
{
UDQContext udq_context(st);
const UDQInput& udq = schedule.getUDQConfig(sim_step);
eval_udq(udq, udq_context, st);
eval_udq(schedule, sim_step, st);
}
{
const ecl_sum_type * ecl_sum = this->ecl_sum.get();

View File

@@ -60,6 +60,9 @@ WELLDIMS
UNIFOUT
UDQDIMS
50 25 0 50 50 0 0 50 0 20 /
GRID
-- The INIT keyword is used to request an .INIT file. The .INIT file
@@ -347,6 +350,10 @@ WWPR
/
WWPT
/
WUBHP
/
WUOPR
/
SCHEDULE
-- -------------------------------------------------------------------------
RPTSCHED
@@ -355,6 +362,17 @@ RPTSCHED
RPTRST
'BASIC=1' /
UDQ
ASSIGN WUBHP 11 /
ASSIGN WUOPR 20 /
ASSIGN WUBHP P2 12 /
ASSIGN WUBHP P3 13 /
ASSIGN WUBHP P4 14 /
UNITS WUBHP 'BARSA' /
UNITS WUOPR 'SM3/DAY' /
/
-- If no resolution (i.e. case 1), the two following lines must be added:
DRSDT

View File

@@ -25,6 +25,8 @@
#include <boost/test/unit_test.hpp>
#include <ert/util/test_work_area.h>
#include <ert/ecl/ecl_sum.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
@@ -58,9 +60,12 @@ struct test_data {
schedule( this->deck, this->state.getInputGrid(), this->state.get3DProperties(), this->state.runspec()),
summary_config( this->deck, this->schedule, this->state.getTableManager())
{
auto& ioconfig = this->state.getIOConfig();
ioconfig.setBaseName("MSIM");
}
};
double prod_opr(const EclipseState& es, const Schedule& sched, const data::Solution& sol, size_t report_step, double seconds_elapsed) {
const auto& units = es.getUnits();
double oil_rate = 1.0;
@@ -149,6 +154,53 @@ BOOST_AUTO_TEST_CASE(WELL_CLOSE_EXAMPLE) {
test_work_area_free(work_area);
}
}
BOOST_AUTO_TEST_CASE(UDQ_ASSIGN) {
#include "actionx1.include"
test_data td( actionx1 );
msim sim(td.state);
{
test_work_area_type * work_area = test_work_area_alloc("test_msim");
EclipseIO io(td.state, td.state.getInputGrid(), td.schedule, td.summary_config);
sim.well_rate("P1", data::Rates::opt::oil, prod_opr);
sim.well_rate("P2", data::Rates::opt::oil, prod_opr);
sim.well_rate("P3", data::Rates::opt::oil, prod_opr);
sim.well_rate("P4", data::Rates::opt::oil, prod_opr);
sim.well_rate("P1", data::Rates::opt::wat, prod_wpr_P1);
sim.well_rate("P2", data::Rates::opt::wat, prod_wpr_P2);
sim.well_rate("P3", data::Rates::opt::wat, prod_wpr_P3);
sim.well_rate("P4", data::Rates::opt::wat, prod_wpr_P4);
sim.run(td.schedule, io);
const auto& base_name = td.state.getIOConfig().getBaseName();
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( base_name.c_str(), ":");
BOOST_CHECK( ecl_sum_has_general_var(ecl_sum, "WUBHP:P1") );
BOOST_CHECK( ecl_sum_has_general_var(ecl_sum, "WUBHP:P2") );
BOOST_CHECK( ecl_sum_has_general_var(ecl_sum, "WUOPR:P3") );
BOOST_CHECK( ecl_sum_has_general_var(ecl_sum, "WUOPR:P4") );
BOOST_CHECK_EQUAL( ecl_sum_get_unit(ecl_sum, "WUBHP:P1"), "BARSA");
BOOST_CHECK_EQUAL( ecl_sum_get_unit(ecl_sum, "WUOPR:P1"), "SM3/DAY");
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUBHP:P1"), 11);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUBHP:P2"), 12);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUBHP:P3"), 13);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUBHP:P4"), 14);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUOPR:P1"), 20);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUOPR:P2"), 20);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUOPR:P3"), 20);
BOOST_CHECK_EQUAL( ecl_sum_get_general_var(ecl_sum, 1, "WUOPR:P4"), 20);
ecl_sum_free( ecl_sum );
test_work_area_free(work_area);
}
}