diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 9f20e0ebe..492a82d74 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -159,6 +159,7 @@ namespace Opm void handleMESSAGES(const DeckKeyword& keyword, size_t currentStep); void checkUnhandledKeywords( const SCHEDULESection& ) const; + void checkIfAllConnectionsIsShut(size_t currentStep); static double convertInjectionRateToSI(double rawRate, WellInjector::TypeEnum wellType, const Opm::UnitSystem &unitSystem); static double convertInjectionRateToSI(double rawRate, Phase wellPhase, const Opm::UnitSystem &unitSystem); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 21acf25cb..ca3b315ff 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -136,11 +136,15 @@ namespace Opm { for (size_t keywordIdx = 0; keywordIdx < section.size(); ++keywordIdx) { const auto& keyword = section.getKeyword(keywordIdx); - if (keyword.name() == "DATES") + if (keyword.name() == "DATES") { + checkIfAllConnectionsIsShut(currentStep); currentStep += keyword.size(); + } - else if (keyword.name() == "TSTEP") + else if (keyword.name() == "TSTEP") { + checkIfAllConnectionsIsShut(currentStep); currentStep += keyword.getRecord(0).getItem(0).size(); // This is a bit weird API. + } else if (keyword.name() == "WELSPECS") handleWELSPECS( section, keywordIdx, currentStep ); @@ -240,6 +244,8 @@ namespace Opm { } } } + checkIfAllConnectionsIsShut(currentStep); + for (auto rftPair = rftProperties.begin(); rftPair != rftProperties.end(); ++rftPair) { const DeckKeyword& keyword = *rftPair->first; @@ -787,7 +793,6 @@ namespace Opm { }; constexpr auto open = WellCommon::StatusEnum::OPEN; - constexpr auto shut = WellCommon::StatusEnum::SHUT; for( const auto& record : keyword ) { const auto& wellname = record.getItem( "WELL" ).getTrimmedString(0); @@ -856,9 +861,6 @@ namespace Opm { well->addCompletionSet( currentStep, new_completions ); m_events.addEvent( ScheduleEvents::COMPLETION_CHANGE, currentStep ); - - if( new_completions.allCompletionsShut() ) - this->updateWellStatus( *well, currentStep, shut ); } } } @@ -1622,4 +1624,12 @@ namespace Opm { return false; } + + void Schedule::checkIfAllConnectionsIsShut(size_t timestep) { + for( auto& well : this->m_wells ) { + const auto& completions = well.getCompletions(timestep); + if( completions.allCompletionsShut() ) + this->updateWellStatus( well, timestep, WellCommon::StatusEnum::SHUT); + } + } } diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index e88592de3..6f9f39f37 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -658,6 +658,72 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_TryToOpenWellWithShutCompleti BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep)); } +BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_CombineShutCompletionsAndAddNewCompletionsDoNotShutWell) { + Opm::Parser parser; + std::string input = + "START -- 0 \n" + "1 NOV 1979 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 1 DES 1979/ \n" + "/\n" + "WELSPECS\n" + " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + "/\n" + "COMPDAT\n" + " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "DATES -- 2\n" + " 10 JUL 2008 / \n" + "/\n" + "WELOPEN\n" + " 'OP_1' OPEN / \n" + "/\n" + "DATES -- 3\n" + " 10 OKT 2008 / \n" + "/\n" + "WELOPEN\n" + " 'OP_1' SHUT 0 0 0 0 0 / \n " + "/\n" + "COMPDAT\n" + " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "DATES -- 4\n" + " 10 NOV 2008 / \n" + "/\n" + "WELOPEN\n" + " 'OP_1' SHUT 0 0 0 0 0 / \n " + "/\n" + "DATES -- 5\n" + " 11 NOV 2008 / \n" + "/\n" + "COMPDAT\n" + " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "DATES -- 6\n" + " 12 NOV 2008 / \n" + "/\n"; + + EclipseGrid grid(10,10,10); + ParseContext parseContext; + auto deck = parser.parseString(input, parseContext); + TableManager table ( deck ); + Eclipse3DProperties eclipseProperties ( deck , table, grid); + Schedule schedule(parseContext , grid , eclipseProperties, deck, Phases(true, true, true) ); + auto* well = schedule.getWell("OP_1"); + // timestep 3. Close all completions with WELOPEN and immediately open new completions with COMPDAT. + BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, well->getStatus(3)); + BOOST_CHECK( !well->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 3 )); + // timestep 4. Close all completions with WELOPEN. The well will be shut since no completions + // are open. + BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(4)); + BOOST_CHECK( well->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 4 )); + // timestep 5. Open new completions. But keep the well shut, + BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(5)); +} + BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFT) { Opm::Parser parser; std::string input = diff --git a/tests/parser/integration/ScheduleCreateFromDeck.cpp b/tests/parser/integration/ScheduleCreateFromDeck.cpp index 3ef1b20da..9c8a40f11 100644 --- a/tests/parser/integration/ScheduleCreateFromDeck.cpp +++ b/tests/parser/integration/ScheduleCreateFromDeck.cpp @@ -910,7 +910,7 @@ BOOST_AUTO_TEST_CASE(TestWellEvents) { BOOST_CHECK( w1->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 1 )); BOOST_CHECK( w1->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 3 )); BOOST_CHECK( w1->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 4 )); - BOOST_CHECK( w1->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 5 )); + BOOST_CHECK( !w1->hasEvent( ScheduleEvents::WELL_STATUS_CHANGE , 5 )); BOOST_CHECK( w1->hasEvent( ScheduleEvents::COMPLETION_CHANGE , 0 )); BOOST_CHECK( w1->hasEvent( ScheduleEvents::COMPLETION_CHANGE , 5 ));