.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_phbands_and_dos.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_phbands_and_dos.py: Phonon band structures with LO-TO ================================= This example shows how to plot the phonon band structure of AlAs. without the LO-TO splitting. See also tutorial/lesson_rf2.html .. GENERATED FROM PYTHON SOURCE LINES 12-15 Open the PHBST file produced by anaddb and get the phonon bands. Note that the treatment of the LO-TO splitting for q--> 0 requires additional steps. See `plot_phonons_lo_to.py`. .. GENERATED FROM PYTHON SOURCE LINES 15-22 .. code-block:: Python from abipy.abilab import abiopen import abipy.data as abidata with abiopen(abidata.ref_file("trf2_5.out_PHBST.nc")) as ncfile: phbands = ncfile.phbands .. rst-class:: sphx-glr-script-out .. code-block:: none Warning: file /home/runner/work/abipy/abipy/abipy/data/refs/alas_phonons/trf2_5.out_PHBST.nc does not contain atomic_numbers. Particular methods need them! .. GENERATED FROM PYTHON SOURCE LINES 23-24 Read the Phonon DOS from the netcd file produced by anaddb (prtdos 2) .. GENERATED FROM PYTHON SOURCE LINES 24-28 .. code-block:: Python with abiopen(abidata.ref_file("trf2_5.out_PHDOS.nc")) as ncfile: phdos = ncfile.phdos .. GENERATED FROM PYTHON SOURCE LINES 29-30 Plot phonon bands and DOS with matplotib: .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: Python phbands.plot(title="AlAs Phonon bands and DOS in eV") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_and_dos_001.png :alt: AlAs Phonon bands and DOS in eV :srcset: /gallery/images/sphx_glr_plot_phbands_and_dos_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 34-35 For the plotly version use: .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python phbands.plotly(title="AlAs Phonon bands and DOS in eV") .. GENERATED FROM PYTHON SOURCE LINES 39-40 To plot phonon bands and phonon DOS with matplotlib use: .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: Python phbands.plot_with_phdos(phdos, units="cm-1", title="AlAs Phonon bands + DOS in cm-1") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_and_dos_002.png :alt: AlAs Phonon bands + DOS in cm-1 :srcset: /gallery/images/sphx_glr_plot_phbands_and_dos_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 45-46 For the plotly version use: .. GENERATED FROM PYTHON SOURCE LINES 46-50 .. code-block:: Python phbands.plotly_with_phdos(phdos, units="cm-1", title="AlAs Phonon bands + DOS in cm-1") .. GENERATED FROM PYTHON SOURCE LINES 51-52 Plot the phonon band structure with different color for each line (matplotlib version). .. GENERATED FROM PYTHON SOURCE LINES 52-57 .. code-block:: Python phbands.plot_colored_matched(units="cm-1", title="AlAs with different color for each line.") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_and_dos_003.png :alt: AlAs with different color for each line. :srcset: /gallery/images/sphx_glr_plot_phbands_and_dos_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 58-60 Use seaborn and matplotlib to draw a box plot showing the distribution of the phonon frequencies with respect to the mode index. .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python phbands.boxplot(units="meV") .. image-sg:: /gallery/images/sphx_glr_plot_phbands_and_dos_004.png :alt: plot phbands and dos :srcset: /gallery/images/sphx_glr_plot_phbands_and_dos_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 64-65 For the plotly version use: .. GENERATED FROM PYTHON SOURCE LINES 65-67 .. code-block:: Python phbands.boxplotly(units="meV") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.641 seconds) .. _sphx_glr_download_gallery_plot_phbands_and_dos.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_phbands_and_dos.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_phbands_and_dos.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_phbands_and_dos.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_