Highlight atoms
One can highlight the atoms using the following shapes:
sphere
box
cross
One can see the highlight setting:
viewer.avr.highlight.settings
The default settings has selection and fixed items, which are used to highlight the selected atoms and fixed atoms, respectively.
Add highlight item
One can add one highlight item with the following code:
[1]:
from weas_widget import WeasWidget
from ase.build import fcc110
slab = fcc110('Pt', size=(3, 3, 6), vacuum=10.0)
viewer = WeasWidget()
viewer.from_ase(slab)
viewer.avr.highlight.settings['my_highlight'] = {"indices": [len(slab)-1],
"type": "sphere",
"color": [1.0, 0.0, 0.0],
"scale": 1.2,
"opacity": 0.4}
viewer
[1]:
Highlight fixed atoms
When loading ASE atoms, constraints are converted into an atom attribute fixed_xyz (N x 3 booleans). If any axis is fixed, fixed_xyz is stored and the widget automatically highlights those atoms using the fixed crossView entry. If no atoms are fixed, fixed_xyz is omitted.
Pymatgen structures can also carry fixed-atom info via the selective_dynamics site property (True means movable). When present, it is converted into fixed_xyz and preserved on export.
[2]:
from weas_widget import WeasWidget
from ase.build import fcc110
from ase.constraints import FixAtoms
slab = fcc110('Pt', size=(3, 3, 6), vacuum=10.0)
c = FixAtoms(indices=[atom.index for atom in slab if atom.z < 12.0])
slab.set_constraint(c)
viewer = WeasWidget()
viewer.from_ase(slab)
viewer.camera.setting = {"direction": [0, -1, 0]}
viewer
[2]: