.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_dispersion.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_auto_examples_plot_dispersion.py: Phonon band structure from CASTEP force constants ==================================================== Run :class:`~aiida_pythonjob_ins.workflows.DispersionWorkChain` on quartz force constants (a CASTEP ``.castep_bin``), plot the band structure, and visualise the AiiDA provenance graph that produced it. .. GENERATED FROM PYTHON SOURCE LINES 10-14 Set up AiiDA ------------ A shared helper loads a temporary in-memory profile and a localhost Python code (see ``_aiida_setup.py``). Nothing here touches your real AiiDA configuration. .. GENERATED FROM PYTHON SOURCE LINES 14-21 .. code-block:: Python from _aiida_setup import example_data, get_python_code, show_provenance from aiida import orm from aiida.engine import run_get_node code = get_python_code() .. GENERATED FROM PYTHON SOURCE LINES 22-26 Run the dispersion workflow --------------------------- The workflow reads the force constants (a PythonJob), builds a seekpath q-point path, interpolates the phonon modes, and composes a band structure. .. GENERATED FROM PYTHON SOURCE LINES 26-42 .. code-block:: Python from aiida.plugins import WorkflowFactory # Load via WorkflowFactory (direct imports like # `from aiida_pythonjob_ins.workflows import DispersionWorkChain` also work) DispersionWorkChain = WorkflowFactory("pythonjob_ins.dispersion") results, node = run_get_node( DispersionWorkChain, castep_file=orm.SinglefileData(example_data("quartz.castep_bin")), q_spacing=orm.Float(0.05), code=code, ) print(f"WorkChain finished OK: {node.is_finished_ok}") print(f"Outputs: {sorted(results)}") .. rst-class:: sphx-glr-script-out .. code-block:: none Written to /tmp/tmp9prsijhl/euphonic_object.json Written to /tmp/tmpuf0zqm17/euphonic_object.json WorkChain finished OK: True Outputs: ['band_path', 'band_structure', 'phonon_modes', 'structure'] .. GENERATED FROM PYTHON SOURCE LINES 43-46 Plot the band structure ----------------------- The output is a native AiiDA ``BandsData``; use its built-in matplotlib plotting. .. GENERATED FROM PYTHON SOURCE LINES 46-50 .. code-block:: Python bands = results["band_structure"] bands.show_mpl() .. image-sg:: /auto_examples/images/sphx_glr_plot_dispersion_001.png :alt: plot dispersion :srcset: /auto_examples/images/sphx_glr_plot_dispersion_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-56 Provenance ---------- Every step -- the read/interpolate PythonJobs and the structure/path/bands calcfunctions -- is recorded. Here is the graph that produced the band structure. .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python show_provenance(node, title="Dispersion workflow provenance") .. image-sg:: /auto_examples/images/sphx_glr_plot_dispersion_002.png :alt: Dispersion workflow provenance :srcset: /auto_examples/images/sphx_glr_plot_dispersion_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.805 seconds) .. _sphx_glr_download_auto_examples_plot_dispersion.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dispersion.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dispersion.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_dispersion.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_