Skip to main content

A widget to visualize and interact with atomistic structures in Jupyter Notebook.

Project description

Welcome to WEAS Widget!

PyPI version Docs status Unit test

A widget to visualize and edit atomistic structures in Jupyter Notebook. It uses WEAS (Web Environment For Atomistic Structure) in the backend.

Features:

  • Model: space-filling, ball-stick, polyhedral.
  • Supported File type: cif, xyz.
  • Edit structure: move, rotate, delete and replace atoms.
  • Support periodic boundary conditions
  • Animation
  • Isosurface
  • Vector field, e.g., magnetic moment

Installation

Use the pip:

    pip install weas-widget

To install the latest version from source, first clone the repository and then install using pip:

    $ git clone https://github.com/superstar54/weas-widget
    $ pip install -e weas-widget

How to use

Please visit: https://weas-widget.readthedocs.io/en/latest/index.html

Issue

If you encounter any problems, please update the widget to the latest version.

    pip install weas-widget  --upgrade

If the problem persists, please report it on the GitHub issue

Edit the structure with mouse and keyboard

WEAS supports editing the atoms directly in the GUI and synchronizing with the structure of the Python object.

Select Atoms

There are two methods for selecting atoms:

  • Pick Selection: Click directly on an atom to select it.
  • Range Selection: Hold the Shift key and drag the right mouse button to select a group of atoms.

Move, Rotate selected atoms

Press the transform shortcut, and move your mouse.

Operation Shortcut
Move g
Rotate r

Delete selected atoms

Press the x key to delete the selected atoms

Export edited atoms

One can export the edited atoms to ASE or Pymatgen

Example

Load structure

One can load a structure from ASE or Pymatgen

from ase.build import molecule
from weas_widget import WeasWidget
atoms = molecule("C2H6SO")
viewer = WeasWidget()
viewer.from_ase(atoms)
viewer

Crystal view

For a nice visualization of a crystal, one usually shows the polyhedra and the atoms on the unit cell boundary, as well as the bonded atoms outside the cell.

from weas_widget import WeasWidget
viewer1 = WeasWidget()
viewer1.load_example("tio2.cif")
viewer1.modelStyle = 2
viewer1.boundary = [[-0.1, 1.1], [-0.1, 1.1], [-0.1, 1.1]]
viewer1.showBondedAtoms = True
viewer1.colorType = "VESTA"
viewer1

Isosurface

from ase.build import molecule
from weas_widget import WeasWidget
from ase.io.cube import read_cube_data
volume, atoms = read_cube_data("h2o-homo.cube")
viewer = WeasWidget()
viewer.from_ase(atoms)
viewer.volumetricData = {"values": volume}
viewer.isoSettings = [{"isovalue": 0.0001, "mode": 0}]
viewer

Magnetic moment

Show the magnetic moment as a vector field.

from ase.build import bulk
from weas_widget import WeasWidget
import numpy as np
atoms = bulk("Fe", cubic=True)
atoms*=[2, 2, 1]
atoms.set_array("moment", np.ones(len(atoms)))
viewer = WeasWidget()
viewer.from_ase(atoms)
viewer.modelStyle = 1
viewer

Phonon

One can visualize the phonon dispersion via lattice vibrations. One only need to use the eigenstates (calculated with an external software) to generate the trajectory.

import numpy as np
from ase.build import bulk
from weas_widget import WeasWidget
from weas_widget.utils import generate_phonon_trajectory

atoms = bulk("Fe", cubic=True)
eigenvector = np.array([[0, -0.0, 0.5], [0, 0.0, -0.5]])
trajectory = generate_phonon_trajectory(atoms, eigenvector, repeat=[4, 4, 1])
viewer = WeasWidget()
viewer.from_ase(trajectory)
# set a vector field to show the arrow
viewer.vectorField = [{"origins": "positions", "vectors": "movement", "radius": 0.1}]
viewer

Download image

viewer.download_image("filename.png")

Contact

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weas_widget-0.0.11.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

weas_widget-0.0.11-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file weas_widget-0.0.11.tar.gz.

File metadata

  • Download URL: weas_widget-0.0.11.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for weas_widget-0.0.11.tar.gz
Algorithm Hash digest
SHA256 949ffb399c180f4beb31a448dc3844f4b8a291b7b14fb8da8488dd8fe10e90bd
MD5 9c0830fa4c71da2bf922e3c11b739cd1
BLAKE2b-256 40d4ae7d6a85bd1c3686ece04aa2b449f33025eaa0ee2f784685c6dbd3ba2e93

See more details on using hashes here.

File details

Details for the file weas_widget-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: weas_widget-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for weas_widget-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 21697bafdd40be5bba22956022ec9f0a0b50748070bdecd1857dda98438bf9bc
MD5 be0081222dc0e033a36845afcc525197
BLAKE2b-256 4bc8588e0582b1d59c9ba82e229b0c3a423e91b6e8008dd29ee441b2c07b111d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page