adjustments needed for new Joule-Thomson keywords

This commit is contained in:
Paul Egberts 2022-05-17 17:36:37 +02:00
parent a2aa7b9603
commit 25adfda7d9
3 changed files with 63 additions and 54 deletions

View File

@ -60,6 +60,7 @@ public:
GasPvtThermal()
{
enableThermalDensity_ = false;
enableJouleThomson_ = false;
enableThermalViscosity_ = false;
isothermalPvt_ = nullptr;
}
@ -70,10 +71,10 @@ public:
const std::vector<Scalar>& gasdentCT1,
const std::vector<Scalar>& gasdentCT2,
const std::vector<Scalar>& gasJTRefPres,
const std::vector<Scalar>& gasJT,
const std::vector<Scalar>& gasJTC,
const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
bool enableThermalDensity,
bool enableJouleThomson,
bool enableThermalViscosity,
bool enableInternalEnergy)
: isothermalPvt_(isothermalPvt)
@ -82,10 +83,10 @@ public:
, gasdentCT1_(gasdentCT1)
, gasdentCT2_(gasdentCT2)
, gasJTRefPres_(gasJTRefPres)
, gasJT_(gasJT)
, gasJTC_(gasJTC)
, internalEnergyCurves_(internalEnergyCurves)
, enableThermalDensity_(enableThermalDensity)
, enableJouleThomson_(enableJouleThomson)
, enableThermalViscosity_(enableThermalViscosity)
, enableInternalEnergy_(enableInternalEnergy)
{ }
@ -114,6 +115,7 @@ public:
const auto& tables = eclState.getTableManager();
enableThermalDensity_ = tables.GasDenT().size() > 0;
enableJouleThomson_ = tables.GasJT().size() > 0;
enableThermalViscosity_ = tables.hasTables("GASVISCT");
enableInternalEnergy_ = tables.hasTables("SPECHEAT");
@ -148,14 +150,15 @@ public:
}
// Joule Thomson
if (tables.hasTables("JOULETHO")) {
const auto& joulethomsonTables = tables.getJoulethomsonTables();
if (enableJouleThomson_) {
const auto& gasJT = tables.GasJT();
assert(joulethomsonTables.size() == numRegions);
assert(gasJT.size() == numRegions);
for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
gasJTRefPres_[regionIdx] = joulethomsonTables[regionIdx].getColumn("PREF").front();
gasJT_[regionIdx] = joulethomsonTables[regionIdx].getColumn("GAS_JT").front();
gasJTC_[regionIdx] = joulethomsonTables[regionIdx].getColumn("GAS_JTC").front();
const auto& record = gasJT[regionIdx];
gasJTRefPres_[regionIdx] = record.P0;
gasJTC_[regionIdx] = record.C1;
}
}
@ -210,7 +213,6 @@ public:
gasdentCT1_.resize(numRegions);
gasdentCT2_.resize(numRegions);
gasJTRefPres_.resize(numRegions);
gasJT_.resize(numRegions);
gasJTC_.resize(numRegions);
}
@ -229,6 +231,12 @@ public:
bool enableThermalDensity() const
{ return enableThermalDensity_; }
/*!
* \brief Returns true iff Joule-Thomson effect for the gas phase is active.
*/
bool enableJouleThomsony() const
{ return enableJouleThomson_; }
/*!
* \brief Returns true iff the viscosity of the gas phase is temperature dependent.
*/
@ -247,8 +255,6 @@ public:
if (!enableInternalEnergy_)
throw std::runtime_error("Requested the internal energy of gas but it is disabled");
bool enableJouleThomson_ = gasJT_[regionIdx];
if (!enableJouleThomson_) {
// compute the specific internal energy for the specified tempature. We use linear
// interpolation here despite the fact that the underlying heat capacities are
@ -258,7 +264,7 @@ public:
else {
Evaluation Tref = gasdentRefTemp_[regionIdx];
Evaluation Pref = gasJTRefPres_[regionIdx];
Scalar JTC = gasJTC_[regionIdx]; // JTC = 0: JTC calculated
Scalar JTC = gasJTC_[regionIdx]; // if JTC = 999 (default) then JTC calculated
Evaluation invB = inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv);
const Scalar hVap = 480.6e3; // [J / kg]
@ -478,9 +484,6 @@ public:
const std::vector<Scalar>& gasJTRefPres() const
{ return gasJTRefPres_; }
const std::vector<Scalar>& gasJT() const
{ return gasJT_; }
const std::vector<Scalar>& gasJTC() const
{ return gasJTC_; }
@ -499,10 +502,10 @@ public:
this->gasdentCT1() == data.gasdentCT1() &&
this->gasdentCT2() == data.gasdentCT2() &&
this->gasJTRefPres() == data.gasJTRefPres() &&
this->gasJT() == data.gasJT() &&
this->gasJTC() == data.gasJTC() &&
this->internalEnergyCurves() == data.internalEnergyCurves() &&
this->enableThermalDensity() == data.enableThermalDensity() &&
this->enableJouleThomson() == data.enableJouleThomson() &&
this->enableThermalViscosity() == data.enableThermalViscosity() &&
this->enableInternalEnergy() == data.enableInternalEnergy();
}
@ -518,10 +521,10 @@ public:
gasdentCT1_ = data.gasdentCT1_;
gasdentCT2_ = data.gasdentCT2_;
gasJTRefPres_ = data.gasJTRefPres_;
gasJT_ = data.gasJT_;
gasJTC_ = data.gasJTC_;
internalEnergyCurves_ = data.internalEnergyCurves_;
enableThermalDensity_ = data.enableThermalDensity_;
enableJouleThomson_ = data.enableJouleThomson_;
enableThermalViscosity_ = data.enableThermalViscosity_;
enableInternalEnergy_ = data.enableInternalEnergy_;
@ -540,13 +543,13 @@ private:
std::vector<Scalar> gasdentCT2_;
std::vector<Scalar> gasJTRefPres_;
std::vector<Scalar> gasJT_;
std::vector<Scalar> gasJTC_;
// piecewise linear curve representing the internal energy of gas
std::vector<TabulatedOneDFunction> internalEnergyCurves_;
bool enableThermalDensity_;
bool enableJouleThomson_;
bool enableThermalViscosity_;
bool enableInternalEnergy_;
};

