rad-extract-tb2j.py#

Script for extracting of template-based Hamiltonian from TB2J results.

If --output_name is not provided, then the result is printed to the console, otherwise it is written to the text file.

Exchange types#

There are several options to control which exchange types are included in the summary:

Isotropic exchange is always included in the output. By default everything is included.

Usage example#

Example is based on the files from examples folder.

There are two modes in which exchange summary can be printed:

  • With the model of the template

  • Full Hamiltonian

In the first case the model of the template template is constructed from the Hamiltonian and exchange output is grouped based on the names provided in the template:

rad-extract-tb2j.py -fm -if exchange.out -tf template.txt -on summary_formed_model.txt
summary with forced symmetry
================================================================================
    ██████╗  █████╗ ██████╗       ████████╗ █████╗  █████╗ ██╗      ██████╗     
    ██╔══██╗██╔══██╗██╔══██╗      ╚══██╔══╝██╔══██╗██╔══██╗██║     ██╔════╝     
    ██████╔╝███████║██║  ██║█████╗   ██║   ██║  ██║██║  ██║██║     ╚═█████╗     
    ██╔══██╗██╔══██║██║  ██║╚════╝   ██║   ██║  ██║██║  ██║██║       ╚══██║     
    ██║  ██║██║  ██║██████╔╝         ██║   ╚█████╔╝╚█████╔╝███████╗██████╔╝     
    ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝          ╚═╝    ╚════╝  ╚════╝ ╚══════╝╚═════╝      
                          Version: 0.8.3                        ▄   ▄           
                   Documentation: rad-tools.org                 █▀█▀█           
                  Release date: 14 September 2023               █▄█▄█           
        Git hash: 5b4dc9b04aecb7efebb9cd710c02e0ad7fb68e44       ███   ▄▄       
                        Licence: GNU GPLv3                       ████ █  █      
                                                                 ████    █      
             Generated on 20 September 2023 at 2:22:3            ▀▀▀▀▀▀▀▀       
Exchange values are extracted from:
/Users/rybakov.ad/Codes/rad-tools/docs/examples/rad-extract-tb2j/exchange.out
Template used for model formation:
/Users/rybakov.ad/Codes/rad-tools/docs/examples/rad-extract-tb2j/template.txt
================================================================================
Primitive unit cell:
      x          y           z     
 3.89500000  0.00000000 0.00000000 
 -1.94700000 3.37300000 0.00000000 
 0.00000000  0.00000000 24.47800000
================================================================================
Atoms:
 Index Name  a1 (rel)   a2 (rel)   a3 (rel)       x          y           z     
 1     Ni1  0.00000285 0.01808479 0.49999183 -0.03520000 0.06100000 12.23880000
 2     I1   0.33328319 0.66252594 0.56152872 0.00820000  2.23470000 13.74510000
 3     I2   0.66662375 0.32917284 0.43845085 1.95560000  1.11030000 10.73240000
================================================================================
Magnetic moments of magnetic atoms:
 Index Name     m_x         m_y        m_z    
 1     Ni1  -0.00010000 -0.00010000 1.43680000
================================================================================
Notation of Hamiltonian:
(True, True, -1.0)
H = - \sum_{i,j} e_i J_{ij} e_j
Double counting is present.
Spin vectors are normalized to 1.
================================================================================
Spin model:
--------------------------------------------------------------------------------
J1 contains 6 bonds
Isotropic exchange:    0.1219
Full exchange matrix:
     0.0834  -0.0790   0.1773
     0.0803   0.0817   0.0096
    -0.1773  -0.0176   0.2007
Symmetric anisotropic exchange:
    -0.0386   0.0007   0.0000
     0.0007  -0.0402  -0.0040
     0.0000  -0.0040   0.0788
DMI module:
    0.1949
|DMI| / |J_iso|:
    1.5982
DMI vectors:
     0.0136  -0.1773  -0.0796   (Ni1(1) Ni1(1)  -1,   0,   0)
    -0.0136   0.1773   0.0796   (Ni1(1) Ni1(1)   1,   0,   0)
    -0.1449   0.0987  -0.0850   (Ni1(1) Ni1(1)  -1,  -1,   0)
     0.0952  -0.1700   0.0038   (Ni1(1) Ni1(1)   0,  -1,   0)
    -0.0952   0.1700  -0.0038   (Ni1(1) Ni1(1)   0,   1,   0)
     0.1449  -0.0987   0.0850   (Ni1(1) Ni1(1)   1,   1,   0)
