From 022a1f9920834e89d053c84c660a93e0a41ca2a0 Mon Sep 17 00:00:00 2001 From: Nick Papior Date: Mon, 27 Nov 2023 10:53:25 +0100 Subject: [PATCH] ensured HSX files would respect input geometry arguments this is important when the geometry contains spherical orbital information and charges etc. Signed-off-by: Nick Papior --- CHANGELOG.md | 1 + src/sisl/io/siesta/binaries.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 657408e84e..6b740f2068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/sisl/io/siesta/binaries.py b/src/sisl/io/siesta/binaries.py index d7bc1609b8..9c68cbfa74 100644 --- a/src/sisl/io/siesta/binaries.py +++ b/src/sisl/io/siesta/binaries.py @@ -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):