### Features:

• #### Three kinds of boundary condition can be chosen

Boundary condition: Isolated boundary condition ( A ), Periodic boundary condition ( B and C ).

A is an isolated boundary, namely, boundary treatment can't be taken into account.

B or C is one of two types periodic boundary condition, data must be preprocessed on the basis that delete the data on the line of blue dash primarily, and extend dataset to nine times in the space.

• #### Monopolized circles are used to calculate the evenness of data points

evenness = 4 × sumCirclesSize / (pi × regionRectangleSize)

#!/usr/bin/env python
# coding: utf-8
# Evenness v2.0
# calculate the evenness of data points
# Author: Lixin Email: s20180318@xs.ustb.edu.cn
# University of science and technology Beijing
import math
import csv
import pandas as pd
print("------------Evenness v2.0------------")
#input data file
fileName1 = input()
fileName2 = input()
x1 = []
y1 = []
x2 = []
y2 = []
for content in csv_file1:
content = list(map(float,content))
x1.append(content[0])
y1.append(content[1])
for content in csv_file2:
content = list(map(float,content))
x2.append(content[0])
y2.append(content[1])
x11 = list.copy(x1)
y11 = list.copy(y1)
x22 = list.copy(x2)
y22 = list.copy(y2)
print("Set boundary condition:")
print("(A) isolated boundary condition")
print("(B) periodic zero boundary condition")
print("(C) periodic two boundaries condition")
print("Please select pattern and input one of three capitals eg. A:")
pattern = input()
def calProduct(x1,y1):
allProduct = []
for i in range(len(x1)):
product = []
for j in range(len(x1)):
if i  j:
product.append(allProduct[j][i-j-1])
else:
product.append(-1)
if product != []:
newProduct.append(product)
#    print("Generate the product list: " + '\n' + str(newProduct))
return newProduct
def mindata(newProduct,x1):
minPosition = []
minSize = []
for i in range(len(x1)):
mini = max(newProduct[i])
size = 0
minip = 0
for j in range(len(x1)):
if newProduct[i][j] > 0 and newProduct[i][j] = x2Max:
xMax = x2Max
else:
xMax = x1Max
return xMax
def interegion(x1Max,x1Min,y1Max,y1Min,x2Max,x2Min,y2Max,y2Min):
xMax = lessregion(x1Max,x2Max)
xMin = lessregion(x1Min,x2Min)
yMax = lessregion(y1Max,y2Max)
yMin = lessregion(y1Min,y2Min)
print("Intersection region: "+'\n'+"("+str(xMin)+","+str(yMin)+")"+"~"+"("+str(xMax)+","+str(yMax)+")")
return xMax,xMin,yMax,yMin
#calculate the evenness of distribution
def evenness(minSize,x1Max,x1Min,y1Max,y1Min):
sumSize = sum(minSize)
print("The sum of the minimum size is: " + '\n' + str(sumSize))
size = (x1Max-x1Min)*(y1Max-y1Min)
print("The region size is: " + '\n' + str(size))
evenness = 4*sumSize/(math.pi*size)
print("The evenness of the data is: " + '\n' + str(evenness))
return evenness
#find the data in intersection region
def findIntersectionData(x1,y1,x2,y2,xMax,xMin,yMax,yMin):
interx1 = []
intery1 = []
interx2 = []
intery2 = []
for i in range(len(x1)):
if x1[i] = xMin:
if y1[i] = yMin:
interx1.append(x1[i])
intery1.append(y1[i])
for i in range(len(x2)):
if x2[i] = xMin:
if y2[i] = yMin:
interx2.append(x2[i])
intery2.append(y2[i])
#    print("The intersection x1 is: " + '\n' + str(interx1))
#    print("The intersection y1 is: " + '\n' + str(intery1))
#    print("The intersection x2 is: " + '\n' + str(interx2))
#    print("The intersection y2 is: " + '\n' + str(intery2))
return interx1,intery1,interx2,intery2
#calculate the evenness of intersection region
def intereveness(interx1,intery1,interx2,intery2,xMax,xMin,yMax,yMin):
interallProduct1 = calProduct(interx1,intery1)
interallProduct2 = calProduct(interx2,intery2)
internewProduct1 = generateproductlist(interallProduct1)
internewProduct2 = generateproductlist(interallProduct2)
interevenness1 = evenness(interminSize1,xMax,xMin,yMax,yMin)
interevenness2 = evenness(interminSize2,xMax,xMin,yMax,yMin)
print("The intersection evenness of data1 is: " + '\n' + str(interevenness1))
print("The intersection evenness of data2 is: " + '\n' + str(interevenness2))
#save data to csv file
al_x1 = maxLength - len(x1)
if al_x1 > 0:
x1.extend(al_x1*[''])
return x1
al_evenness1 = maxLength - 1
evenness1 = [evenness1]
if al_evenness1 > 0:
evenness1.extend(al_evenness1*[''])
return evenness1
#extend data
def appendnewdata(xzs,newdatax):
for i in range(len(xzs)):
newdatax.append(xzs[i])
return newdatax
def extenddata(x1,y1,x1Max,x1Min,y1Max,y1Min):
#create PBC
l = x1Max - x1Min
k = y1Max - y1Min
xz = []
yz = y1
for i in range(len(x1)):
xzp = x1[i] - l
xz.append(xzp)
xy = []
yy = y1
for i in range(len(x1)):
xyp = x1[i] + l
xy.append(xyp)
xs = x1
ys = []
for i in range(len(y1)):
ysp = y1[i] + k
ys.append(ysp)
xx = x1
yx = []
for i in range(len(y1)):
yxp = y1[i] - k
yx.append(yxp)
xzs = xz
yzs = ys
xzx = xx
yzx = yx
xys = xy
yys = ys
xyx = xy
yyx = yx
newdatax = []
appendnewdata(x1,newdatax)
appendnewdata(xzs,newdatax)
appendnewdata(xs,newdatax)
appendnewdata(xys,newdatax)
appendnewdata(xz,newdatax)
appendnewdata(xy,newdatax)
appendnewdata(xzx,newdatax)
appendnewdata(xx,newdatax)
appendnewdata(xyx,newdatax)
newdatay = []
appendnewdata(y1,newdatay)
appendnewdata(yzs,newdatay)
appendnewdata(ys,newdatay)
appendnewdata(yys,newdatay)
appendnewdata(yz,newdatay)
appendnewdata(yy,newdatay)
appendnewdata(yzx,newdatay)
appendnewdata(yx,newdatay)
appendnewdata(yyx,newdatay)
return newdatax,newdatay
#calculate all PBC products
def calPBCProduct(x1,y1,newdatax,newdatay):
allProduct = []
for i in range(len(x1)):
product = []
for j in range(len(newdatax)):
if i  j:
product.append(allProduct[j][i-j-1])
else:
product.append(-1)
if product != []:
newProduct.append(product)
return newProduct
#find the PBC minimum of radius
def minPBCdata(newProduct,newdatax):
minPosition = []
minSize = []
for i in range(len(newProduct)):
mini = max(newProduct[i])
size = 0
minip = 0
for j in range(len(newdatax)):
if newProduct[i][j] > 0 and newProduct[i][j]  x1Min and y1[i] == y1Min:
del x1[i]
del y1[i]
for i in range(len(x1)-1,-1,-1):
if y1[i] > y1Min and x1[i] == x1Max:
del y1[i]
del x1[i]
(newdatax1,newdatay1) = extenddata(x1,y1,x1Max,x1Min,y1Max,y1Min)
allProduct1 = calPBCProduct(x1,y1,newdatax1,newdatay1)
newProduct1 = generatePBCproductlist(x1,allProduct1)
evenness1 = evenness(minSize1,x1Max,x1Min,y1Max,y1Min)
print("----------DATA2-----------")
(x2Max,x2Min,y2Max,y2Min,num2) = regiondata(x2,y2)
for i in range(len(x2)-1,-1,-1):
if x2[i] > x2Min and y2[i] == y2Min:
del x2[i]
del y2[i]
for i in range(len(x2)-1,-1,-1):
if y2[i] > y2Min and x2[i] == x2Max:
del y2[i]
del x2[i]
(newdatax2,newdatay2) = extenddata(x2,y2,x2Max,x2Min,y2Max,y2Min)
allProduct2 = calPBCProduct(x2,y2,newdatax2,newdatay2)
newProduct2 = generatePBCproductlist(x2,allProduct2)
evenness2 = evenness(minSize2,x2Max,x2Min,y2Max,y2Min)
print("----------INTERSECTION-----------")
(xMax,xMin,yMax,yMin) = interegion(x1Max,x1Min,y1Max,y1Min,x2Max,x2Min,y2Max,y2Min)
(interx1,intery1,interx2,intery2) = findIntersectionData(x11,y11,x22,y22,xMax,xMin,yMax,yMin)
for i in range(len(interx1)-1,-1,-1):
if interx1[i] > xMin and intery1[i] == yMin:
del interx1[i]
del intery1[i]
for i in range(len(interx1)-1,-1,-1):
if intery1[i] > yMin and interx1[i] == xMax:
del intery1[i]
del interx1[i]
for i in range(len(interx2)-1,-1,-1):
if interx2[i] > xMin and intery2[i] == yMin:
del interx2[i]
del intery2[i]
for i in range(len(interx2)-1,-1,-1):
if intery2[i] > yMin and interx2[i] == xMax:
del intery2[i]
del interx2[i]
(internewdatax1,internewdatay1) = extenddata(interx1,intery1,xMax,xMin,yMax,yMin)
interallProduct1 = calPBCProduct(interx1,intery1,internewdatax1,internewdatay1)
internewProduct1 = generatePBCproductlist(interx1,interallProduct1)
interevenness1 = evenness(interminSize1,xMax,xMin,yMax,yMin)
(internewdatax2,internewdatay2) = extenddata(interx2,intery2,xMax,xMin,yMax,yMin)
interallProduct2 = calPBCProduct(interx2,intery2,internewdatax2,internewdatay2)
internewProduct2 = generatePBCproductlist(interx2,interallProduct2)
interevenness2 = evenness(interminSize2,xMax,xMin,yMax,yMin)
#save
print("***********Calculation has been finished!!!***********")
print("***********start to save file in csv***********")
maxLength = max(len(x1),len(x2))
DataFrame1.index = range(1,len(DataFrame1) + 1)
print("Please input the out file name(.csv): ")
saveFile = input()
DataFrame1.to_csv(saveFile)
print("***********Date has been saved in csv***********")
#create B PBC unit
elif pattern == 'B':
print("***********start to calculate!!!***********")
print("----------DATA1-----------")
(x1Max,x1Min,y1Max,y1Min,num1) = regiondata(x1,y1)
for i in range(len(x1)-1,-1,-1):
if x1[i] == x1Min:
del x1[i]
del y1[i]
for i in range(len(x1)-1,-1,-1):
if x1[i] == x1Max:
del x1[i]
del y1[i]
for i in range(len(x1)-1,-1,-1):
if y1[i] == y1Min:
del y1[i]
del x1[i]
for i in range(len(x1)-1,-1,-1):
if y1[i] == y1Max:
del y1[i]
del x1[i]
(newdatax1,newdatay1) = extenddata(x1,y1,x1Max,x1Min,y1Max,y1Min)
allProduct1 = calPBCProduct(x1,y1,newdatax1,newdatay1)
newProduct1 = generatePBCproductlist(x1,allProduct1)
evenness1 = evenness(minSize1,x1Max,x1Min,y1Max,y1Min)
print("----------DATA2-----------")
(x2Max,x2Min,y2Max,y2Min,num2) = regiondata(x2,y2)
for i in range(len(x2)-1,-1,-1):
if x2[i] == x2Min:
del x2[i]
del y2[i]
for i in range(len(x2)-1,-1,-1):
if x2[i] == x2Max:
del x2[i]
del y2[i]
for i in range(len(x2)-1,-1,-1):
if y2[i] == y2Min:
del y2[i]
del x2[i]
for i in range(len(x2)-1,-1,-1):
if y2[i] == y2Max:
del y2[i]
del x2[i]
(newdatax2,newdatay2) = extenddata(x2,y2,x2Max,x2Min,y2Max,y2Min)
allProduct2 = calPBCProduct(x2,y2,newdatax2,newdatay2)
newProduct2 = generatePBCproductlist(x2,allProduct2)
evenness2 = evenness(minSize2,x2Max,x2Min,y2Max,y2Min)
print("----------INTERSECTION-----------")
(xMax,xMin,yMax,yMin) = interegion(x1Max,x1Min,y1Max,y1Min,x2Max,x2Min,y2Max,y2Min)
(interx1,intery1,interx2,intery2) = findIntersectionData(x11,y11,x22,y22,xMax,xMin,yMax,yMin)
for i in range(len(interx1)-1,-1,-1):
if interx1[i] == xMin:
del interx1[i]
del intery1[i]
for i in range(len(interx1)-1,-1,-1):
if interx1[i] == xMax:
del interx1[i]
del intery1[i]
for i in range(len(interx1)-1,-1,-1):
if intery1[i] == yMin:
del intery1[i]
del interx1[i]
for i in range(len(interx1)-1,-1,-1):
if intery1[i] == yMax:
del intery1[i]
del interx1[i]
for i in range(len(interx2)-1,-1,-1):
if interx2[i] == xMin:
del interx2[i]
del intery2[i]
for i in range(len(interx2)-1,-1,-1):
if interx2[i] == xMax:
del interx2[i]
del intery2[i]
for i in range(len(interx2)-1,-1,-1):
if intery2[i] == yMin:
del intery2[i]
del interx2[i]
for i in range(len(interx2)-1,-1,-1):
if intery2[i] == yMax:
del intery2[i]
del interx2[i]
(internewdatax1,internewdatay1) = extenddata(interx1,intery1,xMax,xMin,yMax,yMin)
interallProduct1 = calPBCProduct(interx1,intery1,internewdatax1,internewdatay1)
internewProduct1 = generatePBCproductlist(interx1,interallProduct1)
interevenness1 = evenness(interminSize1,xMax,xMin,yMax,yMin)
(internewdatax2,internewdatay2) = extenddata(interx2,intery2,xMax,xMin,yMax,yMin)
interallProduct2 = calPBCProduct(interx2,intery2,internewdatax2,internewdatay2)
internewProduct2 = generatePBCproductlist(interx2,interallProduct2)
interevenness2 = evenness(interminSize2,xMax,xMin,yMax,yMin)
#save
print("***********Calculation has been finished!!!***********")
print("***********start to save file in csv***********")
maxLength = max(len(x1),len(x2))
DataFrame1 = pd.DataFrame(Data, columns=["x1","y1","minDiameter1","minPosition1","minSize1","evenness1","x2","y2","minDiameter2","minPosition2","minSize2","evenness2","interx1","intery1","interminDiameter1","interminPosition1","interminSize1","interevenness1","interx2","intery2","interminDiameter2","interminPosition2","interminSize2","interevenness2"])
DataFrame1.index = range(1,len(DataFrame1) + 1)
print("Please input the out file name(.csv): ")
saveFile = input()
DataFrame1.to_csv(saveFile)
print("***********Date has been saved in csv***********")
#create isolated boundary condition A
elif pattern == 'A':
#--------------start to calculate----------------
print("***********start to calculate!!!***********")
print("----------DATA1-----------")
allProduct1 = calProduct(x1,y1)
newProduct1 = generateproductlist(allProduct1)
(x1Max,x1Min,y1Max,y1Min,num1) = regiondata(x1,y1)
evenness1 = evenness(minSize1,x1Max,x1Min,y1Max,y1Min)
print("----------DATA2-----------")
allProduct2 = calProduct(x2,y2)
newProduct2 = generateproductlist(allProduct2)
(x2Max,x2Min,y2Max,y2Min,num2) = regiondata(x2,y2)
evenness2 = evenness(minSize2,x2Max,x2Min,y2Max,y2Min)
print("----------INTERSECTION-----------")
(xMax,xMin,yMax,yMin) = interegion(x1Max,x1Min,y1Max,y1Min,x2Max,x2Min,y2Max,y2Min)
(interx1,intery1,interx2,intery2)= findIntersectionData(x1,y1,x2,y2,xMax,xMin,yMax,yMin)
#save
print("***********Calculation has been finished!!!***********")
print("***********start to save file in csv***********")
maxLength = max(len(x1),len(x2))
DataFrame1 = pd.DataFrame(Data, columns=["x1","y1","minDiameter1","minPosition1","minSize1","evenness1","x2","y2","minDiameter2","minPosition2","minSize2","evenness2","interx1","intery1","interminDiameter1","interminPosition1","interminSize1","interevenness1","interx2","intery2","interminDiameter2","interminPosition2","interminSize2","interevenness2"])
DataFrame1.index = range(1,len(DataFrame1) + 1)
print("Please input the out file name(.csv): ")
saveFile = input()
DataFrame1.to_csv(saveFile)
print("***********Date has been saved in csv***********")
else:
print('Please input correct capital A,B,or C!!!')

Email : s20180318@xs.ustb.edu.cn

University of science and technology Beijing