--------------------------------------------------------------------------------
J2 contains 6 bonds
Isotropic exchange:    0.0143
Full exchange matrix:
     0.0382  -0.0467   0.0018
     0.0467   0.0385  -0.0031
    -0.0018   0.0018  -0.0338
Symmetric anisotropic exchange:
     0.0239   0.0000  -0.0000
     0.0000   0.0242  -0.0007
    -0.0000  -0.0007  -0.0481
DMI module:
    0.0468
|DMI| / |J_iso|:
    3.2726
DMI vectors:
    -0.0024  -0.0018  -0.0467   (Ni1(1) Ni1(1)  -2,  -1,   0)
    -0.0148  -0.0298  -0.0329   (Ni1(1) Ni1(1)  -1,   1,   0)
     0.0148   0.0298   0.0329   (Ni1(1) Ni1(1)   1,  -1,   0)
     0.0024   0.0018   0.0467   (Ni1(1) Ni1(1)   2,   1,   0)
    -0.0327   0.0017  -0.0334   (Ni1(1) Ni1(1)  -1,  -2,   0)
     0.0327  -0.0017   0.0334   (Ni1(1) Ni1(1)   1,   2,   0)
--------------------------------------------------------------------------------
J3 contains 6 bonds
Isotropic exchange:   -2.3033
Full exchange matrix:
    -2.2989   0.0118   0.0356
    -0.0111  -2.2992   0.0133
    -0.0356  -0.0120  -2.3119
Symmetric anisotropic exchange:
     0.0044   0.0003   0.0000
     0.0003   0.0041   0.0007
     0.0000   0.0007  -0.0086
DMI module:
    0.0395
|DMI| / |J_iso|:
    0.0171
DMI vectors:
     0.0126  -0.0356   0.0114   (Ni1(1) Ni1(1)  -2,   0,   0)
    -0.0126   0.0356  -0.0114   (Ni1(1) Ni1(1)   2,   0,   0)
    -0.0251   0.0289   0.0095   (Ni1(1) Ni1(1)  -2,  -2,   0)
     0.0193  -0.0344   0.0006   (Ni1(1) Ni1(1)   0,  -2,   0)
    -0.0193   0.0344  -0.0006   (Ni1(1) Ni1(1)   0,   2,   0)
     0.0251  -0.0289  -0.0095   (Ni1(1) Ni1(1)   2,   2,   0)
================================================================================

In the second case exchange summary is printed for every bond in the Hamiltonian. Hamiltonian is filtered with the --max-distance, --min-distance and --template-file.

rad-extract-tb2j.py -if exchange.out -tf template.txt -on summary.txt
summary without forced symmetry
================================================================================
    ██████╗  █████╗ ██████╗       ████████╗ █████╗  █████╗ ██╗      ██████╗     
    ██╔══██╗██╔══██╗██╔══██╗      ╚══██╔══╝██╔══██╗██╔══██╗██║     ██╔════╝     
    ██████╔╝███████║██║  ██║█████╗   ██║   ██║  ██║██║  ██║██║     ╚═█████╗     
    ██╔══██╗██╔══██║██║  ██║╚════╝   ██║   ██║  ██║██║  ██║██║       ╚══██║     
    ██║  ██║██║  ██║██████╔╝         ██║   ╚█████╔╝╚█████╔╝███████╗██████╔╝     
    ╚═╝  ╚═╝╚═╝  ╚═╝╚═════╝          ╚═╝    ╚════╝  ╚════╝ ╚══════╝╚═════╝      
                          Version: 0.8.3                        ▄   ▄           
                   Documentation: rad-tools.org                 █▀█▀█           
                  Release date: 14 September 2023               █▄█▄█           
        Git hash: 5b4dc9b04aecb7efebb9cd710c02e0ad7fb68e44       ███   ▄▄       
                        Licence: GNU GPLv3                       ████ █  █      
                                                                 ████    █      
             Generated on 20 September 2023 at 2:22:4            ▀▀▀▀▀▀▀▀       
