1#!/usr/local/bin/python3.8
2r"""
3Speed of Sound
4==============
5
6This example shows how to compute the speed of sound by fitting phonon frequencies
7along selected directions by linear least-squares fit.
8For a command line interface use:
9
10    abiview.py ddb_vs input_DDB
11"""
12from __future__ import print_function
13
14import os
15import abipy.data as abidata
16
17from abipy import abilab
18from abipy.dfpt.vsound import SoundVelocity
19
20# Initialize object from DDB file.
21ddb_path = os.path.join(abidata.dirpath, "refs", "si_sound_vel", "Si_DDB")
22sv = SoundVelocity.from_ddb(ddb_path)
23
24# Get pandas dataframe with results.
25df = sv.get_dataframe()
26abilab.print_dataframe(df)
27
28# Plot fit
29sv.plot()
30