GUI and notebook integration

The ChemicalSystem class provides some convenience functions for integration with the AMS GUI programs, as well as Jupyter notebooks:

ChemicalSystem.gui() int

Opens AMSinput to show the ChemicalSystem.

This will block the Python interpreter until the AMSinput process exits. Returns the exit code of the AMSinput process.

Note that atom selections are currently not shown in AMSinput.

ChemicalSystem.plot(figsize: Tuple[float, float] | None = (4, 4), ax=None, keep_axis: bool = False, **kwargs) None

Shows a ChemicalSystem in a Jupyter notebook.

  • figsize determines the size of the generated figure.

  • ax can be used to place the figure into a Matplotlib subplot object.

  • keep_axis determines the visibility of the axes of the plot.

The remaining keyword arguments of this method are forwarded to ASE’s plot_atoms function, see the ASE documentation for details. A useful application of the keyword arguments is rotating the molecule in the plot:

mol = ChemicalSystem(...)
mol.plot(rotation="50x,40y,30z")

This method relies on ASE and matplotlib for the actual plotting and calling it may throw an ImportError if either of the two packages is can not be found in your Python environment.

Alternatively, you may use the view function from PLAMS:

from scm.plams import view
from scm.libbase import ChemicalSystem

cs = ChemicalSystem("""
System
  Atoms
    H 0. 0. 0.
    H 0.7 0. 0.
  End
  BondOrders
    1 2 1.0
  End
End
""")

view(cs)  # shows up in a Jupyter notebook
view(cs, picture_path="mystructure.png")  # save to disk

See the view documentation in PLAMS for details.