.. 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 Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_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 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-24 .. code-block:: default 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 25-30 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 30-34 .. code-block:: default plotter = ddb.anacompare_asr(asr_list=(0, 2), dipdip=-1) print(plotter) .. rst-class:: sphx-glr-script-out 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 Sites (2) # SP a b c --- ---- -------- -------- --- 0 Mg 0 0 0 1 O 0.333333 0.666667 0.5 Abinit Spacegroup: spgid: 0, num_spatial_symmetries: 12, has_timerev: True, symmorphic: False Number of q-points: 345 Atomic mass units: {12.0: 24.305, 8.0: 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 Sites (2) # SP a b c --- ---- -------- -------- --- 0 Mg 0 0 0 1 O 0.333333 0.666667 0.5 Abinit Spacegroup: spgid: 0, num_spatial_symmetries: 12, has_timerev: True, symmorphic: False Number of q-points: 345 Atomic mass units: {12.0: 24.305, 8.0: 15.9994} Has non-analytical contribution for q --> 0: True .. GENERATED FROM PYTHON SOURCE LINES 35-36 To plot the bands on the same figure with matplotlib, use: .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: default plotter.combiplot() .. image:: /gallery/images/sphx_glr_plot_ddb_asr_001.png :alt: plot ddb asr :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 40-41 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 41-44 .. code-block:: default plotter.combiplotly() .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 45-46 To disable the DOS computation, set ``nqsmall` to 0: .. GENERATED FROM PYTHON SOURCE LINES 46-49 .. code-block:: default plotter = ddb.anacompare_asr(asr_list=(0, 2), nqsmall=0, ndivsm=10, dipdip=-1) .. GENERATED FROM PYTHON SOURCE LINES 50-51 To plot the bands on different subplots with matplotlib, use: .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: default plotter.gridplot() .. image:: /gallery/images/sphx_glr_plot_ddb_asr_002.png :alt: asr: 0, dipdip: -1, chneut: 1, asr: 2, dipdip: -1, chneut: 1 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 55-56 For the plotly version, use: .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: default plotter.gridplotly() .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 59-60 Finally, remember to close the file with: .. GENERATED FROM PYTHON SOURCE LINES 60-62 .. code-block:: default ddb.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 8.178 seconds) .. _sphx_glr_download_gallery_plot_ddb_asr.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/abinit/abipy/gh-pages?filepath=notebooks/gallery/plot_ddb_asr.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_ddb_asr.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ddb_asr.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_