From c8343d95f68dece71de964996ee2f600a96489fa Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 15 Jan 2021 16:09:36 +0100 Subject: [PATCH] add support for DIFFC and DIFFUSE --- .../SimulationConfig/SimulationConfig.hpp | 3 ++ .../eclipse/EclipseState/Tables/FlatTable.hpp | 46 +++++++++++++++++++ .../EclipseState/Tables/TableManager.hpp | 3 ++ .../SimulationConfig/SimulationConfig.cpp | 18 ++++++-- .../EclipseState/Tables/TableManager.cpp | 11 +++++ .../eclipse/EclipseState/Tables/Tables.cpp | 1 + .../share/keywords/000_Eclipse100/D/DIFFC | 8 +++- tests/parser/TableManagerTests.cpp | 24 ++++++++++ 8 files changed, 108 insertions(+), 6 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp b/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp index ba926a772..99cc63cad 100644 --- a/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp +++ b/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp @@ -48,6 +48,7 @@ namespace Opm { bool hasDISGAS() const; bool hasVAPOIL() const; bool isThermal() const; + bool isDiffusive() const; bool operator==(const SimulationConfig& data) const; @@ -61,6 +62,7 @@ namespace Opm { serializer(m_DISGAS); serializer(m_VAPOIL); serializer(m_isThermal); + serializer(m_diffuse); } private: @@ -71,6 +73,7 @@ namespace Opm { bool m_DISGAS; bool m_VAPOIL; bool m_isThermal; + bool m_diffuse; }; } //namespace Opm diff --git a/opm/parser/eclipse/EclipseState/Tables/FlatTable.hpp b/opm/parser/eclipse/EclipseState/Tables/FlatTable.hpp index aa604b448..9eb8fd1c1 100644 --- a/opm/parser/eclipse/EclipseState/Tables/FlatTable.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/FlatTable.hpp @@ -51,6 +51,52 @@ struct DensityTable : public FlatTable< DENSITYRecord > { } }; +struct DiffCoeffRecord { + static constexpr std::size_t size = 8; + + double oil_mw; + double gas_mw; + double gas_in_gas; + double oil_in_gas; + double gas_in_oil; + double oil_in_oil; + double gas_in_oil_cross_phase; + double oil_in_oil_cross_phase; + + bool operator==(const DiffCoeffRecord& data) const { + return oil_mw == data.oil_mw && + gas_mw == data.gas_mw && + gas_in_gas == data.gas_in_gas && + oil_in_gas == data.oil_in_gas && + gas_in_oil == data.gas_in_oil && + oil_in_oil == data.oil_in_oil && + gas_in_oil_cross_phase == data.gas_in_oil_cross_phase && + oil_in_oil_cross_phase == data.oil_in_oil_cross_phase; + } + + template + void serializeOp(Serializer& serializer) + { + serializer(oil_mw); + serializer(gas_mw); + serializer(gas_in_gas); + serializer(oil_in_gas); + serializer(gas_in_oil); + serializer(oil_in_oil); + serializer(gas_in_oil_cross_phase); + serializer(oil_in_oil_cross_phase); + } +}; + +struct DiffCoeffTable : public FlatTable< DiffCoeffRecord > { + using FlatTable< DiffCoeffRecord >::FlatTable; + + static DiffCoeffTable serializeObject() + { + return DiffCoeffTable({{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}}); + } +}; + struct PVTWRecord { static constexpr std::size_t size = 5; diff --git a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp index f3944fa3a..61885f39a 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp @@ -162,6 +162,7 @@ namespace Opm { const PvcdoTable& getPvcdoTable() const; const DensityTable& getDensityTable() const; + const DiffCoeffTable& getDiffusionCoefficientTable() const; const PlyvmhTable& getPlyvmhTable() const; const RockTable& getRockTable() const; const ViscrefTable& getViscrefTable() const; @@ -215,6 +216,7 @@ namespace Opm { m_pvtwTable.serializeOp(serializer); m_pvcdoTable.serializeOp(serializer); m_densityTable.serializeOp(serializer); + m_diffCoeffTable.serializeOp(serializer); m_plyvmhTable.serializeOp(serializer); m_rockTable.serializeOp(serializer); m_plmixparTable.serializeOp(serializer); @@ -514,6 +516,7 @@ namespace Opm { PvtwTable m_pvtwTable; PvcdoTable m_pvcdoTable; DensityTable m_densityTable; + DiffCoeffTable m_diffCoeffTable; PlyvmhTable m_plyvmhTable; RockTable m_rockTable; PlmixparTable m_plmixparTable; diff --git a/src/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp b/src/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp index 2b7693cc1..f7d96701c 100644 --- a/src/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp +++ b/src/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp @@ -51,7 +51,8 @@ namespace Opm { m_useCPR(false), m_DISGAS(false), m_VAPOIL(false), - m_isThermal(false) + m_isThermal(false), + m_diffuse(false) { } @@ -64,7 +65,8 @@ namespace Opm { m_useCPR(false), m_DISGAS(false), m_VAPOIL(false), - m_isThermal(false) + m_isThermal(false), + m_diffuse(false) { if (DeckSection::hasRUNSPEC(deck)) { const RUNSPECSection runspec(deck); @@ -81,7 +83,9 @@ namespace Opm { if (runspec.hasKeyword()) { m_VAPOIL = true; } - + if (runspec.hasKeyword()) { + m_diffuse = true; + } this->m_isThermal = runspec.hasKeyword() || runspec.hasKeyword(); } @@ -97,6 +101,7 @@ namespace Opm { result.m_DISGAS = true; result.m_VAPOIL = false; result.m_isThermal = true; + result.m_diffuse = true; return result; } @@ -133,6 +138,10 @@ namespace Opm { return this->m_isThermal; } + bool SimulationConfig::isDiffusive() const { + return this->m_diffuse; + } + bool SimulationConfig::operator==(const SimulationConfig& data) const { return this->getThresholdPressure() == data.getThresholdPressure() && this->bcconfig() == data.bcconfig() && @@ -140,7 +149,8 @@ namespace Opm { this->useCPR() == data.useCPR() && this->hasDISGAS() == data.hasDISGAS() && this->hasVAPOIL() == data.hasVAPOIL() && - this->isThermal() == data.isThermal(); + this->isThermal() == data.isThermal() && + this->isDiffusive() == data.isDiffusive(); } } //namespace Opm diff --git a/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp b/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp index 4dc5e4b06..d3ca26454 100644 --- a/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp +++ b/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -150,6 +151,9 @@ namespace Opm { if( deck.hasKeyword( "DENSITY" ) ) this->m_densityTable = DensityTable( deck.getKeyword( "DENSITY" ) ); + if( deck.hasKeyword( "DIFFC" ) ) + this->m_diffCoeffTable = DiffCoeffTable( deck.getKeyword( "DIFFC" ) ); + if( deck.hasKeyword( "ROCK" ) ) this->m_rockTable = RockTable( deck.getKeyword( "ROCK" ) ); @@ -235,6 +239,7 @@ namespace Opm { m_pvcdoTable = data.m_pvcdoTable; m_plyvmhTable = data.m_plyvmhTable; m_densityTable = data.m_densityTable; + m_diffCoeffTable = data.m_diffCoeffTable; m_plmixparTable = data.m_plmixparTable; m_shrateTable = data.m_shrateTable; m_stone1exTable = data.m_stone1exTable; @@ -282,6 +287,7 @@ namespace Opm { result.m_pvtwTable = PvtwTable::serializeObject(); result.m_pvcdoTable = PvcdoTable::serializeObject(); result.m_densityTable = DensityTable::serializeObject(); + result.m_diffCoeffTable = DiffCoeffTable::serializeObject(); result.m_plyvmhTable = PlyvmhTable::serializeObject(); result.m_rockTable = RockTable::serializeObject(); result.m_plmixparTable = PlmixparTable::serializeObject(); @@ -1087,6 +1093,10 @@ namespace Opm { return this->m_densityTable; } + const DiffCoeffTable& TableManager::getDiffusionCoefficientTable() const { + return this->m_diffCoeffTable; + } + const RockTable& TableManager::getRockTable() const { return this->m_rockTable; } @@ -1222,6 +1232,7 @@ namespace Opm { m_pvtwTable == data.m_pvtwTable && m_pvcdoTable == data.m_pvcdoTable && m_densityTable == data.m_densityTable && + m_diffCoeffTable == data.m_diffCoeffTable && m_plmixparTable == data.m_plmixparTable && m_plyvmhTable == data.m_plyvmhTable && m_shrateTable == data.m_shrateTable && diff --git a/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp b/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp index 18be56772..57f3fae99 100644 --- a/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp +++ b/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp @@ -1526,6 +1526,7 @@ FlatTable< T >::FlatTable( const DeckKeyword& kw ) : {} template FlatTable< DENSITYRecord >::FlatTable( const DeckKeyword& ); +template FlatTable< DiffCoeffRecord >::FlatTable( const DeckKeyword& ); template FlatTable< PVTWRecord >::FlatTable( const DeckKeyword& ); template FlatTable< PVCDORecord >::FlatTable( const DeckKeyword& ); template FlatTable< ROCKRecord >::FlatTable( const DeckKeyword& ); diff --git a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/D/DIFFC b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/D/DIFFC index 5a70a8142..1ac7e5286 100644 --- a/src/opm/parser/eclipse/share/keywords/000_Eclipse100/D/DIFFC +++ b/src/opm/parser/eclipse/share/keywords/000_Eclipse100/D/DIFFC @@ -10,11 +10,13 @@ "items": [ { "name": "OIL_MOL_WEIGHT", - "value_type": "DOUBLE" + "value_type": "DOUBLE", + "dimension": "1" }, { "name": "GAS_MOL_WEIGHT", - "value_type": "DOUBLE" + "value_type": "DOUBLE", + "dimension": "1" }, { "name": "GAS_GAS_DIFF_COEFF", @@ -39,11 +41,13 @@ { "name": "GAS_OIL_CROSS_DIFF_COEFF", "value_type": "DOUBLE", + "default": 0.0, "dimension": "Length*Length/Time" }, { "name": "OIL_OIL_CROSS_DIFF_COEFF", "value_type": "DOUBLE", + "default": 0.0, "dimension": "Length*Length/Time" } ] diff --git a/tests/parser/TableManagerTests.cpp b/tests/parser/TableManagerTests.cpp index 978636457..bc9a7b465 100644 --- a/tests/parser/TableManagerTests.cpp +++ b/tests/parser/TableManagerTests.cpp @@ -1667,6 +1667,30 @@ BOOST_AUTO_TEST_CASE( TestParseDENSITY ) { BOOST_CHECK_EQUAL( 1.3, density[0].gas ); } +BOOST_AUTO_TEST_CASE( TestParseDIFFC ) { + const std::string data = R"( + TABDIMS + 1* 1 / + + DIFFC + 1.1 1.2 1.3 1.4 1.5 1.6 1* 1.8/ + )"; + + Opm::Parser parser; + auto deck = parser.parseString(data); + Opm::TableManager tables( deck ); + const auto& diffc = tables.getDiffusionCoefficientTable(); + double conversion_factor = (60*60*24); + BOOST_CHECK_EQUAL( 1.1, diffc[0].oil_mw ); + BOOST_CHECK_EQUAL( 1.2, diffc[0].gas_mw ); + BOOST_CHECK_CLOSE( 1.3, diffc[0].gas_in_gas*conversion_factor, epsilon()); + BOOST_CHECK_CLOSE( 1.4, diffc[0].oil_in_gas*conversion_factor, epsilon() ); + BOOST_CHECK_CLOSE( 1.5, diffc[0].gas_in_oil*conversion_factor, epsilon() ); + BOOST_CHECK_CLOSE( 1.6, diffc[0].oil_in_oil*conversion_factor, epsilon() ); + BOOST_CHECK_CLOSE( 0.0, diffc[0].gas_in_oil_cross_phase*conversion_factor, epsilon() ); + BOOST_CHECK_CLOSE( 1.8, diffc[0].oil_in_oil_cross_phase*conversion_factor, epsilon() ); +} + BOOST_AUTO_TEST_CASE( TestParseROCK ) { const std::string data = R"( TABDIMS