viewer

This module is the interface to the Atomic Simulation Environment (ASE, https://wiki.fysik.dtu.dk/ase/) GUI, which enables a molecular viewer to be launched. This viewer allows the visualization of atomic positions and bonds.

class MDMC.MD.ase.viewer.Viewer(images: ase.gui.images.Images = None, rotations: str = '', expr: str = None)[source]

Subclasses the ASE GUI to provide a molecular viewer for MDMC.

It modifies how bonds are plotted by using an alternative get_bonds function in the set_atoms method.

It removes GUI menu options that are not applicable in MDMC.

get_menu_data()[source]

Subset of default ASE GUI menu options which are applicable to MDMC

set_atoms(atoms: ASEAtoms)[source]

Almost an exact copy from ASE

This method is defined purely so that an alternative to the get_bonds function is used. Now the bonds are set during __init__.

Parameters

atoms (ASEAtoms) – The atoms which will be set

MDMC.MD.ase.viewer.get_bonds(atoms: ASEAtoms) numpy.ndarray[source]

Adds (0, 0, 0,) to each bonded atom pair defined within an ASEAtoms object

Parameters

atoms (ASEAtoms) – The ASEAtoms object for which the bonds are required for plotting

MDMC.MD.ase.viewer.limit_atoms(atoms: ASEAtoms, max_atoms: int) ASEAtoms[source]

Limits the number of atoms that are passed to a visualizer

Parameters
  • atoms (ASEAtoms) – The ASEAtoms object to be visualized

  • max_atoms (int) – The maximum number of atoms which can be passed to the visualizer

Warns

warnings.warn – If the number of atoms is greater than max_atoms, the user is warned that atoms will be capped at this size

MDMC.MD.ase.viewer.view(atoms: list[Atom], viewer: str = 'X3DOM', cell: numpy.ndarray = None, **settings: dict) Optional[IPython.core.display.HTML][source]

Launches the ASE GUI for a collection of atoms

Parameters
  • atoms (list) – A list of Atom (MDMC.MD.structures.Atom) to view

  • viewer (str, optional) – The viewer used to display the visualization. This can be ‘X3DOM’, which allows for inline visualization in Jupyter notebooks, or ‘ASE’, which displays in an external window. The default is ‘X3DOM’.

  • cell (numpy.ndarray, optional) – An array of float specifying the dimensions of the cell to view. The default is None.

  • **settings

    max_atoms (int)

    Sets the maximum number of atoms that will be viewed

MDMC.MD.ase.viewer.view_ase(atoms: ASEAtoms, **settings: dict) None[source]

View atom using the ASE viewer

Parameters
  • ase_atoms (ASEAtoms) – The ASEAtoms object to be visualized using the ASE viewer

  • **settings

    max_atoms (int)

    Sets the maximum number of atoms that will be viewed

MDMC.MD.ase.viewer.view_x3dom(atoms: ASEAtoms, **settings: dict) IPython.core.display.HTML[source]

View atoms using the X3D viewer, which enables inline visualization within a IPython/Jupyter notebook

Parameters
  • ase_atoms (ASEAtoms) – The ASEAtoms object to be visualized using the X3D viewer

  • **settings

    max_atoms (int)

    Sets the maximum number of atoms that will be viewed