From f1ab605fbec129b9cb8668068932645f9364f53d Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 18 Nov 2024 13:44:54 +0100 Subject: [PATCH] move gasWaterPerfRateInj to RatioCalculator --- opm/simulators/wells/RatioCalculator.cpp | 30 +++++++++++++++++++ opm/simulators/wells/RatioCalculator.hpp | 26 +++++++++++----- opm/simulators/wells/StandardWell.hpp | 8 ----- opm/simulators/wells/StandardWell_impl.hpp | 35 ++-------------------- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/opm/simulators/wells/RatioCalculator.cpp b/opm/simulators/wells/RatioCalculator.cpp index 6df2372dc..227d547da 100644 --- a/opm/simulators/wells/RatioCalculator.cpp +++ b/opm/simulators/wells/RatioCalculator.cpp @@ -26,6 +26,7 @@ #include #include +#include #include @@ -117,6 +118,35 @@ gasOilVolumeRatio(Value& volumeRatio, volumeRatio += tmp_gas / b_perfcells_dense[gasComp_]; } +template +void +RatioCalculator:: +gasWaterPerfRateInj(const std::vector& cq_s, + PerforationRates& perf_rates, + const Value& rvw, + const Value& rsw, + const Value& pressure, + DeferredLogger& deferred_logger) const + +{ + const Scalar dw = 1.0 - getValue(rvw) * getValue(rsw); + + if (dw <= 0.0) { + deferred_logger.debug(dValueError(dw, name_, + "gasWaterPerfRateInj", + rsw, rvw, pressure)); + } else { + // vaporized water into gas + // rvw * q_gr * b_g = rvw * (q_gs - rsw * q_ws) / dw + perf_rates.vap_wat = getValue(rvw) * (getValue(cq_s[gasComp_]) - + getValue(rsw) * getValue(cq_s[waterComp_])) / dw; + // dissolved gas in water + // rsw * q_wr * b_w = rsw * (q_ws - rvw * q_gs) / dw + perf_rates.dis_gas_in_water = getValue(rsw) * (getValue(cq_s[waterComp_]) - + getValue(rvw) * getValue(cq_s[gasComp_])) / dw; + } +} + #define INSTANTIATE_TYPE(T) \ template class RatioCalculator; \ template class RatioCalculator>; \ diff --git a/opm/simulators/wells/RatioCalculator.hpp b/opm/simulators/wells/RatioCalculator.hpp index dc67a9998..67bb0d473 100644 --- a/opm/simulators/wells/RatioCalculator.hpp +++ b/opm/simulators/wells/RatioCalculator.hpp @@ -22,6 +22,8 @@ #ifndef RATIO_CALCULATOR_HPP #define RATIO_CALCULATOR_HPP +#include + #include #include #include @@ -29,16 +31,27 @@ namespace Opm { class DeferredLogger; +template struct PerforationRates; template class RatioCalculator { public: + using Scalar = decltype(getValue(Value{})); + RatioCalculator(unsigned gasCompIdx, unsigned oilCompIdx, unsigned waterCompIdx, std::string_view name); + void disOilVapWatVolumeRatio(Value& volumeRatio, + const Value& rvw, + const Value& rsw, + const Value& pressure, + const std::vector& cmix_s, + const std::vector& b_perfcells_dense, + DeferredLogger& deferred_logger) const; + void gasOilVolumeRatio(Value& volumeRatio, const Value& rv, const Value& rs, @@ -47,13 +60,12 @@ public: const std::vector& b_perfcells_dense, DeferredLogger& deferred_logger) const; - void disOilVapWatVolumeRatio(Value& volumeRatio, - const Value& rvw, - const Value& rsw, - const Value& pressure, - const std::vector& cmix_s, - const std::vector& b_perfcells_dense, - DeferredLogger& deferred_logger) const; + void gasWaterPerfRateInj(const std::vector& cq_s, + PerforationRates& perf_rates, + const Value& rvw, + const Value& rsw, + const Value& pressure, + DeferredLogger& deferred_logger) const; private: unsigned gasComp_; diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 70ade64f0..6b76a62a8 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -489,14 +489,6 @@ namespace Opm PerforationRates& perf_rates, const Value& rvw, const Value& rsw) const; - - template - void gasWaterPerfRateInj(const std::vector& cq_s, - PerforationRates& perf_rates, - const Value& rvw, - const Value& rsw, - const Value& pressure, - DeferredLogger& deferred_logger) const; }; } diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index feb0f8117..5368fbf67 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -345,8 +345,8 @@ namespace Opm } if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { //no oil - gasWaterPerfRateInj(cq_s, perf_rates, rvw, rsw, - pressure, deferred_logger); + ratioCalc.gasWaterPerfRateInj(cq_s, perf_rates, rvw, rsw, + pressure, deferred_logger); } } } @@ -2764,35 +2764,4 @@ namespace Opm } } - - template - template - void - StandardWell:: - gasWaterPerfRateInj(const std::vector& cq_s, - PerforationRates& perf_rates, - const Value& rvw, - const Value& rsw, - const Value& pressure, - DeferredLogger& deferred_logger) const - - { - const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - const unsigned waterCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::waterCompIdx); - - const Scalar dw = 1.0 - getValue(rvw) * getValue(rsw); - - if (dw <= 0.0) { - deferred_logger.debug(dValueError(dw, this->name(), - "gasWaterPerfRateInj", - rsw, rvw, pressure)); - } else { - // vaporized water into gas - // rvw * q_gr * b_g = rvw * (q_gs - rsw * q_ws) / dw - perf_rates.vap_wat = getValue(rvw) * (getValue(cq_s[gasCompIdx]) - getValue(rsw) * getValue(cq_s[waterCompIdx])) / dw; - // dissolved gas in water - // rsw * q_wr * b_w = rsw * (q_ws - rvw * q_gs) / dw - perf_rates.dis_gas_in_water = getValue(rsw) * (getValue(cq_s[waterCompIdx]) - getValue(rvw) * getValue(cq_s[gasCompIdx])) / dw; - } - } } // namespace Opm