From 3e02a48c1048295df40d0d84f03092c6b2111c6e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 15 Oct 2020 09:10:39 +0200 Subject: [PATCH] Convert VFP dimensions without parsing dimension string --- .../EclipseState/Schedule/VFPProdTable.hpp | 2 + .../EclipseState/Schedule/VFPProdTable.cpp | 78 ++++++++++++------- 2 files changed, 50 insertions(+), 30 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp b/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp index f2976ebcd..0a03232d5 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp @@ -23,6 +23,7 @@ #include #include +#include namespace Opm { @@ -83,6 +84,7 @@ public: const std::vector& gfr_data, const std::vector& alq_data, const array_type& data); + static Dimension ALQDimension(const ALQ_TYPE& alq_type, const UnitSystem& unit_system); static VFPProdTable serializeObject(); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp index 96de3bf20..18c478cfd 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp @@ -450,13 +450,17 @@ void VFPProdTable::convertFloToSI(const FLO_TYPE& type, std::vector& values, const UnitSystem& unit_system) { double scaling_factor = 1.0; + const auto liquid_surface_volume = unit_system.getDimension(UnitSystem::measure::liquid_surface_volume).getSIScaling(); + const auto gas_surface_volume = unit_system.getDimension(UnitSystem::measure::gas_surface_volume).getSIScaling(); + const auto time = unit_system.getDimension(UnitSystem::measure::time).getSIScaling(); + switch (type) { case FLO_OIL: case FLO_LIQ: - scaling_factor = unit_system.parse("LiquidSurfaceVolume/Time").getSIScaling(); + scaling_factor = liquid_surface_volume / time; break; case FLO_GAS: - scaling_factor = unit_system.parse("GasSurfaceVolume/Time").getSIScaling(); + scaling_factor = gas_surface_volume / time; break; default: throw std::logic_error("Invalid FLO type"); @@ -472,7 +476,7 @@ void VFPProdTable::convertFloToSI(const FLO_TYPE& type, void VFPProdTable::convertTHPToSI(std::vector& values, const UnitSystem& unit_system) { - double scaling_factor = unit_system.parse("Pressure").getSIScaling(); + const auto scaling_factor = unit_system.getDimension(UnitSystem::measure::pressure).getSIScaling(); scaleValues(values, scaling_factor); } @@ -486,13 +490,14 @@ void VFPProdTable::convertWFRToSI(const WFR_TYPE& type, std::vector& values, const UnitSystem& unit_system) { double scaling_factor = 1.0; + const auto liquid_surface_volume = unit_system.getDimension(UnitSystem::measure::liquid_surface_volume).getSIScaling(); + const auto gas_surface_volume = unit_system.getDimension(UnitSystem::measure::gas_surface_volume).getSIScaling(); switch (type) { case WFR_WOR: case WFR_WCT: - scaling_factor = unit_system.parse("LiquidSurfaceVolume/LiquidSurfaceVolume").getSIScaling(); break; case WFR_WGR: - scaling_factor = unit_system.parse("LiquidSurfaceVolume/GasSurfaceVolume").getSIScaling(); + scaling_factor = liquid_surface_volume / gas_surface_volume; break; default: throw std::logic_error("Invalid FLO type"); @@ -510,13 +515,15 @@ void VFPProdTable::convertGFRToSI(const GFR_TYPE& type, std::vector& values, const UnitSystem& unit_system) { double scaling_factor = 1.0; + const auto liquid_surface_volume = unit_system.getDimension(UnitSystem::measure::liquid_surface_volume).getSIScaling(); + const auto gas_surface_volume = unit_system.getDimension(UnitSystem::measure::gas_surface_volume).getSIScaling(); switch (type) { case GFR_GOR: case GFR_GLR: - scaling_factor = unit_system.parse("GasSurfaceVolume/LiquidSurfaceVolume").getSIScaling(); + scaling_factor = gas_surface_volume / liquid_surface_volume; break; case GFR_OGR: - scaling_factor = unit_system.parse("LiquidSurfaceVolume/GasSurfaceVolume").getSIScaling(); + scaling_factor = liquid_surface_volume / gas_surface_volume; break; default: throw std::logic_error("Invalid FLO type"); @@ -525,32 +532,43 @@ void VFPProdTable::convertGFRToSI(const GFR_TYPE& type, } +Dimension VFPProdTable::ALQDimension(const ALQ_TYPE& alq_type, const UnitSystem& unit_system) { + double scaling_factor = 1.0; + const auto liquid_surface_volume = unit_system.getDimension(UnitSystem::measure::liquid_surface_volume).getSIScaling(); + const auto gas_surface_volume = unit_system.getDimension(UnitSystem::measure::gas_surface_volume).getSIScaling(); + const auto time = unit_system.getDimension(UnitSystem::measure::time).getSIScaling(); + + switch (alq_type) { + case ALQ_IGLR: + scaling_factor = gas_surface_volume / (liquid_surface_volume * time); + break; + case ALQ_TGLR: + scaling_factor = gas_surface_volume / liquid_surface_volume; + break; + case ALQ_GRAT: + scaling_factor = gas_surface_volume / time; + break; + case ALQ_UNDEF: + break; + case ALQ_PUMP: + case ALQ_COMP: + case ALQ_INVALID: + case ALQ_BEAN: + std::logic_error("scaling of the given ALQ type, not implemented "); + break; + default: + throw std::logic_error("Invalid ALQ type"); + } + + return Dimension(scaling_factor); +} + + void VFPProdTable::convertAlqToSI(const ALQ_TYPE& type, std::vector& values, const UnitSystem& unit_system) { - double scaling_factor = 1.0; - switch (type) { - case ALQ_IGLR: - scaling_factor = unit_system.parse("GasSurfaceVolume/LiquidSurfaceVolume*Time").getSIScaling(); - break; - case ALQ_TGLR: - scaling_factor = unit_system.parse("GasSurfaceVolume/LiquidSurfaceVolume").getSIScaling(); - break; - case ALQ_GRAT: - scaling_factor = unit_system.parse("GasSurfaceVolume/Time").getSIScaling(); - break; - case ALQ_UNDEF: - break; - case ALQ_PUMP: - case ALQ_COMP: - case ALQ_INVALID: - case ALQ_BEAN: - std::logic_error("scaling of the given ALQ type, not implemented "); - break; - default: - throw std::logic_error("Invalid ALQ type"); - } - scaleValues(values, scaling_factor); + const auto& dim = VFPProdTable::ALQDimension(type, unit_system); + scaleValues(values, dim.getSIScaling()); }