.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_speed_of_sound.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_speed_of_sound.py: Speed of Sound ============== This example shows how to compute the speed of sound by fitting phonon frequencies along selected directions by linear least-squares fit. For a command line interface use: .. code-block:: bash abiview.py ddb_vs DDB_FILE .. GENERATED FROM PYTHON SOURCE LINES 16-17 Initialize object from DDB file. .. GENERATED FROM PYTHON SOURCE LINES 17-27 .. code-block:: Python import os import abipy.data as abidata from abipy import abilab from abipy.dfpt.vsound import SoundVelocity ddb_path = os.path.join(abidata.dirpath, "refs", "si_sound_vel", "Si_DDB") sv = SoundVelocity.from_ddb(ddb_path) .. GENERATED FROM PYTHON SOURCE LINES 28-29 Get pandas dataframe with results. .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python df = sv.get_dataframe() abilab.print_dataframe(df) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Plot fit with matplotlib .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python sv.plot() .. image-sg:: /gallery/images/sphx_glr_plot_speed_of_sound_001.png :alt: [0.707, 0.000, 0.707] - X, [0.408, 0.408, 0.816] - K, [0.577, 0.577, 0.577] - L :srcset: /gallery/images/sphx_glr_plot_speed_of_sound_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-40 Plot fit with plotly .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python sv.plotly(template="plotly_dark") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.669 seconds) .. _sphx_glr_download_gallery_plot_speed_of_sound.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_speed_of_sound.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_speed_of_sound.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_speed_of_sound.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_