From b4c8dd5e86f0827255adaf255e780f52aadfbc9f Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 2 Jul 2020 13:42:58 +0200 Subject: [PATCH] make the water PVT salt dependent --- .../fluidstates/BlackOilFluidState.hpp | 12 +++++++++ .../fluidsystems/BlackOilFluidSystem.hpp | 12 ++++++--- .../blackoilpvt/WaterPvtMultiplexer.hpp | 27 ------------------- tests/test_eclblackoilpvt.cpp | 7 +++-- tests/test_fluidsystems.cpp | 3 ++- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/opm/material/fluidstates/BlackOilFluidState.hpp b/opm/material/fluidstates/BlackOilFluidState.hpp index 7a9b380cc..e85f36bc0 100644 --- a/opm/material/fluidstates/BlackOilFluidState.hpp +++ b/opm/material/fluidstates/BlackOilFluidState.hpp @@ -76,6 +76,18 @@ LhsEval getInvB_(typename std::enable_if::value, /FluidSystem::referenceDensity(phaseIdx, pvtRegionIdx); } +OPM_GENERATE_HAS_MEMBER(saltConcentration, ) // Creates 'HasMember_saltConcentration'. + +template +unsigned getSaltConcentration_(typename std::enable_if::value, + const FluidState&>::type fluidState) +{ return fluidState.saltConcentration(); } + +template +unsigned getSaltConcentration_(typename std::enable_if::value, + const FluidState&>::type fluidState OPM_UNUSED) +{ return 0; } + /*! * \brief Implements a "tailor-made" fluid state class for the black-oil model. * diff --git a/opm/material/fluidsystems/BlackOilFluidSystem.hpp b/opm/material/fluidsystems/BlackOilFluidSystem.hpp index 9b786d759..16b15afca 100644 --- a/opm/material/fluidsystems/BlackOilFluidSystem.hpp +++ b/opm/material/fluidsystems/BlackOilFluidSystem.hpp @@ -603,6 +603,7 @@ public: const LhsEval& p = Opm::decay(fluidState.pressure(phaseIdx)); const LhsEval& T = Opm::decay(fluidState.temperature(phaseIdx)); + const LhsEval& saltConcentration = Opm::BlackOil::template getSaltConcentration_(fluidState, regionIdx); switch (phaseIdx) { case oilPhaseIdx: { @@ -643,7 +644,7 @@ public: case waterPhaseIdx: return referenceDensity(waterPhaseIdx, regionIdx) - * waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p); + * waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, saltConcentration); } throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx)); @@ -731,6 +732,7 @@ public: const auto& p = Opm::decay(fluidState.pressure(phaseIdx)); const auto& T = Opm::decay(fluidState.temperature(phaseIdx)); + const auto& saltConcentration = Opm::decay(fluidState.saltConcentration()); switch (phaseIdx) { case oilPhaseIdx: { @@ -764,7 +766,7 @@ public: return gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv); } case waterPhaseIdx: - return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p); + return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, saltConcentration); default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx)); } } @@ -786,11 +788,12 @@ public: const auto& p = Opm::decay(fluidState.pressure(phaseIdx)); const auto& T = Opm::decay(fluidState.temperature(phaseIdx)); + const auto& saltConcentration = Opm::decay(fluidState.saltConcentration()); switch (phaseIdx) { case oilPhaseIdx: return oilPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p); case gasPhaseIdx: return gasPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p); - case waterPhaseIdx: return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p); + case waterPhaseIdx: return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, saltConcentration); default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx)); } } @@ -928,6 +931,7 @@ public: const LhsEval& p = Opm::decay(fluidState.pressure(phaseIdx)); const LhsEval& T = Opm::decay(fluidState.temperature(phaseIdx)); + const LhsEval& saltConcentration = Opm::BlackOil::template getSaltConcentration_(fluidState, regionIdx); switch (phaseIdx) { case oilPhaseIdx: { @@ -965,7 +969,7 @@ public: case waterPhaseIdx: // since water is always assumed to be immiscible in the black-oil model, // there is no "saturated water" - return waterPvt_->viscosity(regionIdx, T, p); + return waterPvt_->viscosity(regionIdx, T, p, saltConcentration); } throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx)); diff --git a/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp b/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp index eea6c69e9..d1b4b248e 100644 --- a/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp +++ b/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp @@ -151,20 +151,6 @@ public: const Evaluation& pressure) const { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure)); return 0; } - /*! - * \brief Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters. - */ - template - Evaluation viscosity(unsigned regionIdx, - const Evaluation& temperature, - const Evaluation& pressure) const - { - // assert(realWaterPvt_ != ConstantCompressibilityBrinePvt ); - const Evaluation saltconcentration = 0.0; - OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, saltconcentration)); - return 0; - } - /*! * \brief Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters. */ @@ -190,19 +176,6 @@ public: return 0; } - /*! - * \brief Returns the formation volume factor [-] of the fluid phase. - */ - template - Evaluation inverseFormationVolumeFactor(unsigned regionIdx, - const Evaluation& temperature, - const Evaluation& pressure) const - { - const Evaluation saltconcentration = 0.0; - OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration)); - return 0; - } - void setApproach(WaterPvtApproach appr) { switch (appr) { diff --git a/tests/test_eclblackoilpvt.cpp b/tests/test_eclblackoilpvt.cpp index cc05001f9..4494a68f1 100644 --- a/tests/test_eclblackoilpvt.cpp +++ b/tests/test_eclblackoilpvt.cpp @@ -139,6 +139,7 @@ void ensurePvtApi(const OilPvt& oilPvt, const GasPvt& gasPvt, const WaterPvt& wa while (0) { Evaluation temperature = 273.15 + 20.0; Evaluation pressure = 1e5; + Evaluation saltconcentration = 0.0; Evaluation Rs = 0.0; Evaluation Rv = 0.0; Evaluation So = 0.5; @@ -150,10 +151,12 @@ void ensurePvtApi(const OilPvt& oilPvt, const GasPvt& gasPvt, const WaterPvt& wa ///// tmp = waterPvt.viscosity(/*regionIdx=*/0, temperature, - pressure); + pressure, + saltconcentration); tmp = waterPvt.inverseFormationVolumeFactor(/*regionIdx=*/0, temperature, - pressure); + pressure, + saltconcentration); ///// // oil PVT API diff --git a/tests/test_fluidsystems.cpp b/tests/test_fluidsystems.cpp index 5586f39c8..ca0d1e7cb 100644 --- a/tests/test_fluidsystems.cpp +++ b/tests/test_fluidsystems.cpp @@ -53,6 +53,7 @@ #include #include #include +#include // include the tables for CO2 which are delivered with opm-material by default #include @@ -83,7 +84,7 @@ void ensureBlackoilApi() #endif typedef typename FluidSystem::Scalar Scalar; - typedef Opm::CompositionalFluidState FluidState; + typedef Opm::BlackOilFluidState FluidState; FluidState fluidState; Evaluation XoG = 0.0; Evaluation XgO = 0.0;