1D XYZ Chain
Example calculation of the lowest-energy states in momentum sectors of a one-dimensional XYZ spin chain using QuSpin.
from quspin.operators import hamiltonian
from quspin.basis import spin_basis_1d
import numpy as np
import matplotlib.pyplot as plt
# parameters
L = 16
Jx, Jy, Jz = 0.5, 1.5, 1.0
nev = 3
Emax = 2.0
# XYZ Hamiltonian with periodic boundary conditions
J_xx = [[Jx, i, (i + 1) % L] for i in range(L)]
J_yy = [[Jy, i, (i + 1) % L] for i in range(L)]
J_zz = [[Jz, i, (i + 1) % L] for i in range(L)]
static = [["xx", J_xx], ["yy", J_yy], ["zz", J_zz]]
# calculate low-energy levels in each momentum sector
spectrum = []
for kblock in range(L):
basis = spin_basis_1d(L, pauli=False, kblock=kblock)
H = hamiltonian(
static, [],
basis=basis,
dtype=np.complex128,
check_pcon=False
)
E = H.eigsh(
k=nev,
which="SA",
return_eigenvectors=False
)
E = np.sort(np.real(E))
k = 2.0 * np.pi * kblock / L
spectrum.append((kblock, k, E))
# global ground-state energy
E0 = min(E[0] for _, _, E in spectrum)
# output and plot data
print("# kblock k/pi excitation_energy")
k_plot = []
E_plot = []
for kblock, k, E in spectrum:
for e in E:
excitation = e - E0
if excitation <= Emax:
k_plot.append(k / np.pi)
E_plot.append(excitation)
print(f"{kblock:4d} {k/np.pi:10.6f} {excitation:18.12f}")
# plot
plt.figure(figsize=(8, 5))
plt.scatter(k_plot, E_plot, s=8, alpha=0.6)
plt.xlabel(r"$k/\pi$")
plt.ylabel(r"$E-E_0$")
plt.title("XYZ chain: excitation spectrum")
plt.xlim(0.0, 2.0)
plt.ylim(0.0, Emax)
plt.grid(True)
param_text = (
rf"$L = {L}$" "\n"
rf"$J_x = {Jx:.3f}$" "\n"
rf"$J_y = {Jy:.3f}$" "\n"
rf"$J_z = {Jz:.3f}$"
)
plt.text(
0.03, 0.97, param_text,
transform=plt.gca().transAxes,
fontsize=11,
verticalalignment="top",
bbox=dict(boxstyle="round", facecolor="white", alpha=0.8)
)
plt.tight_layout()
plt.savefig("xyz-disp-lan.png", dpi=300)
print("# saved: xyz-disp-lan.png")