Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions opm/simulators/wells/BlackoilWellModelGasLift_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,6 @@ gasLiftOptimizationStage1(const Simulator& simulator,
group_alq_rates[j]);
}
}
if constexpr (glift_debug) {
int counter = 0;
if (comm.rank() == i) {
counter = wellState.gliftGetDebugCounter();
}
counter = comm.sum(counter);
if (comm.rank() != i) {
wellState.gliftSetDebugCounter(counter);
}
}
}
}
}
Expand Down
23 changes: 20 additions & 3 deletions opm/simulators/wells/GasLiftGroupInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,17 +547,24 @@ getProducerWellRates_(const Well* well, int well_index)
Scalar water_rate = water_pot;
Scalar gas_rate = gas_pot;

// The well rates are potentially limited by the targets
// The other phases are scaled accordingly. i.e. we assume the phase fractions are the same
// This is not 100% true but the best we can do without solving the well equation
if (controls.hasControl(Well::ProducerCMode::ORAT) && oil_rate > static_cast<Scalar>(controls.oil_rate)) {
water_rate *= (static_cast<Scalar>(controls.oil_rate) / oil_rate);
gas_rate *= (static_cast<Scalar>(controls.oil_rate) / oil_rate);
Copy link
Contributor

@hakonhagland hakonhagland Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It seems unlikely that oil_rate will be zero since it is known to be greater than controls.oil_rate, but if controls.oil_rate ~= 0 it could in theory become very small. Should we check for this before scaling? 2) We could also add a comment about why this scaling is needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since oil_rate > controls.oil_rate >= 0 I think controls.oil_rate / oil_rate should be safe.

oil_rate = static_cast<Scalar>(controls.oil_rate);
}

if (controls.hasControl(Well::ProducerCMode::GRAT)) {
gas_rate = std::min(static_cast<Scalar>(controls.gas_rate), gas_rate);
if (controls.hasControl(Well::ProducerCMode::GRAT) && gas_rate > static_cast<Scalar>(controls.gas_rate)) {
water_rate *= (static_cast<Scalar>(controls.gas_rate) / gas_rate);
oil_rate *= (static_cast<Scalar>(controls.gas_rate) / gas_rate);
gas_rate = static_cast<Scalar>(controls.gas_rate);
}

if (controls.hasControl(Well::ProducerCMode::WRAT) && water_rate > static_cast<Scalar>(controls.water_rate)) {
oil_rate *= (static_cast<Scalar>(controls.water_rate) / water_rate);
gas_rate *= (static_cast<Scalar>(controls.water_rate) / water_rate);
water_rate = static_cast<Scalar>(controls.water_rate);
}
if (controls.hasControl(Well::ProducerCMode::LRAT)) {
Expand All @@ -566,6 +573,7 @@ getProducerWellRates_(const Well* well, int well_index)
if (liquid_rate > liquid_rate_lim) {
water_rate = water_rate / liquid_rate * liquid_rate_lim;
oil_rate = oil_rate / liquid_rate * liquid_rate_lim;
gas_rate = gas_rate / liquid_rate * liquid_rate_lim;
}
}

Expand Down Expand Up @@ -668,14 +676,22 @@ initializeGroupRatesRecursive_(const Group& group)
group.name(), oil_rate, gas_rate, water_rate, alq);
}

// The group rates are potentially limited by the group targets
// The other phases are scaled accordingly. i.e. we assume the phase fractions are the same
// This is not 100% true but the best we can do without solving the well equation
if (oil_target && oil_rate > *oil_target) {
water_rate *= (*oil_target/oil_rate);
gas_rate *= (*oil_target/oil_rate);
oil_rate = *oil_target;
}
if (gas_target && gas_rate > *gas_target)
if (gas_target && gas_rate > *gas_target) {
water_rate *= (*gas_target/gas_rate);
oil_rate *= (*gas_target/gas_rate);
gas_rate = *gas_target;
}
if (water_target && water_rate > *water_target) {
oil_rate *= (*water_target/water_rate);
gas_rate *= (*water_target/water_rate);
water_rate = *water_target;
}
if (liquid_target) {
Expand All @@ -684,6 +700,7 @@ initializeGroupRatesRecursive_(const Group& group)
if (liquid_rate > liquid_rate_limited) {
oil_rate = oil_rate / liquid_rate * liquid_rate_limited;
water_rate = water_rate / liquid_rate * liquid_rate_limited;
gas_rate = gas_rate / liquid_rate * liquid_rate_limited;
}
}
}
Expand Down
Loading