2013-10-25 17:28:56 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2013 Statoil ASA.
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
2013-11-08 15:55:11 +01:00
|
|
|
*/
|
2013-10-25 17:28:56 +02:00
|
|
|
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
|
|
|
|
|
|
|
|
|
|
2013-11-08 15:55:11 +01:00
|
|
|
namespace Opm {
|
|
|
|
|
|
2013-10-25 17:28:56 +02:00
|
|
|
Schedule::Schedule(DeckConstPtr deck) {
|
2013-11-18 13:11:49 +01:00
|
|
|
if (deck->hasKeyword("SCHEDULE")) {
|
|
|
|
|
addGroup( "FIELD" );
|
2013-11-08 15:55:11 +01:00
|
|
|
initFromDeck(deck);
|
2013-11-18 13:11:49 +01:00
|
|
|
} else
|
2013-11-05 15:25:47 +01:00
|
|
|
throw std::invalid_argument("Deck does not contain SCHEDULE section.\n");
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::createTimeMap(DeckConstPtr deck) {
|
2013-11-08 15:55:11 +01:00
|
|
|
boost::gregorian::date startDate(defaultStartDate);
|
2013-11-05 17:58:57 +01:00
|
|
|
if (deck->hasKeyword("START")) {
|
|
|
|
|
DeckKeywordConstPtr startKeyword = deck->getKeyword("START");
|
2013-11-08 15:55:11 +01:00
|
|
|
startDate = TimeMap::dateFromEclipse(startKeyword->getRecord(0));
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
2013-11-08 15:55:11 +01:00
|
|
|
|
2013-11-18 13:11:49 +01:00
|
|
|
m_timeMap.reset(new TimeMap(startDate));
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
2013-11-05 15:25:47 +01:00
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::initFromDeck(DeckConstPtr deck) {
|
2013-11-08 15:55:11 +01:00
|
|
|
createTimeMap(deck);
|
|
|
|
|
iterateScheduleSection(deck);
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-18 13:11:49 +01:00
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::iterateScheduleSection(DeckConstPtr deck) {
|
2013-11-08 15:55:11 +01:00
|
|
|
DeckKeywordConstPtr scheduleKeyword = deck->getKeyword("SCHEDULE");
|
2013-11-05 15:25:47 +01:00
|
|
|
size_t deckIndex = scheduleKeyword->getDeckIndex() + 1;
|
|
|
|
|
size_t currentStep = 0;
|
|
|
|
|
while (deckIndex < deck->size()) {
|
2013-11-08 15:55:11 +01:00
|
|
|
|
|
|
|
|
DeckKeywordConstPtr keyword = deck->getKeyword(deckIndex);
|
|
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
if (keyword->name() == "DATES") {
|
2013-11-08 15:55:11 +01:00
|
|
|
handleDATES(keyword);
|
2013-11-05 15:25:47 +01:00
|
|
|
currentStep += keyword->size();
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
2013-11-05 15:25:47 +01:00
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
if (keyword->name() == "TSTEP") {
|
2013-11-08 15:55:11 +01:00
|
|
|
handleTSTEP(keyword);
|
|
|
|
|
currentStep += keyword->getRecord(0)->getItem(0)->size(); // This is a bit weird API.
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
2013-11-08 15:55:11 +01:00
|
|
|
|
|
|
|
|
if (keyword->name() == "WELSPECS")
|
|
|
|
|
handleWELSPECS(keyword);
|
|
|
|
|
|
|
|
|
|
if (keyword->name() == "WCONHIST")
|
|
|
|
|
handleWCONHIST(keyword, currentStep);
|
|
|
|
|
|
|
|
|
|
if (keyword->name() == "WCONPROD")
|
|
|
|
|
handleWCONPROD(keyword, currentStep);
|
|
|
|
|
|
2013-11-11 17:06:22 +01:00
|
|
|
if (keyword->name() == "WCONINJE")
|
|
|
|
|
handleWCONINJE(keyword, currentStep);
|
|
|
|
|
|
|
|
|
|
if (keyword->name() == "WCONINJH")
|
|
|
|
|
handleWCONINJH(keyword, currentStep);
|
2013-11-05 15:25:47 +01:00
|
|
|
|
2013-11-09 13:17:42 +01:00
|
|
|
if (keyword->name() == "COMPDAT")
|
|
|
|
|
handleCOMPDAT( keyword , currentStep );
|
|
|
|
|
|
2013-11-18 16:06:50 +01:00
|
|
|
if (keyword->name() == "GCONINJE")
|
|
|
|
|
handleGCONINJE( keyword , currentStep );
|
|
|
|
|
|
2013-11-05 15:25:47 +01:00
|
|
|
deckIndex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::handleDATES(DeckKeywordConstPtr keyword) {
|
2013-11-08 15:55:11 +01:00
|
|
|
m_timeMap->addFromDATESKeyword(keyword);
|
2013-11-05 15:25:47 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::handleTSTEP(DeckKeywordConstPtr keyword) {
|
2013-11-08 15:55:11 +01:00
|
|
|
m_timeMap->addFromTSTEPKeyword(keyword);
|
2013-11-05 17:58:57 +01:00
|
|
|
}
|
2013-11-05 15:25:47 +01:00
|
|
|
|
|
|
|
|
void Schedule::handleWELSPECS(DeckKeywordConstPtr keyword) {
|
|
|
|
|
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
|
2013-11-08 15:55:11 +01:00
|
|
|
DeckRecordConstPtr record = keyword->getRecord(recordNr);
|
2013-11-18 16:06:50 +01:00
|
|
|
const std::string& wellName = record->getItem("WELL")->getString(0);
|
|
|
|
|
const std::string& groupName = record->getItem("GROUP")->getString(0);
|
|
|
|
|
|
|
|
|
|
if (!hasGroup(groupName)) {
|
|
|
|
|
addGroup(groupName);
|
|
|
|
|
}
|
2013-11-08 15:55:11 +01:00
|
|
|
|
|
|
|
|
if (!hasWell(wellName)) {
|
2013-11-05 15:25:47 +01:00
|
|
|
addWell(wellName);
|
2013-10-25 17:28:56 +02:00
|
|
|
}
|
2013-11-08 15:55:11 +01:00
|
|
|
WellPtr well = getWell(wellName);
|
|
|
|
|
well->addWELSPECS(record);
|
2013-11-05 15:25:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 17:06:22 +01:00
|
|
|
void Schedule::handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode) {
|
2013-11-05 15:25:47 +01:00
|
|
|
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
|
2013-11-08 15:55:11 +01:00
|
|
|
DeckRecordConstPtr record = keyword->getRecord(recordNr);
|
2013-11-11 17:06:22 +01:00
|
|
|
const std::string& wellName = record->getItem("WELL")->getString(0);
|
2013-11-05 15:25:47 +01:00
|
|
|
WellPtr well = getWell(wellName);
|
2013-11-11 17:06:22 +01:00
|
|
|
double orat = record->getItem("ORAT")->getDouble(0);
|
|
|
|
|
double wrat = record->getItem("WRAT")->getDouble(0);
|
|
|
|
|
double grat = record->getItem("GRAT")->getDouble(0);
|
|
|
|
|
|
2013-11-08 15:55:11 +01:00
|
|
|
well->setOilRate(currentStep, orat);
|
2013-11-11 17:06:22 +01:00
|
|
|
well->setWaterRate(currentStep, wrat);
|
|
|
|
|
well->setGasRate(currentStep, grat);
|
2013-11-08 15:55:11 +01:00
|
|
|
well->setInPredictionMode(currentStep, isPredictionMode);
|
2013-11-05 15:25:47 +01:00
|
|
|
}
|
2013-10-25 17:28:56 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-08 15:55:11 +01:00
|
|
|
void Schedule::handleWCONHIST(DeckKeywordConstPtr keyword, size_t currentStep) {
|
2013-11-11 17:06:22 +01:00
|
|
|
handleWCONProducer(keyword, currentStep, false);
|
2013-11-08 15:55:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Schedule::handleWCONPROD(DeckKeywordConstPtr keyword, size_t currentStep) {
|
2013-11-11 17:06:22 +01:00
|
|
|
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 );
|
|
|
|
|
}
|
2013-11-08 15:55:11 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-18 16:06:50 +01:00
|
|
|
|
|
|
|
|
void Schedule::handleGCONINJE(DeckKeywordConstPtr keyword, size_t currentStep) {
|
|
|
|
|
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
|
|
|
|
|
DeckRecordConstPtr record = keyword->getRecord(recordNr);
|
|
|
|
|
const std::string& groupName = record->getItem("GROUP")->getString(0);
|
|
|
|
|
GroupPtr group = getGroup(groupName);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
PhaseEnum phase = PhaseEnumFromString( record->getItem("PHASE")->getString(0) );
|
|
|
|
|
group->setInjectionPhase( currentStep , phase );
|
|
|
|
|
}
|
|
|
|
|
{
|
2013-11-19 17:20:18 +01:00
|
|
|
GroupInjection::ControlEnum controlMode = GroupInjection::ControlEnumFromString( record->getItem("CONTROL_MODE")->getString(0) );
|
2013-11-18 16:06:50 +01:00
|
|
|
group->setInjectionControlMode( currentStep , controlMode );
|
|
|
|
|
}
|
|
|
|
|
group->setSurfaceMaxRate( currentStep , record->getItem("SURFACE_TARGET")->getDouble(0));
|
|
|
|
|
group->setReservoirMaxRate( currentStep , record->getItem("RESV_TARGET")->getDouble(0));
|
|
|
|
|
group->setTargetReinjectFraction( currentStep , record->getItem("REINJ_TARGET")->getDouble(0));
|
|
|
|
|
group->setTargetVoidReplacementFraction( currentStep , record->getItem("VOIDAGE_TARGET")->getDouble(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-09 13:17:42 +01:00
|
|
|
void Schedule::handleCOMPDAT(DeckKeywordConstPtr keyword , size_t currentStep) {
|
|
|
|
|
std::map<std::string , std::vector< CompletionConstPtr> > completionMapList = Completion::completionsFromCOMPDATKeyword( keyword );
|
|
|
|
|
std::map<std::string , std::vector< CompletionConstPtr> >::iterator iter;
|
|
|
|
|
|
|
|
|
|
for( iter= completionMapList.begin(); iter != completionMapList.end(); iter++) {
|
|
|
|
|
const std::string wellName = iter->first;
|
|
|
|
|
WellPtr well = getWell( wellName );
|
|
|
|
|
|
|
|
|
|
well->addCompletions( currentStep , iter->second );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-25 17:28:56 +02:00
|
|
|
boost::gregorian::date Schedule::getStartDate() const {
|
|
|
|
|
return m_timeMap->getStartDate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimeMapConstPtr Schedule::getTimeMap() const {
|
|
|
|
|
return m_timeMap;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 17:58:57 +01:00
|
|
|
void Schedule::addWell(const std::string& wellName) {
|
2013-11-08 15:55:11 +01:00
|
|
|
WellPtr well(new Well(wellName, m_timeMap));
|
2013-11-05 17:58:57 +01:00
|
|
|
m_wells[ wellName ] = well;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-05 15:25:47 +01:00
|
|
|
size_t Schedule::numWells() const {
|
|
|
|
|
return m_wells.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Schedule::hasWell(const std::string& wellName) const {
|
2013-11-08 15:55:11 +01:00
|
|
|
return m_wells.find(wellName) != m_wells.end();
|
2013-11-05 15:25:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WellPtr Schedule::getWell(const std::string& wellName) const {
|
|
|
|
|
if (hasWell(wellName)) {
|
|
|
|
|
return m_wells.at(wellName);
|
2013-11-08 15:55:11 +01:00
|
|
|
} else
|
2013-11-05 15:25:47 +01:00
|
|
|
throw std::invalid_argument("Well: " + wellName + " does not exist");
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-18 13:11:49 +01:00
|
|
|
void Schedule::addGroup(const std::string& groupName) {
|
|
|
|
|
GroupPtr group(new Group(groupName, m_timeMap));
|
|
|
|
|
m_groups[ groupName ] = group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t Schedule::numGroups() const {
|
|
|
|
|
return m_groups.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Schedule::hasGroup(const std::string& groupName) const {
|
|
|
|
|
return m_groups.find(groupName) != m_groups.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GroupPtr Schedule::getGroup(const std::string& groupName) const {
|
|
|
|
|
if (hasGroup(groupName)) {
|
|
|
|
|
return m_groups.at(groupName);
|
|
|
|
|
} else
|
|
|
|
|
throw std::invalid_argument("Group: " + groupName + " does not exist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-11-05 15:25:47 +01:00
|
|
|
|
2013-10-25 17:28:56 +02:00
|
|
|
}
|