Changes to contribute to write segment data to summary file
This commit is contained in:
committed by
Bård Skaflestad
parent
80154e8f5f
commit
fe060c7f48
@@ -125,7 +125,7 @@ namespace Opm {
|
||||
struct Segment {
|
||||
Rates rates;
|
||||
double pressure;
|
||||
std::size_t segIndex;
|
||||
std::size_t segNumber;
|
||||
|
||||
template <class MessageBufferType>
|
||||
void write(MessageBufferType& buffer) const;
|
||||
@@ -317,7 +317,7 @@ namespace Opm {
|
||||
|
||||
template <class MessageBufferType>
|
||||
void Segment::write(MessageBufferType& buffer) const {
|
||||
buffer.write(this->segIndex);
|
||||
buffer.write(this->segNumber);
|
||||
this->rates.write(buffer);
|
||||
buffer.write(this->pressure);
|
||||
}
|
||||
@@ -375,7 +375,7 @@ namespace Opm {
|
||||
|
||||
template <class MessageBufferType>
|
||||
void Segment::read(MessageBufferType& buffer) {
|
||||
buffer.read(this->segIndex);
|
||||
buffer.read(this->segNumber);
|
||||
this->rates.read(buffer);
|
||||
buffer.read(this->pressure);
|
||||
}
|
||||
@@ -412,9 +412,9 @@ namespace Opm {
|
||||
|
||||
seg.read(buffer);
|
||||
|
||||
const auto segIndex = seg.segIndex;
|
||||
const auto segNumber = seg.segNumber;
|
||||
|
||||
this->segments.emplace(segIndex, std::move(seg));
|
||||
this->segments.emplace(segNumber, std::move(seg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <numeric>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
@@ -363,6 +364,39 @@ inline quantity crate( const fn_args& args ) {
|
||||
return { v, rate_unit< phase >() };
|
||||
}
|
||||
|
||||
template< rt phase, bool polymer = false >
|
||||
inline quantity srate( const fn_args& args ) {
|
||||
const quantity zero = { 0, rate_unit< phase >() };
|
||||
// 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 size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well->name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
double eff_fac = efac( args.eff_factors, name );
|
||||
double concentration = polymer
|
||||
? well->getPolymerProperties( args.sim_step ).m_polymerConcentration
|
||||
: 1;
|
||||
|
||||
auto v = segment->second.rates.get( phase, 0.0 ) * eff_fac * concentration;
|
||||
//switch sign of rate - opposite convention in flow vs eclipse
|
||||
v *= -1;
|
||||
|
||||
if( polymer ) return { v, measure::mass_rate };
|
||||
return { v, rate_unit< phase >() };
|
||||
}
|
||||
|
||||
inline quantity trans_factors ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::transmissibility };
|
||||
|
||||
@@ -391,6 +425,31 @@ inline quantity trans_factors ( const fn_args& args ) {
|
||||
return { v, measure::transmissibility };
|
||||
}
|
||||
|
||||
inline quantity spr ( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
// Like completion rate we need to look
|
||||
// up a connection with offset 0.
|
||||
const size_t segNumber = args.num;
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
|
||||
const auto& well = args.schedule_wells.front();
|
||||
const auto& name = well->name();
|
||||
if( args.wells.count( name ) == 0 ) return zero;
|
||||
|
||||
const auto& well_data = args.wells.at( name );
|
||||
|
||||
const auto& segment = well_data.segments.find(segNumber);
|
||||
|
||||
if( segment == well_data.segments.end() ) return zero;
|
||||
|
||||
|
||||
const auto& v = segment->second.pressure;
|
||||
return { v, measure::pressure };
|
||||
}
|
||||
|
||||
|
||||
inline quantity bhp( const fn_args& args ) {
|
||||
const quantity zero = { 0, measure::pressure };
|
||||
if( args.schedule_wells.empty() ) return zero;
|
||||
@@ -835,6 +894,11 @@ static const std::unordered_map< std::string, ofun > funs = {
|
||||
{ "ROPT" , mul( region_rate< rt::oil, producer >, duration ) },
|
||||
{ "RGPT" , mul( region_rate< rt::gas, producer >, duration ) },
|
||||
{ "RWPT" , mul( region_rate< rt::wat, producer >, duration ) },
|
||||
//Multisegment well segment data
|
||||
{ "SOFR", srate< rt::oil > },
|
||||
{ "SWFR", srate< rt::wat > },
|
||||
{ "SGFR", srate< rt::gas > },
|
||||
{ "SPR", spr },
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ static data::Wells result_wells() {
|
||||
segment.rates.set(rt::oil, 543.21*sm3_pr_day);
|
||||
segment.rates.set(rt::gas, 1729.496*sm3_pr_day);
|
||||
segment.pressure = 314.159*unit::barsa;
|
||||
segment.segIndex = 1;
|
||||
segment.segNumber = 1;
|
||||
|
||||
/*
|
||||
The global index assigned to the completion must be manually
|
||||
@@ -170,7 +170,7 @@ static data::Wells result_wells() {
|
||||
data::Well well1 {
|
||||
rates1, 0.1 * ps, 0.2 * ps, 0.3 * ps, 1,
|
||||
{ {well1_comp1} },
|
||||
{ { segment.segIndex, segment } },
|
||||
{ { segment.segNumber, segment } },
|
||||
};
|
||||
data::Well well2 { rates2, 1.1 * ps, 1.2 * ps, 1.3 * ps, 2, { {well2_comp1 , well2_comp2} } };
|
||||
data::Well well3 { rates3, 2.1 * ps, 2.2 * ps, 2.3 * ps, 3, { {well3_comp1} } };
|
||||
@@ -1202,7 +1202,7 @@ BOOST_AUTO_TEST_CASE(READ_WRITE_WELLDATA) {
|
||||
BOOST_CHECK_CLOSE(seg.rates.get(rt::oil), 543.21*sm3_pr_day, 1.0e-10);
|
||||
BOOST_CHECK_CLOSE(seg.rates.get(rt::gas), 1729.496*sm3_pr_day, 1.0e-10);
|
||||
BOOST_CHECK_CLOSE(seg.pressure, 314.159*unit::barsa, 1.0e-10);
|
||||
BOOST_CHECK_EQUAL(seg.segIndex, 1);
|
||||
BOOST_CHECK_EQUAL(seg.segNumber, 1);
|
||||
|
||||
// No data for segment 10 of well W_2 (or no such segment).
|
||||
const auto& W2 = wellRatesCopy.at("W_2");
|
||||
|
||||
Reference in New Issue
Block a user