Density

class py4vasp.data.Density(raw_data)

Bases: py4vasp.data._base.DataBase

The charge and magnetization density.

You can use this class to extract the density data of the Vasp calculation and to have a quick glance at the resulting density.

Parameters

raw_density (RawDensity) – Dataclass containing the raw density data as well as structural information.

Methods Summary

from_dict(dict_)

Initialize refinement class from data dictionary

from_file([file])

Read the data dictionary from the given file.

plot([selection])

Plot the selected density as a 3d isosurface within the structure.

print()

Print a string representation of this class to standard output.

read()

Read the electionic density into a dictionary.

to_dict()

Read the electionic density into a dictionary.

to_viewer3d([selection])

Plot the selected density as a 3d isosurface within the structure.

Methods Documentation

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

plot(selection='charge', **user_options)

Plot the selected density as a 3d isosurface within the structure.

Parameters
  • selection (str) – Can be either charge or magnetization, dependending on which quantity should be visualized.

  • user_options – Further arguments with keyword that get directly passed on to the visualizer. Most importantly, you can set isolevel to adjust the value at which the isosurface is drawn.

Returns

Visualize an isosurface of the density within the 3d structure.

Return type

Viewer3d

print()

Print a string representation of this class to standard output.

read()

Read the electionic density into a dictionary.

Returns

Contains the structure information as well as the density represented of a grid in the unit cell.

Return type

dict

to_dict()

Read the electionic density into a dictionary.

Returns

Contains the structure information as well as the density represented of a grid in the unit cell.

Return type

dict

to_viewer3d(selection='charge', **user_options)

Plot the selected density as a 3d isosurface within the structure.

Parameters
  • selection (str) – Can be either charge or magnetization, dependending on which quantity should be visualized.

  • user_options – Further arguments with keyword that get directly passed on to the visualizer. Most importantly, you can set isolevel to adjust the value at which the isosurface is drawn.

Returns

Visualize an isosurface of the density within the 3d structure.

Return type

Viewer3d