From c659c080cb295ec7b1425ab8d15093ff2cd16ca8 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 22 Oct 2014 12:20:16 +0200 Subject: [PATCH 1/3] Fix SHUT wells Shut wells are not added to the well list and thus not considered in the simulator. The shut well test in test_wellsmanager is modified to assert this behaviour. BUG: This change provokes an assert in the EclipeWriter as number of wells in wellstate is different from number of wells in the schedule. --- opm/core/wells/WellsManager.cpp | 2 +- opm/core/wells/WellsManager_impl.hpp | 5 +++++ tests/test_wellsmanager.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index aa9ff929..7a59f094 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -412,7 +412,7 @@ namespace Opm } if (well->getStatus(timeStep) == WellCommon::SHUT) { - well_controls_shut_well( w_->ctrls[well_index] ); + //well_controls_shut_well( w_->ctrls[well_index] ); well_index++; continue; } diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index d2453a87..cc317428 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -127,6 +127,11 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t int well_index = 0; for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { WellConstPtr well = (*wellIter); + + if (well->getStatus(timeStep) == WellCommon::SHUT) { + continue; + } + { // WELSPECS handling well_names_to_index[well->name()] = well_index; well_names.push_back(well->name()); diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 9b0a8718..a6b1b58e 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -275,7 +275,12 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); Opm::GridManager gridManager(deck); - BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); + Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL); + + // Shut wells are removed from the deck. i.e number of wells should be 2-1 + BOOST_CHECK( wellsManager2.c_wells()->number_of_wells == 1); + + //BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); } From 2ff42c327b9b03d5adc3d5a615764920b334fdaa Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 24 Oct 2014 07:01:36 +0200 Subject: [PATCH 2/3] SHUT wells returns 0 Shut wells returns 0 for bhp and rates in the EclipseWriter --- opm/core/io/eclipse/EclipseWriter.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/opm/core/io/eclipse/EclipseWriter.cpp b/opm/core/io/eclipse/EclipseWriter.cpp index 93f17ff5..874c2548 100644 --- a/opm/core/io/eclipse/EclipseWriter.cpp +++ b/opm/core/io/eclipse/EclipseWriter.cpp @@ -655,7 +655,7 @@ public: "SM3/DAY" /* surf. cub. m. per day */) { } - virtual double retrieveValue(const SimulatorTimer& /*timer*/, + virtual double retrieveValue(const SimulatorTimer& timer, const WellState& wellState, const std::map& wellNameToIdxMap) { @@ -666,6 +666,11 @@ public: return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } + // TODO: Why only positive rates? using namespace Opm::unit; return convert::to(std::max(0., rate(wellState)), @@ -705,6 +710,11 @@ public: return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } + // find the index for the quantity in the wellState this->updateTimeStepWellIndex_(wellNameToIdxMap); if (this->flatIdx_ < 0) { @@ -748,7 +758,7 @@ public: "Pascal") { } - virtual double retrieveValue(const SimulatorTimer& /*timer*/, + virtual double retrieveValue(const SimulatorTimer& timer, const WellState& wellState, const std::map& wellNameToIdxMap) { @@ -758,6 +768,10 @@ public: // well not active in current time step return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } return bhp(wellState); } From 2b1dc85804a9b182fee61077326c58ecf10bd116 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 24 Oct 2014 07:05:43 +0200 Subject: [PATCH 3/3] Make the comment in test_wellsmanager more precise The comment now precisly says that Shut wells are not added instead to the well list instead of removed. --- tests/test_wellsmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index a6b1b58e..70cc0c23 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL); - // Shut wells are removed from the deck. i.e number of wells should be 2-1 + // Shut wells are not added to the deck. i.e number of wells should be 2-1 BOOST_CHECK( wellsManager2.c_wells()->number_of_wells == 1); //BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL));