.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_ebands.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_ebands.py: Band structure plot =================== This example shows how to plot a band structure using the eigenvalues stored in the GSR file produced at the end of the GS run. .. GENERATED FROM PYTHON SOURCE LINES 10-13 .. code-block:: default from abipy.abilab import abiopen import abipy.data as abidata .. GENERATED FROM PYTHON SOURCE LINES 14-16 Here we use one of the GSR files shipped with abipy. Replace filename with the path to your GSR file or your WFK file. .. GENERATED FROM PYTHON SOURCE LINES 16-19 .. code-block:: default filename = abidata.ref_file("si_nscf_GSR.nc") .. GENERATED FROM PYTHON SOURCE LINES 20-23 Open the GSR file and extract the band structure. (alternatively one can use the shell and `abiopen.py OUT_GSR.nc -nb` to open the file in a jupyter notebook. .. GENERATED FROM PYTHON SOURCE LINES 23-27 .. code-block:: default with abiopen(filename) as ncfile: ebands = ncfile.ebands .. GENERATED FROM PYTHON SOURCE LINES 28-31 Plot the band energies with matplotlib. Note that the labels for the k-points are found automatically in an internal database. Use `with_gaps` to show fundamental and direct gaps. .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: default ebands.plot(with_gaps=True, title="Silicon band structure") .. image:: /gallery/images/sphx_glr_plot_ebands_001.png :alt: Silicon band structure, Si$_{2}$: $E^{dir}_{gap}$ = 2.53, $E^{fund}_{gap}$ = 0.52 (eV) :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 35-36 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 36-43 .. code-block:: default ebands.plotly(with_gaps=True, title="Silicon band structure") # .. warning: # # Note that, for the time being, ``with_gaps`` is incompatible with the ``title`` argument. .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 44-45 Plot the BZ and the k-point path with matplotlib .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: default ebands.kpoints.plot() .. image:: /gallery/images/sphx_glr_plot_ebands_002.png :alt: plot ebands :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.239 seconds) .. _sphx_glr_download_gallery_plot_ebands.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/abinit/abipy/gh-pages?filepath=notebooks/gallery/plot_ebands.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ebands.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ebands.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_