.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_qpbands_with_interpolation.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_qpbands_with_interpolation.py: GW corrections ============== This example shows how to interpolate the GW corrections and use the interpolated values to correct the KS band structure computed on a high symmetry k-path and the KS energies of a k-mesh. Finally, the KS and the GW results are plotted with matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 10-72 .. rst-class:: sphx-glr-horizontal * .. image:: /gallery/images/sphx_glr_plot_qpbands_with_interpolation_001.png :alt: Si$_{2}$: $E^{dir}_{gap}$ = 3.13, $E^{fund}_{gap}$ = 1.04 (eV) :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qpbands_with_interpolation_002.png :alt: Combiplot :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qpbands_with_interpolation_003.png :alt: Boxplot, LDA, GW (interpolated) :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qpbands_with_interpolation_004.png :alt: Combiboxplot :class: sphx-glr-multi-img * .. image:: /gallery/images/sphx_glr_plot_qpbands_with_interpolation_005.png :alt: Gridplot, Si$_{2}$: $E^{dir}_{gap}$ = 2.53, $E^{fund}_{gap}$ = 0.52 (eV), Si$_{2}$: $E^{dir}_{gap}$ = 3.13, $E^{fund}_{gap}$ = 1.04 (eV) :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none sigres.structure and ks_ebands_kpath.structures differ. Check your files! Using: 30 star-functions. nstars/nk: 5.0 FIT vs input data: Mean Absolute Error= 1.013e-13 (meV) sigres.structure and ks_ebands_kpath.structures differ. Check your files! | .. code-block:: default import abipy.data as abidata from abipy.abilab import abiopen, ElectronBandsPlotter # Get quasiparticle results from the SIGRES.nc database. sigres = abiopen(abidata.ref_file("si_g0w0ppm_nband30_SIGRES.nc")) # Read the KS band energies computed on the k-path with abiopen(abidata.ref_file("si_nscf_GSR.nc")) as gsr_nscf: ks_ebands_kpath = gsr_nscf.ebands # Read the KS band energies computed on the Monkhorst-Pack (MP) mesh # and compute the DOS with the Gaussian method with abiopen(abidata.ref_file("si_scf_GSR.nc")) as gsr_scf: ks_ebands_kmesh = gsr_scf.ebands ks_edos = ks_ebands_kmesh.get_edos() # Interpolate the QP corrections and use the interpolated values to correct # the KS energies stored in `ks_ebands_kpath` and `ks_ebands_kmesh`. # # The QP energies are returned in r.qp_ebands_kpath and r.qp_ebands_kmesh. # Note that the KS energies are optional but this is the recommended approach # because the code will interpolate the corrections instead of the QP energies. r = sigres.interpolate(lpratio=5, ks_ebands_kpath=ks_ebands_kpath, ks_ebands_kmesh=ks_ebands_kmesh ) qp_edos = r.qp_ebands_kmesh.get_edos() # Get points with ab-initio QP energies from the SIGRES so that # we can plot the interpolate interpolated QP band structure with the first principles results. # This part is optional points = sigres.get_points_from_ebands(r.qp_ebands_kpath, size=24) r.qp_ebands_kpath.plot(points=points, with_gaps=True) #raise ValueError() # Shortcut: pass the name of the GSR files directly. #r = sigres.interpolate(ks_ebands_kpath=abidata.ref_file("si_nscf_GSR.nc"), # ks_ebands_kmesh=abidata.ref_file("si_scf_GSR.nc")) #ks_edos = r.ks_ebands_kmesh.get_edos() #qp_edos = r.qp_ebands_kmesh.get_edos() # Use ElectronBandsPlotter to plot the KS and the QP band structure with matplotlib. plotter = ElectronBandsPlotter() plotter.add_ebands("LDA", ks_ebands_kpath, edos=ks_edos) plotter.add_ebands("GW (interpolated)", r.qp_ebands_kpath, edos=qp_edos) # Get pandas dataframe with band structure parameters. #df = plotter.get_ebands_frame() #print(df) # By default, the two band energies are shifted wrt to *their* fermi level. # Use e=0 if you don't want to shift the eigenvalus # so that it's possible to visualize the QP corrections. plotter.combiplot(title="Combiplot") plotter.boxplot(swarm=True, title="Boxplot") plotter.combiboxplot(swarm=True, title="Combiboxplot") # sphinx_gallery_thumbnail_number = 4 plotter.gridplot(title="Gridplot", with_gaps=True) sigres.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.490 seconds) .. _sphx_glr_download_gallery_plot_qpbands_with_interpolation.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_qpbands_with_interpolation.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_qpbands_with_interpolation.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_qpbands_with_interpolation.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_