.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_ddb_asr.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_ddb_asr.py: Phonon bands with/without the ASR ================================= This example shows how to plot a phonon band structure with and without enforcing the acoustic sum rule (ASR). Both matplotlib and plotly plots are supported. .. important:: Note that a **manager.yml** configuration file and an abinit installation are required to run this script as AbiPy needs to invoke anaddb to compute phonons from the DDB file. .. GENERATED FROM PYTHON SOURCE LINES 17-18 Open the DDB file with: .. GENERATED FROM PYTHON SOURCE LINES 18-25 .. code-block:: Python from abipy import abilab import abipy.data as abidata filepath = abidata.ref_file("mp-1009129-9x9x10q_ebecs_DDB") ddb = abilab.abiopen(filepath) .. GENERATED FROM PYTHON SOURCE LINES 26-31 The ``ddb.anacompare_asr`` method computes the phonon bands and the DOS by calling anaddb with different values of asr and returns a PhononBandsPlotter object: To make the computation faster, we use the **advanced** options dipdip -1. This option should produce results similar to dipdip 1 yet make sure to test the effect of this variable before using it in production. .. GENERATED FROM PYTHON SOURCE LINES 31-35 .. code-block:: Python plotter = ddb.anacompare_asr(asr_list=(0, 2), dipdip=-1) print(plotter) .. rst-class:: sphx-glr-script-out .. code-block:: none [0] asr: 0, dipdip: -1, chneut: 1 --> ================================= Structure ================================= Full Formula (Mg1 O1) Reduced Formula: MgO abc : 2.908638 2.908638 2.656848 angles: 90.000000 90.000000 120.000000 pbc : True True True Sites (2) # SP a b c --- ---- -------- -------- --- 0 Mg 0 0 0 1 O 0.333333 0.666667 0.5 Abinit Spacegroup: spgid: 1, num_spatial_symmetries: 12, has_timerev: True, symmorphic: False Number of q-points: 345 Atomic mass units: {np.float64(12.0): np.float64(24.305), np.float64(8.0): np.float64(15.9994)} Has non-analytical contribution for q --> 0: True [1] asr: 2, dipdip: -1, chneut: 1 --> ================================= Structure ================================= Full Formula (Mg1 O1) Reduced Formula: MgO abc : 2.908638 2.908638 2.656848 angles: 90.000000 90.000000 120.000000 pbc : True True True Sites (2) # SP a b c --- ---- -------- -------- --- 0 Mg 0 0 0 1 O 0.333333 0.666667 0.5 Abinit Spacegroup: spgid: 1, num_spatial_symmetries: 12, has_timerev: True, symmorphic: False Number of q-points: 345 Atomic mass units: {np.float64(12.0): np.float64(24.305), np.float64(8.0): np.float64(15.9994)} Has non-analytical contribution for q --> 0: True .. GENERATED FROM PYTHON SOURCE LINES 36-37 To plot the bands on the same figure with matplotlib, use: .. GENERATED FROM PYTHON SOURCE LINES 37-40 .. code-block:: Python plotter.combiplot() .. image-sg:: /gallery/images/sphx_glr_plot_ddb_asr_001.png :alt: plot ddb asr :srcset: /gallery/images/sphx_glr_plot_ddb_asr_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-42 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python plotter.combiplotly() .. GENERATED FROM PYTHON SOURCE LINES 46-47 To disable the DOS computation, set ``nqsmall` to 0: .. GENERATED FROM PYTHON SOURCE LINES 47-50 .. code-block:: Python plotter = ddb.anacompare_asr(asr_list=(0, 2), nqsmall=0, ndivsm=10, dipdip=-1) .. GENERATED FROM PYTHON SOURCE LINES 51-52 To plot the bands on different subplots with matplotlib, use: .. GENERATED FROM PYTHON SOURCE LINES 52-55 .. code-block:: Python plotter.gridplot() .. image-sg:: /gallery/images/sphx_glr_plot_ddb_asr_002.png :alt: asr: 0, dipdip: -1, chneut: 1, asr: 2, dipdip: -1, chneut: 1 :srcset: /gallery/images/sphx_glr_plot_ddb_asr_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-57 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 57-59 .. code-block:: Python plotter.gridplotly() .. GENERATED FROM PYTHON SOURCE LINES 60-61 Finally, remember to close the file with: .. GENERATED FROM PYTHON SOURCE LINES 61-63 .. code-block:: Python ddb.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.544 seconds) .. _sphx_glr_download_gallery_plot_ddb_asr.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ddb_asr.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ddb_asr.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_ddb_asr.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_