Skip to content

Commit 55e556e

Browse files
committed
maint: check bnorm first
1 parent d967001 commit 55e556e

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
@@ -2641,21 +2641,21 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
26412641
# We just need second shell coordinates
26422642
xyz = idx[1][1]
26432643
if len(xyz) == nbonds - 1:
2644-
# Add one bond
2645-
if atom is None:
2646-
atom = Atom(iaZ, R=self.atoms[ia].R)
2647-
if bond is None:
2648-
bond_length = ria + PT.radius(atom.Z)
2649-
else:
2650-
bond_length = bond
26512644
# Compute bond vector
26522645
bvec = len(xyz) * self.xyz[ia] - np.sum(xyz, axis=0)
26532646
bnorm = bvec.dot(bvec) ** .5
26542647
if bnorm > 0.1:
26552648
# only add to geometry if new position is away from ia-atom
2649+
if bond is None:
2650+
bond_length = ria + PT.radius(atom.Z)
2651+
else:
2652+
bond_length = bond
26562653
bvec *= bond_length / bnorm
26572654
new_xyz.append(self.xyz[ia] + bvec)
2658-
new_atom.append(atom)
2655+
if atom is None:
2656+
new_atom.append(Atom(iaZ, R=self.atoms[ia].R))
2657+
else:
2658+
new_atom.append(atom)
26592659
if len(new_xyz) > 0:
26602660
return self.add(self.__class__(new_xyz, new_atom))
26612661
else:

0 commit comments

Comments
 (0)