diff --git a/opm/material/fluidsystems/BlackOilFluidSystem.hpp b/opm/material/fluidsystems/BlackOilFluidSystem.hpp index ffbd12361..649b54ca2 100644 --- a/opm/material/fluidsystems/BlackOilFluidSystem.hpp +++ b/opm/material/fluidsystems/BlackOilFluidSystem.hpp @@ -1274,6 +1274,26 @@ public: return canonicalToActivePhaseIdx_[phaseIdx]; } + /*! + * \copydoc BaseFluidSystem::diffusionCoefficient + */ + template + static LhsEval diffusionCoefficient(const FluidState& fluidState, + const ParameterCache& /*paramCache*/, + unsigned phaseIdx, + unsigned compIdx) + { + const auto& p = Opm::decay(fluidState.pressure(phaseIdx)); + const auto& T = Opm::decay(fluidState.temperature(phaseIdx)); + + switch (phaseIdx) { + case oilPhaseIdx: return oilPvt().diffusionCoefficient(T, p, compIdx); + case gasPhaseIdx: return gasPvt().diffusionCoefficient(T, p, compIdx); + case waterPhaseIdx: return 0.0; + default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx)); + } + } + private: static void resizeArrays_(size_t numRegions) { diff --git a/opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp b/opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp index e3ba4f2aa..7f824f937 100644 --- a/opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp @@ -276,6 +276,14 @@ public: brineReferenceDensity_ == data.brineReferenceDensity_; } + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned /*compIdx*/) const + { + return BinaryCoeffBrineCO2::liquidDiffCoeff(temperature, pressure); + } + private: std::vector brineReferenceDensity_; std::vector co2ReferenceDensity_; diff --git a/opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp b/opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp index fceeff9dc..85edeb5a3 100644 --- a/opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp @@ -31,7 +31,9 @@ #include #include +#include #include +#include #include #if HAVE_ECL_INPUT @@ -52,10 +54,14 @@ class Co2GasPvt { typedef std::vector > SamplingPoints; typedef Opm::CO2 CO2; + typedef Opm::SimpleHuDuanH2O H2O; public: typedef Opm::Tabulated1DFunction TabulatedOneDFunction; + //! The binary coefficients for brine and CO2 used by this fluid system + typedef Opm::BinaryCoeff::Brine_CO2 BinaryCoeffBrineCO2; + explicit Co2GasPvt() = default; Co2GasPvt(const std::vector& gasReferenceDensity) : gasReferenceDensity_(gasReferenceDensity) @@ -205,6 +211,14 @@ public: const Evaluation& /*pressure*/) const { return 0.0; /* this is dry gas! */ } + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned /*compIdx*/) const + { + return BinaryCoeffBrineCO2::gasDiffCoeff(temperature, pressure); + } + const Scalar gasReferenceDensity(unsigned regionIdx) const { return gasReferenceDensity_[regionIdx]; } diff --git a/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp index 470c51160..cd92b685b 100644 --- a/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp @@ -272,6 +272,14 @@ public: const Evaluation& /*Rs*/) const { return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } + const Scalar oilReferenceDensity(unsigned regionIdx) const { return oilReferenceDensity_[regionIdx]; } diff --git a/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp index 513b7f23d..6bf552d4f 100644 --- a/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp @@ -278,6 +278,14 @@ public: const Evaluation& /*pressure*/) const { return 0.0; /* this is dead oil! */ } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } + const Scalar oilReferenceDensity(unsigned regionIdx) const { return oilReferenceDensity_[regionIdx]; } diff --git a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp index acfba2683..952d6194c 100644 --- a/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp @@ -288,6 +288,14 @@ public: const Evaluation& /*pressure*/) const { return 0.0; /* this is dry gas! */ } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } + const Scalar gasReferenceDensity(unsigned regionIdx) const { return gasReferenceDensity_[regionIdx]; } diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp index 845c18674..e196947a4 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp @@ -272,6 +272,17 @@ public: const Evaluation& Rv) const { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); return 0; } + /*! + * \copydoc BaseFluidSystem::diffusionCoefficient + */ + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned compIdx) const + { + OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx)); return 0; + } + /*! * \brief Returns the concrete approach for calculating the PVT relations. * diff --git a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp index 01c98eb9c..a18406e9a 100644 --- a/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp +++ b/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp @@ -367,6 +367,13 @@ public: const Evaluation& pressure) const { return isothermalPvt_->saturationPressure(regionIdx, temperature, pressure); } + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned compIdx) const + { + return isothermalPvt_->diffusionCoefficient(temperature, pressure, compIdx); + } const IsothermalPvt* isoThermalPvt() const { return isothermalPvt_; } diff --git a/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp b/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp index 0d95dad75..eafce2a39 100644 --- a/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp @@ -602,6 +602,13 @@ public: throw NumericalIssue(errlog.str()); } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } const Scalar gasReferenceDensity(unsigned regionIdx) const { return gasReferenceDensity_[regionIdx]; } diff --git a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp index c68f64352..9c88fb909 100644 --- a/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp +++ b/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp @@ -266,6 +266,17 @@ public: const Evaluation& Rs) const { OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs)); return 0; } + /*! + * \copydoc BaseFluidSystem::diffusionCoefficient + */ + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned compIdx) const + { + OPM_OIL_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx)); return 0; + } + void setApproach(OilPvtApproach appr) { switch (appr) { diff --git a/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp b/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp index 8abf2de11..df7ac6304 100644 --- a/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp +++ b/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp @@ -377,6 +377,14 @@ public: const Evaluation& pressure) const { return isothermalPvt_->saturationPressure(regionIdx, temperature, pressure); } + template + Evaluation diffusionCoefficient(const Evaluation& temperature, + const Evaluation& pressure, + unsigned compIdx) const + { + return isothermalPvt_->diffusionCoefficient(temperature, pressure, compIdx); + } + const IsothermalPvt* isoThermalPvt() const { return isothermalPvt_; } diff --git a/opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp b/opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp index 8942ec026..d99c0d3dd 100644 --- a/opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp @@ -189,6 +189,14 @@ public: return invBg/invMugBg; } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } + /*! * \brief Return the reference density the solvent phase for a given PVT region */ diff --git a/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp b/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp index 14fb73676..9f8db806c 100644 --- a/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp +++ b/opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp @@ -628,6 +628,14 @@ public: throw NumericalIssue(errlog.str()); } + template + Evaluation diffusionCoefficient(const Evaluation& /*temperature*/, + const Evaluation& /*pressure*/, + unsigned /*compIdx*/) const + { + throw std::runtime_error("Not implemented: The PVT model does not provide a diffusionCoefficient()"); + } + const Scalar gasReferenceDensity(unsigned regionIdx) const { return gasReferenceDensity_[regionIdx]; }