Heterogeneity is the spatial variability in permeability and can be calculated by two methods:

1- Dykstra-Parson Coefficient

2- Lorentz Coefficient


1-Dykstra-Parson Coefficient

data= read.csv("karpur.csv")
head(data)
##    depth caliper ind.deep ind.med  gamma phi.N R.deep  R.med      SP
## 1 5667.0   8.685  618.005 569.781 98.823 0.410  1.618  1.755 -56.587
## 2 5667.5   8.686  497.547 419.494 90.640 0.307  2.010  2.384 -61.916
## 3 5668.0   8.686  384.935 300.155 78.087 0.203  2.598  3.332 -55.861
## 4 5668.5   8.686  278.324 205.224 66.232 0.119  3.593  4.873 -41.860
## 5 5669.0   8.686  183.743 131.155 59.807 0.069  5.442  7.625 -34.934
## 6 5669.5   8.686  109.512  75.633 57.109 0.048  9.131 13.222 -39.769
##   density.corr density phi.core   k.core Facies phi.cor.frac
## 1       -0.033   2.205  33.9000 2442.590     F1     0.339000
## 2       -0.067   2.040  33.4131 3006.989     F1     0.334131
## 3       -0.064   1.888  33.1000 3370.000     F1     0.331000
## 4       -0.053   1.794  34.9000 2270.000     F1     0.349000
## 5       -0.054   1.758  35.0644 2530.758     F1     0.350644
## 6       -0.058   1.759  35.3152 2928.314     F1     0.353152
data <- data[order(data$k.core, decreasing = TRUE), ]
k=data$k.core

Sorting permeability values in a descending order and finding samples >= k portions

data = data[order(data$k.core, decreasing=TRUE), ]
K = data$k.core

#Calculating Number of Samples >= k
sample = c(1: length(K))

# Calculating % >= k
k_percent = (sample * 100) / length(K)

Straight line can be shown

sample=c(1:length(k))
k_percent=(sample*100)/length(k)
xlab="portion of total samples having larger or equal k"
ylab="permeability(md)"
plot(k_percent,k,log="y",xlab=xlab,ylab=ylab,pch=10,cex=0.5,col="#001c49")

A linear model is fitted to the data.

log_k=log(k)
model = lm(log_k ~ k_percent)
plot(k_percent,log_k, xlab = xlab, ylab = ylab, pch = 10, cex = 0.5, col = "#001c49")
abline(model, col = 'red', lwd = 2)

Calculating the Heterogeneity Index

new_data = data.frame(k_percent  = c(50, 84.1))
predicted_values = predict(model, new_data)
heterogenity_index = (predicted_values[1] - predicted_values[2]) / predicted_values[1]
heterogenity_index
##         1 
## 0.2035464

So, the heterogeneity index = 0.2 , which means slightly heterogeneous reservoir, which can be approximated by homogeneous numerical model with minimal error

2-Lorentz Method

The Lorenz coefficient of permeability variation is obtained by plotting graph of cumulative kh versus cumulative phi h

Reading data set again.

data = read.csv("karpur.csv")

Calculating thickness values for each layer from their tops.

#thickness calculation
thickness = c(0.5)
for (i in 2:819) {
  h = data$depth[i] - data$depth[i-1]
  thickness = append(thickness, h)
}

data = data[order(data$k.core, decreasing = TRUE), ]

Then, calculate the flow capacity and storage capacity which is easily the multiplication between permeability and porosity with corresponding thickness. Then calculate the cumulative sum of each one using cumsum() function.

KH = thickness * data$k.core
PH = thickness * data$phi.core
cum_sum_kh = cumsum(KH)
cum_sum_ph = cumsum(PH)

Finally we need to calculate the following terms:

∑cum.k.coretotal & ∑cum.phi.coretotal

frac_tot_vol = (cum_sum_ph/100) / max(cum_sum_ph/100) #to convert phi between (0,1)
frac_tot_flow = cum_sum_kh / max(cum_sum_kh)

Now, plotting the percent of storage capacity on X-axis and the percent of flow capacity on Y-axis:

plot(frac_tot_vol,frac_tot_flow, pch = 10, cex = 0.2, col = '#001c49', text(0.4, 0.8, "D"))
text(0,0, "A", pos = 2)

plot(frac_tot_vol,frac_tot_flow, pch = 10, cex = 0.2, col = '#001c49', text(0.4, 0.8, "D"))
text(0,0, "A", pos = 2)
text(1,1, "B", pos = 1)
text(1,0, "C", pos = 2)
abline(0,1, col = 'red', lwd = 2)

# Set the CRAN mirror
options(repos = c(CRAN = "https://cran.rstudio.com"))

# Install the DescTools package
install.packages("DescTools")
## package 'DescTools' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'DescTools'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## E:\graduation project\R-4.3.1\library\00LOCK\DescTools\libs\x64\DescTools.dll
## to E:\graduation project\R-4.3.1\library\DescTools\libs\x64\DescTools.dll:
## Permission denied
## Warning: restored 'DescTools'
## 
## The downloaded binary packages are in
##  C:\Users\QS\AppData\Local\Temp\Rtmp2j1RdD\downloaded_packages
# Load the DescTools package
library(DescTools)
## Warning: package 'DescTools' was built under R version 4.3.2
require("DescTools")
library(DescTools)

area = AUC(frac_tot_vol, frac_tot_flow, method="trapezoid")

The formula of Lorenz Coefficient:

Lcoff  = (area - 0.5) / 0.5
Lcoff
## [1] 0.4524741

is 0.45, in Lorenz method if the value is closer to zero, it considers more heterogeneous. So the current value considers as heterogeneous reservoir.