Exchange values are extracted from:
/Users/rybakov.ad/Codes/rad-tools/docs/examples/rad-extract-tb2j/exchange.out
Template used for filtering:
/Users/rybakov.ad/Codes/rad-tools/docs/examples/rad-extract-tb2j/template.txt
================================================================================
Primitive unit cell:
      x          y           z     
 3.89500000  0.00000000 0.00000000 
 -1.94700000 3.37300000 0.00000000 
 0.00000000  0.00000000 24.47800000
================================================================================
Atoms:
 Index Name  a1 (rel)   a2 (rel)   a3 (rel)       x          y           z     
 1     Ni1  0.00000285 0.01808479 0.49999183 -0.03520000 0.06100000 12.23880000
 2     I1   0.33328319 0.66252594 0.56152872 0.00820000  2.23470000 13.74510000
 3     I2   0.66662375 0.32917284 0.43845085 1.95560000  1.11030000 10.73240000
================================================================================
Magnetic moments of magnetic atoms:
 Index Name     m_x         m_y        m_z    
 1     Ni1  -0.00010000 -0.00010000 1.43680000
================================================================================
Notation of Hamiltonian:
(True, True, -1.0)
H = - \sum_{i,j} e_i J_{ij} e_j
Double counting is present.
Spin vectors are normalized to 1.
================================================================================
Spin Hamiltonian:
Atom1  Atom2  (  i,   j,   k)  J_iso   Distance
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  0,  -1,   0)  0.1354   3.8946 
Full exchange matrix:
    -0.1153  -0.2164   0.3256
    -0.2176   0.3967   0.1959
     0.2724   0.1661   0.1247
Symmetric anisotropic exchange:
    -0.2507  -0.2170   0.2990
    -0.2170   0.2613   0.1810
     0.2990   0.1810  -0.0107
DMI module:
    0.0305
|DMI| / |J_iso|:
    0.2253
DMI vector:
     0.0149  -0.0266   0.0006
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  0,   1,   0)  0.1354   3.8946 
Full exchange matrix:
    -0.1153  -0.2176   0.2724
    -0.2164   0.3967   0.1661
     0.3256   0.1959   0.1247
Symmetric anisotropic exchange:
    -0.2507  -0.2170   0.2990
    -0.2170   0.2613   0.1810
     0.2990   0.1810  -0.0107
DMI module:
    0.0305
|DMI| / |J_iso|:
    0.2253
DMI vector:
    -0.0149   0.0266  -0.0006
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  1,   0,   0)  0.1261   3.8950 
Full exchange matrix:
     0.5708   0.1127  -0.2509
    -0.1127  -0.4622  -0.3343
     0.2509  -0.2957   0.2698
Symmetric anisotropic exchange:
     0.4447   0.0000   0.0000
     0.0000  -0.5883  -0.3150
     0.0000  -0.3150   0.1437
DMI module:
    0.2757
|DMI| / |J_iso|:
    2.1860
DMI vector:
    -0.0193   0.2509   0.1127
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -1,   0,   0)  0.1261   3.8950 
Full exchange matrix:
     0.5708  -0.1127   0.2509
     0.1127  -0.4622  -0.2957
    -0.2509  -0.3343   0.2698
Symmetric anisotropic exchange:
     0.4447   0.0000   0.0000
     0.0000  -0.5883  -0.3150
     0.0000  -0.3150   0.1437
DMI module:
    0.2757
|DMI| / |J_iso|:
    2.1860
DMI vector:
     0.0193  -0.2509  -0.1127
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  1,   1,   0)  0.1043   3.8951 
Full exchange matrix:
    -0.2054   0.3404  -0.1580
     0.0976   0.3106   0.3290
    -0.4400  -0.0850   0.2076
Symmetric anisotropic exchange:
    -0.3097   0.2190  -0.2990
     0.2190   0.2063   0.1220
    -0.2990   0.1220   0.1033
DMI module:
    0.2783
|DMI| / |J_iso|:
    2.6694
DMI vector:
     0.2070  -0.1410   0.1214
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -1,  -1,   0)  0.1043   3.8951 
Full exchange matrix:
    -0.2054   0.0976  -0.4400
     0.3404   0.3106  -0.0850
    -0.1580   0.3290   0.2076
