Visualise

load_atoms.view(atoms: Atoms, show_bonds: bool = False, start_rotation: bool | None = None)[source]

Generate an interactive visualisation of an ase.Atoms object.

Parameters:
  • atoms – The atoms object to visualise.

  • show_bonds – Whether to show bonds between atoms.

  • start_rotation – Whether to start the visualisation rotating. If None, the default is to start rotating if there are fewer than 400 atoms.

Example

Visualise an ethanol molecule in a Jupyter notebook:

from ase.build import molecule
from load_atoms import view

ethanol = molecule("CH3CH2OH")
view(ethanol, show_bonds=True)

Save the visualisation to an html file:

from pathlib import Path

viz = view(ethanol, show_bonds=True)
Path("ethanol.html").write_text(viz.data)