From 14351c5794eb30d1e4820d49a873592a1aa1dd2d Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 9 Apr 2019 09:56:29 +0200 Subject: [PATCH] black oil PVT: make the maximum oil saturation a evaluation the maximum oil saturation *can* depend on the most current solution, so it needs to include derivatives. Note that this fix should not change the converged solution, only the convergence behaviour, i.e., if changes in the results are encountered, these are likely only numerical noise. --- opm/material/fluidsystems/BlackOilFluidSystem.hpp | 8 ++++---- .../blackoilpvt/ConstantCompressibilityOilPvt.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp | 2 +- .../fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp | 6 +++--- .../fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp | 2 +- opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp | 5 +++-- tests/test_eclblackoilpvt.cpp | 4 +--- 11 files changed, 18 insertions(+), 19 deletions(-) diff --git a/opm/material/fluidsystems/BlackOilFluidSystem.hpp b/opm/material/fluidsystems/BlackOilFluidSystem.hpp index a55690fed..43604fb07 100644 --- a/opm/material/fluidsystems/BlackOilFluidSystem.hpp +++ b/opm/material/fluidsystems/BlackOilFluidSystem.hpp @@ -144,14 +144,14 @@ public: void setRegionIndex(unsigned val) { regionIdx_ = val; } - const Scalar maxOilSat() const + const Evaluation& maxOilSat() const { return maxOilSat_; } - void setMaxOilSat(Scalar val) + void setMaxOilSat(const Evaluation& val) { maxOilSat_ = val; } private: - Scalar maxOilSat_; + Evaluation maxOilSat_; unsigned regionIdx_; }; @@ -1000,7 +1000,7 @@ public: static LhsEval saturatedDissolutionFactor(const FluidState& fluidState, unsigned phaseIdx, unsigned regionIdx, - Scalar maxOilSaturation) + const LhsEval& maxOilSaturation) { assert(0 <= phaseIdx && phaseIdx <= numPhases); assert(0 <= regionIdx && regionIdx <= numRegions()); diff --git a/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp index 2b367abf9..deaa97105 100644 --- a/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp @@ -250,7 +250,7 @@ public: const Evaluation& /*temperature*/, const Evaluation& /*pressure*/, const Evaluation& /*oilSaturation*/, - Scalar /*maxOilSaturation*/) const + const Evaluation& /*maxOilSaturation*/) const { return 0.0; /* this is dead oil! */ } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp index 23fad68cf..f788c9296 100644 --- a/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp @@ -239,7 +239,7 @@ public: const Evaluation& /*temperature*/, const Evaluation& /*pressure*/, const Evaluation& /*oilSaturation*/, - Scalar /*maxOilSaturation*/) const + const Evaluation& /*maxOilSaturation*/) const { return 0.0; /* this is dead oil! */ } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp index 915e382d8..fb0b36e77 100644 --- a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp @@ -266,7 +266,7 @@ public: const Evaluation& /*temperature*/, const Evaluation& /*pressure*/, const Evaluation& /*oilSaturation*/, - Scalar /*maxOilSaturation*/) const + const Evaluation& /*maxOilSaturation*/) const { return 0.0; /* this is dry gas! */ } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp index 18597313e..6c4a30e5a 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp @@ -228,7 +228,7 @@ public: const Evaluation& temperature, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + const Evaluation& maxOilSaturation) const { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); return 0; } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp index 1be575c5b..11e13e7b8 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp @@ -328,7 +328,7 @@ public: const Evaluation& temperature, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + const Evaluation& maxOilSaturation) const { return isothermalPvt_->saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation); } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp index c3b6ce7c1..3280f2fdc 100644 --- a/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp @@ -28,8 +28,8 @@ #define OPM_LIVE_OIL_PVT_HPP #include - #include +#include #include #include @@ -500,14 +500,14 @@ public: const Evaluation& /*temperature*/, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + Evaluation maxOilSaturation) const { Evaluation tmp = saturatedGasDissolutionFactorTable_[regionIdx].eval(pressure, /*extrapolate=*/true); // apply the vaporization parameters for the gas phase (cf. the Eclipse VAPPARS // keyword) - maxOilSaturation = std::min(maxOilSaturation, Scalar(1.0)); + maxOilSaturation = Opm::min(maxOilSaturation, Scalar(1.0)); if (vapPar2_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) { static const Scalar eps = 0.001; const Evaluation& So = Opm::max(oilSaturation, eps); diff --git a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp index 413ccebd9..72f3c0478 100644 --- a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp +++ b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp @@ -215,7 +215,7 @@ public: const Evaluation& temperature, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + const Evaluation& maxOilSaturation) const { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); return 0; } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp b/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp index 9deccb464..3de6b7874 100644 --- a/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp +++ b/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp @@ -335,7 +335,7 @@ public: const Evaluation& temperature, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + const Evaluation& maxOilSaturation) const { return isothermalPvt_->saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation); } /*! diff --git a/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp b/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp index b881c104c..86417c0db 100644 --- a/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp @@ -28,6 +28,7 @@ #define OPM_WET_GAS_PVT_HPP #include +#include #include #include #include @@ -520,14 +521,14 @@ public: const Evaluation& /*temperature*/, const Evaluation& pressure, const Evaluation& oilSaturation, - Scalar maxOilSaturation) const + Evaluation maxOilSaturation) const { Evaluation tmp = saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure, /*extrapolate=*/true); // apply the vaporization parameters for the gas phase (cf. the Eclipse VAPPARS // keyword) - maxOilSaturation = std::min(maxOilSaturation, Scalar(1.0)); + maxOilSaturation = Opm::min(maxOilSaturation, Scalar(1.0)); if (vapPar1_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) { static const Scalar eps = 0.001; const Evaluation& So = Opm::max(oilSaturation, eps); diff --git a/tests/test_eclblackoilpvt.cpp b/tests/test_eclblackoilpvt.cpp index b80a664a0..d8766fb52 100644 --- a/tests/test_eclblackoilpvt.cpp +++ b/tests/test_eclblackoilpvt.cpp @@ -132,8 +132,6 @@ static const char* deckString1 = template void ensurePvtApi(const OilPvt& oilPvt, const GasPvt& gasPvt, const WaterPvt& waterPvt) { - typedef typename Opm::MathToolbox Toolbox; - // we don't want to run this, we just want to make sure that it compiles while (0) { Evaluation temperature = 273.15 + 20.0; @@ -141,7 +139,7 @@ void ensurePvtApi(const OilPvt& oilPvt, const GasPvt& gasPvt, const WaterPvt& wa Evaluation Rs = 0.0; Evaluation Rv = 0.0; Evaluation So = 0.5; - typename Toolbox::Scalar maxSo = 1.0; + Evaluation maxSo = 1.0; Evaluation tmp; /////