Symmetric anisotropic exchange:
    -0.3097   0.2190  -0.2990
     0.2190   0.2063   0.1220
    -0.2990   0.1220   0.1033
DMI module:
    0.2783
|DMI| / |J_iso|:
    2.6694
DMI vector:
    -0.2070   0.1410  -0.1214
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  1,  -1,   0)  0.0158   6.7458 
Full exchange matrix:
     0.0411   0.0264  -0.0277
    -0.0304   0.0381   0.0128
     0.0237  -0.0128  -0.0319
Symmetric anisotropic exchange:
     0.0253  -0.0020  -0.0020
    -0.0020   0.0223   0.0000
    -0.0020   0.0000  -0.0477
DMI module:
    0.0404
|DMI| / |J_iso|:
    2.5614
DMI vector:
     0.0128   0.0257   0.0284
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -1,   1,   0)  0.0158   6.7458 
Full exchange matrix:
     0.0411  -0.0304   0.0237
     0.0264   0.0381  -0.0128
    -0.0277   0.0128  -0.0319
Symmetric anisotropic exchange:
     0.0253  -0.0020  -0.0020
    -0.0020   0.0223   0.0000
    -0.0020   0.0000  -0.0477
DMI module:
    0.0404
|DMI| / |J_iso|:
    2.5614
DMI vector:
    -0.0128  -0.0257  -0.0284
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -1,  -2,   0)  0.0161   6.7460 
Full exchange matrix:
     0.0368  -0.0287  -0.0015
     0.0287   0.0428  -0.0311
     0.0015   0.0251  -0.0312
Symmetric anisotropic exchange:
     0.0207   0.0000   0.0000
     0.0000   0.0267  -0.0030
     0.0000  -0.0030  -0.0473
DMI module:
    0.0402
|DMI| / |J_iso|:
    2.4914
DMI vector:
    -0.0281   0.0015  -0.0287
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  1,   2,   0)  0.0161   6.7460 
Full exchange matrix:
     0.0368   0.0287   0.0015
    -0.0287   0.0428   0.0251
    -0.0015  -0.0311  -0.0312
Symmetric anisotropic exchange:
     0.0207   0.0000   0.0000
     0.0000   0.0267  -0.0030
     0.0000  -0.0030  -0.0473
DMI module:
    0.0402
|DMI| / |J_iso|:
    2.4914
DMI vector:
     0.0281  -0.0015   0.0287
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  2,   1,   0)  0.0110   6.7467 
Full exchange matrix:
     0.0367   0.0618  -0.0003
    -0.0578   0.0347   0.0041
     0.0043  -0.0021  -0.0383
Symmetric anisotropic exchange:
     0.0257   0.0020   0.0020
     0.0020   0.0237   0.0010
     0.0020   0.0010  -0.0493
DMI module:
    0.0599
|DMI| / |J_iso|:
    5.4312
DMI vector:
     0.0031   0.0023   0.0598
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -2,  -1,   0)  0.0110   6.7467 
Full exchange matrix:
     0.0367  -0.0578   0.0043
     0.0618   0.0347  -0.0021
    -0.0003   0.0041  -0.0383
Symmetric anisotropic exchange:
     0.0257   0.0020   0.0020
     0.0020   0.0237   0.0010
     0.0020   0.0010  -0.0493
DMI module:
    0.0599
|DMI| / |J_iso|:
    5.4312
DMI vector:
    -0.0031  -0.0023  -0.0598
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  0,  -2,   0) -2.2810   7.7892 
Full exchange matrix:
    -2.2827  -0.0076   0.0403
    -0.0084  -2.2637   0.0236
    -0.0083  -0.0036  -2.2967
Symmetric anisotropic exchange:
    -0.0017  -0.0080   0.0160
    -0.0080   0.0173   0.0100
     0.0160   0.0100  -0.0157
DMI module:
    0.0278
|DMI| / |J_iso|:
    0.0122
DMI vector:
     0.0136  -0.0243   0.0004
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  0,   2,   0) -2.2810   7.7892 
Full exchange matrix:
    -2.2827  -0.0084  -0.0083
    -0.0076  -2.2637  -0.0036
     0.0403   0.0236  -2.2967
