mirror of
https://github.com/NehZio/Crystal-MEC
synced 2024-12-22 12:23:51 +01:00
Performance + bugfix with not_in_frag keyword
This commit is contained in:
parent
19a92fb431
commit
eef1cf3d03
@ -84,21 +84,21 @@ if __name__=='__main__':
|
|||||||
xVec = find_center(X,coordinates)
|
xVec = find_center(X,coordinates)
|
||||||
M = rotation_matrix(k,xVec)
|
M = rotation_matrix(k,xVec)
|
||||||
|
|
||||||
rotate(M, coordinates)
|
coordinates = rotate(M, coordinates)
|
||||||
if Y != []:
|
if Y != []:
|
||||||
k = [0,1,0]
|
k = [0,1,0]
|
||||||
|
|
||||||
yVec = find_center(Y,coordinates)
|
yVec = find_center(Y,coordinates)
|
||||||
M = rotation_matrix(k,yVec)
|
M = rotation_matrix(k,yVec)
|
||||||
|
|
||||||
rotate(M, coordinates)
|
coordinates = rotate(M, coordinates)
|
||||||
if Z != []:
|
if Z != []:
|
||||||
k = [0,0,1]
|
k = [0,0,1]
|
||||||
|
|
||||||
zVec = find_center(Z,coordinates)
|
zVec = find_center(Z,coordinates)
|
||||||
M = rotation_matrix(k,zVec)
|
M = rotation_matrix(k,zVec)
|
||||||
|
|
||||||
rotate(M, coordinates)
|
coordinates = rotate(M, coordinates)
|
||||||
|
|
||||||
if verbose > 2:
|
if verbose > 2:
|
||||||
print("The big cell contains %5i atoms and will be printed in the file big_cell.xyz\n"%len(coordinates))
|
print("The big cell contains %5i atoms and will be printed in the file big_cell.xyz\n"%len(coordinates))
|
||||||
@ -113,6 +113,8 @@ if __name__=='__main__':
|
|||||||
|
|
||||||
# Finding the fragment
|
# Finding the fragment
|
||||||
|
|
||||||
|
coordinates = sorted(coordinates, key=lambda x:distance(x,[0,0,0]))
|
||||||
|
|
||||||
nAt, coordinates = find_fragment(coordinates,pattern,npattern,notInFrag)
|
nAt, coordinates = find_fragment(coordinates,pattern,npattern,notInFrag)
|
||||||
|
|
||||||
if verbose > 2 or showFrag:
|
if verbose > 2 or showFrag:
|
||||||
|
@ -70,7 +70,7 @@ def out_input_param(rB , rPP, center, X, Y, Z, symmetry, outputFile, pattern, np
|
|||||||
if len(notInFrag) > 0:
|
if len(notInFrag) > 0:
|
||||||
print("The following %5s will be excluded from the fragment :"%('atom'+'s'*(len(notInFrag)>1)))
|
print("The following %5s will be excluded from the fragment :"%('atom'+'s'*(len(notInFrag)>1)))
|
||||||
for i in notInFrag:
|
for i in notInFrag:
|
||||||
print(" %2s % 8.6f % 8.6f % 8.6f"%(i[0],i[1],i[2],i[3]))
|
print(" % 8.6f % 8.6f % 8.6f"%(i[0],i[1],i[2]))
|
||||||
print()
|
print()
|
||||||
|
|
||||||
# Write the coordinates to a file using the string
|
# Write the coordinates to a file using the string
|
||||||
|
@ -181,7 +181,7 @@ def read_input(inputFile):
|
|||||||
while line.strip().casefold() != 'end':
|
while line.strip().casefold() != 'end':
|
||||||
ls = line.split()
|
ls = line.split()
|
||||||
try:
|
try:
|
||||||
notInFrag.append([ls[0],float(ls[1]),float(ls[2]),float(ls[3])])
|
notInFrag.append([float(ls[0]),float(ls[1]),float(ls[2])])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("Error while parsing the input file : bad value for the atom %s"%line)
|
print("Error while parsing the input file : bad value for the atom %s"%line)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
12
src/utils.py
12
src/utils.py
@ -204,6 +204,8 @@ def find_fragment(coordinates, patterns, npatterns,notInFrag):
|
|||||||
for at in coordinates:
|
for at in coordinates:
|
||||||
if at[3] == pattern[1]:
|
if at[3] == pattern[1]:
|
||||||
d = distance([0,0,0],at)
|
d = distance([0,0,0],at)
|
||||||
|
if d > 10:
|
||||||
|
break
|
||||||
if d < dc :
|
if d < dc :
|
||||||
accept = True
|
accept = True
|
||||||
for exc in notInFrag:
|
for exc in notInFrag:
|
||||||
@ -222,12 +224,20 @@ def find_fragment(coordinates, patterns, npatterns,notInFrag):
|
|||||||
atIn.append([100,100,100,d])
|
atIn.append([100,100,100,d])
|
||||||
|
|
||||||
for at in coordinates:
|
for at in coordinates:
|
||||||
|
if distance(at,[0,0,0]) > 10:
|
||||||
|
break
|
||||||
if at[3] == pattern[j+1]:
|
if at[3] == pattern[j+1]:
|
||||||
atIn = sorted(atIn,key=operator.itemgetter(3))
|
atIn = sorted(atIn,key=operator.itemgetter(3))
|
||||||
d = distance(at,c)
|
d = distance(at,c)
|
||||||
trial = [at[0],at[1],at[2],d,coordinates.index(at)]
|
trial = [at[0],at[1],at[2],d,coordinates.index(at)]
|
||||||
if d < atIn[-1][3] and trial not in atIn:
|
if d < atIn[-1][3] and trial not in atIn:
|
||||||
atIn[-1] = trial
|
accept = True
|
||||||
|
for exc in notInFrag:
|
||||||
|
d = distance(exc,trial)
|
||||||
|
if d < 1e-5:
|
||||||
|
accept = False
|
||||||
|
if accept:
|
||||||
|
atIn[-1] = trial
|
||||||
for at in atIn:
|
for at in atIn:
|
||||||
inPattern.append(at[4])
|
inPattern.append(at[4])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user