This post is available as an IPython notebook.
Hamiltonians on one dimensional chains provide a good sanity check when trying out new numerical methods. The Jordan-Wigner transform is an easy way to obtain the eigenvalues of systems of fermions. For an annihiliation operator , the transform is defined as , where is the Pauli operator along the axis, and is the operator acting on site .
The series of Kronecker products would be an ideal application of a nest function, but Python does not have such a function built in. Instead, we define a recursive function to get the desired Kronecker product:
import numpy as np def nested_kronecker_product(a): if len(a) == 2: return np.kron(a,a) else: return np.kron(a, nested_kronecker_product(a[1:]))
With this function, the transform is easy to define. We pad the transform with identity operators to match the lattice length:
def jordan_wigner_transform(j, lattice_length): sigma = np.array([[0, 1], [0, 0]]) sigma_z = np.array([[1, 0], [0, -1]]) I = np.eye(2) operators =  for k in range(j): operators.append(sigma_z) operators.append(sigma) for k in range(lattice_length-j-1): operators.append(I) return -nested_kronecker_product(operators)
Now we can get our transformed fermionic operators:
lattice_length = 4 a =  for i in range(lattice_length): a.append(jordan_wigner_transform(i, lattice_length))
Next we define a Hamiltonian of interest, namely spinless fermions on an open chain:
where and indicate neighbors on the chain. The Python definition of this Hamiltonian is
def hamiltonian(gam, lam, a, lattice_length): H = 0 for i in range(lattice_length - 1): H += a[i].T.dot(a[i+1]) - a[i].dot(a[i+1].T) H -= gam*(a[i].T.dot(a[i+1].T) - a[i].dot(a[i+1])) for i in range(lattice_length): H -= 2*lam*(a[i].dot(a[i].T)) return H
Here we observed the fermionic canonical commutation relations and performed substitutions. To get the eigenvalues for a particular parameter combination, we write
gam, lam =1, 1 H = hamiltonian(gam, lam, a, lattice_length) eigenvalues = np.linalg.eig(H) sorted(eigenvalues)
[-8.7587704831436479, -8.0641777724759276, -6.7587704831436497, -6.0641777724759232, -5.694592710667723, -5.0000000000000036, -4.9999999999999991, -4.3054072893322797, -3.6945927106677212, -3.0000000000000004, -2.9999999999999991, -2.3054072893322788, -1.9358222275240897, -1.241229516856365, 0.064177772475912706, 0.75877048314363438]