Kpoint

class py4vasp.data.Kpoint(raw_data)

Bases: py4vasp.data._base.DataBase

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.

Parameters

raw_kpoint (RawKpoint) – Dataclass containing the raw k-points data used in the calculation.

Methods Summary

distances()

Convert the coordinates of the k points into a one dimensional array

from_dict(dict_)

Initialize refinement class from data dictionary

from_file([file])

Read the data dictionary from the given file.

labels()

Get any labels given in the input file for specific k points.

line_length()

Get the number of points per line in the Brillouin zone.

mode()

Get the k-point generation mode specified in the Vasp input file

number_lines()

Get the number of lines in the Brillouin zone.

print()

Print a string representation of this class to standard output.

read()

Read the k points data into a dictionary.

to_dict()

Read the k points data into a dictionary.

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

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

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_dict(dict_)

Initialize refinement class from data dictionary

Parameters

data_dict (dict) – Data dictionary that contains one or more different raw data sources.

classmethod from_file(file=None)

Read the data dictionary 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 Path or raw.File) – Filename from which the data is extracted. If not present the default filename is used. Alternatively, you can open the file yourself and pass the File 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 File object in which case this is left to the user.

Return type

DataBase

labels()

Get any labels given in the input file for specific k points.

Parameters

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

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

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

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

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Returns

A string representing which mode was used to setup the k-points.

Return type

str

number_lines()

Get the number of lines in the Brillouin zone.

Parameters

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

Returns

The number of lines the band structure contains. For regular meshes this is set to 1.

Return type

int

print()

Print a string representation of this class to standard output.

read()

Read the k points data into a dictionary.

Parameters

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

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

to_dict()

Read the k points data into a dictionary.

Parameters

source (str, optional) – If you used a KPOINTS_OPT file to use a second k-point mesh, you can provide a keyword argument source=”kpoints_opt” to use the k-points defined in that file instead of the one specified in KPOINTS.

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