{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# ElectronBandsPlotter\n\nThis example shows how to plot several band structures on a grid\n\nWe use two GSR files:\n\n si_scf_GSR.n: energies on a homogeneous sampling of the BZ (can be used to compute DOS)\n si_nscf_GSR.nc: energies on a k-path in the BZ (used to plot the band dispersion)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from abipy.abilab import ElectronBandsPlotter\nfrom abipy.data import ref_file\n\n# To plot a grid with two band structures:\nplotter = ElectronBandsPlotter()\nplotter.add_ebands(\"BZ sampling\", ref_file(\"si_scf_GSR.nc\"))\nplotter.add_ebands(\"k-path\", ref_file(\"si_nscf_GSR.nc\"))\n\n# Get pandas dataframe\nframe = plotter.get_ebands_frame()\nprint(frame)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To create a grid plot use:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plotter.gridplot(with_gaps=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To plot a grid with band structures + DOS, use the optional argument `edos_objects`\nThe first subplot gets the band dispersion from eb_objects[0] and the DOS from edos_objects[0]\nedos_kwargs is an optional dictionary passed to `get_dos` to compute the DOS.\n\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "eb_objects = 2 * [ref_file(\"si_nscf_GSR.nc\")]\nedos_objects = 2 * [ref_file(\"si_scf_GSR.nc\")]\n\nplotter = ElectronBandsPlotter()\nplotter.add_ebands(\"Si\", ref_file(\"si_nscf_GSR.nc\"), edos=ref_file(\"si_scf_GSR.nc\"))\nplotter.add_ebands(\"Same data\", ref_file(\"si_nscf_GSR.nc\"), edos=ref_file(\"si_scf_GSR.nc\"))\n# sphinx_gallery_thumbnail_number = 2\nplotter.gridplot()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.0" } }, "nbformat": 4, "nbformat_minor": 0 }