magnopy-lswt

This page explains how to use optimize spin direction via numerical minimization. See docs for magnopy-lswt for full list of supported arguments. On this page we give examples of how to use the script and text and files that it can produce.

Spin Hamiltonian and its source

This script works with the spin Hamiltonian that is coming from some third-party software. At the moment magnopy supports TB2J and GROGU.

Hint

There is a number of ways to use this script with the hand-made Hamiltonian:

  • Prepare the file that mimics the format of TB2J.

  • Prepare the file that mimics the GROGU file format.

  • Prepare the spin Hamiltonian programmatically and use the scenario of this command-line script from within your python script: magnopy.scenarios.optimize_sd().

Two parameters are required

  • Source of the spin Hamiltonian (--spinham-source);

  • Path to the file with the spin Hamiltonian (--spinham-filename)

For example, if "ferro-easy-axis.txt" is a file with the spin Hamiltonian and the source of the file is GROGU, then you can run the script as

Input files
magnopy-lswt --spinham-source GROGU --spinham-filename ferro-easy-axis.txt
Output to the console
     ███╗   ███╗  █████╗   ██████╗  ███╗   ██╗  ██████╗  ██████╗  ██╗   ██╗     
     ████╗ ████║ ██╔══██╗ ██╔════╝  ████╗  ██║ ██╔═══██╗ ██╔══██╗ ╚██╗ ██╔╝     
     ██╔████╔██║ ███████║ ██║  ███╗ ██╔██╗ ██║ ██║   ██║ ██████╔╝  ╚████╔╝      
     ██║╚██╔╝██║ ██╔══██║ ██║  ╚██║ ██║╚██╗██║ ██║   ██║ ██╔═══╝    ╚██╔╝       
     ██║ ╚═╝ ██║ ██║  ██║ ╚██████╔╝ ██║ ╚████║ ╚██████╔╝ ██║         ██║        
     ╚═╝     ╚═╝ ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═══╝  ╚═════╝  ╚═╝         ╚═╝        
                           Version: 0.4.3                       ▄   ▄           
                     Documentation: magnopy.org                 █▀█▀█           
                    Release date: 9 January 2026                █▄█▄█           
                         License: GNU GPLv3                      ███   ▄▄       
               Copyright (C) 2023-2026  Magnopy Team             ████ █  █      
                                                                 ████    █      
              Generated on 9 January 2026 at 17:39:49            ▀▀▀▀▀▀▀▀       

=================================== Comment ====================================

Executed the command

  /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/envs/latest/bin/magnopy-lswt --spinham-source GROGU --spinham-filename /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt -of /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results

which resulted in argument values

<< spinham_source       : GROGU
<< spinham_filename     : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
<< spin_directions      : None
<< magnetic_field       : None
<< output_folder        : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results
<< k_path               : None
<< kpoints              : None
<< relative             : False
<< spglib_symprec       : 1e-05
<< number_processors    : None
<< spin_values          : None
<< no_html              : False
<< hide_personal_data   : False
<< spglib_types         : None
<< make_sd_image        : None

Parameters are loaded from "GROGU", source file
<<< /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt

=============================== External effects ===============================

Magnetic flux density : None

======================= Optimization of spin directions ========================

Spin directions for the ground state are not given, attempt to optimize.

Energy tolerance      : 1.00000e-05 meV
Torque tolerance      : 1.00000e-05
Supercell             : 1 x 1 x 1 (original unit cell of the Hamiltonian)

Note: we recommend to obtain ground state outside of the magnopy-lswt program
and provide --spin-directions argument to it. See magnopy-optimize-sd, for
dedicated spin optimization of magnopy.
─────┬─────────────┬─────────────┬─────────────
step │     E_0     │  delta E_0  │ max torque 
─────┴─────────────┴─────────────┴─────────────
1       -3.0994541     0.0527579     0.0147363
2       -3.0996972     0.0002431     0.0109888
3       -3.1000000     0.0003028     0.0000103
4       -3.1000000     0.0000000     0.0000000
───────────────────────────────────────────────

