3
0
mirror of https://github.com/NehZio/Crystal-MEC synced 2024-10-19 22:41:50 +02:00

Pattern recognition amelioration

This commit is contained in:
Leo gaspard 2019-05-09 08:19:00 +02:00
parent bd414ac6ae
commit 92a00d2e59
3 changed files with 25 additions and 15 deletions

8
DOC.md
View File

@ -10,11 +10,13 @@ There is no obligation to put any order in the keywords
* OUTPUT output_file_name * OUTPUT output_file_name
* PATTERN nAtom1 labelAtom1 nAtom2 labelAtom2 ... * PATTERN
nAtom1 labelAtom1 nAtom2 labelAtom2 ...
...
NRETTAP
Not that, if you have more than once the Atom1, you will have to place it again at the end (for example, 5 Ir 8 Sr 6 O 5 Ir)
* NPATTERN nPattern * NPATTERN nPattern1 nPattern2 ...
* LATTICE * LATTICE

View File

@ -5,7 +5,7 @@
<a href="url"><img src="https://github.com/NehZio/Crystal-MET/blob/master/images/fig3.png" align="left" height="400" width="400" ></a> <a href="url"><img src="https://github.com/NehZio/Crystal-MET/blob/master/images/fig3.png" align="left" height="400" width="400" ></a>
Crystal MET (Crystal Maker Effective Tool) is a python3 programs that helps you building a system using only the informations taken from a CIF file. Crystal MET (Crystal Maker Effective Tool) is a python3 programs, developped during an internship at the [LCPQ](www.lcpq.ups-tlse.fr) that helps you building a system using only the informations taken from a CIF file.
Use it with care, always check the output, it may work differently from what you expect. Use it with care, always check the output, it may work differently from what you expect.

View File

@ -28,8 +28,8 @@ yAxis = 'x'
zAxis = 'x' zAxis = 'x'
sym = 'x' sym = 'x'
output_file = 'x' output_file = 'x'
pattern = 'x' pattern = []
npattern = 'x' npattern = []
atoms = 'x' atoms = 'x'
dist = 'x' dist = 'x'
lattice = 'x' lattice = 'x'
@ -194,13 +194,19 @@ def read_input(inputFile):
output_file = line[1] output_file = line[1]
elif line[0] == 'PATTERN': elif line[0] == 'PATTERN':
pattern = [] pattern = []
for i in range(1,len(line)): line = f.readline()
if i%2 == 1: while line.strip() != 'NRETTAP':
pattern.append(int(line[i])) pattern.append([])
else: line = line.split()
pattern.append(line[i]) for i in range(len(line)):
if i%2 == 0:
pattern[-1].append(int(line[i]))
else:
pattern[-1].append(line[i])
line = f.readline()
elif line[0] == 'NPATTERN': elif line[0] == 'NPATTERN':
npattern = int(line[1]) for i in range(1,len(line)):
npattern.append(int(line[i]))
elif line[0] == 'LATTICE': elif line[0] == 'LATTICE':
a = float(f.readline().split()[1]) a = float(f.readline().split()[1])
b = float(f.readline().split()[1]) b = float(f.readline().split()[1])
@ -336,7 +342,7 @@ def set_pp(rPP,coords, notIn): #Select which atoms are in the first shell of pse
now = datetime.datetime.now() now = datetime.datetime.now()
printProgressBar(start,now,i+1,len(coords),prefix='Finding the first shell',length=50) printProgressBar(start,now,i+1,len(coords),prefix='Finding the first shell',length=50)
for j in range(len(coords)): for j in range(len(coords)):
if coords[i][4] != 'O' or dist_zero(coords[j]) > 2*(max([atoms[k] for k in range(3,len(atoms),4)])*npattern+rPP): if coords[i][4] != 'O' or dist_zero(coords[j]) > 2*(max([atoms[k] for k in range(3,len(atoms),4)])*sum(npattern)+rPP):
break break
if coords[i][4] == 'O': if coords[i][4] == 'O':
if coords[j][4] == 'C' and coords[j][3] not in notIn: if coords[j][4] == 'C' and coords[j][3] not in notIn:
@ -351,6 +357,7 @@ def find_frag(pattern, n, coords):
#the fragment according to user input #the fragment according to user input
inFrag = [] inFrag = []
start = datetime.datetime.now() start = datetime.datetime.now()
inPattern = []
for k in range(n): for k in range(n):
closest = [100,100,100] closest = [100,100,100]
now = datetime.datetime.now() now = datetime.datetime.now()
@ -359,7 +366,7 @@ def find_frag(pattern, n, coords):
if j[3] == pattern[1]: if j[3] == pattern[1]:
if distance(j,[0,0,0]) < distance([0,0,0],closest) and [j[0],j[1],j[2],distance(j,j), coords.index(j)] not in inFrag: if distance(j,[0,0,0]) < distance([0,0,0],closest) and [j[0],j[1],j[2],distance(j,j), coords.index(j)] not in inFrag:
closest = [j[0],j[1],j[2],distance(j,j), coords.index(j)] closest = [j[0],j[1],j[2],distance(j,j), coords.index(j)]
for i in range(1,len(pattern)//2): for i in range(len(pattern)//2):
inPattern = [closest] inPattern = [closest]
for j in range(int(pattern[2*i])): for j in range(int(pattern[2*i])):
inPattern.append([100,100,100,distance([100,100,100],closest)]) inPattern.append([100,100,100,distance([100,100,100],closest)])
@ -744,7 +751,8 @@ def main():
coords = sorted(coords,key=dist_zero) coords = sorted(coords,key=dist_zero)
coords = cut_bath(rBath,coords) coords = cut_bath(rBath,coords)
coords = find_frag(pattern, npattern ,coords) for i in range(len(pattern)):
coords = find_frag(pattern[i], npattern[i],coords)
coords = sorted(coords,key=operator.itemgetter(4)) coords = sorted(coords,key=operator.itemgetter(4))
coords = set_pp(rPP,coords,notIn) coords = set_pp(rPP,coords,notIn)
coords = sorted(coords,key=dist_zero,reverse=True) coords = sorted(coords,key=dist_zero,reverse=True)