From 9956ef1dfc0ed55133e8f77a2ab6c98d47bc4c7c Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Mon, 30 Oct 2023 23:15:56 +0100 Subject: [PATCH 1/5] Facilitate using network node pressures from restart --- opm/input/eclipse/EclipseState/EclipseState.hpp | 7 +++++++ opm/io/eclipse/rst/network.hpp | 3 +++ src/opm/input/eclipse/EclipseState/EclipseState.cpp | 11 +++++++++++ src/opm/io/eclipse/rst/network.cpp | 1 + 4 files changed, 22 insertions(+) diff --git a/opm/input/eclipse/EclipseState/EclipseState.hpp b/opm/input/eclipse/EclipseState/EclipseState.hpp index c6c6d883e..df65e77a5 100644 --- a/opm/input/eclipse/EclipseState/EclipseState.hpp +++ b/opm/input/eclipse/EclipseState/EclipseState.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ namespace Opm { namespace Opm { namespace RestartIO { class RstAquifer; + class RstNetwork; }} // namespace Opm::RestartIO namespace Opm { @@ -124,6 +126,9 @@ namespace Opm { // When we know and decide to handle the same for AQUFETP and AQUCT, this part will be refactored void appendAqufluxSchedule(const std::unordered_set& ids); + void loadRestartNetworkPressures(const RestartIO::RstNetwork& network); + const std::optional >& getRestartNetworkPressures() const { return this->m_restart_network_pressures; } + template void serializeOp(Serializer& serializer) { @@ -183,6 +188,8 @@ namespace Opm { std::string m_title{}; FaultCollection m_faults{}; + + std::optional > m_restart_network_pressures{std::nullopt}; }; } // namespace Opm diff --git a/opm/io/eclipse/rst/network.hpp b/opm/io/eclipse/rst/network.hpp index ef961bf2d..4ead39641 100644 --- a/opm/io/eclipse/rst/network.hpp +++ b/opm/io/eclipse/rst/network.hpp @@ -68,6 +68,9 @@ namespace Opm { namespace RestartIO { /// Whether or not to include lift gas of subordinate wells as /// part of the produced gas entering the network at this node. bool add_lift_gas{false}; + + /// Node pressure + double pressure{}; }; explicit RstNetwork(std::shared_ptr rstView, diff --git a/src/opm/input/eclipse/EclipseState/EclipseState.cpp b/src/opm/input/eclipse/EclipseState/EclipseState.cpp index ba277b04a..ac9e3a3a6 100644 --- a/src/opm/input/eclipse/EclipseState/EclipseState.cpp +++ b/src/opm/input/eclipse/EclipseState/EclipseState.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -315,6 +316,16 @@ namespace Opm { this->aquifer_config.appendAqufluxSchedule(ids); } + void EclipseState::loadRestartNetworkPressures(const RestartIO::RstNetwork& network) { + if (!network.isActive()) return; + + this->m_restart_network_pressures = std::map{}; + auto& node_pressures = this->m_restart_network_pressures.value(); + for (const auto& node : network.nodes()) { + node_pressures[node.name] = node.pressure; + } + } + void EclipseState::assignRunTitle(const Deck& deck) { if (! deck.hasKeyword()) { diff --git a/src/opm/io/eclipse/rst/network.cpp b/src/opm/io/eclipse/rst/network.cpp index 34faf807b..552ad02ba 100644 --- a/src/opm/io/eclipse/rst/network.cpp +++ b/src/opm/io/eclipse/rst/network.cpp @@ -193,6 +193,7 @@ namespace { usys.to_si(Opm::UnitSystem::measure::pressure, rnode[VI::RNode::index::PressureLimit]); } + node.pressure = rnode[VI::RNode::index::NodePres]; return node; } From a47aee1af5f434a842b77d33a0cd2c0bd26e597b Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Mon, 13 Nov 2023 23:25:12 +0100 Subject: [PATCH 2/5] Resolved test failures (with and without network defined). --- src/opm/input/eclipse/Schedule/Group/Group.cpp | 2 +- src/opm/io/eclipse/rst/netbalan.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/opm/input/eclipse/Schedule/Group/Group.cpp b/src/opm/input/eclipse/Schedule/Group/Group.cpp index 88292893f..52f2cee24 100644 --- a/src/opm/input/eclipse/Schedule/Group/Group.cpp +++ b/src/opm/input/eclipse/Schedule/Group/Group.cpp @@ -223,7 +223,7 @@ Group::Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, const auto gas_inj_limits = GasInjectionLimits { rst_group }; const auto water_inj_limits = WaterInjectionLimits{ rst_group }; - if ((rst_group.prod_cmode != 0) || has_active(prod_limits)) { + if ((rst_group.prod_cmode != 0) || rst_group.exceed_action >0 || has_active(prod_limits)) { this->updateProduction(make_production_properties(rst_group, prod_limits, unit_system_arg)); } diff --git a/src/opm/io/eclipse/rst/netbalan.cpp b/src/opm/io/eclipse/rst/netbalan.cpp index 927651add..c01698b26 100644 --- a/src/opm/io/eclipse/rst/netbalan.cpp +++ b/src/opm/io/eclipse/rst/netbalan.cpp @@ -63,8 +63,7 @@ namespace { double thpToleranceValue(const std::vector& doubhead, const Opm::UnitSystem& usys) { - return usys.to_si(Opm::UnitSystem::measure::pressure, - doubhead[VI::doubhead::Netbalthpc]); + return doubhead[VI::doubhead::Netbalthpc]; } bool is_finite_float(const double x) From 3d8b7e863e6251bb0a5506b1d20a36d43cd4f4e5 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Tue, 14 Nov 2023 13:34:39 +0100 Subject: [PATCH 3/5] Avoid unused paramter --- src/opm/io/eclipse/rst/netbalan.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/opm/io/eclipse/rst/netbalan.cpp b/src/opm/io/eclipse/rst/netbalan.cpp index c01698b26..f3ab40514 100644 --- a/src/opm/io/eclipse/rst/netbalan.cpp +++ b/src/opm/io/eclipse/rst/netbalan.cpp @@ -60,8 +60,7 @@ namespace { doubhead[VI::doubhead::Netbalnpre]); } - double thpToleranceValue(const std::vector& doubhead, - const Opm::UnitSystem& usys) + double thpToleranceValue(const std::vector& doubhead) { return doubhead[VI::doubhead::Netbalthpc]; } @@ -111,7 +110,7 @@ Opm::RestartIO::RstNetbalan::RstNetbalan(const std::vector& intehead, : calc_interval_ (calcInterval(doubhead, usys)) , ptol_ (pressureToleranceValue(doubhead, usys)) , pressure_max_iter_ (maxBalanceIter(intehead)) - , thp_tolerance_ (thpToleranceValue(doubhead, usys)) + , thp_tolerance_ (thpToleranceValue(doubhead)) , thp_max_iter_ (maxTHPIter(intehead)) , target_branch_balance_error_(targetBranchBalanceError(doubhead, usys)) , max_branch_balance_error_ (maxBranchBalanceError(doubhead, usys)) From 87bdf6381cd7b3d8a695436451d3c7be6d52e16b Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Tue, 14 Nov 2023 15:15:00 +0100 Subject: [PATCH 4/5] Apply unit conversion --- src/opm/io/eclipse/rst/network.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opm/io/eclipse/rst/network.cpp b/src/opm/io/eclipse/rst/network.cpp index 552ad02ba..19ce855e7 100644 --- a/src/opm/io/eclipse/rst/network.cpp +++ b/src/opm/io/eclipse/rst/network.cpp @@ -193,7 +193,8 @@ namespace { usys.to_si(Opm::UnitSystem::measure::pressure, rnode[VI::RNode::index::PressureLimit]); } - node.pressure = rnode[VI::RNode::index::NodePres]; + node.pressure = usys.to_si(Opm::UnitSystem::measure::pressure, + rnode[VI::RNode::index::NodePres]); return node; } From 1d8c5640a2df8f63f8c28da6eb09951ddcb77590 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Tue, 14 Nov 2023 18:05:40 +0100 Subject: [PATCH 5/5] Resolve test failures --- tests/test_rst_netbalan.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_rst_netbalan.cpp b/tests/test_rst_netbalan.cpp index 2c23c9495..0f4336ab1 100644 --- a/tests/test_rst_netbalan.cpp +++ b/tests/test_rst_netbalan.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(No_Active_Network) BOOST_CHECK_CLOSE(netbalan.interval(), 0.0, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressureTolerance(), 0.0*Opm::unit::barsa, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressureMaxIter(), std::size_t{0}); - BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 0.01*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 0.01, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thpMaxIter(), std::size_t{10}); BOOST_CHECK_MESSAGE(! netbalan.targetBalanceError().has_value(), @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(Norne) BOOST_CHECK_CLOSE(netbalan.interval(), 0.0, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressureTolerance(), 0.2*Opm::unit::barsa, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressureMaxIter(), std::size_t{0}); - BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 0.01*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 0.01, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thpMaxIter(), std::size_t{10}); BOOST_CHECK_MESSAGE(! netbalan.targetBalanceError().has_value(), @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(Iota) BOOST_CHECK_CLOSE(netbalan.interval(), 1.0*Opm::unit::day, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressureTolerance(), 2.0*Opm::unit::barsa, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressureMaxIter(), std::size_t{3}); - BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 4.0*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thpTolerance(), 4.0, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thpMaxIter(), std::size_t{5}); BOOST_CHECK_MESSAGE(netbalan.targetBalanceError().has_value(), @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(No_Active_Network) BOOST_CHECK_CLOSE(netbalan.interval(), 0.0, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressure_tolerance(), 0.0, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressure_max_iter(), std::size_t{0}); - BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 0.01*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 0.01, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thp_max_iter(), std::size_t{10}); BOOST_CHECK_MESSAGE(! netbalan.target_balance_error().has_value(), @@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(Norne) BOOST_CHECK_CLOSE(netbalan.interval(), 0.0, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressure_tolerance(), 0.2*Opm::unit::barsa, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressure_max_iter(), std::size_t{0}); - BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 0.01*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 0.01, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thp_max_iter(), std::size_t{10}); BOOST_CHECK_MESSAGE(! netbalan.target_balance_error().has_value(), @@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(Iota) BOOST_CHECK_CLOSE(netbalan.interval(), 1.0*Opm::unit::day, 1.0e-7); BOOST_CHECK_CLOSE(netbalan.pressure_tolerance(), 2.0*Opm::unit::barsa, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.pressure_max_iter(), std::size_t{3}); - BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 4.0*Opm::unit::barsa, 1.0e-7); + BOOST_CHECK_CLOSE(netbalan.thp_tolerance(), 4.0, 1.0e-7); BOOST_CHECK_EQUAL(netbalan.thp_max_iter(), std::size_t{5}); BOOST_CHECK_MESSAGE(netbalan.target_balance_error().has_value(),