Skip to main content

Multiphase flow package

Project description

flotech

flotech

Multiphase Flow Correlation Library

A Python library implementing various multiphase flow correlations for oil and gas production systems, including fluid property calculations and pressure gradient predictions.

Features

  • Multiple Correlation Models:
    • Mukherjee and Brill (1985)
    • Ansari et al. (1994)
    • Aziz and Govier (1972)
    • Hydro Model
    • Gray
    • Fancher and Brown
    • Duns and Ross
    • Stanford Correlation
    • Plus Some more
  • Fluid Property Calculations:
    • Oil, water, and gas properties
    • PVT (Pressure-Volume-Temperature) relationships
  • IPR Calculations:
    • Vogel's Inflow Performance Relationship
    • Darcy's equation

Installation

You can install flotech via pip:

Installation

pip install flotech

Well Performance Analysis with FloTech

This project calculates Vertical Lift Performance (VLP) and compares different multiphase flow correlations along with Vogel Inflow Performance Relationship (IPR).

import numpy as np
import pandas as pd
import math
import flotech
import matplotlib.pyplot as plt
import flotech.FluidProps
import flotech.BeggsandBrill as BB
import flotech.Gray1974 as GR
import flotech.Ansari_1994 as AN
from flotech import HYDRO3Phase as HY, AzizandGovier1972 as AZ, FancherandBrown1963 as FB, Stanford as ST
from flotech import DunsandRos1963 as DR, MukherjeeandBrill1985 as MB

# Input parameters
oil_rate = 900
water_rate = 500
gor = 250
gas_grav = 0.65
oil_grav = 40
wtr_grav = 1.07
diameter = 3
angle = 90.0
thp = 100
tht = 100.0
twf = 150.0
depth = 8000
sample_size = 150

# Temperature gradient calculation
def temp_gradient(t0, t1, depth):
    if depth == 0:
        return 0
    else:
        return abs(t0 - t1) / depth    

t_grad = temp_gradient(tht, twf, depth)
depths = np.linspace(0, depth, sample_size)
temps = tht + t_grad * depths

# Pressure traverse function using a given correlation
def pressure_traverse_general(oil_rate, corr_object):
    p = []
    dpdz = []
    for i in range(len(depths)):
        if i == 0:
            p.append(thp)
        else:
            dz = (depths[i] - depths[i-1])
            pressure = p[i-1] + dz * dpdz[i-1]
            p.append(pressure)
        dpdz_step = corr_object.Pgrad(p[i], temps[i], oil_rate, water_rate, gor, gas_grav, oil_grav, wtr_grav, diameter, angle) 
        dpdz.append(dpdz_step)
    return p, dpdz

# Calculate bottom-hole pressures (BHP) for a range of rates
def vlp(rates, corr_obj):
    bhps = []
    for q in rates:
        p, dpdz = pressure_traverse_general(q, corr_obj)
        bhp = p[-1]
        bhps.append(bhp)
    return bhps

rates = np.linspace(10, 5000, sample_size)

# Plot VLP curves for different correlations
bhps = vlp(rates, FB)
plt.plot(rates, bhps, label="FancherBrown")

bhps = vlp(rates, BB)
plt.plot(rates, bhps, label="Beggs and Brill")

bhps = vlp(rates, AZ)
plt.plot(rates, bhps, label="Aziz Govier")

bhps = vlp(rates, ST)
plt.plot(rates, bhps, label="Stanford University FM")

bhps = vlp(rates, HY)
plt.plot(rates, bhps, label="Hydro 3Phase")

bhps = vlp(rates, DR)
plt.plot(rates, bhps, label="Duns and Ross")

bhps = vlp(rates, MB)
plt.plot(rates, bhps, label="Mukherjee and Brill 1985")

bhps = vlp(rates, AN)
plt.plot(rates, bhps, label="Ansari 1994 - Mechanistic")

bhps = vlp(rates, GR)
plt.plot(rates, bhps, label="Gray 1974")

# Vogel IPR curve parameters and plot
pres = 5000  # psia (Reservoir pressure)
qmax = 5000  # STB/day (Maximum rate at zero pressure)

pwfs = np.linspace(0, pres, 100)
q_vogel = qmax * (1 - 0.2 * (pwfs / pres) - 0.8 * (pwfs / pres) ** 2)

plt.plot(q_vogel, pwfs, label='Vogel IPR', color='black', linewidth=2)

plt.xlabel('Oil Rate (STB/day)')
plt.ylabel('Bottomhole Pressure (psia)')
plt.title('Vogel IPR vs TPR')
plt.legend()
plt.grid(True)
plt.show()

