def test(Lx, Ly):
    N = Lx * Ly
    tr = square_lattice_trans(Lx, Ly)

    basis_dict = {}
    Nfs = range(N + 1)

    for Nf in Nfs:
        basis_blocks = []
        pcon_basis = spinful_fermion_basis_general(N, Nf=(Nf, N - Nf))
        Ns_block = 0
        for blocks in tr.allowed_blocks_iter_parity():
            print(N, Nf, N - Nf)
            print(blocks)
            basis = spinful_fermion_basis_general(N, Nf=(Nf, N - Nf), **blocks)
            Ns_block += basis.Ns
            basis_blocks.append(basis)

        assert (Ns_block == pcon_basis.Ns)

        basis_dict[Nf] = (pcon_basis, basis_blocks)

    J = [[np.sqrt(2.0), i, tr.T_x[i]] for i in range(N)]
    J.extend([[np.sqrt(2.0), i, tr.T_y[i]] for i in range(N)])

    Jp = [[1.0, i, tr.T_x[i]] for i in range(N)]
    Jp.extend([[1.0, i, tr.T_y[i]] for i in range(N)])

    Jm = [[-1.0, i, tr.T_x[i]] for i in range(N)]
    Jm.extend([[-1.0, i, tr.T_y[i]] for i in range(N)])

    static = [["n|n", J], ["+-|", Jp], ["-+|", Jm], ["|+-", Jp], ["|-+", Jm]]

    E_symm = {}

    for Nf, (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 Nf={} sector".format(Nf))
示例#2
0
basis_fermion = spinless_fermion_basis_general(N_2d, make_basis=False,
									Nf=N_2d//2,
									kxblock=(T_x,0),kyblock=(T_y,0),
									rblock=(R,0),
									pxblock=(P_x,0),pyblock=(P_y,0),
								)

basis_fermion_full = spinless_fermion_basis_general(N_2d, make_basis=True,
									Nf=N_2d//2,
								)



basis_spinful_fermion = spinful_fermion_basis_general(N_2d, make_basis=False,
									Nf=(N_2d//8,N_2d//8),
									kxblock=(T_x,0),kyblock=(T_y,0),
									rblock=(R,0),
									pxblock=(P_x,0),pyblock=(P_y,0),
								)

basis_spinful_fermion_full = spinful_fermion_basis_general(N_2d, make_basis=True,
									Nf=(N_2d//8,N_2d//8),
								)


bases_2d=[basis_boson,basis_spin,basis_fermion,basis_spinful_fermion]
bases_2d_full=[basis_boson_full,basis_spin_full,basis_fermion_full,basis_spinful_fermion_full]


for i,(basis_2d,basis_2d_full) in enumerate(zip(bases_2d,bases_2d_full)):
	# grab states of full basis
	states=basis_2d_full.states
示例#3
0
# visualise graph
pos = nx.spring_layout(hex_graph, seed=42, iterations=100)
nx.draw(hex_graph, pos=pos, with_labels=True)
plt.show(block=False)
#
###### model parameters
#
N_up = 2  # number of spin-up fermions
N_down = 2  # number of spin-down fermions
t = 1.0  # tunnelling matrix element
U = 2.0  # on-site fermion interaction strength
#
##### set up Fermi-Hubbard Hubbard Hamiltonian with quspin #####
#
### compute basis
basis = spinful_fermion_basis_general(N, Nf=(N_up, N_down))
print('Hilbert space size: {0:d}.\n'.format(basis.Ns))
#
# define site-coupling lists
tunnelling = [[-t, i, j] for i in range(N) for j in hex_graph.adj[i]]
interactions = [[U, i, i] for i in range(N)]
#
# define site-coupling lists [hermitian conjugates "-+|" and "|-+" contained in tunnelling list]
static = [["n|n", interactions], ["+-|", tunnelling], ["|+-", tunnelling]]
dynamic = []
#
### construct Hamiltonian
H = hamiltonian(static, dynamic, basis=basis, dtype=np.float64)
#
# compute eigensystem
E, V = H.eigsh(k=4, which='SA', maxiter=1E4)
示例#4
0
    )

    basis_fermion = spinless_fermion_basis_general(N_2d,
                                                   make_basis=False,
                                                   Nf=N_2d // 2,
                                                   **basis_dict)

    basis_fermion_full = spinless_fermion_basis_general(
        N_2d,
        make_basis=False,
        Nf=N_2d // 2,
    )

    basis_spinful_fermion = spinful_fermion_basis_general(N_2d,
                                                          make_basis=False,
                                                          Nf=(N_2d // 8,
                                                              N_2d // 8),
                                                          **basis_dict)

    basis_spinful_fermion_full = spinful_fermion_basis_general(
        N_2d,
        make_basis=False,
        Nf=(N_2d // 8, N_2d // 8),
    )

    bases_2d = [basis_boson, basis_spin, basis_fermion, basis_spinful_fermion]
    bases_2d_full = [
        basis_boson_full, basis_spin_full, basis_fermion_full,
        basis_spinful_fermion_full
    ]
示例#5
0
	
	
	compare(static_list,basis,basis_op)
	print('passed bosons')


	if Np==None: 
		Nf=Np
	elif type(Np) is list:
		Nf=list(zip(Np,Np))	
	else: 
		Nf=(Np,Np)

	basis=spinful_fermion_basis_general(N_2d, make_basis=False,
									Nf=Nf,
									kxblock=(T_x,0),kyblock=(T_y,0),
									pxblock=(P_x,0),pyblock=(P_y,0),
								)

	basis_op=spinful_fermion_basis_general(N_2d, make_basis=True,
									Nf=Nf,
									kxblock=(T_x,0),kyblock=(T_y,0),
									pxblock=(P_x,0),pyblock=(P_y,0),
					
								)


	compare(static_list_spfs,basis,basis_op)
	print('passed spinful fermios')
	
	
t_y = x + Lx * (
    (y + 1) % Ly)  # translation along y-direction for one spin species
# create the spin-up spin-down combined transformations
s = np.arange(
    2 * N_2d)  # sites [0,1,2,...,N_2d-1,...,2*N_2d-1] in advanced notation
T_x = np.hstack(
    (t_x, t_x + N_2d))  # translation along x-direction for both spin species
T_y = np.hstack(
    (t_y, t_y + N_2d))  # translation along y-direction for both spin species
PH = -(s + 1)  # particle-hole in the advanced case
#
###### setting up bases ###### (note optional argument simple_symm=False)
#basis_2d=spinful_fermion_basis_general(N_2d,simple_symm=False,Nf=(2,2),kxblock=(T_x,0),kyblock=(T_y,0))
basis_2d = spinful_fermion_basis_general(N_2d,
                                         simple_symm=False,
                                         Nf=(6, 6),
                                         kxblock=(T_x, 0),
                                         kyblock=(T_y, 0),
                                         phblock=(PH, 0))
#
###### setting up hamiltonian ######
# setting up site-coupling lists for advanced case
hopping_left = [[-J, i, T_x[i]]
                for i in range(2 * N_2d)] + [[-J, i, T_y[i]]
                                             for i in range(2 * N_2d)]
hopping_right = [[+J, i, T_x[i]]
                 for i in range(2 * N_2d)] + [[+J, i, T_y[i]]
                                              for i in range(2 * N_2d)]
interaction = [[U, i, i + N_2d] for i in range(N_2d)]
#
static = [
    ["+-", hopping_left],  # spin-up and spin-down hop to left
def test(Lx,Ly):

	N = Lx*Ly

	nmax = int(eval("2*1/2"))
	sps = nmax+1
	tr = square_lattice_trans(Lx,Ly)


	basis_dict = {}
	basis_dict_f = {}
	basis_dict_combined = {}
	Nups=range(nmax*N+1)

	for Nup in Nups:
		basis_blocks=[]
		basis_blocks_f=[]

		pcon_basis = spin_basis_general(N,Nup=Nup,pauli=False)
		pcon_basis_f = spinful_fermion_basis_general(N,Nf=(Nup,N-Nup),double_occupancy=False)

		Ns_block = 0
		for blocks in tr.allowed_blocks_spin_inversion_iter(Nup,sps):
			basis =  spin_basis_general(N,Nup=Nup,pauli=False,**blocks)
			Ns_block += basis.Ns
			basis_blocks.append(basis)

		Ns_block_f = 0
		for blocks_f in tr.allowed_blocks_spin_inversion_iter(Nup,sps): # requires simple symmetry definition
			basis_f =  spinful_fermion_basis_general(N,Nf=(Nup,N-Nup),double_occupancy=False,**blocks_f)
			Ns_block_f += basis_f.Ns
			basis_blocks_f.append(basis_f)

		try:
			assert(Ns_block == pcon_basis.Ns)
		except AssertionError:
			print(Nup,Ns_block,pcon_basis.Ns)
			raise AssertionError("reduced blocks don't sum to particle sector.")

		try:
			assert(Ns_block_f == pcon_basis_f.Ns)
		except AssertionError:
			print(Nup,Ns_block_f,pcon_basis_f.Ns)
			raise AssertionError("fermion reduced blocks don't sum to particle sector.")

		try:
			assert(Ns_block == pcon_basis_f.Ns)
		except AssertionError:
			print(Nup,Ns_block_f,pcon_basis_f.Ns)
			raise AssertionError("fermion reduced blocks don't match spin blocks.")


		basis_dict[Nup] = (pcon_basis,basis_blocks)
		basis_dict_f[Nup] = (pcon_basis_f,basis_blocks_f)
		basis_dict_combined[Nup] = (pcon_basis,basis_blocks,pcon_basis_f,basis_blocks_f)
		


	J = [[1.0,i,tr.T_x[i]] for i in range(N)] + [[1.0,i,tr.T_y[i]] for i in range(N)]
	

	J_nn_ij = [[-0.25,i,tr.T_x[i]] for i in range(N)] + [[-0.25,i,tr.T_y[i]] for i in range(N)]
	J_nn_ji = [[-0.25,tr.T_x[i],i] for i in range(N)] + [[-0.25,tr.T_y[i],i] for i in range(N)]
	J_nn_ij_p = [[0.25,i,tr.T_x[i]] for i in range(N)] + [[0.25,i,tr.T_y[i]] for i in range(N)]
	J_nn_ji_p = [[0.25,tr.T_x[i],i] for i in range(N)] + [[0.25,tr.T_y[i],i] for i in range(N)]
	
	J_cccc_ij = [[-1.0,i,tr.T_x[i],tr.T_x[i],i] for i in range(N)] + [[-1.0,i,tr.T_y[i],tr.T_y[i],i] for i in range(N)]
	J_cccc_ji = [[-1.0,tr.T_x[i],i,i,tr.T_x[i]] for i in range(N)] + [[-1.0,tr.T_y[i],i,i,tr.T_y[i]] for i in range(N)]


	static = [["zz",J],["+-",J],["-+",J]]
	static_f = [["nn|",J_nn_ij_p],["|nn",J_nn_ji_p],["n|n",J_nn_ij],["n|n",J_nn_ji],["+-|+-",J_cccc_ij],["+-|+-",J_cccc_ji]]
	
	E_symm = {}
	E_symm_f = {}

	#'''
	for N,(pcon_basis,basis_blocks,pcon_basis_f,basis_blocks_f) in basis_dict_combined.items():

		H_pcon = hamiltonian(static,[],basis=pcon_basis,dtype=np.float64)
		H_pcon_f = hamiltonian(static_f,[],basis=pcon_basis_f,dtype=np.float64)

		if H_pcon.Ns>0:
			E_pcon = np.linalg.eigvalsh(H_pcon.todense())
		else:
			E_pcon = np.array([])

		if H_pcon_f.Ns>0:
			E_pcon_f = np.linalg.eigvalsh(H_pcon_f.todense())
		else:
			E_pcon_f = np.array([])


		E_block = []
		E_block_f = []
		for basis, basis_f in zip(basis_blocks,basis_blocks_f):

			H = hamiltonian(static,[],basis=basis,dtype=np.complex128)
			H_f = hamiltonian(static_f,[],basis=basis_f,dtype=np.complex128)
			
			if H.Ns>0:
				E_block.append(np.linalg.eigvalsh(H.todense()))
			
			if H_f.Ns>0:
				E_block_f.append(np.linalg.eigvalsh(H_f.todense()))

		E_block = np.hstack(E_block)
		E_block.sort()
		
		E_block_f = np.hstack(E_block_f)
		E_block_f.sort()

		np.testing.assert_allclose(E_pcon,E_block,atol=1e-13)
		np.testing.assert_allclose(E_pcon_f,E_block_f,atol=1e-13)
		np.testing.assert_allclose(E_pcon,E_pcon_f,atol=1e-13)
		
		print("passed N={} sector".format(N))
示例#8
0
U_onsite = [[1.0, i, i] for i in range(N)]

operator_list_0 = [["+-|", Jp], ["-+|", Jm], ["|+-", Jp], ["|-+", Jm]]
operator_list_1 = [["n|n", U_onsite]]

operator_dict = dict(H0=operator_list_0, H1=operator_list_1)

basis_f = spinless_fermion_basis_1d(L=N, Nf=2)
basis_1 = tensor_basis(basis_f, basis_f)

basis_f = spinless_fermion_basis_general(N, Nf=2)
basis_2 = tensor_basis(basis_f, basis_f)

basis_3 = spinful_fermion_basis_1d(L=N, Nf=(2, 2))
basis_4 = spinful_fermion_basis_general(N, Nf=(2, 2))

basis_dict = dict(tensored_spinless_fermion_basis_1d=basis_1,
                  spinful_fermion_basis_1d=basis_3,
                  tensored_spinless_fermion_basis_general=basis_2,
                  spinful_fermion_basis_general=basis_4)
for basis_name, basis in basis_dict.items():

    H_U = quantum_operator(operator_dict,
                           basis=basis,
                           dtype=np.float64,
                           check_pcon=False,
                           check_symm=False,
                           check_herm=False)

    E_quspin = np.zeros(E_paper.shape, )
示例#9
0
    # 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

    basis_1 = spin_basis_1d(L=L, Nup=range(0, L, 2), kblock=0)
    basis_1g = spin_basis_general(N=L, Nup=range(0, L, 2), kblock=(t, 0))

    basis_2 = boson_basis_1d(L=L, Nb=range(0, L, 2), kblock=0)
    basis_2g = boson_basis_general(N=L, Nb=range(0, L, 2), kblock=(t, 0))

    basis_3 = spinless_fermion_basis_1d(L=L, Nf=range(0, L, 2), kblock=0)
    basis_3g = spinless_fermion_basis_general(N=L,
                                              Nf=range(0, L, 2),
示例#10
0
###### setting up user-defined BASIC symmetry transformations for 2d lattice ######
s = np.arange(N_2d)  # sites [0,1,2,...,N_2d-1] in simple notation
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
S = -(s + 1)  # fermion spin inversion in the simple case
#
###### setting up bases ######
basis_2d = spinful_fermion_basis_general(
    N_2d,
    Nf=(3, 3),
    double_occupancy=False,
    kxblock=(T_x, 0),
    kyblock=(T_y, 0),
    pxblock=(P_x, 1),
    pyblock=(P_y, 0),  # contains GS
    sblock=(S, 0))
print(basis_2d)
#
###### setting up hamiltonian ######
# setting up site-coupling lists for simple case
hopping_left = [[-J, i, T_x[i]] for i in range(N_2d)] + [[-J, i, T_y[i]]
                                                         for i in range(N_2d)]
hopping_right = [[+J, i, T_x[i]] for i in range(N_2d)] + [[+J, i, T_y[i]]
                                                          for i in range(N_2d)]
potential = [[-mu, i] for i in range(N_2d)]
interaction = [[U, i, i] for i in range(N_2d)]
#
Jp = [[1.0, i, T_x[i]] for i in range(2 * N)]
Jp.extend([[1.0, i, T_y[i]] for i in range(2 * N)])

Jm = [[-1.0, i, T_x[i]] for i in range(2 * N)]
Jm.extend([[-1.0, i, T_y[i]] for i in range(2 * N)])

U_onsite = [[1.0, i, i + N] for i in range(N)]

operator_list_0 = [["+-", Jp], ["-+", Jm]]
operator_list_1 = [["nn", U_onsite]]

operator_dict = dict(H0=operator_list_0, H1=operator_list_1)

basis = spinful_fermion_basis_general(N,
                                      Nf=(2, 2),
                                      ky=(T_y, 0),
                                      kx=(T_x, 0),
                                      simple_symm=False)

basis_name = "general spinful fermions advanced"

H_U = quantum_operator(operator_dict,
                       basis=basis,
                       dtype=np.float64,
                       check_pcon=False,
                       check_symm=False,
                       check_herm=False)

E_quspin = np.zeros(E_paper.shape)
for j, U in enumerate(np.linspace(0.0, 4.0, 9)):
示例#12
0
文件: ed.py 项目: cygnus2/FQLMs
def build_basis(Lx, Ly, U=4.0, μ=0):
    N_2d = Lx * Ly

    Nup = N_2d
    Ndown = N_2d

    J = 1.0

    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
    P_x = x + Lx * (Ly - y - 1)  # reflection about x-axis
    T_y = x + Lx * ((y + 1) % Ly)  # translation along y-direction
    P_y = (Lx - x - 1) + Lx * y  # reflection about y-axis
    S = -(s + 1)  # fermion spin inversion in the simple case
    P_xy = (Lx - x - 1) + Lx * (Ly - y - 1)  # point reflection about origin

    #basis = spinful_fermion_basis_general(
    #   N_2d, pxyblock=(P_xy, 1)
    #)

    basis = spinful_fermion_basis_general(N_2d, double_occupancy=False)

    #print(basis)

    hop_right = ([[+0.5, i, T_x[i]]
                  for i in range(N_2d)] + [[+0.5, i, T_y[i]]
                                           for i in range(N_2d)])
    hop_left = ([[-0.5, i, T_x[i]]
                 for i in range(N_2d)] + [[-0.5, i, T_y[i]]
                                          for i in range(N_2d)])
    print(hop_right)

    coupling_1 = ([[-J / 2, i, T_x[i]]
                   for i in range(N_2d)] + [[-J / 2, i, T_y[i]]
                                            for i in range(N_2d)] +
                  [[-J / 2, T_x[i], i]
                   for i in range(N_2d)] + [[-J / 2, T_y[i], i]
                                            for i in range(N_2d)])

    coupling_2 = ([[J / 2, i, i, T_x[i]]
                   for i in range(N_2d)] + [[J / 2, i, i, T_y[i]]
                                            for i in range(N_2d)] +
                  [[J / 2, T_x[i], i, T_x[i]]
                   for i in range(N_2d)] + [[J / 2, T_y[i], i, T_y[i]]
                                            for i in range(N_2d)])

    coupling_3 = ([[J / 2, i, T_x[i], i]
                   for i in range(N_2d)] + [[J / 2, i, T_y[i], i]
                                            for i in range(N_2d)] +
                  [[J / 2, i, T_x[i], T_x[i]]
                   for i in range(N_2d)] + [[J / 2, i, T_y[i], T_y[i]]
                                            for i in range(N_2d)])

    coupling_4 = ([[-J, i, T_x[i], i, T_x[i]]
                   for i in range(N_2d)] + [[-J, i, T_y[i], i, T_y[i]]
                                            for i in range(N_2d)])

    coupling_5 = ([[-J / 2, i, T_x[i], T_x[i], i]
                   for i in range(N_2d)] + [[-J / 2, i, T_y[i], T_y[i], i]
                                            for i in range(N_2d)] +
                  [[-J / 2, T_x[i], i, i, T_x[i]]
                   for i in range(N_2d)] + [[-J / 2, T_y[i], i, i, T_y[i]]
                                            for i in range(N_2d)])

    pot = [[-U / 2, i] for i in range(N_2d)]  # -\mu \sum_j n_{j \sigma}I

    static_free = [
        ["+-|", hop_left],  # up hops left
        ["|+-", hop_left],  # down hops left
        ["-+|", hop_right],  # up hops right
        ["|-+", hop_right],  # down hops right
    ]

    # Interaction
    interact = [[U, i, i]
                for i in range(N_2d)]  # U/2 \sm_j n_{j,up} n_{j,down}

    mass1 = [[(-1)**(i % 2 + math.floor(i / 2)) * 1e-5, i]
             for i in range(N_2d)]
    if U <= 0:
        mass2 = [[(-1)**(i % 2 + math.floor(i / 2)) * 1e-5, i]
                 for i in range(N_2d)]
    else:
        mass2 = [[-1 * (-1)**(i % 2 + math.floor(i / 2)) * 1e-5, i]
                 for i in range(N_2d)]

    static_int = [
        ["n|n", interact],  # up-down interaction
        ["n|", pot],  # up on-site potention
        ["|n", pot],  # down on-site potent ion
    ]

    # Proper slater state
    slater_free = [
        ["+-|", hop_left],  # up hops left
        ["|+-", hop_left],  # down hops left
        ["-+|", hop_right],  # up hops right
        ["|-+", hop_right],  # down hops right
        ["n|", mass1],
        ["|n", mass2],
    ]

    num = [[1, i] for i in range(N_2d)]

    particle_number = [
        ["n|", num],
        ["|n", num],
    ]

    particle_up = [
        ["n|", num],
    ]

    tJ = [["n|n", coupling_1], ["n|nn", coupling_2], ["nn|n", coupling_3],
          ["nn|nn", coupling_4], ["+-|+-", coupling_5]]

    return basis, static_free, static_int, slater_free, particle_number, particle_up, tJ
#
J=1.0 # hopping matrix element
U=2.0 # onsite interaction
mu=0.5 # 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=spinful_fermion_basis_general(N_2d,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_left=[[-J,i,T_x[i]] for i in range(N_2d)] + [[-J,i,T_y[i]] for i in range(N_2d)]
hopping_right=[[+J,i,T_x[i]] for i in range(N_2d)] + [[+J,i,T_y[i]] for i in range(N_2d)]
potential=[[-mu,i] for i in range(N_2d)]
interaction=[[U,i,T_x[i]] for i in range(N_2d)] + [[U,i,T_y[i]] for i in range(N_2d)]
#
static=[["+-|",hopping_left], # spin up hops to left
		["-+|",hopping_right], # spin up hops to right
		["|+-",hopping_left], # spin down hopes to left
		["|-+",hopping_right], # spin up hops to right
		["n|",potential], # onsite potenial, spin up
		["|n",potential], # onsite potential, spin down
		["n|n",interaction]] # spin up-spin down interaction
N_2d = Lx*Ly # number of sites for spin 1
#
J=1.0 # hopping matrix element
U=2.0 # onsite interaction
mu=0.5 # chemical potential
#
###### setting up user-defined BASIC symmetry transformations for 2d lattice ######
s = np.arange(N_2d) # sites [0,1,2,...,N_2d-1] in simple notation
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
S = -(s+1) # fermion spin inversion in the simple case
#
###### setting up bases ######
basis_2d=spinful_fermion_basis_general(N_2d,Nf=(2,2),kxblock=(T_x,0),kyblock=(T_y,0),sblock=(S,0))
#
###### setting up hamiltonian ######
# setting up site-coupling lists for simple case
hopping_left =[[-J,i,T_x[i]] for i in range(N_2d)] + [[-J,i,T_y[i]] for i in range(N_2d)]
hopping_right=[[+J,i,T_x[i]] for i in range(N_2d)] + [[+J,i,T_y[i]] for i in range(N_2d)]
potential=[[-mu,i] for i in range(N_2d)]
interaction=[[U,i,i] for i in range(N_2d)]
#
static=[["+-|",hopping_left], # spin up hops to left
		["-+|",hopping_right], # spin up hops to right
		["|+-",hopping_left], # spin down hopes to left
		["|-+",hopping_right], # spin up hops to right
		["n|",potential], # onsite potenial, spin up
		["|n",potential], # onsite potential, spin down
		["n|n",interaction]] # spin up-spin down interaction
       1) % Lx + Lx * y  # translation along x-direction for one spin species
t_y = x + Lx * (
    (y + 1) % Ly)  # translation along y-direction for one spin species
# create the spin-up spin-down combined transformations
s = np.arange(
    2 * N_2d)  # sites [0,1,2,...,N_2d-1,...,2*N_2d-1] in advanced notation
T_x = np.hstack(
    (t_x, t_x + N_2d))  # translation along x-direction for both spin species
T_y = np.hstack(
    (t_y, t_y + N_2d))  # translation along y-direction for both spin species
S = np.roll(s, N_2d)  # fermion spin inversion in the advanced case
#
###### setting up bases ###### (note optional argument simple_symm=False)
basis_2d = spinful_fermion_basis_general(N_2d,
                                         simple_symm=False,
                                         Nf=(2, 2),
                                         kxblock=(T_x, 0),
                                         kyblock=(T_y, 0),
                                         sblock=(S, 0))
#
###### setting up hamiltonian ######
# setting up site-coupling lists for advanced case
hopping_left = [[-J, i, T_x[i]]
                for i in range(2 * N_2d)] + [[-J, i, T_y[i]]
                                             for i in range(2 * N_2d)]
hopping_right = [[+J, i, T_x[i]]
                 for i in range(2 * N_2d)] + [[+J, i, T_y[i]]
                                              for i in range(2 * N_2d)]
potential = [[-mu, i] for i in range(2 * N_2d)]
interaction = [[U, i, i + N_2d] for i in range(N_2d)]
#
static = [