Multiphase flow package [This is a Test Release]
Project description
flotech
flotech
This is a test release, beta.Please use with caution.Some correlations might not give the best results.This package should be used as is.
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()
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flotech-0.2.2.tar.gz.
File metadata
- Download URL: flotech-0.2.2.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e774222a2d8919ade34a18a829925da91bf6005115eb4748183eb17453cef436
|
|
| MD5 |
0fdb687dad798b0b8718d68c28380382
|
|
| BLAKE2b-256 |
8c6c30298dbc70a0c00ea2ad6f217c94384a552dd1da591566837ea6ab964ccc
|
File details
Details for the file flotech-0.2.2-py3-none-any.whl.
File metadata
- Download URL: flotech-0.2.2-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2312ddb7628861cf48e8cb3d7e23ea1b4d7213deb499989facf480a0a03da182
|
|
| MD5 |
a782bd8467ea5ba935ce0d1d62444ede
|
|
| BLAKE2b-256 |
0a76c42aa9da6b3957629ce423ddc83753a93e255f770a9a5e7b12b3d6a2d2b7
|