From b3dc1ea5ca1e6a8f4362c6dc760ae953a77ea783 Mon Sep 17 00:00:00 2001 From: Kristian Flikka Date: Fri, 21 Feb 2014 12:48:36 +0100 Subject: [PATCH] Added rest of WGRUPCON handlingin Well and Schedule --- .../EclipseState/Schedule/Schedule.cpp | 10 +++++ .../EclipseState/Schedule/ScheduleEnums.cpp | 4 ++ .../EclipseState/Schedule/ScheduleEnums.hpp | 3 +- .../eclipse/EclipseState/Schedule/Well.cpp | 19 ++++++++ .../eclipse/EclipseState/Schedule/Well.hpp | 7 +++ .../Schedule/tests/ScheduleEnumTests.cpp | 5 +++ .../EclipseState/Schedule/tests/WellTests.cpp | 45 +++++++++++++++++++ .../ScheduleCreateFromDeck.cpp | 9 +++- .../SCHEDULE/SCHEDULE_WGRUPCON | 2 +- 9 files changed, 101 insertions(+), 3 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index df4571476..d5cc41801 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -401,6 +401,16 @@ namespace Opm { well->setAvailableForGroupControl(currentStep, availableForGroupControl); well->setGuideRate(currentStep, record->getItem("GUIDE_RATE")->getRawDouble(0)); + + if (record->getItem("PHASE")->defaultApplied()) { + well->setGuideRatePhase(currentStep, GuideRate::UNDEFINED); + } + else { + std::string guideRatePhase = record->getItem("PHASE")->getString(0); + well->setGuideRatePhase(currentStep, GuideRate::GuideRatePhaseEnumFromString(guideRatePhase)); + } + + well->setGuideRateScalingFactor(currentStep, record->getItem("SCALING_FACTOR")->getRawDouble(0)); } } diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp index dba64d8f4..ea839d447 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp @@ -388,6 +388,8 @@ namespace Opm { return "RAT"; case RES: return "RES"; + case UNDEFINED: + return "UNDEFINED"; default: throw std::invalid_argument("unhandled enum value"); } @@ -412,6 +414,8 @@ namespace Opm { return RAT; else if (stringValue == "RES") return RES; + else if (stringValue == "UNDEFINED") + return UNDEFINED; else throw std::invalid_argument("Unknown enum state string: " + stringValue ); } diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp index 989be8056..721b00c2b 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp @@ -176,7 +176,8 @@ namespace Opm { WGA = 5, CVAL = 6, RAT = 7, - RES = 8 + RES = 8, + UNDEFINED = 9 }; const std::string GuideRatePhaseEnum2String( GuideRatePhaseEnum enumValue ); GuideRatePhaseEnum GuideRatePhaseEnumFromString( const std::string& stringValue ); diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index 5b9aedf4d..584e1dbef 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -47,6 +47,8 @@ namespace Opm { m_isProducer(new DynamicState(timeMap, true)), m_isAvailableForGroupControl(new DynamicState(timeMap, true)), m_guideRate(new DynamicState(timeMap, -1.0)), + m_guideRatePhase(new DynamicState(timeMap, GuideRate::UNDEFINED)), + m_guideRateScalingFactor(new DynamicState(timeMap, 1.0)), m_completions( new DynamicState( timeMap , CompletionSetConstPtr( new CompletionSet()) )), m_groupName( new DynamicState( timeMap , "" )), m_headI(headI), @@ -224,6 +226,23 @@ namespace Opm { m_guideRate->add(timeStep, guideRate); } + GuideRate::GuideRatePhaseEnum Well::getGuideRatePhase(size_t timeStep) const { + return m_guideRatePhase->get(timeStep); + } + + void Well::setGuideRatePhase(size_t timeStep, GuideRate::GuideRatePhaseEnum phase) { + m_guideRatePhase->add(timeStep, phase); + } + + double Well::getGuideRateScalingFactor(size_t timeStep) const { + return m_guideRateScalingFactor->get(timeStep); + } + + void Well::setGuideRateScalingFactor(size_t timeStep, double scalingFactor) { + m_guideRateScalingFactor->add(timeStep, scalingFactor); + } + + void Well::switch2Producer(size_t timeStep ) { m_isProducer->add(timeStep , true); m_surfaceInjectionRate->add(timeStep, 0); diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index eff43b6c7..59cce8e33 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -87,6 +88,10 @@ namespace Opm { void setAvailableForGroupControl(size_t timeStep, bool isAvailableForGroupControl); double getGuideRate(size_t timeStep) const; void setGuideRate(size_t timeStep, double guideRate); + GuideRate::GuideRatePhaseEnum getGuideRatePhase(size_t timeStep) const; + void setGuideRatePhase(size_t timeStep, GuideRate::GuideRatePhaseEnum phase); + double getGuideRateScalingFactor(size_t timeStep) const; + void setGuideRateScalingFactor(size_t timeStep, double scalingFactor); void addWELSPECS(DeckRecordConstPtr deckRecord); void addCompletions(size_t time_step , const std::vector& newCompletions); @@ -122,6 +127,8 @@ namespace Opm { std::shared_ptr > m_isProducer; std::shared_ptr > m_isAvailableForGroupControl; std::shared_ptr > m_guideRate; + std::shared_ptr > m_guideRatePhase; + std::shared_ptr > m_guideRateScalingFactor; std::shared_ptr > m_completions; std::shared_ptr > m_groupName; diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleEnumTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleEnumTests.cpp index 3b181fb39..91ad46a53 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleEnumTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleEnumTests.cpp @@ -388,6 +388,7 @@ BOOST_AUTO_TEST_CASE(GuideRatePhaseEnum2String) { BOOST_CHECK_EQUAL( "CVAL" , GuideRate::GuideRatePhaseEnum2String(GuideRate::CVAL)); BOOST_CHECK_EQUAL( "RAT" , GuideRate::GuideRatePhaseEnum2String(GuideRate::RAT)); BOOST_CHECK_EQUAL( "RES" , GuideRate::GuideRatePhaseEnum2String(GuideRate::RES)); + BOOST_CHECK_EQUAL( "UNDEFINED" , GuideRate::GuideRatePhaseEnum2String(GuideRate::UNDEFINED)); } @@ -402,6 +403,7 @@ BOOST_AUTO_TEST_CASE(GuideRatePhaseEnumFromString) { BOOST_CHECK_EQUAL( GuideRate::CVAL , GuideRate::GuideRatePhaseEnumFromString("CVAL")); BOOST_CHECK_EQUAL( GuideRate::RAT , GuideRate::GuideRatePhaseEnumFromString("RAT")); BOOST_CHECK_EQUAL( GuideRate::RES , GuideRate::GuideRatePhaseEnumFromString("RES")); + BOOST_CHECK_EQUAL( GuideRate::UNDEFINED, GuideRate::GuideRatePhaseEnumFromString("UNDEFINED")); } @@ -416,6 +418,7 @@ BOOST_AUTO_TEST_CASE(GuideRatePhaseEnum2Loop) { BOOST_CHECK_EQUAL( GuideRate::CVAL , GuideRate::GuideRatePhaseEnumFromString( GuideRate::GuideRatePhaseEnum2String( GuideRate::CVAL ) )); BOOST_CHECK_EQUAL( GuideRate::RAT , GuideRate::GuideRatePhaseEnumFromString( GuideRate::GuideRatePhaseEnum2String( GuideRate::RAT ) )); BOOST_CHECK_EQUAL( GuideRate::RES , GuideRate::GuideRatePhaseEnumFromString( GuideRate::GuideRatePhaseEnum2String( GuideRate::RES ) )); + BOOST_CHECK_EQUAL( GuideRate::UNDEFINED , GuideRate::GuideRatePhaseEnumFromString( GuideRate::GuideRatePhaseEnum2String( GuideRate::UNDEFINED ) )); BOOST_CHECK_EQUAL( "OIL" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "OIL" ) )); BOOST_CHECK_EQUAL( "WAT" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "WAT" ) )); @@ -426,4 +429,6 @@ BOOST_AUTO_TEST_CASE(GuideRatePhaseEnum2Loop) { BOOST_CHECK_EQUAL( "CVAL" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "CVAL" ) )); BOOST_CHECK_EQUAL( "RAT" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "RAT" ) )); BOOST_CHECK_EQUAL( "RES" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "RES" ) )); + BOOST_CHECK_EQUAL( "UNDEFINED" , GuideRate::GuideRatePhaseEnum2String(GuideRate::GuideRatePhaseEnumFromString( "UNDEFINED" ) )); + } diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index 0f4f5aa54..9fbacad8a 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -379,3 +379,48 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { BOOST_CHECK( well.hasInjectionControl( 11 , Opm::WellInjector::THP )); BOOST_CHECK( well.hasInjectionControl( 11 , Opm::WellInjector::BHP )); } + +/*********************************************************************/ + + +BOOST_AUTO_TEST_CASE(WellSetAvailableForGroupControl_ControlSet) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); + Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); + + BOOST_CHECK(well.isAvailableForGroupControl(10)); + well.setAvailableForGroupControl(12, false); + BOOST_CHECK(!well.isAvailableForGroupControl(13)); + well.setAvailableForGroupControl(15, true); + BOOST_CHECK(well.isAvailableForGroupControl(15)); +} + +BOOST_AUTO_TEST_CASE(WellSetGuideRate_GuideRateSet) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); + Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); + + BOOST_CHECK_LT(well.getGuideRate(0), 0); + well.setGuideRate(1, 32.2); + BOOST_CHECK_LT(well.getGuideRate(0), 0); + BOOST_CHECK_EQUAL(32.2, well.getGuideRate(1)); +} + +BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); + Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); + BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase(0)); + well.setGuideRatePhase(3, Opm::GuideRate::RAT); + BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase(2)); + BOOST_CHECK_EQUAL(Opm::GuideRate::RAT, well.getGuideRatePhase(3)); +} + + +BOOST_AUTO_TEST_CASE(WellSetScalingFactor_ScalingFactorSetSet) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); + Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); + BOOST_CHECK_EQUAL(1.0, well.getGuideRateScalingFactor(0)); + well.setGuideRateScalingFactor(4, 0.6); + BOOST_CHECK_EQUAL(1.0, well.getGuideRateScalingFactor(3)); + BOOST_CHECK_EQUAL(0.6, well.getGuideRateScalingFactor(4)); +} + + diff --git a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp index 41657b5cf..20b5178ff 100644 --- a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp +++ b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -469,13 +470,19 @@ BOOST_AUTO_TEST_CASE(WellTestWGRUPCONWellPropertiesSet) { WellConstPtr well1 = sched->getWell("W_1"); BOOST_CHECK(well1->isAvailableForGroupControl(0)); BOOST_CHECK_EQUAL(-1, well1->getGuideRate(0)); + BOOST_CHECK_EQUAL(GuideRate::OIL, well1->getGuideRatePhase(0)); + BOOST_CHECK_EQUAL(1.0, well1->getGuideRateScalingFactor(0)); WellConstPtr well2 = sched->getWell("W_2"); BOOST_CHECK(!well2->isAvailableForGroupControl(0)); - + BOOST_CHECK_EQUAL(-1, well2->getGuideRate(0)); + BOOST_CHECK_EQUAL(GuideRate::UNDEFINED, well2->getGuideRatePhase(0)); + BOOST_CHECK_EQUAL(1.0, well2->getGuideRateScalingFactor(0)); WellConstPtr well3 = sched->getWell("W_3"); BOOST_CHECK(well3->isAvailableForGroupControl(0)); BOOST_CHECK_EQUAL(100, well3->getGuideRate(0)); + BOOST_CHECK_EQUAL(GuideRate::RAT, well3->getGuideRatePhase(0)); + BOOST_CHECK_EQUAL(0.5, well3->getGuideRateScalingFactor(0)); } diff --git a/testdata/integration_tests/SCHEDULE/SCHEDULE_WGRUPCON b/testdata/integration_tests/SCHEDULE/SCHEDULE_WGRUPCON index 18b32f085..4f90149ed 100644 --- a/testdata/integration_tests/SCHEDULE/SCHEDULE_WGRUPCON +++ b/testdata/integration_tests/SCHEDULE/SCHEDULE_WGRUPCON @@ -14,7 +14,7 @@ WELSPECS WGRUPCON 'W_1' 2* OIL / 'W_2' NO / - 'W_3' YES 100 RATE / + 'W_3' YES 100 RAT 0.5 / / TSTEP