PairCorrelation

class py4vasp.data.PairCorrelation(*args, **kwargs)

Bases: Mixin, Refinery, Mixin

The pair-correlation function for one or several blocks of an MD simulation.

Use this class to inspect how the correlation of the position of different ions types in an MD simulation. The pair-correlation function gives insight into the structural properties and may help to identify certain orders in the system.

Examples

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

>>> calc.pair_correlation.read()

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

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

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

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

Attributes Summary

path

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.

labels()

Return all possible labels for the selection string.

plot(*args, **kwargs)

Wrapper around the to_graph() function.

print()

Print a string representation of this instance.

read(*args, **kwargs)

Convenient wrapper around to_dict.

to_dict([selection])

Read the pair-correlation function and store it in a dictionary.

to_graph([selection])

Plot selected pair-correlation functions.

to_image(*args[, filename])

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

to_plotly(*args, **kwargs)

Convert the graph of this quantity to a plotly figure.

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

labels()

Return all possible labels for the selection string.

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.

to_dict(selection='__all__')

Read the pair-correlation function and store it in a dictionary.

Parameters:

selection (str) –

String specifying which pair-correlation functions are used. Select ‘total’ for the total pair-correlation function or the name of any two ion types (e.g. ‘Sr~Ti’) for a specific pair-correlation function. When no selection is given, all possibilities are read. Separate distinct labels by commas or whitespace. For a complete list of all possible selections, please use

>>> calc.pair_correlation.labels()

Returns:

Contains the labels corresponding to the selection and the associated pair-correlation function for every selected block. Furthermore, the dictionary contains the distances at which the pair-correlation functions are evaluated.

Return type:

dict

Examples

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

>>> calc.pair_correlation.to_dict()

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

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

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

>>> calc.pair_correlation[5].to_dict()
>>> calc.pair_correlation[1:6].to_dict()
to_graph(selection='total')

Plot selected pair-correlation functions.

Parameters:

selection (str) –

String specifying which pair-correlation functions are used. Select ‘total’ for the total pair-correlation function or the name of any two ion types (e.g. ‘Sr~Ti’) for a specific pair-correlation function. When no selection is given, the total pair correlation is used. Separate distinct labels by commas or whitespace. For a complete list of all possible selections, please use

>>> calc.pair_correlation.labels()

Returns:

The graph plots the pair-correlation function for all selected blocks and ion pairs. Note that the various blocks with the same legend and only different ion combinations use different color schemes.

Return type:

Graph

Examples

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

>>> calc.pair_correlation.to_graph()

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

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

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

>>> calc.pair_correlation[5].to_graph()
>>> calc.pair_correlation[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.