Skip to content

Importing Magnetic Structures

Tobias Weber (Institut Laue-Langevin) edited this page Jul 3, 2024 · 12 revisions

Back to Contents.

If you have already created a magnetic model in another magnon calculation tool, you can alternatively try importing it using the table importer (select "Structure" -> "Import From Table..." in the menu):

  1. Paste the list of magnetic sites in the "Magnetic Sites Table" field and select the indices of the columns using the spin boxes above.
  2. Paste the list of magnetic couplings in the "Magnetic Couplings Table" field and also select the correct column indices.
  3. Click "Import Sites" and "Import Couplings" and verify that it has been correctly recognised.

Importing From SpinW

In SpinW these two lists can be generated using these commands (where sw_obj names the SpinW object):

sw_obj.table("atom")
sw_obj.table("bond", [], true)

Currently, you can use these column indices for importing SpinW tables (these may change at any time, though):

  • Sites: name=0, x=3, y=4, z=5, Sx=-1, Sy=-1, Sz=-1, |S|=2,
  • Couplings: name=-1, site1=10, site2=12, Δx=2, Δy=3, Δz=4, J=16, DMIx=25, DMIy=26, DMIz=27,
  • Options: 1-Based: checked, Unite Tokens: checked.

Importing From Sunny

In Sunny these two lists can be generated using this script (where magsys names the System object):

using Printf
import LinearAlgebra.norm2

site_idx = 1
@printf("# %6s %10s %10s %10s %10s %10s %10s %10s\n",
    "name", "x", "y", "z", "Sx", "Sy", "Sz", "|S|")
for (r, s) in zip(magsys.crystal.positions, magsys.dipoles)
    @printf(stderr, "%8d %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g %10.4g\n",
        site_idx, r[1], r[2], r[3], s[1], s[2], s[3], norm2(s))
    global site_idx += 1
end

term_idx = 1
@printf("\n# %6s %8s %8s %8s %8s %8s %10s %10s %10s %10s\n",
    "name", "site1", "site2", "dx", "dy", "dz", "J", "DMIx", "DMIy", "DMIz")
for interaction in magsys.interactions_union
    for p in interaction.pair
        J = 0.
        dmi = [ 0., 0., 0. ]

        if length(p.bilin) == 1
            J = p.bilin[1]
        elseif length(p.bilin) == 9
            J = p.bilin[1, 1]
            dmi[1] =  p.bilin[2, 3]
            dmi[2] = -p.bilin[1, 3]
            dmi[3] =  p.bilin[1, 2]
        end

        @printf(stderr, "%8d %8d %8d %8d %8d %8d %10.4g %10.4g %10.4g %10.4g\n",
            term_idx, p.bond.i, p.bond.j, p.bond.n[1], p.bond.n[2], p.bond.n[3],
            J, dmi[1], dmi[2], dmi[3])

        global term_idx += 1
    end
end

Please use these column indices for importing Sunny tables:

  • Sites: name=0, x=1, y=2, z=3, Sx=4, Sy=5, Sz=6, |S|=7,
  • Couplings: name=0, site1=1, site2=2, Δx=3, Δy=4, Δz=5, J=6, DMIx=7, DMIy=8, DMIz=9,
  • Options: 1-Based: checked, Unite Tokens: unchecked.