PK Rr
plot_phonons_msqd.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Debye-Waller and generalized phonon DOS\n\nThis example shows how to plot the generalized phonon DOS with the mean square\ndisplacement tensor in cartesian coords and how to calculate Debye Waller factors\nas a function of temperature.\n\nSee :cite:`Lee1995` for the further details about the internal implementation and\n:cite:`Trueblood1996` for the different conventions used by crystallographers.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy import abilab\n\n# Open DDB file for alpha-SiO2 taken from https://materialsproject.org/materials/mp-7000/\nfilepath = os.path.join(abidata.dirpath, \"refs\", \"mp-7000_DDB.bz2\")\nddb = abilab.abiopen(filepath)\n\n# Invoke anaddb to compute phonon bands and dos.\n#dos_method = \"gaussian\"\ndos_method = \"tetra\"\nphbst_file, phdos_file = ddb.anaget_phbst_and_phdos_files(nqsmall=4, dos_method=dos_method,\n ndivsm=1, mpi_procs=2)\n\n# Extract msqd_dos\nmsqd_dos = phdos_file.msqd_dos\n#print(msqd_dos)\n\n#for fmt in (\"cartesian\", \"cif\", \"ustar\", \"beta\", \"B\"):\nfor fmt in (\"cartesian\", \"cif\"):\n df = msqd_dos.get_dataframe(temp=300, view=\"all\", fmt=fmt)\n abilab.print_dataframe(df, title=\"Format: %s\" % fmt)\n\n# Plot generalized phonon DOS for each inequivalent atom in the unit cell.\nmsqd_dos.plot()\n\n# Plot tensor(T) for each inequivalent atom.\nmsqd_dos.plot_tensor()\n\nmsqd_dos.plot_uiso()\n\n# To save the structure and the U tensor at T=300K in CIF format, use:\n#msqd_dos.write_cif_file(\"DW.cif\", temp=300)\n\n# To visualize the thermal ellipsoids with Vesta, use:\n#msqd_dos.vesta_open(temp=300)\n\n# Remember to close the files.\nphbst_file.close()\nphdos_file.close()\nddb.close()"
]
}
],
"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
}PK ɄR}
plot_qha.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Quasi-harmonic approximation\n\nThis example shows how to use the GSR.nc and PHDOS.nc files computed with different volumes\nto compute thermodynamic properties within the quasi-harmonic approximation.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.dfpt.phonons import PhononBands\nfrom abipy.dfpt.qha import QHA\n\n# We use a list of GSR.nc and PHDOS.nc files corresponding to different isotropic strains.\n# These files are shipped with AbiPy so that we don't need to run calculations from scratch.\nstrains = [-4, -2, 0, 2, 4, 6]\ndirpath = os.path.join(abidata.dirpath, \"refs\", \"si_qha\")\n\ngsr_paths = [os.path.join(dirpath, \"mp-149_{:+d}_GSR.nc\".format(s)) for s in strains]\ndos_paths = [os.path.join(dirpath, \"mp-149_{:+d}_PHDOS.nc\".format(s)) for s in strains]\n\n# Initialize QHA object from files.\n# The PHDOS.nc files can be obtained from the DDB used ddb.anaget_phbst_and_phdos_files(...)\nqha = QHA.from_files(gsr_paths, dos_paths)\n\n# To change the default EOS (vinet), use\n#qha.set_eos(\"murnaghan\")\n\nqha.plot_energies(title=\"Energies as a function of volume for different T\")\n\nqha.plot_thermal_expansion_coeff(title=\"Thermal expansion coefficient as a function of T\")\n\nqha.plot_vol_vs_t(title=\"Volume as a function of T\")\n\n# Fake temperatures to test the plotting function.\nphbs_list = [PhononBands.from_file(os.path.join(dirpath, \"mp-149_{:+d}_PHBST.nc\".format(s))) for s in\n strains[2:4]]\n\nqha.plot_phbs(phbs_list, temperatures=[10, 20], title=\"Phonon band structures with color depending on T\")\n\n# Here we build a Phonopy QHA object.\n# Cannot run this code because it breaks sphinx-gallery\n\n#qha_phonopy = qha.get_phonopy_qha(tstop=500, num=11)\n#qha_phonopy.run()\n#qha_phonopy.plot_bulk_modulus_temperature().show()"
]
}
],
"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
}PK لR//D plot_ebands_scatter3d.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# e-bands scatter3d\n\nThis example shows how to plot a particular \"band\" in 3D\nwith matplotlib scatter3D.\nThe color of the point gives the energy of the state wrt to the Fermi level.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\n# Open the GSR file and extract the band structure.\nwith abilab.abiopen(abidata.ref_file(\"ni_kpath_GSR.nc\")) as ncfile:\n ncfile.ebands.plot_scatter3d(band=9, spin=0)"
]
}
],
"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
}PK R "z z plot_gruneisen.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Gruneisen parameters\n\nThis example shows how to analyze the Gruneisen parameters\ncomputed by anaddb via finite difference.\nSee also v8/Input/t45.in\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy import abilab\n\n# Open the file with abiopen\n# Alternatively one can use the shell and `abiopen.py OUT_GRUNS.nc -nb`\n# to open the file in a jupyter notebook.\nncfile = abilab.abiopen(abidata.ref_file(\"mg2si_GRUNS.nc\"))\n\n# Plot phonon DOSes computed by anaddb.\nncfile.plot_doses(title=\"DOSes available in the GRUNS file.\")\n\n# Plot phonon bands with markers\n# sphinx_gallery_thumbnail_number = 2\nncfile.plot_phbands_with_gruns(title=\"Phonon bands with markers proportional to Gruneisen parameters + DOSes\")\n\nncfile.plot_gruns_bs(title=\"Gruneisen along high-symmetry path.\")\n\nncfile.plot_phbands_with_gruns(fill_with=\"gruns_fd\",\n title=\"Gruneisen parameters with finite differences.\", with_doses=None)\n\nncfile.plot_gruns_scatter(units='cm-1',title=\"Scatter plot with Gruneisen parameters\")\n\n# Construct plotter object to analyze multiple phonon bands.\nplotter = ncfile.get_plotter()\nplotter.combiboxplot()\n\nncfile.close()"
]
}
],
"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
}PK R plot_efatbands_lm.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# LM-fatbands\n\nThis example shows how to plot the LM-projected fatbands.\nThe FATBANDS file must have benn produced with prtdos 3 and prtdosm 1.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.abilab as abilab\nimport abipy.data as abidata\n\nfbnc_kpath = abilab.abiopen(abidata.ref_file(\"ni_kpath_FATBANDS.nc\"))\nprint(fbnc_kpath)\n\n# NC files have contributions up to L = 4 (g channel)\n# but here we are intererested in s,p,d terms only so we use the optional argument lmax\nlmax = 2\n\n# we are not interested in a small energy window around the Fermi level.\nelims = [-1.5, +1]\n\n# and a subset of bands (remember that in python we start to count from 0)\nblist = list(range(4, 10))\n\n# Plot fatbands with LM character up to lmax.\n# The grid contains (lmax + 1) columns, each column has (2l + 1) subplots\n# corresponding to the LM character for M in [-l, -l-1, ... 0, 1, +l].\nfbnc_kpath.plot_fatbands_mview(iatom=0, fact=1.5, lmax=lmax,\n ylims=elims, blist=list(range(4, 10)),\n title=\"LM fatbands for atom index 0\")\n\nfbnc_kpath.close()"
]
}
],
"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
}PK REO
} plot_edos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Electron DOS\n\nThis example shows how to compute the DOS from\nthe eigenvalues stored in the WFK file with the gaussian method.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\n# Open the wavefunction file computed with a homogeneous sampling of the BZ\n# and extract the band structure on the k-mesh.\nwith abiopen(abidata.ref_file(\"si_scf_WFK.nc\")) as gs_wfk:\n gs_ebands = gs_wfk.ebands\n\n# Compute the DOS with the Gaussian method (default)\nedos = gs_ebands.get_edos(method=\"gaussian\", step=0.01, width=0.1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot electron DOS and IDOS with matplotlib use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"edos.plot(title=\"Silicon DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"edos.plotly(title=\"Silicon DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot electron DOS and IDOS with matplotlib use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"edos.plot_dos_idos(title=\"DOS and Integrated DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"edos.plotly_dos_idos(title=\"DOS and Integrated DOS\")"
]
}
],
"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
}PK R=| plot_gw_spectral_functions.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# G0W0 spectral function\n\nThis examples shows how to plot the G0W0 spectral functions A(w) at the gamma point.\nSee also lesson tgw2_4\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\n# Open the file with the GW results\nsigres = abiopen(abidata.ref_file(\"al_g0w0_sigmaw_SIGRES.nc\"))\n\n# Plot A(w) for the first spin, the gamma point, and all bands\nsigres.plot_spectral_functions()\n\n# Only bands in [0, 1, 2]\nsigres.plot_spectral_functions(spin=0, kpoint=(0, 0, 0), include_bands=range(0, 3))\n\nsigres.close()"
]
}
],
"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
}PK R plot_eph_from_mp.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Electrons and Phonons from the materials project website\n\nThis example shows how to dowload the electronic band structure\nand the DDB file using the mp identifier and use the AbiPy API\nto generate a matplotlib grid with electrons + phonons.\n\nIMPORTANT: Electrons and Phonons have been obtained with different codes\nand different computational settings! Of course, one can always\ninitialize ElectronBands and PhononBands from local netcdf files\nobtained with Abinit\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\n\n# List of mp ids for Si, Diamond\nmpids = [\"mp-149\", \"mp-66\"]\n\n# Get list of AbiPy ebands from mpids\nebands_list = [abilab.ElectronBands.from_mpid(mpid) for mpid in mpids]\n\n# Get list of DDB files from the MP website and run anaddb to get the phonon bands.\nphbands_list = []\nfor i, mpid in enumerate(mpids):\n print(\"Downloading DDB for mpid %s (%s) ...\" % (mpid, ebands_list[i].structure.formula))\n ddb = abilab.DdbFile.from_mpid(mpid)\n if ddb is None:\n raise RuntimeError(\"%d does not provide DDB\" % mpid)\n print(\"Invoking anaddb to compute phonon bands...\")\n phbst, _ = ddb.anaget_phbst_and_phdos_files(nqsmall=0)\n phbands_list.append(phbst.phbands)\n phbst.close()\n ddb.close()\n\n# The figure has [len(mpids), 2] subplots\n# The i-th row contains electrons and phonons for the i-th mp identifier.\nnrows, ncols = len(mpids), 2\nax_mat, fig, plt = abilab.get_axarray_fig_plt(None, nrows=nrows, ncols=ncols,\n sharex=False, sharey=False, squeeze=False)\n\n# Use the `ax` keyword argument to select the matplotlib Axes used to plot the object.\n# In the band structure plot, we show the fundamental/direct gap as well as the possible\n# phonon-absorption (-emission) processes allowed by energy-conservation.\n# (This is a qualitative analysis of e-ph scattering, quasi-momentum and ph dispersion are not taken into account).\nfor i, (ebands, phbands) in enumerate(zip(ebands_list, phbands_list)):\n ebands.plot(ax=ax_mat[i, 0], with_gaps=True, ylims=(-5, 10), max_phfreq=phbands.maxfreq, show=False)\n phbands.plot(ax=ax_mat[i, 1], show=False)\n\n # Hide xlabel if not last row.\n if i != len(ebands_list) - 1:\n for ax in ax_mat[i]:\n ax.xaxis.label.set_visible(False)\n\nplt.show()"
]
}
],
"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
}PK RN N plot_phbands_nkpt_tsmear.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Multiple phonon bands with DDB robot\n\nThis example shows how to plot several phonon band structures on a grid.\n\n.. important::\n\n Note that a **manager.yml** file and an abinit installation are required\n to run this script as AbiPy needs to invoke anaddb to compute phonons from the DDB file.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We start by defining a list of DDB files:\nobtained with the same structure but different k-mesh and tmear:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\nimport os\n\npaths = [\n #\"mgb2_444k_0.01tsmear_DDB\",\n #\"mgb2_444k_0.02tsmear_DDB\",\n #\"mgb2_444k_0.04tsmear_DDB\",\n \"mgb2_888k_0.01tsmear_DDB\",\n #\"mgb2_888k_0.02tsmear_DDB\",\n \"mgb2_888k_0.04tsmear_DDB\",\n \"mgb2_121212k_0.01tsmear_DDB\",\n #\"mgb2_121212k_0.02tsmear_DDB\",\n \"mgb2_121212k_0.04tsmear_DDB\",\n]\n\npaths = [os.path.join(abidata.dirpath, \"refs\", \"mgb2_phonons_nkpt_tsmear\", f) for f in paths]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we initialize the DdbRobot from this list of paths:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"robot = abilab.DdbRobot.from_files(paths)\nprint(robot.keys())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we change the keys associated to the different files\nby defining a function that computes the new label from the\ninfo reported in the ddb object.\nThese lables are then used to generate the legend in the matplotlib plot.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"robot.remap_labels(lambda ddb: \"nkpt: %s, tsmear: %.2f\" % (ddb.header[\"nkpt\"], ddb.header[\"tsmear\"]))\nprint(robot.keys())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Invoke anaddb to build a PhononBands plotter.\nWe use a small q-mesh for the ph-DOS to speedup the computation:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r = robot.anaget_phonon_plotters(nqsmall=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To group the results by tsmear use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r.phbands_plotter.gridplot_with_hue(\"tsmear\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If Phonon DOSes are wanted, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r.phbands_plotter.gridplot_with_hue(\"tsmear\", with_dos=True)\n\n#r.phbands_plotter.gridplot()\n\nrobot.close()"
]
}
],
"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
}PK ȄRn^ plot_potentials.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Potentials\n\nThis example shows how to plot the potentials stored in netcdf files.\nUse the input variables `prtpot`, `prtvha`, `prtvhxc`, `prtvxc` with\n`iomode 3` to produce these files at the end of the SCF-GS run.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# VKS = Hartree + XC potential + sum of local part of pseudos.\nwith abiopen(abidata.ref_file(\"ni_666k_POT.nc\")) as ncfile:\n vks = ncfile.vks\n\n#vks.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{ks}(r)$\")\n\n# Hartree potential.\nwith abiopen(abidata.ref_file(\"ni_666k_VHA.nc\")) as ncfile:\n vh = ncfile.vh\n\nvh.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{hartree}(r)$\")\n\n# XC potential.\nwith abiopen(abidata.ref_file(\"ni_666k_VXC.nc\")) as ncfile:\n vxc = ncfile.vxc\n\nvxc.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{xc}(r)$\")\n\n# Hartree + XC potential.\nwith abiopen(abidata.ref_file(\"ni_666k_VHXC.nc\")) as ncfile:\n vhxc = ncfile.vhxc\n\nvhxc.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{hxc}(r)$\")\n\nvloc = vks - vhxc\nvloc.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{loc}(r)$\")\n\nfoo = vhxc - vh - vxc\n#foo.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], num=400, title=\"$V_{hxc - h - xc}(r)$\")\n\n# To plot the wavefunction along the lines connect the firt atom in the structure\n# and all the neighbors within a sphere of radius 3 Angstrom:\n#vxc.plot_line_neighbors(site_index=0, radius=3)"
]
}
],
"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
}PK R
plot_efatbands.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# MgB2 fatbands\n\nThis example shows how to plot the L-projected fatbands of MgB2\nusing the FATBANDS.nc files produced by abinit with prtdos 3.\nSee also PhysRevLett.86.4656\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.abilab as abilab\nimport abipy.data as abidata\n\n# Open the file (alternatively one can use the shell and `abiopen.py FILE -nb`\n# to open the file in a jupyter notebook\n# This file has been produced on a k-path so it's not suitable for DOS calculations.\nfbnc_kpath = abilab.abiopen(abidata.ref_file(\"mgb2_kpath_FATBANDS.nc\"))\n\n# Print file info (dimensions, variables ...)\n# Note that prtdos = 3, so LM decomposition is not available.\nprint(fbnc_kpath)\n\n\n# Plot the k-points belonging to the path.\nfbnc_kpath.ebands.kpoints.plot()\n\n# NC files have contributions up to L=4 (g channel)\n# but here we are intererested in s,p,d terms only so\n# we use the optional argument lmax\nlmax = 2\n\n# Plot the electronic fatbands grouped by atomic type.\nfbnc_kpath.plot_fatbands_typeview(lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_typeview(lmax=lmax)\n\n# Plot the electronic fatbands grouped by L.\nfbnc_kpath.plot_fatbands_lview(lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_lview(lmax=lmax)\n\n# Now we read another FATBANDS file produced on 18x18x18 k-mesh\nfbnc_kmesh = abilab.abiopen(abidata.ref_file(\"mgb2_kmesh181818_FATBANDS.nc\"))\n\nprint(fbnc_kmesh)\n#fbnc_kmesh.ebands.kpoints.plot()\n\n# Plot the L-PJDOS grouped by atomic type.\nfbnc_kmesh.plot_pjdos_typeview(lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kmesh.plotly_pjdos_typeview(lmax=lmax)\n\n# Plot the L-PJDOS grouped by L.\nfbnc_kmesh.plot_pjdos_lview(lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kmesh.plotly_pjdos_lview(lmax=lmax)\n\n# Now we use the two netcdf files to produce plots with fatbands + PJDOSEs.\n# The data for the DOS is taken from pjdosfile.\n# sphinx_gallery_thumbnail_number = 6\nfbnc_kpath.plot_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, lmax=lmax, view=\"type\", tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, lmax=lmax, view=\"type\")\n\n# fatbands + PJDOS grouped by L\nfbnc_kpath.plot_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, lmax=lmax, view=\"lview\", tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, lmax=lmax, view=\"lview\")\n\nfbnc_kpath.close()\nfbnc_kmesh.close()"
]
}
],
"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
}PK R?k plotly_phbands_and_dos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Phonon Band structures (Plotly version)\n\nThis example shows how to plot the phonon band structure of AlAs with plotly.\nSee tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the PHBST file produced by anaddb and get the phonon bands.\nwith abiopen(abidata.ref_file(\"trf2_5.out_PHBST.nc\")) as ncfile:\n phbands = ncfile.phbands\n\n# Read the Phonon DOS from the netcd file produced by anaddb (prtdos 2)\nwith abiopen(abidata.ref_file(\"trf2_5.out_PHDOS.nc\")) as ncfile:\n phdos = ncfile.phdos"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"plot phonon bands and DOS.\n`plot_phonons_lo_to.py` shows how to treat the LO-TO splitting.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plotly(title=\"AlAs Phonon bands and DOS in eV\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"plot phonon bands with DOS.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plotly_with_phdos(phdos, units=\"cm-1\", title=\"AlAs Phonon bands + DOS in cm-1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"plot phonon DOS.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos.plotly(units=\"cm-1\", title=\"Phonon DOS and IDOS in cm-1\")\n\n# Plot the phonon band structure with different color for each line.\n#phbands.plot_colored_matched(units=\"cm-1\",\n# title=\"AlAs with different color for each line.\")\n\n# sphinx_gallery_thumbnail_path = '_static/plotly_logo.png'"
]
}
],
"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
}PK R&P P plot_lobster_files.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Lobster COHP/COP/DOS\n\nThis example shows how to analyze the output files\nproduced by Lobster code <\n\nUse `abiview.py lobster DIRPATH` for a command line interface.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.abilab import LobsterAnalyzer\n\ndirpath = os.path.join(abidata.dirpath, \"refs\", \"lobster_gaas\")\n\n# Open the all the lobster files produced in directory dirpath\n# with the (optional) prefix GaAs_\nlobana = LobsterAnalyzer.from_dir(dirpath, prefix=\"GaAs_\")\nprint(lobana)\n\n# Plot COOP + COHP + DOS.\nlobana.plot(title=\"COOP + COHP + DOS\")\n\n# Plot COHP for all sites in from_site_index and Lobster DOS.\nlobana.plot_coxp_with_dos(from_site_index=[0, 1])\n\n# Plot orbital projections.\nlobana.plot_coxp_with_dos(from_site_index=[0], with_orbitals=True)\n\n#lobana.plot_with_ebands(ebands=\"out_GSR.nc\")"
]
}
],
"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
}PK Rv?
plot_ebands.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Band structure plot\n\nThis example shows how to plot a band structure\nusing the eigenvalues stored in the GSR file\nproduced at the end of the GS run.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we use one of the GSR files shipped with abipy.\nReplace filename with the path to your GSR file or your WFK file.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"filename = abidata.ref_file(\"si_nscf_GSR.nc\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Open the GSR file and extract the band structure.\n(alternatively one can use the shell and `abiopen.py OUT_GSR.nc -nb`\nto open the file in a jupyter notebook.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"with abiopen(filename) as ncfile:\n ebands = ncfile.ebands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the band energies with matplotlib.\nNote that the labels for the k-points are found automatically in an internal database.\nUse `with_gaps` to show fundamental and direct gaps.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ebands.plot(with_gaps=True, title=\"Silicon band structure\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ebands.plotly(with_gaps=True, title=\"Silicon band structure\")\n\n# .. warning:\n#\n# Note that, for the time being, ``with_gaps`` is incompatible with the ``title`` argument."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the BZ and the k-point path with matplotlib\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ebands.kpoints.plot()"
]
}
],
"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
}PK ׄR plot_fold2bloch.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Unfolding with fold2bloch\n\nThis example shows how to plot the results produced by fold2bloch.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from __future__ import division, print_function\n\nfrom abipy import abilab\nimport abipy.data as abidata\n\n\nwith abilab.abiopen(abidata.ref_file(\"h6_FOLD2BLOCH.nc\")) as ncfile:\n print(ncfile)\n # Plot folded bands\n ncfile.ebands.plot(title=\"Folded bands\")\n\n # Plot unfolded bands along the path defined by kbounds.\n kbounds = [0, 1/2, 0, 0, 0, 0, 0, 0, 1/2]\n klabels = [\"Y\", r\"$\\Gamma$\", \"X\"]\n # sphinx_gallery_thumbnail_number = 2\n ncfile.plot_unfolded(kbounds, klabels, title=\"Unfolded bands\")"
]
}
],
"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
}PK R¦ plot_kpath_from_ibz.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# K-path from IBZ\n\nThis example shows how to extract energies along a k-path\nfrom a calculation done with a (relatively dense) IBZ sampling.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the file with energies computed with a homogeneous sampling of the BZ\n# and extract the band structure object.\nwith abiopen(abidata.ref_file(\"si_scf_GSR.nc\")) as gs_file:\n ebands_ibz = gs_file.ebands\n\n# This is a GS calculation done with a 8x8x8 k-mesh.\nprint(ebands_ibz.kpoints)\n\n# Build new ebands with energies along G-X-L-G path.\n# Smooth bands require dense meshes.\nr = ebands_ibz.with_points_along_path(knames=[\"G\", \"X\", \"L\", \"G\"])\n\nprint(r.ebands)\nr.ebands.plot()"
]
}
],
"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
}PK ׄR5
plot_ebands_spin.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Spin-polarized e-bands\n\nThis example shows how to plot the band structure of nickel\nusing the eigenvalues stored in the GSR file produced at the end of the GS run.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\n# Open the GSR file and extract the band structure.\n# (alternatively one can use the shell and `abiopen.py OUT_GSR.nc -nb`\n# to open the file in a jupyter notebook.\nwith abilab.abiopen(abidata.ref_file(\"ni_666k_GSR.nc\")) as ncfile:\n ni_ebands_kmesh = ncfile.ebands\n\nwith abilab.abiopen(abidata.ref_file(\"ni_kpath_GSR.nc\")) as ncfile:\n ni_ebands_kpath = ncfile.ebands\n\n# Energy limits in eV for plots. The pseudo contains semi-core states but\n# we are not interested in this energy region. Fermi level set to zero.\nelims = [-10, 2]\n\n# Plot band energies on k-path\nni_ebands_kpath.plot(ylims=elims, title=\"Ni band structure\")\n\n# Compute DOS with Gaussian method.\nni_edos = ni_ebands_kmesh.get_edos()\n\n# Plot energies on k-path + DOS\nni_ebands_kpath.plot_with_edos(ni_edos, ylims=elims,\n title=\"Ni band structure + DOS\")\n\n# Plot electronic DOS.\n#ni_edos.plot_dos_idos(xlims=elims)\n#ni_edos.plot(xlims=elims)\n#ni_edos.plot_up_minus_down(xlims=elims)\n\n\n# Boxplot for 10 > band >= 5\nni_ebands_kpath.boxplot(brange=[5, 10],\n title=\"Boxplot for up and down spin and 10 > band >= 5\")\n\n\n# Use ElectronBandsPlotter to analyze multiple ElectronBands object\nplotter = abilab.ElectronBandsPlotter()\nplotter.add_ebands(\"k-mesh\", ni_ebands_kmesh)\nplotter.add_ebands(\"k-path\", ni_ebands_kpath)\n\nylims = [-10, 5]\n#plotter.combiplot(ylims=ylims)\nplotter.gridplot(ylims=ylims)\n#plotter.boxplot(brange=[5, 10])\nplotter.combiboxplot(brange=[5, 10])"
]
}
],
"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
}PK ׄR1C plot_phthermo.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Thermodinamic properties\n\nThis example shows how to compute and plot thermodinamic properties within\nthe harmonic approximation using the phonon DOS produced by anaddb.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Read the Phonon DOS from the netcd file produced by anaddb (prtdos 2)\nncfile = abiopen(abidata.ref_file(\"trf2_5.out_PHDOS.nc\"))\nphdos = ncfile.phdos\n\n# Print crystalline structure and zero-point energy.\nprint(ncfile.structure)\nzpe = phdos.zero_point_energy\nprint(\"Zero point energy:\", zpe, zpe.to(\"J\"), zpe.to(\"Ha\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute free energy from 2 to 300 K (20 points)\nBy default, energies are is eV and thermodynamic quantities are given\non a per-unit-cell basis.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"f = phdos.get_free_energy(tstart=2, tstop=300, num=20)\n#f.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot U, F, S, Cv as a function of T.\nUse J/mol units, results are divided by formula_units.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos.plot_harmonic_thermo(units=\"Jmol\", formula_units=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plotly version:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos.plotly_harmonic_thermo(units=\"Jmol\", formula_units=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remember to close the file:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ncfile.close()"
]
}
],
"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
}PK RBf7 plot_wannier90_abiwan.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Band structure interpolation with Wannier functions\n\nThis example shows how to analyze the wannier90 results using\nthe ABIWAN.nc netcdf file produced by Abinit when calling wannier90 in library mode.\nUse `abiopen FILE.wout` for a command line interface and\nthe `--expose` option to generate matplotlib figures automatically.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.abilab import abiopen\n\n# Open the ABIWAN file\nfilepath = os.path.join(abidata.dirpath, \"refs\", \"wannier90\", \"tutoplugs_tw90_4\", \"tw90_4o_DS3_ABIWAN.nc\")\nabiwan = abiopen(filepath)\nprint(abiwan)\n\n# Plot the matrix elements of the KS Hamiltonian in real space in the Wannier Gauge.\nabiwan.hwan.plot(title=\"Matrix elements in real space\")\n\n# Interpolate bands with Wannier functions using an automatically selected k-path\n# with 5 points for the smallest segment.\nebands_wan_kpath = abiwan.interpolate_ebands(line_density=5)\nebands_wan_kpath.plot(title=\"Wannier-interpolated\")\n\n# Interpolate bands in the IBZ defined by ngkpt\nebands_wan_kmesh = abiwan.interpolate_ebands(ngkpt=[8, 8, 8])\nedos = ebands_wan_kmesh.get_edos()\nebands_wan_kpath.plot_with_edos(edos, title=\"Wannier-interpolated bands and DOS\")\n\n# To compare the interpolated bands with ab-initio results,\n# pass a file with the ab-initio bands to the get_plotter_from_ebands method\n# that will return an ElectronBandsPlotter object.\n\n#plotter = abiwan.get_plotter_from_ebands(\"out_GSR.nc\")\n#plotter.combiplot()"
]
}
],
"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
}PK ܄R plot_efatbands_spin.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# spin-polarized fatbands\n\nThis example shows how to plot the L-projected fatbands of Ni\nusing the results stored in the FATBANDS.nc files produced with prtdos 3.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.abilab as abilab\nimport abipy.data as abidata\n\n# Open the file (alternatively one can use the shell and `abiopen.py FILE -nb`\n# to open the file in a jupyter notebook\n# This file has been produced on a k-path so it's not suitable for DOS calculations.\nfbnc_kpath = abilab.abiopen(abidata.ref_file(\"ni_kpath_FATBANDS.nc\"))\n\n# NC files have contributions up to L = 4 (g channel)\n# but here we are intererested in s,p,d terms only so we use the optional argument lmax\nlmax = 2\n\n# Energy limits in eV for plots. The pseudo contains semi-core states but\n# we are not interested in this energy region. Fermi level set to zero.\nelims = [-10, 2]\n\n# Print file info (dimensions, variables ...)\n# Note that prtdos = 3, so LM decomposition is not available.\nprint(fbnc_kpath)\n\n# Plot the k-points belonging to the path.\n#fbnc_kpath.ebands.kpoints.plot()\n\n# Plot the electronic fatbands grouped by atomic type.\nfbnc_kpath.plot_fatbands_typeview(ylims=elims, lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_typeview(ylims=elims, lmax=lmax)\n\n# Plot the electronic fatbands grouped by L.\nfbnc_kpath.plot_fatbands_lview(ylims=elims, lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_lview(ylims=elims, lmax=lmax)\n\n# Now we read another FATBANDS file produced on 18x18x18 k-mesh\nfbnc_kmesh = abilab.abiopen(abidata.ref_file(\"ni_666k_FATBANDS.nc\"))\n\n# Plot the L-PJDOS grouped by atomic type.\nfbnc_kmesh.plot_pjdos_typeview(xlims=elims, lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kmesh.plotly_pjdos_typeview(xlims=elims, lmax=lmax)\n\n# Plot the L-PJDOS grouped by L.\nfbnc_kmesh.plot_pjdos_lview(xlims=elims, lmax=lmax, tight_layout=True)\n\n# For the plotly version use:\nfbnc_kmesh.plotly_pjdos_lview(xlims=elims, lmax=lmax)\n\n# Now we use the two netcdf files to produce plots with fatbands + PJDOSEs.\n# The data for the DOS is taken from pjdosfile.\nfbnc_kpath.plot_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, ylims=elims, lmax=lmax, view=\"type\", tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, ylims=elims, lmax=lmax, view=\"type\")\n\n# fatbands + PJDOS grouped by L\nfbnc_kpath.plot_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, ylims=elims, lmax=lmax, view=\"lview\", tight_layout=True)\n\n# For the plotly version use:\nfbnc_kpath.plotly_fatbands_with_pjdos(pjdosfile=fbnc_kmesh, ylims=elims, lmax=lmax, view=\"lview\")\n\n# Close files.\nfbnc_kpath.close()\nfbnc_kmesh.close()"
]
}
],
"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
}PK Revv v plot_ebands_grid.ipynb{
"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
}PK RfW plot_scr.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Dielectric function with LFE\n\nThis examples shows how to plot the macroscopic dielectric function\ncomputed in the GW code (optdriver 3)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\nwith abiopen(abidata.ref_file(\"sio2_SCR.nc\")) as ncfile:\n # The SCR file contains a structure and electron bands in the IBZ.\n # We can thus use the ebands object to plot bands + DOS.\n print(ncfile)\n\n edos = ncfile.ebands.get_edos()\n ncfile.ebands.plot_with_edos(edos, title=\"KS energies used to compute the SCR file.\")\n\n # sphinx_gallery_thumbnail_number = 2\n ncfile.plot_emacro(title=\"Macroscopic dielectric function of $SiO_2$ with local-field effects.\")\n\n ncfile.plot_eelf(title=\"Electron Energy Loss Function of $SiO_2$\")"
]
}
],
"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
}PK Rm%Wq
plot_qpconvergence.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# GW Convergence\n\nThis example shows how to use the SigresRobot to visualize the convergence of the\nQP results stored in the SIGRES.nc files produced by the GW code (sigma run).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import SigresRobot\nimport abipy.data as abidata\n\n# List of SIGRES files computed with different values of nband.\nfilenames = [\n \"si_g0w0ppm_nband10_SIGRES.nc\",\n \"si_g0w0ppm_nband20_SIGRES.nc\",\n \"si_g0w0ppm_nband30_SIGRES.nc\",\n]\n\nfilepaths = [abidata.ref_file(fname) for fname in filenames]\n\n# Build robot from list of file paths\nrobot = SigresRobot.from_files(filepaths)\n#robot.remap_labels(lambda sigres: sigres.params[\"sigma_nband\"])\n\n# Plot the convergence of the QP gaps.\nrobot.plot_qpgaps_convergence(sortby=\"sigma_nband\", title=\"QP gaps vs sigma_nband\")\n\n# Plot the convergence of the QP energies.\nrobot.plot_qpdata_conv_skb(spin=0, kpoint=[0, 0, 0], band=3, sortby=\"sigma_nband\")\n\n# sphinx_gallery_thumbnail_number = 3\nrobot.plot_qpfield_vs_e0(\"qpeme0\", sortby=\"sigma_nband\", title=\"QP energies vs sigma_nband\")"
]
}
],
"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
}PK RS" plot_gscycle.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Ground-state SCF cycle\n\nThis example shows how to plot the results of the\nGS self-consistent cycle reported in the main output file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the output file with GS calculation (Note the .abo extension).\n# Alternatively, one can use `abiopen.py run.abo -nb`\n# to generate a jupyter notebook.\nabo = abiopen(abidata.ref_file(\"refs/si_ebands/run.abo\"))\n\n# Plot all SCF-GS sections found in the output file.\n# Use abo.next_d2de_scf_cycle() for DFPT cycles.\nscf_cycle = abo.next_gs_scf_cycle()\nif scf_cycle is not None:\n scf_cycle.plot()\n\n# If timopt -1, we can extract the timing and plot the data.\ntimer = abo.get_timer()\ntimer.plot_pie()\n\nabo.close()"
]
}
],
"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
}PK لRQ* plot_xrd.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# X-ray diffraction pattern\n\nThis example shows how to plot the X-ray diffraction pattern with pymatgen\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\n# Extract the structure (supports multiple formats e.g netcdf, Abinit input, cif, POSCAR)\n# Also available via the `abistruct.py xrd FILE` command line interface.\nstructure = abilab.Structure.from_file(abidata.ref_file(\"si_scf_WFK.nc\"))\n\nimport sys\nif sys.version[0:3] > '2.7':\n # pmg broke py compatibility\n structure.plot_xrd()"
]
}
],
"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
}PK DŽRrI plot_ddb_asr.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Phonon bands with/without the ASR\n\nThis example shows how to plot a phonon band structure\nwith and without enforcing the acoustic sum rule (ASR).\nBoth matplotlib and plotly are supported.\n\n.. important::\n\n Note that a **manager.yml** configuration file and an abinit installation are required\n to run this script as AbiPy needs to invoke anaddb to compute phonons from the DDB file.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Open the DDB file with:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\nfilepath = abidata.ref_file(\"mp-1009129-9x9x10q_ebecs_DDB\")\nddb = abilab.abiopen(filepath)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``ddb.anacompare_asr`` method computes the phonon bands and the DOS by calling anaddb\nwith different values of asr and returns a PhononBandsPlotter object:\nTo make the computation faster, we use the **advanced** options dipdip -1.\nThis option should produce results similar to dipdip 1 yet make sure to test\nthe effect of this variable before using it in production.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter = ddb.anacompare_asr(asr_list=(0, 2), dipdip=-1)\nprint(plotter)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the bands on the same figure with matplotlib, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.combiplot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.combiplotly()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To disable the DOS computation, set ``nqsmall` to 0:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter = ddb.anacompare_asr(asr_list=(0, 2), nqsmall=0, ndivsm=10, dipdip=-1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the bands on different subplots with matplotlib, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.gridplot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.gridplotly()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, remember to close the file with:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ddb.close()"
]
}
],
"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
}PK R!z@ plot_fermisurface.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# MgB2 Fermi surface\n\nThis example shows how to plot the Fermi surface with matplotlib\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\nwith abilab.abiopen(abidata.ref_file(\"mgb2_kmesh181818_FATBANDS.nc\")) as fbnc_kmesh:\n ebands = fbnc_kmesh.ebands\n\n# Build ebands in full BZ.\neb3d = ebands.get_ebands3d()\n\n# Use matplotlib to plot isosurfaces corresponding to the Fermi level (default)\n# Warning: requires skimage package, rendering could be slow.\neb3d.plot_isosurfaces()\n\n# Alternatively, it's possible to export the data in xcrysden format\n# and then use `xcrysden --bxsf mgb2.bxsf`\n#eb3d.to_bxsf(\"mgb2.bxsf\")\n\n# If you have mayavi installed, try:\n#eb3d.mvplot_isosurfaces()"
]
}
],
"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
}PK R( plot_phbands_and_dos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Phonon band structures with LO-TO\n\nThis example shows how to plot the phonon band structure of AlAs.\nwithout the LO-TO splitting.\nSee tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Open the PHBST file produced by anaddb and get the phonon bands.\nNote that the treatment of the LO-TO splitting for q--> 0 requires\nadditional steps. See `plot_phonons_lo_to.py`.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\nwith abiopen(abidata.ref_file(\"trf2_5.out_PHBST.nc\")) as ncfile:\n phbands = ncfile.phbands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Read the Phonon DOS from the netcd file produced by anaddb (prtdos 2)\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"with abiopen(abidata.ref_file(\"trf2_5.out_PHDOS.nc\")) as ncfile:\n phdos = ncfile.phdos"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot phonon bands and DOS with matplotib:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plot(title=\"AlAs Phonon bands and DOS in eV\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plotly(title=\"AlAs Phonon bands and DOS in eV\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot phonon bands and phonon DOS with matplotlib use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plot_with_phdos(phdos, units=\"cm-1\",\n title=\"AlAs Phonon bands + DOS in cm-1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plotly_with_phdos(phdos, units=\"cm-1\",\n title=\"AlAs Phonon bands + DOS in cm-1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the phonon band structure with different color for each line (matplotlib version).\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plot_colored_matched(units=\"cm-1\",\n title=\"AlAs with different color for each line.\")"
]
}
],
"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
}PK لRtP plot_scqpgw.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# self-consistent GW\n\nThis example shows how to visualize the SCGW QP amplitudes in the KS basis set.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\nsigres = abiopen(abidata.ref_file(\"QPSC_SIGRES.nc\"))\n\n#print(\"calctyp\",sigres.gwcalctyp)\n#sigres.print_qps()\n\n#qp = sigres.get_qpcorr(spin=0, kpoint=(0,0,0), band=0)\n#print(qp)\n\n# Visualize matrix at the Gamma point\nsigres.plot_eigvec_qp(kpoint=[0, 0, 0])\n\n# Plot components for all k-points in the SIGRES.\nsigres.plot_eigvec_qp()"
]
}
],
"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
}PK ԄR=I plot_scr_matrix.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# SCR matrix\n\nThis examples shows how to plot the matrix elements of the\ninverse dielectric function stored in the SCR file (optdriver 3)\nSee also `plot_scr.py` for the optical spectrum.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\nwith abiopen(abidata.ref_file(\"sio2_SCR.nc\")) as ncfile:\n #print(ncfile)\n # The SCR file contains a structure and electron bands in the IBZ.\n # We can thus use the ebands object to plot bands + DOS.\n #ncfile.ebands.plot()\n\n # Read e^{-1}_{G1, G2}(k, omega)\n\n kpoint = [0.5, 0, 0]\n em1 = ncfile.reader.read_wggmat(kpoint)\n print(em1)\n\n gvec1 = [1, 0, 0]\n gvec2 = [-1, 0, 0]\n\n # Plot matrix element as function of frequency along the real axis\n em1.plot_freq(gvec1=gvec1, gvec2=gvec2, waxis=\"real\")\n\n # Plot data along the imaginary axis\n # Note that gvectors can also be specifined in terms of their index.\n em1.plot_freq(gvec1=0, gvec2=0, waxis=\"imag\")\n\n # Plot e^{-1}_{G1, G2} along the imaginary axis.\n em1.plot_gg(wpos=\"imag\")"
]
}
],
"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
}PK ׄR
g{ plot_hist.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Structural relaxation\n\nThis example shows how to analyze the results of a\nstructure relaxation run using the HIST.nc file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the HIST file.\n# (alternatively one can use the shell and `abiopen.py OUT_HIST.nc -nb`\n# to open the file in jupyter notebook.\nhist = abiopen(abidata.ref_file(\"sic_relax_HIST.nc\"))\n\n# The structure at the end of the structural relaxation.\nprint(hist.final_structure)\n\n# Plot the evolution of the lattice parameters, forces, etotal, ...\nhist.plot(tight_layout=True)\n\n# For the plotly version use:\nhist.plotly()\n\n# Plot the total energy at the different relaxation steps.\nhist.plot_energies(tight_layout=True)\n\nhist.close()"
]
}
],
"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
}PK R9Zd0 0 plot_multiple_mdf.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Multiple Bethe-Salpeter calculations\n\nThis example shows how to analyze multiple MDF files.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy import abilab\n\n# Read data from multiple files.\nmdf_paths = abidata.ref_files(\"si_444_MDF.nc\", \"si_666_MDF.nc\", \"si_888_MDF.nc\")\nrobot = abilab.MdfRobot.from_files(mdf_paths)\n\n# Build MultipleMdfPlotter\nplotter = robot.get_multimdf_plotter()\n\n# Plot the dielectric function with excitonic effects.\nplotter.plot(mdf_type=\"exc\", qview=\"avg\",\n title=\"Real and Imaginary part (averaged over q-points)\", tight_layout=True)\n\n# Plot the dielectric function computed at the RPA level with KS energies.\n# Show q-point dependence.\nplotter.plot(mdf_type=\"rpa\", qview=\"all\",\n title=\"Real and Imaginary part for individual q-points\", tight_layout=True)\n\nrobot.close()"
]
}
],
"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
}PK R4Ś plot_optic.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Optic results\n\nThis example shows how to plot the optical properties\ncomputed by optic within the independent-particle approximation,\nno local-field effects and no excitonic effects.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\n# Here we use one of the OPTIC.nc files shipped with abipy.\n# Replace filename with the path to your OPTIC.nc file.\nfilename = abidata.ref_file(\"gaas_121212_OPTIC.nc\")\n\nncfile = abilab.abiopen(filename)\n\n# Optic files have a Structure and an ElectronBands object.\n#ncfile.ebands.plot()\n\n# To plot linear dielectric tensor and other optical\n# properties for all tensor components available in the file:\nncfile.plot_linopt(title=\"Linear dielectric function\")\n\n# To plot the second Harmonic tensor\nncfile.plot_shg(title=\"Second Harmonic Generation\")\n\n# Remember to close the file.\nncfile.close()\n\n# Use OpticRobot to analyze multiple file e.g. convergence studies.\nfilenames = [\n abidata.ref_file(\"gaas_444_OPTIC.nc\"),\n abidata.ref_file(\"gaas_888_OPTIC.nc\"),\n abidata.ref_file(\"gaas_121212_OPTIC.nc\"),\n]\n\nrobot = abilab.OpticRobot.from_files(filenames)\n\n# sphinx_gallery_thumbnail_number = 3\nrobot.plot_linopt_convergence(title=r\"Convergence of $\\epsilon$ wrt nkpt\")\n\nrobot.plot_shg_convergence(title=r\"Convergence of $\\chi^2(-2\\omega,\\omega,\\omega)$ wrt nkpt\")\n\n# Remember to close the file or use the `with` context manager.\nrobot.close()"
]
}
],
"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
}PK ՄRK plot_ebands_boxplot.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Seaborn boxplot\n\nThis example shows how to use seaborn to draw a box plot\nshowing the distributions of eigenvalues with respect to the band index.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the file with energies computed with a homogeneous sampling\n# of the BZ and extract the band structure.\nwith abiopen(abidata.ref_file(\"si_scf_GSR.nc\")) as gsr:\n ebands = gsr.ebands"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n# Use `swarm=True` to show the datapoints on top of the boxes\nebands.boxplot(swarm=True)\nplt.show()"
]
}
],
"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
}PK R&m m plot_ejdos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Joint Density of States\n\nThis example shows how plot the different contributions\nto the electronic joint density of states of Silicon\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\n# Extract the bands computed with the SCF cycle on a Monkhorst-Pack mesh.\nwith abiopen(abidata.ref_file(\"si_scf_WFK.nc\")) as wfk_file:\n ebands = wfk_file.ebands\n\n# Select the valence and conduction bands to include in the JDOS\n# Here we include valence bands from 0 to 3 and the first conduction band (4).\nvrange = range(0, 4)\ncrange = range(4, 5)\n\n# Plot joint-DOS.\nebands.plot_ejdosvc(vrange, crange)\n\n# Plot decomposition of joint-DOS in terms of v --> c transitions\nebands.plot_ejdosvc(vrange, crange, cumulative=False)\n\n# Show optical (vertical) transitions of energy 2.8 eV\nwith abiopen(abidata.ref_file(\"si_nscf_GSR.nc\")) as gsr_file:\n gsr_file.ebands.plot_transitions(2.8)"
]
}
],
"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
}PK RHwP P plot_den.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Density\n\nThis example shows how to analyze the electronic density\nstored in the DEN.nc file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the DEN.nc file\nncfile = abiopen(abidata.ref_file(\"si_DEN.nc\"))\n\n# The DEN file has a `Density`, a `Structure` and an `ElectronBands` object\nprint(ncfile.structure)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the KS eigenvalues.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ncfile.ebands.plot()\n\ndensity = ncfile.density\nprint(density)\n\n# To visualize the total charge wih vesta\n#visu = density.visualize(\"vesta\"); visu()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the density along the line connecting\nthe first and the second in the structure:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"density.plot_line(point1=0, point2=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"alternatively, one can define the line in terms of two points\nin fractional coordinates:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"density.plot_line(point1=[0, 0, 0], point2=[2.25, 2.25, 2.25], num=300)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the density along the lines connect the firt atom in the structure\nand all the neighbors within a sphere of radius 3 Angstrom:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"density.plot_line_neighbors(site_index=0, radius=3)"
]
}
],
"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
}PK Rd6I I plot_phbands_grid.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Multiple phonon bands\n\nThis example shows how to plot several phonon band structures on a grid.\n\nWe use two files produced by anaddb:\n\n trf2_5.out_PHBST.nc: phonon frequencies on a q-path in the BZ (used to plot the band dispersion)\n trf2_5.out_PHDOS.nc: phonon DOS compute with anaddb.\n\nSee also tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We start by defining a list with the paths to the PHBST.nc files\nIn this case, for simplicity, we use the same file but we must\nuse different labels when adding them to the plotter with the add_phbands method.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\nphbst_paths = 2 * [abidata.ref_file(\"trf2_5.out_PHBST.nc\")]\n\nplotter = abilab.PhononBandsPlotter()\nplotter.add_phbands(\"AlAs\", phbst_paths[0])\nplotter.add_phbands(\"Same AlAs\", phbst_paths[1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At this point, we can use the plotter methods to plot the data:\nTo produce a grid plot:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.gridplot(units=\"eV\", title=\"GridPlot in eV\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At this point, we can use the plotter methods to plot the data:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"plotter.boxplot(units=\"cm-1\", title=\"BoxPlot in cm-1\")\n\nplotter.combiboxplot(units=\"Ha\", title=\"CombiboxPlot in Ha\")\n\n#plotter.combiplot(title=\"CombiPlot in eV\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot a grid with band structures + DOS, use the optional argument `phdos` of add_phbands\nThe first subplot gets the band dispersion from phbst_paths[0] and the dos from phdos_paths[0]\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbst_paths = 3 * [abidata.ref_file(\"trf2_5.out_PHBST.nc\")]\nphdos_paths = 3 * [abidata.ref_file(\"trf2_5.out_PHDOS.nc\")]\n\nplotter = abilab.PhononBandsPlotter()\nplotter.add_phbands(\"AlAs phbands + DOS\", phbst_paths[0], phdos=phdos_paths[0])\nplotter.add_phbands(\"Same-data\", phbst_paths[1], phdos=phdos_paths[1])\nplotter.add_phbands(\"Same-data2\", phbst_paths[2], phdos=phdos_paths[2])\n\nplotter.gridplot(units=\"cm-1\", tight_layout=True, title=\"Bands + DOS in cm-1 with gridplot\")\n\n#plotter.combiplot(title=\"Bands + DOS in eV with combiplot\")"
]
}
],
"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
}PK ԄR : : plot_qps.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# SIGRES file (GW)\n\nThis example shows how to visualize the QP results\nstored in the SIGRES produced by the GW code (sigma run)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\nsigres = abiopen(abidata.ref_file(\"tgw1_9o_DS4_SIGRES.nc\"))\n\n# Printout of the QPState results\n#sigres.print_qps()\n\nsigres.plot_qps_vs_e0(tight_layout=True, title=\"QP data vs KS energy\")\n\nsigres.plot_qpgaps(title=\"QP direct gaps\")\n\nsigres.plot_qpgaps(plot_qpmks=True, title=\"QP - KS direct gap\")\n\nsigres.plot_qpbands_ibz()\n\nsigres.plot_ksbands_with_qpmarkers(fact=1000)\n\nsigres.close()"
]
}
],
"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
}PK ȄR plot_phonon_fatbands.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Phonon fatbands\n\nThis example shows how to plot the phonon fatbands of AlAs.\nSee tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the PHBST file produced by anaddb and get the phonon bands.\nwith abiopen(abidata.ref_file(\"trf2_5.out_PHBST.nc\")) as ncfile:\n phbands = ncfile.phbands\n\n# Plot the phonon band structure with matplotlib.\nphbands.plot_fatbands(title=\"AlAs phonon fatbands without LO-TO splitting\")\n\n# For the plotly version, use:\nphbands.plotly_fatbands(title=\"AlAs phonon fatbands without LO-TO splitting\")\n\n# Provide the PHDOS file path produced by anaddb.\n# sphinx_gallery_thumbnail_number = 2\nphdos_path = abidata.ref_file(\"trf2_5.out_PHDOS.nc\")\n\n# Plot the phonon band structure + PJDOS with matplotlib.\nphbands.plot_fatbands(units=\"Thz\", phdos_file=phdos_path, title=\"AlAs phonon fatbands with PJDOS\")\n\n# For the plotly version, use:\nphbands.plotly_fatbands(units=\"Thz\", phdos_file=phdos_path, title=\"AlAs phonon fatbands with PJDOS\")\n\n# Plot contributions to the phonon displacement at the Gamma point grouped by atom type.\nphbands.plot_phdispl(qpoint=(0, 0, 0), units=\"meV\", title=r\"phonon displacements at $\\Gamma$\")\n\n# Plot (orthonormal) eigenvectors instead of displacements.\nphbands.plot_phdispl(qpoint=(0, 0, 0), use_eigvec=True, units=\"meV\", title=r\"phonon eigenvectors at $\\Gamma$\")\n\n# Decompose contributions along the three Cartesian directions.\nphbands.plot_phdispl_cartdirs(qpoint=(0, 0, 0), units=\"cm-1\")"
]
}
],
"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
}PK RQc c % plot_qpbands_with_interpolation.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# GW corrections\n\nThis example shows how to interpolate the GW corrections and use the interpolated\nvalues to correct the KS band structure computed on a high symmetry k-path and\nthe KS energies of a k-mesh. Finally, the KS and the GW results are plotted with matplotlib.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen, ElectronBandsPlotter\n\n# Get quasiparticle results from the SIGRES.nc database.\nsigres = abiopen(abidata.ref_file(\"si_g0w0ppm_nband30_SIGRES.nc\"))\n\n# Read the KS band energies computed on the k-path\nwith abiopen(abidata.ref_file(\"si_nscf_GSR.nc\")) as gsr_nscf:\n ks_ebands_kpath = gsr_nscf.ebands\n\n# Read the KS band energies computed on the Monkhorst-Pack (MP) mesh\n# and compute the DOS with the Gaussian method\nwith abiopen(abidata.ref_file(\"si_scf_GSR.nc\")) as gsr_scf:\n ks_ebands_kmesh = gsr_scf.ebands\n\nks_edos = ks_ebands_kmesh.get_edos()\n\n# Interpolate the QP corrections and use the interpolated values to correct\n# the KS energies stored in `ks_ebands_kpath` and `ks_ebands_kmesh`.\n#\n# The QP energies are returned in r.qp_ebands_kpath and r.qp_ebands_kmesh.\n# Note that the KS energies are optional but this is the recommended approach\n# because the code will interpolate the corrections instead of the QP energies.\n\nr = sigres.interpolate(lpratio=5,\n ks_ebands_kpath=ks_ebands_kpath,\n ks_ebands_kmesh=ks_ebands_kmesh\n )\nqp_edos = r.qp_ebands_kmesh.get_edos()\n\n# Get points with ab-initio QP energies from the SIGRES so that\n# we can plot the interpolate interpolated QP band structure with the first principles results.\n# This part is optional\npoints = sigres.get_points_from_ebands(r.qp_ebands_kpath, size=24)\nr.qp_ebands_kpath.plot(points=points, with_gaps=True)\n#raise ValueError()\n\n# Shortcut: pass the name of the GSR files directly.\n#r = sigres.interpolate(ks_ebands_kpath=abidata.ref_file(\"si_nscf_GSR.nc\"),\n# ks_ebands_kmesh=abidata.ref_file(\"si_scf_GSR.nc\"))\n#ks_edos = r.ks_ebands_kmesh.get_edos()\n#qp_edos = r.qp_ebands_kmesh.get_edos()\n\n# Use ElectronBandsPlotter to plot the KS and the QP band structure with matplotlib.\nplotter = ElectronBandsPlotter()\nplotter.add_ebands(\"LDA\", ks_ebands_kpath, edos=ks_edos)\nplotter.add_ebands(\"GW (interpolated)\", r.qp_ebands_kpath, edos=qp_edos)\n\n# Get pandas dataframe with band structure parameters.\n#df = plotter.get_ebands_frame()\n#print(df)\n\n# By default, the two band energies are shifted wrt to *their* fermi level.\n# Use e=0 if you don't want to shift the eigenvalus\n# so that it's possible to visualize the QP corrections.\nplotter.combiplot(title=\"Combiplot\")\nplotter.boxplot(swarm=True, title=\"Boxplot\")\nplotter.combiboxplot(swarm=True, title=\"Combiboxplot\")\n# sphinx_gallery_thumbnail_number = 4\nplotter.gridplot(title=\"Gridplot\", with_gaps=True)\n\nsigres.close()"
]
}
],
"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
}PK Ru&' ' plot_a2f.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Eliashberg function\n\nThis example shows how to plot the Eliashberg function a2F(w)\nand the total e-ph coupling strenght in metals.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\nphdos_path = abidata.ref_file(\"al_161616q_PHDOS.nc\")\n\nncfile = abilab.abiopen(abidata.ref_file(\"al_888k_161616q_A2F.nc\"))\nprint(ncfile)\n\n#ncfile.phbands.plot()\n#ncfile.a2f_qintp.plot()\n#with_lambda = False\n#fig = ncfile.a2f_qcoarse.plot_nuterms(with_lambda=with_lambda, show=False)\n#ncfile.a2f_qintp.plot_nuterms(axmat=fig.axes, with_lambda=with_lambda)\n\n#ncfile.plot()\nncfile.plot_with_a2f(phdos=phdos_path)\n\nncfile.plot_eph_strength(what=\"gamma\")\n#ncfile.plot_eph_strength(what=\"lambda\")\n\nncfile.plot_a2f_interpol()\n\n# Grid with 3 plots (a2F, F, a2F) with F taken from PHDOS file.\n#ncfile.a2f_qintp.plot_a2(phdos_path)"
]
}
],
"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
}PK R[ plot_wannier90_wout.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Wannier90 wout file\n\nThis example shows how to plot the convergence\nof the wannierization cycle using the .wout file produced by wannier90.\nUse `abiopen FILE.wout` for a command line interface and\nthe `--expose` option to generate matplotlib figures automatically.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.abilab import abiopen\n\n# Open the wout file\nfilepath = os.path.join(abidata.dirpath, \"refs\", \"wannier90\", \"example01_gaas.wout\")\nwout = abiopen(filepath)\nprint(wout)\n\n# Plot the convergence of the Wannierise cycle.\nwout.plot(title=\"Wannierise cycle\")\n\n# Plot the convergence of the Wannier centers and spread\n# as function of iteration number\nwout.plot_centers_spread(title=\"MLWF centeres and spread\")"
]
}
],
"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
}PK Ro̙
plot_bz.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Brillouin zone\n\nThis example shows how to display the Brillouin zone\nwith pymatgen and matplotlib.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the WKF file.\nwfk_file = abiopen(abidata.ref_file(\"si_scf_WFK.nc\"))\n\n# Extract the crystalline structure.\nstructure = wfk_file.structure"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To visualize the BZ with matplotlib, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"structure.plot_bz()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remember to close the wfk file with:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"wfk_file.close()"
]
}
],
"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
}PK RxL plot_funcs.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Function1D object\n\nThis example shows how to use the Function1D object to analyze and plot results.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\nimport matplotlib.pyplot as plt\n\nfrom abipy.abilab import Function1D\n\n# Build mesh [0, 2pi] with 100 points.\nmesh = np.linspace(0, 2*np.pi, num=100)\n\n# Compute sine function.\nsine = Function1D.from_func(np.sin, mesh)\n\n# Call matplotlib to plot data.\nfig = plt.figure()\nax = fig.add_subplot(1, 1, 1)\n\n# Plot sine.\nsine.plot_ax(ax, label=\"sin(x)\")\n\n# Spline sine on the coarse mesh sx, and plot the data.\nsx = np.linspace(0, 2*np.pi, num=25)\nsplsine = sine.spline(sx)\n\nplt.plot(sx, splsine, \"ro\", label=\"splined sine\")\n\n# Compute the 1-st and 2-nd order derivatives\n# with finite differences (5-point stencil).\nfor order in [1,2]:\n der = sine.finite_diff(order=order)\n der.plot_ax(ax, label=\"D sin(x) %d\" % order)\n\n# Integrate the sine function and plot the results.\n(1 - sine.integral()).plot_ax(ax, marker=\".\", label=r\"$1 - \\int\\,\\sin(x)\\,dx$\")\n\nplt.legend(loc=\"best\")\nplt.show()"
]
}
],
"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
}PK R" plot_dfpt_cycle.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# DFPT SCF cycle\n\nThis example shows how to plot the results of the DFPT\nself-consistent cycle reported in the main output file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the output file with DFPT calculations (Note the .abo extension).\n# Alternatively, one can use `abiopen.py run.abo -nb` to generate a jupyter notebook.\nabo = abiopen(abidata.ref_file(\"refs/gs_dfpt.abo\"))\n\n# Plot all SCF-GS sections found in the output file.\nwhile True:\n dfpt_cycle = abo.next_d2de_scf_cycle()\n if dfpt_cycle is None: break\n dfpt_cycle.plot()\n\n\n# If timopt -1, we can extract the timing and plot the data.\n#timer = abo.get_timer()\n#timer.plot_pie()\n\nabo.close()"
]
}
],
"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
}PK R_> > plot_mdf.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Bethe-Salpeter\n\nThis example shows how to plot the macroscopic dielectric function (MDF)\ncomputed in the Bethe-Salpeter code.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen\n\n# Open the MDF file produced in the tutorial.\nmdf_file = abiopen(abidata.ref_file(\"tbs_4o_DS2_MDF.nc\"))\n\n# Plot the imaginary part of the macroscopic\n# dielectric function (EXC, RPA, GWRPA) between 2 and 5 eV.\nxlims = (2, 5)\n\nmdf_file.plot_mdfs(xlims=xlims,\n title=\"Si absorption spectrum: EXC vs RPA (averaged over small q-points)\")\n\n# Plot the real part for the first q-point --> 0\nmdf_file.plot_mdfs(cplx_mode=\"Re\", qpoint=0, xlims=xlims,\n title=\"Real part for the first q-point: EXC vs RPA\")\n\n# Plot the 6 different components of the macroscopic dielectric tensor\ntensor_exc = mdf_file.get_tensor(\"exc\")\ntensor_exc.symmetrize(mdf_file.structure)\ntensor_exc.plot(title=\"Si macroscopic dielectric tensor (Reduced coord)\")\n\ntensor_exc.plot(red_coords=False,\n title=\"Si macroscopic dielectric tensor (Cartesian coord)\")\n\nmdf_file.close()"
]
}
],
"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
}PK ÄR#Xw w plot_phonons_lo_to.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Phonon bands with LO-TO from PHBST.nc\n\nThis example shows how to plot the phonon band structure of AlAs\nincluding the LO-TO splitting.\nThese resultas tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Open PHBST file produced by anaddb and extract the phonon bands object.\n(alternatively one can use the shell and `abiopen.py OUT_PHBST.nc -nb`\nto open the file in a jupyter notebook.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\nwith abiopen(abidata.ref_file(\"ZnSe_hex_886.out_PHBST.nc\")) as ncfile:\n phbands = ncfile.phbands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Phonon frequencies with non analytical contributions, if calculated, are saved\nin the anaddb.nc file produced by anaddb. The results should be fetched from there\nand added to the phonon bands.\nNotice that all the directions starting from or arriving at gamma that are used\nin the path should explicitely calculated, even if the values are the same.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.read_non_anal_from_file(abidata.ref_file(\"ZnSe_hex_886.anaddb.nc\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the phonon frequencies. Note that the labels for the q-points\nare found automatically by searching in an internal database.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plot(title=\"ZnSe with LO-TO splitting\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phbands.plotly(title=\"ZnSe with LO-TO splitting\")"
]
}
],
"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
}PK R O plot_multiple_hist.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Multiple Structural relaxations\n\nThis example shows how to analyze the results of multiple\nstructure relaxations with the HIST robot.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy import abilab\nimport abipy.data as abidata\n\nfiles = [\n abidata.ref_file(\"sic_relax_HIST.nc\"),\n abidata.ref_file(\"sic_relax_HIST.nc\"),\n]\n\n# Build HIST robot from paths, use user-selected labels.\nrobot = abilab.HistRobot.from_files(files, labels=[\"sic_relaxation\", \"same_hist\"])\n\n# Get dataframe with most important results.\nprint(robot.get_dataframe())\n\nrobot.gridplot()\n\n# Use combiplot to compare the results\n# (meaningless in this case as we are using the same HIST file).\nrobot.combiplot()"
]
}
],
"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
}PK R:_0 plot_ebands_edos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Bands + DOS\n\nThis example shows how to compute the DOS and plot a\nband structure with DOS using two GSR files.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the file with energies computed on a k-path in the BZ\n# and extract the band structure object.\nwith abiopen(abidata.ref_file(\"si_nscf_GSR.nc\")) as nscf_file:\n nscf_ebands = nscf_file.ebands\n\n# Open the file with energies computed with a homogeneous sampling of the BZ\n# and extract the band structure object.\nwith abiopen(abidata.ref_file(\"si_scf_GSR.nc\")) as gs_file:\n gs_ebands = gs_file.ebands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Compute the DOS with the Gaussian method (use default values for\nthe broadening and the step of the linear mesh.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"edos = gs_ebands.get_edos()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot bands and DOS with matplotlib use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"nscf_ebands.plot_with_edos(edos, e0=None, with_gaps=True, title=\"Si Electron bands + DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"nscf_ebands.plotly_with_edos(edos, e0=None, with_gaps=True, title=\"Si Electron bands + DOS\")\n\nprint(\"nscf_ebands.efermi\", nscf_ebands.fermie)\nprint(\"gs_ebands.efermi\", gs_ebands.fermie)"
]
}
],
"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
}PK RS: : plot_phonons.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# AlAs Phonon bands\n\nThis example shows how to plot the phonon band structure of AlAs.\nSee tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open PHBST file produced by anaddb and extract the phonon bands object.\n# (alternatively one can use the shell and `abiopen.py OUT_PHBST.nc -nb`\n# to open the file in a jupyter notebook.\nwith abiopen(abidata.ref_file(\"trf2_5.out_PHBST.nc\")) as ncfile:\n phbands = ncfile.phbands\n\n# Plot the phonon frequencies. Note that the labels for the q-points\n# are found automatically in an internal database.\nphbands.plot(units=\"cm-1\", title=\"AlAs without LO-TO splitting\")\n\n# Alternatively you can use the optional argument qlabels\n# that defines the mapping reduced_coordinates --> name of the q-point.\n#qlabels = {\n# (0,0,0): \"$\\Gamma$\",\n# (0.375, 0.375, 0.7500): \"K\",\n# (0.5, 0.5, 1.0): \"X\",\n# (0.5, 0.5, 0.5): \"L\",\n# (0.5, 0.0, 0.5): \"X\",\n# (0.5, 0.25, 0.75): \"W\",\n#}\n\n# and pass it to the plot method:\n#phbands.plot(title=\"AlAs without LO-TO splitting\", qlabels=qlabels)"
]
}
],
"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
}PK ՄR.E} } plot_speed_of_sound.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Speed of Sound\n\nThis example shows how to compute the speed of sound by fitting phonon frequencies\nalong selected directions by linear least-squares fit.\nFor a command line interface use:\n\n abiview.py ddb_vs input_DDB\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from __future__ import print_function\n\nimport os\nimport abipy.data as abidata\n\nfrom abipy import abilab\nfrom abipy.dfpt.vsound import SoundVelocity\n\n# Initialize object from DDB file.\nddb_path = os.path.join(abidata.dirpath, \"refs\", \"si_sound_vel\", \"Si_DDB\")\nsv = SoundVelocity.from_ddb(ddb_path)\n\n# Get pandas dataframe with results.\ndf = sv.get_dataframe()\nabilab.print_dataframe(df)\n\n# Plot fit\nsv.plot()\nsv.plotly()"
]
}
],
"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
}PK REv plot_phonons_infrared.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Infrared spectrum of AlAs\n\nThis example shows how to plot the infrared spectrum of a polar semiconductor (AlAs)\nfrom the DDB file See tutorial/lesson_rf2.html\n\nFor a command line interfase, use:\n\n abiview.py ddb_ir in_DDB\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy import abilab\n\n# Open DDB file for alpha-SiO2 taken from https://materialsproject.org/materials/mp-7000/\nfilepath = os.path.join(abidata.dirpath, \"refs\", \"mp-7000_DDB.bz2\")\nddb = abilab.abiopen(filepath)\n\n# Invoke anaddb to compute dielectric tensor and oscillator strength.\ntgen = ddb.anaget_dielectric_tensor_generator(asr=2, chneut=1, dipdip=1, verbose=1)\nprint(tgen)\n\n# Set phonon damping factor in eV (full width).\ngamma_ev = 1e-3\n\n# Plot IR spectrum in Cartesian coordinates.\ntgen.plot_all(gamma_ev=gamma_ev, title=\"Diagonal and off-diagonal components\")\n\ntgen.plot(component=\"diag\", reim=\"re\", gamma_ev=gamma_ev, title=\"Real part, diagonal components\")\ntgen.plotly(component=\"diag\", reim=\"re\", gamma_ev=gamma_ev, title=\"Real part, diagonal components\")\n\ntgen.plot(component=\"diag\", reim=\"im\", gamma_ev=gamma_ev, title=\"Imaginary part, diagonal components\")\ntgen.plotly(component=\"diag\", reim=\"im\", gamma_ev=gamma_ev, title=\"Imaginary part, diagonal components\")\n\nddb.close()"
]
}
],
"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
}PK ɄR9z? ? plot_phonon_pjdos.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Projected phonon DOS\n\nThis example shows how to plot the projected phonon DOS (PJDOS) of AlAs.\nSee tutorial/lesson_rf2.html\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Read the Phonon DOS from the netcdf file produced by anaddb with prtdos 2\n(alternatively one can use the shell and `abiopen.py OUT_PHDOS.nc -nb`\nto open the file in a jupyter notebook.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\nphdos_file = abiopen(abidata.ref_file(\"trf2_5.out_PHDOS.nc\"))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the PJDOS with matplotlib, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos_file.plot_pjdos_type(units=\"cm-1\", title=\"AlAs type-projected phonon DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the plotly version, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos_file.plotly_pjdos_type(units=\"cm-1\", title=\"AlAs type-projected phonon DOS\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To have the projection along the cartesian directions (summed over atomic types), use\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos_file.plot_pjdos_cartdirs_type(units=\"Thz\", stacked=True,\n title=\"Type-projected ph-DOS decomposed along the three Cartesian directions.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To plot the PJDOS for all the inequivalent sites, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos_file.plot_pjdos_cartdirs_site(view=\"inequivalent\", stacked=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Remember to close the file\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"phdos_file.close()"
]
}
],
"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
}PK Rt; ; plot_ifcs.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Interatomic Force Constants\n\nThis example shows how to plot the longitudinal part\nof the Interatomic Force Constants in real-space starting from a DDB file.\n\nSee e.g. \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy import abilab\n\n# Open DDB file for AlAs\nfilepath = os.path.join(abidata.dirpath, \"refs\", \"alas_phonons\", \"trf2_3_DDB\")\nddb = abilab.abiopen(filepath)\n\n# Call anaddb to compute the Interatomic Force Constants\n# Default args are: asr=2, chneut=1, dipdip=1.\nifc = ddb.anaget_ifc()\n\n# Plot the total longitudinal IFCs in local coordinates, filtered according to the optional arguments.\nifc.plot_longitudinal_ifc(title=\"Total Longitudinal IFCs\")\n\n# Plots the short range longitudinal IFCs in local coordinates, filtered according to the optional arguments.\nifc.plot_longitudinal_ifc_short_range(title=\"Longitudinal SR-IFCs\")\n\n# Plots the Ewald part of the IFCs in local coordinates, filtered according to the optional arguments.\nifc.plot_longitudinal_ifc_ewald(title=\"Longitudinal LR-IFCs\")\n\nddb.close()"
]
}
],
"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
}PK R+ + plot_lobster_cohp.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Lobster COHPCAR\n\nThis example shows how to analyze the COHPCAR file\nproduced by Lobster code \n\nUse `abiopen.py FILE` with --expose or --print for a command line interface\nand --notebook to generate a jupyter notebook.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.abilab import abiopen\n\ndirpath = os.path.join(abidata.dirpath, \"refs\", \"lobster_gaas\")\nfilename = os.path.join(dirpath, \"GaAs_COHPCAR.lobster.gz\")\n\n# Open the COHPCAR.lobster file (same API for COOPCAR.lobster)\ncohp_file = abiopen(filename)\nprint(cohp_file)\n\n# Plot COHP.\ncohp_file.plot(title=\"GaAs COHP\")\n\n# Plot integrated COHP.\ncohp_file.plot(what=\"i\", title=\"GaAs integrated COHP\")\n\n# Plot total overlap for all sites listed in `from_site_index`\ncohp_file.plot_site_pairs_total(from_site_index=[0], title=\"COHP total overlap for site index 0\")\n\n# Plot partial crystal orbital projections for all sites listed in `from_site_index`\ncohp_file.plot_site_pairs_partial(from_site_index=[0], title=\"COHP with orbital projections from site index 0\")"
]
}
],
"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
}PK RUwV plot_edos_vs_broad.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Multiple e-DOSes\n\nThis example shows how to compute and plot multiple\nelectron DOSes obtained with different values of the gaussian broadening.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\n\nfrom abipy import abilab\n\n# Open the wavefunction file computed with a homogeneous sampling of the BZ\n# and extract the band structure on the k-mesh.\nwith abilab.abiopen(abidata.ref_file(\"si_scf_WFK.nc\")) as gs_wfk:\n gs_bands = gs_wfk.ebands\n\n# Compute the DOS with different values of the Gaussian smearing.\nwidths = [0.1, 0.2, 0.3]\n\nedos_plotter = gs_bands.compare_gauss_edos(widths, step=0.1)\n\n# Invoke ElectronDosPlotter methods to plot results.\nedos_plotter.combiplot(title=\"e-DOS as function of the Gaussian broadening\")\n\nedos_plotter.gridplot(title=\"gridplot version\")\n\nwith abilab.abiopen(abidata.ref_file(\"ni_666k_GSR.nc\")) as gsr:\n ni_ebands_kmesh = gsr.ebands\n\nedos_plotter = ni_ebands_kmesh.compare_gauss_edos(widths=[0.1, 0.2, 0.3], step=0.2)\n\ntitle = \"e-DOS as function of the Gaussian broadening\"\nedos_plotter.combiplot(dos_mode=\"idos+dos\")\nedos_plotter.combiplot(dos_mode=\"dos\", spin_mode=\"resolved\")\n\nedos_plotter.gridplot(title=\"gridplot version\")\nedos_plotter.gridplot(spin_mode=\"resolved\")"
]
}
],
"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
}PK ӄRϲ> > plot_qha_vs_qmesh.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Quasi-harmonic approximation (convergence wrt Q-mesh)\n\nThis example shows how to use the GSR.nc and PHDOS.nc files computed with different volumes\nto analyze the convergence of QHA thermodynamic properties with respect to the number of q-points\nused to compute the phonon DOS.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport abipy.data as abidata\n\nfrom abipy.dfpt.qha import QHAQmeshAnalyzer\n\n# We use a list of GSR.nc and PHDOS.nc files corresponding to different isotropic strains.\n# These files are shipped with AbiPy so that we don't need to run calculations from scratch.\n#strains = [-4, -2, 0, 2, 4, 6]\nstrains = [-2, 0, 2, 4]\ndirpath = os.path.join(abidata.dirpath, \"refs\", \"si_qha\")\n\ngsr_paths = [os.path.join(dirpath, \"mp-149_{:+d}_GSR.nc\".format(s)) for s in strains]\nddb_paths = [os.path.join(dirpath, \"mp-149_{:+d}_DDB\".format(s)) for s in strains]\n\n# Initialize QHA object from files.\nqhana = QHAQmeshAnalyzer(gsr_paths, ddb_paths)\n\n# To change the default EOS (vinet), use\n#qhana.set_eos(\"vinet\")\n\n# Compute ph-DOS with this list of nqsmall values.\nqhana.run_qlist([2, 4])\n\n# Analyze convergence. API similar to QHA.\nqhana.plot_energies(title=\"Energies as a function of volume for different T\")\n\nqhana.plot_thermal_expansion_coeff(title=\"Thermal expansion coefficient as a function of T\")\n\nqhana.plot_vol_vs_t(title=\"Volume as a function of T\")"
]
}
],
"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
}PK R4 plot_structure.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Unit cell\n\nThis example shows how to display the unit cell with matplotlib.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Extract structure from the netcdf file:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"with abiopen(abidata.ref_file(\"sio2_kpath_GSR.nc\")) as gsr:\n structure = gsr.structure"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To visualize the structure with matplotlib, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"structure.plot(color_scheme=\"Jmol\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To wrap sites into first unit cell, use:\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# sphinx_gallery_thumbnail_number = 2\nstructure.plot(to_unit_cell=True)"
]
}
],
"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
}PK R(P
plot_qpbands_with_scissor.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# GW with scissors operator\n\nThis example shows how to generate an energy-dependent scissors operator\nby fitting the GW corrections as function of the KS eigenvalues.\nWe then use the scissors operator to correct the KS band structure\ncomputed on a high symmetry k-path. Finally, the LDA and the QPState band\nstructure are plotted with matplotlib.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import abipy.data as abidata\nfrom abipy.abilab import abiopen, ElectronBandsPlotter\n\n# Get the QP results from the SIGRES.nc database.\nsigma_file = abiopen(abidata.ref_file(\"si_g0w0ppm_nband30_SIGRES.nc\"))\n\n# Let's have a look at the QP correction as function of the KS energy.\n# Don't shift KS eigenvalues to have zero energy at the Fermi energy.\n# because we need the absolute values for the fit.\n# The qpeme0(e0) curve consists of two branches:\n# the one in the [-6, 5.7] eV interval associated to valence states\n# and the one in the [6.1, 15] eV interval associated to conduction bands.\n# We will fit these results with 2 functions defined in these two domains.\nsigma_file.plot_qps_vs_e0(e0=None)\nsigma_file.plot_qps_vs_e0()\n\nqplist_spin = sigma_file.qplist_spin\n\n# Define the two domains and construct the scissors operator\ndomains = [[-10, 6.1], [6.1, 18]]\nscissors = qplist_spin[0].build_scissors(domains, bounds=None)\n\n# Read the KS band energies computed on the k-path\nks_bands = abiopen(abidata.ref_file(\"si_nscf_GSR.nc\")).ebands\n\n# Read the KS band energies computed on the Monkhorst-Pack (MP) mesh\n# and compute the DOS with the Gaussian method\nks_mpbands = abiopen(abidata.ref_file(\"si_scf_GSR.nc\")).ebands\nks_edos = ks_mpbands.get_edos()\n\n# Apply the scissors operator first on the KS band structure\n# along the k-path then on the energies computed with the MP mesh.\nqp_bands = ks_bands.apply_scissors(scissors)\n\nqp_mpbands = ks_mpbands.apply_scissors(scissors)\n\n# Compute the DOS with the modified QPState energies.\nqp_edos = qp_mpbands.get_edos()\n\n# Plot the LDA and the QPState band structure with matplotlib.\nplotter = ElectronBandsPlotter()\n\nplotter.add_ebands(\"LDA\", ks_bands, edos=ks_edos)\nplotter.add_ebands(\"LDA+scissors(e)\", qp_bands, edos=qp_edos)\n\n# By default, the two band energies are shifted wrt to *their* fermi level.\n# Use e=0 if you don't want to shift the eigenvalus\n# so that it's possible to visualize the QP corrections.\nplotter.combiplot(title=\"Silicon band structure\")\n\nplotter.gridplot(title=\"Silicon band structure\")\nsigma_file.close()"
]
}
],
"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
}PK Rt3 plot_wfk.ipynb{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Wavefunction file\n\nThis example shows how to analyze the wavefunctions\nstored in the WFK.nc file.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from abipy.abilab import abiopen\nimport abipy.data as abidata\n\n# Open the DEN.nc file\nncfile = abiopen(abidata.ref_file(\"si_nscf_WFK.nc\"))\nprint(ncfile)\n\n# The DEN file has a `Structure` an `ElectronBands` object and wavefunctions.\n#print(ncfile.structure)\n\n# To plot the KS eigenvalues.\n#ncfile.ebands.plot()\n\n# Extract the wavefunction for the first spin, the first band and k=[0.5, 0, 0]\nwave = ncfile.get_wave(spin=0, kpoint=[0.5, 0, 0], band=0)\nprint(wave)\n\n# This is equivalent to\n#wave = ncfile.get_wave(spin=0, kpoint=0, band=0)\n# because [0.5, 0, 0] is the first k-point in the WFK file\n\n# To visualize the total charge wih vesta\n#visu = wave.visualize_ur2(\"vesta\"); visu()\n\n# To plot the wavefunction along the line connecting\n# the first and the second in the structure:\n#wave.plot_line(point1=0, point2=1)\n\n#wave.plot_line(point1=0, point2=1, with_krphase=True)\n\n# alternatively, one can define the line in terms of two points\n# in fractional coordinates:\nwave.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], with_krphase=False, num=400)\nwave.plot_line(point1=[0, 0, 0], point2=[0, 4, 0], with_krphase=True, num=400)\n\n# To plot the wavefunction along the lines connect the firt atom in the structure\n# and all the neighbors within a sphere of radius 3 Angstrom:\n#wave.plot_line_neighbors(site_index=0, radius=3)\n\nncfile.close()"
]
}
],
"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
}PK Rr
plot_phonons_msqd.ipynbPK ɄR}
plot_qha.ipynbPK لR//D plot_ebands_scatter3d.ipynbPK R "z z plot_gruneisen.ipynbPK R R$ plot_efatbands_lm.ipynbPK REO
} , plot_edos.ipynbPK R=| 8 plot_gw_spectral_functions.ipynbPK R > plot_eph_from_mp.ipynbPK RN N K plot_phbands_nkpt_tsmear.ipynbPK ȄRn^ ] plot_potentials.ipynbPK R
!g plot_efatbands.ipynbPK R?k u plotly_phbands_and_dos.ipynbPK R&P P ) plot_lobster_files.ipynbPK Rv?
plot_ebands.ipynbPK ׄR Ζ plot_fold2bloch.ipynbPK R¦ plot_kpath_from_ibz.ipynbPK ׄR5
plot_ebands_spin.ipynbPK ׄR1C plot_phthermo.ipynbPK RBf7 ? plot_wannier90_abiwan.ipynbPK ܄R , plot_efatbands_spin.ipynbPK Revv v plot_ebands_grid.ipynbPK RfW plot_scr.ipynbPK Rm%Wq
plot_qpconvergence.ipynbPK RS" plot_gscycle.ipynbPK لRQ* plot_xrd.ipynbPK DŽRrI plot_ddb_asr.ipynbPK R!z@ plot_fermisurface.ipynbPK R( plot_phbands_and_dos.ipynbPK لRtP & plot_scqpgw.ipynbPK ԄR=I , plot_scr_matrix.ipynbPK ׄR
g{ 5 plot_hist.ipynbPK R9Zd0 0 ; plot_multiple_mdf.ipynbPK R4Ś _C plot_optic.ipynbPK ՄRK M plot_ebands_boxplot.ipynbPK R&m m T plot_ejdos.ipynbPK RHwP P [ plot_den.ipynbPK Rd6I I h plot_phbands_grid.ipynbPK ԄR : : w plot_qps.ipynbPK ȄR } plot_phonon_fatbands.ipynbPK RQc c % plot_qpbands_with_interpolation.ipynbPK Ru&' ' plot_a2f.ipynbPK R[ plot_wannier90_wout.ipynbPK Ro̙
plot_bz.ipynbPK RxL plot_funcs.ipynbPK R" D plot_dfpt_cycle.ipynbPK R_> > plot_mdf.ipynbPK ÄR#Xw w plot_phonons_lo_to.ipynbPK R O / plot_multiple_hist.ipynbPK R:_0 plot_ebands_edos.ipynbPK RS: : plot_phonons.ipynbPK ՄR.E} } plot_speed_of_sound.ipynbPK REv plot_phonons_infrared.ipynbPK ɄR9z? ? plot_phonon_pjdos.ipynbPK Rt; ; } plot_ifcs.ipynbPK R+ + plot_lobster_cohp.ipynbPK RUwV E plot_edos_vs_broad.ipynbPK ӄRϲ> > 3% plot_qha_vs_qmesh.ipynbPK R4 . plot_structure.ipynbPK R(P
7 plot_qpbands_with_scissor.ipynbPK Rt3 E plot_wfk.ipynbPK <