Skip to content

Commit 2d0d383

Browse files
committed
maint: bond_completion with .close(..., ret_xyz=True) call
1 parent 98f44d2 commit 2d0d383

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sisl/geometry.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,8 +3104,10 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
31043104
for ia in selection:
31053105
iaZ = self.atoms[ia].Z
31063106
ria = PT.radius(iaZ)
3107-
idx = self.close(ia, R=(0.1, 0.1 + 2 * ria))[1]
3108-
if len(idx) == nbonds - 1:
3107+
idx = self.close(ia, R=(0.1, 0.1 + 2 * ria), ret_xyz=True)
3108+
# We just need second shell coordinates
3109+
xyz = idx[1][1]
3110+
if len(xyz) == nbonds - 1:
31093111
# Add one bond
31103112
if atom is None:
31113113
atom = Atom(iaZ, R=self.atoms[ia].R)
@@ -3114,9 +3116,7 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
31143116
else:
31153117
bond_length = bond
31163118
# Compute bond vector
3117-
bvec = len(idx) * self.xyz[ia]
3118-
for jdx in idx:
3119-
bvec -= self.axyz(jdx)
3119+
bvec = len(xyz) * self.xyz[ia] - np.sum(xyz, axis=0)
31203120
bnorm = bvec.dot(bvec) ** .5
31213121
if bnorm > 0.1:
31223122
# only add to geometry if new position is away from ia-atom

0 commit comments

Comments
 (0)