Heterogeneity is a function of horizontal permeability and can often be measured using two methods: 1- Dyktra-Parsons

The data used

dataset= read.csv("karpur.csv")
head(dataset)
##    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
## 1       -0.033   2.205  33.9000 2442.590     F1
## 2       -0.067   2.040  33.4131 3006.989     F1
## 3       -0.064   1.888  33.1000 3370.000     F1
## 4       -0.053   1.794  34.9000 2270.000     F1
## 5       -0.054   1.758  35.0644 2530.758     F1
## 6       -0.058   1.759  35.3152 2928.314     F1
#SORTING DATD BASED ON K CORE

dataset = dataset[order(dataset$k.core, decreasing = TRUE),  ]
#EXTRACTING K CORE VALUES IN ORDER 
K = dataset$k.core
sample = c(1:819)
k_percent = (sample * 100) / 820

Now,plot Y values (log permeability) and X values k_percent

# Define axis titles
xlab = "Portion of Total Sample Having Higher K "
ylab = "K (md)"
# Draw the graph
plot(k_percent, K, log =  'y', xlab = xlab, ylab = ylab, pch = 12, cex = 0.6, col = "#001c49")

find the Linear Mode

log_k = log(K)
model = lm(log_k ~ k_percent)
plot(k_percent,log_k, xlab = xlab, ylab = ylab, pch = 12, cex = 0.6, col = "#001c49")
abline(model, col = 'green', lwd = 2)

to calculate heterogeneity index:

# Define new data
new_data = data.frame(k_percent  = c(50, 84.1))
# Predict values using the model
predicted_values = predict(model, new_data)
# Calculate the heterogenity index
heterogenity_index = (predicted_values[1] - predicted_values[2]) / predicted_values[1]
heterogenity_index
##         1 
## 0.2038692

2- Lorenz Coefficient

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

need to calculate the thickness of each permeability

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

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

calculate the flow capacity and storage capacity Then calculate the cumulative sum of each one

KH = thickness * data$k.core
PH = thickness * data$phi.core
sum_kh = cumsum(KH)
sum_ph = cumsum(PH)

we need to calculate the fraction total volume and fraction total flow

frac_tot_volume = (sum_ph/100) / max(sum_ph/100) 
frac_tot_flow = sum_kh / max(sum_kh)

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

 plot(frac_tot_volume,frac_tot_flow, pch = 8, cex = 0.4, 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 = 'green', lwd = 2)

We need to estimate the area under the curve (ADBCA).

require("DescTools")
## Loading required package: DescTools

Loading required package: DescTools

library(DescTools)

area = AUC(frac_tot_volume, frac_tot_flow, method="trapezoid")
Lorenz_Coefficient  = (area - 0.5) / 0.5

The heterogeneity Index:

Lorenz_Coefficient
## [1] -0.02338238
## [1] 0.4524741