The Spectrum of the Transverse Field Ising Model and the Jordan-Wigner Transformation

This example shows how to code up the transverse-field Ising chain and the Jordan-Wigner-equivalent fermion p-wave superconductor:

\[\begin{split}H&=&\sum_{j=0}^{L-1}-J\sigma^z_{j+1}\sigma^z_j - h\sigma^x_j, \nonumber\\ H&=&\sum_{j=0}^{L-1}J\left(-c^\dagger_jc_{j+1} + c_jc^\dagger_{j+1} \right) +J\left( -c^\dagger_jc^\dagger_{j+1} + c_jc_{j+1}\right) + 2h\left(n_j-\frac{1}{2}\right).\end{split}\]

Details about the code below can be found in SciPost Phys. 7, 020 (2019).

Script

download

  1#####################################################################
  2#                            example 4                              #
  3#    In this script we demonstrate how to construct fermionic       #
  4#    Hamiltonians, and check the Jordan-Wigner transformation.      #
  5#####################################################################
  6from quspin.operators import hamiltonian  # Hamiltonians and operators
  7from quspin.basis import (
  8    spin_basis_1d,
  9    spinless_fermion_basis_1d,
 10)  # Hilbert space spin basis
 11import numpy as np  # generic math functions
 12import matplotlib.pyplot as plt  # plotting library
 13
 14#
 15##### define model parameters #####
 16L = 8  # system size
 17J = 1.0  # spin zz interaction
 18h = np.sqrt(2)  # z magnetic field strength
 19#
 20# loop over spin inversion symmetry block variable and boundary conditions
 21for zblock, PBC in zip([-1, 1], [1, -1]):
 22    #
 23    ##### define spin model
 24    # site-coupling lists (PBC for both spin inversion sectors)
 25    h_field = [[-h, i] for i in range(L)]
 26    J_zz = [[-J, i, (i + 1) % L] for i in range(L)]  # PBC
 27    # define spin static and dynamic lists
 28    static_spin = [["zz", J_zz], ["x", h_field]]  # static part of H
 29    dynamic_spin = []  # time-dependent part of H
 30    # construct spin basis in pos/neg spin inversion sector depending on APBC/PBC
 31    basis_spin = spin_basis_1d(L=L, zblock=zblock)
 32    # build spin Hamiltonians
 33    H_spin = hamiltonian(static_spin, dynamic_spin, basis=basis_spin, dtype=np.float64)
 34    # calculate spin energy levels
 35    E_spin = H_spin.eigvalsh()
 36    #
 37    ##### define fermion model
 38    # define site-coupling lists for external field
 39    h_pot = [[2.0 * h, i] for i in range(L)]
 40    if PBC == 1:  # periodic BC: odd particle number subspace only
 41        # define site-coupling lists (including boudary couplings)
 42        J_pm = [[-J, i, (i + 1) % L] for i in range(L)]  # PBC
 43        J_mp = [[+J, i, (i + 1) % L] for i in range(L)]  # PBC
 44        J_pp = [[-J, i, (i + 1) % L] for i in range(L)]  # PBC
 45        J_mm = [[+J, i, (i + 1) % L] for i in range(L)]  # PBC
 46        # construct fermion basis in the odd particle number subsector
 47        basis_fermion = spinless_fermion_basis_1d(L=L, Nf=range(1, L + 1, 2))
 48    elif PBC == -1:  # anti-periodic BC: even particle number subspace only
 49        # define bulk site coupling lists
 50        J_pm = [[-J, i, i + 1] for i in range(L - 1)]
 51        J_mp = [[+J, i, i + 1] for i in range(L - 1)]
 52        J_pp = [[-J, i, i + 1] for i in range(L - 1)]
 53        J_mm = [[+J, i, i + 1] for i in range(L - 1)]
 54        # add boundary coupling between sites (L-1,0)
 55        J_pm.append([+J, L - 1, 0])  # APBC
 56        J_mp.append([-J, L - 1, 0])  # APBC
 57        J_pp.append([+J, L - 1, 0])  # APBC
 58        J_mm.append([-J, L - 1, 0])  # APBC
 59        # construct fermion basis in the even particle number subsector
 60        basis_fermion = spinless_fermion_basis_1d(L=L, Nf=range(0, L + 1, 2))
 61    # define fermionic static and dynamic lists
 62    static_fermion = [
 63        ["+-", J_pm],
 64        ["-+", J_mp],
 65        ["++", J_pp],
 66        ["--", J_mm],
 67        ["z", h_pot],
 68    ]
 69    dynamic_fermion = []
 70    # build fermionic Hamiltonian
 71    H_fermion = hamiltonian(
 72        static_fermion,
 73        dynamic_fermion,
 74        basis=basis_fermion,
 75        dtype=np.float64,
 76        check_pcon=False,
 77        check_symm=False,
 78    )
 79    # calculate fermionic energy levels
 80    E_fermion = H_fermion.eigvalsh()
 81    #
 82    ##### plot spectra
 83    plt.plot(
 84        np.arange(H_fermion.Ns), E_fermion / L, marker="o", color="b", label="fermion"
 85    )
 86    plt.plot(
 87        np.arange(H_spin.Ns),
 88        E_spin / L,
 89        marker="x",
 90        color="r",
 91        markersize=2,
 92        label="spin",
 93    )
 94    plt.xlabel("state number", fontsize=16)
 95    plt.ylabel("energy", fontsize=16)
 96    plt.xticks(fontsize=16)
 97    plt.yticks(fontsize=16)
 98    plt.legend(fontsize=16)
 99    plt.grid()
100    plt.tight_layout()
101    plt.savefig("example4.pdf", bbox_inches="tight")
102    # plt.show()
103    plt.close()