@@ -56,7 +56,7 @@ def parallel_vectors(v1, v2, tol=TOLERANCE):
56
56
cos = numpy .dot (_normalize (v1 ), _normalize (v2 ))
57
57
return (abs (cos - 1 ) < TOLERANCE ) | (abs (cos + 1 ) < TOLERANCE )
58
58
59
- def argsort_coords (coords , decimals = None , tol = TOLERANCE ):
59
+ def argsort_coords (coords , decimals = None , tol = 0.05 ):
60
60
# * np.round for decimal places can lead to more errors than the actual
61
61
# difference between two numbers. For example,
62
62
# np.round([0.1249999999,0.1250000001], 2) => [0.124, 0.125]
@@ -65,19 +65,24 @@ def argsort_coords(coords, decimals=None, tol=TOLERANCE):
65
65
# the coordinates might look more different.
66
66
# * Using the power of two as the factor can reduce such errors, although not
67
67
# faithfully rounding to the required decimals.
68
+ # * For normal molecules, tol~=0.1 in coordinates is enough to distinguish
69
+ # atoms in molecule. A very tight threshold is not appropriate here. With
70
+ # tight threshold, small differences in coordinates may lead to different
71
+ # arg orders.
68
72
if decimals is None :
69
- fac = 2 ** int (- numpy .log2 (tol ) + .5 )
73
+ fac = 2 ** int (- numpy .log2 (tol ))
70
74
else :
71
- fac = 2 ** int (3.3219281 * decimals + .5 )
72
- coords = numpy .around (coords * fac )
75
+ fac = 2 ** int (3.3219281 * decimals )
76
+ # +.5 for rounding to the nearest integer
77
+ coords = (coords * fac + .5 ).astype (int )
73
78
idx = numpy .lexsort ((coords [:,2 ], coords [:,1 ], coords [:,0 ]))
74
79
return idx
75
80
76
- def sort_coords (coords , decimals = None , tol = TOLERANCE ):
81
+ def sort_coords (coords , decimals = None , tol = 0.05 ):
77
82
if decimals is None :
78
83
decimals = int (- numpy .log10 (tol )) - 1
79
84
coords = numpy .asarray (coords )
80
- idx = argsort_coords (coords , decimals = decimals )
85
+ idx = argsort_coords (coords , decimals )
81
86
return coords [idx ]
82
87
83
88
# ref. http://en.wikipedia.org/wiki/Rotation_matrix
@@ -490,8 +495,8 @@ def symm_identical_atoms(gpname, atoms):
490
495
dup_atom_ids = []
491
496
for op in ops :
492
497
newc = numpy .dot (coords , op )
493
- idx = argsort_coords (newc , tol = TOLERANCE * 5 )
494
- if not numpy .allclose (coords0 , newc [idx ], atol = TOLERANCE * 5 ):
498
+ idx = argsort_coords (newc )
499
+ if not numpy .allclose (coords0 , newc [idx ], atol = TOLERANCE ):
495
500
raise PointGroupSymmetryError (
496
501
'Symmetry identical atoms not found. This may be due to '
497
502
'the strict setting of the threshold symm.geom.TOLERANCE. '
0 commit comments