Visualizing System objects

In this notebook, experimental plotting methods of pyscal is illustrated. The plotting functionality works only through jupyter notebooks or jupyter lab. It depends on ipywidgets and plotly to render the output. There is some extra configuration that needs to be done which is mentioned below:

For Jupyter Notebooks

pip install "notebook>=5.3" "ipywidgets>=7.2"

or

conda install "notebook>=5.3" "ipywidgets>=7.2"

For Jupyter Lab

pip install jupyterlab "ipywidgets>=7.5"

or

conda install jupyterlab "ipywidgets=7.5"

followed by,

jupyter labextension install jupyterlab-plotly@4.11.0
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.11.0

We start by importing the necessary modules

import pyscal.core as pc

Now we can set up a system and read in a file to be visualized

sys = pc.System()
sys.read_inputfile("../tests/conf8k.dump", customkeys=["vx", "vy", "vz"])

We will further calculate some q values and also the solid particles in the system which will be used later for visualization

sys.find_neighbors(method="cutoff", cutoff=0)
sys.calculate_q([4, 5, 6], averaged=True)
sys.find_solids()
448

In order to visualize the system, the show method can be used. This method renders a widget which a slider for the radius of atoms and a text box for entering the colormap to be used for coloring atoms. A list of colormaps can be found here. The widget also has a Render plot button which will generate the plot.

sys.show()

This is just a general rendering of the system. Further customization can be done. For example, we can color the atoms using the averaged q6 values.

sys.show(colorby="aq6")

We can also select which atoms are to be plotted. For example we can refine the figure to only plot the atoms that are identified as solid in the find_solids method.

sys.show(colorby="aq6", filterby="solid")

Any atom property can used to color the map. These include any Atom attribute, calculated q values which can be accessed by qx or aqx, for traditional and averaged Steinhardts parameters respectively. x stands for the number of q. It can also be attributes that are stored in the Atom.custom variable. In the above code bit, when the file was read in, the custom variable was used to read in the velocities for each atom. We will color atoms using the velocity in x direction, that is vx attribute.

sys.show(colorby="vx")