def test(sps, Lx, Ly): N = Lx * Ly nmax = sps - 1 tr = square_lattice_trans(Lx, Ly) basis_dict = {} Nbs = range(nmax * N + 1) for Nb in Nbs: basis_blocks = [] pcon_basis = boson_basis_general(N, Nb=Nb, sps=sps) Ns_block = 0 for blocks in tr.allowed_blocks_iter(): basis = boson_basis_general(N, Nb=Nb, sps=sps, **blocks) Ns_block += basis.Ns basis_blocks.append(basis) try: assert (Ns_block == pcon_basis.Ns) except AssertionError: print(Ns_block, pcon_basis.Ns) raise AssertionError basis_dict[Nb] = (pcon_basis, basis_blocks) J = [[1.0, i, tr.T_x[i]] for i in range(N)] J.extend([[1.0, i, tr.T_y[i]] for i in range(N)]) static = [["nn", J], ["+-", J], ["-+", J]] E_symm = {} for Nb, (pcon_basis, basis_blocks) in basis_dict.items(): H_pcon = hamiltonian(static, [], basis=pcon_basis, dtype=np.float64) if H_pcon.Ns > 0: E_pcon = np.linalg.eigvalsh(H_pcon.todense()) else: E_pcon = np.array([]) E_block = [] for basis in basis_blocks: H = hamiltonian(static, [], basis=basis, dtype=np.complex128) if H.Ns > 0: E_block.append(np.linalg.eigvalsh(H.todense())) E_block = np.hstack(E_block) E_block.sort() np.testing.assert_allclose(E_pcon, E_block, atol=1e-13) print("passed Nb={} sector".format(Nb))
def __init__(self, U, z, max_p, L): #initialises object parameters self.U = U self.z = z - 2 #effective z is different to 'number of nearest neighbours' z, depends on positioning self.L = L self.basis = boson_basis_general(self.L, sps=max_p + 1) #basis generation self.local_z = [self.z for i in range(self.L)] #local_z list self.local_z[0] = self.local_z[0] + 1 self.local_z[self.L - 1] = self.local_z[ self.L - 1] + 1 #differences in the z for the ends of the chain
U = 1.0 # onsite interaction mu = 0.371 # chemical potential # ###### setting up user-defined symmetry transformations for 2d lattice ###### s = np.arange(N_2d) # sites [0,1,2,....] x = s % Lx # x positions for sites y = s // Lx # y positions for sites T_x = (x + 1) % Lx + Lx * y # translation along x-direction T_y = x + Lx * ((y + 1) % Ly) # translation along y-direction P_x = x + Lx * (Ly - y - 1) # reflection about x-axis P_y = (Lx - x - 1) + Lx * y # reflection about y-axis # ###### setting up bases ###### basis_2d = boson_basis_general(N_2d, sps=N_sps, kxblock=(T_x, 0), kyblock=(T_y, 0), pxblock=(P_x, 0), pyblock=(P_y, 0)) # ###### setting up hamiltonian ###### # setting up site-coupling lists #hopping=[[-J,i,T_x[i]] for i in range(N_2d)] + [[-J,i,T_y[i]] for i in range(N_2d)] potential = [[-mu - U / 2.0, i] for i in range(N_2d)] interaction = [[U / 2.0, i, i] for i in range(N_2d)] # print("# J E/N") for J in np.linspace(0, 0.1, 41): # hopping matrix element hopping = [[-J, i, T_x[i]] for i in range(N_2d)] + [[-J, i, T_y[i]] for i in range(N_2d)] static = [["+-", hopping], ["-+", hopping], ["n", potential], ["nn", interaction]]
T_y = x +Lx*((y+1)%Ly) # translation along y-direction R = np.rot90(s.reshape(Lx,Ly), axes=(0,1)).reshape(N_2d) # rotate P_x = x + Lx*(Ly-y-1) # reflection about x-axis P_y = (Lx-x-1) + Lx*y # reflection about y-axis Z = -(s+1) # spin inversion # ###### setting up bases ###### basis_boson = boson_basis_general(N_2d, make_basis=False, Nb=N_2d//4,sps=2, kxblock=(T_x,0),kyblock=(T_y,0), rblock=(R,0), pxblock=(P_x,0),pyblock=(P_y,0), # zblock=(Z,0) ) basis_boson_full = boson_basis_general(N_2d, make_basis=True, Nb=N_2d//4,sps=2, ) basis_spin = spin_basis_general(N_2d, pauli=False, make_basis=False, Nup=N_2d//2, kxblock=(T_x,0),kyblock=(T_y,0), rblock=(R,0), pxblock=(P_x,0),pyblock=(P_y,0), zblock=(Z,0)
J = np.sqrt(7) J_p = [[+J, i, T_x[i]] for i in range(N_2d)] + [[+J, i, T_y[i]] for i in range(N_2d)] J_n = [[-J, i, T_x[i]] for i in range(N_2d)] + [[-J, i, T_y[i]] for i in range(N_2d)] lattice_trans = square_lattice_trans(Lx, Ly) allowed_sectors = lattice_trans.allowed_blocks_iter() for ii, basis_dict in enumerate(allowed_sectors): ###### setting up bases ###### basis_boson = boson_basis_general(N_2d, make_basis=False, Nb=N_2d // 4, sps=2, **basis_dict) basis_boson_full = boson_basis_general( N_2d, make_basis=False, Nb=N_2d // 4, sps=2, ) basis_spin = spin_basis_general(N_2d, pauli=False, make_basis=False, Nup=N_2d // 2, zblock=(Z, 0),
basis_op=spinless_fermion_basis_general(N_2d, make_basis=True, Nf=Np, kxblock=(T_x,0),kyblock=(T_y,0), pxblock=(P_x,0),pyblock=(P_y,0), ) compare(static_list,basis,basis_op) print('passed spinless fermios') basis=boson_basis_general(N_2d, make_basis=False, Nb=Np, sps=3, kxblock=(T_x,0),kyblock=(T_y,0), pxblock=(P_x,0),pyblock=(P_y,0), ) basis_op=boson_basis_general(N_2d, make_basis=True, Nb=Np, sps=3, kxblock=(T_x,0),kyblock=(T_y,0), pxblock=(P_x,0),pyblock=(P_y,0), ) compare(static_list,basis,basis_op) print('passed bosons')
sys.path.insert(0, qspin_path) from quspin.basis import spin_basis_1d, boson_basis_1d, spinless_fermion_basis_1d, spinful_fermion_basis_1d from quspin.basis import spin_basis_general, boson_basis_general, spinless_fermion_basis_general, spinful_fermion_basis_general from itertools import product import numpy as np for L in [6, 7]: # symmetry-free basis_1 = spin_basis_1d(L=L, Nup=range(0, L, 2)) basis_1g = spin_basis_general(N=L, Nup=range(0, L, 2)) basis_2 = boson_basis_1d(L=L, Nb=range(0, L, 2)) basis_2g = boson_basis_general(N=L, Nb=range(0, L, 2)) basis_3 = spinless_fermion_basis_1d(L=L, Nf=range(0, L, 2)) basis_3g = spinless_fermion_basis_general(N=L, Nf=range(0, L, 2)) basis_4 = spinful_fermion_basis_1d(L=L, Nf=product(range(0, L, 2), range(0, L, 2))) basis_4g = spinful_fermion_basis_general(N=L, Nf=product( range(0, L, 2), range(0, L, 2))) # symmetry-ful t = (np.arange(L) + 1) % L