#Dyktra-Parsons coefficient of variation is a popular method that can be used for distribution of the permeability on a log-normal probability graph paper.This is done by arranging the permeability values in descending order and then calculating for each permeability, the percent of the samples with permeability greater than that value. to avoid values of zero or 100%, the percent greater than or equal to value is normalized by n+1, where n it is the number of samples. #loading the data
data = read.csv(“karpur.csv”) k_core = data$k.core summary(k_core)
#arranging the permeability values in descending order
sorted_k = sort(k_core, decreasing = TRUE) head(sorted_k)
#Then calculating for each permeability, the percent of the samples with permeability greater than that value. to avoid values of zero or 100%, the percent greater than or equal to value is normalized by n+1, where n it is the number of samples. n = length(sorted_k) #the total number of samples k_percent = c(1:n)/(n+1) head(k_percent)
#polt the data on a lognormal probability graph,where k_percent on the x-axis, sorted_k on the y-axis:
plot( x = k_percent, y = sorted_k, type=“l”, xlab = “% >= k”, ylab = “k”, log=‘y’, lwd=2 )
#as we can see in the graph, the curve in the interval [0.1, 0.9] can be approximated vary well with a straight line, so let’s fit a straight line to this portion of the data
nearly_linear_k_values = sorted_k[floor(0.1n): floor(0.9n)] nearly_linear_k_percent = k_percent[floor(0.1n): floor(0.9n)] linear_model = lm(log10(nearly_linear_k_values) ~ nearly_linear_k_percent) summary(linear_model) plot( x = k_percent, y = sorted_k, type=“l”, xlab = “% >= k”, ylab = “k”, log=‘y’, lwd=2 ) abline(linear_model, col=“yellow”, lwd=2) #Appling:V=(k50−k84.1)/k50 log_k50_and_84.1 = predict( linear_model, data.frame(nearly_linear_k_percent=c(0.50, 0.841)) ) print(10^log_k50_and_84.1)
#Lorenz coefficient #The Lorenz coefficient of permeability variation is obtained by plotting a graph of cumulative kh versus cumulative phi*h, sometimes called a flow capacity plot.
#calculate the thickness from the depths.
#the differences in depths gives the thickness:
d = data$depth h = d[2:n]-d[1:n-1] #differences in depths summary(h)
#we need one more value to have the same number of data samples
h = append(h, 0.5)
#cumulative kh and cumulative phi*h
df = data.frame(h) # we will use data frames to store the data df[‘h’] = h # 1st column k = data\(k.core df['k'] = k # 2nd column df['phi'] = data\)phi.core # 3nd column df = df[order(k, decreasing = TRUE),] #sort data such that k is in descending order
df[‘kh’] = df[‘k’]*df[‘h’] #multiply k and h df[‘sum_kh’] = cumsum(df[‘kh’]) #calculate the cumulative sum df[‘sum_kh/total’] = df[‘sum_kh’]/df[n, ‘sum_kh’] #divide by the total
#same for phi and h
df[‘phih’] = df[‘phi’]*df[‘h’] df[‘sum_phih’] = cumsum(df[‘phih’]) df[‘sum_phih/total’] = df[‘sum_phih’]/df[n, ‘sum_phih’]
#plot cumulative kh versus cumulative phi*h
plot( df[‘sum_phih/total’][1:n,1], df[‘sum_kh/total’][1:n,1], xlab = “fraction of total volume (phih)”, ylab = “fraction of total flow capacity (kh)”, type = “l”, lwd = 2 )
#we need to calculate the area under the above graph, I implemented the trapezoid method to find the AUC. x = c(df[‘sum_phih/total’][1:n,1]) dx = x[2:n] - x[1:n-1]
y1 = c(df[‘sum_kh/total’][1:n,1])[1:n-1] y2 = c(df[‘sum_kh/total’][1:n,1])[2:n]
lower_area = sum(y1dx) #Reduce(“+”, y1dx) upper_area = sum(y2dx) #Reduce(“+”, y2dx)
AUC = (lower_area + upper_area)/2
print(AUC)
#finally we calculate Lorenz coefficient as fallows:
#Lorenz coefficient=(AUC−0.5)/0.5 Lorenz_coefficient = (AUC - 0.5)/0.5 print(Lorenz_coefficient)