.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_eph_from_mp.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_eph_from_mp.py: Electrons and Phonons from the materials project website ======================================================== This example shows how to dowload the electronic band structure and the DDB file using the mp identifier and use the AbiPy API to generate a matplotlib grid with electrons + phonons. IMPORTANT: Electrons and Phonons have been obtained with different codes and different computational settings! Of course, one can always initialize ElectronBands and PhononBands from local netcdf files obtained with Abinit .. GENERATED FROM PYTHON SOURCE LINES 15-56 .. image:: /gallery/images/sphx_glr_plot_eph_from_mp_001.png :alt: Si$_{2}$: $E^{dir}_{gap}$ = 2.56, $E^{fund}_{gap}$ = 0.61 (eV), C$_{2}$: $E^{dir}_{gap}$ = 5.57, $E^{fund}_{gap}$ = 4.11 (eV) :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Structure object does not have symmetry operations computed from Abinit. Calling spglib to get symmetry operations. Structure object does not have symmetry operations computed from Abinit. Calling spglib to get symmetry operations. Downloading DDB for mpid mp-149 (Si2) ... Invoking anaddb to compute phonon bands... Downloading DDB for mpid mp-66 (C2) ... Invoking anaddb to compute phonon bands... | .. code-block:: default from abipy import abilab # List of mp ids for Si, Diamond mpids = ["mp-149", "mp-66"] # Get list of AbiPy ebands from mpids ebands_list = [abilab.ElectronBands.from_mpid(mpid) for mpid in mpids] # Get list of DDB files from the MP website and run anaddb to get the phonon bands. phbands_list = [] for i, mpid in enumerate(mpids): print("Downloading DDB for mpid %s (%s) ..." % (mpid, ebands_list[i].structure.formula)) ddb = abilab.DdbFile.from_mpid(mpid) if ddb is None: raise RuntimeError("%d does not provide DDB" % mpid) print("Invoking anaddb to compute phonon bands...") phbst, _ = ddb.anaget_phbst_and_phdos_files(nqsmall=0) phbands_list.append(phbst.phbands) phbst.close() ddb.close() # The figure has [len(mpids), 2] subplots # The i-th row contains electrons and phonons for the i-th mp identifier. nrows, ncols = len(mpids), 2 ax_mat, fig, plt = abilab.get_axarray_fig_plt(None, nrows=nrows, ncols=ncols, sharex=False, sharey=False, squeeze=False) # Use the `ax` keyword argument to select the matplotlib Axes used to plot the object. # In the band structure plot, we show the fundamental/direct gap as well as the possible # phonon-absorption (-emission) processes allowed by energy-conservation. # (This is a qualitative analysis of e-ph scattering, quasi-momentum and ph dispersion are not taken into account). for i, (ebands, phbands) in enumerate(zip(ebands_list, phbands_list)): ebands.plot(ax=ax_mat[i, 0], with_gaps=True, ylims=(-5, 10), max_phfreq=phbands.maxfreq, show=False) phbands.plot(ax=ax_mat[i, 1], show=False) # Hide xlabel if not last row. if i != len(ebands_list) - 1: for ax in ax_mat[i]: ax.xaxis.label.set_visible(False) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 26.218 seconds) .. _sphx_glr_download_gallery_plot_eph_from_mp.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_eph_from_mp.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_eph_from_mp.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_eph_from_mp.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_