Skip to content

Commit

Permalink
Merge pull request #1158 from andlaus/thermal_stuff
Browse files Browse the repository at this point in the history
Thermal stuff
  • Loading branch information
joakim-hove authored Dec 1, 2017
2 parents 6f198ea + 36f477c commit 8ffee74
Show file tree
Hide file tree
Showing 30 changed files with 332 additions and 22 deletions.
9 changes: 8 additions & 1 deletion lib/eclipse/EclipseState/Eclipse3DProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ namespace Opm {
// pore volume multipliers
supportedDoubleKeywords.emplace_back( "MULTPV", 1.0, "1" );

/* rock heat capacity, E300 only */
supportedDoubleKeywords.emplace_back("HEATCR", nan, distributeTopLayer, "Energy/AbsoluteTemperature*Length*Length*Length" );
supportedDoubleKeywords.emplace_back("HEATCRT", 0.0, distributeTopLayer, "Energy/AbsoluteTemperature*AbsoluteTemperature*Length*Length*Length" );

// the permeability keywords
for( const auto& kw : { "PERMR", "PERMTHT", "PERMX", "PERMY", "PERMZ", } )
supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" );
Expand Down Expand Up @@ -415,7 +419,10 @@ namespace Opm {

// initialisation
supportedDoubleKeywords.emplace_back( "SWATINIT", 0.0, "1");
supportedDoubleKeywords.emplace_back( "THCONR", 0.0, "1");
supportedDoubleKeywords.emplace_back( "THCONR", 0.0, "Energy/AbsoluteTemperature*Length*Time");

// saturation dependence of thermal conductivity, E300 only
supportedDoubleKeywords.emplace_back( "THCONSF", 0.0, "1");

return supportedDoubleKeywords;
}
Expand Down
13 changes: 8 additions & 5 deletions lib/eclipse/EclipseState/Runspec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Phase get_phase( const std::string& str ) {
if( str == "WATER" ) return Phase::WATER;
if( str == "SOLVENT" ) return Phase::SOLVENT;
if( str == "POLYMER" ) return Phase::POLYMER;
if( str == "ENERGY" ) return Phase::ENERGY;

throw std::invalid_argument( "Unknown phase '" + str + "'" );
}
Expand All @@ -44,6 +45,7 @@ std::ostream& operator<<( std::ostream& stream, const Phase& p ) {
case Phase::WATER: return stream << "WATER";
case Phase::SOLVENT: return stream << "SOLVENT";
case Phase::POLYMER: return stream << "POLYMER";
case Phase::ENERGY: return stream << "ENERGY";

}

Expand All @@ -52,12 +54,13 @@ std::ostream& operator<<( std::ostream& stream, const Phase& p ) {

using un = std::underlying_type< Phase >::type;

Phases::Phases( bool oil, bool gas, bool wat, bool sol, bool pol ) noexcept :
Phases::Phases( bool oil, bool gas, bool wat, bool sol, bool pol, bool energy ) noexcept :
bits( (oil ? (1 << static_cast< un >( Phase::OIL ) ) : 0) |
(gas ? (1 << static_cast< un >( Phase::GAS ) ) : 0) |
(wat ? (1 << static_cast< un >( Phase::WATER ) ) : 0) |
(sol ? (1 << static_cast< un >( Phase::SOLVENT ) ) : 0) |
(pol ? (1 << static_cast< un >( Phase::POLYMER ) ) : 0) )
(pol ? (1 << static_cast< un >( Phase::POLYMER ) ) : 0) |
(energy ? (1 << static_cast< un >( Phase::ENERGY ) ) : 0) )

{}

Expand All @@ -70,12 +73,12 @@ size_t Phases::size() const noexcept {
}

Runspec::Runspec( const Deck& deck ) :
active_phases( Phases{ deck.hasKeyword( "OIL" ),
active_phases( Phases( deck.hasKeyword( "OIL" ),
deck.hasKeyword( "GAS" ),
deck.hasKeyword( "WATER" ),
deck.hasKeyword( "SOLVENT" ),
deck.hasKeyword( "POLYMER" )
} ),
deck.hasKeyword( "POLYMER" ),
deck.hasKeyword( "THERMAL" ) ) ),
m_tabdims( deck ),
endscale( deck )
{}
Expand Down
23 changes: 23 additions & 0 deletions lib/eclipse/EclipseState/Schedule/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ namespace Opm {
else if (keyword.name() == "WSOLVENT")
handleWSOLVENT(keyword, currentStep);

else if (keyword.name() == "WTEMP")
handleWTEMP(keyword, currentStep);

else if (keyword.name() == "WCONINJH")
handleWCONINJH(section, keyword, currentStep);

Expand Down Expand Up @@ -714,6 +717,26 @@ namespace Opm {
}
}

void Schedule::handleWTEMP( const DeckKeyword& keyword, size_t currentStep) {
for( const auto& record : keyword ) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);

for (auto* well : getWells(wellNamePattern)) {
// TODO: Can this be done like this? Setting the temperature only has an
// effect on injectors, but specifying this for producers won't hurt and
// wells can also switch their injector/producer status. Note that
// modifying the injector properties for producer wells currently leads
// to a very weird segmentation fault downstream. For now, let's take the
// water route.
if (well->isInjector(currentStep)) {
WellInjectionProperties injectionProperties = well->getInjectionProperties(currentStep);
injectionProperties.temperature = record.getItem("TEMP").getSIDouble(0);
well->setInjectionProperties(currentStep, injectionProperties);
}
}
}
}

