diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 2bccd2058..d80519ef0 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -443,12 +443,6 @@ namespace Opm const IntensiveQuantities& intQuants, DeferredLogger& deferred_logger) const; - std::tuple - connectionRatezFraction(double& rate, - const double dis_gas_rate, - const std::vector& cq_s, - const IntensiveQuantities& intQuants) const; - template void gasOilPerfRateInj(const std::vector& cq_s, PerforationRates& perf_rates, diff --git a/opm/simulators/wells/StandardWellConnections.cpp b/opm/simulators/wells/StandardWellConnections.cpp index 8feff450c..efbecffae 100644 --- a/opm/simulators/wells/StandardWellConnections.cpp +++ b/opm/simulators/wells/StandardWellConnections.cpp @@ -639,6 +639,32 @@ connectionRatePolymer(double& rate, return {well_.restrictEval(cq_s_poly), cq_s_poly}; } +template +std::tuple::Eval, + typename StandardWellConnections::EvalWell> +StandardWellConnections:: +connectionRatezFraction(double& rate, + const double dis_gas_rate, + const std::vector& cq_s, + const std::variant>& solventConcentration) const +{ + // TODO: the application of well efficiency factor has not been tested with an example yet + const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); + EvalWell cq_s_zfrac_effective = cq_s[gasCompIdx]; + if (well_.isInjector()) { + cq_s_zfrac_effective *= std::get(solventConcentration); + } else if (cq_s_zfrac_effective.value() != 0.0) { + const double dis_gas_frac = dis_gas_rate / cq_s_zfrac_effective.value(); + const auto& vol = std::get>(solventConcentration); + cq_s_zfrac_effective *= dis_gas_frac * vol[0] + (1.0 - dis_gas_frac) * vol[1]; + } + + rate = cq_s_zfrac_effective.value(); + + cq_s_zfrac_effective *= well_.wellEfficiencyFactor(); + return {well_.restrictEval(cq_s_zfrac_effective), cq_s_zfrac_effective}; +} + #define INSTANCE(...) \ template class StandardWellConnections, \ __VA_ARGS__,double>; diff --git a/opm/simulators/wells/StandardWellConnections.hpp b/opm/simulators/wells/StandardWellConnections.hpp index 515c31758..073e85d13 100644 --- a/opm/simulators/wells/StandardWellConnections.hpp +++ b/opm/simulators/wells/StandardWellConnections.hpp @@ -104,6 +104,12 @@ public: const std::variant& oxygenConcentration, const std::variant& ureaConcentration) const; + std::tuple + connectionRatezFraction(double& rate, + const double dis_gas_rate, + const std::vector& cq_s, + const std::variant>& solventConcentration) const; + private: void computePressureDelta(); diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 787a8c818..3a252f606 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -558,10 +558,18 @@ namespace Opm } if constexpr (has_zFraction) { + std::variant> solventConcentration; + if (this->isInjector()) { + solventConcentration = this->wsolvent(); + } else { + solventConcentration = std::array{this->extendEval(intQuants.xVolume()), + this->extendEval(intQuants.yVolume())}; + } std::tie(connectionRates[perf][Indices::contiZfracEqIdx], cq_s_zfrac_effective) = - connectionRatezFraction(perf_data.solvent_rates[perf], - perf_rates.dis_gas, cq_s, intQuants); + this->connections_.connectionRatezFraction(perf_data.solvent_rates[perf], + perf_rates.dis_gas, cq_s, + solventConcentration); } if constexpr (has_brine) { @@ -2256,32 +2264,6 @@ namespace Opm } - template - std::tuple::Eval, - typename StandardWell::EvalWell> - StandardWell:: - connectionRatezFraction(double& rate, - const double dis_gas_rate, - const std::vector& cq_s, - const IntensiveQuantities& intQuants) const - { - // TODO: the application of well efficiency factor has not been tested with an example yet - const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - EvalWell cq_s_zfrac_effective = cq_s[gasCompIdx]; - if (this->isInjector()) { - cq_s_zfrac_effective *= this->wsolvent(); - } else if (cq_s_zfrac_effective.value() != 0.0) { - const double dis_gas_frac = dis_gas_rate / cq_s_zfrac_effective.value(); - cq_s_zfrac_effective *= this->extendEval(dis_gas_frac*intQuants.xVolume() + (1.0-dis_gas_frac)*intQuants.yVolume()); - } - - rate = cq_s_zfrac_effective.value(); - - cq_s_zfrac_effective *= this->well_efficiency_factor_; - return {Base::restrictEval(cq_s_zfrac_effective), cq_s_zfrac_effective}; - } - - template template void