Skip to content

Commit

Permalink
Merge pull request #200 from totto82/RPR_fix
Browse files Browse the repository at this point in the history
Fix RPR summary output
  • Loading branch information
joakim-hove authored Sep 11, 2017
2 parents 3958efb + 10229cd commit 4bbf3d3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
23 changes: 19 additions & 4 deletions opm/output/eclipse/Summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,26 @@ quantity fpr( const fn_args& args ) {
}

quantity rpr(const fn_args& args) {
quantity p = region_sum( args , "PRESSURE" ,measure::pressure );

const auto& cells = args.regionCache.cells( args.num );
if (cells.size() > 0)
p /= cells.size();
return p;
if (cells.empty())
return { 0.0 , measure::pressure };

if( !args.state.has( "PRESSURE" ) )
return { 0.0, measure::pressure };

const auto& p = args.state.data( "PRESSURE" );
const auto& pv = args.pv;
const auto& sw = args.state.data( "SWAT" );

double rpr = 0.0;
double sum_hcpv = 0.0;
for (auto cell_index : cells) {
double hcpv = pv[cell_index]*(1.0 - sw[cell_index]);
rpr += hcpv * p[cell_index];
sum_hcpv += hcpv;
}
return { rpr / sum_hcpv, measure::pressure };
}

quantity roip(const fn_args& args) {
Expand Down
16 changes: 6 additions & 10 deletions tests/summary_deck_non_constant_porosity.DATA
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ SUMMARYTESTS
DIMENS
10 10 10 /

REGDIMS
3 /

OIL
GAS
WATER
Expand All @@ -38,16 +41,9 @@ PORO
REGIONS

FIPNUM
100*1
100*2
100*3
100*4
100*5
100*6
100*7
100*8
100*9
100*10 /
400*1
200*2
400*3 /


SUMMARY
Expand Down
38 changes: 38 additions & 0 deletions tests/test_Summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,46 @@ BOOST_AUTO_TEST_CASE(fpr) {
// fpr = sum_ (p * hcpv ) / hcpv, hcpv = pv * (1 - sw)
const double fpr2_si = ( (0.8 * 0.1 + 0.3 * 0.2) * 500 * 1 ) / ( (0.8 * 0.1 + 0.3 * 0.2) * 500);
BOOST_CHECK_CLOSE( fpr2_si, ecl_sum_get_field_var( resp2, 1, "FPR" ), 1e-5 ); //
}

BOOST_AUTO_TEST_CASE(rpr) {
setup cfg( "test_rpr", "summary_deck_non_constant_porosity.DATA");

{
out::Summary writer( cfg.es, cfg.config, cfg.grid, cfg.name );
writer.add_timestep( 1, 2 * day, cfg.es, cfg.wells, cfg.solution, {});
writer.add_timestep( 1, 5 * day, cfg.es, cfg.wells, cfg.solution, {});
writer.add_timestep( 2, 10 * day, cfg.es, cfg.wells, cfg.solution, {});
writer.write();
}

auto res = readsum( cfg.name );
const auto* resp = res.get();

BOOST_CHECK( ecl_sum_has_general_var( resp , "RPR:1"));
BOOST_CHECK( ecl_sum_has_general_var( resp , "RPR:3"));
BOOST_CHECK( !ecl_sum_has_general_var( resp , "RPR:4"));
UnitSystem units( UnitSystem::UnitType::UNIT_TYPE_METRIC );

// rpr = sum_ (p * hcpv ) / hcpv, hcpv = pv * (1 - sw)
// region 1; layer 1:4
{
const double rpr_si = ( 2.5 * 0.1 * 400 * (1 - 8.0) ) / ( (400*0.1) * (1 - 8.0));
std::string rpr_key = "RPR:1";
BOOST_CHECK_CLOSE( rpr_si , units.to_si( UnitSystem::measure::pressure , ecl_sum_get_general_var( resp, 1, rpr_key.c_str())) , 1e-5);
}
// region 2; layer 5:6
{
const double rpr_si = ( (5 * 0.1 + 6 * 0.2) * 100 * (1 - 8.0) ) / ( (0.1 + 0.2) * 100 * (1 - 8.0));
std::string rpr_key = "RPR:2";
BOOST_CHECK_CLOSE( rpr_si , units.to_si( UnitSystem::measure::pressure , ecl_sum_get_general_var( resp, 1, rpr_key.c_str())) , 1e-5);
}
// region 3; layer 7:10
{
const double rpr_si = ( 8.5 * 0.2 * 400 * (1 - 8.0) ) / ( (400*0.2) * (1 - 8.0));
std::string rpr_key = "RPR:3";
BOOST_CHECK_CLOSE( rpr_si , units.to_si( UnitSystem::measure::pressure , ecl_sum_get_general_var( resp, 1, rpr_key.c_str())) , 1e-5);
}

}

Expand Down

0 comments on commit 4bbf3d3

Please sign in to comment.