From 10229cd53e4d39bacccd707f39bfe791bb443054 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 6 Sep 2017 12:47:10 +0200 Subject: [PATCH] Fix RPR summary output - weight RPR by hydrocarbon pore volume --- opm/output/eclipse/Summary.cpp | 23 +++++++++-- tests/summary_deck_non_constant_porosity.DATA | 16 +++----- tests/test_Summary.cpp | 38 +++++++++++++++++++ 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/opm/output/eclipse/Summary.cpp b/opm/output/eclipse/Summary.cpp index b7a342f..07d7e9c 100644 --- a/opm/output/eclipse/Summary.cpp +++ b/opm/output/eclipse/Summary.cpp @@ -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) { diff --git a/tests/summary_deck_non_constant_porosity.DATA b/tests/summary_deck_non_constant_porosity.DATA index 0ff0ed9..b013e3f 100644 --- a/tests/summary_deck_non_constant_porosity.DATA +++ b/tests/summary_deck_non_constant_porosity.DATA @@ -14,6 +14,9 @@ SUMMARYTESTS DIMENS 10 10 10 / +REGDIMS + 3 / + OIL GAS WATER @@ -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 diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index ea514cc..a3f4938 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -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); + } }