Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowed atoms in tbtnc, and enabled PDOS of ADOS in viz #871

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ we hit release version 1.0.0.
## [0.15.3] - YYYY-MM-DD

### Added
- added ADOS extraction of PDOS data in `sisl.viz`
- enabled submodule access without imports:

import sisl
Expand Down
24 changes: 15 additions & 9 deletions src/sisl/io/tbtrans/_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def read_lattice(self) -> Lattice:
return lattice

def read_geometry(self, *args, **kwargs) -> Geometry:
"""Returns `Geometry` object from this file"""
"""Returns `Geometry` object from this file

Parameters
----------
atoms :
atoms used instead of random species
"""
lattice = self.read_lattice()

xyz = _a.arrayd(np.copy(self.xa))
Expand All @@ -64,23 +70,23 @@ def read_geometry(self, *args, **kwargs) -> Geometry:
lasto = _a.arrayi(np.copy(self.lasto) + 1)
nos = np.diff(lasto, prepend=0)

if "atom" in kwargs:
# The user "knows" which atoms are present
atms = kwargs["atom"]
atoms = kwargs.get("atoms", kwargs.get("atom"))

if atoms is not None:
# Check that all atoms have the correct number of orbitals.
# Otherwise we will correct them
for i in range(len(atms)):
if atms[i].no != nos[i]:
atms[i] = Atom(atms[i].Z, [-1] * nos[i], tag=atms[i].tag)
for i in range(len(atoms)):
if atoms[i].no != nos[i]:
atoms[i] = Atom(atoms[i].Z, [-1] * nos[i], tag=atoms[i].tag)

else:
# Default to Hydrogen atom with nos[ia] orbitals
# This may be counterintuitive but there is no storage of the
# actual species
atms = [Atom("H", [-1] * o) for o in nos]
atoms = [Atom("H", [-1] * o) for o in nos]

# Create and return geometry object
geom = Geometry(xyz, atms, lattice=lattice)
geom = Geometry(xyz, atoms, lattice=lattice)

return geom

Expand Down
26 changes: 18 additions & 8 deletions src/sisl/viz/data/pdos.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@
Extra arguments to be passed to the PDOSData constructor, which depends
on the source requested.

Except for the hamiltonian source, no extra arguments are needed (and they
won't be used). See PDOSData.from_hamiltonian for the extra arguments accepted
by the hamiltonian data constructor.
One should check ``PDOSData.from_*`` for details for each PDOS retrieval.
"""
if source == "pdos":
sile = FileDataSIESTA(fdf=fdf, cls=pdosSileSiesta)
Expand All @@ -272,7 +270,7 @@

geometry = fdf.read_geometry(output=True)

return cls.new(sile, geometry=geometry)
return cls.new(sile, geometry=geometry, **kwargs)

Check warning on line 273 in src/sisl/viz/data/pdos.py

View check run for this annotation

Codecov / codecov/patch

src/sisl/viz/data/pdos.py#L273

Added line #L273 was not covered by tests
elif source == "wfsx":
sile = FileDataSIESTA(fdf=fdf, cls=wfsxSileSiesta)

Expand Down Expand Up @@ -304,7 +302,10 @@
@new.register
@classmethod
def from_tbtrans(
cls, tbt_nc: tbtncSileTBtrans, geometry: Union[Geometry, None] = None
cls,
tbt_nc: tbtncSileTBtrans,
geometry: Union[Geometry, None] = None,
elec: Union[int, str, None] = None,
):
"""Reads the PDOS from a *.TBT.nc file coming from a TBtrans run.

Expand All @@ -316,18 +317,27 @@
Full geometry of the system (including scattering and electrode regions).
Right now only used to get the basis of each atom, which is not
stored in the TBT.nc file.
elec:
which electrode to get the PDOS from. Can be None for the Green function,
otherwise the specified. Otherwise it is the index/name of an electrode
so that one gets the ADOS from that electrode.
"""
PDOS = tbt_nc.DOS(sum=False).T
if elec is None:
elec = "Gf"
PDOS = tbt_nc.DOS(sum=False).T

Check warning on line 327 in src/sisl/viz/data/pdos.py

View check run for this annotation

Codecov / codecov/patch

src/sisl/viz/data/pdos.py#L325-L327

Added lines #L325 - L327 were not covered by tests
else:
PDOS = tbt_nc.ADOS(elec, sum=False).T
elec = f"A{elec}"

Check warning on line 330 in src/sisl/viz/data/pdos.py

View check run for this annotation

Codecov / codecov/patch

src/sisl/viz/data/pdos.py#L329-L330

Added lines #L329 - L330 were not covered by tests
E = tbt_nc.E

read_geometry_kwargs = {}
if geometry is not None:
read_geometry_kwargs["atom"] = geometry.atoms
read_geometry_kwargs["atoms"] = geometry.atoms

Check warning on line 335 in src/sisl/viz/data/pdos.py

View check run for this annotation

Codecov / codecov/patch

src/sisl/viz/data/pdos.py#L335

Added line #L335 was not covered by tests

# Read the geometry from the TBT.nc file and get only the device part
geometry = tbt_nc.read_geometry(**read_geometry_kwargs).sub(tbt_nc.a_dev)

return cls.new(PDOS, geometry, E)
return cls.new(PDOS, geometry, E, extra_attrs={"elec": elec})

Check warning on line 340 in src/sisl/viz/data/pdos.py

View check run for this annotation

Codecov / codecov/patch

src/sisl/viz/data/pdos.py#L340

Added line #L340 was not covered by tests

@new.register
@classmethod
Expand Down