From fb5c83086ab6fc39a5692bad7b8105f7b52c6a4f Mon Sep 17 00:00:00 2001 From: Atle Haugan Date: Wed, 12 Mar 2014 11:21:57 +0100 Subject: [PATCH] Moved (duplicated) m_isInPredictionMode to WellProductionProperties and WellInjectionProperties. --- .../EclipseState/Schedule/Schedule.cpp | 6 ++-- .../eclipse/EclipseState/Schedule/Well.cpp | 20 +------------ .../eclipse/EclipseState/Schedule/Well.hpp | 17 +++++------ .../EclipseState/Schedule/tests/WellTests.cpp | 28 +++++++++++++++---- .../ScheduleCreateFromDeck.cpp | 10 +++---- 5 files changed, 39 insertions(+), 42 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 86a61c1ea..ada961f2f 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -185,7 +185,6 @@ namespace Opm { well->setProducerControlMode( currentStep , control ); } well->setStatus( currentStep , status ); - well->setInPredictionMode(currentStep, isPredictionMode); { double liquidRate = 0; double resVRate = 0; @@ -200,6 +199,7 @@ namespace Opm { } WellProductionProperties properties = well->getProductionProperties(currentStep); + properties.PredictionMode = isPredictionMode; properties.OilRate = orat; properties.WaterRate = wrat; properties.GasRate = grat; @@ -302,9 +302,9 @@ namespace Opm { properties.BHPLimit = BHPLimit; properties.THPLimit = THPLimit; properties.InjectorType = injectorType; + properties.PredictionMode = true; well->setInjectionProperties(currentStep, properties); well->setInjectorControlMode(currentStep , controlMode ); - well->setInPredictionMode(currentStep, true); if (record->getItem("RATE")->defaultApplied()) well->dropInjectionControl( currentStep , WellInjector::RATE ); @@ -347,8 +347,8 @@ namespace Opm { well->setStatus( currentStep , status ); WellInjectionProperties properties(well->getInjectionProperties(currentStep)); properties.SurfaceInjectionRate = injectionRate; + properties.PredictionMode = false; well->setInjectionProperties(currentStep, properties); - well->setInPredictionMode(currentStep, false ); } } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index d3ca40bbe..8061365c3 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -28,12 +28,10 @@ namespace Opm { Well::Well(const std::string& name, int headI, int headJ, double refDepth, TimeMapConstPtr timeMap , size_t creationTimeStep) - : //m_injectorType(new DynamicState(timeMap, WellInjector::WATER)), - m_injectorControlMode(new DynamicState(timeMap, WellInjector::RATE)), + : m_injectorControlMode(new DynamicState(timeMap, WellInjector::RATE)), m_producerControlMode(new DynamicState(timeMap, WellProducer::ORAT)), m_status(new DynamicState(timeMap, WellCommon::OPEN)), //m_injectionControls(new DynamicState(timeMap, 0)), - m_inPredictionMode(new DynamicState(timeMap, true)), m_isProducer(new DynamicState(timeMap, true)), m_isAvailableForGroupControl(new DynamicState(timeMap, true)), m_guideRate(new DynamicState(timeMap, -1.0)), @@ -90,14 +88,6 @@ namespace Opm { } -// WellInjector::TypeEnum Well::getInjectorType(size_t timeStep) const { -// return m_injectorType->get(timeStep); -// } - -// void Well::setInjectorType(size_t timeStep, WellInjector::TypeEnum injectorType) { -// m_injectorType->add(timeStep , injectorType); -// } - WellInjector::ControlModeEnum Well::getInjectorControlMode(size_t timeStep) const { return m_injectorControlMode->get(timeStep); } @@ -169,14 +159,6 @@ namespace Opm { // m_waterRate->add(timeStep, 0); } - bool Well::isInPredictionMode(size_t timeStep) const { - return m_inPredictionMode->get(timeStep); - } - - void Well::setInPredictionMode(size_t timeStep, bool inPredictionMode) { - m_inPredictionMode->add(timeStep, inPredictionMode); - } - /*****************************************************************/ bool Well::hasProductionControl(size_t timeStep , WellProducer::ControlModeEnum controlMode) const { diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index e4e26e2dd..d1c71406a 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -43,15 +43,16 @@ namespace Opm { double ResVRate; double BHPLimit; double THPLimit; + bool PredictionMode; int ProductionControls; WellProductionProperties() {OilRate=0.0; GasRate=0.0; WaterRate=0.0; LiquidRate=0.0; ResVRate=0.0; - BHPLimit=0.0; THPLimit=0.0; ProductionControls=0;} + BHPLimit=0.0; THPLimit=0.0; PredictionMode=true; ProductionControls=0;} WellProductionProperties(const WellProductionProperties& props) {OilRate=props.OilRate; GasRate=props.GasRate; WaterRate=props.WaterRate; LiquidRate=props.LiquidRate; ResVRate=props.ResVRate; - BHPLimit=props.BHPLimit; THPLimit=props.THPLimit; + BHPLimit=props.BHPLimit; THPLimit=props.THPLimit; PredictionMode=props.PredictionMode; ProductionControls=props.ProductionControls;} } WellProductionProperties; @@ -60,16 +61,18 @@ namespace Opm { double ReservoirInjectionRate; double BHPLimit; double THPLimit; + bool PredictionMode; WellInjector::TypeEnum InjectorType; int InjectionControls; WellInjectionProperties() {SurfaceInjectionRate=0.0; ReservoirInjectionRate=0.0; - BHPLimit=0.0; THPLimit=0.0; InjectorType=WellInjector::WATER, InjectionControls=0;} + BHPLimit=0.0; THPLimit=0.0; PredictionMode=true; + InjectorType=WellInjector::WATER, InjectionControls=0;} WellInjectionProperties(const WellInjectionProperties& props) {SurfaceInjectionRate=props.SurfaceInjectionRate; ReservoirInjectionRate=props.ReservoirInjectionRate; - BHPLimit=props.BHPLimit; THPLimit=props.THPLimit; + BHPLimit=props.BHPLimit; THPLimit=props.THPLimit; PredictionMode=props.PredictionMode; InjectorType=props.InjectorType; InjectionControls=props.InjectionControls;} } WellInjectionProperties; @@ -82,8 +85,6 @@ namespace Opm { const std::string getGroupName(size_t timeStep) const; void setGroupName(size_t timeStep , const std::string& groupName); -// WellInjector::TypeEnum getInjectorType(size_t timeStep) const; -// void setInjectorType(size_t timeStep, WellInjector::TypeEnum injectorType); WellInjector::ControlModeEnum getInjectorControlMode(size_t timeStep) const; void setInjectorControlMode(size_t timeStep, WellInjector::ControlModeEnum injectorControlMode); WellProducer::ControlModeEnum getProducerControlMode(size_t timeStep) const; @@ -102,8 +103,6 @@ namespace Opm { int getHeadJ() const; double getRefDepth() const; - bool isInPredictionMode(size_t timeStep) const; - void setInPredictionMode(size_t timeStep, bool isInPredictionMode); bool isProducer(size_t timeStep) const; bool isInjector(size_t timeStep) const; @@ -131,12 +130,10 @@ namespace Opm { size_t m_creationTimeStep; std::string m_name; - //std::shared_ptr > m_injectorType; std::shared_ptr > m_injectorControlMode; std::shared_ptr > m_producerControlMode; std::shared_ptr > m_status; - std::shared_ptr > m_inPredictionMode; std::shared_ptr > m_isProducer; std::shared_ptr > m_isAvailableForGroupControl; std::shared_ptr > m_guideRate; diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index 66f8b1adc..060553c91 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -108,14 +108,30 @@ BOOST_AUTO_TEST_CASE(seLiquidRate_RateSetCorrect) { } -BOOST_AUTO_TEST_CASE(setPredictionMode_ModeSetCorrect) { +BOOST_AUTO_TEST_CASE(setPredictionModeProduction_ModeSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Well well("WELL1" , 0, 0, 0.0, timeMap , 0); - BOOST_CHECK_EQUAL( true, well.isInPredictionMode( 5 )); - well.setInPredictionMode( 5 , false ); // Go to history mode - BOOST_CHECK_EQUAL(false , well.isInPredictionMode( 5 )); - BOOST_CHECK_EQUAL(false , well.isInPredictionMode( 8 )); + BOOST_CHECK_EQUAL( true, well.getProductionProperties(5).PredictionMode); + Opm::WellProductionProperties props; + props.PredictionMode = false; + well.setProductionProperties( 5 , props); + BOOST_CHECK_EQUAL(false , well.getProductionProperties(5).PredictionMode); + BOOST_CHECK_EQUAL(false , well.getProductionProperties(8).PredictionMode); +} + + + +BOOST_AUTO_TEST_CASE(setPredictionModeInjection_ModeSetCorrect) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); + Opm::Well well("WELL1" , 0, 0, 0.0, timeMap , 0); + + BOOST_CHECK_EQUAL( true, well.getInjectionProperties(5).PredictionMode); + Opm::WellInjectionProperties props; + props.PredictionMode = false; + well.setInjectionProperties( 5 , props); + BOOST_CHECK_EQUAL(false , well.getInjectionProperties(5).PredictionMode); + BOOST_CHECK_EQUAL(false , well.getInjectionProperties(8).PredictionMode); } @@ -325,6 +341,8 @@ BOOST_AUTO_TEST_CASE(InjectorType) { Opm::WellInjectionProperties injectionProps(well.getInjectionProperties(1)); injectionProps.InjectorType = Opm::WellInjector::WATER; well.setInjectionProperties(1, injectionProps); + // TODO: Should we test for something other than water here, as long as + // the default value for InjectorType is WellInjector::WATER? BOOST_CHECK_EQUAL( Opm::WellInjector::WATER , well.getInjectionProperties(5).InjectorType); } diff --git a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp index 2a8d02701..5b39bb0b3 100644 --- a/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp +++ b/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp @@ -121,13 +121,13 @@ BOOST_AUTO_TEST_CASE(WellTesting) { { WellPtr well1 = sched->getWell("W_1"); - BOOST_CHECK(well1->isInPredictionMode(0)); + BOOST_CHECK(well1->getProductionProperties(0).PredictionMode); BOOST_CHECK_EQUAL(0, well1->getProductionProperties(0).OilRate); BOOST_CHECK_EQUAL(0, well1->getProductionProperties(1).OilRate); BOOST_CHECK_EQUAL(0, well1->getProductionProperties(2).OilRate); - BOOST_CHECK(!well1->isInPredictionMode(3)); + BOOST_CHECK(!well1->getProductionProperties(3).PredictionMode); BOOST_CHECK_CLOSE(4000/Metric::Time , well1->getProductionProperties(3).OilRate , 0.001); BOOST_CHECK_CLOSE(4000/Metric::Time , well1->getProductionProperties(4).OilRate , 0.001); BOOST_CHECK_CLOSE(4000/Metric::Time , well1->getProductionProperties(5).OilRate , 0.001); @@ -139,15 +139,15 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK_CLOSE(12345/Metric::Time , well1->getProductionProperties(5).GasRate , 0.001); - BOOST_CHECK(!well1->isInPredictionMode(6)); + BOOST_CHECK(!well1->getProductionProperties(6).PredictionMode); BOOST_CHECK_CLOSE(14000/Metric::Time , well1->getProductionProperties(6).OilRate , 0.001); - BOOST_CHECK(well1->isInPredictionMode(7)); + BOOST_CHECK(well1->getProductionProperties(7).PredictionMode); BOOST_CHECK_CLOSE(11000/Metric::Time , well1->getProductionProperties(7).OilRate , 0.001); BOOST_CHECK_CLOSE(44/Metric::Time , well1->getProductionProperties(7).WaterRate , 0.001); BOOST_CHECK_CLOSE(188/Metric::Time , well1->getProductionProperties(7).GasRate , 0.001); - BOOST_CHECK(!well1->isInPredictionMode(8)); + BOOST_CHECK(!well1->getProductionProperties(8).PredictionMode); BOOST_CHECK_CLOSE(13000/Metric::Time , well1->getProductionProperties(8).OilRate , 0.001); BOOST_CHECK( well1->isInjector(9));