.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_gpath.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_gallery_plot_gpath.py: e-ph matrix along a path in the BZ ================================== This example shows how to use the GPATH.nc file produced by ABINIT to plot e-ph matrix elements along a path in the BZ. .. GENERATED FROM PYTHON SOURCE LINES 9-14 .. code-block:: Python import os import abipy.data as abidata from abipy.eph.gpath import GpathFile .. GENERATED FROM PYTHON SOURCE LINES 15-18 Here we use one of the GPATH files shipped with abipy with the e-ph matrix g(k,q) with q along a path and k fixed. Replace the call to abidata.ref_file("") with the path to your GPATH.nc .. GENERATED FROM PYTHON SOURCE LINES 18-22 .. code-block:: Python gpath_q = GpathFile(abidata.ref_file("teph4zpr_9o_DS1_GPATH.nc")) print(gpath_q) .. rst-class:: sphx-glr-script-out .. code-block:: none ================================= File Info ================================= Name: teph4zpr_9o_DS1_GPATH.nc Directory: /home/runner/work/abipy/abipy/abipy/data/refs/teph4zpr Size: 120.01 kB Access Time: Wed Jul 2 08:07:31 2025 Modification Time: Wed Jul 2 08:00:59 2025 Change Time: Wed Jul 2 08:00:59 2025 ================================= Structure ================================= Full Formula (Mg1 O1) Reduced Formula: MgO abc : 3.007126 3.007126 3.007126 angles: 60.000000 60.000000 60.000000 pbc : True True True Sites (2) # SP a b c --- ---- --- --- --- 0 Mg 0 0 0 1 O 0.5 0.5 0.5 Abinit Spacegroup: spgid: 0, num_spatial_symmetries: 48, has_timerev: True, symmorphic: False =========================== Electronic Bands (kq) =========================== Number of electrons: 16.0, Fermi level: 6.729 (eV) nsppol: 1, nkpt: 42, mband: 20, nspinor: 1, nspden: 1 {} Direct gap: Energy: 4.479 (eV) Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Final state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 Fundamental gap: Energy: 4.479 (eV) Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Final state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 Bandwidth: 72.521 (eV) Valence maximum located at kpt index 0: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Conduction minimum located at kpt index 0: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 TIP: Use `--verbose` to print k-point coordinates with more digits .. GENERATED FROM PYTHON SOURCE LINES 23-24 To plot the e-ph matrix elements as a function of q. .. GENERATED FROM PYTHON SOURCE LINES 24-34 .. code-block:: Python gpath_q.plot_g_qpath(band_range=None, which_g="avg", with_qexp=0, scale=1, gmax_mev=250, ph_modes=None, with_phbands=True, with_ebands=False, ) .. image-sg:: /gallery/images/sphx_glr_plot_gpath_001.png :alt: k = $\Gamma$ m, n = 5 - 7 :srcset: /gallery/images/sphx_glr_plot_gpath_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 35-36 For the meaning of the different arguments, see the docstring .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: Python print(gpath_q.plot_g_qpath.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none Plot the averaged ``|g(k,q)|`` in meV units along the q-path. Args: band_range: Band range that will be averaged over (python convention). If None all bands are considered. which_g: "avg" to plot the symmetrized ``|g|``, "raw" for unsymmetrized ``|g|``. "all" for both. with_qexp: Multiply ``|g(k, q)|`` by ``|q|^{with_qexp}``. scale: Scaling factor for the marker size used when with_phbands is True. gmax_mev: Show results up to gmax in meV. ph_modes: List of ph branch indices to show (start from 0). If None all modes are shown. with_phbands: False if phonon bands should now be displayed. with_ebands: False if electron bands should now be displayed. ax_mat: List of |matplotlib-Axes| or None if a new figure should be created. fontsize: fontsize for legends and titles Keyword arguments controlling the display of the figure: ================ ======================================================= kwargs Meaning ================ ======================================================= title Title of the plot. Default: None. show True to show the figure. Default: True. savefig "abc.png" or "abc.svg" to save the figure to a file. size_kwargs Dictionary with options passed to fig.set_size_inches e.g. size_kwargs=dict(w=3, h=4). tight_layout True to call fig.tight_layout. Default: False. ax_grid True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged. ax_annotate Add labels to subplots e.g. (a), (b). Default: False fig_close Close figure. Default: False. plotly Try to convert mpl figure to plotly: Default: False ================ ======================================================= .. GENERATED FROM PYTHON SOURCE LINES 39-41 Here we read another file with the e-ph matrix g(k,q) with k along a path and q fixed. .. GENERATED FROM PYTHON SOURCE LINES 41-45 .. code-block:: Python gpath_k = GpathFile(abidata.ref_file("teph4zpr_9o_DS2_GPATH.nc")) print(gpath_k) .. rst-class:: sphx-glr-script-out .. code-block:: none ================================= File Info ================================= Name: teph4zpr_9o_DS2_GPATH.nc Directory: /home/runner/work/abipy/abipy/abipy/data/refs/teph4zpr Size: 91.79 kB Access Time: Wed Jul 2 08:07:32 2025 Modification Time: Wed Jul 2 08:00:59 2025 Change Time: Wed Jul 2 08:00:59 2025 ================================= Structure ================================= Full Formula (Mg1 O1) Reduced Formula: MgO abc : 3.007126 3.007126 3.007126 angles: 60.000000 60.000000 60.000000 pbc : True True True Sites (2) # SP a b c --- ---- --- --- --- 0 Mg 0 0 0 1 O 0.5 0.5 0.5 Abinit Spacegroup: spgid: 0, num_spatial_symmetries: 48, has_timerev: True, symmorphic: False ============================ Electronic Bands (k) ============================ Number of electrons: 16.0, Fermi level: 6.729 (eV) nsppol: 1, nkpt: 42, mband: 20, nspinor: 1, nspden: 1 {} Direct gap: Energy: 4.479 (eV) Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Final state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 Fundamental gap: Energy: 4.479 (eV) Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Final state: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 Bandwidth: 72.521 (eV) Valence maximum located at kpt index 0: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 7, eig: 4.490, occ: 0.000 Conduction minimum located at kpt index 0: spin: 0, kpt: [+0.000, +0.000, +0.000], band: 8, eig: 8.969, occ: 0.000 TIP: Use `--verbose` to print k-point coordinates with more digits .. GENERATED FROM PYTHON SOURCE LINES 46-47 To plot the e-ph matrix elements as a function of q. .. GENERATED FROM PYTHON SOURCE LINES 47-55 .. code-block:: Python gpath_k.plot_g_kpath(band_range=None, which_g="avg", scale=1, gmax_mev=250, ph_modes=None, with_ebands=True, ) .. image-sg:: /gallery/images/sphx_glr_plot_gpath_002.png :alt: q = [0.110, 0.000, 0.000] m, n = 5 - 7 :srcset: /gallery/images/sphx_glr_plot_gpath_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-57 For the meaning of the different arguments, see the docstring .. GENERATED FROM PYTHON SOURCE LINES 57-58 .. code-block:: Python print(gpath_k.plot_g_kpath.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none Plot the averaged ``|g(k,q)|`` in meV units along the k-path. Args: band_range: Band range that will be averaged over (python convention). which_g: "avg" to plot the symmetrized ``|g|``, "raw" for unsymmetrized ``|g|``."all" for both. scale: Scaling factor for the marker size used when with_phbands is True. gmax_mev: Show results up to gmax in meV. ph_modes: List of ph branch indices to show (start from 0). If None all modes are show. with_ebands: False if electron bands should now be displayed. ax_mat: List of |matplotlib-Axes| or None if a new figure should be created. fontsize: fontsize for legends and titles Keyword arguments controlling the display of the figure: ================ ======================================================= kwargs Meaning ================ ======================================================= title Title of the plot. Default: None. show True to show the figure. Default: True. savefig "abc.png" or "abc.svg" to save the figure to a file. size_kwargs Dictionary with options passed to fig.set_size_inches e.g. size_kwargs=dict(w=3, h=4). tight_layout True to call fig.tight_layout. Default: False. ax_grid True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged. ax_annotate Add labels to subplots e.g. (a), (b). Default: False fig_close Close figure. Default: False. plotly Try to convert mpl figure to plotly: Default: False ================ ======================================================= .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.131 seconds) .. _sphx_glr_download_gallery_plot_gpath.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_gpath.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_gpath.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_gpath.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_