Merge from master, fix conflict (injector introduction)

This commit is contained in:
Kristian Flikka
2013-11-20 14:11:17 +01:00
14 changed files with 256 additions and 47 deletions

View File

@@ -78,6 +78,11 @@ namespace Opm {
if (keyword->name() == "WCONPROD")
handleWCONPROD(keyword, currentStep);
if (keyword->name() == "WCONINJE")
handleWCONINJE(keyword, currentStep);
if (keyword->name() == "WCONINJH")
handleWCONINJH(keyword, currentStep);
if (keyword->name() == "COMPDAT")
handleCOMPDAT(keyword, currentStep);
@@ -128,24 +133,52 @@ namespace Opm {
}
}
void Schedule::handleWCON(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode) {
void Schedule::handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem(0)->getString(0);
double orat = record->getItem("ORAT")->getDouble(0);
const std::string& wellName = record->getItem("WELL")->getString(0);
WellPtr well = getWell(wellName);
double orat = record->getItem("ORAT")->getDouble(0);
double wrat = record->getItem("WRAT")->getDouble(0);
double grat = record->getItem("GRAT")->getDouble(0);
well->setOilRate(currentStep, orat);
well->setWaterRate(currentStep, wrat);
well->setGasRate(currentStep, grat);
well->setInPredictionMode(currentStep, isPredictionMode);
}
}
void Schedule::handleWCONHIST(DeckKeywordConstPtr keyword, size_t currentStep) {
handleWCON(keyword, currentStep, false);
handleWCONProducer(keyword, currentStep, false);
}
void Schedule::handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep) {
handleWCON(keyword, currentStep, true);
handleWCONProducer(keyword, currentStep, true);
}
void Schedule::handleWCONINJE(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem("WELL")->getString(0);
WellPtr well = getWell(wellName);
double injectionRate = record->getItem("SURFACE_FLOW_TARGET")->getDouble(0);
well->setInjectionRate( currentStep , injectionRate );
well->setInPredictionMode(currentStep, true);
}
}
void Schedule::handleWCONINJH(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellName = record->getItem("WELL")->getString(0);
WellPtr well = getWell(wellName);
double injectionRate = record->getItem("RATE")->getDouble(0);
well->setInjectionRate( currentStep , injectionRate );
well->setInPredictionMode(currentStep, false );
}
}
void Schedule::handleCOMPDAT(DeckKeywordConstPtr keyword, size_t currentStep) {

View File

@@ -62,10 +62,13 @@ namespace Opm
void addWell(const std::string& wellName);
void handleWELSPECS(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWCON(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode);
void handleWELSPECS(DeckKeywordConstPtr keyword);
void handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode);
void handleWCONHIST(DeckKeywordConstPtr keyword , size_t currentStep);
void handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
void handleCOMPDAT(DeckKeywordConstPtr keyword , size_t currentStep);
void handleWCONINJE(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWCONINJH(DeckKeywordConstPtr keyword, size_t currentStep);
void handleDATES(DeckKeywordConstPtr keyword);
void handleTSTEP(DeckKeywordConstPtr keyword);
void handleGRUPTREE(DeckKeywordConstPtr keyword, size_t currentStep);

View File

@@ -31,38 +31,89 @@ namespace Opm {
Well::Well(const std::string& name , TimeMapConstPtr timeMap)
: m_oilRate( new DynamicState<double>( timeMap , 0.0)) ,
m_gasRate(new DynamicState<double>(timeMap, 0.0)),
m_waterRate(new DynamicState<double>(timeMap, 0.0)),
m_injectionRate(new DynamicState<double>(timeMap, 0.0)),
m_inPredictionMode(new DynamicState<bool>(timeMap, true)),
m_isProducer(new DynamicState<bool>(timeMap, true)) ,
m_completions( new DynamicState<CompletionSetConstPtr>( timeMap , CompletionSetConstPtr( new CompletionSet()) ))
{
m_name = name;
}
const std::string& Well::name() const {
return m_name;
}
double Well::getOilRate(size_t timeStep) const {
return m_oilRate->get(timeStep);
}
void Well::setOilRate(size_t timeStep, double oilRate) {
m_oilRate->add(timeStep, oilRate);
switch2Producer( timeStep );
}
double Well::getGasRate(size_t timeStep) const {
return m_gasRate->get(timeStep);
}
void Well::setGasRate(size_t timeStep, double gasRate) {
m_gasRate->add(timeStep, gasRate);
switch2Producer( timeStep );
}
double Well::getWaterRate(size_t timeStep) const {
return m_waterRate->get(timeStep);
}
void Well::setWaterRate(size_t timeStep, double waterRate) {
m_waterRate->add(timeStep, waterRate);
switch2Producer( timeStep );
}
double Well::getInjectionRate(size_t timeStep) const {
return m_injectionRate->get(timeStep);
}
void Well::setInjectionRate(size_t timeStep, double injectionRate) {
m_injectionRate->add(timeStep, injectionRate);
switch2Injector( timeStep );
}
bool Well::isProducer(size_t timeStep) const {
return m_isProducer->get(timeStep);
}
bool Well::isInjector(size_t timeStep) const {
return !isProducer(timeStep);
}
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);
}
void Well::switch2Producer(size_t timeStep ) {
m_isProducer->add(timeStep , true);
m_injectionRate->add(timeStep, 0);
}
void Well::switch2Injector(size_t timeStep ) {
m_isProducer->add(timeStep , false);
m_oilRate->add(timeStep, 0);
m_gasRate->add(timeStep, 0);
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);
}
void Well::addWELSPECS(DeckRecordConstPtr deckRecord) {
}

