implement gasvisct

This commit is contained in:
goncalvesmachadoc
2023-05-09 10:48:25 +02:00
parent b38cedf113
commit abaa1074ff
8 changed files with 76 additions and 88 deletions

View File

@@ -581,6 +581,7 @@ std::optional<JFunc> make_jfunc(const Deck& deck) {
initSimpleTableContainer<SpecheatTable>(deck, "SPECHEAT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<SpecrockTable>(deck, "SPECROCK", m_tabdims.getNumSatTables());
initSimpleTableContainer<OilvisctTable>(deck, "OILVISCT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<GasvisctTable>(deck, "GASVISCT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<WatvisctTable>(deck, "WATVISCT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<PlyadsTable>(deck, "PLYADS", m_tabdims.getNumSatTables());
@@ -592,7 +593,6 @@ std::optional<JFunc> make_jfunc(const Deck& deck) {
initPlyrockTables(deck);
initPlymaxTables(deck);
initGasvisctTables(deck);
initRTempTables(deck);
initRocktabTables(deck);
initPlyshlogTables(deck);
@@ -618,34 +618,7 @@ std::optional<JFunc> make_jfunc(const Deck& deck) {
} else if (hasRTEMPVD) {
initSimpleTableContainer<RtempvdTable>(deck, "RTEMPVD", "RTEMPVD", m_eqldims.getNumEquilRegions());
}
}
void TableManager::initGasvisctTables(const Deck& deck) {
const std::string keywordName = "GASVISCT";
size_t numTables = m_tabdims.getNumPVTTables();
if (!deck.hasKeyword(keywordName))
return; // the table is not featured by the deck...
auto& container = forceGetTables(keywordName , numTables);
if (deck.count(keywordName) > 1) {
complainAboutAmbiguousKeyword(deck, keywordName);
return;
}
const auto& tableKeyword = deck[keywordName].back();
for (size_t tableIdx = 0; tableIdx < tableKeyword.size(); ++tableIdx) {
const auto& tableRecord = tableKeyword.getRecord( tableIdx );
const auto& dataItem = tableRecord.getItem( 0 );
if (dataItem.data_size() > 0) {
std::shared_ptr<GasvisctTable> table = std::make_shared<GasvisctTable>( deck , dataItem );
container.addTable( tableIdx , table );
}
}
}
}
void TableManager::initPlyshlogTables(const Deck& deck) {

View File

@@ -1170,46 +1170,12 @@ WatvisctTable::getWaterViscosityColumn() const
return SimpleTable::getColumn(1);
}
GasvisctTable::GasvisctTable(const Deck& deck, const DeckItem& deckItem)
GasvisctTable::GasvisctTable(const DeckItem& item, const int tableID)
{
int numComponents = deck.get<ParserKeywords::COMPS>().back().getRecord(0).getItem(0).get<int>(0);
auto temperatureDimension = deck.getActiveUnitSystem().getDimension("Temperature");
auto viscosityDimension = deck.getActiveUnitSystem().getDimension("Viscosity");
m_schema.addColumn(ColumnSchema("Temperature", Table::STRICTLY_INCREASING, Table::DEFAULT_NONE));
for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
std::string columnName = "Viscosity" + std::to_string(compIdx);
m_schema.addColumn(ColumnSchema(columnName, Table::INCREASING, Table::DEFAULT_NONE));
}
SimpleTable::addColumns();
if (deckItem.data_size() % numColumns() != 0)
throw std::runtime_error("Number of columns in the data file is inconsistent "
"with the expected number for keyword GASVISCT");
size_t rows = deckItem.data_size() / m_schema.size();
for (size_t columnIndex = 0; columnIndex < m_schema.size(); columnIndex++) {
auto& column = getColumn(columnIndex);
for (size_t rowIdx = 0; rowIdx < rows; rowIdx++) {
size_t deckIndex = rowIdx * m_schema.size() + columnIndex;
if (deckItem.defaultApplied(deckIndex))
column.addDefault("GASVISCT");
else {
double rawValue = deckItem.get<double>(deckIndex);
double SIValue;
if (columnIndex == 0)
SIValue = temperatureDimension.convertRawToSi(rawValue);
else
SIValue = viscosityDimension.convertRawToSi(rawValue);
column.addValue(SIValue, "GASVISCT");
}
}
}
m_schema.addColumn(ColumnSchema("Viscosity", Table::RANDOM, Table::DEFAULT_NONE));
SimpleTable::init("GASVISCT", item, tableID);
}
const TableColumn&
@@ -1219,17 +1185,16 @@ GasvisctTable::getTemperatureColumn() const
}
const TableColumn&
GasvisctTable::getGasViscosityColumn(size_t compIdx) const
GasvisctTable::getGasViscosityColumn() const
{
return SimpleTable::getColumn(1 + compIdx);
return SimpleTable::getColumn(1);
}
RtempvdTable::RtempvdTable(const DeckItem& item, const int tableID)
{
m_schema.addColumn(ColumnSchema("Depth", Table::STRICTLY_INCREASING, Table::DEFAULT_NONE));
m_schema.addColumn(ColumnSchema("Temperature", Table::RANDOM, Table::DEFAULT_NONE));
SimpleTable::init("GASVISCT", item, tableID);
SimpleTable::init("RTEMPVD", item, tableID);
}
const TableColumn&

View File

@@ -61,14 +61,41 @@ initFromState(const EclipseState& eclState, const Schedule& schedule)
// viscosity
if (enableThermalViscosity_) {
if (tables.getViscrefTable().empty())
OPM_THROW(std::runtime_error, "VISCREF is required when GASVISCT is present");
const auto& gasvisctTables = tables.getGasvisctTables();
auto gasCompIdx = tables.gas_comp_index();
std::string gasvisctColumnName = "Viscosity" + std::to_string(static_cast<long long>(gasCompIdx));
const auto& viscrefTable = tables.getViscrefTable();
if (gasvisctTables.size() != numRegions) {
OPM_THROW(std::runtime_error,
fmt::format("Tables sizes mismatch. GASVISCT: {}, NumRegions: {}\n",
gasvisctTables.size(), numRegions));
}
if (viscrefTable.size() != numRegions) {
OPM_THROW(std::runtime_error,
fmt::format("Tables sizes mismatch. VISCREF: {}, NumRegions: {}\n",
viscrefTable.size(), numRegions));
}
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);
const auto& TCol = gasvisctTables[regionIdx].getColumn("Temperature").vectorCopy();
const auto& muCol = gasvisctTables[regionIdx].getColumn("Viscosity").vectorCopy();
gasvisctCurves_[regionIdx].setXYContainers(TCol, muCol);
viscrefPress_[regionIdx] = viscrefTable[regionIdx].reference_pressure;
// temperature used to calculate the reference viscosity [K].
constexpr const Scalar Tref = 273.15 + 20;
constexpr const Scalar Rvref = 0.0;
constexpr const Scalar Rvwref = 0.0;
// compute the reference viscosity using the isothermal PVT object.
viscRef_[regionIdx] =
isothermalPvt_->viscosity(regionIdx,
Tref,
viscrefPress_[regionIdx],
Rvref,
Rvwref);
}
}

View File

@@ -52,6 +52,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule)
const auto& tables = eclState.getTableManager();
enableThermalDensity_ = tables.OilDenT().size() > 0;
enableJouleThomson_ = tables.OilJT().size() > 0;
enableThermalViscosity_ = tables.hasTables("OILVISCT");
enableInternalEnergy_ = tables.hasTables("SPECHEAT");