Merge pull request #4518 from atgeirr/fix-zero-rate-control-eq

Treat rate control with zero target same as stopped well.
This commit is contained in:
Bård Skaflestad 2023-03-10 16:12:08 +01:00 committed by GitHub
commit 1ac190e4a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 0 deletions

View File

@ -35,6 +35,7 @@
#include <opm/simulators/wells/WellAssemble.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
#include <opm/simulators/wells/WellInterfaceIndices.hpp>
#include <opm/simulators/wells/WellState.hpp>
namespace Opm {
@ -162,6 +163,9 @@ assembleControlEq(const WellState& well_state,
bhp_from_thp,
control_eq,
deferred_logger);
} else if (rateControlWithZeroTarget(well_state.well(well_.indexOfWell()).production_cmode, prod_controls)) {
// Production mode, zero target. Treat as STOP.
control_eq = primary_variables.getWQTotal();
} else {
// Find rates.
const auto rates = getRates();

View File

@ -36,6 +36,7 @@
#include <opm/simulators/wells/WellAssemble.hpp>
#include <opm/simulators/wells/WellBhpThpCalculator.hpp>
#include <opm/simulators/wells/WellInterfaceFluidSystem.hpp>
#include <opm/simulators/wells/WellState.hpp>
namespace Opm {
@ -142,6 +143,9 @@ assembleControlEq(const WellState& well_state,
bhp_from_thp,
control_eq,
deferred_logger);
} else if (rateControlWithZeroTarget(well_state.well(well_.indexOfWell()).production_cmode, prod_controls)) {
// Production mode, zero target. Treat as STOP.
control_eq = primary_variables.eval(PrimaryVariables::WQTotal);
} else {
// Find rates.
const auto rates = getRates();

View File

@ -43,6 +43,32 @@
namespace Opm
{
bool rateControlWithZeroTarget(const Well::ProducerCMode mode,
const Well::ProductionControls& controls)
{
switch (mode) {
case Well::ProducerCMode::ORAT:
return controls.oil_rate == 0.0;
case Well::ProducerCMode::WRAT:
return controls.water_rate == 0.0;
case Well::ProducerCMode::GRAT:
return controls.gas_rate == 0.0;
case Well::ProducerCMode::LRAT:
return controls.liquid_rate == 0.0;
case Well::ProducerCMode::CRAT:
// Unsupported, will cause exception elsewhere, treat as nonzero target here.
return false;
case Well::ProducerCMode::RESV:
if (controls.prediction_mode) {
return controls.resv_rate == 0.0;
} else {
return controls.water_rate == 0.0 && controls.oil_rate == 0.0 && controls.gas_rate == 0.0;
}
default:
return false;
}
}
template<class FluidSystem>
WellAssemble<FluidSystem>::
WellAssemble(const WellInterfaceFluidSystem<FluidSystem>& well)

View File

@ -27,6 +27,7 @@
#include <opm/core/props/BlackoilPhases.hpp>
#include <opm/input/eclipse/Schedule/ScheduleTypes.hpp>
#include <opm/input/eclipse/Schedule/Well/WellEnums.hpp>
#include <functional>
@ -43,6 +44,10 @@ class WellState;
class WellInjectionControls;
class WellProductionControls;
/// Helper to avoid singular control equations.
bool rateControlWithZeroTarget(const WellProducerCMode mode,
const WellProductionControls& controls);
template<class FluidSystem>
class WellAssemble {
static constexpr int Water = BlackoilPhases::Aqua;
@ -80,6 +85,8 @@ private:
const WellInterfaceFluidSystem<FluidSystem>& well_;
};
}
#endif // OPM_WELL_ASSEMBLE_HEADER_INCLUDED