Well Diagram

Wellbore Pressure Profile

This project calculates Vertical Lift Performance (VLP) and compares different multiphase flow correlations along the wellbore path

import numpy as np
import pandas as pd
import math
import flotech
import matplotlib.pyplot as plt
import flotech.FluidProps
import flotech.BeggsandBrill as BB
import flotech.Gray1974 as GR
import flotech.Ansari_1994 as AN
from flotech import HYDRO3Phase as HY, AzizandGovier1972 as AZ, FancherandBrown1963 as FB, Stanford as ST
from flotech import DunsandRos1963 as DR, MukherjeeandBrill1985 as MB
import numpy as np

plt.figure(figsize=(10,20))
oil_rate= 900
water_rate = 500
gor = 250
gas_grav = 0.65
oil_grav = 40
wtr_grav = 1.07
diameter=3
angle=90.0
thp= 100
tht=100.0
twf=150.0
depth = 8000
sample_size =150

def temp_gradient(t0,t1, depth):
    if depth==0:
        return 0
    else:
        return abs(t0-t1)/depth    

t_grad = temp_gradient(tht,twf, depth)
depths = np.linspace(0, depth, sample_size)
temps = tht + t_grad * depths


def pressure_traverse_general(corr_object):
    p=[]
    dpdz=[]
    for i in range(len(depths)):

        if i==0:
            p.append(thp)
        else:
            dz = (depths[i]-depths[i-1])
            pressure = p[i-1]+dz*dpdz[i-1]
            p.append(pressure)

        dpdz_step = corr_object.Pgrad(p[i], temps[i], oil_rate, water_rate, gor, gas_grav, oil_grav, wtr_grav, diameter, angle) 
        dpdz.append(dpdz_step)
    return p, dpdz


bhps,_ = pressure_traverse_general(FB)
plt.plot(bhps, depths, label="FancherBrown", lw=3); 

bhps,_ = pressure_traverse_general(BB)
plt.plot(bhps, depths, label="Beggs and Brill", lw=3); 

bhps,_ = pressure_traverse_general(AZ)
plt.plot(bhps, depths, label="Aziz Govier", lw=3); 

bhps,_ = pressure_traverse_general(ST)
plt.plot(bhps, depths, label="Stanford University FM", lw=3); 

bhps,_ = pressure_traverse_general(HY)
plt.plot(bhps, depths, label="Hydro 3Phase", lw=3); 

bhps,_ = pressure_traverse_general(DR)
plt.plot(bhps, depths, label="Duns and Ross", lw=3); 

bhps,_ = pressure_traverse_general(MB)
plt.plot(bhps, depths, label="Mukherjee and Brill 1985", lw=3); 


bhps,_ = pressure_traverse_general(AN)
plt.plot(bhps, depths, label="Ansari 1994 - Mechanistic", lw=3); 


bhps,_ = pressure_traverse_general(GR)
plt.plot(bhps, depths, label="Gray 1974", lw=3); 

plt.gca().invert_yaxis()
plt.ylabel("TVD ft")
plt.xlabel("Pressure psig")

# Move x-axis ticks and labels to the top
plt.gca().xaxis.set_ticks_position('top')      # Move ticks to top
plt.gca().xaxis.set_label_position('top')      # Move x-axis label to top
plt.gca().tick_params(axis='x', which='both', direction='inout')  # Optional: change tick direction
plt.grid(alpha=.2)


plt.legend()
plt.show()
plt.savefig(r"images\well_pressures.png")

Wellbore Plot

Well Diagram

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flotech-0.2.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flotech-0.2-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file flotech-0.2.tar.gz.

File metadata

  • Download URL: flotech-0.2.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for flotech-0.2.tar.gz
Algorithm Hash digest
SHA256 40cb7a99ddb3c7c934734ab7183293ea11593df9f7740b8a1f42c5d07fc90225
MD5 3159630d35ea16eeca9dec3993167f45
BLAKE2b-256 96fe751322bed209fcf724cba12851126930293ec9f5d1e10f7ab3bdb52c0068

See more details on using hashes here.

File details

Details for the file flotech-0.2-py3-none-any.whl.

File metadata

  • Download URL: flotech-0.2-py3-none-any.whl
  • Upload date:
  • Size: 36.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for flotech-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 554c571a2f08dc0fb9a2ba990a8041f6d9bcbac79fe3773df5c49b06b846dab7
MD5 f158a4008558d7769a5c23217a053b28
BLAKE2b-256 e38fe825b9b311eafe2805da8a6978b9f5b293d12f486f9343c4777749a713d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page