void Schedule::handleWCONINJH( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) {
for( const auto& record : keyword ) {
const std::string& wellName = record.getItem("WELL").getTrimmedString(0);
Expand Down
2 changes: 2 additions & 0 deletions lib/eclipse/EclipseState/Schedule/Well.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ namespace Opm {
throw std::invalid_argument( "Production of 'SOLVENT' requested." );
case Phase::POLYMER:
throw std::invalid_argument( "Production of 'POLYMER' requested." );
case Phase::ENERGY:
throw std::invalid_argument( "Production of 'ENERGY' requested." );
}

throw std::logic_error( "Unreachable state. Invalid Phase value. "
Expand Down
7 changes: 7 additions & 0 deletions lib/eclipse/EclipseState/Schedule/WellInjectionProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/parser/eclipse/Units/Units.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/WellInjectionProperties.hpp>

#include <iostream>
Expand All @@ -27,6 +29,9 @@ namespace Opm {
WellInjectionProperties::WellInjectionProperties() {
surfaceInjectionRate=0.0;
reservoirInjectionRate=0.0;
temperature=
Metric::TemperatureOffset
+ ParserKeywords::STCOND::TEMPERATURE::defaultValue;
BHPLimit=0.0;
THPLimit=0.0;
VFPTableNumber=0;
Expand All @@ -40,6 +45,7 @@ namespace Opm {
bool WellInjectionProperties::operator==(const WellInjectionProperties& other) const {
if ((surfaceInjectionRate == other.surfaceInjectionRate) &&
(reservoirInjectionRate == other.reservoirInjectionRate) &&
(temperature == other.temperature) &&
(BHPLimit == other.BHPLimit) &&
(THPLimit == other.THPLimit) &&
(VFPTableNumber == other.VFPTableNumber) &&
Expand All @@ -62,6 +68,7 @@ namespace Opm {
<< "WellInjectionProperties { "
<< "surfacerate: " << wp.surfaceInjectionRate << ", "
<< "reservoir rate " << wp.reservoirInjectionRate << ", "
<< "temperature: " << wp.temperature << ", "
<< "BHP limit: " << wp.BHPLimit << ", "
<< "THP limit: " << wp.THPLimit << ", "
<< "VFP table: " << wp.VFPTableNumber << ", "
Expand Down
24 changes: 22 additions & 2 deletions lib/eclipse/EclipseState/Tables/TableManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include <opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Sof3Table.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SorwmisTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SsfnTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SwofTable.hpp>
Expand All @@ -73,6 +75,8 @@
#include <opm/parser/eclipse/EclipseState/Tables/Eqldims.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Regdims.hpp>

#include <opm/parser/eclipse/Units/Units.hpp>

namespace Opm {

TableManager::TableManager( const Deck& deck )
Expand All @@ -81,9 +85,12 @@ namespace Opm {
hasImptvd (deck.hasKeyword("IMPTVD")),
hasEnptvd (deck.hasKeyword("ENPTVD")),
hasEqlnum (deck.hasKeyword("EQLNUM")),
m_jfunc( deck ),
m_rtemp( ParserKeywords::RTEMP::TEMP::defaultValue )
m_jfunc( deck )
{
// determine the default resevoir temperature in Kelvin
m_rtemp = ParserKeywords::RTEMP::TEMP::defaultValue;
m_rtemp += Metric::TemperatureOffset; // <- default values always use METRIC as the unit system!

initDims( deck );
initSimpleTables( deck );
initFullTables(deck, "PVTG", m_pvtgTables);
Expand Down Expand Up @@ -204,6 +211,9 @@ namespace Opm {
addTables( "PVDO", m_tabdims.getNumPVTTables());
addTables( "PVDS", m_tabdims.getNumPVTTables());

addTables( "SPECHEAT", m_tabdims.getNumPVTTables());
addTables( "SPECROCK", m_tabdims.getNumSatTables());

addTables( "OILVISCT", m_tabdims.getNumPVTTables());
addTables( "WATVISCT", m_tabdims.getNumPVTTables());
addTables( "GASVISCT", m_tabdims.getNumPVTTables());
Expand Down Expand Up @@ -301,6 +311,8 @@ namespace Opm {
initSimpleTableContainer<PvdgTable>(deck, "PVDG", m_tabdims.getNumPVTTables());
initSimpleTableContainer<PvdoTable>(deck, "PVDO", m_tabdims.getNumPVTTables());
initSimpleTableContainer<PvdsTable>(deck, "PVDS", m_tabdims.getNumPVTTables());
initSimpleTableContainer<SpecheatTable>(deck, "SPECHEAT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<SpecrockTable>(deck, "SPECROCK", m_tabdims.getNumSatTables());
initSimpleTableContainer<OilvisctTable>(deck, "OILVISCT", m_tabdims.getNumPVTTables());
initSimpleTableContainer<WatvisctTable>(deck, "WATVISCT", m_tabdims.getNumPVTTables());

Expand Down Expand Up @@ -618,6 +630,14 @@ namespace Opm {
return getTables("PVDS");
}

const TableContainer& TableManager::getSpecheatTables() const {
return getTables("SPECHEAT");
}

const TableContainer& TableManager::getSpecrockTables() const {
return getTables("SPECROCK");
}

const TableContainer& TableManager::getOilvisctTables() const {
return getTables("OILVISCT");
}
Expand Down
38 changes: 38 additions & 0 deletions lib/eclipse/EclipseState/Tables/Tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
#include <opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Sof3Table.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SorwmisTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SsfnTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/SwofTable.hpp>
Expand Down Expand Up @@ -100,6 +102,42 @@ PvtoTable::PvtoTable( const DeckKeyword& keyword, size_t tableIdx) :
PvtxTable::init(keyword , tableIdx);
}

SpecheatTable::SpecheatTable(const DeckItem& item)
{
m_schema.addColumn(ColumnSchema("TEMPERATURE", Table::STRICTLY_INCREASING, Table::DEFAULT_NONE));
m_schema.addColumn(ColumnSchema("CP_OIL", Table::RANDOM, Table::DEFAULT_LINEAR));
m_schema.addColumn(ColumnSchema("CP_WATER", Table::RANDOM, Table::DEFAULT_LINEAR));
m_schema.addColumn(ColumnSchema("CP_GAS", Table::RANDOM, Table::DEFAULT_LINEAR));

SimpleTable::init(item);
}

const TableColumn& SpecheatTable::getTemperatureColumn() const
{ return SimpleTable::getColumn(0); }

const TableColumn& SpecheatTable::getCpOilColumn() const
{ return SimpleTable::getColumn(1); }

const TableColumn& SpecheatTable::getCpWaterColumn() const
{ return SimpleTable::getColumn(2); }

const TableColumn& SpecheatTable::getCpGasColumn() const
{ return SimpleTable::getColumn(3); }

SpecrockTable::SpecrockTable(const DeckItem& item)
{
m_schema.addColumn(ColumnSchema("TEMPERATURE", Table::STRICTLY_INCREASING, Table::DEFAULT_NONE));
m_schema.addColumn(ColumnSchema("CP_ROCK", Table::RANDOM, Table::DEFAULT_LINEAR));

SimpleTable::init(item);
}

const TableColumn& SpecrockTable::getTemperatureColumn() const
{ return SimpleTable::getColumn(0); }

const TableColumn& SpecrockTable::getCpRockColumn() const
{ return SimpleTable::getColumn(1); }

SwofTable::SwofTable( const DeckItem& item , const bool jfunc) {

m_schema.addColumn( ColumnSchema( "SW" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE) );
Expand Down
16 changes: 16 additions & 0 deletions lib/eclipse/Units/UnitSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace {
1, /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
1 / Metric::Energy
};

static const double from_metric[] = {
Expand Down Expand Up @@ -95,6 +96,7 @@ namespace {
1, /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
Metric::Energy
};

static constexpr const char* metric_names[] = {
Expand Down Expand Up @@ -124,6 +126,7 @@ namespace {
"SM3/RM3", /* gas inverse formation volume factor */
"SM3/RM3", /* oil inverse formation volume factor */
"SM3/RM3", /* water inverse formation volume factor */
"KJ", /* energy */
};

static const double to_field[] = {
Expand Down Expand Up @@ -153,6 +156,7 @@ namespace {
1 / (Field::GasSurfaceVolume / Field::ReservoirVolume), /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
1 / Field::Energy
};

static const double from_field[] = {
Expand Down Expand Up @@ -182,6 +186,7 @@ namespace {
Field::GasSurfaceVolume / Field::ReservoirVolume, /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
Field::Energy
};

static constexpr const char* field_names[] = {
Expand Down Expand Up @@ -211,6 +216,7 @@ namespace {
"MSCF/RB", /* gas inverse formation volume factor */
"STB/RB", /* oil inverse formation volume factor */
"STB/RB", /* water inverse formation volume factor */
"BTU", /* energy */
};

static const double to_lab[] = {
Expand Down Expand Up @@ -240,6 +246,7 @@ namespace {
1, /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
1 / Lab::Energy
};

static const double from_lab[] = {
Expand Down Expand Up @@ -269,6 +276,7 @@ namespace {
1, /* gas inverse formation volume factor */
1, /* oil inverse formation volume factor */
1, /* water inverse formation volume factor */
Lab::Energy
};

static constexpr const char* lab_names[] = {
Expand Down Expand Up @@ -298,6 +306,7 @@ namespace {
"SCC/RCC", /* gas formation volume factor */
"SCC/RCC", /* oil inverse formation volume factor */
"SCC/RCC", /* water inverse formation volume factor */
"J", /* energy */
};

static const double to_pvt_m[] = {
Expand Down Expand Up @@ -327,6 +336,7 @@ namespace {
1 / (PVT_M::GasSurfaceVolume / PVT_M::ReservoirVolume), /* 1/Bg */
1 / (PVT_M::LiquidSurfaceVolume / PVT_M::ReservoirVolume), /* 1/Bo */
1 / (PVT_M::LiquidSurfaceVolume / PVT_M::ReservoirVolume), /* 1/Bw */
1 / PVT_M::Energy
};

static const double from_pvt_m[] = {
Expand Down Expand Up @@ -356,6 +366,7 @@ namespace {
PVT_M::GasSurfaceVolume / PVT_M::ReservoirVolume, /* 1/Bg */
PVT_M::LiquidSurfaceVolume / PVT_M::ReservoirVolume, /* 1/Bo */
PVT_M::LiquidSurfaceVolume / PVT_M::ReservoirVolume, /* 1/Bw */
PVT_M::Energy
};

static constexpr const char* pvt_m_names[] = {
Expand Down Expand Up @@ -385,6 +396,7 @@ namespace {
"SM3/RM3", /* gas inverse formation volume factor */
"SM3/RM3", /* oil inverse formation volume factor */
"SM3/RM3", /* water inverse formation volume factor */
"KJ" /* energy */
};
}

Expand Down Expand Up @@ -601,6 +613,7 @@ namespace {
system.addDimension("Viscosity" , Metric::Viscosity);
system.addDimension("Timestep" , Metric::Timestep);
system.addDimension("SurfaceTension" , Metric::SurfaceTension);
system.addDimension("Energy", Metric::Energy);
system.addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
return system;
}
Expand Down Expand Up @@ -630,6 +643,7 @@ namespace {
system.addDimension("Viscosity", Field::Viscosity);
system.addDimension("Timestep", Field::Timestep);
system.addDimension("SurfaceTension" , Field::SurfaceTension);
system.addDimension("Energy", Field::Energy);
system.addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
return system;
}
Expand Down Expand Up @@ -659,6 +673,7 @@ namespace {
system.addDimension("Viscosity", Lab::Viscosity);
system.addDimension("Timestep", Lab::Timestep);
system.addDimension("SurfaceTension" , Lab::SurfaceTension);
system.addDimension("Energy", Lab::Energy);
system.addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
return system;
}
Expand Down Expand Up @@ -687,6 +702,7 @@ namespace {
system.addDimension("Viscosity" , PVT_M::Viscosity);
system.addDimension("Timestep" , PVT_M::Timestep);
system.addDimension("SurfaceTension" , PVT_M::SurfaceTension);
system.addDimension("Energy", PVT_M::Energy);
system.addDimension("ContextDependent", std::numeric_limits<double>::quiet_NaN());
return system;
}
Expand Down
Loading

0 comments on commit 8ffee74

Please sign in to comment.