mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
Extracts unit system from VFP data file
Modifies the VFP table extraction process to retrieve the unit system defined in the data file. Convert ALQ values from SI to raw values
This commit is contained in:
1 parent
0d738013c4
commit
acb582ab07
5 files changed
+93
-43
No files matched your search
@@ -49,7 +49,7 @@ namespace RiaOpmParserTools
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Opm::VFPInjTable createInjectionTable( const Opm::DeckKeyword& keyword )
|
||||
std::pair<Opm::UnitSystem, Opm::VFPInjTable> createInjectionTable( const Opm::DeckKeyword& keyword )
|
||||
{
|
||||
Opm::UnitSystem unitSystem;
|
||||
{
|
||||
@@ -63,13 +63,13 @@ Opm::VFPInjTable createInjectionTable( const Opm::DeckKeyword& keyword )
|
||||
}
|
||||
}
|
||||
|
||||
return { keyword, unitSystem };
|
||||
return { unitSystem, { keyword, unitSystem } };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword )
|
||||
std::pair<Opm::UnitSystem, Opm::VFPProdTable> createProductionTable( const Opm::DeckKeyword& keyword )
|
||||
{
|
||||
Opm::UnitSystem unitSystem;
|
||||
{
|
||||
@@ -85,19 +85,23 @@ Opm::VFPProdTable createProductionTable( const Opm::DeckKeyword& keyword )
|
||||
|
||||
bool gaslift_opt_active = false;
|
||||
|
||||
return { keyword, gaslift_opt_active, unitSystem };
|
||||
return { unitSystem, { keyword, gaslift_opt_active, unitSystem } };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>> extractVfpTablesFromDataFile( const std::string& dataDeckFilename )
|
||||
std::tuple<Opm::UnitSystem, std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>>
|
||||
extractVfpTablesFromDataFile( const std::string& dataDeckFilename )
|
||||
{
|
||||
if ( !std::filesystem::exists( dataDeckFilename ) ) return {};
|
||||
if ( !std::filesystem::exists( dataDeckFilename ) )
|
||||
return std::tuple<Opm::UnitSystem, std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>>{};
|
||||
|
||||
std::vector<Opm::VFPProdTable> prodTables;
|
||||
std::vector<Opm::VFPInjTable> injTables;
|
||||
|
||||
std::optional<Opm::UnitSystem> unitSystemFromTables;
|
||||
|
||||
try
|
||||
{
|
||||
// The parser is not robust when looking for a small number of keywords. Several keywords is added as parsing error occurs.
|
||||
@@ -126,9 +130,15 @@ std::pair<std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>> extract
|
||||
{
|
||||
std::string prodKeyword = "VFPPROD";
|
||||
auto keywordList = deck.getKeywordList( prodKeyword );
|
||||
|
||||
for ( auto kw : keywordList )
|
||||
{
|
||||
auto table = createProductionTable( *kw );
|
||||
const auto& [tableUnitSystem, table] = createProductionTable( *kw );
|
||||
|
||||
if ( !unitSystemFromTables )
|
||||
{
|
||||
unitSystemFromTables = tableUnitSystem;
|
||||
}
|
||||
prodTables.push_back( table );
|
||||
}
|
||||
}
|
||||
@@ -137,7 +147,12 @@ std::pair<std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>> extract
|
||||
auto keywordList = deck.getKeywordList( injKeyword );
|
||||
for ( auto kw : keywordList )
|
||||
{
|
||||
auto table = createInjectionTable( *kw );
|
||||
const auto& [tableUnitSystem, table] = createInjectionTable( *kw );
|
||||
|
||||
if ( !unitSystemFromTables )
|
||||
{
|
||||
unitSystemFromTables = tableUnitSystem;
|
||||
}
|
||||
injTables.push_back( table );
|
||||
}
|
||||
}
|
||||
@@ -158,7 +173,13 @@ std::pair<std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>> extract
|
||||
RiaLogging::warning( text );
|
||||
}
|
||||
|
||||
return { prodTables, injTables };
|
||||
Opm::UnitSystem unitSystemValue;
|
||||
if ( unitSystemFromTables )
|
||||
{
|
||||
unitSystemValue = *unitSystemFromTables;
|
||||
}
|
||||
|
||||
return std::tuple<Opm::UnitSystem, std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>>{ unitSystemValue, prodTables, injTables };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
namespace RiaOpmParserTools
|
||||
{
|
||||
|
||||
std::pair<std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>> extractVfpTablesFromDataFile( const std::string& dataDeckFilename );
|
||||
std::tuple<Opm::UnitSystem, std::vector<Opm::VFPProdTable>, std::vector<Opm::VFPInjTable>>
|
||||
extractVfpTablesFromDataFile( const std::string& dataDeckFilename );
|
||||
|
||||
std::map<std::string, std::vector<std::pair<int, int>>> extractWseglink( const std::string& filename );
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "RimVfpTable.h"
|
||||
|
||||
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
@@ -74,7 +76,11 @@ void RimVfpTableData::ensureDataIsImported()
|
||||
|
||||
m_vfpTables = std::make_unique<RigVfpTables>();
|
||||
|
||||
const auto [vfpProdTables, vfpInjTables] = RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() );
|
||||
const auto& [unitSystem, vfpProdTables, vfpInjTables] =
|
||||
RiaOpmParserTools::extractVfpTablesFromDataFile( m_filePath().path().toStdString() );
|
||||
|
||||
m_vfpTables->setUnitSystem( unitSystem );
|
||||
|
||||
for ( const auto& prod : vfpProdTables )
|
||||
{
|
||||
m_vfpTables->addProductionTable( prod );
|
||||
|
||||
@@ -81,7 +81,7 @@ VfpPlotData RigVfpTables::populatePlotData( const Opm::VFPProdTable&
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpTableSelection& tableSelection )
|
||||
const VfpTableSelection& tableSelection ) const
|
||||
{
|
||||
VfpPlotData plotData;
|
||||
|
||||
@@ -206,7 +206,7 @@ VfpPlotData RigVfpTables::populatePlotData( const Opm::VFPProdTable&
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpValueSelection& valueSelection )
|
||||
const VfpValueSelection& valueSelection ) const
|
||||
{
|
||||
VfpPlotData plotData;
|
||||
|
||||
@@ -528,7 +528,7 @@ QString RigVfpTables::textForPlotData( const VfpPlotData& plotData )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RigVfpTables::getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType )
|
||||
std::vector<double> RigVfpTables::getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ) const
|
||||
{
|
||||
std::vector<double> xVals;
|
||||
if ( variableType == RimVfpDefines::ProductionVariableType::WATER_CUT )
|
||||
@@ -542,13 +542,23 @@ std::vector<double> RigVfpTables::getProductionTableData( const Opm::VFPProdTabl
|
||||
else if ( variableType == RimVfpDefines::ProductionVariableType::ARTIFICIAL_LIFT_QUANTITY )
|
||||
{
|
||||
xVals = table.getALQAxis();
|
||||
|
||||
// Convert ALQ values to raw values. No conversion of this data type is done in convertToDisplayUnit. As convertToDisplayUnit is a
|
||||
// static function, it will require a lot of refactoring to get the unit system information communicated to this function.
|
||||
auto alq_dim = table.ALQDimension( table.getALQType(), m_unitSystem );
|
||||
for ( double& value : xVals )
|
||||
{
|
||||
value = alq_dim.convertSiToRaw( value );
|
||||
}
|
||||
}
|
||||
else if ( variableType == RimVfpDefines::ProductionVariableType::FLOW_RATE )
|
||||
{
|
||||
// Values are converted in convertToDisplayUnit
|
||||
xVals = table.getFloAxis();
|
||||
}
|
||||
else if ( variableType == RimVfpDefines::ProductionVariableType::THP )
|
||||
{
|
||||
// Values are converted in convertToDisplayUnit
|
||||
xVals = table.getTHPAxis();
|
||||
}
|
||||
|
||||
@@ -578,7 +588,7 @@ size_t RigVfpTables::getVariableIndex( const Opm::VFPProdTable& tab
|
||||
size_t primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
size_t familyValue,
|
||||
const VfpTableSelection& tableSelection )
|
||||
const VfpTableSelection& tableSelection ) const
|
||||
{
|
||||
if ( targetVariable == primaryVariable ) return primaryValue;
|
||||
if ( targetVariable == familyVariable ) return familyValue;
|
||||
@@ -601,7 +611,7 @@ size_t RigVfpTables::getVariableIndexForValue( const Opm::VFPProdTable&
|
||||
double primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
double familyValue,
|
||||
const VfpValueSelection& valueSelection )
|
||||
const VfpValueSelection& valueSelection ) const
|
||||
{
|
||||
auto findClosestIndex = []( const std::vector<double>& values, const double value )
|
||||
{
|
||||
@@ -780,6 +790,14 @@ RimVfpDefines::FlowingGasFractionType RigVfpTables::getFlowingGasFractionType( c
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigVfpTables::setUnitSystem( const Opm::UnitSystem& unitSystem )
|
||||
{
|
||||
m_unitSystem = unitSystem;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "VerticalFlowPerformance/RimVfpDefines.h"
|
||||
|
||||
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
@@ -100,6 +102,7 @@ struct VfpTableInitialData
|
||||
class RigVfpTables
|
||||
{
|
||||
public:
|
||||
void setUnitSystem( const Opm::UnitSystem& unitSystem );
|
||||
void addInjectionTable( const Opm::VFPInjTable& table );
|
||||
void addProductionTable( const Opm::VFPProdTable& table );
|
||||
|
||||
@@ -140,19 +143,19 @@ private:
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase );
|
||||
|
||||
static VfpPlotData populatePlotData( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpTableSelection& tableSelection );
|
||||
VfpPlotData populatePlotData( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpTableSelection& tableSelection ) const;
|
||||
|
||||
static VfpPlotData populatePlotData( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpValueSelection& valueSelection );
|
||||
VfpPlotData populatePlotData( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
RimVfpDefines::InterpolatedVariableType interpolatedVariable,
|
||||
RimVfpDefines::FlowingPhaseType flowingPhase,
|
||||
const VfpValueSelection& valueSelection ) const;
|
||||
|
||||
static QString axisTitle( RimVfpDefines::ProductionVariableType variableType, RimVfpDefines::FlowingPhaseType flowingPhase );
|
||||
static QString getDisplayUnit( RimVfpDefines::ProductionVariableType variableType );
|
||||
@@ -163,22 +166,22 @@ private:
|
||||
|
||||
static QString textForPlotData( const VfpPlotData& plotData );
|
||||
|
||||
static std::vector<double> getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType );
|
||||
static size_t getVariableIndex( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType targetVariable,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
size_t primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
size_t familyValue,
|
||||
const VfpTableSelection& tableSelection );
|
||||
std::vector<double> getProductionTableData( const Opm::VFPProdTable& table, RimVfpDefines::ProductionVariableType variableType ) const;
|
||||
size_t getVariableIndex( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType targetVariable,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
size_t primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
size_t familyValue,
|
||||
const VfpTableSelection& tableSelection ) const;
|
||||
|
||||
static size_t getVariableIndexForValue( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType targetVariable,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
double primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
double familyValue,
|
||||
const VfpValueSelection& valueSelection );
|
||||
size_t getVariableIndexForValue( const Opm::VFPProdTable& table,
|
||||
RimVfpDefines::ProductionVariableType targetVariable,
|
||||
RimVfpDefines::ProductionVariableType primaryVariable,
|
||||
double primaryValue,
|
||||
RimVfpDefines::ProductionVariableType familyVariable,
|
||||
double familyValue,
|
||||
const VfpValueSelection& valueSelection ) const;
|
||||
|
||||
std::optional<Opm::VFPInjTable> injectionTable( int tableNumber ) const;
|
||||
std::optional<Opm::VFPProdTable> productionTable( int tableNumber ) const;
|
||||
@@ -194,4 +197,5 @@ private:
|
||||
private:
|
||||
std::vector<Opm::VFPInjTable> m_injectionTables;
|
||||
std::vector<Opm::VFPProdTable> m_productionTables;
|
||||
Opm::UnitSystem m_unitSystem;
|
||||
};
|
||||
Reference in new issue
Block a user