View File

@@ -37,16 +37,33 @@ namespace Opm {
const std::string& name() const;
double getOilRate(size_t timeStep) const;
void setOilRate(size_t timeStep, double oilRate);
void setOilRate(size_t timeStep, double oilRate);
double getGasRate(size_t timeStep) const;
void setGasRate(size_t timeStep, double gasRate);
double getWaterRate(size_t timeStep) const;
void setWaterRate(size_t timeStep, double waterRate);
double getInjectionRate(size_t timeStep) const;
void setInjectionRate(size_t timeStep, double injectionRate);
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;
void addWELSPECS(DeckRecordConstPtr deckRecord);
void addCompletions(size_t time_step , const std::vector<CompletionConstPtr>& newCompletions);
CompletionSetConstPtr getCompletions(size_t timeStep);
private:
void switch2Producer(size_t timeStep );
void switch2Injector(size_t timeStep );
std::string m_name;
boost::shared_ptr<DynamicState<double> > m_oilRate;
boost::shared_ptr<DynamicState<double> > m_gasRate;
boost::shared_ptr<DynamicState<double> > m_waterRate;
boost::shared_ptr<DynamicState<double> > m_injectionRate;
boost::shared_ptr<DynamicState<bool> > m_inPredictionMode;
boost::shared_ptr<DynamicState<bool> > m_isProducer;
boost::shared_ptr<DynamicState<CompletionSetConstPtr> > m_completions;
};
typedef boost::shared_ptr<Well> WellPtr;

View File

@@ -112,3 +112,75 @@ BOOST_AUTO_TEST_CASE(UpdateCompletions) {
}
BOOST_AUTO_TEST_CASE(setGasRate_RateSetCorrect) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Well well("WELL1" , timeMap);
BOOST_CHECK_EQUAL(0.0 , well.getGasRate( 5 ));
well.setGasRate( 5 , 108 );
BOOST_CHECK_EQUAL(108 , well.getGasRate( 5 ));
BOOST_CHECK_EQUAL(108 , well.getGasRate( 8 ));
}
BOOST_AUTO_TEST_CASE(setWaterRate_RateSetCorrect) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Well well("WELL1" , timeMap);
BOOST_CHECK_EQUAL(0.0 , well.getWaterRate( 5 ));
well.setWaterRate( 5 , 108 );
BOOST_CHECK_EQUAL(108 , well.getWaterRate( 5 ));
BOOST_CHECK_EQUAL(108 , well.getWaterRate( 8 ));
}
BOOST_AUTO_TEST_CASE(setInjectionRate_RateSetCorrect) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Well well("WELL1" , timeMap);
BOOST_CHECK_EQUAL(0.0 , well.getInjectionRate( 5 ));
well.setInjectionRate( 5 , 108 );
BOOST_CHECK_EQUAL(108 , well.getInjectionRate( 5 ));
BOOST_CHECK_EQUAL(108 , well.getInjectionRate( 8 ));
}
BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) {
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
Opm::Well well("WELL1" , timeMap);
/* 1: Well is created as producer */
BOOST_CHECK_EQUAL( false , well.isInjector(0));
BOOST_CHECK_EQUAL( true , well.isProducer(0));
/* Set an injection rate => Well becomes an Injector */
well.setInjectionRate(3 , 100);
BOOST_CHECK_EQUAL( true , well.isInjector(3));
BOOST_CHECK_EQUAL( false , well.isProducer(3));
BOOST_CHECK_EQUAL( 100 , well.getInjectionRate(3));
/* Set rates => Well becomes a producer; injection rate should be set to 0. */
well.setOilRate(4 , 100 );
well.setGasRate(4 , 200 );
well.setWaterRate(4 , 300 );
BOOST_CHECK_EQUAL( false , well.isInjector(4));
BOOST_CHECK_EQUAL( true , well.isProducer(4));
BOOST_CHECK_EQUAL( 0 , well.getInjectionRate(4));
BOOST_CHECK_EQUAL( 100 , well.getOilRate(4));
BOOST_CHECK_EQUAL( 200 , well.getGasRate(4));
BOOST_CHECK_EQUAL( 300 , well.getWaterRate(4));
/* Set injection rate => Well becomes injector - all produced rates -> 0 */
well.setInjectionRate( 6 , 50 );
BOOST_CHECK_EQUAL( true , well.isInjector(6));
BOOST_CHECK_EQUAL( false , well.isProducer(6));
BOOST_CHECK_EQUAL( 50 , well.getInjectionRate(6));
BOOST_CHECK_EQUAL( 0 , well.getOilRate(6));
BOOST_CHECK_EQUAL( 0 , well.getGasRate(6));
BOOST_CHECK_EQUAL( 0 , well.getWaterRate(6));
}

