Skip to content

Commit bda662d

Browse files
committed
bug: determine which atom to add before looking up radius
1 parent 0158364 commit bda662d

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
@@ -3113,16 +3113,17 @@ def bond_completion(self, nbonds, atom=None, bond=None, idx=None):
31133113
bnorm = bvec.dot(bvec) ** .5
31143114
if bnorm > 0.1:
31153115
# only add to geometry if new position is away from ia-atom
3116+
if atom is None:
3117+
this_atom = Atom(iaZ, R=self.atoms[ia].R)
3118+
else:
3119+
this_atom = atom
31163120
if bond is None:
3117-
bond_length = ria + PT.radius(atom.Z)
3121+
bond_length = ria + PT.radius(this_atom.Z)
31183122
else:
31193123
bond_length = bond
31203124
bvec *= bond_length / bnorm
31213125
new_xyz.append(self.xyz[ia] + bvec)
3122-
if atom is None:
3123-
new_atom.append(Atom(iaZ, R=self.atoms[ia].R))
3124-
else:
3125-
new_atom.append(atom)
3126+
new_atom.append(this_atom)
31263127
if len(new_xyz) > 0:
31273128
return self.add(self.__class__(new_xyz, new_atom))
31283129
else:

0 commit comments

Comments
 (0)