From 24777604aee9c5c27bf6598d7a04d29c1886d902 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 18 Nov 2024 13:44:54 +0100 Subject: [PATCH] move gasOilPerfRateProd to RatioCalculator --- opm/simulators/wells/RatioCalculator.cpp | 35 ++++++++++++++- opm/simulators/wells/RatioCalculator.hpp | 8 ++++ opm/simulators/wells/StandardWell.hpp | 7 --- opm/simulators/wells/StandardWell_impl.hpp | 50 ++++------------------ 4 files changed, 51 insertions(+), 49 deletions(-) diff --git a/opm/simulators/wells/RatioCalculator.cpp b/opm/simulators/wells/RatioCalculator.cpp index 4c44db426..f08d00fed 100644 --- a/opm/simulators/wells/RatioCalculator.cpp +++ b/opm/simulators/wells/RatioCalculator.cpp @@ -90,6 +90,40 @@ disOilVapWatVolumeRatio(Value& volumeRatio, volumeRatio += tmp_gas / b_perfcells_dense[gasComp_]; } +template +void +RatioCalculator:: +gasOilPerfRateProd(std::vector& cq_s, + PerforationRates& perf_rates, + const Value& rv, + const Value& rs, + const Value& rvw, + const bool waterActive, + const bool isProducer) const +{ + const Value cq_sOil = cq_s[oilComp_]; + const Value cq_sGas = cq_s[gasComp_]; + const Value dis_gas = rs * cq_sOil; + const Value vap_oil = rv * cq_sGas; + + cq_s[gasComp_] += dis_gas; + cq_s[oilComp_] += vap_oil; + + // recording the perforation solution gas rate and solution oil rates + if (isProducer) { + perf_rates.dis_gas = getValue(dis_gas); + perf_rates.vap_oil = getValue(vap_oil); + } + + if (waterActive) { + const Value vap_wat = rvw * cq_sGas; + cq_s[waterComp_] += vap_wat; + if (isProducer) { + perf_rates.vap_wat = getValue(vap_wat); + } + } +} + template void RatioCalculator:: @@ -127,7 +161,6 @@ gasWaterPerfRateInj(const std::vector& cq_s, const Value& rsw, const Value& pressure, DeferredLogger& deferred_logger) const - { const Scalar dw = 1.0 - getValue(rvw) * getValue(rsw); diff --git a/opm/simulators/wells/RatioCalculator.hpp b/opm/simulators/wells/RatioCalculator.hpp index 0c0b48298..b84267eed 100644 --- a/opm/simulators/wells/RatioCalculator.hpp +++ b/opm/simulators/wells/RatioCalculator.hpp @@ -52,6 +52,14 @@ public: const std::vector& b_perfcells_dense, DeferredLogger& deferred_logger) const; + void gasOilPerfRateProd(std::vector& cq_s, + PerforationRates& perf_rates, + const Value& rv, + const Value& rs, + const Value& rvw, + const bool waterActive, + const bool isProducer) const; + void gasOilVolumeRatio(Value& volumeRatio, const Value& rv, const Value& rs, diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 098e0aff5..b788a6578 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -476,13 +476,6 @@ namespace Opm const Value& pressure, const Value& rvw, DeferredLogger& deferred_logger) const; - - template - void gasOilPerfRateProd(std::vector& cq_s, - PerforationRates& perf_rates, - const Value& rv, - const Value& rs, - const Value& rvw) const; }; } diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 9ff5edbf3..c416ffce5 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -272,9 +272,15 @@ namespace Opm cq_s[componentIdx] = b_perfcells_dense[componentIdx] * cq_p; } - if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { - gasOilPerfRateProd(cq_s, perf_rates, rv, rs, rvw); - } else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { + if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && + FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) + { + ratioCalc.gasOilPerfRateProd(cq_s, perf_rates, rv, rs, rvw, + FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx), + this->isProducer()); + } else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && + FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) + { ratioCalc.gasWaterPerfRateProd(cq_s, perf_rates, rvw, rsw, this->isProducer()); } } else { @@ -2702,42 +2708,4 @@ namespace Opm perf_rates.vap_wat = getValue(rvw) * (getValue(cq_s[gasCompIdx]) - getValue(rs) * getValue(cq_s[oilCompIdx])) / d; } } - - - - template - template - void - StandardWell:: - gasOilPerfRateProd(std::vector& cq_s, - PerforationRates& perf_rates, - const Value& rv, - const Value& rs, - const Value& rvw) const - { - const unsigned oilCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::oilCompIdx); - const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - const Value cq_sOil = cq_s[oilCompIdx]; - const Value cq_sGas = cq_s[gasCompIdx]; - const Value dis_gas = rs * cq_sOil; - const Value vap_oil = rv * cq_sGas; - - cq_s[gasCompIdx] += dis_gas; - cq_s[oilCompIdx] += vap_oil; - - // recording the perforation solution gas rate and solution oil rates - if (this->isProducer()) { - perf_rates.dis_gas = getValue(dis_gas); - perf_rates.vap_oil = getValue(vap_oil); - } - - if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { - const unsigned waterCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx); - const Value vap_wat = rvw * cq_sGas; - cq_s[waterCompIdx] += vap_wat; - if (this->isProducer()) - perf_rates.vap_wat = getValue(vap_wat); - } - } - } // namespace Opm