Domain: Physics — Quantum Mechanics

Problem:
A one-dimensional spin-1/2 XXZ chain of length `L = 12` with open boundary conditions is described by the Hamiltonian:

\[
H = \sum_{j=0}^{L-2} \left[ \frac{J_{xy}}{2} (S_j^+ S_{j+1}^- + S_j^- S_{j+1}^+) + J_{zz} S_j^z S_{j+1}^z \right] + h_z \sum_{j=0}^{L-1} S_j^z,
\]

with interaction strengths \(J_{xy} = \sqrt{2}\), \(J_{zz} = 1.0\), and external field \(h_z = 1/\sqrt{3}\). Compute the ground state energy \(E_0\) and provide the ground state energy rounded to three decimal places.

Answer: -6.839

Solution code:
import numpy as np
from scipy.sparse import dok_matrix
from scipy.sparse.linalg import eigsh

L = 12
J_xy = np.sqrt(2)
J_zz = 1.0
h_z = 1/np.sqrt(3)
dim = 2**L

def Sz(site, state):
    return 0.5 if (state >> site) & 1 else -0.5

def flip_spin(state, site):
    return state ^ (1 << site)

H = dok_matrix((dim, dim), dtype=np.float64)

for state in range(dim):
    # Diagonal field and interaction parts
    diag = 0
    for j in range(L):
        diag += h_z * Sz(j, state)
    for j in range(L-1):
        diag += J_zz * Sz(j, state) * Sz(j+1, state)
    H[state, state] = diag

    # Off-diagonal flip-flop terms
    for j in range(L-1):
        sj = (state >> j) & 1
        sjp1 = (state >> (j+1)) & 1
        if sj != sjp1:
            flipped = state ^ (1 << j) ^ (1 << (j+1))
            H[state, flipped] += 0.5 * J_xy

# Compute ground state energy
E0, _ = eigsh(H.tocsr(), k=1, which='SA', maxiter=10000)
print(round(E0[0],3))