Class GasLiftOptimizer

java.lang.Object
neqsim.process.fielddevelopment.screening.GasLiftOptimizer
All Implemented Interfaces:
Serializable

public class GasLiftOptimizer extends Object implements Serializable
Multi-well gas lift optimization for optimal gas allocation.

This class optimizes the allocation of limited lift gas across multiple wells to maximize total field production. It considers:

  • Well performance curves: Oil rate vs. injection gas rate for each well
  • Gas availability: Total available lift gas constraint
  • Compression constraints: Maximum compression power
  • Well constraints: Minimum/maximum injection rates per well
  • Economic factors: Value of incremental oil vs. cost of compression

Optimization Methods

The optimizer supports multiple solution methods:

  • Equal slope: Allocate gas so marginal production increase is equal for all wells
  • Proportional: Allocate gas proportional to well potential
  • Sequential: Fill wells in order of highest marginal response
  • Gradient-based: Iterative optimization using derivatives

Mathematical Basis

For optimal gas allocation, the marginal production increase should be equal across all wells:

∂Qoil₁/∂Qgas₁ = ∂Qoil₂/∂Qgas₂ = ... = ∂Qoilₙ/∂Qgasₙ

Subject to the total gas constraint:

ΣQgasᵢ ≤ Qgas_available

Usage Example

GasLiftOptimizer optimizer = new GasLiftOptimizer();

// Add wells with their performance curves
optimizer.addWell("Well-1", performanceCurve1, 50000.0); // Max 50 MSm³/d injection
optimizer.addWell("Well-2", performanceCurve2, 40000.0);
optimizer.addWell("Well-3", performanceCurve3, 60000.0);

// Set total available gas
optimizer.setAvailableGas(100000.0, "Sm3/d");

// Set compression constraints
optimizer.setMaxCompressionPower(5000.0); // kW
optimizer.setCompressionEfficiency(0.75);

// Optimize
AllocationResult result = optimizer.optimize();