================================= Ground state =================================

Order of the atoms and their spglib types are
Name spglib_type
Fe        1     

Directions of spin vectors of the ground state and spin values are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/SPIN_VECTORS.txt

Image of the spin directions is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/SPIN_DIRECTIONS.html

Classic energy of optimized state (E_0 = -3.100 meV) is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/E_0.txt

============================= K-points and k-path ==============================

Deducing k-points based on the crystal symmetry.
See wulfric.org for more details on procedure and conventions.

spglib_symprec  : 1.00000e-05.
Space group     : 221
Bravais lattice : cP
Convention      : HPKOT
K-path          : GAMMA-X-M-GAMMA-R-X|R-M

Full list of pre-defined high-symmetry points is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/HIGH-SYMMETRY_POINTS.txt

High-symmetry points and chosen k-path are plotted in
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/K-POINTS.html

Explicit list of k-points is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/K-POINTS.txt

===================================== LSWT =====================================


Correction to the classic ground state energy (E_2 = -3.100 meV) is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/E_2.txt

Coefficients before one-operator term are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/ONE_OPERATOR_TERMS.txt
(shall be zero if the ground state is correct)

##################################  WARNING  ###################################
#W Coefficients before the one-operator terms are not zero. It might indicate W#
#W that the ground state (spin directions) is not a ground state of the       W#
#W considered spin Hamiltonian and the results might not be meaningful. If    W#
#W O_alpha << 1 then the problem can also be numerical (due to the finite     W#
#W point arithmetic) and the results are just fine in that case. Contact      W#
#W developers if you are in doubts: magnopy.org.                              W#
###############################  END OF WARNING  ###############################


Start calculations over k-points ... Done

==================================== Output ====================================


Omegas are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/OMEGAS.txt
Deltas are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/DELTAS.txt
Plot is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/OMEGAS.png
Plot is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/1/magnopy-results/DELTAS.png

============================ Finished with WARNINGS ============================
Created files

Ground state

One need to know the ground state (i. e. spin directions for every spin of the Hamiltonian) for the calculation of the exited states. There are two ways for magnopy to know the spin directions

  • Input from the user

    User can provide a file with spin directions using the command

    Input files
    magnopy-lswt --spin-directions sd-ferro-easy-axis.txt --spinham-source GROGU --spinham-filename ferro-easy-axis.txt
    
    Output to the console
         ███╗   ███╗  █████╗   ██████╗  ███╗   ██╗  ██████╗  ██████╗  ██╗   ██╗     
         ████╗ ████║ ██╔══██╗ ██╔════╝  ████╗  ██║ ██╔═══██╗ ██╔══██╗ ╚██╗ ██╔╝     
         ██╔████╔██║ ███████║ ██║  ███╗ ██╔██╗ ██║ ██║   ██║ ██████╔╝  ╚████╔╝      
         ██║╚██╔╝██║ ██╔══██║ ██║  ╚██║ ██║╚██╗██║ ██║   ██║ ██╔═══╝    ╚██╔╝       
         ██║ ╚═╝ ██║ ██║  ██║ ╚██████╔╝ ██║ ╚████║ ╚██████╔╝ ██║         ██║        
         ╚═╝     ╚═╝ ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═══╝  ╚═════╝  ╚═╝         ╚═╝        
                               Version: 0.4.3                       ▄   ▄           
                         Documentation: magnopy.org                 █▀█▀█           
                        Release date: 9 January 2026                █▄█▄█           
                             License: GNU GPLv3                      ███   ▄▄       
                   Copyright (C) 2023-2026  Magnopy Team             ████ █  █      
                                                                     ████    █      
                  Generated on 9 January 2026 at 17:39:52            ▀▀▀▀▀▀▀▀       
    
    =================================== Comment ====================================
    
    Executed the command
    
      /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/envs/latest/bin/magnopy-lswt --spin-directions /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/sd-ferro-easy-axis.txt --spinham-source GROGU --spinham-filename /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt -of /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results
    
    which resulted in argument values
    
    << spinham_source       : GROGU
    << spinham_filename     : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    << spin_directions      : ['/home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/sd-ferro-easy-axis.txt']
    << magnetic_field       : None
    << output_folder        : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results
    << k_path               : None
    << kpoints              : None
    << relative             : False
    << spglib_symprec       : 1e-05
    << number_processors    : None
    << spin_values          : None
    << no_html              : False
    << hide_personal_data   : False
    << spglib_types         : None
    << make_sd_image        : None
    
    Parameters are loaded from "GROGU", source file
    <<< /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    
    =============================== External effects ===============================
    
    Magnetic flux density : None
    
    ================================= Ground state =================================
    
    Order of the atoms and their spglib types are
    Name spglib_type
    Fe        1     
    
    Directions of spin vectors of the ground state and spin values are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/SPIN_VECTORS.txt
    
    Image of the spin directions is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/SPIN_DIRECTIONS.html
    
    Classic energy of optimized state (E_0 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/E_0.txt
    
    ============================= K-points and k-path ==============================
    
    Deducing k-points based on the crystal symmetry.
    See wulfric.org for more details on procedure and conventions.
    
    spglib_symprec  : 1.00000e-05.
    Space group     : 221
    Bravais lattice : cP
    Convention      : HPKOT
    K-path          : GAMMA-X-M-GAMMA-R-X|R-M
    
    Full list of pre-defined high-symmetry points is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/HIGH-SYMMETRY_POINTS.txt
    
    High-symmetry points and chosen k-path are plotted in
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/K-POINTS.html
    
    Explicit list of k-points is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/K-POINTS.txt
    
    ===================================== LSWT =====================================
    
    
    Correction to the classic ground state energy (E_2 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/E_2.txt
    
    Coefficients before one-operator term are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/ONE_OPERATOR_TERMS.txt
    (shall be zero if the ground state is correct)
    
    Start calculations over k-points ... Done
    
    ==================================== Output ====================================
    
    
    Omegas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/OMEGAS.txt
    Deltas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/DELTAS.txt
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/OMEGAS.png
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/2/magnopy-results/DELTAS.png
    
    ================================= Finished OK ==================================
    
    Created files
  • Internal optimization

    If user do not provide any input, then magnopy tries to optimize spin directions within unit cell. See also magnopy-optimize-sd.

K-path and k-points

Magnopy solves magnon problem for a set of points in reciprocal space. Therefore, it needs to know a set of k-points to perform the calculations. User is left with two options

  • --kpoints

    Provide explicit list of k-points

    Input files
    magnopy-lswt --kpoints k-points-ferro-easy-axis.txt --relative --spinham-source GROGU --spinham-filename ferro-easy-axis.txt
    
    Output to the console
         ███╗   ███╗  █████╗   ██████╗  ███╗   ██╗  ██████╗  ██████╗  ██╗   ██╗     
         ████╗ ████║ ██╔══██╗ ██╔════╝  ████╗  ██║ ██╔═══██╗ ██╔══██╗ ╚██╗ ██╔╝     
         ██╔████╔██║ ███████║ ██║  ███╗ ██╔██╗ ██║ ██║   ██║ ██████╔╝  ╚████╔╝      
         ██║╚██╔╝██║ ██╔══██║ ██║  ╚██║ ██║╚██╗██║ ██║   ██║ ██╔═══╝    ╚██╔╝       
         ██║ ╚═╝ ██║ ██║  ██║ ╚██████╔╝ ██║ ╚████║ ╚██████╔╝ ██║         ██║        
         ╚═╝     ╚═╝ ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═══╝  ╚═════╝  ╚═╝         ╚═╝        
                               Version: 0.4.3                       ▄   ▄           
                         Documentation: magnopy.org                 █▀█▀█           
                        Release date: 9 January 2026                █▄█▄█           
                             License: GNU GPLv3                      ███   ▄▄       
                   Copyright (C) 2023-2026  Magnopy Team             ████ █  █      
                                                                     ████    █      
                  Generated on 9 January 2026 at 17:39:54            ▀▀▀▀▀▀▀▀       
    
    =================================== Comment ====================================
    
    Executed the command
    
      /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/envs/latest/bin/magnopy-lswt --kpoints /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/k-points-ferro-easy-axis.txt --relative --spinham-source GROGU --spinham-filename /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt -of /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results
    
    which resulted in argument values
    
    << spinham_source       : GROGU
    << spinham_filename     : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    << spin_directions      : None
    << magnetic_field       : None
    << output_folder        : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results
    << k_path               : None
    << kpoints              : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/k-points-ferro-easy-axis.txt
    << relative             : True
    << spglib_symprec       : 1e-05
    << number_processors    : None
    << spin_values          : None
    << no_html              : False
    << hide_personal_data   : False
    << spglib_types         : None
    << make_sd_image        : None
    
    Parameters are loaded from "GROGU", source file
    <<< /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    
    =============================== External effects ===============================
    
    Magnetic flux density : None
    
    ======================= Optimization of spin directions ========================
    
    Spin directions for the ground state are not given, attempt to optimize.
    
    Energy tolerance      : 1.00000e-05 meV
    Torque tolerance      : 1.00000e-05
    Supercell             : 1 x 1 x 1 (original unit cell of the Hamiltonian)
    
    Note: we recommend to obtain ground state outside of the magnopy-lswt program
    and provide --spin-directions argument to it. See magnopy-optimize-sd, for
    dedicated spin optimization of magnopy.
    ─────┬─────────────┬─────────────┬─────────────
    step │     E_0     │  delta E_0  │ max torque 
    ─────┴─────────────┴─────────────┴─────────────
    1       -3.0992420     0.0854398     0.0173467
    2       -3.0999985     0.0007565     0.0007791
    3       -3.1000000     0.0000015     0.0000041
    ───────────────────────────────────────────────
    
    ================================= Ground state =================================
    
    Order of the atoms and their spglib types are
    Name spglib_type
    Fe        1     
    
    Directions of spin vectors of the ground state and spin values are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/SPIN_VECTORS.txt
    
    Image of the spin directions is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/SPIN_DIRECTIONS.html
    
    Classic energy of optimized state (E_0 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/E_0.txt
    
    ============================= K-points and k-path ==============================
    
    K-points are provided by user.
    
    Explicit list of k-points is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/K-POINTS.txt
    
    ===================================== LSWT =====================================
    
    
    Correction to the classic ground state energy (E_2 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/E_2.txt
    
    Coefficients before one-operator term are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/ONE_OPERATOR_TERMS.txt
    (shall be zero if the ground state is correct)
    
    ##################################  WARNING  ###################################
    #W Coefficients before the one-operator terms are not zero. It might indicate W#
    #W that the ground state (spin directions) is not a ground state of the       W#
    #W considered spin Hamiltonian and the results might not be meaningful. If    W#
    #W O_alpha << 1 then the problem can also be numerical (due to the finite     W#
    #W point arithmetic) and the results are just fine in that case. Contact      W#
    #W developers if you are in doubts: magnopy.org.                              W#
    ###############################  END OF WARNING  ###############################
    
    
    Start calculations over k-points ... Done
    
    ==================================== Output ====================================
    
    
    Omegas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/OMEGAS.txt
    Deltas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/DELTAS.txt
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/OMEGAS.png
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/3/magnopy-results/DELTAS.png
    
    ============================ Finished with WARNINGS ============================
    
    Created files
  • --k-path

    Let magnopy deduce the set of high-symmetry points based on the space group of the crystal and use recommended k-path (see documentation of wulfric for more details, magnopy uses convention="HPKOT"). User can control k-path, but limited to the list of the predefined high-symmetry points.

    Input files
    magnopy-lswt --k-path GAMMA-X-S|GAMMA-Y --spinham-source GROGU --spinham-filename ferro-easy-axis.txt
    
    Output to the console
         ███╗   ███╗  █████╗   ██████╗  ███╗   ██╗  ██████╗  ██████╗  ██╗   ██╗     
         ████╗ ████║ ██╔══██╗ ██╔════╝  ████╗  ██║ ██╔═══██╗ ██╔══██╗ ╚██╗ ██╔╝     
         ██╔████╔██║ ███████║ ██║  ███╗ ██╔██╗ ██║ ██║   ██║ ██████╔╝  ╚████╔╝      
         ██║╚██╔╝██║ ██╔══██║ ██║  ╚██║ ██║╚██╗██║ ██║   ██║ ██╔═══╝    ╚██╔╝       
         ██║ ╚═╝ ██║ ██║  ██║ ╚██████╔╝ ██║ ╚████║ ╚██████╔╝ ██║         ██║        
         ╚═╝     ╚═╝ ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═══╝  ╚═════╝  ╚═╝         ╚═╝        
                               Version: 0.4.3                       ▄   ▄           
                         Documentation: magnopy.org                 █▀█▀█           
                        Release date: 9 January 2026                █▄█▄█           
                             License: GNU GPLv3                      ███   ▄▄       
                   Copyright (C) 2023-2026  Magnopy Team             ████ █  █      
                                                                     ████    █      
                  Generated on 9 January 2026 at 17:39:56            ▀▀▀▀▀▀▀▀       
    
    =================================== Comment ====================================
    
    Executed the command
    
      /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/envs/latest/bin/magnopy-lswt --k-path GAMMA-X-S|GAMMA-Y --spinham-source GROGU --spinham-filename /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt -of /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results
    
    which resulted in argument values
    
    << spinham_source       : GROGU
    << spinham_filename     : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    << spin_directions      : None
    << magnetic_field       : None
    << output_folder        : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results
    << k_path               : GAMMA-X-S|GAMMA-Y
    << kpoints              : None
    << relative             : False
    << spglib_symprec       : 1e-05
    << number_processors    : None
    << spin_values          : None
    << no_html              : False
    << hide_personal_data   : False
    << spglib_types         : None
    << make_sd_image        : None
    
    Parameters are loaded from "GROGU", source file
    <<< /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
    
    =============================== External effects ===============================
    
    Magnetic flux density : None
    
    ======================= Optimization of spin directions ========================
    
    Spin directions for the ground state are not given, attempt to optimize.
    
    Energy tolerance      : 1.00000e-05 meV
    Torque tolerance      : 1.00000e-05
    Supercell             : 1 x 1 x 1 (original unit cell of the Hamiltonian)
    
    Note: we recommend to obtain ground state outside of the magnopy-lswt program
    and provide --spin-directions argument to it. See magnopy-optimize-sd, for
    dedicated spin optimization of magnopy.
    ─────┬─────────────┬─────────────┬─────────────
    step │     E_0     │  delta E_0  │ max torque 
    ─────┴─────────────┴─────────────┴─────────────
    1       -3.0999098     0.0776058     0.0060041
    2       -3.1000000     0.0000902     0.0000272
    3       -3.1000000     0.0000000     0.0000000
    ───────────────────────────────────────────────
    
    ================================= Ground state =================================
    
    Order of the atoms and their spglib types are
    Name spglib_type
    Fe        1     
    
    Directions of spin vectors of the ground state and spin values are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/SPIN_VECTORS.txt
    
    Image of the spin directions is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/SPIN_DIRECTIONS.html
    
    Classic energy of optimized state (E_0 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/E_0.txt
    
    ============================= K-points and k-path ==============================
    
    Deducing k-points based on the crystal symmetry.
    See wulfric.org for more details on procedure and conventions.
    
    spglib_symprec  : 1.00000e-05.
    Space group     : 221
    Bravais lattice : cP
    Convention      : HPKOT
    
    ##################################  WARNING  ###################################
    #W User-provided k-path contains undefined labels of high-symmetry points.    W#
    #W Pre-defined points are                                                     W#
    #W   - GAMMA                                                                  W#
    #W   - R                                                                      W#
    #W   - M                                                                      W#
    #W   - X                                                                      W#
    #W   - X1                                                                     W#
    #W Using recommended k-path instead.                                          W#
    ###############################  END OF WARNING  ###############################
    
    K-path          : GAMMA-X-M-GAMMA-R-X|R-M
    
    Full list of pre-defined high-symmetry points is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/HIGH-SYMMETRY_POINTS.txt
    
    High-symmetry points and chosen k-path are plotted in
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/K-POINTS.html
    
    Explicit list of k-points is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/K-POINTS.txt
    
    ===================================== LSWT =====================================
    
    
    Correction to the classic ground state energy (E_2 = -3.100 meV) is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/E_2.txt
    
    Coefficients before one-operator term are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/ONE_OPERATOR_TERMS.txt
    (shall be zero if the ground state is correct)
    
    ##################################  WARNING  ###################################
    #W Coefficients before the one-operator terms are not zero. It might indicate W#
    #W that the ground state (spin directions) is not a ground state of the       W#
    #W considered spin Hamiltonian and the results might not be meaningful. If    W#
    #W O_alpha << 1 then the problem can also be numerical (due to the finite     W#
    #W point arithmetic) and the results are just fine in that case. Contact      W#
    #W developers if you are in doubts: magnopy.org.                              W#
    ###############################  END OF WARNING  ###############################
    
    
    Start calculations over k-points ... Done
    
    ==================================== Output ====================================
    
    
    Omegas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/OMEGAS.txt
    Deltas are saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/DELTAS.txt
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/OMEGAS.png
    Plot is saved in file
    >>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/4/magnopy-results/DELTAS.png
    
    ============================ Finished with WARNINGS ============================
    
    Created files

External magnetic field

File with the spin Hamiltonian specifies interaction parameters that are intrinsic to the material.

In order to add external effects, for instance an external magnetic field one can use --magnetic-field parameter.

This parameter expects three numbers, that specify three Cartesian components of the external magnetic field (magnetic flux density, B). Values are interpreted in Tesla.

For example, use the command

Input files
magnopy-lswt --magnetic-field 1.7112 1.7112 0 --spinham-source GROGU --spinham-filename ferro-easy-axis.txt
Output to the console
     ███╗   ███╗  █████╗   ██████╗  ███╗   ██╗  ██████╗  ██████╗  ██╗   ██╗     
     ████╗ ████║ ██╔══██╗ ██╔════╝  ████╗  ██║ ██╔═══██╗ ██╔══██╗ ╚██╗ ██╔╝     
     ██╔████╔██║ ███████║ ██║  ███╗ ██╔██╗ ██║ ██║   ██║ ██████╔╝  ╚████╔╝      
     ██║╚██╔╝██║ ██╔══██║ ██║  ╚██║ ██║╚██╗██║ ██║   ██║ ██╔═══╝    ╚██╔╝       
     ██║ ╚═╝ ██║ ██║  ██║ ╚██████╔╝ ██║ ╚████║ ╚██████╔╝ ██║         ██║        
     ╚═╝     ╚═╝ ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═══╝  ╚═════╝  ╚═╝         ╚═╝        
                           Version: 0.4.3                       ▄   ▄           
                     Documentation: magnopy.org                 █▀█▀█           
                    Release date: 9 January 2026                █▄█▄█           
                         License: GNU GPLv3                      ███   ▄▄       
               Copyright (C) 2023-2026  Magnopy Team             ████ █  █      
                                                                 ████    █      
              Generated on 9 January 2026 at 17:39:59            ▀▀▀▀▀▀▀▀       

=================================== Comment ====================================

Executed the command

  /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/envs/latest/bin/magnopy-lswt --magnetic-field 1.7112 1.7112 0 --spinham-source GROGU --spinham-filename /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt -of /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results

which resulted in argument values

<< spinham_source       : GROGU
<< spinham_filename     : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt
<< spin_directions      : None
<< magnetic_field       : [1.7112, 1.7112, 0.0]
<< output_folder        : /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results
<< k_path               : None
<< kpoints              : None
<< relative             : False
<< spglib_symprec       : 1e-05
<< number_processors    : None
<< spin_values          : None
<< no_html              : False
<< hide_personal_data   : False
<< spglib_types         : None
<< make_sd_image        : None

Parameters are loaded from "GROGU", source file
<<< /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/resources/ferro-easy-axis.txt

=============================== External effects ===============================

Magnetic flux density : |1.71120, 1.71120, 0.00000| = 2.42000 Tesla

======================= Optimization of spin directions ========================

Spin directions for the ground state are not given, attempt to optimize.

Energy tolerance      : 1.00000e-05 meV
Torque tolerance      : 1.00000e-05
Supercell             : 1 x 1 x 1 (original unit cell of the Hamiltonian)

Note: we recommend to obtain ground state outside of the magnopy-lswt program
and provide --spin-directions argument to it. See magnopy-optimize-sd, for
dedicated spin optimization of magnopy.
─────┬─────────────┬─────────────┬─────────────
step │     E_0     │  delta E_0  │ max torque 
─────┴─────────────┴─────────────┴─────────────
1       -3.2251956     0.0346272     0.1492693
2       -3.2751744     0.0499788     0.0312509
3       -3.2790727     0.0038983     0.0136345
4       -3.2801348     0.0010621     0.0019277
5       -3.2801579     0.0000231     0.0000629
6       -3.2801579     0.0000000     0.0000004
───────────────────────────────────────────────

================================= Ground state =================================

Order of the atoms and their spglib types are
Name spglib_type
Fe        1     

Directions of spin vectors of the ground state and spin values are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/SPIN_VECTORS.txt

Image of the spin directions is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/SPIN_DIRECTIONS.html

Classic energy of optimized state (E_0 = -3.280 meV) is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/E_0.txt

============================= K-points and k-path ==============================

Deducing k-points based on the crystal symmetry.
See wulfric.org for more details on procedure and conventions.

spglib_symprec  : 1.00000e-05.
Space group     : 221
Bravais lattice : cP
Convention      : HPKOT
K-path          : GAMMA-X-M-GAMMA-R-X|R-M

Full list of pre-defined high-symmetry points is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/HIGH-SYMMETRY_POINTS.txt

High-symmetry points and chosen k-path are plotted in
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/K-POINTS.html

Explicit list of k-points is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/K-POINTS.txt

===================================== LSWT =====================================


Correction to the classic ground state energy (E_2 = -3.140 meV) is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/E_2.txt

Coefficients before one-operator term are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/ONE_OPERATOR_TERMS.txt
(shall be zero if the ground state is correct)

##################################  WARNING  ###################################
#W Coefficients before the one-operator terms are not zero. It might indicate W#
#W that the ground state (spin directions) is not a ground state of the       W#
#W considered spin Hamiltonian and the results might not be meaningful. If    W#
#W O_alpha << 1 then the problem can also be numerical (due to the finite     W#
#W point arithmetic) and the results are just fine in that case. Contact      W#
#W developers if you are in doubts: magnopy.org.                              W#
###############################  END OF WARNING  ###############################


Start calculations over k-points ... Done

==================================== Output ====================================


Omegas are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/OMEGAS.txt
Deltas are saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/DELTAS.txt
Plot is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/OMEGAS.png
Plot is saved in file
>>> /home/docs/checkouts/readthedocs.org/user_builds/magnopy-tutorials/checkouts/latest/docs/source/master-tutorial/2_black-box/prompt-run_plot-2-lswt/5/magnopy-results/DELTAS.png

============================ Finished with WARNINGS ============================
Created files

to add magnetic field of \(2.42\) Tesla along the direction \((1, 1, 0)\) (i.e. in the \(xy\) plane, right in between the \(x\) and \(y\) axis).

Total running time of the script: (0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery