diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.cpp b/opm/simulators/wells/WellInterfaceFluidSystem.cpp index d46f12954..7640f2a15 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -590,41 +590,6 @@ checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits, } } -template -void -WellInterfaceFluidSystem:: -checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits, - const SingleWellState& ws, - RatioLimitCheckReport& report) const -{ - assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)); - assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)); - - // function to calculate wgr based on rates - auto wgr = [](const std::vector& rates, - const PhaseUsage& pu) { - - const double water_rate = -rates[pu.phase_pos[Water]]; - const double gas_rate = -rates[pu.phase_pos[Gas]]; - if (water_rate <= 0.) - return 0.; - else if (gas_rate <= 0.) - return 1.e100; // big value to mark it as violated - else - return (water_rate / gas_rate); - }; - - const double max_wgr_limit = econ_production_limits.maxWaterGasRatio(); - assert(max_wgr_limit > 0.); - - const bool wgr_limit_violated = WellTest(*this).checkMaxRatioLimitWell(ws, max_wgr_limit, wgr); - - if (wgr_limit_violated) { - report.ratio_limit_violated = true; - WellTest(*this).checkMaxRatioLimitCompletions(ws, max_wgr_limit, wgr, report); - } -} - template void WellInterfaceFluidSystem:: @@ -652,7 +617,9 @@ checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits, } if (econ_production_limits.onMaxWaterGasRatio()) { - checkMaxWGRLimit(econ_production_limits, ws, report); + assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)); + assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)); + WellTest(*this).checkMaxWGRLimit(econ_production_limits, ws, report); } if (econ_production_limits.onMaxGasLiquidRatio()) { diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.hpp b/opm/simulators/wells/WellInterfaceFluidSystem.hpp index d5087fbea..9f5b478df 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.hpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.hpp @@ -131,10 +131,6 @@ protected: const SingleWellState& ws, RatioLimitCheckReport& report) const; - void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits, - const SingleWellState& ws, - RatioLimitCheckReport& report) const; - void checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits, const SingleWellState& ws, RatioLimitCheckReport& report, diff --git a/opm/simulators/wells/WellTest.cpp b/opm/simulators/wells/WellTest.cpp index a3fa18228..fbd475998 100644 --- a/opm/simulators/wells/WellTest.cpp +++ b/opm/simulators/wells/WellTest.cpp @@ -119,5 +119,36 @@ void WellTest::checkMaxGORLimit(const WellEconProductionLimits& econ_production_ } } +void WellTest::checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits, + const SingleWellState& ws, + RatioLimitCheckReport& report) const +{ + static constexpr int Gas = BlackoilPhases::Vapour; + static constexpr int Water = BlackoilPhases::Aqua; + + // function to calculate wgr based on rates + auto wgr = [](const std::vector& rates, + const PhaseUsage& pu) { + + const double water_rate = -rates[pu.phase_pos[Water]]; + const double gas_rate = -rates[pu.phase_pos[Gas]]; + if (water_rate <= 0.) + return 0.; + else if (gas_rate <= 0.) + return 1.e100; // big value to mark it as violated + else + return (water_rate / gas_rate); + }; + + const double max_wgr_limit = econ_production_limits.maxWaterGasRatio(); + assert(max_wgr_limit > 0.); + + const bool wgr_limit_violated = this->checkMaxRatioLimitWell(ws, max_wgr_limit, wgr); + + if (wgr_limit_violated) { + report.ratio_limit_violated = true; + this->checkMaxRatioLimitCompletions(ws, max_wgr_limit, wgr, report); + } +} } // namespace Opm diff --git a/opm/simulators/wells/WellTest.hpp b/opm/simulators/wells/WellTest.hpp index 59033a91c..3d90cf46d 100644 --- a/opm/simulators/wells/WellTest.hpp +++ b/opm/simulators/wells/WellTest.hpp @@ -64,6 +64,11 @@ public: void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits, const SingleWellState& ws, RatioLimitCheckReport& report) const; + + void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits, + const SingleWellState& ws, + RatioLimitCheckReport& report) const; + private: const WellInterfaceGeneric& well_; //!< Reference to well interface };