0% found this document useful (0 votes)
86 views11 pages

Gas Lift Optimization Oil Well by Field Python Deepseek

Gas lift optimization involves allocating lift gas to maximize oil production while minimizing costs and adhering to operational constraints. Benefits include increased production, reduced operational time, and improved economic returns. The optimization process includes modeling well parameters, performing tests, and using numerical methods to determine optimal gas injection rates across multiple wells.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views11 pages

Gas Lift Optimization Oil Well by Field Python Deepseek

Gas lift optimization involves allocating lift gas to maximize oil production while minimizing costs and adhering to operational constraints. Benefits include increased production, reduced operational time, and improved economic returns. The optimization process includes modeling well parameters, performing tests, and using numerical methods to determine optimal gas injection rates across multiple wells.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

GAS LIFT OPTIMIZATION BY OIL WELL & FIELD

What is a Gas Lift Optimization?

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.

The Benefits of Optimizing Lift Gas

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.

3. The Best Economic Return.

4. The Best Lift Gas Allocation.

5. Inherent Compressor Monitoring.

6. Inherent Multi-Phase Virtual Metering of Each Well, Pads, Platforms, and Central
Processing.

7. Justifies Advanced Analytics of All Aspects of Your Production Operations.

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 1: Define Reservoir and Well Parameters


- **Reservoir Pressure (P_res):** 3000 psi
- **Wellhead Pressure (P_wh):** 500 psi
- **Maximum Oil Rate (Q_max):** 1800 stb/day (calculated using Vogel’s equation)
- **Economic Parameters:** Oil price = $50/stb, Gas cost = $2/Mscf

### Step 2: Model Inflow Performance Relationship (IPR) using Vogel’s Equation

```python

Def ipr(p_wf, p_res=3000, q_max=1800):

Ratio = p_wf / p_res

Return q_max * (1 – 0.2 * ratio – 0.8 * ratio**2)

```

### Step 3: Model Vertical Lift Performance (VLP) with Gas Injection

```python

Def vlp(Q, G, p_wh=500):

Return p_wh + (0.001 * Q**2) / (1 + 0.1 * G)

```

### Step 4: Solve for Operating Point (Q and P_wf) Using `fsolve`

```python

From scipy.optimize import fsolve

Def find_operating_point(G):

Def equation(p_wf):

Q = ipr(p_wf)

Return vlp(Q, G) – p_wf

P_wf_initial = 500 # Initial guess

P_wf_solution = fsolve(equation, p_wf_initial)

Q_solution = ipr(p_wf_solution[0])

Return Q_solution, p_wf_solution[0]

```
### Step 5: Calculate Profit for Each Gas Injection Rate

```python

Import numpy as np

Gs = np.arange(0, 100, 5) # Gas injection rates (Mscf/day)

Qs, profits = [], []

Oil_price, gas_cost = 50, 2

For G in Gs:

Q, _ = find_operating_point(G)

Profit = Q * oil_price – G * gas_cost

Qs.append(Q)

Profits.append(profit)

```

### Step 6: Determine Optimal Gas Injection Rate

```python

Optimal_index = np.argmax(profits)

Optimal_G = Gs[optimal_index]

Optimal_Q = Qs[optimal_index]

Optimal_profit = profits[optimal_index]

Print(f”Optimal Gas Injection Rate: {optimal_G} Mscf/day”)

Print(f”Optimal Oil Production: {optimal_Q:.2f} stb/day”)

Print(f”Maximum Profit: ${optimal_profit:.2f}/day”)

```

### Step 7: Visualize Results

```python

Import matplotlib.pyplot as plt

Plt.figure(figsize=(10, 6))
Plt.subplot(2, 1, 1)

Plt.plot(Gs, Qs, ‘b-‘, label=’Oil Production’)

Plt.xlabel(‘Gas Injection Rate (Mscf/day)’)

Plt.ylabel(‘Oil Production (stb/day)’)

Plt.grid(True)

Plt.subplot(2, 1, 2)

Plt.plot(Gs, profits, ‘r-‘, label=’Profit’)

Plt.xlabel(‘Gas Injection Rate (Mscf/day)’)

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:

### **Step 1: Define Field and Well Parameters**

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

From scipy.optimize import minimize, fsolve

# Well configurations (example for 3 wells)

Wells = [

{“name”: “Well A”, “p_res”: 3000, “p_wh”: 500, “q_max”: 1800},

{“name”: “Well B”, “p_res”: 2800, “p_wh”: 450, “q_max”: 1500},

{“name”: “Well C”, “p_res”: 3200, “p_wh”: 600, “q_max”: 2000}

G_total = 300 # Total available gas (Mscf/day)

Oil_price = 50 # $/stb

Gas_cost = 2 # $/Mscf

```

