Skip to content

Commit

Permalink
ensured HSX files would respect input geometry arguments
Browse files Browse the repository at this point in the history
this is important when the geometry contains
spherical orbital information and charges etc.

Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Nov 27, 2023
1 parent d2f72a9 commit 022a1f9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ we hit release version 1.0.0.
- Creation of [n]-triangulenes (`sisl.geom.triangulene`)

### Fixed
- HSX file reads should respect input geometry arguments
- enabled slicing in matrix assignments, #650
- changed `Shape.volume()` to `Shape.volume`
- growth direction for zigzag heteroribbons
Expand Down
29 changes: 29 additions & 0 deletions src/sisl/io/siesta/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,35 @@ def _read_atoms(self, **kwargs):
# now create atoms object
atoms = Atoms([atoms[ia] for ia in isa])

base = kwargs.get("geometry", kwargs.get("geom", None))
if base is None:
return atoms

# Now compare the atoms such that we select the best one
def get_best(aF, aI):
if len(aF) != len(aI):
# the file has the correct number of orbitals
return aF

if aF.Z != aI.Z:
return aF

# check for orbitals being atomicorbital
for orb in aI:
if not isinstance(orb, AtomicOrbital):
return aF

for oF, oI in zip(aF, aI):
for prop in ("n", "l", "m", "zeta", "P"):
if getattr(oF, prop) != getattr(oI, prop):
return aF

# the atoms are the same, so we select the input atom
# since it likely contains the spherical functions
# and the charge
return aI

atoms = Atoms(map(get_best, atoms, base))
return atoms

def _r_geometry_v0(self, **kwargs):
Expand Down

0 comments on commit 022a1f9

Please sign in to comment.