Skip to content

Conversation

@totto82
Copy link
Member

@totto82 totto82 commented Dec 3, 2025

Start using IPR in gaslift optimization.
Gives a significant speed-up compared to the old code

@totto82
Copy link
Member Author

totto82 commented Dec 3, 2025

jenkins build this please

@totto82
Copy link
Member Author

totto82 commented Dec 4, 2025

jenkins build this failure_report please

@totto82
Copy link
Member Author

totto82 commented Dec 4, 2025

jenkins build this failure_report please

@totto82 totto82 changed the title FOR TESTING: Fix glift2 Using IPR in gaslift optimization Dec 4, 2025
@totto82 totto82 added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Dec 4, 2025
@totto82 totto82 requested a review from hakonhagland December 4, 2025 15:04
@totto82 totto82 marked this pull request as ready for review December 4, 2025 15:04
@hakonhagland
Copy link
Contributor

Do we have any profiling results demonstrating the speedup?

@totto82
Copy link
Member Author

totto82 commented Dec 5, 2025

jenkins build this failure_report please

1 similar comment
@totto82
Copy link
Member Author

totto82 commented Dec 5, 2025

jenkins build this failure_report please

@totto82
Copy link
Member Author

totto82 commented Dec 5, 2025

jenkins build this failure_report please

Copy link
Contributor

@hakonhagland hakonhagland left a comment

Choose a reason for hiding this comment

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

I profiled this PR with tracy and compared with master for test case 4_GLIFT_MODEL5.DATA and 4 MPI ranks.

The results indicate a 15% overall speedup by using Inflow Performance Relationship (IPR) for gas lift optimization BHP calculations:

Metric Master PR #6653 Improvement
Total runtime 5.81 s 4.93 s -15.1%
Gas lift BHP solve 562 ms 33 ms -94%
MPI synchronization 725 ms 394 ms -46%

It looks very good to me. I will approve this once the comments have been addressed.

return {-potentials[this->oil_pos_],
-potentials[this->gas_pos_],
-potentials[this->water_pos_],
bhp,
Copy link
Contributor

Choose a reason for hiding this comment

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

This now returns BasicRates which seems to indicate to the reader that well rates are returned, but BasicRates now includes bhp which is a pressure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we rename to something like BasicWellState or LimitedWellState? However, that may be confused with the well state? Any other suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about RatesAndBhp and LimitedRatesAndBhp ?

std::optional<typename GasLiftSingleWell<TypeTag>::Scalar>
GasLiftSingleWell<TypeTag>::
computeBhpAtThpLimit_(Scalar alq, bool debug_output) const
computeBhpAtThpLimit_(Scalar alq, Scalar bhp, bool debug_output) const
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more readable if bhp is renamed current_bhp or similar? And add a comment above the method describing input parameters and purpose of method.

OPM_TIMEFUNCTION();
const auto& groupStateHelper = this->simulator_.problem().wellModel().groupStateHelper();
auto bhp_at_thp_limit = this->well_.computeBhpAtThpLimitProdWithAlq(
auto bhp_at_thp_limit = this->well_.computeBhpAtThpLimitProdWithAlqUsingIPR(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment why we now are using computeBhpAtThpLimitProdWithAlqUsingIPR() instead of computeBhpAtThpLimitProdWithAlq() ?

std::optional<typename GasLiftSingleWellGeneric<Scalar, IndexTraits>::LimitedRates>
GasLiftSingleWellGeneric<Scalar, IndexTraits>::
computeLimitedWellRatesWithALQ_(Scalar alq) const
computeLimitedWellRatesWithALQ_(Scalar alq, Scalar bhp) const
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe change bhp to current_bhp? And add a comment above the method explaining input parameters and purpose of method.

rates.gas,
water_rate,
rates.water,
rates.bhp,
Copy link
Contributor

Choose a reason for hiding this comment

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

The name LimitedRates seems to indicate to the reader that it contains limited rates. But now it also contains bhp which is a pressure.

, water_is_limited{water_is_limited_}
, alq{alq_}
, alq_is_limited{alq_is_limited_}
, bhp(bhp_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use curly braces to be consistent with the above initializations

}

Scalar oil, gas, water;
Scalar oil, gas, water, bhp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Refer to earlier comment about the name BasicRates and including bhp as a member.

template<typename TypeTag>
std::optional<typename WellInterface<TypeTag>::Scalar>
WellInterface<TypeTag>::
computeBhpAtThpLimitProdWithAlqUsingIPR(const Simulator& simulator,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment above this method about its purpose

{
OPM_TIMEFUNCTION();
WellStateType well_state_copy = well_state;
const auto& groupStateHelper = simulator.problem().wellModel().groupStateHelper();
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, we should avoid passing around simulator and instead pass groupStateHelper if possible to avoid this kind of hidden dual state pattern where the groupStateHelper is not the same as simulator.problem().wellModel().groupStateHelper(), see: #6631. But I think this requires a larger refactorization, and is better done in a follow-up PR.

@totto82
Copy link
Member Author

totto82 commented Dec 8, 2025

jenkins build this failure_report please

@totto82 totto82 merged commit 630e4d3 into OPM:master Dec 9, 2025
2 checks passed
@akva2
Copy link
Member

akva2 commented Dec 9, 2025

@totto82
Copy link
Member Author

totto82 commented Dec 9, 2025

This was merged with warnings

Sorry. I will fix asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants