move checkMaxWGRLimit to WellTest

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

View File

@ -590,41 +590,6 @@ checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits,
} }
} }
template<typename FluidSystem>
void
WellInterfaceFluidSystem<FluidSystem>::
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<double>& 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<typename FluidSystem> template<typename FluidSystem>
void void
WellInterfaceFluidSystem<FluidSystem>:: WellInterfaceFluidSystem<FluidSystem>::
@ -652,7 +617,9 @@ checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
} }
if (econ_production_limits.onMaxWaterGasRatio()) { 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()) { if (econ_production_limits.onMaxGasLiquidRatio()) {

View File

@ -131,10 +131,6 @@ protected:
const SingleWellState& ws, const SingleWellState& ws,
RatioLimitCheckReport& report) const; RatioLimitCheckReport& report) const;
void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
void checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits, void checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws, const SingleWellState& ws,
RatioLimitCheckReport& report, RatioLimitCheckReport& report,

View File

@ -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<double>& 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 } // namespace Opm

View File

@ -64,6 +64,11 @@ public:
void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits, void checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws, const SingleWellState& ws,
RatioLimitCheckReport& report) const; RatioLimitCheckReport& report) const;
void checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits,
const SingleWellState& ws,
RatioLimitCheckReport& report) const;
private: private:
const WellInterfaceGeneric& well_; //!< Reference to well interface const WellInterfaceGeneric& well_; //!< Reference to well interface
}; };