Fixed bug in summary output of completion rates.

This commit is contained in:
Joakim Hove 2016-10-25 16:25:46 +02:00
parent 08d89858af
commit 2def85a70c
3 changed files with 13 additions and 14 deletions

View File

@ -143,7 +143,7 @@ struct fn_args {
const data::Wells& wells;
const data::Solution& state;
const out::RegionCache& regionCache;
const GridDims& grid;
const EclipseGrid& grid;
};
/* Since there are several enums in opm scattered about more-or-less
@ -183,19 +183,22 @@ inline quantity rate( const fn_args& args ) {
template< rt phase, bool injection = true >
inline quantity crate( const fn_args& args ) {
const quantity zero = { 0, rate_unit< phase >() };
const size_t index = args.num;
// The args.num value is the literal value which will go to the
// NUMS array in the eclispe SMSPEC file; the values in this array
// are offset 1 - whereas we need to use this index here to look
// up a completion with offset 0.
const auto global_index = args.num - 1;
const auto active_index = args.grid.activeIndex( global_index );
if( args.schedule_wells.empty() ) return zero;
const auto& name = args.schedule_wells.front()->name();
if( args.wells.count( name ) == 0 ) return zero;
const auto& well = args.wells.at( name );
const auto& completion = std::find_if( well.completions.begin(),
well.completions.end(),
[=]( const data::Completion& c ) {
return c.index == index;
return c.index == active_index;
} );
if( completion == well.completions.end() ) return zero;

View File

@ -501,10 +501,10 @@ WELSPECS
COMPDAT
-- 'Well' I J K1 K2
-- Passing 0 to I/J means they'll get the well head I/J
W_1 0 0 1 1 /
W_2 0 0 1 1 /
W_2 1 1 1 1 /
W_3 0 0 1 1 /
W_1 0 0 1 1 / -- Active index: 0
W_2 0 0 1 1 / -- Active index: 1
W_2 0 0 2 2 / -- Active index: 101
W_3 0 0 1 1 / -- Active index: 2
/
WCONHIST

View File

@ -478,11 +478,7 @@ BOOST_AUTO_TEST_CASE(completion_kewords) {
/* Solvent flow rate + or - Note OPM uses negative values for producers, while CNFR outputs positive
values for producers*/
BOOST_CHECK_CLOSE( -300.3, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CNFR", 3 ), 1e-5 );
BOOST_CHECK_CLOSE( 200.3, ecl_sum_get_well_completion_var( resp, 1, "W_2", "CNFR", 1 ), 1e-5 );
/* CGPT's wildcarding means W_2's completions should also be available */
BOOST_CHECK_CLOSE( 200.2, ecl_sum_get_well_completion_var( resp, 1, "W_2", "CGPT", 1 ), 1e-5 );
BOOST_CHECK_CLOSE( 2 * 200.2, ecl_sum_get_well_completion_var( resp, 2, "W_2", "CGPT", 1 ), 1e-5 );
BOOST_CHECK_CLOSE( 200.3, ecl_sum_get_well_completion_var( resp, 1, "W_2", "CNFR", 2 ), 1e-5 );
}
BOOST_AUTO_TEST_CASE(field_keywords) {