RawKeywordPtr Parser::createRawKeyword(const DeckConstPtr deck, const std::string& filename , size_t lineNR , const std::string& keywordString, bool strictParsing) const { if (hasKeyword(keywordString)) { ParserKeywordConstPtr parserKeyword = m_parserKeywords.find(keywordString)->second; ParserKeywordActionEnum action = parserKeyword->getAction(); if (action == THROW_EXCEPTION) throw std::invalid_argument("Parsing terminated by fatal keyword: " + keywordString); if (parserKeyword->getSizeType() == SLASH_TERMINATED) return RawKeywordPtr(new RawKeyword(keywordString , filename , lineNR)); else { size_t targetSize; if (parserKeyword->hasFixedSize()) targetSize = parserKeyword->getFixedSize(); else { const std::pair<std::string, std::string> sizeKeyword = parserKeyword->getSizeDefinitionPair(); DeckKeywordConstPtr sizeDefinitionKeyword = deck->getKeyword(sizeKeyword.first); DeckItemConstPtr sizeDefinitionItem; { DeckRecordConstPtr record = sizeDefinitionKeyword->getRecord(0); sizeDefinitionItem = record->getItem(sizeKeyword.second); } targetSize = sizeDefinitionItem->getInt(0); } return RawKeywordPtr(new RawKeyword(keywordString, filename , lineNR , targetSize , parserKeyword->isTableCollection())); } } else { if (strictParsing) { throw std::invalid_argument("Keyword " + keywordString + " not recognized "); } else { return RawKeywordPtr(new RawKeyword(keywordString, filename , lineNR , 0)); } } }
void PolymerInflowFromDeck::setInflowValues(Opm::DeckConstPtr deck, Opm::EclipseStateConstPtr eclipseState, size_t currentStep) { Opm::DeckKeywordConstPtr keyword = deck->getKeyword("WPOLYMER"); // Schedule schedule(deck); ScheduleConstPtr schedule = eclipseState->getSchedule(); for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) { DeckRecordConstPtr record = keyword->getRecord(recordNr); const std::string& wellNamesPattern = record->getItem("WELL")->getTrimmedString(0); std::string wellName = record->getItem("WELL")->getTrimmedString(0); std::vector<WellPtr> wells = schedule->getWells(wellNamesPattern); for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter) { WellPtr well = *wellIter; WellInjectionProperties injection = well->getInjectionProperties(currentStep); if (injection.injectorType == WellInjector::WATER) { WellPolymerProperties polymer = well->getPolymerProperties(currentStep); wellPolymerRate_.insert(std::make_pair(wellName, polymer.m_polymerConcentration)); } else { OPM_THROW(std::logic_error, "For polymer injector you must have a water injector"); } } } }
WellProductionProperties:: WellProductionProperties(DeckRecordConstPtr record) { init(); WaterRate = record->getItem("WRAT")->getSIDouble(0); OilRate = record->getItem("ORAT")->getSIDouble(0); GasRate = record->getItem("GRAT")->getSIDouble(0); }
void EclipseState::initTitle(DeckConstPtr deck){ if (deck->hasKeyword("TITLE")) { DeckKeywordConstPtr titleKeyword = deck->getKeyword("TITLE"); DeckRecordConstPtr record = titleKeyword->getRecord(0); DeckItemPtr item = record->getItem(0); std::vector<std::string> itemValue = item->getStringData(); m_title = boost::algorithm::join(itemValue, " "); } }
std::pair<std::string , std::vector<CompletionPtr> > Completion::completionsFromCOMPDATRecord( DeckRecordConstPtr compdatRecord ) { std::vector<CompletionPtr> completions; std::string well = compdatRecord->getItem("WELL")->getTrimmedString(0); // We change from eclipse's 1 - n, to a 0 - n-1 solution int I = compdatRecord->getItem("I")->getInt(0) - 1; int J = compdatRecord->getItem("J")->getInt(0) - 1; int K1 = compdatRecord->getItem("K1")->getInt(0) - 1; int K2 = compdatRecord->getItem("K2")->getInt(0) - 1; CompletionStateEnum state = CompletionStateEnumFromString( compdatRecord->getItem("STATE")->getTrimmedString(0) ); { DeckItemConstPtr CFItem = compdatRecord->getItem("CF"); if (CFItem->defaultApplied()) throw std::invalid_argument("The connection factor item can not be defaulted"); } double CF = compdatRecord->getItem("CF")->getSIDouble(0); double diameter = compdatRecord->getItem("DIAMETER")->getSIDouble(0); double skinFactor = compdatRecord->getItem("SKIN")->getRawDouble(0); for (int k = K1; k <= K2; k++) { CompletionPtr completion(new Completion(I , J , k , state , CF, diameter, skinFactor )); completions.push_back( completion ); } return std::pair<std::string , std::vector<CompletionPtr> >( well , completions ); }
WellProductionProperties WellProductionProperties::history(DeckRecordConstPtr record) { WellProductionProperties p(record); p.predictionMode = false; // Modes supported in WCONHIST just from {O,W,G}RAT values // // Note: The default value of observed {O,W,G}RAT is zero // (numerically) whence the following control modes are // unconditionally supported. const std::vector<std::string> controlModes{ "ORAT", "WRAT", "GRAT", "LRAT", "RESV" }; for (std::vector<std::string>::const_iterator mode = controlModes.begin(), end = controlModes.end(); mode != end; ++mode) { const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString(*mode); p.addProductionControl(cmode); } // BHP control must be explictly provided. if (!record->getItem("BHP")->defaultApplied(0)) { p.addProductionControl(WellProducer::BHP); } { const auto cmodeItem = record->getItem("CMODE"); if (!cmodeItem->defaultApplied(0)) { const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem->getString(0) ); if (p.hasProductionControl( cmode )) p.controlMode = cmode; else throw std::invalid_argument("Setting CMODE to unspecified control"); } } return p; }
void TimeMap::addFromTSTEPKeyword( DeckKeywordConstPtr TSTEPKeyword ) { if (TSTEPKeyword->name() != "TSTEP") throw std::invalid_argument("Method requires TSTEP keyword input."); { DeckRecordConstPtr record = TSTEPKeyword->getRecord( 0 ); DeckItemConstPtr item = record->getItem( 0 ); for (size_t itemIndex = 0; itemIndex < item->size(); itemIndex++) { double days = item->getRawDouble( itemIndex ); long int wholeSeconds = static_cast<long int>(days * 24*60*60); long int milliSeconds = static_cast<long int>((days * 24*60*60 - wholeSeconds)*1000); boost::posix_time::time_duration step = boost::posix_time::seconds(wholeSeconds) + boost::posix_time::milliseconds(milliSeconds); addTStep( step ); } } }
boost::posix_time::ptime TimeMap::timeFromEclipse(DeckRecordConstPtr dateRecord) { static const std::string errorMsg("The datarecord must consist of the for values " "\"DAY(int), MONTH(string), YEAR(int), TIME(string)\".\n"); if (dateRecord->size() != 4) { throw std::invalid_argument( errorMsg); } DeckItemConstPtr dayItem = dateRecord->getItem( 0 ); DeckItemConstPtr monthItem = dateRecord->getItem( 1 ); DeckItemConstPtr yearItem = dateRecord->getItem( 2 ); DeckItemConstPtr timeItem = dateRecord->getItem( 3 ); try { int day = dayItem->getInt(0); const std::string& month = monthItem->getString(0); int year = yearItem->getInt(0); std::string eclipseTimeString = timeItem->getString(0); return TimeMap::timeFromEclipse(day, month, year, eclipseTimeString); } catch (...) { throw std::invalid_argument( errorMsg ); } }
WellProductionProperties WellProductionProperties::prediction(DeckRecordConstPtr record) { WellProductionProperties p(record); p.predictionMode = true; p.LiquidRate = record->getItem("LRAT" )->getSIDouble(0); p.ResVRate = record->getItem("RESV" )->getSIDouble(0); p.BHPLimit = record->getItem("BHP" )->getSIDouble(0); p.THPLimit = record->getItem("THP" )->getSIDouble(0); p.ALQValue = record->getItem("ALQ" )->getRawDouble(0); //NOTE: Unit of ALQ is never touched p.VFPTableNumber = record->getItem("VFP_TABLE")->getInt(0); const std::vector<std::string> controlModes{ "ORAT", "WRAT", "GRAT", "LRAT", "RESV", "BHP" , "THP" }; for (std::vector<std::string>::const_iterator mode = controlModes.begin(), end = controlModes.end(); mode != end; ++mode) { if (!record->getItem(*mode)->defaultApplied(0)) { const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString(*mode); p.addProductionControl(cmode); } } { const auto cmodeItem = record->getItem("CMODE"); if (cmodeItem->hasValue(0)) { const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem->getString(0) ); if (p.hasProductionControl( cmode )) p.controlMode = cmode; else throw std::invalid_argument("Setting CMODE to unspecified control"); } } return p; }
/*! * \brief Implement the temperature part of the oil PVT properties. */ void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr eclState) { ////// // initialize the isothermal part ////// isothermalPvt_ = new IsothermalPvt; isothermalPvt_->initFromDeck(deck, eclState); ////// // initialize the thermal part ////// auto tables = eclState->getTableManager(); enableThermalDensity_ = deck->hasKeyword("THERMEX1"); enableThermalViscosity_ = deck->hasKeyword("VISCREF"); unsigned numRegions = isothermalPvt_->numRegions(); setNumRegions(numRegions); // viscosity if (deck->hasKeyword("VISCREF")) { const auto& oilvisctTables = tables->getOilvisctTables(); Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword("VISCREF"); assert(oilvisctTables.size() == numRegions); assert(viscrefKeyword->size() == numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& TCol = oilvisctTables[regionIdx].getColumn("Temperature").vectorCopy(); const auto& muCol = oilvisctTables[regionIdx].getColumn("Viscosity").vectorCopy(); oilvisctCurves_[regionIdx].setXYContainers(TCol, muCol); DeckRecordConstPtr viscrefRecord = viscrefKeyword->getRecord(regionIdx); viscrefPress_[regionIdx] = viscrefRecord->getItem("REFERENCE_PRESSURE")->getSIDouble(0); viscrefRs_[regionIdx] = viscrefRecord->getItem("REFERENCE_RS")->getSIDouble(0); // temperature used to calculate the reference viscosity [K]. the // value does not really matter if the underlying PVT object really // is isothermal... Scalar Tref = 273.15 + 20; // compute the reference viscosity using the isothermal PVT object. viscRef_[regionIdx] = isothermalPvt_->viscosity(regionIdx, Tref, viscrefPress_[regionIdx], viscrefRs_[regionIdx]); } } // quantities required for density. note that we just always use the values // for the first EOS. (since EOS != PVT region.) refTemp_ = 0.0; if (deck->hasKeyword("THERMEX1")) { int oilCompIdx = deck->getKeyword("OCOMPIDX")->getRecord(0)->getItem("OIL_COMPONENT_INDEX")->getInt(0) - 1; // always use the values of the first EOS refTemp_ = deck->getKeyword("TREF")->getRecord(0)->getItem("TEMPERATURE")->getSIDouble(oilCompIdx); refPress_ = deck->getKeyword("PREF")->getRecord(0)->getItem("PRESSURE")->getSIDouble(oilCompIdx); refC_ = deck->getKeyword("CREF")->getRecord(0)->getItem("COMPRESSIBILITY")->getSIDouble(oilCompIdx); thermex1_ = deck->getKeyword("THERMEX1")->getRecord(0)->getItem("EXPANSION_COEFF")->getSIDouble(oilCompIdx); } }