move checkMaxGORLimit to WellTest

This commit is contained in:
Arne Morten Kvarving 2022-10-24 11:06:35 +02:00
parent 37f51420f6
commit fe8259bb76
4 changed files with 41 additions and 39 deletions

View File

@ -590,40 +590,6 @@ checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
}
}
template<typename FluidSystem>
void
WellInterfaceFluidSystem<FluidSystem>::
checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const
{
assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx));
assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx));
// function to calculate gor based on rates
auto gor = [](const std::vector<double>& rates,
const PhaseUsage& pu) {
const double oil_rate = -rates[pu.phase_pos[Oil]];
const double gas_rate = -rates[pu.phase_pos[Gas]];
if (gas_rate <= 0.)
return 0.;
else if (oil_rate <= 0.)
return 1.e100; // big value to mark it as violated
else
return (gas_rate / oil_rate);
};
const double max_gor_limit = econ_production_limits.maxGasOilRatio();
assert(max_gor_limit > 0.);
const bool gor_limit_violated = WellTest(*this).checkMaxRatioLimitWell(ws, max_gor_limit, gor);
if (gor_limit_violated) {
report.ratio_limit_violated = true;
WellTest(*this).checkMaxRatioLimitCompletions(ws, max_gor_limit, gor, report);
}
}
template<typename FluidSystem>
void
WellInterfaceFluidSystem<FluidSystem>::
@ -680,7 +646,9 @@ checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
}
if (econ_production_limits.onMaxGasOilRatio()) {
checkMaxGORLimit(econ_production_limits, ws, report);
assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx));
assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx));
WellTest(*this).checkMaxGORLimit(econ_production_limits, ws, report);
}
if (econ_production_limits.onMaxWaterGasRatio()) {

View File

@ -131,10 +131,6 @@ protected:
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
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;

View File

@ -22,6 +22,7 @@
#include <config.h>
#include <opm/simulators/wells/WellTest.hpp>
#include <opm/simulators/wells/ParallelWellInfo.hpp>
#include <opm/simulators/wells/SingleWellState.hpp>
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
@ -87,4 +88,36 @@ void WellTest::checkMaxRatioLimitCompletions(const SingleWellState& ws,
}
}
void WellTest::checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const
{
static constexpr int Oil = BlackoilPhases::Liquid;
static constexpr int Gas = BlackoilPhases::Vapour;
// function to calculate gor based on rates
auto gor = [](const std::vector<double>& rates,
const PhaseUsage& pu) {
const double oil_rate = -rates[pu.phase_pos[Oil]];
const double gas_rate = -rates[pu.phase_pos[Gas]];
if (gas_rate <= 0.)
return 0.;
else if (oil_rate <= 0.)
return 1.e100; // big value to mark it as violated
else
return (gas_rate / oil_rate);
};
const double max_gor_limit = econ_production_limits.maxGasOilRatio();
assert(max_gor_limit > 0.);
const bool gor_limit_violated = this->checkMaxRatioLimitWell(ws, max_gor_limit, gor);
if (gor_limit_violated) {
report.ratio_limit_violated = true;
this->checkMaxRatioLimitCompletions(ws, max_gor_limit, gor, report);
}
}
} // namespace Opm

View File

@ -33,6 +33,7 @@ namespace Opm
class PhaseUsage;
class SingleWellState;
class WellEconProductionLimits;
class WellInterfaceGeneric;
struct RatioLimitCheckReport {
@ -59,6 +60,10 @@ public:
const double max_ratio_limit,
const RatioFunc& ratioFunc,
RatioLimitCheckReport& report) const;
void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
private:
const WellInterfaceGeneric& well_; //!< Reference to well interface
};