Announcement - New Release (0.4.3)

29 views
Skip to first unread message

Magnopy support

unread,
Jan 9, 2026, 12:43:31 PMJan 9
to Magnopy support
New version of magnopy has been published, see release notes for detailed description.

This release improves numerical stability and speed of LSWT calculations.

Best,
Developers of magnopy

Sergey S

unread,
Jan 26, 2026, 11:54:00 PMJan 26
to Magnopy support
Dear developers,

Sorry if I post in a wrong thread... I have a question on the AFM square lattice Heisenberg model simulations by magnopy. The cell and lattice are set up in the following way

cell = np.eye(3)
cell[1] = [0., 2., 0.]

atoms = dict( names=["Fe1", "Fe2"], positions=[[0.0, 0.0, 0.0], [0.0, 0.5, 0.0]], spins=[0.5, 0.5], g_factors=[1.0, 1.0],
# Different, to get correct high-symmetry points and k-path
spglib_types=[1, 2],
)

Hamiltonian is

# Choose a convention
convention = magnopy.Convention(multiple_counting=True, spin_normalized=False, c21=1, c22=1)

# Create an empty spin Hamiltonian
spinham = magnopy.SpinHamiltonian(cell=cell, atoms=atoms, convention=convention)

# Add a Heisenberg exchange interaction between nearest neighbors
parameter = magnopy.converter22.from_iso(iso=1.0) # Antiferromagnetic exchange

spinham.add_22(alpha=0, beta=0, nu=(0, 0, 0), parameter=parameter) #along x
spinham.add_22(alpha=1, beta=1, nu=(1, 0, 0), parameter=parameter) #along x
spinham.add_22(alpha=0, beta=1, nu=(0, 0, 0), parameter=parameter) #along y
spinham.add_22(alpha=1, beta=0, nu=(0, 1, 0), parameter=parameter) #along y

Then we try to  calculate E(k) along kx direction
lswt = magnopy.LSWT(spinham=spinham, spin_directions=[[0, 0, 1], [0, 0, -1]])
print(lswt.omega(k=[0.2, 0.0, 0], relative=True))

but get  
[nan, nan]

adding
spinham.add_22(alpha=0, beta=0, nu=(1, 0, 0), parameter=parameter) #along x
does not help

What is wrong with our setup?

Surprisingly the code works correctly if we do the same for ky:
print(lswt.omega(k=[0.0, 0.2, 0], relative=True))

since we get [1.1755705-6.16297582e-33j 1.1755705-1.10134748e-17j]

Thank you in advance!

yours,
Sergey

пятница, 9 января 2026 г. в 22:43:31 UTC+5, Magnopy support:

Magnopy support

unread,
Jan 27, 2026, 8:07:20 AMJan 27
to Magnopy support
Dear Sergey,

The issue is with the ground state.

The diagonalization of the Hamiltonian at the kx point fails because the "grand dynamical matrix" is not positive-definite. This can be checked with

GDM_x = lswt.GDM(k=[0.2, 0., 0.], relative=True)

try:
np.linalg.cholesky(GDM_x)
except np.linalg.LinAlgError:
print("GDM is not positive definite")

The ground state that is supplied to LSWT(...) have the same periodicity as the underlying lattice.

There are two atoms in the unit cell along y, therefore an AFM order is reproduced in that direction and the diagonalization works.

However, there is only one unique atom along the x direction in the unit cell, therefore, there is an FM order along x and the diagonalization fails.

The classical ground state of the Hamiltonian can be numerically obtain via minimisation (note that it is done on the supercell, to catch the non-commensurate ground state)

magnopy.scenarios.optimize_sd(spinham=spinham, supercell=(4,4,1), output_folder="optimisation_4_4_1")

which yields

Screenshot-1.png
To reproduce that ground state one needs to construct a 2x1x1 supercell (see make_supercell()) or use another unit cell with two atoms in it (see example below).

