Kpoint¶
- class py4vasp.data.Kpoint(data_context, **kwargs)¶
Bases:
Refinery
The k points used in the Vasp calculation.
This class provides utility functionality to extract information about the k points used by Vasp. As such it is mostly used as a helper class for other postprocessing classes to extract the required information, e.g., to generate a band structure.
Attributes Summary
Returns the path from which the output is obtained.
Methods Summary
Convert the coordinates of the k points into a one dimensional array
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.
labels
()Get any labels given in the input file for specific k points.
Get the number of points per line in the Brillouin zone.
mode
()Get the k-point generation mode specified in the Vasp input file
Get the number of points in the Brillouin zone.
Get the number of lines in the Brillouin zone.
path_indices
(start, finish)Find linear dependent k points between start and finish
print
()Print a string representation of this instance.
read
(*args, **kwargs)Convenient wrapper around to_dict.
to_dict
()Read the k points data into a dictionary.
Attributes Documentation
- path¶
Returns the path from which the output is obtained.
Methods Documentation
- distances()¶
Convert the coordinates of the k points into a one dimensional array
For every line in the Brillouin zone, the distance between each k point and the start of the line is calculated. Then the distances of different lines are concatenated into a single list. This routine is mostly useful to plot data along high-symmetry lines like band structures.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
A reduction of the k points onto a one-dimensional array based on the distance between the points.
- Return type:
np.ndarray
- 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
- labels()¶
Get any labels given in the input file for specific k points.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
A list of all the k-points explicitly named in the file or the coordinates of the band edges if no name was provided.
- Return type:
list[str]
- line_length()¶
Get the number of points per line in the Brillouin zone.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
The number of points used to sample a single line.
- Return type:
int
- mode()¶
Get the k-point generation mode specified in the Vasp input file
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
A string representing which mode was used to setup the k-points.
- Return type:
str
- number_kpoints()¶
Get the number of points in the Brillouin zone.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
The number of points used to sample the Brillouin zone.
- Return type:
int
- number_lines()¶
Get the number of lines in the Brillouin zone.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
The number of lines the band structure contains. For regular meshes this is set to 1.
- Return type:
int
- path_indices(start, finish)¶
Find linear dependent k points between start and finish
Loop over all possible k points and return the indices of the ones for which k-point - start is linear dependent on finish - start.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
A list of indices of all k points that fulfil the linear dependence.
- Return type:
list[int]
- 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 k points data into a dictionary.
- Parameters:
selection (str, optional) – You can select “kpoints_opt” or “kpoints_wan” here, to read from those meshes instead of the default one defined by the KPOINTS file.
- Returns:
Contains the coordinates of the k points (in crystal units) as well as their weights used for integrations. Moreover, some data specified in the input file of Vasp are transferred such as the mode used to generate the k points, the line length (if line mode was used), and any labels set for specific points.
- Return type:
dict