View File

@@ -64,14 +64,14 @@ BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) {
DeckRecordConstPtr rec3 = kw1->getRecord(2);
BOOST_CHECK_EQUAL( 11U , rec3->size() );
DeckItemConstPtr item1 = rec1->getItem("WellName");
DeckItemConstPtr item1 = rec1->getItem("WELL");
DeckItemConstPtr item1_index = rec1->getItem(0);
BOOST_CHECK_EQUAL( item1 , item1_index );
BOOST_CHECK_EQUAL( "OP_1" , item1->getString(0));
item1 = rec3->getItem("WellName");
item1 = rec3->getItem("WELL");
BOOST_CHECK_EQUAL( "OP_3" , item1->getString(0));

View File

@@ -49,14 +49,14 @@ BOOST_AUTO_TEST_CASE( parse_WCHONHIST_OK ) {
DeckRecordConstPtr rec3 = kw1->getRecord(2);
BOOST_CHECK_EQUAL( 11U , rec3->size() );
DeckItemConstPtr item1 = rec1->getItem("WellName");
DeckItemConstPtr item1 = rec1->getItem("WELL");
DeckItemConstPtr item1_index = rec1->getItem(0);
BOOST_CHECK_EQUAL( item1 , item1_index );
BOOST_CHECK_EQUAL( "OP_1" , item1->getString(0));
item1 = rec3->getItem("WellName");
item1 = rec3->getItem("WELL");
BOOST_CHECK_EQUAL( "OP_3" , item1->getString(0));
@@ -65,5 +65,5 @@ BOOST_AUTO_TEST_CASE( parse_WCHONHIST_OK ) {
BOOST_CHECK_EQUAL( 2U , deck->numKeywords("WCONHIST"));
kw1 = deck->getKeyword("WCONHIST" , 1 );
rec3 = kw1->getRecord(2);
BOOST_CHECK_EQUAL( "OP_3_B" , rec3->getItem("WellName")->getString(0));
BOOST_CHECK_EQUAL( "OP_3_B" , rec3->getItem("WELL")->getString(0));
}

View File

@@ -68,26 +68,28 @@ BOOST_AUTO_TEST_CASE(WellTesting) {
BOOST_CHECK_EQUAL(4000, well1->getOilRate(3));
BOOST_CHECK_EQUAL(4000, well1->getOilRate(4));
BOOST_CHECK_EQUAL(4000, well1->getOilRate(5));
BOOST_CHECK_EQUAL(4 , well1->getWaterRate(3));
BOOST_CHECK_EQUAL(12345 , well1->getGasRate(3));
BOOST_CHECK_EQUAL(4 , well1->getWaterRate(4));
BOOST_CHECK_EQUAL(12345 , well1->getGasRate(4));
BOOST_CHECK_EQUAL(4 , well1->getWaterRate(5));
BOOST_CHECK_EQUAL(12345 , well1->getGasRate(5));
BOOST_CHECK(!well1->isInPredictionMode(6));
BOOST_CHECK_EQUAL(14000, well1->getOilRate(6));
BOOST_CHECK(well1->isInPredictionMode(7));
BOOST_CHECK_EQUAL(11000, well1->getOilRate(7));
BOOST_CHECK_EQUAL(44 , well1->getWaterRate(7));
BOOST_CHECK_EQUAL(188 , well1->getGasRate(7));
BOOST_CHECK(!well1->isInPredictionMode(8));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(8));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(9));
BOOST_CHECK_EQUAL(13000, well1->getOilRate(10));
BOOST_CHECK_EQUAL(3U, sched->numWells());
BOOST_CHECK(sched->hasWell("W_1"));
BOOST_CHECK(sched->hasWell("W_2"));
BOOST_CHECK(sched->hasWell("W_3"));
{
WellPtr well1 = sched->getWell("W_1");
BOOST_CHECK_EQUAL(13000, well1->getOilRate(8));
}
BOOST_CHECK( well1->isInjector(9));
BOOST_CHECK_EQUAL(20000, well1->getInjectionRate(9));
BOOST_CHECK_EQUAL(5000, well1->getInjectionRate(10));
}
}

