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

Read electron-phonon quantities #174

Open
wants to merge 3 commits into
base: electron_phonon
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/py4vasp/_raw/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class ElectronPhononSelfEnergy(schema.Sequence):
eigenvalues: VaspData
debye_waller: VaspData
fan: VaspData

bks_idx: VaspData

@dataclasses.dataclass
class ElectronPhononTransport(schema.Sequence):
Expand Down
5 changes: 3 additions & 2 deletions src/py4vasp/_raw/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,16 @@ def selections(quantity):
schema.add(
raw.ElectronPhononSelfEnergy,
required=raw.Version(6, 5),
size=f"{group}/self_energy_meta/id_size",
size=f"{group}/self_energy_meta/ncalculators",
eigenvalues=f"{group}/eigenvalues/eigenvalues",
debye_waller=f"{group}/self_energy_{{}}/selfen_dw",
bks_idx=f"{group}/self_energy_{{}}/bks_idx",
fan=f"{group}/self_energy_{{}}/selfen_fan",
)
schema.add(
raw.ElectronPhononTransport,
required=raw.Version(6, 5),
size=f"{group}/transport_meta/id_size",
size=f"{group}/transport_meta/ncalculators",
mobility=f"{group}/transport_{{}}/mobility",
transport_function=f"{group}/transport_{{}}/transport_function",
)
2 changes: 1 addition & 1 deletion src/py4vasp/calculation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class provides a more flexible interface with which you can determine the source
"workfunction",
)
_nested = {
"electron_phonon": ("self_energy",),
"electron_phonon": ("self_energy","transport",),
}
_private = ("dispersion",)
__all__ = _quantities + tuple(_nested) + _input_files
Expand Down
27 changes: 27 additions & 0 deletions src/py4vasp/calculation/_electron_phonon_self_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,33 @@ def to_dict(self):
"fan": self._read_slice_of_data("fan"),
}

def __len__(self):
return self._raw_data.size

def _read_slice_of_data(self, name):
slice_of_data = getattr(self._raw_data, name)[self._steps]
return [data[:] for data in slice_of_data]

def select(self, selection):
tree = select.Tree.from_string(selection)
for selection in tree.selections():
print(selection)

def get_fan(self,arg):
iband,ikpt,isp,*more = arg
st = SparseTensor(self._raw_data.bks_idx,
self._raw_data.fan)
return st(iband,ikpt,isp)

class SparseTensor():
def __init__(self,bks_idx,tensor):
self.bks_idx = bks_idx
self.tensor = tensor

def _get_ibks(self,iband,ikpt,isp):
return self.bks_idx[iband,ikpt,isp]

def __getitem__(self,arg):
iband,ikpt,isp,*more = arg
ibks = self._get_ibks(iband,ikpt,isp)
return self.tensor[ibks,more]
25 changes: 25 additions & 0 deletions src/py4vasp/calculation/_electron_phonon_transport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright © VASP Software GmbH,
# Licensed under the Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from py4vasp.calculation import _base, _slice


class ElectronPhononTransport(_slice.Mixin, _base.Refinery):
"Placeholder for electron phonon transport"

@_base.data_access
def __str__(self):
return "electron phonon transport"

@_base.data_access
def to_dict(self):
return {
"transport_function": self._read_slice_of_data("transport_function"),
"mobility": self._read_slice_of_data("mobility"),
}

def __len__(self):
return self._raw_data.size

def _read_slice_of_data(self, name):
slice_of_data = getattr(self._raw_data, name)[self._steps]
return [data[:] for data in slice_of_data]