.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/3-trajectory.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_3-trajectory.py: Trajectory plotting =================== This example demonstrates the visualization of trajectory data. It also includes visualization of atomic forces. The same parameters can be used with `chemiscope.show` to visualize an interactive widget in a Jupyter notebook. .. GENERATED FROM PYTHON SOURCE LINES 14-20 .. code-block:: Python import ase.io import numpy as np import chemiscope .. GENERATED FROM PYTHON SOURCE LINES 21-22 Load structures and properties .. GENERATED FROM PYTHON SOURCE LINES 23-39 .. code-block:: Python frames = ase.io.read("data/trajectory.xyz", ":") properties = { # concise definition of a property, with just an array and the type # inferred by the size "index": np.arange(len(frames)), # an example of the verbose definition "energy": { "target": "structure", "values": [frame.info["energy"] for frame in frames], "units": "eV", "description": "potential energy, computed with DFTB+", }, } .. GENERATED FROM PYTHON SOURCE LINES 40-41 Create a visualization and save it as a file that can be viewed at chemiscope.org .. GENERATED FROM PYTHON SOURCE LINES 42-83 .. code-block:: Python chemiscope.write_input( "trajectory-md.json.gz", # dataset metadata can also be included, to provide a self-contained description # of the data, authors and references meta={ "name": "Allyl alcohol MD trajectory.", "description": ( "This dataset contains data from a DFTB+ trajectory of allyl alcohol." ), "authors": ["The chemiscope developers"], "references": [ ( "G. Fraux, R. Cersonsky, and M. Ceriotti, " '"Chemiscope: interactive structure-property explorer for materials ' 'and molecules," JOSS 5(51), 2117 (2020).' ) ], }, frames=frames, properties=properties, # visualize forces as vectors shapes={ "forces": chemiscope.ase_vectors_to_arrows( frames, "forces", scale=1, radius=0.15 ) }, settings={ # these are reasonable settings for trajectory visualization "structure": [ { "keepOrientation": True, "playbackDelay": 100, "shape": "forces", # visualize force vectors } ], "map": { "joinPoints": True, }, }, ) .. GENERATED FROM PYTHON SOURCE LINES 84-86 The file can also be viewed in a notebook. Use `chemiscope.show` above to bypass the creation of a JSON file and directly create a viewer. .. GENERATED FROM PYTHON SOURCE LINES 87-89 .. code-block:: Python chemiscope.show_input("trajectory-md.json.gz") .. chemiscope:: _datasets/fig_3-trajectory_004.json.gz :mode: default .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.020 seconds) .. _sphx_glr_download_examples_3-trajectory.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 3-trajectory.ipynb <3-trajectory.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 3-trajectory.py <3-trajectory.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 3-trajectory.zip <3-trajectory.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_