From bb444b5139938ec78255f9370fb004ffcf981bd6 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 30 Jan 2014 16:31:35 +0100 Subject: [PATCH] Added flag injectionControls to keep track of available injection controls. --- .../EclipseState/Schedule/Schedule.cpp | 55 +++++++++++++------ .../EclipseState/Schedule/ScheduleEnums.hpp | 1 + .../eclipse/EclipseState/Schedule/Well.cpp | 41 ++++++++++++-- .../eclipse/EclipseState/Schedule/Well.hpp | 8 ++- .../EclipseState/Schedule/tests/WellTests.cpp | 34 ++++++++++++ .../ScheduleCreateFromDeck.cpp | 11 ++++ opm/parser/share/keywords/W/WCONINJE | 8 +-- .../SCHEDULE/SCHEDULE_WELLS2 | 2 +- 8 files changed, 129 insertions(+), 31 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index ed474e473..5ed418904 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -189,31 +189,37 @@ namespace Opm { resVRate = record->getItem("RESV")->getSIDouble(0); BHPLimit = record->getItem("BHP")->getSIDouble(0); THPLimit = record->getItem("THP")->getSIDouble(0); - - if (record->getItem("LRAT")->defaultApplied()) - well->dropProductionControl( currentStep , WellProducer::LRAT ); - - if (record->getItem("RESV")->defaultApplied()) - well->dropProductionControl( currentStep , WellProducer::RESV ); - - if (record->getItem("BHP")->defaultApplied()) - well->dropProductionControl( currentStep , WellProducer::BHP ); - - if (record->getItem("THP")->defaultApplied()) - well->dropProductionControl( currentStep , WellProducer::THP ); } well->setLiquidRate( currentStep , liquidRate ); well->setResVRate( currentStep , resVRate ); well->setBHPLimit(currentStep, BHPLimit , true); well->setTHPLimit(currentStep, THPLimit , true); - } + if (isPredictionMode) { + if (record->getItem("LRAT")->defaultApplied()) + well->dropProductionControl( currentStep , WellProducer::LRAT ); + + if (record->getItem("RESV")->defaultApplied()) + well->dropProductionControl( currentStep , WellProducer::RESV ); + + if (record->getItem("BHP")->defaultApplied()) + well->dropProductionControl( currentStep , WellProducer::BHP ); + + if (record->getItem("THP")->defaultApplied()) + well->dropProductionControl( currentStep , WellProducer::THP ); + } else { + well->dropProductionControl( currentStep , WellProducer::LRAT ); + well->dropProductionControl( currentStep , WellProducer::RESV ); + well->dropProductionControl( currentStep , WellProducer::BHP ); + well->dropProductionControl( currentStep , WellProducer::THP ); + } + } + if (record->getItem("ORAT")->defaultApplied()) well->dropProductionControl( currentStep , WellProducer::ORAT ); if (record->getItem("GRAT")->defaultApplied()) { - std::cout << "Defaulted GRAT identified " << std::endl; well->dropProductionControl( currentStep , WellProducer::GRAT ); } @@ -235,10 +241,10 @@ namespace Opm { DeckRecordConstPtr record = keyword->getRecord(recordNr); const std::string& wellName = record->getItem("WELL")->getString(0); WellPtr well = getWell(wellName); - double surfaceInjectionRate = record->getItem("SURFACE_FLOW_TARGET")->getSIDouble(0); - double reservoirInjectionRate = record->getItem("RESV_FLOW_TARGET")->getSIDouble(0); - double BHPLimit = record->getItem("BHP_TARGET")->getSIDouble(0); - double THPLimit = record->getItem("THP_TARGET")->getSIDouble(0); + double surfaceInjectionRate = record->getItem("RATE")->getSIDouble(0); + double reservoirInjectionRate = record->getItem("RESV")->getSIDouble(0); + double BHPLimit = record->getItem("BHP")->getSIDouble(0); + double THPLimit = record->getItem("THP")->getSIDouble(0); WellInjector::ControlModeEnum controlMode = WellInjector::ControlModeFromString( record->getItem("CMODE")->getString(0)); WellCommon::StatusEnum status = WellCommon::StatusFromString( record->getItem("STATUS")->getString(0)); WellInjector::TypeEnum injectorType = WellInjector::TypeFromString( record->getItem("TYPE")->getString(0) ); @@ -251,6 +257,19 @@ namespace Opm { well->setInjectorControlMode(currentStep , controlMode ); well->setInjectorType( currentStep , injectorType ); well->setInPredictionMode(currentStep, true); + + if (record->getItem("RATE")->defaultApplied()) + well->dropInjectionControl( currentStep , WellInjector::RATE ); + + if (record->getItem("RESV")->defaultApplied()) + well->dropInjectionControl( currentStep , WellInjector::RESV ); + + if (record->getItem("THP")->defaultApplied()) + well->dropInjectionControl( currentStep , WellInjector::THP ); + + if (record->getItem("BHP")->defaultApplied()) + well->dropInjectionControl( currentStep , WellInjector::BHP ); + } } diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp index 93f2effd0..6340bad97 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp @@ -103,6 +103,7 @@ namespace Opm { THP = 128, GRUP = 256 }; + /* The items BHP, THP and GRUP only apply in prediction mode: WCONPROD. The elements in this enum are used as bitmasks to diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index bb1077210..20e5c64c1 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -42,7 +42,7 @@ namespace Opm { m_producerControlMode(new DynamicState(timeMap, WellProducer::ORAT)), m_status(new DynamicState(timeMap, WellCommon::OPEN)), m_productionControls(new DynamicState(timeMap, 0)), - m_injectorControls(new DynamicState(timeMap, 0)), + m_injectionControls(new DynamicState(timeMap, 0)), m_inPredictionMode(new DynamicState(timeMap, true)), m_isProducer(new DynamicState(timeMap, true)) , m_completions( new DynamicState( timeMap , CompletionSetConstPtr( new CompletionSet()) )), @@ -84,8 +84,11 @@ namespace Opm { m_BHPLimit->add(timeStep, BHPLimit); if (producer) addProductionControl( timeStep , WellProducer::BHP); + else + addInjectionControl( timeStep , WellInjector::BHP ); } + double Well::getTHPLimit(size_t timeStep) const { return m_THPLimit->get(timeStep); } @@ -94,6 +97,8 @@ namespace Opm { m_THPLimit->add(timeStep, THPLimit); if (producer) addProductionControl( timeStep , WellProducer::THP); + else + addInjectionControl( timeStep , WellInjector::THP ); } WellInjector::TypeEnum Well::getInjectorType(size_t timeStep) const { @@ -179,6 +184,7 @@ namespace Opm { void Well::setSurfaceInjectionRate(size_t timeStep, double injectionRate) { m_surfaceInjectionRate->add(timeStep, injectionRate); switch2Injector( timeStep ); + addInjectionControl( timeStep , WellInjector::RATE ); } double Well::getReservoirInjectionRate(size_t timeStep) const { @@ -188,6 +194,7 @@ namespace Opm { void Well::setReservoirInjectionRate(size_t timeStep, double injectionRate) { m_reservoirInjectionRate->add(timeStep, injectionRate); switch2Injector( timeStep ); + addInjectionControl( timeStep , WellInjector::RESV ); } @@ -220,6 +227,7 @@ namespace Opm { m_inPredictionMode->add(timeStep, inPredictionMode); } + /*****************************************************************/ bool Well::hasProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) const { int controls = m_productionControls->get( timeStep ); @@ -248,10 +256,33 @@ namespace Opm { } - /* - bool hasInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const; - void addInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode); - */ + bool Well::hasInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const { + int controls = m_injectionControls->get( timeStep ); + if (controls & controlMode) + return true; + else + return false; + } + + + void Well::addInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) { + int controls = m_injectionControls->get( timeStep ); + if ((controls & controlMode) == 0) { + controls += controlMode; + m_injectionControls->add(timeStep , controls ); + } + } + + + void Well::dropInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) { + int controls = m_injectionControls->get( timeStep ); + if ((controls & controlMode) != 0) { + controls -= controlMode; + m_injectionControls->add(timeStep , controls ); + } + } + + /*****************************************************************/ // WELSPECS diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index 310a260d8..cbbb5343f 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -68,8 +68,10 @@ namespace Opm { void setStatus(size_t timeStep, WellCommon::StatusEnum Status); bool hasProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) const; - bool hasInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const; void dropProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode); + + bool hasInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode) const; + void dropInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode); int getHeadI() const; @@ -88,7 +90,7 @@ namespace Opm { void switch2Producer(size_t timeStep ); void switch2Injector(size_t timeStep ); - void addInjectorControl(size_t timeStep , WellInjector::ControlModeEnum controlMode); + void addInjectionControl(size_t timeStep , WellInjector::ControlModeEnum controlMode); void addProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode); @@ -108,7 +110,7 @@ namespace Opm { std::shared_ptr > m_producerControlMode; std::shared_ptr > m_status; std::shared_ptr > m_productionControls; - std::shared_ptr > m_injectorControls; + std::shared_ptr > m_injectionControls; std::shared_ptr > m_inPredictionMode; std::shared_ptr > m_isProducer; diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index 583c09535..0f4f5aa54 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -345,3 +345,37 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) { BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::BHP )); BOOST_CHECK( well.hasProductionControl( 11 , Opm::WellProducer::THP )); } + + + +BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { + + Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); + Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); + + + BOOST_CHECK( !well.hasInjectionControl( 1 , Opm::WellInjector::RATE )); + BOOST_CHECK( !well.hasInjectionControl( 1 , Opm::WellInjector::RESV )); + + well.setSurfaceInjectionRate( 2 , 100 ); + BOOST_CHECK( well.hasInjectionControl( 2, Opm::WellInjector::RATE )); + BOOST_CHECK( !well.hasInjectionControl( 2 , Opm::WellInjector::RESV )); + + well.setReservoirInjectionRate( 2 , 100 ); + BOOST_CHECK( well.hasInjectionControl( 2 , Opm::WellInjector::RESV )); + + well.setBHPLimit( 10 , 100 , false); + well.setTHPLimit( 10 , 100 , false); + + BOOST_CHECK( well.hasInjectionControl( 10 , Opm::WellInjector::RATE )); + BOOST_CHECK( well.hasInjectionControl( 10 , Opm::WellInjector::RESV )); + BOOST_CHECK( well.hasInjectionControl( 10 , Opm::WellInjector::THP )); + BOOST_CHECK( well.hasInjectionControl( 10 , Opm::WellInjector::BHP )); + + well.dropInjectionControl( 11 , Opm::WellInjector::RESV ); + + BOOST_CHECK( well.hasInjectionControl( 11 , Opm::WellInjector::RATE )); + BOOST_CHECK( !well.hasInjectionControl( 11 , Opm::WellInjector::RESV )); + BOOST_CHECK( well.hasInjectionControl( 11 , Opm::WellInjector::THP )); + BOOST_CHECK( well.hasInjectionControl( 11 , Opm::WellInjector::BHP )); +} diff --git a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp index 4640350f5..27af3dddd 100644 --- a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp +++ b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp @@ -142,6 +142,17 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK_EQUAL( WellInjector::RATE , well1->getInjectorControlMode( 11 )); BOOST_CHECK_EQUAL( WellCommon::OPEN , well1->getStatus( 11 )); BOOST_CHECK_EQUAL( WellCommon::SHUT , well1->getStatus( 12 )); + + BOOST_CHECK( well1->hasInjectionControl( 9 , WellInjector::RATE )); + BOOST_CHECK( well1->hasInjectionControl( 9 , WellInjector::RESV )); + BOOST_CHECK( !well1->hasInjectionControl( 9 , WellInjector::THP )); + BOOST_CHECK( !well1->hasInjectionControl( 9 , WellInjector::BHP )); + + BOOST_CHECK( well1->hasInjectionControl( 12 , WellInjector::RATE )); + BOOST_CHECK( !well1->hasInjectionControl( 12 , WellInjector::RESV )); + BOOST_CHECK( well1->hasInjectionControl( 12 , WellInjector::THP )); + BOOST_CHECK( well1->hasInjectionControl( 12 , WellInjector::BHP )); + } } diff --git a/opm/parser/share/keywords/W/WCONINJE b/opm/parser/share/keywords/W/WCONINJE index 6acd45a6d..62cdbf6d3 100644 --- a/opm/parser/share/keywords/W/WCONINJE +++ b/opm/parser/share/keywords/W/WCONINJE @@ -3,10 +3,10 @@ {"name" : "TYPE" , "value_type" : "STRING" }, {"name" : "STATUS" , "value_type" : "STRING" , "default" : "OPEN"}, {"name" : "CMODE" , "value_type" : "STRING" }, - {"name" : "SURFACE_FLOW_TARGET" , "value_type" : "FLOAT" , "dimension" : "FlowVolume/t"}, - {"name" : "RESV_FLOW_TARGET" , "value_type" : "FLOAT" , "dimension" : "FlowVolume/t"}, - {"name" : "BHP_TARGET" , "value_type" : "FLOAT" , "dimension" : "P" , "default" : 6891}, - {"name" : "THP_TARGET" , "value_type" : "FLOAT" , "dimension" : "P"}, + {"name" : "RATE" , "value_type" : "FLOAT" , "dimension" : "FlowVolume/t"}, + {"name" : "RESV" , "value_type" : "FLOAT" , "dimension" : "FlowVolume/t"}, + {"name" : "BHP" , "value_type" : "FLOAT" , "dimension" : "P" , "default" : 6891}, + {"name" : "THP" , "value_type" : "FLOAT" , "dimension" : "P"}, {"name" : "VFP_TABLE" , "value_type" : "INT" , "default" : 0}, {"name" : "VAPOIL_C" , "value_type" : "FLOAT" , "default" : 0}, {"name" : "GAS_STEAM_RATIO" , "value_type" : "FLOAT" , "default" : 0}, diff --git a/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 b/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 index f2c698a21..fc1c5b162 100644 --- a/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 +++ b/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 @@ -117,5 +117,5 @@ DATES -- 12 / WCONINJE - 'W_1' 'WATER' 'SHUT' 'RATE' 20000.000 200000.000 123 678 4* / + 'W_1' 'WATER' 'SHUT' 'RATE' 20000.000 * 123 678 4* / /