System.out.println("Total oil production: " + result.totalOilRate + " Sm³/d");
for (WellAllocation alloc : result.allocations) {
  System.out.println(
      alloc.wellName + ": " + alloc.gasRate + " Sm³/d gas → " + alloc.oilRate + " Sm³/d oil");
}
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • wells

    • availableGas

      private double availableGas
    • maxCompressionPower

      private double maxCompressionPower
    • compressionEfficiency

      private double compressionEfficiency
    • suctionPressure

      private double suctionPressure
    • dischargePressure

      private double dischargePressure
    • gasSpecificGravity

      private double gasSpecificGravity
    • method

    • tolerance

      private double tolerance
    • maxIterations

      private int maxIterations
  • Constructor Details

    • GasLiftOptimizer

      public GasLiftOptimizer()
      Creates a new gas lift optimizer.
  • Method Details

    • addWell

      public GasLiftOptimizer addWell(String name, GasLiftOptimizer.PerformanceCurve curve, double maxGasRate)
      Adds a well with its performance curve.
      Parameters:
      name - well name
      curve - gas lift performance curve
      maxGasRate - maximum gas injection rate (Sm³/d)
      Returns:
      this for chaining
    • addWell

      public GasLiftOptimizer addWell(String name, double naturalRate, double maxRate, double optimalGas, double maxGasRate)
      Adds a well with simplified curve parameters.
      Parameters:
      name - well name
      naturalRate - natural flow rate (Sm³/d)
      maxRate - maximum rate with gas lift (Sm³/d)
      optimalGas - optimal gas injection (Sm³/d)
      maxGasRate - maximum allowed gas rate (Sm³/d)
      Returns:
      this for chaining
    • setAvailableGas

      public GasLiftOptimizer setAvailableGas(double gas, String unit)
      Sets the available lift gas.
      Parameters:
      gas - available gas
      unit - unit (Sm3/d, MSm3/d)
      Returns:
      this for chaining
    • setMaxCompressionPower

      public GasLiftOptimizer setMaxCompressionPower(double maxPower)
      Sets compression constraints.
      Parameters:
      maxPower - maximum compression power (kW)
      Returns:
      this for chaining
    • setCompressionEfficiency

      public GasLiftOptimizer setCompressionEfficiency(double efficiency)
      Sets compression efficiency.
      Parameters:
      efficiency - isentropic efficiency (0-1)
      Returns:
      this for chaining
    • setCompressionPressures

      public GasLiftOptimizer setCompressionPressures(double suction, double discharge)
      Sets compression pressures.
      Parameters:
      suction - suction pressure (bara)
      discharge - discharge pressure (bara)
      Returns:
      this for chaining
    • setOptimizationMethod

      public GasLiftOptimizer setOptimizationMethod(GasLiftOptimizer.OptimizationMethod method)
      Sets the optimization method.
      Parameters:
      method - optimization method
      Returns:
      this for chaining
    • setWellEnabled

      public GasLiftOptimizer setWellEnabled(String wellName, boolean enabled)
      Sets a well's enabled status.
      Parameters:
      wellName - well name
      enabled - true to include in optimization
      Returns:
      this for chaining
    • setWellPriority

      public GasLiftOptimizer setWellPriority(String wellName, double priority)
      Sets a well's priority.
      Parameters:
      wellName - well name
      priority - priority (higher = more gas)
      Returns:
      this for chaining
    • optimize

      Runs the optimization.
      Returns:
      allocation result
    • optimizeEqualSlope

      private GasLiftOptimizer.AllocationResult optimizeEqualSlope(double totalGas)
      Optimizes using equal slope (marginal response) method.

      This method implements the optimal gas allocation strategy based on economic theory. At the optimum, the marginal production response should be equal for all wells:

      ∂Q_oil,1/∂Q_gas,1 = ∂Q_oil,2/∂Q_gas,2 = ... = λ

      where λ is the common marginal response (Lagrange multiplier). The algorithm uses binary search to find λ such that the total gas allocation equals the available gas.

      Algorithm:

      1. Bracket the common marginal response λ between [0, max_slope]
      2. Binary search: for each λ, find gas allocation per well where slope = λ
      3. If total allocation is greater than available, increase λ (less gas per well)
      4. If total allocation is less than available, decrease λ (more gas per well)
      5. Converge when |total - available| / available is less than tolerance
      Parameters:
      totalGas - total available gas (Sm³/d)
      Returns:
      allocation result with optimal distribution
    • findWellByName

      private GasLiftOptimizer.WellData findWellByName(String name)
      Finds well data by name.
      Parameters:
      name - well name to find
      Returns:
      well data or null if not found
    • findGasRateForSlope

      private double findGasRateForSlope(GasLiftOptimizer.WellData well, double targetSlope)
      Finds gas rate that gives target marginal response using binary search.

      For a given performance curve, finds the gas rate Q_gas where:

      ∂Q_oil/∂Q_gas = targetSlope

      Uses the diminishing returns property: higher gas rates yield lower marginal response.

      Parameters:
      well - well data with performance curve
      targetSlope - target marginal response (Sm³ oil / Sm³ gas)
      Returns:
      gas rate that achieves target slope (Sm³/d)
    • optimizeProportional

      private GasLiftOptimizer.AllocationResult optimizeProportional(double totalGas)
      Optimizes using proportional allocation.

      Allocates gas proportionally to each well's production potential:

      Q_gas,i = Q_gas_total × (potential_i / Σ potential_j)

      where potential_i = (Q_oil_max,i - Q_oil_natural,i) × priority_i

      This is a simple heuristic that does not account for varying marginal responses but is fast and intuitive.

      Parameters:
      totalGas - total available gas (Sm³/d)
      Returns:
      allocation result
    • optimizeSequential

      private GasLiftOptimizer.AllocationResult optimizeSequential(double totalGas)
      Optimizes using sequential filling (greedy algorithm).

      Incrementally allocates gas to the well with the highest marginal response:

      1. Start with minimum gas allocation for each well
      2. Compute marginal response for all wells
      3. Add increment to well with highest response
      4. Repeat until gas is exhausted or no beneficial allocation remains

      This greedy approach converges to the optimal solution as the increment size approaches zero. Uses 1% increments for reasonable accuracy.

      Parameters:
      totalGas - total available gas (Sm³/d)
      Returns:
      allocation result
    • optimizeGradient

      private GasLiftOptimizer.AllocationResult optimizeGradient(double totalGas)
      Optimizes using gradient descent.

      Iteratively adjusts allocations to equalize marginal responses:

      Q_gas,i(k+1) = Q_gas,i(k) + α × (∂Q_oil,i/∂Q_gas,i - avg_slope)

      where α is the step size. After each iteration, allocations are renormalized to satisfy the total gas constraint. The step size decreases with iterations for convergence stability.

      Parameters:
      totalGas - total available gas (Sm³/d)
      Returns:
      allocation result
    • calculateMaxGasFromPower

      private double calculateMaxGasFromPower()
      Calculates maximum gas rate limited by compression power.

      Inverts the compression power equation to find the maximum gas rate:

      Q_max = W_max / [0.1 × ln(P2/P1) / η]

      where W_max is the maximum available compression power.

      Returns:
      maximum gas rate (Sm³/d) or Double.MAX_VALUE if unconstrained
    • calculateCompressionPower

      private double calculateCompressionPower(double gasRate)
      Calculates compression power for a given gas rate.

      Uses simplified isothermal compression power formula:

      W = 0.1 × Q × ln(P2/P1) / η

      where:

      • W = power (kW)
      • Q = gas rate (Sm³/d)
      • P2/P1 = compression ratio
      • η = isentropic efficiency
      Parameters:
      gasRate - gas rate (Sm³/d)
      Returns:
      compression power (kW)
    • getEnabledWellCount

      private int getEnabledWellCount()
      Gets count of enabled wells.
      Returns:
      number of wells enabled for optimization
    • getWellCount

      public int getWellCount()
      Gets number of wells.
      Returns:
      well count