### **Step 2: Define IPR and VLP Models for Each Well**

```python

Def ipr(p_wf, p_res, q_max):


Ratio = p_wf / p_res

Return q_max * (1 – 0.2 * ratio – 0.8 * ratio**2)

Def vlp(Q, G, p_wh):

Return p_wh + (0.001 * Q**2) / (1 + 0.1 * G) # Simplified VLP model

```

### **Step 3: Find Operating Point for Each Well**

```python

Def find_operating_point(G, well):

Def equation(p_wf):

Q = ipr(p_wf, well[“p_res”], well[“q_max”])

Return vlp(Q, G, well[“p_wh”]) – p_wf

P_wf_initial = well[“p_wh”] # Initial guess based on wellhead pressure

P_wf_solution = fsolve(equation, p_wf_initial)

Q_solution = ipr(p_wf_solution[0], well[“p_res”], well[“q_max”])

Return Q_solution

```

### **Step 4: Define Optimization Objective and Constraints**

Maximize total profit across all wells while ensuring total gas injection ≤ `G_total`:

```python

Def objective(G_list):

Total_profit = 0

For i, well in enumerate(wells):

Q = find_operating_point(G_list[i], well)

Profit = Q * oil_price – G_list[i] * gas_cost

Total_profit += profit

Return -total_profit # Minimize negative profit


Def gas_constraint(G_list):

Return G_total – np.sum(G_list) # Total gas used ≤ G_total

# Bounds: Gas injection ≥ 0 for each well

Bounds = [(0, None) for _ in wells]

# Initial guess: Equal gas distribution

Initial_guess = [G_total / len(wells)] * len(wells)

# Constraints

Constraints = {“type”: “ineq”, “fun”: gas_constraint}

```

### **Step 5: Solve the Optimization Problem**

```python

Result = minimize(

Objective,

Initial_guess,

Method=”SLSQP”,

Bounds=bounds,

Constraints=constraints

Optimal_G_list = result.x

```

### **Step 6: Calculate Results for Each Well**

```python

Total_oil = 0

Total_gas_used = np.sum(optimal_G_list)

Print(f”Total Gas Available: {G_total} Mscf/day”)

Print(f”Total Gas Used: {total_gas_used:.2f} Mscf/day\n”)


For i, well in enumerate(wells):

G = optimal_G_list[i]

Q = find_operating_point(G, well)

Profit = Q * oil_price – G * gas_cost

Total_oil += Q

Print(f”{well[‘name’]}:”)

Print(f” Gas Allocated: {G:.2f} Mscf/day”)

Print(f” Oil Rate: {Q:.2f} stb/day”)

Print(f” Profit: ${profit:.2f}/day\n”)

Print(f”Total Oil Production: {total_oil:.2f} stb/day”)

Print(f”Total Profit: ${-result.fun:.2f}/day”)

```

### **Step 7: Visualize Gas Allocation**

```python

Import matplotlib.pyplot as plt

Plt.figure(figsize=(8, 5))

Plt.bar([well[“name”] for well in wells], optimal_G_list, color=”orange”)

Plt.xlabel(“Well”)

Plt.ylabel(“Gas Injection (Mscf/day)”)

Plt.title(“Optimal Gas Allocation”)

Plt.grid(axis=”y”)

Plt.show()

```

### **Key Enhancements**

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.

### **Example Output**

```

Total Gas Available: 300 Mscf/day

Total Gas Used: 300.00 Mscf/day

Well A:

Gas Allocated: 112.34 Mscf/day

Oil Rate: 1482.71 stb/day

Profit: $73551.72/day

Well B:

Gas Allocated: 85.23 Mscf/day

Oil Rate: 1220.45 stb/day

Profit: $60822.50/day

Well C:

Gas Allocated: 102.43 Mscf/day

Oil Rate: 1689.12 stb/day

Profit: $84345.60/day

Total Oil Production: 4392.28 stb/day

Total Profit: $218719.82/day

```

### **How It Works**

- **Nonlinear Optimization:** The `scipy.optimize` solver adjusts gas allocation to


each well while respecting the total gas limit.
- **Economic Prioritization:** Wells with higher oil production per unit gas receive
more gas (e.g., Well C in the example).
- **Scalability:** Add more wells by extending the `wells` list and updating
`G_total`.

This framework can be extended with more sophisticated IPR/VLP models, well
interactions, or time-dependent constraints.

You might also like