View File

@@ -1,5 +1,5 @@
{"name" : "WCONHIST", "items" :
[{"name" : "WellName" , "value_type" : "STRING"},
[{"name" : "WELL" , "value_type" : "STRING"},
{"name" : "OpenShut" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "ControlMode" , "value_type" : "STRING"},
{"name" : "ORAT" , "value_type" : "FLOAT", "default" : 0.0},

View File

@@ -0,0 +1 @@
{"name" : "WCONINJ" , "action" : "THROW_EXCEPTION"}

View File

@@ -1,12 +1,12 @@
{"name" : "WCONINJE" , "items" : [
{"name" : "well_name" , "value_type" : "STRING" },
{"name" : "type" , "value_type" : "STRING" },
{"name" : "status" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "WELL" , "value_type" : "STRING" },
{"name" : "TYPE" , "value_type" : "STRING" },
{"name" : "STATUS" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "CMODE" , "value_type" : "STRING" },
{"name" : "surface_flow_target" , "value_type" : "FLOAT"},
{"name" : "resv_flow_target" , "value_type" : "FLOAT"},
{"name" : "bhp_target" , "value_type" : "FLOAT"},
{"name" : "thp_target" , "value_type" : "FLOAT"},
{"name" : "SURFACE_FLOW_TARGET" , "value_type" : "FLOAT"},
{"name" : "RESV_FLOW_TARGET" , "value_type" : "FLOAT"},
{"name" : "BHP_TARGET" , "value_type" : "FLOAT"},
{"name" : "THP_TARGET" , "value_type" : "FLOAT"},
{"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},

View File

@@ -0,0 +1,14 @@
{"name" : "WCONINJH" , "items" : [
{"name" : "WELL" , "value_type" : "STRING" },
{"name" : "TYPE" , "value_type" : "STRING" },
{"name" : "STATUS" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "RATE" , "value_type" : "FLOAT"},
{"name" : "BHP" , "value_type" : "FLOAT"},
{"name" : "THP" , "value_type" : "FLOAT"},
{"name" : "VFP_TABLE" , "value_type" : "INT" , "default" : 0},
{"name" : "VAPOIL_C" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "SURFACE_OIL_FRACTION" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "SURFACE_WATER_FRACTION" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "SURFACE_GAS_FRACTION" , "value_type" : "FLOAT" , "default" : 0},
{"name" : "CMODE" , "value_type" : "STRING" }
]}

View File

@@ -1,5 +1,5 @@
{"name" : "WCONPROD" , "items" :
[{"name" : "WellName" , "value_type" : "STRING"},
[{"name" : "WELL" , "value_type" : "STRING"},
{"name" : "OpenShut" , "value_type" : "STRING" , "default" : "OPEN"},
{"name" : "ControlMode" , "value_type" : "STRING"},
{"name" : "ORAT" , "value_type" : "FLOAT", "default" : 0.0},

View File

@@ -36,7 +36,7 @@ COMPDAT
WCONHIST
'W_1' 'OPEN' 'ORAT' 4000.000 4.000 1.46402E+006 5* /
'W_1' 'OPEN' 'ORAT' 4000.000 4.000 12345 5* /
'W_2' 'OPEN' 'ORAT' 7998.000 2.000 1461075.000 5* /
'W_3' 'OPEN' 'ORAT' 7999.000 1.000 1471824.000 5* /
/
@@ -63,7 +63,7 @@ COMPDAT
WCONPROD
'W_1' 'OPEN' 'ORAT' 11000.000 4.000 1.46402E+006 5* /
'W_1' 'OPEN' 'ORAT' 11000.000 44.000 188 5* /
'W_2' 'OPEN' 'ORAT' 17998.000 2.000 1461075.000 5* /
'W_3' 'OPEN' 'ORAT' 17999.000 1.000 1471824.000 5* /
/
@@ -77,7 +77,23 @@ WCONHIST
'W_3' 'OPEN' 'ORAT' 17999.000 1.000 1471824.000 5* /
/
DATES -- 9, 10
DATES -- 9
10 JLY 2008 /
/
WCONINJE
'W_1' 'WATER' 1* 'RATE' 20000.000 5* /
/
DATES -- 10
10 AUG 2008 /
/
WCONINJH
'W_1' 'WATER' 1* 5000.000 /
/
DATES -- 11
10 SEP 2008 /
/