diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 6946d546f..64f55f737 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -179,13 +179,9 @@ namespace Opm { double wrat = record->getItem("WRAT")->getSIDouble(0); double grat = record->getItem("GRAT")->getSIDouble(0); WellCommon::StatusEnum status = WellCommon::StatusFromString( record->getItem("STATUS")->getString(0)); - - if (status != WellCommon::SHUT) { - WellProducer::ControlModeEnum control = WellProducer::ControlModeFromString( record->getItem("CMODE")->getString(0)); - well->setProducerControlMode( currentStep , control ); - } + WellProductionProperties properties = well->getProductionPropertiesCopy(currentStep); + well->setStatus( currentStep , status ); - WellProductionProperties properties = well->getProductionPropertiesCopy(currentStep); { double liquidRate = 0; double resVRate = 0; @@ -255,7 +251,7 @@ namespace Opm { const std::string& cmodeString = record->getItem("CMODE")->getString(0); WellProducer::ControlModeEnum control = WellProducer::ControlModeFromString( cmodeString ); if (properties.hasProductionControl( control)) - well->setProducerControlMode( currentStep , control ); + properties.controlMode = control; else { /* This is an awkward situation. The current control mode variable @@ -341,7 +337,7 @@ namespace Opm { const std::string& cmodeString = record->getItem("CMODE")->getString(0); WellInjector::ControlModeEnum controlMode = WellInjector::ControlModeFromString( cmodeString ); if (properties.hasInjectionControl( controlMode)) - well->setInjectorControlMode( currentStep , controlMode ); + properties.controlMode = controlMode; else { throw std::invalid_argument("Tried to set invalid control: " + cmodeString + " for well: " + wellName); } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index 2372a060f..2296e5359 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -28,9 +28,7 @@ namespace Opm { Well::Well(const std::string& name, int headI, int headJ, double refDepth, TimeMapConstPtr timeMap , size_t creationTimeStep) - : m_injectorControlMode(new DynamicState(timeMap, WellInjector::RATE)), - m_producerControlMode(new DynamicState(timeMap, WellProducer::ORAT)), - m_status(new DynamicState(timeMap, WellCommon::OPEN)), + : m_status(new DynamicState(timeMap, WellCommon::OPEN)), m_isAvailableForGroupControl(new DynamicState(timeMap, true)), m_guideRate(new DynamicState(timeMap, -1.0)), m_guideRatePhase(new DynamicState(timeMap, GuideRate::UNDEFINED)), @@ -95,23 +93,6 @@ namespace Opm { } - WellInjector::ControlModeEnum Well::getInjectorControlMode(size_t timeStep) const { - return m_injectorControlMode->get(timeStep); - } - - void Well::setInjectorControlMode(size_t timeStep, WellInjector::ControlModeEnum injectorControlMode) { - m_injectorControlMode->add(timeStep , injectorControlMode); - } - - WellProducer::ControlModeEnum Well::getProducerControlMode(size_t timeStep) const { - return m_producerControlMode->get(timeStep); - } - - void Well::setProducerControlMode(size_t timeStep, WellProducer::ControlModeEnum controlMode) { - m_producerControlMode->add(timeStep , controlMode); - } - - bool Well::isProducer(size_t timeStep) const { return m_isProducer->get(timeStep); } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index 8af605414..b7e336838 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -44,6 +44,7 @@ namespace Opm { double THPLimit; bool predictionMode; int productionControls; + WellProducer::ControlModeEnum controlMode; WellProductionProperties() { OilRate=0.0; @@ -55,6 +56,7 @@ namespace Opm { THPLimit=0.0; predictionMode=true; productionControls=0; + controlMode = WellProducer::ORAT; } bool hasProductionControl(WellProducer::ControlModeEnum controlMode) const { @@ -75,26 +77,28 @@ namespace Opm { productionControls += controlMode; } } + } WellProductionProperties; -} WellProductionProperties; typedef struct WellInjectionProperties { - double surfaceInjectionRate; - double reservoirInjectionRate; + double surfaceInjectionRate; + double reservoirInjectionRate; double BHPLimit; double THPLimit; bool predictionMode; + int injectionControls; WellInjector::TypeEnum injectorType; - int injectionControls; + WellInjector::ControlModeEnum controlMode; WellInjectionProperties() { surfaceInjectionRate=0.0; - reservoirInjectionRate=0.0; + reservoirInjectionRate=0.0; BHPLimit=0.0; THPLimit=0.0; predictionMode=true; - injectorType=WellInjector::WATER; injectionControls=0; + injectorType = WellInjector::WATER; + controlMode = WellInjector::RATE; } bool hasInjectionControl(WellInjector::ControlModeEnum controlMode) const { @@ -115,8 +119,8 @@ namespace Opm { injectionControls += controlMode; } } + } WellInjectionProperties; -} WellInjectionProperties; class Well { public: @@ -127,10 +131,6 @@ namespace Opm { const std::string getGroupName(size_t timeStep) const; void setGroupName(size_t timeStep , const std::string& groupName); - WellInjector::ControlModeEnum getInjectorControlMode(size_t timeStep) const; - void setInjectorControlMode(size_t timeStep, WellInjector::ControlModeEnum injectorControlMode); - WellProducer::ControlModeEnum getProducerControlMode(size_t timeStep) const; - void setProducerControlMode(size_t timeStep, WellProducer::ControlModeEnum controlMode); WellCommon::StatusEnum getStatus(size_t timeStep) const; void setStatus(size_t timeStep, WellCommon::StatusEnum Status); @@ -152,19 +152,19 @@ namespace Opm { void addWELSPECS(DeckRecordConstPtr deckRecord); void addCompletions(size_t time_step , const std::vector& newCompletions); CompletionSetConstPtr getCompletions(size_t timeStep) const; - void setProductionProperties(size_t timeStep , const WellProductionProperties properties); - WellProductionProperties getProductionPropertiesCopy(size_t timeStep) const; + + void setProductionProperties(size_t timeStep , const WellProductionProperties properties); + WellProductionProperties getProductionPropertiesCopy(size_t timeStep) const; const WellProductionProperties& getProductionProperties(size_t timeStep) const; - void setInjectionProperties(size_t timeStep , const WellInjectionProperties properties); - WellInjectionProperties getInjectionPropertiesCopy(size_t timeStep) const; + + void setInjectionProperties(size_t timeStep , const WellInjectionProperties properties); + WellInjectionProperties getInjectionPropertiesCopy(size_t timeStep) const; const WellInjectionProperties& getInjectionProperties(size_t timeStep) const; private: size_t m_creationTimeStep; std::string m_name; - - std::shared_ptr > m_injectorControlMode; - std::shared_ptr > m_producerControlMode; + std::shared_ptr > m_status; std::shared_ptr > m_isAvailableForGroupControl; diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index c3249b18d..da517877c 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -371,16 +371,6 @@ BOOST_AUTO_TEST_CASE(InjectorType) { } -BOOST_AUTO_TEST_CASE(ControlMode) { - Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1", 1, 2, 2334.32, timeMap, 0); - - well.setInjectorControlMode( 1 , Opm::WellInjector::RESV ); - BOOST_CHECK_EQUAL( Opm::WellInjector::RESV , well.getInjectorControlMode( 5 )); - - well.setProducerControlMode( 1 , Opm::WellProducer::GRUP ); - BOOST_CHECK_EQUAL( Opm::WellProducer::GRUP , well.getProducerControlMode( 5 )); -} BOOST_AUTO_TEST_CASE(WellStatus) { diff --git a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp index 1369820cb..a854319c3 100644 --- a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp +++ b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp @@ -34,6 +34,7 @@ using namespace Opm; + BOOST_AUTO_TEST_CASE(CreateSchedule) { ParserPtr parser(new Parser()); @@ -63,7 +64,6 @@ BOOST_AUTO_TEST_CASE(WCONPROD_MissingCmode) { ParserPtr parser(new Parser()); boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_MISSING_CMODE"); DeckPtr deck = parser->parseFile(scheduleFile.string()); - BOOST_CHECK_NO_THROW( new Schedule(deck) ); } @@ -99,10 +99,13 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK_EQUAL( WellCommon::SHUT , well2->getStatus(3)); - BOOST_CHECK_EQUAL( WellProducer::ORAT , well2->getProducerControlMode( 3 )); - BOOST_CHECK( well2->getProductionPropertiesCopy(3).hasProductionControl(WellProducer::ORAT)); - BOOST_CHECK( well2->getProductionPropertiesCopy(3).hasProductionControl(WellProducer::GRAT)); - BOOST_CHECK( !well2->getProductionPropertiesCopy(8).hasProductionControl(WellProducer::GRAT)); + { + const WellProductionProperties& prop3 = well2->getProductionProperties(3); + BOOST_CHECK_EQUAL( WellProducer::ORAT , prop3.controlMode); + BOOST_CHECK( prop3.hasProductionControl(WellProducer::ORAT)); + BOOST_CHECK( prop3.hasProductionControl(WellProducer::GRAT)); + } + BOOST_CHECK( !well2->getProductionProperties(8).hasProductionControl(WellProducer::GRAT)); } @@ -110,12 +113,14 @@ BOOST_AUTO_TEST_CASE(WellTesting) { WellPtr well3 = sched->getWell("W_3"); BOOST_CHECK_EQUAL( WellCommon::AUTO , well3->getStatus(3)); - BOOST_CHECK_EQUAL( 0 , well3->getProductionPropertiesCopy(2).LiquidRate); - BOOST_CHECK_CLOSE( 999/Metric::Time , well3->getProductionPropertiesCopy(7).LiquidRate , 0.001); + + { + const WellProductionProperties& prop7 = well3->getProductionProperties(7); + BOOST_CHECK_CLOSE( 999/Metric::Time , prop7.LiquidRate , 0.001); + BOOST_CHECK_EQUAL( WellProducer::RESV, prop7.controlMode); + } BOOST_CHECK_EQUAL( 0 , well3->getProductionPropertiesCopy(8).LiquidRate); - - BOOST_CHECK_EQUAL( WellProducer::RESV, well3->getProducerControlMode( 7 )); } { @@ -150,26 +155,34 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK(!well1->getProductionPropertiesCopy(8).predictionMode); BOOST_CHECK_CLOSE(13000/Metric::Time , well1->getProductionPropertiesCopy(8).OilRate , 0.001); - BOOST_CHECK( well1->isInjector(9)); - BOOST_CHECK_CLOSE(20000/Metric::Time , well1->getInjectionPropertiesCopy(9).surfaceInjectionRate, 0.001); - BOOST_CHECK_CLOSE(200000/Metric::Time, well1->getInjectionPropertiesCopy(9).reservoirInjectionRate, 0.001); - BOOST_CHECK_CLOSE(6891 * Metric::Pressure , well1->getInjectionPropertiesCopy(9).BHPLimit, 0.001); - BOOST_CHECK_CLOSE(0 , well1->getInjectionPropertiesCopy(9).THPLimit , 0.001); BOOST_CHECK_CLOSE(123.00 * Metric::Pressure , well1->getInjectionPropertiesCopy(10).BHPLimit, 0.001); BOOST_CHECK_CLOSE(678.00 * Metric::Pressure , well1->getInjectionPropertiesCopy(10).THPLimit, 0.001); - BOOST_CHECK_CLOSE(5000/Metric::Time , well1->getInjectionPropertiesCopy(11).surfaceInjectionRate, 0.001); + { + const WellInjectionProperties& prop11 = well1->getInjectionProperties(11); + BOOST_CHECK_CLOSE(5000/Metric::Time , prop11.surfaceInjectionRate, 0.001); + BOOST_CHECK_EQUAL( WellInjector::RATE , prop11.controlMode); + BOOST_CHECK_EQUAL( WellCommon::OPEN , well1->getStatus( 11 )); + } - BOOST_CHECK_EQUAL( WellInjector::RESV , well1->getInjectorControlMode( 9 )); - 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->getInjectionPropertiesCopy(9).hasInjectionControl(WellInjector::RATE )); - BOOST_CHECK( well1->getInjectionPropertiesCopy(9).hasInjectionControl(WellInjector::RESV )); - BOOST_CHECK( !well1->getInjectionPropertiesCopy(9).hasInjectionControl(WellInjector::THP)); - BOOST_CHECK( !well1->getInjectionPropertiesCopy(9).hasInjectionControl(WellInjector::BHP)); + + BOOST_CHECK( well1->isInjector(9)); + { + const WellInjectionProperties& prop9 = well1->getInjectionProperties(9); + BOOST_CHECK_CLOSE(20000/Metric::Time , prop9.surfaceInjectionRate , 0.001); + BOOST_CHECK_CLOSE(200000/Metric::Time , prop9.reservoirInjectionRate, 0.001); + BOOST_CHECK_CLOSE(6891 * Metric::Pressure , prop9.BHPLimit, 0.001); + BOOST_CHECK_CLOSE(0 , prop9.THPLimit , 0.001); + BOOST_CHECK_EQUAL( WellInjector::RESV , prop9.controlMode); + BOOST_CHECK( prop9.hasInjectionControl(WellInjector::RATE )); + BOOST_CHECK( prop9.hasInjectionControl(WellInjector::RESV )); + BOOST_CHECK( !prop9.hasInjectionControl(WellInjector::THP)); + BOOST_CHECK( !prop9.hasInjectionControl(WellInjector::BHP)); + } + + BOOST_CHECK_EQUAL( WellCommon::SHUT , well1->getStatus( 12 )); BOOST_CHECK( well1->getInjectionPropertiesCopy(12).hasInjectionControl(WellInjector::RATE )); BOOST_CHECK( !well1->getInjectionPropertiesCopy(12).hasInjectionControl(WellInjector::RESV)); BOOST_CHECK( well1->getInjectionPropertiesCopy(12).hasInjectionControl(WellInjector::THP ));