Magnon band structure from TB2J output
======================================

In this section we show an application of calculating the magnon band
structure using the TB2J results.

There is a script within the TB2J package: TB2J_magnon.py, which can be
used to plot the magnon band structure. We can show its usage by:

::

   TB2J_magnon.py --help

   usage: TB2J_magnon.py [-h] [--fname FNAME] [--qpath QPATH]  [--figfname FIGFNAME] [--show]

   TB2J_magnon: Plot magnon band structure from the TB2J magnetic interaction parameters

   optional arguments:
     -h, --help     show this help message and exit
     --fname FNAME  exchange xml file name. default: exchange.xml
     --qpath QPATH  The names of special q-points. If not given, the path will be automatically choosen. See https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html for the table of special kpoints and the default path.
     --figfname FIGFNAME  The file name of the figure. It should be e.g. png, pdf or other types of files which could be generated by matplotlib.
     --show         whether to show magnon band structure.

The input file specified to the –fname parameter is by default
exchange.xml file, which is the output in the Multibinit xml format, as
can be found in the TB2J_results/Multibinit directory.

Here we take the BCC Fe as an example. After we have the TB2J_results
directory, we can go to the Multibinit directory and find the
exchange.xml file. The q-path can be generated automatically from the
atomic structure information, using the
[ASE][https://wiki.fysik.dtu.dk/ase/ase] library. We need to specify a
path of q-points if the default is not what we want. The default k-path
and the labels of the special kpoints can be found at `this
page <https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html>`__.
For example, we want a path of “Gamma-N-P-Gamma-H-N” instead of the
default, it can be given by:

::

   TB2J_magnon.py --qpath GNPGHN --figfname magnon.png --show

The magnon band structure is then written to a By using the –show
parameter, the band structure is shown on screen.

.. figure:: magnon_band.assets/exchange_magnon-1593690872101.png
   :alt: exchange_magnon

   exchange_magnon

From version v0.7.5, the infomation for plotting the band structure is written into a json file(magnon_band.json), together with the 
script for parsing the file and plot the band structure (plot_magnon_from_json_file.py). 


From version v0.7.7, there is a script to plot the magnon density of states.

::
    
    TB2J_magnon_dos.py --help
    usage: TB2J_magnon_dos.py [-h] [-p PATH] [-n NPOINTS] [-w WINDOW WINDOW] [-k KMESH KMESH KMESH]
                              [-s SMEARING_WIDTH] [-g] [-Jq] [--show] [-f FIG_FILENAME] [-t TXT_FILENAME]
    
    Plot magnon DOS
    
    options:
      -h, --help            show this help message and exit
      -p PATH, --path PATH  path to exchange.xml
      -n NPOINTS, --npoints NPOINTS
                            number of points in the energy
      -w WINDOW WINDOW, --window WINDOW WINDOW
                            energy window for the dos, two numbers giving the lower and upper bound
      -k KMESH KMESH KMESH, --kmesh KMESH KMESH KMESH
                            k mesh
      -s SMEARING_WIDTH, --smearing_width SMEARING_WIDTH
                            Gauss smearing width in meV. Default is 10 meV.
      -g, --gamma           gamma centered k mesh
      -Jq                   use Jq
      --show                show the figure
      -f FIG_FILENAME, --fig_filename FIG_FILENAME
                            output filename for figure.
      -t TXT_FILENAME, --txt_filename TXT_FILENAME
                            output filename of the data for the magnon DOS. Default: magnon_dos.txt
    
For example, with the following command, we get the DOS for bcc Fe. 

::

    TB2J_magnon_dos.py --show -s 10 -k 25 25 25 -f magnon_dos.png --show


.. figure:: magnon_band.assets/magnon_dos.png
   :alt: magnon_dos

   magnon_dos

The energies and the DOS are also saved to a txt file specified. The two columns of the file are the energies, and 
the DOS, respectively. It can be used for plotting the DOS if you want to plot in your own style. 
