move checkMaxWaterCutLimit to WellTest

This commit is contained in:
Arne Morten Kvarving 2022-10-24 11:06:35 +02:00
parent e7273868f5
commit 2b152e67e1
4 changed files with 57 additions and 58 deletions

View File

@ -550,46 +550,6 @@ checkRateEconLimits(const WellEconProductionLimits& econ_production_limits,
return false;
}
template<typename FluidSystem>
void
WellInterfaceFluidSystem<FluidSystem>::
checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const
{
assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx));
assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx));
// function to calculate water cut based on rates
auto waterCut = [](const std::vector<double>& rates,
const PhaseUsage& pu) {
const double oil_rate = -rates[pu.phase_pos[Oil]];
const double water_rate = -rates[pu.phase_pos[Water]];
const double liquid_rate = oil_rate + water_rate;
if (liquid_rate <= 0.)
return 0.;
else if (water_rate < 0)
return 0.;
else if (oil_rate < 0)
return 1.;
else
return (water_rate / liquid_rate);
};
const double max_water_cut_limit = econ_production_limits.maxWaterCut();
assert(max_water_cut_limit > 0.);
const bool watercut_limit_violated =
WellTest(*this).checkMaxRatioLimitWell(ws, max_water_cut_limit, waterCut);
if (watercut_limit_violated) {
report.ratio_limit_violated = true;
WellTest(*this).checkMaxRatioLimitCompletions(ws, max_water_cut_limit,
waterCut, report);
}
}
template<typename FluidSystem>
void
WellInterfaceFluidSystem<FluidSystem>::
@ -607,7 +567,9 @@ checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
// extent.
if (econ_production_limits.onMaxWaterCut()) {
checkMaxWaterCutLimit(econ_production_limits, ws, report);
assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx));
assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx));
WellTest(*this).checkMaxWaterCutLimit(econ_production_limits, ws, report);
}
if (econ_production_limits.onMaxGasOilRatio()) {

View File

@ -127,10 +127,6 @@ protected:
const double* rates_or_potentials,
Opm::DeferredLogger& deferred_logger) const;
void checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
void checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report,

View File

@ -29,6 +29,7 @@
namespace Opm
{
template<class RatioFunc>
bool WellTest::checkMaxRatioLimitWell(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc) const
@ -44,6 +45,7 @@ bool WellTest::checkMaxRatioLimitWell(const SingleWellState& ws,
return (well_ratio > max_ratio_limit);
}
template<class RatioFunc>
void WellTest::checkMaxRatioLimitCompletions(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc,
@ -151,4 +153,41 @@ void WellTest::checkMaxWGRLimit(const WellEconProductionLimits& econ_production_
}
}
void WellTest::checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const
{
static constexpr int Oil = BlackoilPhases::Liquid;
static constexpr int Water = BlackoilPhases::Aqua;
// function to calculate water cut based on rates
auto waterCut = [](const std::vector<double>& rates,
const PhaseUsage& pu) {
const double oil_rate = -rates[pu.phase_pos[Oil]];
const double water_rate = -rates[pu.phase_pos[Water]];
const double liquid_rate = oil_rate + water_rate;
if (liquid_rate <= 0.)
return 0.;
else if (water_rate < 0)
return 0.;
else if (oil_rate < 0)
return 1.;
else
return (water_rate / liquid_rate);
};
const double max_water_cut_limit = econ_production_limits.maxWaterCut();
assert(max_water_cut_limit > 0.);
const bool watercut_limit_violated =
this->checkMaxRatioLimitWell(ws, max_water_cut_limit, waterCut);
if (watercut_limit_violated) {
report.ratio_limit_violated = true;
this->checkMaxRatioLimitCompletions(ws, max_water_cut_limit,
waterCut, report);
}
}
} // namespace Opm

View File

@ -24,7 +24,6 @@
#ifndef OPM_WELL_TEST_HEADER_INCLUDED
#define OPM_WELL_TEST_HEADER_INCLUDED
#include <functional>
#include <limits>
#include <vector>
@ -49,18 +48,6 @@ public:
//! \brief Constructor sets reference to well.
WellTest(const WellInterfaceGeneric& well) : well_(well) {}
using RatioFunc = std::function<double(const std::vector<double>& rates,
const PhaseUsage& pu)>;
bool checkMaxRatioLimitWell(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc) const;
void checkMaxRatioLimitCompletions(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc,
RatioLimitCheckReport& report) const;
void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
@ -69,7 +56,22 @@ public:
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
void checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
private:
template<class RatioFunc>
bool checkMaxRatioLimitWell(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc) const;
template<class RatioFunc>
void checkMaxRatioLimitCompletions(const SingleWellState& ws,
const double max_ratio_limit,
const RatioFunc& ratioFunc,
RatioLimitCheckReport& report) const;
const WellInterfaceGeneric& well_; //!< Reference to well interface
};