Viewer3d

class py4vasp.data.Viewer3d(viewer)

Bases: object

Collection of data and elements to be displayed in a structure viewer.

Parameters

viewer (nglview.NGLWidget) – The raw viewer used to display the structure. Currently we are only supporting the nglview package.

Methods Summary

from_structure(structure[, supercell])

Generate a new Viewer3d from a structure.

from_trajectory(trajectory)

Generate a new Viewer3d from a trajectory.

hide_arrows_at_atoms()

Remove all arrows from the atoms.

hide_axes()

Hide the cartesian axis.

hide_cell()

Hide the unit cell of the crystal.

show_arrows_at_atoms(arrows[, color])

Add arrows at all the atoms.

show_axes()

Show the cartesian axis in the corner of the figure.

show_cell()

Show the unit cell of the crystal.

show_isosurface(volume_data, **kwargs)

Add an isosurface to the structure.

Methods Documentation

classmethod from_structure(structure, supercell=None)

Generate a new Viewer3d from a structure.

Parameters
  • structure (data.Structure) – Defines the structure of the Vasp calculation.

  • supercell (int or np.ndarray) – If present the cell is extended by the specified factor along each axis.

classmethod from_trajectory(trajectory)

Generate a new Viewer3d from a trajectory.

Parameters
  • trajectory (data.Structure) – Defines the trajectory of the Vasp MD run.

  • supercell (int or np.ndarray) – If present the cell is extended by the specified factor along each axis.

hide_arrows_at_atoms()

Remove all arrows from the atoms.

Notes

If two different kind of atoms have been added to the system, there is currently no option to distinguish between them.

hide_axes()

Hide the cartesian axis.

hide_cell()

Hide the unit cell of the crystal.

show_arrows_at_atoms(arrows, color=[0.1, 0.1, 0.8])

Add arrows at all the atoms.

Parameters
  • arrows (np.ndarray) – An array containing the direction of an arrow for every atom in the unit cell. This arrow will be drawn in the figure.

  • color (np.ndarray) – rgb values of the arrow, defaulting to blue.

Notes

If you are working on a supercell, the code will automatically extend the size of the array to show arrows in the supercell, too.

show_axes()

Show the cartesian axis in the corner of the figure.

show_cell()

Show the unit cell of the crystal.

show_isosurface(volume_data, **kwargs)

Add an isosurface to the structure.

Parameters
  • volume_data (np.ndarray) – The raw data represented on a 3d grid. Make sure the grid aligns with the FFT grid used in the Vasp calculation.

  • kwargs – Additional parameters passed on to the visualizer. Most relevant is the isolevel changing the position at which the isosurface is drawn.