Updates and actions related to Joacim's comments

This commit is contained in:
Edvin Brudevoll 2015-04-07 08:02:06 +02:00
parent 8ac548d564
commit 8a7f8e6c59
5 changed files with 62 additions and 138 deletions

View File

@ -29,9 +29,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/WellInjectionProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/WellPolymerProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
namespace Opm {
@ -108,7 +106,7 @@ namespace Opm {
handleWELOPEN(keyword, currentStep , deck->hasKeyword("COMPLUMP"));
if (keyword->name() == "WELTARG")
handleWELTARG(keyword, currentStep);
handleWELTARG(deck, keyword, currentStep);
if (keyword->name() == "GRUPTREE")
handleGRUPTREE(keyword, currentStep);
@ -416,11 +414,9 @@ namespace Opm {
}
}
const std::string& wellNamePattern = record->getItem("WELL")->getTrimmedString(0);
const std::vector<WellPtr>& wells = getWells(wellNamePattern);
for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) {
WellPtr well = *wellIter;
@ -490,19 +486,28 @@ namespace Opm {
else if(!haveCompletionData) {
WellCommon::StatusEnum status = WellCommon::StatusFromString( record->getItem("STATUS")->getTrimmedString(0));
well->setStatus(currentStep, status);
}
}
}
}
void Schedule::handleWELTARG(DeckKeywordConstPtr keyword, size_t currentStep) {
/*
The documentation for the WELTARG keyword says that the well must have been fully specified and initialized using one of the WCONxxxx keywords prior to
modifying the well using the WELTARG keyword. The following implementation of handling the WELTARG keyword does not check or enforce in any way that
this is done (i.e. it is not checked or verified that the well is initialized with any WCONxxxx keyword).
*/
void Schedule::handleWELTARG(DeckConstPtr deck, DeckKeywordConstPtr keyword, size_t currentStep) {
Opm::UnitSystem unitSystem = *deck->getActiveUnitSystem();
double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time")->getSIScaling();
double siFactorG = unitSystem.parse("GasSurfaceVolume/Time")->getSIScaling();
double siFactorP = unitSystem.parse("Pressure")->getSIScaling();
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellNamePattern = record->getItem("WELL")->getTrimmedString(0);
const std::string& cMode = record->getItem("CMODE")->getTrimmedString(0);
double newValue = record->getItem("NEW_VALUE")->getRawDouble(0);
double newValue = getNewValue(record);
const std::vector<WellPtr>& wells = getWells(wellNamePattern);
for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) {
@ -510,58 +515,34 @@ namespace Opm {
WellProductionProperties prop = well->getProductionPropertiesCopy(currentStep);
if (cMode == "ORAT"){
prop.OilRate = newValue;
prop.OilRate = newValue * siFactorL;
}
else if (cMode == "WRAT"){
prop.WaterRate = newValue;
prop.WaterRate = newValue * siFactorL;
}
else if (cMode == "GRAT"){
prop.GasRate = newValue;
prop.GasRate = newValue * siFactorG;
}
else if (cMode == "LRAT"){
prop.LiquidRate = newValue;
}
else if (cMode == "CRAT"){
prop.LinearlyCombinedRate = newValue;
prop.LiquidRate = newValue * siFactorL;
}
else if (cMode == "RESV"){
prop.ResVRate = newValue;
prop.ResVRate = newValue * siFactorL;
}
else if (cMode == "BHP"){
prop.BHPLimit = newValue;
prop.BHPLimit = newValue * siFactorP;
}
else if (cMode == "THP"){
prop.THPLimit = newValue;
prop.THPLimit = newValue * siFactorP;
}
else if (cMode == "VFP"){
prop.VFPTableNumber = newValue;
}
else if (cMode == "LIFT"){
prop.ArtificialLiftQuantity = newValue;
prop.VFPTableNumber = static_cast<int> (newValue);
}
else if (cMode == "GUID"){
prop.GuideRate = newValue;
well->setGuideRate(currentStep, newValue);
}
else if (cMode == "WGRA"){
prop.WetGasRate = newValue;
}
else if (cMode == "NGL"){
prop.NGLRate = newValue;
}
else if (cMode == "CVAL"){
prop.CalorificProductionRate = newValue;
}
else if (cMode == "REIN"){
prop.ReinjectionFraction = newValue;
}
else if (cMode == "STRA"){
prop.SteamRate = newValue;
}
else if (cMode == "SATP"){
prop.SaturationPressureOffset = newValue;
}
else if (cMode == "SATT"){
prop.SaturationTemperatureOffset = newValue;
else{
throw std::invalid_argument("Invalid keyword (MODE) supplied");
}
well->setProductionProperties(currentStep, prop);
@ -569,6 +550,20 @@ namespace Opm {
}
}
double Schedule::getNewValue(DeckRecordConstPtr record) {
double newValue = 0.0;
auto item = record->getItem("NEW_VALUE");
if (!item->hasValue(0)){
throw std::invalid_argument("Sorry - the value item in WELTARG can not be defaulted");
}
else{
newValue = item->getRawDouble(0);
}
return newValue;
}
void Schedule::handleGCONINJE(DeckConstPtr deck, DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
@ -600,7 +595,6 @@ namespace Opm {
}
}
void Schedule::handleGCONPROD(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
@ -673,9 +667,6 @@ namespace Opm {
m_rootGroupTree->add(currentStep, newTree);
}
//
//
void Schedule::handleWRFT(DeckKeywordConstPtr keyword, size_t currentStep) {
/* Rule for handling RFT: Request current RFT data output for specified wells, plus output when
@ -704,8 +695,6 @@ namespace Opm {
}
}
void Schedule::handleWRFTPLT(DeckKeywordConstPtr keyword, size_t currentStep) {
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
@ -752,7 +741,6 @@ namespace Opm {
well->setPLTActive(currentStep, false);
break;
}
}
}
}
@ -790,12 +778,10 @@ namespace Opm {
return wells.size();
}
bool Schedule::hasWell(const std::string& wellName) const {
return m_wells.hasKey( wellName );
}
std::vector<WellConstPtr> Schedule::getWells() const {
return getWells(m_timeMap->size()-1);
}
@ -815,7 +801,6 @@ namespace Opm {
return wells;
}
WellPtr Schedule::getWell(const std::string& wellName) const {
return m_wells.get( wellName );
}
@ -837,8 +822,6 @@ namespace Opm {
return wells;
}
void Schedule::addGroup(const std::string& groupName, size_t timeStep) {
if (!m_timeMap) {
throw std::invalid_argument("TimeMap is null, can't add group named: " + groupName);
@ -872,7 +855,6 @@ namespace Opm {
newGroup->addWell(timeStep , well);
}
void Schedule::checkUnhandledKeywords(DeckConstPtr deck) const {
if (deck->hasKeyword("COMPORD")) {
auto compordKeyword = deck->getKeyword("COMPORD");
@ -884,7 +866,6 @@ namespace Opm {
}
}
double Schedule::convertInjectionRateToSI(double rawRate, WellInjector::TypeEnum wellType, const Opm::UnitSystem &unitSystem) {
switch (wellType) {
case WellInjector::MULTI:
@ -920,7 +901,6 @@ namespace Opm {
}
}
bool Schedule::convertEclipseStringToBool(const std::string& eclipseString) {
std::string lowerTrimmed = boost::algorithm::to_lower_copy(eclipseString);
boost::algorithm::trim(lowerTrimmed);
@ -934,7 +914,6 @@ namespace Opm {
else throw std::invalid_argument("String " + eclipseString + " not recognized as a boolean-convertible string.");
}
size_t Schedule::getMaxNumCompletionsForWells(size_t timestep) const {
size_t ncwmax = 0;
const std::vector<WellConstPtr>& wells = getWells();

View File

@ -86,7 +86,7 @@ namespace Opm
void handleWPOLYMER(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWCONINJH(DeckConstPtr deck, DeckKeywordConstPtr keyword, size_t currentStep);
void handleWELOPEN(DeckKeywordConstPtr keyword, size_t currentStep, bool hascomplump);
void handleWELTARG(DeckKeywordConstPtr keyword, size_t currentStep);
void handleWELTARG(DeckConstPtr deck, DeckKeywordConstPtr keyword, size_t currentStep);
void handleGCONINJE(DeckConstPtr deck, DeckKeywordConstPtr keyword, size_t currentStep);
void handleGCONPROD(DeckKeywordConstPtr keyword, size_t currentStep);
void handleDATES(DeckKeywordConstPtr keyword);
@ -99,6 +99,7 @@ namespace Opm
static double convertInjectionRateToSI(double rawRate, WellInjector::TypeEnum wellType, const Opm::UnitSystem &unitSystem);
static double convertInjectionRateToSI(double rawRate, Phase::PhaseEnum wellPhase, const Opm::UnitSystem &unitSystem);
double getNewValue(DeckRecordConstPtr record);
static bool convertEclipseStringToBool(const std::string& eclipseString);
};

View File

@ -115,23 +115,13 @@ namespace Opm {
void WellProductionProperties::init() {
OilRate = 0.0;
GasRate = 0.0;
WaterRate = 0.0;
GasRate = 0.0;
LiquidRate = 0.0;
LinearlyCombinedRate = 0.0;
ResVRate = 0.0;
BHPLimit = 0.0;
THPLimit = 0.0;
VFPTableNumber = 0.0;
ArtificialLiftQuantity = 0.0;
GuideRate = 0.0;
WetGasRate = 0.0;
NGLRate = 0.0;
CalorificProductionRate = 0.0;
ReinjectionFraction = 0.0;
SteamRate = 0.0;
SaturationPressureOffset = 0.0;
SaturationTemperatureOffset = 0.0;
VFPTableNumber = 0;
controlMode = WellProducer::CMODE_UNDEFINED;
m_productionControls = 0;

View File

@ -26,23 +26,13 @@
namespace Opm {
struct WellProductionProperties {
double OilRate;
double GasRate;
double WaterRate;
double GasRate;
double LiquidRate;
double LinearlyCombinedRate;
double ResVRate;
double BHPLimit;
double THPLimit;
double VFPTableNumber;
double ArtificialLiftQuantity;
double GuideRate;
double WetGasRate;
double NGLRate;
double CalorificProductionRate;
double ReinjectionFraction;
double SteamRate;
double SaturationPressureOffset;
double SaturationTemperatureOffset;
int VFPTableNumber;
bool predictionMode;
WellProducer::ControlModeEnum controlMode;

View File

@ -69,7 +69,6 @@ static DeckPtr createDeckWithWells() {
return parser.parseString(input);
}
static DeckPtr createDeckWithWellsOrdered() {
Opm::Parser parser;
std::string input =
@ -85,7 +84,6 @@ static DeckPtr createDeckWithWellsOrdered() {
return parser.parseString(input);
}
static DeckPtr createDeckWithWellsAndCompletionData() {
Opm::Parser parser;
std::string input =
@ -117,11 +115,9 @@ static DeckPtr createDeckWithWellsAndCompletionData() {
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
"/\n";
return parser.parseString(input);
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) {
DeckPtr deck(new Deck());
DeckKeywordPtr keyword(new DeckKeyword("SCHEDULE"));
@ -131,7 +127,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) {
BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1983 , boost::gregorian::Jan , 1)));
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) {
DeckPtr deck = createDeckWithWellsOrdered();
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(100,100,100);
@ -143,8 +138,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) {
BOOST_CHECK_EQUAL( "AW_3" , wells[2]->name());
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) {
DeckPtr deck = createDeck();
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
@ -152,7 +145,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) {
BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1998 , boost::gregorian::Mar , 8)));
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithSCHEDULENoThrow) {
DeckPtr deck(new Deck());
DeckKeywordPtr keyword(new DeckKeyword("SCHEDULE"));
@ -162,7 +154,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithSCHEDULENoThrow) {
BOOST_CHECK_NO_THROW(Schedule schedule(grid , deck));
}
BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeck();
@ -172,7 +163,6 @@ BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) {
BOOST_CHECK_THROW( schedule.getWell("WELL2") , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithoutGRUPTREE_HasRootGroupTreeNodeForTimeStepZero) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeck();
@ -180,7 +170,6 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithoutGRUPTREE_HasRootGroupTreeNodeForT
BOOST_CHECK_EQUAL("FIELD", schedule.getGroupTree(0)->getNode("FIELD")->name());
}
BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithGRUPTREE_HasRootGroupTreeNodeForTimeStepZero) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeck();
@ -203,9 +192,6 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithGRUPTREE_HasRootGroupTreeNodeForTime
BOOST_CHECK(FAREN->hasChildGroup("BARNET"));
}
BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeck();
@ -242,7 +228,6 @@ BOOST_AUTO_TEST_CASE(WellsIterator_HasWells_WellsReturned) {
BOOST_CHECK_EQUAL(3U, wells_t3.size());
}
BOOST_AUTO_TEST_CASE(WellsIteratorWithRegex_HasWells_WellsReturned) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeckWithWells();
@ -337,8 +322,6 @@ static DeckPtr createDeckWithWellsAndCompletionDataWithWELOPEN() {
return parser.parseString(input);
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) {
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>(10,10,10);
DeckPtr deck = createDeckWithWellsAndCompletionDataWithWELOPEN();
@ -406,12 +389,8 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) {
currentStep = 5;
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep));
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_TryToOpenWellWithShutCompletionsDoNotOpenWell) {
Opm::Parser parser;
std::string input =
@ -459,7 +438,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_TryToOpenWellWithShutCompleti
BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep));
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithCOMPLUMPwithC1_ThrowsExcpetion) {
Opm::Parser parser;
std::string input =
@ -651,7 +629,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFT) {
}
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFTPLT) {
Opm::Parser parser;
std::string input =
@ -738,26 +715,17 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) {
"WELTARG\n"
" OP_1 ORAT 1300 /\n"
" OP_1 WRAT 1400 /\n"
" OP_1 GRAT 1500 /\n"
" OP_1 GRAT 1500.52 /\n"
" OP_1 LRAT 1600.58 /\n"
" OP_1 CRAT 1722.15 /\n"
" OP_1 RESV 1801.05 /\n"
" OP_1 BHP 1900 /\n"
" OP_1 THP 2000 /\n"
" OP_1 VFP 2100 /\n"
" OP_1 LIFT 2200 /\n"
" OP_1 GUID 2300 /\n"
" OP_1 WGRA 2490.09 /\n"
" OP_1 NGL 2519.51 /\n"
" OP_1 CVAL 2600 /\n"
" OP_1 REIN 2700 /\n"
" OP_1 STRA 2800 /\n"
" OP_1 SATP 2900 /\n"
" OP_1 SATT 3000 /\n"
" OP_1 VFP 2100.09 /\n"
" OP_1 GUID 2300.14 /\n"
"/\n";
DeckPtr deck = parser.parseString(input);
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>( 10 , 10 , 10 );
std::shared_ptr<const EclipseGrid> grid = std::make_shared<const EclipseGrid>( 10 , 10 , 10 );
Schedule schedule(grid , deck);
WellPtr well = schedule.getWell("OP_1");
@ -765,24 +733,20 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) {
WellProductionProperties wpp = well->getProductionProperties(currentStep);
BOOST_CHECK_EQUAL(wpp.WaterRate,0);
Opm::UnitSystem unitSystem = *deck->getActiveUnitSystem();
double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time")->getSIScaling();
double siFactorG = unitSystem.parse("GasSurfaceVolume/Time")->getSIScaling();
double siFactorP = unitSystem.parse("Pressure")->getSIScaling();
currentStep = 2;
wpp = well->getProductionProperties(currentStep);
BOOST_CHECK_EQUAL(wpp.OilRate, 1300);
BOOST_CHECK_EQUAL(wpp.WaterRate, 1400);
BOOST_CHECK_EQUAL(wpp.GasRate, 1500);
BOOST_CHECK_EQUAL(wpp.LiquidRate, 1600.58);
BOOST_CHECK_EQUAL(wpp.LinearlyCombinedRate, 1722.15);
BOOST_CHECK_EQUAL(wpp.ResVRate, 1801.05);
BOOST_CHECK_EQUAL(wpp.BHPLimit, 1900);
BOOST_CHECK_EQUAL(wpp.THPLimit, 2000);
BOOST_CHECK_EQUAL(wpp.OilRate, 1300 * siFactorL);
BOOST_CHECK_EQUAL(wpp.WaterRate, 1400 * siFactorL);
BOOST_CHECK_EQUAL(wpp.GasRate, 1500.52 * siFactorG);
BOOST_CHECK_EQUAL(wpp.LiquidRate, 1600.58 * siFactorL);
BOOST_CHECK_EQUAL(wpp.ResVRate, 1801.05 * siFactorL);
BOOST_CHECK_EQUAL(wpp.BHPLimit, 1900 * siFactorP);
BOOST_CHECK_EQUAL(wpp.THPLimit, 2000 * siFactorP);
BOOST_CHECK_EQUAL(wpp.VFPTableNumber, 2100);
BOOST_CHECK_EQUAL(wpp.ArtificialLiftQuantity, 2200);
BOOST_CHECK_EQUAL(wpp.GuideRate, 2300);
BOOST_CHECK_EQUAL(wpp.WetGasRate, 2490.09);
BOOST_CHECK_EQUAL(wpp.NGLRate, 2519.51);
BOOST_CHECK_EQUAL(wpp.CalorificProductionRate, 2600);
BOOST_CHECK_EQUAL(wpp.ReinjectionFraction, 2700);
BOOST_CHECK_EQUAL(wpp.SteamRate, 2800);
BOOST_CHECK_EQUAL(wpp.SaturationPressureOffset, 2900);
BOOST_CHECK_EQUAL(wpp.SaturationTemperatureOffset, 3000);
BOOST_CHECK_EQUAL(well->getGuideRate(2), 2300.14);
}