-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace KPM with Lanczos #339
base: main
Are you sure you want to change the base?
Conversation
2d43b9d
to
2f1c50e
Compare
Here is an example where floating point roundoff leads to a large error in the intensity. This happens very small energy modes lead to ill-conditioning. cryst = Sunny.bcc_crystal()
sys = System(cryst, [1 => Moment(; s=1, g=2)], :dipole; dims=(1, 1, 1))
sys = to_inhomogeneous(sys)
set_exchange_at!(sys, -1.0, (1, 1, 1, 1), (1, 1, 1, 2); offset=[0, 0, 0])
polarize_spins!(sys, [0, 0, 1])
energy_per_site(sys)
kernel = lorentzian(fwhm=0.2)
energies = range(0, 6, 1000)
qs = [[0.35, 0.35, 0]]
measure = ssf_custom((q, ssf) -> real(ssf[1, 1]), sys) # Sˣˣ(q,ω) only
swt = SpinWaveTheoryKPM(sys; measure, lanczos_iters=4, tol=1, regularization=1e-8)
res = intensities(swt, qs; energies, kernel)
swt0 = SpinWaveTheory(sys; measure, regularization=1e-8)
res0 = intensities(swt0, qs; energies, kernel)
lines(vec(res.data))
lines!(vec(res0.data)) Note that the blue curve is missing some intensity near zero energy. In this particular case, the magnetic cell consists of two sites and a single bond. The dynamical matrix has size 4×4. The two modes should energies of 2 and 0, slightly modified by the default regularization of D = Sunny.dynamical_matrix(swt.swt, Sunny.Vec3(only(qs)))
It = Diagonal([1, 1, -1, -1])
eigvals(It * D) # ±(2 + ϵ), ±ϵ However, there is an inversion ("particle-hole") symmetry in this problem that Lanczos doesn't exactly respect. Specifically, because A workaround for this specific problem could be to modify the Lanczos iterations to exactly respect inversion symmetry, e.g., following the algorithm in Fig. 4 of Grüning et al, Implementation and testing..., arXiv:1102.3909. However, other applications of LSWT will not have this exact inversion symmetry, and a general solution is lacking. One idea is to double the dimension of the matrix size by working with both wavevectors |
d7eab6a
to
d19ef07
Compare
f6da49e
to
4e506a5
Compare
The Lanczos algorithm promises these benefits relative to KPM:
Whereas KPM is susceptible to a loss of intensity near Goldstone modes, Lanczos seems to avoid this problem.(See below.)As currently implemented, Lanczos is currently slower than KPM per iteration. But many fewer iterations are required, so Lanczos still seems favorable in overall speed. And future optimizations may be possible, e.g., operating on multiple right-hand side vectors in parallel.
A possible disadvantage of Lanczos is the accumulation of numerical roundoff error (loss of orthogonality in basis vectors for the Krylov space), and the effects of this are harder to quantify. See https://arxiv.org/abs/2410.11090 for a modern mathematical review of the Lanczos method. A backward stability analysis, in Sec. 4, suggests that the instabilities of Lanczos are not catastrophic for the desired observables. Empirically, however, Lanczos can still exhibit severe artifacts in estimating the intensities of bands near zero energy (quantified in examples below). Note, however, that these are cases where KPM also fails.
Another consideration is that Lanczos requires direct diagonalization of a tridiagonal matrix. After$k$ Lanczos iterations, this cost should scale like $\mathcal{O}(k^2)$ , which may dominate if $k$ sufficiently large.