Dispersion¶
- class py4vasp.data.Dispersion(data_context, **kwargs)¶
Bases:
Refinery
Generic class for all dispersions (electrons, phonons).
Provides some utility functionalities common to all dispersions to avoid duplication of code.
Attributes Summary
Returns the path from which the output is obtained.
Methods Summary
from_data
(raw_data)Create the instance directly from the raw data.
from_file
(file)Read the quantities from the given file.
from_path
([path])Read the quantities from the given path.
plot
([projections])Generate a graph of the dispersion.
print
()Print a string representation of this instance.
read
(*args, **kwargs)Convenient wrapper around to_dict.
to_dict
()Read the dispersion into a dictionary.
Attributes Documentation
- path¶
Returns the path from which the output is obtained.
Methods Documentation
- classmethod from_data(raw_data)¶
Create the instance directly from the raw data.
Use this approach when the data is put into the correct format by other means than reading from the VASP output files. A typical use case is to read the data with from_path and then act on it with some postprocessing and pass the results to this method.
- Parameters:
raw_data – The raw data required to produce this Refinery.
- Return type:
A Refinery instance to handle the passed data.
- classmethod from_file(file)¶
Read the quantities from the given file.
You want to use this method if you want to avoid using the Calculation wrapper, for example because you renamed the output of the VASP calculation.
- Parameters:
file (str or io.BufferedReader) – Filename from which the data is extracted. Alternatively, you can open the file yourself and pass the Reader object. In that case, you need to take care the file is properly closed again and be aware the generated instance of this class becomes unusable after the file is closed.
- Returns:
The returned instance handles opening and closing the file for every function called on it, unless a Reader object is passed in which case this is left to the user.
- Return type:
Refinery
Notes
VASP produces multiple output files whereas this routine will only link to the single specified file. Prefer from_path routine over this method unless you renamed the VASP output files, because from_path can collate results from multiple files.
- classmethod from_path(path=None)¶
Read the quantities from the given path.
The VASP schema determines the particular files accessed. The files will only be accessed when the data is required for a particular postprocessing call.
- Parameters:
path (str or pathlib.Path) – Path to the directory with the outputs of the VASP calculation. If not set explicitly the current directory will be used.
- Returns:
The returned instance handles opening and closing the files for every function called on it.
- Return type:
Refinery
- plot(projections=None)¶
Generate a graph of the dispersion.
The bands are plotted along the k-point distances. The k-point labels are added as ticks if present. Pass a dictionary with projections to generate a fatband plot based on the weights passed.
- Parameters:
projections (dict) – The key will be used for the legend of the figure. The values will be used to broaden the lines. Must have the same shape as the eigenvalues of the dispersion.
- Returns:
Contains the band structure for all the k points. If projections are passed, the width of the band is adjusted accordingly.
- Return type:
Graph
- print()¶
Print a string representation of this instance.
- read(*args, **kwargs)¶
Convenient wrapper around to_dict. Check that function for examples and optional arguments.
- to_dict()¶
Read the dispersion into a dictionary.
- Returns:
Contains the k-point distances and associated labels as well as the eigenvalues of all the bands.
- Return type:
dict