import numpy as np

import magnopy


cell = np.array([[1., 1, 0.],
[-1., 1, 0.],
[0., 0., 1.]])

atoms = dict(
names=["Fe1", "Fe2"],
positions=[[0., 0., 0.], [0.5, 0.5, 0.]],
spins=[0.5, 0.5],
g_factors=[1.0, 1.0],
# Different, to get correct high-symmetry points and k-path
spglib_types=[1, 2],
)

# Choose a convention
convention = magnopy.Convention(
multiple_counting=True, spin_normalized=False, c21=1, c22=1
)

# Create an empty spin Hamiltonian
spinham = magnopy.SpinHamiltonian(cell=cell, atoms=atoms, convention=convention)

# Add a Heisenberg exchange interaction between nearest neighbors
parameter = magnopy.converter22.from_iso(iso=1.0) # Antiferromagnetic exchange

# Same as "spinham.add_22(alpha=0, beta=0, nu=(1, 0, 0), parameter=parameter)" in original UC
spinham.add_22(alpha=0, beta=1, nu=(0, -1, 0), parameter=parameter) #along x

# Same as "spinham.add_22(alpha=1, beta=1, nu=(1, 0, 0), parameter=parameter)" in original UC
spinham.add_22(alpha=1, beta=0, nu=(1, 0, 0), parameter=parameter) #along x

# Same as "spinham.add_22(alpha=0, beta=1, nu=(0, 0, 0), parameter=parameter)" in original UC
spinham.add_22(alpha=0, beta=1, nu=(0, 0, 0), parameter=parameter) #along y

# Same as "spinham.add_22(alpha=1, beta=0, nu=(0, 1, 0), parameter=parameter)" in original UC
spinham.add_22(alpha=1, beta=0, nu=(1, 1, 0), parameter=parameter) #along y

lswt = magnopy.LSWT(spinham=spinham, spin_directions = [[0, 0, 1], [0, 0, -1]])


print(lswt.omega(k = [0.2*6.28318531, 0., 0.], relative=False)) # 0.2 along kx in relative (original UC)
print(lswt.omega(k = [0., 0.2*3.14159265, 0.], relative=False)) # 0.2 along ky in relative (original UC)

pe21, pe22 = magnopy.experimental.plot_spinham(spinham=spinham)

pe22.save("e-2D.html", axes_visible=False)


P. S. The line "spinham.add_22(alpha=0, beta=0, nu=(0, 0, 0), parameter=parameter) #along x" is potentially misleading (perhaps there will be a warning for that situation in the future versions of magnopy). If the idea was to add on-site anisotropy, then I recommend to use the function SpinHamiltonian.add_21() instead. If the idea was to add an exchange bond, then I suspect a typo, so the line should read as "spinham.add_22(alpha=0, beta=0, nu=(1, 0, 0), parameter=parameter) #along x".

One can always check what bonds the Hamiltonian contains with text

for alpha, beta, nu, _ in spinham.p22:
print(f"{alpha} -> {beta} at {nu}")

or graphics

pe21, pe22 = magnopy.experimental.plot_spinham(spinham=spinham)

pe22.save("e.html", axes_visible=False)

Here is the Hamiltonian from your example, it looks like it missing a bond for the atom #0 and there is a fictitious bond with the zero length. 
Screenshot-2.png

Best,
Andrey

Sergey S

unread,
Jan 27, 2026, 8:08:18 AMJan 27
to Magnopy support
Dear Andrey,

This was an extremely stupid mistake! Of course, one can do LSWT only on top of the correct ground state. I'm very sorry for bothering you with this stupid issue and thank you for different hints helping to figure out what was the problem. 

This was extremely useful, thank you indeed!

Sincerely yours,
Sergey 

вторник, 27 января 2026 г. в 18:07:20 UTC+5, Magnopy support:
Reply all
Reply to author
Forward
0 new messages