AGA 7 takes a flowing volume, rate or flowing conditions and calculates base volume, base volume flow rate or volume correction factor. It requires flowing and base pressure, temperature and compressibility. Compressibility is calculated by your favourite equation of state, such as AGA 8.The algorithm for the calculation is extremely straightforward. It is really just the application of the real gas law to the measured volume.
For Flowing Volume:
Pf * Vf = Zf * n * R * Tf
so Vf = Zf * n * R * Tf / Pf
For Base Volume:
Pb * Vb = Zb * n * R * Tb
so Vb = Zb * n * R * Tb / Pb
Dividing the equations, we get
Vb/Vf = (Zb * n * R * Tb / Pb )/( Zf * n * R * Tf / Pf)
so Vb= Vf *(Zb * n * R * Tb * Pf) / ( Zf * n * R * Tf * Pb)
Changing the pressure and temperature doesn't change the number of moles, and R is a constant, so:
Vb= Vf *(Zb * Tb * Pf) / ( Zf * Tf * Pb)
S is defined as Zb / Zf
Fpm is defined as Pf / 101.56 kPa, or Pf / 14.73 PSIF
pb is defined as 101.56 kPa / Pb, or 14.73 PSI / Pb
Ftm is defined as 288.7056 Deg Kelvin / Tf, or 519.67 Deg. Rankin / Tf
Ftb is defined as Tb / 288.7056 Deg Kelvin, or Tb / 519.67 Deg. Rankin
So Fpm * Fpb = Pf / Pb
and Ftm * Ftb = Tb / Tf
So Vb = Vf * Fpm * Fpb* Ftm * Ftb * S
Calculate Fpm = Pf / 101.56 kPa (US base conditions, defined by AGA 7 spec)
Calculate Fpb = 101.56/Pb
Calculate Ftm = (15.55556 + 273.15)/Tf Deg. K (US base conditions, defined by AGA 7 spec)
Calculate Ftb = Tb / (15.55556 + 273.15) Deg. K (US base conditions, defined by AGA 7 spec)
Calculate S = Zb / Zf = Fpv2
Calculate BMV (base multiplier value) = Fpm * Fpb * Ftm * Ftb * S
Apply meter factor to BMV (Note: this is often done to the actual volume prior to using AGA 7.)
Calculate base volume Vb = Vf * BMV / 1000 (Converts M3 to E3M3, or Ft3 to MSCF)
Source: http://www.squinch.org/