View File

@ -60,6 +60,7 @@ public:
OilPvtThermal()
{
enableThermalDensity_ = false;
enableJouleThomson_ = false;
enableThermalViscosity_ = false;
enableInternalEnergy_ = false;
isothermalPvt_ = nullptr;
@ -74,10 +75,10 @@ public:
const std::vector<Scalar>& oildentCT1,
const std::vector<Scalar>& oildentCT2,
const std::vector<Scalar>& oilJTRefPres,
const std::vector<Scalar>& oilJT,
const std::vector<Scalar>& oilJTC,
const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
bool enableThermalDensity,
bool enableJouleThomson,
bool enableThermalViscosity,
bool enableInternalEnergy)
: isothermalPvt_(isothermalPvt)
@ -89,10 +90,10 @@ public:
, oildentCT1_(oildentCT1)
, oildentCT2_(oildentCT2)
, oilJTRefPres_(oilJTRefPres)
, oilJT_(oilJT)
, oilJTC_(oilJTC)
, internalEnergyCurves_(internalEnergyCurves)
, enableThermalDensity_(enableThermalDensity)
, enableJouleThomson_(enableJouleThomson)
, enableThermalViscosity_(enableThermalViscosity)
, enableInternalEnergy_(enableInternalEnergy)
{ }
@ -174,14 +175,15 @@ public:
}
// Joule Thomson
if (tables.hasTables("JOULETHO")) {
const auto& joulethomsonTables = tables.getJoulethomsonTables();
if (enableJouleThomson_) {
const auto& oilJT = tables.OilJT();
assert(joulethomsonTables.size() == numRegions);
assert(oilJT.size() == numRegions);
for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
oilJTRefPres_[regionIdx] = joulethomsonTables[regionIdx].getColumn("PREF").front();
oilJT_[regionIdx] = joulethomsonTables[regionIdx].getColumn("OIL_JT").front();
oilJTC_[regionIdx] = joulethomsonTables[regionIdx].getColumn("OIL_JTC").front();
const auto& record = oilJT[regionIdx];
oilJTRefPres_[regionIdx] = record.P0;
oilJTC_[regionIdx] = record.C1;
}
}
@ -232,7 +234,6 @@ public:
oildentCT1_.resize(numRegions);
oildentCT2_.resize(numRegions);
oilJTRefPres_.resize(numRegions);
oilJT_.resize(numRegions);
oilJTC_.resize(numRegions);
}
@ -248,6 +249,12 @@ public:
bool enableThermalDensity() const
{ return enableThermalDensity_; }
/*!
* \brief Returns true iff Joule-Thomson effect for the oil phase is active.
*/
bool enableJouleThomsony() const
{ return enableJouleThomson_; }
/*!
* \brief Returns true iff the viscosity of the oil phase is temperature dependent.
*/
@ -269,8 +276,6 @@ public:
if (!enableInternalEnergy_)
throw std::runtime_error("Requested the internal energy of oil but it is disabled");
bool enableJouleThomson_ = oilJT_[regionIdx];
if (!enableJouleThomson_) {
// compute the specific internal energy for the specified tempature. We use linear
// interpolation here despite the fact that the underlying heat capacities are
@ -280,7 +285,7 @@ public:
else {
Evaluation Tref = oildentRefTemp_[regionIdx];
Evaluation Pref = oilJTRefPres_[regionIdx];
Scalar JTC = oilJTC_[regionIdx]; // JTC = 0: JTC calculated
Scalar JTC = oilJTC_[regionIdx]; // if JTC = 999 (default) then JTC calculated
Evaluation invB = inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rs);
Evaluation Cp = internalEnergyCurves_[regionIdx].eval(temperature, /*extrapolate=*/true)/temperature;
@ -489,9 +494,6 @@ public:
const std::vector<Scalar>& oilJTRefPres() const
{ return oilJTRefPres_; }
const std::vector<Scalar>& oilJT() const
{ return oilJT_; }
const std::vector<Scalar>& oilJTC() const
{ return oilJTC_; }
@ -512,10 +514,10 @@ public:
this->oildentCT1() == data.oildentCT1() &&
this->oildentCT2() == data.oildentCT2() &&
this->oilJTRefPres() == data.oilJTRefPres() &&
this->oilJT() == data.oilJT() &&
this->oilJTC() == data.oilJTC() &&
this->internalEnergyCurves() == data.internalEnergyCurves() &&
this->enableThermalDensity() == data.enableThermalDensity() &&
this->enableJouleThomson() == data.enableJouleThomson() &&
this->enableThermalViscosity() == data.enableThermalViscosity() &&
this->enableInternalEnergy() == data.enableInternalEnergy();
}
@ -534,10 +536,10 @@ public:
oildentCT1_ = data.oildentCT1_;
oildentCT2_ = data.oildentCT2_;
oilJTRefPres_ = data.oilJTRefPres_;
oilJT_ = data.oilJT_;
oilJTC_ = data.oilJTC_;
internalEnergyCurves_ = data.internalEnergyCurves_;
enableThermalDensity_ = data.enableThermalDensity_;
enableJouleThomson_ = data.enableJouleThomson_;
enableThermalViscosity_ = data.enableThermalViscosity_;
enableInternalEnergy_ = data.enableInternalEnergy_;
@ -560,13 +562,13 @@ private:
std::vector<Scalar> oildentCT2_;
std::vector<Scalar> oilJTRefPres_;
std::vector<Scalar> oilJT_;
std::vector<Scalar> oilJTC_;
// piecewise linear curve representing the internal energy of oil
std::vector<TabulatedOneDFunction> internalEnergyCurves_;
bool enableThermalDensity_;
bool enableJouleThomson_;
bool enableThermalViscosity_;
bool enableInternalEnergy_;
};

