Python Android Termux Calculator for Piping Size, Flow & Velocity
·4 mins
Table of Contents
Steps required #
graph TD;
A[π± Get Android] --> B[π¦ Install Termux]
B --> C[π Install Python]
C --> D[βοΈ Install Python's Library]
D --> E[πββοΈ Run Script]
Script Features #
This python calculator offers x3 calculation methods which are mostly used for initial piping estimations.
- Velocity from Pipe internal diameter & Volumetric flow
- Pipe internal diameter from Velocity & Volumetric flow
- Volumetric flow from Pipe internal diameter & Velocity
In this script I used x2 python libraries
Script application #
In petrochemical industry while designing piping vendor generally provide standards that needs to be followed. In chlor-alkali industry for instance following velocities are observed for various fluids:
| Service | Material of Construction | Superficial Design Velocity (ft/s) |
|---|---|---|
| Brine, gravity flow | Mild steel, rubber lined or FRP | 1.8-2.0 |
| Brine, forced flow | Mild steel, rubber lined or FRP | 4.5-5.0 |
| Lime solution (25 g/l concentration), forced flow | PVC/FRP | 1.5-1.8 |
| Soda ash solution (20 g/l concentration), forced flow | PVC/FRP | 1.5-1.8 |
| Hydrogen gas | Mild steel, seamless | 22.0-25.0 |
| Chlorine gas | Mild steel, rubber lined | 15.0-20.0 |
| HβSOβ, forced flow | Steel | 5.0-7.0 |
| HCl (33%), gravity flow | Mild steel, rubber lined or PVC/FRP | 1.0-1.2 |
| HCl (33%), forced flow | Mild steel, rubber lined or PVC/FRP | 3.0-5.0 |
| Caustic lye (50% concentration), forced flow | Mild steel pipe | 1.0-1.2 |
| Water-forced flow | Mild steel/PVC/FRP | 5.0-7.0 |
UHDENORA one the primary EPC & design company have mentioned following additional guidelines
| Service | Recommended Velocity in m/s |
|---|---|
| Cooling / demin water | 1.5-2.0 |
| Instrument air | 10-30 |
| Nitrogen | 15-20 |
| Process Condensate | 1.2-2.5 |
| Steam Condensate | 0.5-1 |
| Steam (L.P.) | 15-30 |
| Steam (M.P.) | 25-40 |
| Wet Chlorine | 5-10 |
| Wet Hydrogen | 10-15 |
| Ultra Pure Brine | 1-2 |
| 32 % NaOH, pump discharge | 1-2 |
| 32 % NaOH, below cells | 0.7-0.9 |
| Anolyte, below cells | 0.5-0.7 |
Additional tables & sources are uploaded here. Using these tables & the python calculator one can have preliminary checks at various units of plant which handles different fluids
Script source code #
#! /usr/bin/python
from scipy.optimize import fsolve
from math import *
import pint
unt = pint.UnitRegistry(autoconvert_offset_to_baseunit=True,\
auto_reduce_dimensions=True)
Q_ = unt.Quantity
print ('1- Velocity [m/s] from I.D & flow')
print ('2- I.D [mm] from velocity & flow')
print ('3- Flow [m^3/hr] from I.D & velocity')
cho= int( input('Type choice 1, 2 or 3: ') )
def roots(x, *args):
if cho==1:
v=x
d,f= args[0], args[1]
elif cho==2:
d=x
v,f= args[0], args[1]
else:
f=x
v,d= args[0], args[1]
return f / (pi * d**2 * 0.25) - v
def caseV():
flo= input('Type flow in m^3/hr: ')
f= float(flo) * unt('m^3/hr')
id= input('Type I.D in mm: ')
d= float(id) * unt('mm')
d.ito(unt('m'))
sol, =fsolve( roots, x0=5000, args=(d.m,f.m) )
sol= abs( sol.item() ) * unt('m/hr') #np.float64-> python float
print( sol.to(unt('m/s')) ) #cannot use .ito ??
def caseD():
flo= input('Type flow in m^3/hr: ')
f= float(flo) * unt('m^3/hr')
vel= input('Type velocity in m/s: ')
v= float(vel) * unt('m/s')
v.ito(unt('m/hr'))
sol, =fsolve( roots, x0=0.2, args=(v.m,f.m) )
sol= abs( sol.item() ) * unt('m')
print( sol.to(unt('mm')) )
def caseF():
id= input('Type I.D in mm: ')
d= float(id) * unt('mm')
d.ito(unt('m')) #float-> d.m is magnitude
vel= input('Type velocity in m/s: ')
v= float(vel) * unt('m/s')
v.ito(unt('m/hr')) #float-> v.m is magnitude
sol, =fsolve( roots, x0=10, args=(v.m,d.m) )
print( abs( sol.item() ) * unt('m^3/hr') )
caseV() if cho==1 else ( caseD() if cho==2 else caseF() )
Important Considerations #
- For corrosive fluids, it is generally recommended to use lower velocities to minimize corrosion and erosion.
- Sulfuric Acid (HβSOβ):
- For carbon steel piping, it is crucial to maintain fluid velocities between 1 and 3 ft/s (0.3 to 0.9 m/s).
- Velocities below 1 ft/s can lead to hydrogen-grooving failure, while velocities above approximately 3 ft/s can cause erosion-corrosion.
- Sulfuric Acid (HβSOβ):
- For fluids with suspended solids, the velocity must be high enough to prevent settling but not so high as to cause excessive erosion.
- Pure Brine:
- A velocity in the range of 1 to 2 m/s (3.3 to 6.6 ft/s) is a reasonable starting point.
- Leaning towards the lower end of the range is suggested to mitigate corrosion and erosion.
- Raw Brine (with high sulfate):
- General recommendations for fluid velocities in pipelines often fall within the range of 1 to 2 m/s (3.3 to 6.6 ft/s).
- To prevent scaling and solids sedimentation, the velocity needs to be carefully managed. Too low a velocity can allow solids to settle, while too high a velocity might not prevent certain types of scaling and could lead to erosion.
- Pure Brine: