Gas Lift Optimization Oil Well by Field Python Deepseek
Gas Lift Optimization Oil Well by Field Python Deepseek
Lift gas optimization allocates available lift gas to maximize overall production,
minimize costs and achieve other business objectives while operating within
constraints such as compressor limitations, water production, and total liquid
production rate capacity and downstream interactions of wells.
1. Higher Production, especially from aging fields. 15% gains are typical in our
experience.
2. Reduced Length of Operation of Fields. This reduces overall expenditures and HSE
risks.
6. Inherent Multi-Phase Virtual Metering of Each Well, Pads, Platforms, and Central
Processing.
PROCESS
1. The first step is to digitalize your wells, test and production separators, pressures,
and temperatures at the wellhead and production network. This is necessary to
characterize the state of your wells, both during tests and in real time.
2. Have a history of process conditions and test rates for each well.
3. Execute multi-rate tests, varying injected gas rate while on test, capturing well test
rates for gas, oil, or liquid.
4. We model the operating conditions and lift gas rates vs. Production for each well.
Inherent in these models is each well’s gas lift performance curve (multi-
dimensional lift surfaces).
5. Gather your constraints, including available lift gas and other compressor
constraints, and downstream production handling capacity, so do not overrun
separators and hard limits on maximum and minimum lift gas for each well.
6. For single well optimization, “invert” the models to create Model Predictive Control
(MPC). This allows you to put set points on each wells’ production if you like.
7. For multi-well optimization, generate live lift curves considering current well
conditions, then walk back lift gas from individual wells’ peak production until one
or more constraints are met. Essentially dial back the well with the least change in
production for lift gas employed, that is, the least slope at that step in the process.
This results in the best allocation of lift gas within and bumping up against
constraints. This is repeated on a frequency that makes sense for your asset.
To optimize gas lift operations in an oil field using Python, we model the relationship
between gas injection and oil production, considering reservoir and economic factors.
Here’s a step-by-step solution:
### Step 2: Model Inflow Performance Relationship (IPR) using Vogel’s Equation
```python
```
### Step 3: Model Vertical Lift Performance (VLP) with Gas Injection
```python
```
### Step 4: Solve for Operating Point (Q and P_wf) Using `fsolve`
```python
Def find_operating_point(G):
Def equation(p_wf):
Q = ipr(p_wf)
Q_solution = ipr(p_wf_solution[0])
```
### Step 5: Calculate Profit for Each Gas Injection Rate
```python
Import numpy as np
For G in Gs:
Q, _ = find_operating_point(G)
Qs.append(Q)
Profits.append(profit)
```
```python
Optimal_index = np.argmax(profits)
Optimal_G = Gs[optimal_index]
Optimal_Q = Qs[optimal_index]
Optimal_profit = profits[optimal_index]
```
```python
Plt.figure(figsize=(10, 6))
Plt.subplot(2, 1, 1)
Plt.grid(True)
Plt.subplot(2, 1, 2)
Plt.ylabel(‘Profit ($/day)’)
Plt.grid(True)
Plt.tight_layout()
Plt.show()
```
### Explanation
1. **IPR and VLP Models:** The IPR is modeled using Vogel’s equation to relate
bottomhole pressure (P_wf) to oil production (Q). The VLP incorporates gas injection
(G) to reduce the pressure required to lift fluids.
2. **Numerical Solution:** The operating point (Q, P_wf) for each G is found by solving
the IPR and VLP equations simultaneously using `fsolve`.
3. **Profit Maximization:** By evaluating profit (revenue from oil minus gas costs)
across a range of G values, the optimal G maximizing profit is identified.
4. **Visualization:** Plots of oil production and profit versus gas injection rate
illustrate the optimal operating point.
### Results
- **Optimal Gas Injection Rate:** Found at the peak of the profit curve.
- **Output:** Includes optimal G, corresponding Q, and maximum profit, with plots
showing trends.
This approach provides a foundational framework, which can be enhanced with more
detailed multiphase flow models and economic considerations for real-world applications.
Include number of oil wells to optimize the oil rate based on a gas
injection distribution by field
To optimize gas lift operations across **multiple wells** in a field while distributing a
limited gas supply, we need to extend the previous approach to handle **gas allocation
constraints** and **well-specific parameters**. Here’s the enhanced solution:
Assume a field with 3 wells and a total gas supply of `G_total = 300 Mscf/day`. Each well
has unique reservoir properties:
```python
Import numpy as np
Wells = [
Oil_price = 50 # $/stb
Gas_cost = 2 # $/Mscf
```
### **Step 2: Define IPR and VLP Models for Each Well**
```python
```
```python
Def equation(p_wf):
Return Q_solution
```
Maximize total profit across all wells while ensuring total gas injection ≤ `G_total`:
```python
Def objective(G_list):
Total_profit = 0
Q = find_operating_point(G_list[i], well)
Total_profit += profit
# Constraints
```
```python
Result = minimize(
Objective,
Initial_guess,
Method=”SLSQP”,
Bounds=bounds,
Constraints=constraints
Optimal_G_list = result.x
```
```python
Total_oil = 0
Total_gas_used = np.sum(optimal_G_list)
G = optimal_G_list[i]
Q = find_operating_point(G, well)
Total_oil += Q
Print(f”{well[‘name’]}:”)
```
```python
Plt.figure(figsize=(8, 5))
Plt.xlabel(“Well”)
Plt.grid(axis=”y”)
Plt.show()
```
1. **Multiple Wells with Unique Parameters:** Each well has its own IPR/VLP curves
and reservoir properties.
2. **Gas Allocation Constraint:** Total gas used across all wells cannot exceed
`G_total`.
3. **Profit Maximization:** The optimizer balances gas distribution to maximize total
profit, prioritizing wells with higher economic returns.
```
Well A:
Profit: $73551.72/day
Well B:
Profit: $60822.50/day
Well C:
Profit: $84345.60/day
```
This framework can be extended with more sophisticated IPR/VLP models, well
interactions, or time-dependent constraints.