Skip to content

Commit 0158364

Browse files
committed
maint: check bnorm first
1 parent 2d0d383 commit 0158364

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

sisl/geometry.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,21 +3108,21 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
31083108
# We just need second shell coordinates
31093109
xyz = idx[1][1]
31103110
if len(xyz) == nbonds - 1:
3111-
# Add one bond
3112-
if atom is None:
3113-
atom = Atom(iaZ, R=self.atoms[ia].R)
3114-
if bond is None:
3115-
bond_length = ria + PT.radius(atom.Z)
3116-
else:
3117-
bond_length = bond
31183111
# Compute bond vector
31193112
bvec = len(xyz) * self.xyz[ia] - np.sum(xyz, axis=0)
31203113
bnorm = bvec.dot(bvec) ** .5
31213114
if bnorm > 0.1:
31223115
# only add to geometry if new position is away from ia-atom
3116+
if bond is None:
3117+
bond_length = ria + PT.radius(atom.Z)
3118+
else:
3119+
bond_length = bond
31233120
bvec *= bond_length / bnorm
31243121
new_xyz.append(self.xyz[ia] + bvec)
3125-
new_atom.append(atom)
3122+
if atom is None:
3123+
new_atom.append(Atom(iaZ, R=self.atoms[ia].R))
3124+
else:
3125+
new_atom.append(atom)
31263126
if len(new_xyz) > 0:
31273127
return self.add(self.__class__(new_xyz, new_atom))
31283128
else:

0 commit comments

Comments
 (0)