View File

@ -71,7 +71,6 @@ public:
const std::vector<Scalar>& watdentCT1,
const std::vector<Scalar>& watdentCT2,
const std::vector<Scalar>& watJTRefPres,
const std::vector<Scalar>& watJT,
const std::vector<Scalar>& watJTC,
const std::vector<Scalar>& pvtwRefPress,
const std::vector<Scalar>& pvtwRefB,
@ -81,6 +80,7 @@ public:
const std::vector<TabulatedOneDFunction>& watvisctCurves,
const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
bool enableThermalDensity,
bool enableJouleThomson,
bool enableThermalViscosity,
bool enableInternalEnergy)
: isothermalPvt_(isothermalPvt)
@ -89,7 +89,6 @@ public:
, watdentCT1_(watdentCT1)
, watdentCT2_(watdentCT2)
, watJTRefPres_(watJTRefPres)
, watJT_(watJT)
, watJTC_(watJTC)
, pvtwRefPress_(pvtwRefPress)
, pvtwRefB_(pvtwRefB)
@ -99,6 +98,7 @@ public:
, watvisctCurves_(watvisctCurves)
, internalEnergyCurves_(internalEnergyCurves)
, enableThermalDensity_(enableThermalDensity)
, enableJouleThomson_(enableJouleThomson)
, enableThermalViscosity_(enableThermalViscosity)
, enableInternalEnergy_(enableInternalEnergy)
{ }
@ -127,6 +127,7 @@ public:
const auto& tables = eclState.getTableManager();
enableThermalDensity_ = tables.WatDenT().size() > 0;
enableJouleThomson_ = tables.WatJT().size() > 0;
enableThermalViscosity_ = tables.hasTables("WATVISCT");
enableInternalEnergy_ = tables.hasTables("SPECHEAT");
@ -148,21 +149,23 @@ public:
const auto& pvtwTables = tables.getPvtwTable();
assert(pvtwTables.size() == numRegions);
for (unsigned regionIdx = 0; regionIdx < numRegions; ++ regionIdx) {
pvtwRefPress_[regionIdx] = pvtwTables[regionIdx].reference_pressure;
pvtwRefB_[regionIdx] = pvtwTables[regionIdx].volume_factor;
}
}
// Joule Thomson
if (tables.hasTables("JOULETHO")) {
const auto& joulethomsonTables = tables.getJoulethomsonTables();
// Joule Thomson
if (enableJouleThomson_) {
const auto& watJT = tables.WatJT();
assert(joulethomsonTables.size() == numRegions);
assert(watJT.size() == numRegions);
for (unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
watJTRefPres_[regionIdx] = joulethomsonTables[regionIdx].getColumn("PREF").front();
watJT_[regionIdx] = joulethomsonTables[regionIdx].getColumn("WAT_JT").front();
watJTC_[regionIdx] = joulethomsonTables[regionIdx].getColumn("WAT_JTC").front();
const auto& record = watJT[regionIdx];
watJTRefPres_[regionIdx] = record.P0;
watJTC_[regionIdx] = record.C1;
}
}
@ -242,7 +245,6 @@ public:
watdentCT1_.resize(numRegions);
watdentCT2_.resize(numRegions);
watJTRefPres_.resize(numRegions);
watJT_.resize(numRegions);
watJTC_.resize(numRegions);
internalEnergyCurves_.resize(numRegions);
}
@ -259,6 +261,12 @@ public:
bool enableThermalDensity() const
{ return enableThermalDensity_; }
/*!
* \brief Returns true iff Joule-Thomson effect for the water phase is active.
*/
bool enableJouleThomsony() const
{ return enableJouleThomson_; }
/*!
* \brief Returns true iff the viscosity of the water phase is temperature dependent.
*/
@ -280,8 +288,6 @@ public:
if (!enableInternalEnergy_)
throw std::runtime_error("Requested the internal energy of water but it is disabled");
bool enableJouleThomson_ = watJT_[regionIdx];
if (!enableJouleThomson_) {
// compute the specific internal energy for the specified tempature. We use linear
// interpolation here despite the fact that the underlying heat capacities are
@ -291,7 +297,7 @@ public:
else {
Evaluation Tref = watdentRefTemp_[regionIdx];
Evaluation Pref = watJTRefPres_[regionIdx];
Scalar JTC =watJTC_[regionIdx]; // JTC = 0: JTC calculated
Scalar JTC =watJTC_[regionIdx]; // if JTC = 999 (default) then JTC calculated
Evaluation invB = inverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration);
Evaluation Cp = internalEnergyCurves_[regionIdx].eval(temperature, /*extrapolate=*/true)/temperature;
@ -421,9 +427,6 @@ public:
const std::vector<Scalar>& watJTRefPres() const
{ return watJTRefPres_; }
const std::vector<Scalar>& watJT() const
{ return watJT_; }
const std::vector<Scalar>& watJTC() const
{ return watJTC_; }
@ -453,6 +456,7 @@ public:
this->watvisctCurves() == data.watvisctCurves() &&
this->internalEnergyCurves() == data.internalEnergyCurves() &&
this->enableThermalDensity() == data.enableThermalDensity() &&
this->enableJouleThomson() == data.enableJouleThomson() &&
this->enableThermalViscosity() == data.enableThermalViscosity() &&
this->enableInternalEnergy() == data.enableInternalEnergy();
}
@ -468,7 +472,6 @@ public:
watdentCT1_ = data.watdentCT1_;
watdentCT2_ = data.watdentCT2_;
watJTRefPres_ = data.watJTRefPres_;
watJT_ = data.watJT_;
watJTC_ = data.watJTC_;
pvtwRefPress_ = data.pvtwRefPress_;
pvtwRefB_ = data.pvtwRefB_;
@ -478,6 +481,7 @@ public:
watvisctCurves_ = data.watvisctCurves_;
internalEnergyCurves_ = data.internalEnergyCurves_;
enableThermalDensity_ = data.enableThermalDensity_;
enableJouleThomson_ = data.enableJouleThomson_;
enableThermalViscosity_ = data.enableThermalViscosity_;
enableInternalEnergy_ = data.enableInternalEnergy_;
@ -496,7 +500,6 @@ private:
std::vector<Scalar> watdentCT2_;
std::vector<Scalar> watJTRefPres_;
std::vector<Scalar> watJT_;
std::vector<Scalar> watJTC_;
std::vector<Scalar> pvtwRefPress_;
@ -511,6 +514,7 @@ private:
std::vector<TabulatedOneDFunction> internalEnergyCurves_;
bool enableThermalDensity_;
bool enableJouleThomson_;
bool enableThermalViscosity_;
bool enableInternalEnergy_;
};