Symmetric anisotropic exchange:
    -0.0017  -0.0080   0.0160
    -0.0080   0.0173   0.0100
     0.0160   0.0100  -0.0157
DMI module:
    0.0278
|DMI| / |J_iso|:
    0.0122
DMI vector:
    -0.0136   0.0243  -0.0004
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  2,   0,   0) -2.3130   7.7900 
Full exchange matrix:
    -2.2927  -0.0131  -0.0408
     0.0131  -2.3297  -0.0325
     0.0408  -0.0035  -2.3167
Symmetric anisotropic exchange:
     0.0203   0.0000   0.0000
     0.0000  -0.0167  -0.0180
     0.0000  -0.0180  -0.0037
DMI module:
    0.0452
|DMI| / |J_iso|:
    0.0196
DMI vector:
    -0.0145   0.0408  -0.0131
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -2,   0,   0) -2.3130   7.7900 
Full exchange matrix:
    -2.2927   0.0131   0.0408
    -0.0131  -2.3297  -0.0035
    -0.0408  -0.0325  -2.3167
Symmetric anisotropic exchange:
     0.0203   0.0000   0.0000
     0.0000  -0.0167  -0.0180
     0.0000  -0.0180  -0.0037
DMI module:
    0.0452
|DMI| / |J_iso|:
    0.0196
DMI vector:
     0.0145  -0.0408   0.0131
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) ( -2,  -2,   0) -2.3160   7.7902 
Full exchange matrix:
    -2.3213   0.0199  -0.0492
    -0.0019  -2.3043  -0.0188
     0.0172   0.0388  -2.3223
Symmetric anisotropic exchange:
    -0.0053   0.0090  -0.0160
     0.0090   0.0117   0.0100
    -0.0160   0.0100  -0.0063
DMI module:
    0.0453
|DMI| / |J_iso|:
    0.0196
DMI vector:
    -0.0288   0.0332   0.0109
--------------------------------------------------------------------------------
Ni1(1) Ni1(1) (  2,   2,   0) -2.3160   7.7902 
Full exchange matrix:
    -2.3213  -0.0019   0.0172
     0.0199  -2.3043   0.0388
    -0.0492  -0.0188  -2.3223
Symmetric anisotropic exchange:
    -0.0053   0.0090  -0.0160
     0.0090   0.0117   0.0100
    -0.0160   0.0100  -0.0063
DMI module:
    0.0453
|DMI| / |J_iso|:
    0.0196
DMI vector:
     0.0288  -0.0332  -0.0109
================================================================================

Arguments#

-if, --input-filename#

Relative or absolute path to the "exchange.out" file, including the name and extension of the file itself.

required
type: str

-tf, --template-file#

Relative or absolute path to the template file, including the name and extension of the file.

optional
type: str

-on, --output-name#

Name of the output files.

If this parameter is not specified, the result is printed in the standard output stream.

optional
type: str

-d, --decimals#

Decimals after the comma for the exchange values.

default: 4
type: int

Changed in version 0.5.17: Renamed from -acc/--accuracy.

-fm, --form-model#

Whether to form the model from the template.

default: False
type: bool

Changed in version 0.8.0: Renamed from -fs/--force-symmetry.

-noa, --no-anisotropic#

Whether to output anisotropic exchange.

default: False
type: bool

Changed in version 0.8.0: Renamed from -a/--anisotropic.

-nom, --no-matrix#

Whether to output whole matrix exchange.

default: False
type: bool

Changed in version 0.8.0: Renamed from -m/--matrix.

-nodmi#

Whether to output DMI exchange.

default: False
type: bool

Changed in version 0.8.0: Renamed from -dmi.

-v, --verbose#

Verbose output, propagates to the called methods.

default: False
type: bool

-maxd, --max-distance#

(<=) Maximum distance.

All the bonds with the distance between atom 1 and atom 2 greater than maximum distance are excluded from the model.

optional
type: float

New in version 0.8.0.

-mind, --min-distance#

(>=) Minimum distance.

All the bonds with the distance between atom 1 and atom 2 lower than minimum distance are excluded from the Hamiltonian.

optional
type: float

New in version 0.8.0.