/*! * \brief Initialize the oil parameters via the data specified by the PVDO ECL keyword. */ void initFromDeck(const Deck& deck, const EclipseState& eclState) { const auto& pvdoTables = eclState.getTableManager().getPvdoTables(); const auto& densityKeyword = deck.getKeyword("DENSITY"); assert(pvdoTables.size() == densityKeyword.size()); size_t numRegions = pvdoTables.size(); setNumRegions(numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) { Scalar rhoRefO = densityKeyword.getRecord(regionIdx).getItem("OIL").getSIDouble(0); Scalar rhoRefG = densityKeyword.getRecord(regionIdx).getItem("GAS").getSIDouble(0); Scalar rhoRefW = densityKeyword.getRecord(regionIdx).getItem("WATER").getSIDouble(0); setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW); const auto& pvdoTable = pvdoTables.getTable<PvdoTable>(regionIdx); const auto& BColumn(pvdoTable.getFormationFactorColumn()); std::vector<Scalar> invBColumn(BColumn.size()); for (unsigned i = 0; i < invBColumn.size(); ++i) invBColumn[i] = 1/BColumn[i]; inverseOilB_[regionIdx].setXYArrays(pvdoTable.numRows(), pvdoTable.getPressureColumn(), invBColumn); oilMu_[regionIdx].setXYArrays(pvdoTable.numRows(), pvdoTable.getPressureColumn(), pvdoTable.getViscosityColumn()); } initEnd(); }
/*! * \brief Implement the temperature part of the water PVT properties. */ void initFromDeck(const Deck& deck, const EclipseState& eclState) { ////// // initialize the isothermal part ////// isothermalPvt_ = new IsothermalPvt; isothermalPvt_->initFromDeck(deck, eclState); ////// // initialize the thermal part ////// const auto& tables = eclState.getTableManager(); enableThermalDensity_ = deck.hasKeyword("WATDENT"); enableThermalViscosity_ = deck.hasKeyword("VISCREF"); unsigned numRegions = isothermalPvt_->numRegions(); setNumRegions(numRegions); if (enableThermalDensity_) { const auto& watdentKeyword = deck.getKeyword("WATDENT"); assert(watdentKeyword.size() == numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& watdentRecord = watdentKeyword.getRecord(regionIdx); watdentRefTemp_[regionIdx] = watdentRecord.getItem("REFERENCE_TEMPERATURE").getSIDouble(0); watdentCT1_[regionIdx] = watdentRecord.getItem("EXPANSION_COEFF_LINEAR").getSIDouble(0); watdentCT2_[regionIdx] = watdentRecord.getItem("EXPANSION_COEFF_QUADRATIC").getSIDouble(0); } } if (enableThermalViscosity_) { const auto& viscrefKeyword = deck.getKeyword("VISCREF"); const auto& watvisctTables = tables.getWatvisctTables(); assert(watvisctTables.size() == numRegions); assert(viscrefKeyword.size() == numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) { const auto& T = watvisctTables[regionIdx].getColumn("Temperature").vectorCopy(); const auto& mu = watvisctTables[regionIdx].getColumn("Viscosity").vectorCopy(); watvisctCurves_[regionIdx].setXYContainers(T, mu); const auto& viscrefRecord = viscrefKeyword.getRecord(regionIdx); viscrefPress_[regionIdx] = viscrefRecord.getItem("REFERENCE_PRESSURE").getSIDouble(0); } } }
/*! * \brief Initialize the parameters for dry gas using an ECL deck. * * This method assumes that the deck features valid DENSITY and PVDG keywords. */ void initFromDeck(DeckConstPtr deck, EclipseStateConstPtr eclState) { const auto& pvdgTables = eclState->getTableManager()->getPvdgTables(); const auto& densityKeyword = deck->getKeyword("DENSITY"); assert(pvdgTables.size() == densityKeyword.size()); size_t numRegions = pvdgTables.size(); setNumRegions(numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) { Scalar rhoRefO = densityKeyword.getRecord(regionIdx).getItem("OIL").getSIDouble(0); Scalar rhoRefG = densityKeyword.getRecord(regionIdx).getItem("GAS").getSIDouble(0); Scalar rhoRefW = densityKeyword.getRecord(regionIdx).getItem("WATER").getSIDouble(0); setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW); // determine the molar masses of the components Scalar p = 1.01325e5; // surface pressure, [Pa] Scalar T = 273.15 + 15.56; // surface temperature, [K] Scalar MO = 175e-3; // [kg/mol] Scalar MG = Opm::Constants<Scalar>::R*T*rhoRefG / p; // [kg/mol], consequence of the ideal gas law Scalar MW = 18.0e-3; // [kg/mol] // TODO (?): the molar mass of the components can possibly specified // explicitly in the deck. setMolarMasses(regionIdx, MO, MG, MW); const auto& pvdgTable = pvdgTables.getTable<PvdgTable>(regionIdx); // say 99.97% of all time: "premature optimization is the root of all // evil". Eclipse does this "optimization" for apparently no good reason! std::vector<Scalar> invB(pvdgTable.numRows()); const auto& Bg = pvdgTable.getFormationFactorColumn(); for (unsigned i = 0; i < Bg.size(); ++ i) { invB[i] = 1.0/Bg[i]; } size_t numSamples = invB.size(); inverseGasB_[regionIdx].setXYArrays(numSamples, pvdgTable.getPressureColumn(), invB); gasMu_[regionIdx].setXYArrays(numSamples, pvdgTable.getPressureColumn(), pvdgTable.getViscosityColumn()); } initEnd(); }
/*! * \brief Implement the temperature part of the gas 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("TREF"); enableThermalViscosity_ = deck->hasKeyword("GASVISCT"); unsigned numRegions = isothermalPvt_->numRegions(); setNumRegions(numRegions); // viscosity if (enableThermalViscosity_) { const auto& gasvisctTables = tables->getGasvisctTables(); Opm::DeckKeywordConstPtr viscrefKeyword = deck->getKeyword("VISCREF"); int gasCompIdx = deck->getKeyword("GCOMPIDX")->getRecord(0)->getItem("GAS_COMPONENT_INDEX")->getInt(0) - 1; std::string gasvisctColumnName = "Viscosity"+std::to_string(static_cast<long long>(gasCompIdx)); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& T = gasvisctTables[regionIdx].getColumn("Temperature").vectorCopy(); const auto& mu = gasvisctTables[regionIdx].getColumn(gasvisctColumnName).vectorCopy(); gasvisctCurves_[regionIdx].setXYContainers(T, mu); } } // quantities required for density. note that we just always use the values // for the first EOS. (since EOS != PVT region.) refTemp_ = 0.0; if (enableThermalDensity_) { refTemp_ = deck->getKeyword("TREF")->getRecord(0)->getItem("TEMPERATURE")->getSIDouble(0); } }
/*! * \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); } }
/*! * \brief Implement the temperature part of the oil PVT properties. */ void initFromDeck(const Deck& deck, const EclipseState& eclState) { ////// // initialize the isothermal part ////// isothermalPvt_ = new IsothermalPvt; isothermalPvt_->initFromDeck(deck, eclState); ////// // initialize the thermal part ////// const auto& tables = eclState.getTableManager(); enableThermalDensity_ = deck.hasKeyword("OILDENT"); enableThermalViscosity_ = deck.hasKeyword("OILVISCT"); enableInternalEnergy_ = deck.hasKeyword("SPECHEAT"); unsigned numRegions = isothermalPvt_->numRegions(); setNumRegions(numRegions); // viscosity if (deck.hasKeyword("OILVISCT")) { if (!deck.hasKeyword("VISCREF")) throw std::runtime_error("VISCREF is required when OILVISCT is present"); const auto& oilvisctTables = tables.getOilvisctTables(); const auto& 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); const auto& 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]); } } // temperature dependence of oil density if (enableThermalDensity_) { const auto& oildentKeyword = deck.getKeyword("OILDENT"); assert(oildentKeyword.size() == numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& oildentRecord = oildentKeyword.getRecord(regionIdx); oildentRefTemp_[regionIdx] = oildentRecord.getItem("REFERENCE_TEMPERATURE").getSIDouble(0); oildentCT1_[regionIdx] = oildentRecord.getItem("EXPANSION_COEFF_LINEAR").getSIDouble(0); oildentCT2_[regionIdx] = oildentRecord.getItem("EXPANSION_COEFF_QUADRATIC").getSIDouble(0); } } if (deck.hasKeyword("SPECHEAT")) { // the specific internal energy of liquid oil. be aware that ecl only specifies the // heat capacity (via the SPECHEAT keyword) and we need to integrate it // ourselfs to get the internal energy for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& specheatTable = tables.getSpecheatTables()[regionIdx]; const auto& temperatureColumn = specheatTable.getColumn("TEMPERATURE"); const auto& cvOilColumn = specheatTable.getColumn("CV_OIL"); std::vector<double> uSamples(temperatureColumn.size()); Scalar u = temperatureColumn[0]*cvOilColumn[0]; for (size_t i = 0;; ++i) { uSamples[i] = u; if (i >= temperatureColumn.size() - 1) break; // integrate to the heat capacity from the current sampling point to the next // one. this leads to a quadratic polynomial. Scalar c_v0 = cvOilColumn[i]; Scalar c_v1 = cvOilColumn[i + 1]; Scalar T0 = temperatureColumn[i]; Scalar T1 = temperatureColumn[i + 1]; u += 0.5*(c_v0 + c_v1)*(T1 - T0); } internalEnergyCurves_[regionIdx].setXYContainers(temperatureColumn.vectorCopy(), uSamples); } } }
/*! * \brief Initialize the oil parameters via the data specified by the PVTO ECL keyword. */ void initFromDeck(const Deck& deck, const EclipseState& eclState) { const auto& pvtoTables = eclState.getTableManager().getPvtoTables(); const auto& densityKeyword = deck.getKeyword("DENSITY"); assert(pvtoTables.size() == densityKeyword.size()); size_t numRegions = pvtoTables.size(); setNumRegions(numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) { Scalar rhoRefO = densityKeyword.getRecord(regionIdx).getItem("OIL").getSIDouble(0); Scalar rhoRefG = densityKeyword.getRecord(regionIdx).getItem("GAS").getSIDouble(0); Scalar rhoRefW = densityKeyword.getRecord(regionIdx).getItem("WATER").getSIDouble(0); setReferenceDensities(regionIdx, rhoRefO, rhoRefG, rhoRefW); } // initialize the internal table objects for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) { const auto& pvtoTable = pvtoTables[regionIdx]; const auto& saturatedTable = pvtoTable.getSaturatedTable(); assert(saturatedTable.numRows() > 1); auto& oilMu = oilMuTable_[regionIdx]; auto& satOilMu = saturatedOilMuTable_[regionIdx]; auto& invOilB = inverseOilBTable_[regionIdx]; auto& invSatOilB = inverseSaturatedOilBTable_[regionIdx]; auto& gasDissolutionFac = saturatedGasDissolutionFactorTable_[regionIdx]; std::vector<Scalar> invSatOilBArray; std::vector<Scalar> satOilMuArray; // extract the table for the gas dissolution and the oil formation volume factors for (unsigned outerIdx = 0; outerIdx < saturatedTable.numRows(); ++ outerIdx) { Scalar Rs = saturatedTable.get("RS", outerIdx); Scalar BoSat = saturatedTable.get("BO", outerIdx); Scalar muoSat = saturatedTable.get("MU", outerIdx); satOilMuArray.push_back(muoSat); invSatOilBArray.push_back(1.0/BoSat); invOilB.appendXPos(Rs); oilMu.appendXPos(Rs); assert(invOilB.numX() == outerIdx + 1); assert(oilMu.numX() == outerIdx + 1); const auto& underSaturatedTable = pvtoTable.getUnderSaturatedTable(outerIdx); size_t numRows = underSaturatedTable.numRows(); for (unsigned innerIdx = 0; innerIdx < numRows; ++ innerIdx) { Scalar po = underSaturatedTable.get("P", innerIdx); Scalar Bo = underSaturatedTable.get("BO", innerIdx); Scalar muo = underSaturatedTable.get("MU", innerIdx); invOilB.appendSamplePoint(outerIdx, po, 1.0/Bo); oilMu.appendSamplePoint(outerIdx, po, muo); } } // update the tables for the formation volume factor and for the gas // dissolution factor of saturated oil { const auto& tmpPressureColumn = saturatedTable.getColumn("P"); const auto& tmpGasSolubilityColumn = saturatedTable.getColumn("RS"); invSatOilB.setXYContainers(tmpPressureColumn, invSatOilBArray); satOilMu.setXYContainers(tmpPressureColumn, satOilMuArray); gasDissolutionFac.setXYContainers(tmpPressureColumn, tmpGasSolubilityColumn); } updateSaturationPressure_(regionIdx); // make sure to have at least two sample points per Rs value for (unsigned xIdx = 0; xIdx < invOilB.numX(); ++xIdx) { // a single sample point is definitely needed assert(invOilB.numY(xIdx) > 0); // everything is fine if the current table has two or more sampling points // for a given mole fraction if (invOilB.numY(xIdx) > 1) continue; // find the master table which will be used as a template to extend the // current line. We define master table as the first table which has values // for undersaturated oil... size_t masterTableIdx = xIdx + 1; for (; masterTableIdx < saturatedTable.numRows(); ++masterTableIdx) { if (pvtoTable.getUnderSaturatedTable(masterTableIdx).numRows() > 1) break; } if (masterTableIdx >= saturatedTable.numRows()) throw std::runtime_error("PVTO tables are invalid: The last table must exhibit at least one " "entry for undersaturated oil!"); // extend the current table using the master table. extendPvtoTable_(regionIdx, xIdx, pvtoTable.getUnderSaturatedTable(xIdx), pvtoTable.getUnderSaturatedTable(masterTableIdx)); } } vapPar2_ = 0.0; if (deck.hasKeyword("VAPPARS")) { const auto& vapParsKeyword = deck.getKeyword("VAPPARS"); vapPar2_ = vapParsKeyword.getRecord(0).getItem("OIL_DENSITY_PROPENSITY").template get<double>(0); } initEnd(); }
/*! * \brief Implement the temperature part of the gas PVT properties. */ void initFromDeck(const Deck& deck, const EclipseState& eclState) { ////// // initialize the isothermal part ////// isothermalPvt_ = new IsothermalPvt; isothermalPvt_->initFromDeck(deck, eclState); ////// // initialize the thermal part ////// const auto& tables = eclState.getTableManager(); enableThermalDensity_ = deck.hasKeyword("GASDENT"); enableThermalViscosity_ = deck.hasKeyword("GASVISCT"); enableInternalEnergy_ = deck.hasKeyword("SPECHEAT"); unsigned numRegions = isothermalPvt_->numRegions(); setNumRegions(numRegions); // viscosity if (enableThermalViscosity_) { const auto& gasvisctTables = tables.getGasvisctTables(); int gasCompIdx = deck.getKeyword("GCOMPIDX").getRecord(0).getItem("GAS_COMPONENT_INDEX").get< int >(0) - 1; std::string gasvisctColumnName = "Viscosity"+std::to_string(static_cast<long long>(gasCompIdx)); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& T = gasvisctTables[regionIdx].getColumn("Temperature").vectorCopy(); const auto& mu = gasvisctTables[regionIdx].getColumn(gasvisctColumnName).vectorCopy(); gasvisctCurves_[regionIdx].setXYContainers(T, mu); } } // temperature dependence of gas density if (enableThermalDensity_) { const auto& gasdentKeyword = deck.getKeyword("GASDENT"); assert(gasdentKeyword.size() == numRegions); for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& gasdentRecord = gasdentKeyword.getRecord(regionIdx); gasdentRefTemp_[regionIdx] = gasdentRecord.getItem("REFERENCE_TEMPERATURE").getSIDouble(0); gasdentCT1_[regionIdx] = gasdentRecord.getItem("EXPANSION_COEFF_LINEAR").getSIDouble(0); gasdentCT2_[regionIdx] = gasdentRecord.getItem("EXPANSION_COEFF_QUADRATIC").getSIDouble(0); } } if (deck.hasKeyword("SPECHEAT")) { // the specific internal energy of gas. be aware that ecl only specifies the heat capacity // (via the SPECHEAT keyword) and we need to integrate it ourselfs to get the // internal energy for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) { const auto& specHeatTable = tables.getSpecheatTables()[regionIdx]; const auto& temperatureColumn = specHeatTable.getColumn("TEMPERATURE"); const auto& cvGasColumn = specHeatTable.getColumn("CV_GAS"); std::vector<double> uSamples(temperatureColumn.size()); // the specific enthalpy of vaporization. since ECL does not seem to // feature a proper way to specify this quantity, we use the value for // methane. A proper model would also need to consider the enthalpy // change due to dissolution, i.e. the enthalpies of the gas and oil // phases should depend on the phase composition const Scalar hVap = 480.6e3; // [J / kg] Scalar u = temperatureColumn[0]*cvGasColumn[0] + hVap; for (size_t i = 0;; ++i) { uSamples[i] = u; if (i >= temperatureColumn.size() - 1) break; // integrate to the heat capacity from the current sampling point to the next // one. this leads to a quadratic polynomial. Scalar c_v0 = cvGasColumn[i]; Scalar c_v1 = cvGasColumn[i + 1]; Scalar T0 = temperatureColumn[i]; Scalar T1 = temperatureColumn[i + 1]; u += 0.5*(c_v0 + c_v1)*(T1 - T0); } internalEnergyCurves_[regionIdx].setXYContainers(temperatureColumn.vectorCopy(), uSamples); } } }