diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index 77419b436..98dd4037c 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -446,6 +446,12 @@ namespace Opm std::tuple connectionRatesMICP(const std::vector& cq_s, const IntensiveQuantities& intQuants) const; + + std::tuple + connectionRatezFraction(double& rate, + const double dis_gas_rate, + const std::vector& cq_s, + const IntensiveQuantities& intQuants) const; }; } diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 5789fdfe2..1e29292bb 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -745,20 +745,10 @@ namespace Opm } if constexpr (has_zFraction) { - // TODO: the application of well efficiency factor has not been tested with an example yet - const unsigned gasCompIdx = Indices::canonicalToActiveComponentIndex(FluidSystem::gasCompIdx); - 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 = perf_rates.dis_gas / cq_s_zfrac_effective.value(); - cq_s_zfrac_effective *= this->extendEval(dis_gas_frac*intQuants.xVolume() + (1.0-dis_gas_frac)*intQuants.yVolume()); - } - auto& perf_rate_solvent = perf_data.solvent_rates; - perf_rate_solvent[perf] = cq_s_zfrac_effective.value(); - - cq_s_zfrac_effective *= this->well_efficiency_factor_; - connectionRates[perf][Indices::contiZfracEqIdx] = Base::restrictEval(cq_s_zfrac_effective); + std::tie(connectionRates[perf][Indices::contiZfracEqIdx], + cq_s_zfrac_effective) = + connectionRatezFraction(perf_data.solvent_rates[perf], + perf_rates.dis_gas, cq_s, intQuants); } if constexpr (has_brine) { @@ -2410,4 +2400,30 @@ namespace Opm Base::restrictEval(cq_s_urea)}; } + + 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}; + } + } // namespace Opm