The output of TB2J
==================


In the following we describe the output files which TB2J produces. By running wann2J.py or siesta2J.py, a directory with the name TB2J\_results (or the directory specified by the --output_path) will be generated, which contains the following output files:

* exchange.out: A human readable output file, which summarizes the results.

* Multibinit: A directory containing output which can be read directly by the Multibinit code. 

* The exchange.out file contains three sections: cell, atoms and exchange. The cell section contains the lattice parameter matrix. The atoms section contains the positions, charges (for verification) and magnetic moments of the atoms: see example below ::

    ==========================================================================================
    Information:
    Exchange parameters generated by TB2J 0.2.5.
    ==========================================================================================
    Cell (Angstrom):
    0.030   3.950   3.950
    3.950   0.030   3.950
    3.950   3.950   0.030

    ==========================================================================================
    Atoms:
    (Note: charge and magmoms only count the wannier functions.)
    Atom_number       x          y         z     w_charge    M(x)      M(y)      M(z)
    Bi1             0.2413    0.2413    0.2413    2.1538   -0.0015    0.0000   -0.0044
    Bi2             4.2060    4.2060    4.2060    2.1538    0.0000    0.0000    0.0044
    Fe1             2.0165    2.0165    2.0165    6.3564   -0.0260    0.0000    3.7927
    Fe2             5.9812    5.9812    5.9812    6.3564   -0.0176    0.0000   -3.7927
    O1              5.5238    2.1558    3.9388    4.8306   -0.0013    0.0000   -0.0705
    .....
    Total                                        46.0038   -0.0493    0.0000   -0.0000

    ==========================================================================================
    Exchange:
    i           j           R       J_iso(meV)       vector         distance(A)
    ----------------------------------------------------------------------------------------
    Fe2         Fe1   (0,   1,   1)  -28.9371 ( 3.934,  0.015,  0.015)  3.934
    J_iso: -28.9371
    [Testing!] Jprime: -59.620,  B: -15.342
    [Testing!] DMI: (-0.5191  1.3581  0.1090)
    [Testing!] J_ani:
    [[ 0.    -0.002  0.047]
    [-0.002  0.    -0.154]
    [ 0.047 -0.154  0.   ]]
    

Here, the charge and magnetic moment of each atom are only integrated with the WFs attached to this atom. As such they can differ from the quantities coming from the direct DFT output, as not all bands are used in the construction of WFs. The WF charges should be integers, for LCAO the values depend on the band energy cutoffs. In addition, the exclusion of very deep lying levels from the calculation of :math:`J` can also lead to deviations in the charges which might appear both for WFs and for LCAO. Another source of difference between the TB2J charges and magnetic moments and the DFT ones is the integration volume around the atoms, which is not necessarily the same. However, for localized :math:`d` and :math:`f` orbitals the magnetic moments should be close to their DFT counterparts, for TB2J to yield correct results for the parameters. Large differences between the TB2J and DFT values indicate that something may have gone wrong: either in in the contour integration :math:`\int^{E_F} d\epsilon` used in TB2J, or in the construction of the Wannier functions (incorrect wannierization process or too small WF basis set). Often, it comes from excluding an orbital that is important for the magnetic interaction in the studied system. In the case of metallic system, the Fermi energy might have to be slightly shifted with respect to the DFT reference due to different numerical method used in the integration of charge density.

Each pair of atoms is labeled by three parameters, the index :math:`i`, :math:`j` and :math:`R`, where :math:`i` and :math:`j` are the indices in the unit cell. The vector :math:`\vec{R}` specifies the cell the atom :math:`j` is translated to, i.e. the reduced positions of the two atoms are :math:`\vec{r}_i` and :math:`\vec{r}_j+\vec{R}` , respectively. By default, the interaction is calculated within a supercell corresponding to the k-mesh. For example, with a :math:`7\times 7 \times 7` k-mesh, all :math:`ij` pairs will be produced for the spin labeled :math:`i` in the center cell of a :math:`7\times 7 \times 7` supercell. With the rcut flag, only the parameters for :math:`ij` pairs within a distance of rcut are calculated. The exchange parameters are reported as follows: magnetic atom :math:`i` connected with magnetic atom :math:`j`, :math:`R` is the lattice vector between the unit cells containing :math:`i` and :math:`j`, the value of :math:`J` for this pair of magnetic atoms in meV, the vector connecting them, and the distance between the pair of atoms. If SOC is enabled, the DMI and anisotropic :math:`J^{ani}` parameters are given in addition. The DMI vectors :math:`\vec{D}` and the anisotropic :math:`J^{ani}` are printed as vectors and matrices, respectively.  

Apart from the main exchange.out file, TB2J delivers several other outputs, which provide the input for spin dynamics (SD) and Monte Carlo (MC) simulations. TB2J is interfaced with several SD and MC codes. It has native support to the Multibinit code delivered as part of the Abinit code since version 9.0 . The  TB2J\_results/Multibinit directory contains the templates of input files for this code. One can usually run spin-dynamics with slight or no modification of these files. "Testing" inputs are also generated for Vampire  and Thomas Ostler's GPU-ASD code.
