Skip to content

Commit 330f2b6

Browse files
committed
bug: determine which atom to add before looking up radius
1 parent 55e556e commit 330f2b6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sisl/geometry.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,16 +2646,17 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
26462646
bnorm = bvec.dot(bvec) ** .5
26472647
if bnorm > 0.1:
26482648
# only add to geometry if new position is away from ia-atom
2649+
if atom is None:
2650+
this_atom = Atom(iaZ, R=self.atoms[ia].R)
2651+
else:
2652+
this_atom = atom
26492653
if bond is None:
2650-
bond_length = ria + PT.radius(atom.Z)
2654+
bond_length = ria + PT.radius(this_atom.Z)
26512655
else:
26522656
bond_length = bond
26532657
bvec *= bond_length / bnorm
26542658
new_xyz.append(self.xyz[ia] + bvec)
2655-
if atom is None:
2656-
new_atom.append(Atom(iaZ, R=self.atoms[ia].R))
2657-
else:
2658-
new_atom.append(atom)
2659+
new_atom.append(this_atom)
26592660
if len(new_xyz) > 0:
26602661
return self.add(self.__class__(new_xyz, new_atom))
26612662
else:

0 commit comments

Comments
 (0)