# Auxiliary tools#

`phono3py-kdeplot`

: Distribution of phonon lifetime#

**This script is under the development and may contain bugs.** But a feature is
briefly introduced below since it may be useful. Scipy is needed to use this
script.

This script draws density of phonon modes in the frequency-lifetime plane. Its density is estimated using Gaussian-KDE using scipy. Then (frequency, lifetime)-data points are superimposed on the density plot.

`phono3py-kdeplot`

reads a result of the thermal conductivity calculation as the
first argument:

```
% phono3py-kdeplot kappa-m111111.hdf5
```

This calculation takes some time from minutes to hours depending on mesh numbers and nbins. Therefore it is recommended to start with smaller mesh and gradually to increase mesh numbers and nbins up to satisfaction.

After finishing the calculation, the plot is saved in `lifetime.png`

. The black
dots show original data points. The drawing area is automatically set to make
the look good, where its higher lifetime side is not drawn if all density beyond
a lifetime value is smaller than some ratio (see --dr, --density-ratio)
of the maximum density.

The following plot is drawn with a \(19 \times 19 \times 19\) mesh and nbins=200
and the `Si-PBEsol`

example is used to generate the data. The colormap of ‘jet’
in matplotlib is used.

### Options#

`--temperature`

#

Pick up one temperature point. For example, `--temperature=300`

for 300 K, which
works only if thermal conductivity is calculated at temperatures including 300
K.

Without specifying this option, the 31st temperature index is chosen. This often corresponds to 300 K if phono3py ran without setting temperature range and step.

`--nbins`

#

This option controls the resolution of the density plot. The default value is 100. With larger nbins, the resolution of the plot becomes better, but the computation will take more time.

```
% phono3py-kdeplot --nbins=200 kappa-m111111.hdf5
```

`--cutoff`

, `--fmax`

#

The option `--cutoff`

(`--fmax`

) sets the maximum value of lifetime (frequency)
to be included as data points **before** Gaussian-KDE. Normally increasing this
value from the chosen value without specifying this option does nothing since
automatic control of drawing area cuts high lifetime (frequency) side if the
density is low.

`--xmax`

and `--ymax`

#

Maximum values of drawing region of phonon frequency (x-axis) and lifetime
(y-axis) are specified by `--xmax`

and `--ymax`

, respectively.

`--ymax`

switches off automatic determination of maximum value of drawing region
along y-axis, therefore as a side effect, the computation will be roughly twice
faster.

```
% phono3py-kdeplot --ymax=60 kappa-m111111.hdf5
```

`--zmax`

#

Maximum value of the density is specified with this option. The color along colorbar saturates by choosing a smaller value than the maximum value of density in the data.

`--dr`

, `--density-ratio`

#

The density threshold is specified by the ratio with respect to maximum density.
Normally smaller value results in larger drawing region. The default value is
0.1. When `--ymax`

is specified together, this option is ignored.

```
% phono3py-kdeplot --dr=0.01 kappa-m111111.hdf5
```

`--cmap`

#

Color map to be used for the density plot. It’s given by the name presented at the matplotlib documentation, https://matplotlib.org/users/colormaps.html. The default colormap depends on your matplotlib environment.

```
% phono3py-kdeplot --cmap="OrRd" kappa-m111111.hdf5
```

The following figures are those drawn with `jet`

, `bwr`

, `seismic`

, `gnuplot`

,
`hsv`

, and `OrRd`

colormaps.