Given these conditions, calculate the Z factor using the correlation by Hall and Yarborough:

# inputs
pres   <- 200  # psia
temp   <- 180  # deg F
gas.sg <- 0.65
n2     <- 0.1
co2    <- 0.08
h2s    <- 0.02
library(rNodal)

# calculating without considering gas impurities
z.hallyarborough(pres, temp, gas.sg) # output is a list
## [1] 0.9819788

Hall-Yarborough

z.hallyarborough(pres, temp, gas.sg)
## [1] 0.9819788
Z(correlation = "HY", pres.a = 5000, temp.f = 180, gas.sg = 0.65, 
  n2.frac = 0.1, co2.frac = 0.08, h2s.frac = 0.02)
## [1] 1.000347
Z(correlation = 1, pres.a = pres, temp.f = temp, gas.sg)
## [1] 0.9819788

Brill-Beggs

z.brillbeggs(pres, temp, gas.sg)
## [1] 0.9839005
Z(correlation = "BB", pres, temp, gas.sg)
## [1] 0.9839005
Z(correlation = "2", pres.a = pres, temp.f = temp, gas.sg)
## [1] 0.9839005
Z(correlation = "2", pres.a = 5000, temp.f = 180, gas.sg = 0.65, 
  n2.frac = 0.1, co2.frac = 0.08, h2s.frac = 0.02)
## [1] 0.9779973
# check temp.pr
# worksheet has a bug in the Farenheit add formula in the book
rNodal:::.z.brillbeggs(5000, 180, 0.65, 
                       n2.frac = 0.1, co2.frac = 0.08, h2s.frac = 0.02)
## $pres.pc
## [1] 697.164
## 
## $temp.pc
## [1] 345.357
## 
## $pres.pr
## [1] 7.171914
## 
## $temp.pr
## [1] 1.853155
## 
## $A
## [1] 0.5746034
## 
## $B
## [1] 2.904786
## 
## $C
## [1] 0.04626825
## 
## $D
## [1] 1.06893
## 
## $z
## [1] 0.9779973
# check temp.pr
# worksheet has a bug in the Farenheit add formula in the book
rNodal:::.z.brillbeggs(5000, 180, 0.65, 
                       n2.frac = 0.1, co2.frac = 0.08, h2s.frac = 0.02)
## $pres.pc
## [1] 697.164
## 
## $temp.pc
## [1] 345.357
## 
## $pres.pr
## [1] 7.171914
## 
## $temp.pr
## [1] 1.853155
## 
## $A
## [1] 0.5746034
## 
## $B
## [1] 2.904786
## 
## $C
## [1] 0.04626825
## 
## $D
## [1] 1.06893
## 
## $z
## [1] 0.9779973
# calculating without considering gas impurities
# data from paper pg 490
z.hallyarborough(2000, 150, 0.7) # output is a list
## [1] 0.8176161
Z(correlation = "BB", 2000, 150, 0.7)
## [1] 0.808433