combining wellIsStopped and wellUnderZeroRateTaget

for better readability.
This commit is contained in:
Kai Bao 2023-03-29 14:33:05 +02:00
parent b6eecf5c55
commit 9304542dbe
16 changed files with 53 additions and 46 deletions

View File

@ -116,7 +116,7 @@ assembleControlEq(const WellState& well_state,
return rates;
};
if (well_.wellUnderZeroRateControl(summaryState, well_state)) {
if (well_.stopppedOrZeroRateTarget(summaryState, well_state)) {
control_eq = primary_variables.getWQTotal();
} else if (well_.isInjector() ) {
// Find scaling factor to get injection rate,

View File

@ -64,7 +64,7 @@ init()
template<class FluidSystem, class Indices, class Scalar>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::
update(const WellState& well_state, const bool zero_rate_target)
update(const WellState& well_state, const bool stop_or_zero_rate_target)
{
static constexpr int Water = BlackoilPhases::Aqua;
static constexpr int Gas = BlackoilPhases::Vapour;
@ -104,7 +104,7 @@ update(const WellState& well_state, const bool zero_rate_target)
}
}
value_[seg][WQTotal] = total_seg_rate;
if (zero_rate_target && seg == 0) {
if (stop_or_zero_rate_target && seg == 0) {
value_[seg][WQTotal] = 0;
}
if (std::abs(total_seg_rate) > 0.) {
@ -155,7 +155,7 @@ void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::
updateNewton(const BVectorWell& dwells,
const double relaxation_factor,
const double dFLimit,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
const double max_pressure_change)
{
const std::vector<std::array<double, numWellEq>> old_primary_variables = value_;
@ -198,7 +198,7 @@ updateNewton(const BVectorWell& dwells,
}
}
if (zero_rate_target) {
if (stop_or_zero_rate_target) {
value_[0][WQTotal] = 0.;
}
}
@ -207,7 +207,7 @@ template<class FluidSystem, class Indices, class Scalar>
void MultisegmentWellPrimaryVariables<FluidSystem,Indices,Scalar>::
copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
const double rho,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const
{
@ -394,7 +394,7 @@ copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
}
WellBhpThpCalculator(well_)
.updateThp(rho, zero_rate_target, [this]() { return well_.wellEcl().alq_value(); },
.updateThp(rho, stop_or_zero_rate_target, [this]() { return well_.wellEcl().alq_value(); },
{FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx),
FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx),
FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)},

View File

@ -88,19 +88,19 @@ public:
void init();
//! \brief Copy values from well state.
void update(const WellState& well_state, const bool zero_rate_target);
void update(const WellState& well_state, const bool stop_or_zero_rate_target);
//! \brief Update values from newton update vector.
void updateNewton(const BVectorWell& dwells,
const double relaxation_factor,
const double DFLimit,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
const double max_pressure_change);
//! \brief Copy values to well state.
void copyToWellState(const MultisegmentWellGeneric<Scalar>& mswell,
const double rho,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const;

View File

@ -152,8 +152,8 @@ namespace Opm
const WellState& well_state,
DeferredLogger& /* deferred_logger */)
{
const bool zero_rate_target = this->wellUnderZeroRateControl(summary_state, well_state);
this->primary_variables_.update(well_state, zero_rate_target);
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
this->primary_variables_.update(well_state, stop_or_zero_rate_target);
}
@ -615,14 +615,14 @@ namespace Opm
const double dFLimit = this->param_.dwell_fraction_max_;
const double max_pressure_change = this->param_.max_pressure_change_ms_wells_;
const bool zero_rate_target = this->wellUnderZeroRateControl(summary_state, well_state);
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
this->primary_variables_.updateNewton(dwells,
relaxation_factor,
dFLimit,
zero_rate_target,
stop_or_zero_rate_target,
max_pressure_change);
this->primary_variables_.copyToWellState(*this, getRefDensity(), zero_rate_target,
this->primary_variables_.copyToWellState(*this, getRefDensity(), stop_or_zero_rate_target,
well_state, deferred_logger);
Base::calculateReservoirRates(well_state.well(this->index_of_well_));
}

View File

@ -365,10 +365,10 @@ namespace Opm
DeferredLogger& deferred_logger) const;
void updatePrimaryVariablesNewton(const BVectorWell& dwells,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
DeferredLogger& deferred_logger);
void updateWellStateFromPrimaryVariables(const bool zero_rate_target,
void updateWellStateFromPrimaryVariables(const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const;

View File

@ -116,7 +116,7 @@ assembleControlEq(const WellState& well_state,
return rates;
};
if (well_.wellUnderZeroRateControl(summaryState, well_state)) {
if (well_.stopppedOrZeroRateTarget(summaryState, well_state)) {
control_eq = primary_variables.eval(PrimaryVariables::WQTotal);
} else if (well_.isInjector()) {
// Find injection rate.

View File

@ -71,7 +71,7 @@ extendEval(const Eval& in) const
template<class FluidSystem, class Indices, class Scalar>
void
StandardWellEval<FluidSystem,Indices,Scalar>::
updateWellStateFromPrimaryVariables(const bool zero_rate_target,
updateWellStateFromPrimaryVariables(const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const
{
@ -79,7 +79,7 @@ updateWellStateFromPrimaryVariables(const bool zero_rate_target,
WellBhpThpCalculator(baseif_).
updateThp(connections_.rho(),
zero_rate_target,
stop_or_zero_rate_target,
[this,&well_state]() { return this->baseif_.getALQ(well_state); },
{FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx),
FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx),

View File

@ -92,7 +92,7 @@ protected:
const int num_cells,
const bool has_polymermw);
void updateWellStateFromPrimaryVariables(const bool zero_rate_target,
void updateWellStateFromPrimaryVariables(const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const;

View File

@ -122,7 +122,7 @@ resize(const int numWellEq)
template<class FluidSystem, class Indices, class Scalar>
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
update(const WellState& well_state,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
DeferredLogger& deferred_logger)
{
static constexpr int Water = BlackoilPhases::Aqua;
@ -160,7 +160,7 @@ update(const WellState& well_state,
}
} else {
value_[WQTotal] = total_well_rate;
if (zero_rate_target) {
if (stop_or_zero_rate_target) {
value_[WQTotal] = 0.;
}
}
@ -245,7 +245,7 @@ updatePolyMW(const WellState& well_state)
template<class FluidSystem, class Indices, class Scalar>
void StandardWellPrimaryVariables<FluidSystem,Indices,Scalar>::
updateNewton(const BVectorWell& dwells,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
[[maybe_unused]] const double dFLimit,
const double dBHPLimit)
{
@ -281,7 +281,7 @@ updateNewton(const BVectorWell& dwells,
// updating the total rates Q_t
value_[WQTotal] = value_[WQTotal] - dwells[0][WQTotal] * relaxation_factor_rate;
if (zero_rate_target) {
if (stop_or_zero_rate_target) {
value_[WQTotal] = 0.;
}
// TODO: here, we make sure it is zero for zero rated wells

View File

@ -102,7 +102,7 @@ public:
//! \brief Copy values from well state.
void update(const WellState& well_state,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
DeferredLogger& deferred_logger);
//! \brief Copy polymer molecular weigt values from well state.
@ -110,7 +110,7 @@ public:
//! \brief Update values from newton update vector.
void updateNewton(const BVectorWell& dwells,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
const double dFLimit,
const double dBHPLimit);

View File

@ -1000,10 +1000,10 @@ namespace Opm
{
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;
const bool zero_rate_target = this->wellUnderZeroRateControl(summary_state, well_state);
updatePrimaryVariablesNewton(dwells, zero_rate_target, deferred_logger);
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
updatePrimaryVariablesNewton(dwells, stop_or_zero_rate_target, deferred_logger);
updateWellStateFromPrimaryVariables(zero_rate_target, well_state, deferred_logger);
updateWellStateFromPrimaryVariables(stop_or_zero_rate_target, well_state, deferred_logger);
Base::calculateReservoirRates(well_state.well(this->index_of_well_));
}
@ -1015,12 +1015,12 @@ namespace Opm
void
StandardWell<TypeTag>::
updatePrimaryVariablesNewton(const BVectorWell& dwells,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
DeferredLogger& deferred_logger)
{
const double dFLimit = this->param_.dwell_fraction_max_;
const double dBHPLimit = this->param_.dbhp_max_rel_;
this->primary_variables_.updateNewton(dwells, zero_rate_target, dFLimit, dBHPLimit);
this->primary_variables_.updateNewton(dwells, stop_or_zero_rate_target, dFLimit, dBHPLimit);
// for the water velocity and skin pressure
if constexpr (Base::has_polymermw) {
@ -1037,11 +1037,11 @@ namespace Opm
template<typename TypeTag>
void
StandardWell<TypeTag>::
updateWellStateFromPrimaryVariables(const bool zero_rate_target,
updateWellStateFromPrimaryVariables(const bool stop_or_zero_rate_target,
WellState& well_state,
DeferredLogger& deferred_logger) const
{
this->StdWellEval::updateWellStateFromPrimaryVariables(zero_rate_target, well_state, deferred_logger);
this->StdWellEval::updateWellStateFromPrimaryVariables(stop_or_zero_rate_target, well_state, deferred_logger);
// other primary variables related to polymer injectivity study
if constexpr (Base::has_polymermw) {
@ -1984,8 +1984,8 @@ namespace Opm
{
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;
const bool zero_rate_target = this->wellUnderZeroRateControl(summary_state, well_state);
this->primary_variables_.update(well_state, zero_rate_target, deferred_logger);
const bool stop_or_zero_rate_target = this->stopppedOrZeroRateTarget(summary_state, well_state);
this->primary_variables_.update(well_state, stop_or_zero_rate_target, deferred_logger);
// other primary variables related to polymer injection
if constexpr (Base::has_polymermw) {

View File

@ -224,7 +224,7 @@ computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>&
}
void WellBhpThpCalculator::updateThp(const double rho,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
const std::function<double()>& alq_value,
const std::array<unsigned,3>& active,
WellState& well_state,
@ -236,7 +236,7 @@ void WellBhpThpCalculator::updateThp(const double rho,
auto& ws = well_state.well(well_.indexOfWell());
// When there is no vaild VFP table provided, we set the thp to be zero.
if (!well_.isVFPActive(deferred_logger) || well_.wellIsStopped() || zero_rate_target) {
if (!well_.isVFPActive(deferred_logger) || stop_or_zero_rate_target) {
ws.thp = 0;
return;
}

View File

@ -82,7 +82,7 @@ public:
//! \brief Update THP.
void updateThp(const double rho,
const bool zero_rate_target,
const bool stop_or_zero_rate_target,
const std::function<double()>& alq_value,
const std::array<unsigned,3>& active,
WellState& well_state,

View File

@ -452,11 +452,9 @@ bool WellInterfaceGeneric::isPressureControlled(const WellState& well_state) con
bool WellInterfaceGeneric::wellUnderZeroRateControl(const SummaryState& summary_state,
const WellState& well_state) const
bool WellInterfaceGeneric::wellUnderZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const
{
if (this->wellIsStopped()) return true;
if (this->isProducer()) { // producers
const auto prod_controls = this->well_ecl_.productionControls(summary_state);
const auto prod_mode = well_state.well(this->indexOfWell()).production_cmode;
@ -468,6 +466,13 @@ bool WellInterfaceGeneric::wellUnderZeroRateControl(const SummaryState& summary_
}
}
bool WellInterfaceGeneric::stopppedOrZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const
{
return (this->wellIsStopped() || this->wellUnderZeroRateTarget(summary_state, well_state));
}
double WellInterfaceGeneric::wmicrobes_() const
{
auto injectorType = this->well_ecl_.injectorType();

View File

@ -195,9 +195,8 @@ public:
bool isPressureControlled(const WellState& well_state) const;
bool wellUnderZeroRateControl(const SummaryState& summary_state,
bool stopppedOrZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const;
protected:
bool getAllowCrossFlow() const;
@ -212,6 +211,9 @@ protected:
int polymerInjTable_() const;
int polymerWaterTable_() const;
bool wellUnderZeroRateTarget(const SummaryState& summary_state,
const WellState& well_state) const;
// definition of the struct OperabilityStatus
struct OperabilityStatus {
bool isOperableAndSolvable() const {

View File

@ -185,7 +185,7 @@ namespace Opm
DeferredLogger& deferred_logger) /* const */
{
const auto& summary_state = ebos_simulator.vanguard().summaryState();
if (this->wellUnderZeroRateControl(summary_state, well_state)) {
if (this->stopppedOrZeroRateTarget(summary_state, well_state)) {
return false;
}