# Calculate the Compressibility Factor 'z' for Hydrocarbon Gases

Computational algorithms to solve equations and find the compressibility factor `z` of hydrocarbon gases. Correlations available: Hall-Yarborough, Dranchuk-AbuKassem, Dranchuk-Purvis-Robinson, Beggs-Brill, Papp, Shell and an Artificial Neural Network correlation (Ann10) by Kamyab et al. The package uses the original Standing-Katz chart for statistical comparison and plotting. Applicable to sweet hydrocarbon gases for now.

# zFactor

Computational tools for chemical, petrochemical and petroleum engineers. Calculates the deviation between different correlations for gas compressibility compared to the original Standing-Katz chart.

## Motivation

For the development of vertical lift performance (VLP) curves and other petroleum engineering calculations, it is necessary to calculate properties of hydrocarbons in mixtures, liquid and gaseous phases. Compressibility is one of these hydrocarbon properties. It is important to count with the apropriate correlation and know its range of applicability in order to calculate other properties dependant of `z`.

There are several compressibility correlations. In this package, few of them, or the most used in the industry, are being evaluated. There have been extensive studies on compressibility correlations. This evaluation is different in the sense that provides a graphical view of the range of applicability as well statistical measures of the errors, besides that the work has been written fully in `R` providing the analysis and results for peer review and reproducibility purposes. All the code, functions, notes, datasets are available via GitHub.

This analysis focus on sweet hydrocarbon gases. Compressibility correlations for sour gases are little bit more complicated since they show significant deviations from the curves in the Standing-Katz charts. Effects of CO2, H2S and N2 have to be accounted for. In a future release of `zFactor` correlations for sour hydrocarbons gases will possibly be covered.

## Correlations used in this study

The correlations that are implemented in R for the package zFactor are:

• Beggs and Brill (BB) `(Azizi N. Behbahani R., 2010)`

• Hall and Yarborough (HY) `(Hall and Yarborough, 1973)`

• Dranchuk and Abou-Kassem (DAK) `(Dranchuk and Abou-Kassem, 1975)`

• Dranchuk, Purvis and Robinson (DPR) `(Dranchuk, Purvis, Robinson, and others, 1973)`

• A correlation by Shell Oil Company (SH) `(Kumar, 2004)`, `(Bahadori, 2016)`, `(de Almeida, VelÃ¡squez, and Barbieri, 2014)`, `(Al-Anazi, Pazuki, Nikookar, and Al-Anazi, 2011)`, `(Azizi N. Behbahani R., 2010)`, `(Mohamadi-Baghmolaei, Azin, Osfouri, Mohamadi-Baghmolaei, and Zarei, 2015)`. The Shell correlation was found cited in two books and several papers (including the equation and constants), but the original paper or authors could not be identified.

• A correlation developed with Artificial Neural Networks (Ann10) by Kamyab et al. `(Kamyab, Sampaio, Qanbari, and Eustes, 2010)`

• An explicit correlation by I. Papp `(Papp, 1979)` mentioned in the comparative analysis paper by Gabor Takacs `(Takacs, 1989)`. Not available in English.

## Versions

• In CRAN: `v 0.1.7`
• In GitHub `development versions`

## Installation

I recommend installing from GitHub using `devtools`, that way you get the latest and greatest version. CRAN release cycles allows updates every one to two months.

You can install the latest version of `zFactor` from GitHub with:

Or, if your prefer, from `CRAN`:

## Range of Applicability

How to interpret the colors? We use the Mean Absolute Percentage Error or `MAPE` to visualize how close the correlation follow the experimental values of the Standing-Katz chart.

• `Blue`: the MAPE is zero or near zero
• `Yellow`: the MAPE is around 10 percent.
• 'Red`: the MAPE has reached 25% or more
• `Pink`: the mean absolute percentage error is above or way above 25%.

You can see for yourself which correlation is more stable at different ranges of pseudo-reduce pressures and temperatures.

## Comparative Analysis

The comparative analysis shows tables with different error measurements:

``````MSE:   Mean Squared Error
RMSE:  Root Mean Squared Error
RMSLE: Root Mean Squared Logarithmic Error. Penalizes understimation.
MAPE:  Mean Absolute Percentage Error = AARE
MPE:   Mean Percentage error = ARE
MAE:   Mean Absolute Error
``````

## What you can do with `zFactor`

• Find `z` with any of the correlations provided
• Get values from the Standing-Katz chart at any of the isotherms limited by the pseudo-reduced pressures (`Ppr`) digitized
• Find what isotherms or pseudo-reduced temperatures (`Tpr`) are available from the Standing and Katz chart
• Find what pseudo-reduced pressure points are available
• Plot any of the Standing-Katz isotherms to view `z` in graphical form
• Plot a tile chart to show the range of applicability of the correlations. In essence, get an idea of the accuracy by the location of the desired point at Tpr and Ppr
• Get a statistics table when comparing any of the correlations to the Standing-Katz chart
• Get a matrix of `z` values calculated from any correlation where the rows are the pseudo-reduced temperatures and the columns the pseudo-reduced pressures
• Plot one or multiple isotherms

## Summary of MAPE statistics

This function shows a statistical summary of the Mean Absolute Percentage Error of all the correlations. We are taking the mean, maximum error, minimum eroor, the median and the mode in the whole range of each opf the correlations.

## Vignettes

