SunnySuite / Sunny.jl

Spin dynamics and generalization to SU(N) coherent states
Other
65 stars 19 forks source link

Support `minimize_energy!` for systems with vacancies #283

Open kbarros opened 4 weeks ago

kbarros commented 4 weeks ago

Minimal reproducer:

using Sunny

latvecs = lattice_vectors(1, 1, 10, 90, 90, 90)
cryst = Crystal(latvecs, [[0,0,0]])
sys = System(cryst, (10,10,1), [SpinInfo(1, S=1, g=2)], :dipole; seed=1)
sys2 = to_inhomogeneous(sys)

set_vacancy_at!(sys2, (1,1,1,1))
minimize_energy!(sys2) # AssertionError: n' * n ≈ 1

Bug reported by Lázaro Cabán Cabrera.

kbarros commented 2 weeks ago

@ddahlbom proposed the workaround:

sys.κs[site] = 0.001

which can be used in place of set_vacancy_at!(sys, site).