bandgap

py4vasp.calculation.bandgap
class py4vasp.calculation._bandgap.Bandgap(*args, **kwargs)

This class describes the band extrema during the relaxation or MD simulation.

The bandgap represents the energy difference between the highest energy electrons in the valence band and the lowest energy electrons in the conduction band of a material. The fundamental gap occurs between the energy states of electrons in the valence and conduction bands irrespective of the k point. In contrast, the direct gap means that transition from valence to conduction band does not change the k momentum.

To study bandgap the extrema of the valence and conduction band play an important role. This class reports the valence band maximum as well as the conduction band minimum. For collinear calculations (ISPIN = 2) all values are reported separately for both spins as well as ignoring the spin. This simplifies comparison to experimental data, where the transitions either conserve the spin or not.

Examples

If you access a method of this class, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.read()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].read()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].read()
>>> calc.bandgap[1:6].read()
conduction_band_minimum()

Return the conduction band minimum.

Returns:

The value of the conduction band minimum for all selected steps.

Return type:

np.ndarray

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.conduction_band_minimum()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].conduction_band_minimum()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].conduction_band_minimum()
>>> calc.bandgap[1:6].conduction_band_minimum()
direct()

Return the direct bandgap.

The direct bandgap is the minimal distance between a valence and conduction band at a single k point and for a single spin.

Returns:

The value of the bandgap for all selected steps.

Return type:

np.ndarray

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.direct()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].direct()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].direct()
>>> calc.bandgap[1:6].direct()
fundamental()

Return the fundamental bandgap.

The fundamental bandgap is between the maximum of the valence band and the minimum of the conduction band.

Returns:

The value of the bandgap for all selected steps.

Return type:

np.ndarray

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.fundamental()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].fundamental()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].fundamental()
>>> calc.bandgap[1:6].fundamental()
plot(*args, **kwargs)

Wrapper around the to_graph() function.

This will merge multiple graphs if you specify different sources with the selection arguments. All arguments are passed to the wrapped function.

print()

Print a string representation of this instance.

read(*args, **kwargs)

Convenient wrapper around to_dict. Check that function for examples and optional arguments.

selections()

Returns possible alternatives for this particular quantity VASP can produce.

The returned dictionary contains a single item with the name of the quantity mapping to all possible selections. Each of these selection may be passed to other functions of this quantity to select which output of VASP is used.

Returns:

The key indicates this quantity and the values possible choices for arguments to other functions of this quantity.

Return type:

dict

to_csv(*args, filename=None, **kwargs)

Converts data to a csv file.

Writes out a csv file for data stored in a dataframe generated with the to_frame() method. Useful for creating external plots for further analysis.

If no filename is provided a default filename is deduced from the name of the class.

Note that the filename must be a keyword argument, i.e., you explicitly need to write filename=”name_of_file” because the arguments are passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.

Parameters:

filename (str | Path) – Name of the csv file which the data is exported to.

to_dict()

Read the bandgap data from a VASP relaxation or MD trajectory.

Returns:

Contains the fundamental and direct gap as well as the coordinates of the k points where the relevant points in the band structure are.

Return type:

dict

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.to_dict()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].to_dict()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].to_dict()
>>> calc.bandgap[1:6].to_dict()
to_frame(*args, **kwargs)

Wrapper around the to_frame() function.

Generates dataframes from the graph object. For information about parameters that can be passed to this method, look at to_graph().

Returns:

Pandas dataframe corresponding to data in the graph

Return type:

Dataframe

to_graph(selection='fundamental, direct')

Plot the direct and fundamental bandgap along the trajectory.

Parameters:

selection (str) – Select which bandgap to include in the plot. By default the fundamental and the direct one are included. In spin-polarized calculations, you can also select up or down to obtain the bandgap without spin flips.

Returns:

Figure with the ionic step on the x axis and the value of the bandgap on the y axis.

Return type:

Graph

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.to_graph()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].to_graph()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].to_graph()
>>> calc.bandgap[1:6].to_graph()
to_image(*args, filename=None, **kwargs)

Read the data and generate an image writing to the given filename.

The filetype is automatically deduced from the filename; possible are common raster (png, jpg) and vector (svg, pdf) formats. If no filename is provided a default filename is deduced from the name of the class and the picture has png format.

Note that the filename must be a keyword argument, i.e., you explicitly need to write filename=”name_of_file” because the arguments are passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.

to_plotly(*args, **kwargs)

Convert the graph of this quantity to a plotly figure.

The arguments to this function are automatically passed on to the to_graph() function. Please check the documentation of that function to learn which arguments are allowed.

valence_band_maximum()

Return the valence band maximum.

Returns:

The value of the valence band maximum for all selected steps.

Return type:

np.ndarray

Examples

If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calc.bandgap.valence_band_maximum()

To select the results for all steps, you don’t specify the array boundaries.

>>> calc.bandgap[:].valence_band_maximum()

You can also select specific steps or a subset of steps as follows

>>> calc.bandgap[5].valence_band_maximum()
>>> calc.bandgap[1:6].valence_band_maximum()