The vignettes contain examples on the use and analysis of the various correlations.

• StandingKatz_chart.Rmd
• Beggs-Brill.Rmd
• Hall-Yarborough.Rmd
• Dranchuk-AbouKassem.Rmd
• Dranchuk-Purvis-Robinson.Rmd
• shell.Rmd
• ANN.Rmd
• Papp.Rmd

## Tests

There are unit tests for the correlations under tests/testthat.

## How the Standing-Katz chart was constructed

The Standing-Katz (SK) chart data has been read directly from a scanned figure of the original plot drawn by Standing and Katz in 1951. The software used to digitize the data is `graphClick` for the operating system `osX` by Apple. This software has been tested and qualified by scolars working on a similar task of digitizing data. `(Rakap, Rakap, Evran, and Cig, 2016)`

Each one of the SK chart pseudo-reduce temperature curves has been digitized. There are some curves where more points were taken to describe the curvature better. Other curves are almost linear and few points were necessary to define the curve.

## References

The following books and papers were consulted during the development of this package:

[1] B. D. Al-Anazi, G. Pazuki, M. Nikookar, et al. "The prediction of the compressibility factor of sour and natural gas by an artificial neural network system". In: Petroleum Science and Technology 29.4 (2011), pp. 325-336. DOI: 10.1080/10916460903330080. <URL: http://doi.org/10.1080/10916460903330080>.

[2] J. C. de Almeida, J. A. VelÃÂ¡squez and R. Barbieri. "A Methodology for Calculating the Natural Gas Compressibility Factor for a Distribution Network". In: Petroleum Science and Technology 32.21 (2014), pp. 2616-2624. DOI: 10.1080/10916466.2012.755194. eprint: http://dx.doi.org/10.1080/10916466.2012.755194. <URL: http://dx.doi.org/10.1080/10916466.2012.755194>.

[3] I. M. Azizi N. Behbahani R. "An efficient correlation for calculating compressibility factor of natural gases". In: Journal of Natural Gas Chemistry Volume 19.Issue 6, 2010, (2010), pp. 642-645. DOI: 10.1016/S1003-9953(09)60081-5. <URL: http://doi.org/10.1016/S1003-9953(09)60081-5>.

[4] A. Bahadori. Fluid Phase Behavior for Conventional and Unconventional Oil and Gas Reservoirs. ISBN 978-0-12-803437-8. Houston, Texas: Gulf Publishing, 2016. <URL: https://books.google.com/books?id=BwXeDAAAQBAJ>.

[5] P. M. Dranchuk and H. Abou-Kassem. "Calculation of Z Factors For Natural Gases Using Equations of State". In: Journal of Canadian Petroleum Technology (Jul. 1975). DOI: 10.2118/75-03-03. <URL: https://doi.org/10.2118/75-03-03>.

[6] P. M. Dranchuk, R. Purvis, D. Robinson, et al. "Computer calculation of natural gas compressibility factors using the Standing and Katz correlation". In: Annual Technical Meeting. Ed. by unknown. Petroleum Society of Canada. 1973. DOI: 10.2118/73-112. <URL: http://doi.org/10.2118/73-112>.

[7] K. R. Hall and L. Yarborough. "A new equation of state for Z-factor calculations". In: Oil and Gas journal 71.7 (1973), pp. 82-92.

[8] M. Kamyab, J. H. Sampaio, F. Qanbari, et al. "Using artificial neural networks to estimate the z-factor for natural hydrocarbon gases". In: Journal of Petroleum Science and Engineering 73.3 (2010), pp. 248-257. DOI: 10.1016/j.petrol.2010.07.006. <URL: http://doi.org/10.1016/j.petrol.2010.07.006>.

[9] N. Kumar. "Compressibility factors for natural and sour reservoir gases by correlations and cubic equations of state". MA Thesis. Texas Tech University, 2004. <URL: https://ttu-ir.tdl.org/ttu-ir/handle/2346/1370>.

[10] M. Mohamadi-Baghmolaei, R. Azin, S. Osfouri, et al. "Prediction of gas compressibility factor using intelligent models". In: Natural Gas Industry B 2.4 (2015), pp. 283-294. DOI: 10.1016/j.ngib.2015.09.001. <URL: http://doi.org/10.1016/j.ngib.2015.09.001>.

[11] I. Papp. "Uj modszer foldgazok elteresi tenyezojenek szamitasara". In: Koolaj es Foldgaz (Nov. 1979), pp. 345-47.

[12] S. Rakap, S. Rakap, D. Evran, et al. "Comparative evaluation of the reliability and validity of three data extraction programs: UnGraph, GraphClick, and DigitizeIt". In: Computers in Human Behavior 55 (2016), pp. 159-166. DOI: 10.1016/j.chb.2015.09.008. <URL: http://doi.org/10.1016/j.chb.2015.09.008>.

[13] G. Takacs. "Comparing Methods for Calculating z Factor". In: Oil and Gas Journal (May. 1989). DOI: NA. <URL: https://www.researchgate.net/publication/236510717_Comparing_methods_for_calculating_Z-factor>.

# Reference manual

install.packages("zFactor")

0.1.7 by Alfonso R. Reyes, a year ago

https://github.com/f0nzie/zFactor

Browse source code at https://github.com/cran/zFactor

Authors: Alfonso R. Reyes [aut, cre]

Documentation:   PDF Manual