Skip to content

Instantly share code, notes, and snippets.

@widoyo
Forked from giljunqueira/AGA3.py
Created September 26, 2013 23:07
Show Gist options
  • Save widoyo/6721860 to your computer and use it in GitHub Desktop.
Save widoyo/6721860 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 27 09:16:20 2010
@author: g.junqueira
AGA3 METER GAS CALCULATION IMPLEMENTATION as a callable Python function
"""
import math
def AGA3 (DP, Tf, Pf, DFLOW, Dr, ALPHA2,ALPHA1=0.00000925,Tr=60.0, Pb=14.73):
"""
Inputs:
DP = Differential pressure, in Inches H2O
Tf = Flowing Temperature Meter, in Deg. F.
Pf = Flowing Pressure meter, in psig
Tb = Base temprature, in Deg. F. (60 deg. F , as defined in USC)
Pb = Base pressure, in psia (14.73psia, as defined in USC)
Dr = reference orifice plate bore diameter at Tr, in inches
ALPHA1 = linear coefficient of thermal expansion for orifice plate material, in in/in-DegF
carbon steel (0.00000620), 304 or 316 stainless (0.00000925),
monel (0.00000795), Hastalloy C (0.0000063)
"""
return 0
def __orifBore(Dr, Tf, ALPHA1=0.00000925, Tr=60.0):
"""
calculates orifice bore diameter at flowing conditions (d)
"""
d = Dr*(1.0 + ALPHA1*(Tf-Tr))
return (d)
def __pipeIntDiam (Dr, ALPHA2, Tf, Tr=60.0):
"""
"""
D = Dr*(1.0 + ALPHA2*(Tf-Tr))
return (D)
def __velOfApproach (d, D):
"""
"""
__Beta = d/D
__Beta2 = math.pow(__Beta, 4.0)
Ev = 1.0/(math.sqrt((1.0-__Beta2)))
return (Ev)
def __unitConversion (unit=0):
"""
0 = U.S
1 = IP
2 = Metric
3 = SI
"""
__const0 = 3.232790 * math.pow(10.0, 2.0)
__const1 = 4.655210 * math.pow(10.0, 4.0)
__const2 = 3.600 * math.pow(10.0,-2.0)
__const3 = 1.0
if unit ==1:
N1 = __const1
elif unit ==2:
N1 = __const2
elif unit ==3:
N1 = __const3
else:
N1 = __const0
return (N1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment