Calculate magnetic parameters

grogupy is specifically written in a modular way, to fully take advantage of python classes. In this simple example we show how to use grogupy to simulate the magnetic interaction between two atoms from a density functional theory (DFT) calculation and create an output file for magnopy. In this example we will use a non-collinear Siesta calculation of the Fe3GeTe2 system with spin-orbit coupling.

First import grogupy, which will import the most important classes, functions and variables in its namespace.

[1]:
import grogupy
/Users/danielpozsar/Documents/studies/elte/phd/grogu/.venv/lib/python3.12/site-packages/grogupy/_tqdm.py:24: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from tqdm.autonotebook import tqdm

Then we start to create the basic classes based on the desired parameters. First create the Kspace class which contains the parameters fot the Brillouin zone integration. Because in this case we only take a single layer of Fe3GeTe2 and there is a large vacuum in the perpendicular direction it is sufficient to only integrate in the plane of the material. Furthermore for a fast initial calculation a 10x10 grid of k-points should be enough.

[2]:
Fe3GeTe2_kspace = grogupy.Kspace(kset=[10, 10, 1])
Fe3GeTe2_kspace
[2]:
<grogupy.Kspace kset=[10 10  1], NK=100>

Then we would like to set the parameters for the complex integral for the Green’s function calculation. This can be done through the Contour class. Again, for an initial calculation 300 sample points should be enough. The energy minimum should be set below the smallest eigenvalue from the Siesta Hamiltonian.

[3]:
Fe3GeTe2_contour = grogupy.Contour(emin=-15, eset=300, esetp=10000)
Fe3GeTe2_contour
[3]:
<grogupy.Contour emin=-20, emax=0, eset=300, esetp=10000>

Then we can create the Hamiltonian class, which extracts and stores the Hamiltonian and geometrical data from the Siesta files using the sisl library. Furthermore we must provide the exchange field orientation in the DFT calculation, which is usually the perpendicular direction from the 2D material.

[4]:
Fe3GeTe2_hamiltonian = grogupy.Hamiltonian(
    infile="./../../../../benchmarks/Fe3GeTe2/Fe3GeTe2.fdf",
    scf_xcf_orientation=[0, 0, 1],
)
Fe3GeTe2_hamiltonian
Spin box Hamiltonian: 100%|██████████| 81/81 [00:00<00:00, 1069.66it/s]
Spin box Overlap matrix: 100%|██████████| 81/81 [00:00<00:00, 1321.54it/s]
Symmetrize Hamiltonian: 100%|██████████| 81/81 [00:00<00:00, 1976.28it/s]
Transpose Hamiltonian: 100%|██████████| 81/81 [00:00<00:00, 1427.03it/s]
Calculate V_XCF: 100%|██████████| 81/81 [00:00<00:00, 6452.04it/s]
Calculate H_XC: 100%|██████████| 3/3 [00:00<00:00, 58.30it/s]
[4]:
<grogupy.Hamiltonian scf_xcf_orientation=[0 0 1], orientation=[0, 0, 1], NO=84>

After these initial steps we can create the Builder class and initialize with the above information. We have to provide the directions of the rotated exchange field and the two perpendicular directions are calculated automatically.

[5]:
orientations = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

Fe3GeTe2 = grogupy.Builder(ref_xcf_orientations=orientations)
Fe3GeTe2.add_kspace(Fe3GeTe2_kspace)
Fe3GeTe2.add_contour(Fe3GeTe2_contour)
Fe3GeTe2.add_hamiltonian(Fe3GeTe2_hamiltonian)
Fe3GeTe2
[5]:
<grogupy.Builder npairs=0, numk=100, kset=[10 10  1], eset=300>

Then we have to define the magnetic entities, which can be a list of orbitals from the Siesta Hamiltonian. We use sisl functions to extract this information based on a more human like definition. For example take two shells from two Fe atoms.

[6]:
magnetic_entities = [dict(atom=3, l=2), dict(atom=4, l=2)]

With this information we can create two MagneticEntity instances.

[7]:
magnetic_entities = Fe3GeTe2.create_magnetic_entities(magnetic_entities)
Fe3GeTe2.add_magnetic_entities(magnetic_entities)
Add magnetic entities:: 100%|██████████| 2/2 [00:00<00:00, 73584.28it/s]

This would be enough to calculate the anisotropy on both sites, but it is not enough to build a spin model, for this we need the exchange tensor between all the pairs. Generally this can be done in a very similar way. First a list of dictionaries must be created, where each dictionary contains ai, aj and Ruc, where the first two is the index from the magnetic_entities and the third is the supercell shift of the second magnetic entity.

[8]:
pairs = [
    dict(ai=0, aj=1, Ruc=[0, 0, 0]),
    dict(ai=0, aj=1, Ruc=[1, 0, 0]),
]
pairs = Fe3GeTe2.create_pairs(pairs)
Fe3GeTe2.add_pairs(pairs)
Fe3GeTe2
Add pairs:: 100%|██████████| 2/2 [00:00<00:00, 76260.07it/s]
[8]:
<grogupy.Builder npairs=2, numk=100, kset=[10 10  1], eset=300>

Now every information is contained in the Fe3GeTe2 instance to run the simulation. There are multiple parameters that can be changed to tune the runtime and the precision of the simulation, but for now let us use the default parameters.

[9]:
Fe3GeTe2.solve()
Rotating Exchange field: 100%|██████████| 3/3 [00:00<00:00, 55.40it/s]
Setup magnetic entities for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 1927.53it/s]
Setup pairs for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 871.18it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 2130.17it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 28532.68it/s]
Rotating Exchange field: 100%|██████████| 3/3 [00:00<00:00, 80.91it/s]
Setup magnetic entities for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 3289.65it/s]
Setup pairs for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 1695.01it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 16777.22it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 16545.58it/s]
Rotating Exchange field: 100%|██████████| 3/3 [00:00<00:00, 72.68it/s]
Setup magnetic entities for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 3274.24it/s]
Setup pairs for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 1545.72it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 11618.57it/s]
Setup perturbations for rotated hamiltonian: 100%|██████████| 2/2 [00:00<00:00, 17848.10it/s]
Parallel over k on CPU0:: 100%|██████████| 100/100 [02:46<00:00,  1.66s/it]
/Users/danielpozsar/Documents/studies/elte/phd/grogu/.venv/lib/python3.12/site-packages/grogupy/physics/utilities.py:534: UserWarning: This is experimenal!
  warnings.warn("This is experimenal!")
/Users/danielpozsar/Documents/studies/elte/phd/grogu/.venv/lib/python3.12/site-packages/grogupy/physics/utilities.py:676: UserWarning: This is experimenal!
  warnings.warn("This is experimenal!")

Now the instance parameters are filled with the data from the simulation, so we can output the information. We can print the instance Fe3GeTe2 to get the information of the run and the to_magnopy() method returns the results in magnopy’s input format.

[10]:
print(Fe3GeTe2)
================================================================================
grogupy version: 0.0.6
Input file: ./../../../../benchmarks/Fe3GeTe2/Fe3GeTe2.fdf
Spin mode: SPIN-ORBIT
================================================================================
SLURM job ID: Could not be determined.
Architecture: CPU
Number of nodes in the parallel cluster: 1
Parallelization is over: K
Solver used for Greens function calculation: Sequential
Solver used for Exchange tensor: Fit
Solver used for Anisotropy tensor: Fit
================================================================================
Cell [Ang]:
3.791001511088653242e+00 0.000000000000000000e+00 0.000000000000000000e+00
-1.895500755544326621e+00 3.283103614407953064e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 2.057000819825037041e+01
================================================================================
DFT axis: [0 0 1]
Quantization axis and perpendicular rotation directions:
[1. 0. 0.] --> [array([ 0.,  0., -1.]), array([0., 1., 0.])]
[0. 1. 0.] --> [array([1., 0., 0.]), array([ 0.,  0., -1.])]
[0. 0. 1.] --> [array([1., 0., 0.]), array([0., 1., 0.])]
================================================================================
Parameters for the Brillouin zone sampling:
Number of k points: 100
K points in each directions: [10 10  1]
Parameters for the contour integral:
Eset: 300
Esetp: 10000
Ebot: -20
Etop: 0
================================================================================

[11]:
print(Fe3GeTe2.to_magnopy(comments=False))
================================================================================
cell Angstrom
3.791001511088653242e+00 0.000000000000000000e+00 0.000000000000000000e+00
-1.895500755544326621e+00 3.283103614407953064e+00 0.000000000000000000e+00
0.000000000000000000e+00 0.000000000000000000e+00 2.057000819825037041e+01
================================================================================
atoms Angstrom
name    x       y       z       Sx      Sy      Sz      # Q
3Fe(l:2) 1.981762848288204e-06 -9.134332829322269e-08 11.653315176909826 6.447254726229378e-05 -0.0005169351977350883 2.011394399384453 # 8.523586381595468
4Fe(l:2) 1.990383996147767e-06 -1.089291427685217e-07 8.916695475519404 -6.171573052964394e-05 0.000512053681777345 2.0114468209146024 # 8.523557236125843
================================================================================
notation
double-counting True
spin-normalized True
exchange-factor 0.5
on-site-factor 1
================================================================================
exchange meV
--------------------------------------------------------------------------------
3Fe(l:2) 4Fe(l:2) 0 0 0 # distance [Ang]: 2.7366197013904223
isotropic -59.857164622795445
DMI 2.436840485000502 0.01418709278360666 4.3221778217174996e-08 # Dx Dy Dz
symmetric-anisotropy 7.4187042864392865 -17.166667476211693 7.711382751285248e-05 -0.015536801936790684 2.436405949442811 # Sxx Syy Sxy Sxz Syz
--------------------------------------------------------------------------------
3Fe(l:2) 4Fe(l:2) 1 0 0 # distance [Ang]: 4.675551295032514
isotropic -5.1235830389129795
DMI 2.693079093975049 1.1485165395532315 5.230905381213948 # Dx Dy Dz
symmetric-anisotropy 2.099656316341804 0.23386271393477462 5.230909275184261 -0.32939388937763386 2.693777191433832 # Sxx Syy Sxy Sxz Syz
--------------------------------------------------------------------------------
================================================================================
on-site meV
--------------------------------------------------------------------------------
3Fe(l:2)
0.4925035491237812 0.7867303057936291 0.0 -1.706336253929844e-05 0.0003915543700303195 -0.11774267220804471 # Kxx Kyy Kzz Kxy Kxz Kyz
--------------------------------------------------------------------------------
4Fe(l:2)
-0.1035880607295833 0.49094251806239514 0.0 -1.7641565031737205e-05 0.0003546238097714085 0.11921380077466687 # Kxx Kyy Kzz Kxy Kxz Kyz
--------------------------------------------------------------------------------
================================================================================

More information can be found in the Tutorials.