def _set_cavity_basis(self): '''Get the basis states for the external coupled system in which to work in. Parameters -------------- types : string Defines the types of cavity. Possible options include: Uniform -- Boson cavity coupled to each site. Can have multiple modes Local -- Individual boson coupled to each "SITES" number of sites. Can have multiple modes fLocal -- Fermionic system coupled to each "SITES" number of sites. 1 mode. ''' if self.types == 'Uniform': basis = boson_basis_1d(L=1, sps=self.Ntot) basis_ms = basis for i in range(self.species - 1): basis_ms = tensor_basis(basis_ms, basis) self.basis = basis_ms if self.types == 'Local': basis = boson_basis_1d(L=self.sites, sps=self.Ntot) basis_ms = basis for i in range(self.species - 1): basis_ms = tensor_basis(basis_ms, basis) self.basis = basis_ms if self.types == 'fLocal': self.basis = spinless_fermion_basis_1d(L=self.sites, Nf=None, nf=None)
def _setup_basis(self, **args_model): """ Build and store: - the basis (self._ss) and the basis without use of symmetries() - config_system """ config_bh1D = {} for p in ['L', 'Nb']: config_bh1D[p] = args_model[p] for p in ['sps', 'kblock', 'pblock']: config_bh1D[p] = args_model.get(p, self._LIST_ARGS_OPT[p][1]) self._ss = boson_basis_1d(**config_bh1D) if np.any([config_bh1D[p] is not None for p in ['kblock', 'pblock']]): self._flag_basis_symm = True config_bh1D['pblock'] = None config_bh1D['kblock'] = None self._ss_nosym = boson_basis_1d(**config_bh1D) self._P = self._ss.get_proj(dtype=np.complex128, pcon=True) self._op_n_sites = None ## there is way to define it using projection else: L = args_model['L'] self._flag_basis_symm = False self._ss_nosym = self._ss self._P = None #Id self._op_n_sites = [ hamiltonian([['n', [[1.0, i]]]], [], basis=self._ss_nosym, dtype=np.float64) for i in range(L) ] i_iplusN = [[1, i, (i + L - 1) % L] for i in range(L)] # Cyclical boundaries self._op_correl_N = [ hamiltonian([['+-', i_iplusN]], [], basis=self._ss_nosym, dtype=np.float64, check_herm=False) for i in range(L) ] Ns = self._ss.Ns #NEW: get the basis.. A little bit convoluted may be an easier way to do that # Dim_H x Nbsites self._basis_fock = np.array( [self._get_basis_to_fock(s) for s in range(Ns)]) # store the index of MI (i.e. 11...11) if (config_bh1D['L'] == config_bh1D['Nb']): self._index_basis_allone = np.where( [np.allclose(b, 1.) for b in self._basis_fock])[0][0] else: self._index_basis_allone = -1 self._index_basis_oneone = [ np.where([b[i] == 1. for b in self._basis_fock])[0] for i in range(L) ]
def getvec_boson(L, H1, static, sps=2, Nb=None, kblock=None, pblock=None, a=1, sparse=True): jb = [[i, 1.0] for i in range(L)] dtype = np.complex128 b = boson_basis_1d(L, sps=sps, Nb=Nb, kblock=kblock, pblock=pblock, a=a) Ns = b.Ns if Ns == 0: return H2 = hamiltonian(static, [], basis=b, dtype=dtype) E, v0 = H2.eigh() v = b.get_vec(v0, sparse=sparse) P = b.get_proj(dtype=np.complex128) if sp.issparse(v): v = v.todense() H2 = H2.todense() H2 = v0.T.conj() * (H2 * v0) H1 = v.T.conj().dot(H1.dot(v)) err_msg = "get_vec() symmetries failed for L={0} {1}".format(b.N, b.blocks) np.testing.assert_allclose(H1, H2, atol=1e-10, err_msg=err_msg)
def _setup_qmodel(self, args_qmodel): """ Setup the quantum model: -- define the Hamiltonian H = - J(t) Sum_l (b_l b_{l+1}^t + h.c.) + U(t) Sum_l (n_l (n_{l}-1)) + mu Sum_l (n_l) with cyclical boundary conditions, U(t) = control_fun(t), J(t) = 1- U(t) """ # Define the hamiltonian self._verbose = args_qmodel.get('verbose', False) config_bh1D = { k: args_qmodel.get(k, v) for k, v in DEFAULT_MODEL.items() } self._basis = boson_basis_1d(**config_bh1D) self.L = config_bh1D['L'] self.Nb = config_bh1D['Nb'] self.mu = args_qmodel.get('mu', 0) U = self.control_fun args_U = [] J = lambda t: 1 - U(t) args_J = [] hop = [[-1, i, (i + 1) % self.L] for i in range(self.L)] # Cyclical boundaries dynamic_hop = [['+-', hop, J, args_J], ['-+', hop, J, args_J]] inter_nn = [[0.5, i, i] for i in range(self.L)] inter_n = [[-0.5, i] for i in range(self.L)] dynamic_inter = [['nn', inter_nn, U, args_U], ['n', inter_n, U, args_U]] dynamic = dynamic_inter + dynamic_hop pot_n = [[self.mu, i] for i in range(self.L)] static = [['n', pot_n]] self._H = hamiltonian(static, dynamic, basis=self._basis, dtype=np.float64) # Define initial and target state _, init = self._H.eigsh(time=0.0, k=1, which='SA', maxiter=1E10) _, tgt = self._H.eigsh(time=np.inf, k=1, which='SA', maxiter=1E10) self.state_init = np.squeeze(init) self.state_tgt = np.squeeze(tgt)
import numpy as np # generic math functions # ##### define model parameters ##### L = 5 # system size J = 1.0 # hopping strength g = 0.809 # amplitude for creating boson mu = 0.9045 # chemical potential U = 1.5 # onsite interaction strength ##### define periodic drive ##### Omega = 4.5 # drive frequency def drive(t, Omega): return np.cos(Omega * t) drive_args = [Omega] # ##### construct basis in the 0-total momentum and +1-parity sector basis = boson_basis_1d(L=L, sps=3, a=1, kblock=0, pblock=1) print(basis) # define PBC site-coupling lists for operators b_pot = [[g, i] for i in range(L)] n_pot = [[-mu, i] for i in range(L)] J_nn = [[-J, i, (i + 1) % L] for i in range(L)] # PBC U_int = [[U, i, i] for i in range(L)] # PBC # static and dynamic lists static = [["+-", J_nn], ["-+", J_nn], ["n", n_pot], ["nn", U_int]] dynamic = [["+", b_pot, drive, drive_args], ["-", b_pot, drive, drive_args]] ###### construct Hamiltonian H = hamiltonian(static, dynamic, dtype=np.float64, basis=basis)
##### define model parameters ##### L=1 # system size Np=101 J=1.0 mu=1.0/3.0 hopping=[[J,0]] chem_pot=[[mu,0]] static=[["+",hopping],["-",hopping],['n',chem_pot]] #### define boson model basis_boson = boson_basis_1d(L,sps=Np) H_boson=hamiltonian(static,[],basis=basis_boson,dtype=np.float64,check_herm=False,check_symm=False,check_pcon=False) E_boson=H_boson.eigvalsh() #### define photon model basis_ho = ho_basis(Np-1) H_ho=hamiltonian(static,[],basis=basis_ho,dtype=np.float64,check_herm=False,check_symm=False,check_pcon=False) E_ho=H_ho.eigvalsh() #print(max(abs(E_boson-E_ho)))
actson = [[1,i,j]] static = [["nn", actson]] dynamic = [] return hamiltonian(static, dynamic, basis=basis, dtype = dtype, check_symm = check_symm) def Ryd_Hamiltonian_bosons(L, Vlist, Delta, Omega, basis): # PBC LF=[[-Delta,i] for i in range(L)] TF=[[-Omega/2,i] for i in range(L)] static = [['nn', Vlist], ['n', LF], ['+', TF], ['-', TF]] dynamic = [] H=hamiltonian(static,dynamic,basis=basis,check_symm = True, dtype=np.float64) energy, psi = H.eigsh(k=1, which='SA') return energy, psi #Setting parameters of our Hamiltonian Lx = 3 Ly = 3 L = Lx*Ly V = 1 ktrunc = 3 D = 0 Vs = get_kn_interactions(V, ktrunc, Lx, Ly) Vbar = np.sum([Vs[i][0] for i in range(len(Vs))]) basis = boson_basis_1d(L, sps =2) O =0.1 energy0, psi0 = Ryd_Hamiltonian_bosons(L, Vs, D, O, basis) print(energy0)
import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt ###### define model parameters ###### #N=8 # lattice sites N = 10 # lattice sites #N_sps=3 # states per site N_sps = 10 # states per site Nb = N # total number of bosons print("N", N) print("N_sps", N_sps) print("Nb", Nb) ###### setting up bases ###### basis_1d = boson_basis_1d(N, Nb=Nb, sps=N_sps) #basis_1d=boson_basis_1d(N,Nb=Nb,sps=N_sps,kblock=0,pblock=1) ###### setting up hamiltonian ###### # J0 = 0.0 # hopping matrix element U0 = 3.01 # onsite interaction #hopping0=[[-J0,j,(j+1)%N] for j in range(N)] hopping0 = [[-J0, j, (j + 1) % N] for j in range(N - 1)] interaction0 = [[0.5 * U0, j, j] for j in range(N)] potential0 = [[-0.5 * U0, j] for j in range(N)] static0 = [["+-", hopping0], ["-+", hopping0], ["nn", interaction0], ["n", potential0]] dynamic0 = [] no_checks = dict(check_symm=False, check_pcon=False, check_herm=False) H0 = hamiltonian(static0, dynamic0,
from quspin.basis import boson_basis_1d # Hilbert space spin basis import numpy as np # generic math functions # ##### define model parameters ##### L=6 # system size J=1.0 # hopping U=np.sqrt(2) # interaction mu=0.0 # chemical potential # ##### construct single-particle Hamiltonian ##### # define boson basis with 3 states per site L bosons in the lattice #basis = boson_basis_1d(L,Nb=L) # full boson basis #basis = boson_basis_1d(L,Nb=L,sps=3) # reduced basis, 3 states per site #basis = boson_basis_1d(L,Nb=L,sps=3,kblock=0) # ... and zero momentum sector #basis = boson_basis_1d(L,Nb=L,sps=3,kblock=1) # ... and first non-zero momentum basis = boson_basis_1d(L,Nb=L,sps=3,kblock=0,pblock=1,cblock=1) # ... + zero momentum and positive parity print(basis) # define site-coupling lists hop=[[-J,i,(i+1)%L] for i in range(L)] #PBC interact=[[0.5*U,i,i] for i in range(L)] # U/2 \sum_j n_j n_j pot=[[-mu-0.5*U,i] for i in range(L)] # -(\mu + U/2) \sum_j j_n # define static and dynamic lists static=[['+-',hop],['-+',hop],['n',pot],['nn',interact]] dynamic=[] # build Hamiltonian H=hamiltonian(static,dynamic,basis=basis,dtype=np.float64) # calculate eigensystem E,V=H.eigh() E1,V1=np.linalg.eig(H.toarray()) E_GS,V_GS=H.eigsh(k=2,which='SA',maxiter=1E10) # only GS print("eigenenergies:", E[0])
i_CM = L//2 # model params J=1.0 mu=0.002 A=1.0 Omega=2.5 hopping=[[-J,i,(i+1)%L] for i in range(L-1)] trap=[[mu*(i-i_CM)**2,i] for i in range(L)] shaking=[[A*Omega*(i-i_CM),i] for i in range(L)] # define basis basis = boson_basis_1d(L,Nb=1,sps=2) ### Hamiltonian def drive(t,Omega): return np.cos(Omega*t) drive_args=[Omega] static=[["+-",hopping],["-+",hopping],['n',trap]] dynamic=[["n",shaking,drive,drive_args]] #### calculate Hamiltonian H=hamiltonian(static,dynamic,basis=basis,dtype=np.float64) E,V=H.eigh()
elif PBC==-1: basis_spin = spin_basis_1d(L=L,zblock=1)#,a=1,kblock=0,pblock=1) static_spin =[["zz",J_zz],["x",x_field]] H_spin=hamiltonian(static_spin,[],basis=basis_spin,dtype=np.float64) E_spin=H_spin.eigvalsh() #### define hcb model J_zz=[[-4.0*J,i,(i+1)%L] for i in range(L)] # PBC x_field=[[-h,i] for i in range(L)] if PBC==1: basis_hcb = boson_basis_1d(L=L,cblock=-1,sps=2)#,a=1,kblock=0,pblock=1) elif PBC==-1: basis_hcb = boson_basis_1d(L=L,cblock=1,sps=2)#,a=1,kblock=0,pblock=1) static_hcb =[["zz",J_zz],["+",x_field],["-",x_field]] H_hcb=hamiltonian(static_hcb,[],basis=basis_hcb,dtype=np.float64) E_hcb=H_hcb.eigvalsh() #### np.testing.assert_allclose(E_fermion-E_spin,0.0,atol=1E-6,err_msg='Failed fermion and spin energies comparison for PBC={}!'.format(PBC)) np.testing.assert_allclose(E_hcb-E_spin,0.0,atol=1E-6,err_msg='Failed hcb and spin energies comparison for PBC={}!'.format(PBC))
qspin_path = os.path.join(os.getcwd(), "../") 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
A=1.0 # drive amplitude Omega=3.0 # drive frequency def drive(t,Omega): return np.exp(-1j*A*np.sin(Omega*t) ) def drive_conj(t,Omega): return np.exp(+1j*A*np.sin(Omega*t) ) drive_args=[Omega] # drive arguments t=Floquet_t_vec(Omega,30,len_T=1) # time vector, 30 stroboscopic periods ### site-couping lists hopping=[[-J,i,(i+1)%L] for i in range(L)] trap=[[mu_trap*(i-i_CM)**2,i] for i in range(L)] ### operator strings for single-particle Hamiltonian static=[['n',trap]] dynamic=[["+-",hopping,drive,drive_args],["-+",hopping,drive_conj,drive_args]] # define single-particle basis basis = boson_basis_1d(L,Nb=1,sps=2) # Nb=1 boson and sps=2 states per site [empty and filled] ### build Hamiltonian H=hamiltonian(static,dynamic,basis=basis,dtype=np.complex128) # calculate eigenvalues and eigenvectors of free particle E,V=H.eigh() def GPE(time,phi): """ This function solves the complex-valued time-dependent Gross-Pitaevskii equation: -i\dot\phi(t) = H(t)\phi(t) + U |\phi(t)|^2 \phi(t) """ # solve static part of GPE phi_dot = -1j*( H.static.dot(phi) + U*np.abs(phi)**2*phi )
@author: fred """ import sys sys.path.append('/home/fred/anaconda3/envs/py36q/lib/python3.6/site-packages') from quspin.operators import hamiltonian # Hamiltonians and operators from quspin.basis import boson_basis_1d # Hilbert space boson basis import numpy as np # generic math functions import matplotlib.pylab as plt # ##Create Hamiltonian L, J, U, mu = 5, 1, 50, 0.0 # system size basis = boson_basis_1d(L, Nb=L, sps=3) hop = [[-J, i, (i + 1) % L] for i in range(L)] #PBC interact = [[0.5 * U, i, i] for i in range(L)] # U/2 \sum_j n_j n_j pot = [[-mu - 0.5 * U, i] for i in range(L)] # -(\mu + U/2) \sum_j j_n static = [['+-', hop], ['-+', hop], ['n', pot], ['nn', interact]] dynamic = [] H = hamiltonian(static, dynamic, basis=basis, dtype=np.float64) ## Compute variance of the number particle for site 0 for the GS E, V = H.eigsh(k=1, which='SA', maxiter=1E10) # only GS n_sites = [ hamiltonian([['n', [[1.0, i]]]], [], basis=basis, dtype=np.float64) for i in range(L) ]
def gen_H_no_inter(basis, L=5, J=1.0): hop=[[-J,i,(i+1)%L] for i in range(L)] #PBC static=[['+-',hop],['-+',hop]] H=hamiltonian(static,[],basis=basis,dtype=np.float64) return H # generate operator for one site (by defaut 'n0') def gen_operator_site(basis, op_string = 'n', site = 0): no_check_sym = {"check_symm" : False} return hamiltonian([[op_string, [[1.0, site]]]], [], basis = basis, **no_check_sym) # Basis without symmetry, get the ground state and compute expected value of n0 # for this state basis = boson_basis_1d(5, Nb=5, sps=3) H = gen_H_no_inter(basis) EGS, VGS = H.eigsh(time=0.0, k = 1, which = 'SA', maxiter = 1E10) n0 = gen_operator_site(basis) print(n0.expt_value(VGS)) # Basis with symmetry symH = {'kblock':0, 'pblock':1} basis_sym = boson_basis_1d(5, Nb=5, sps=3, **symH) H_sym = gen_H_no_inter(basis_sym) EGS_sym, VGS_sym = H_sym.eigsh(time=0.0, k = 1, which = 'SA', maxiter = 1E10) n0_sym = gen_operator_site(basis_sym) print(n0_sym.expt_value(VGS_sym))
def get_hcb_basis(N, **symms): """returns basis object for N hard-core bosons. The operator strings are 'n', '+', '-'""" return boson_basis_1d(N, sps=2, **symms)
sys.path.append('/home/fred/anaconda3/envs/py36q/lib/python3.6/site-packages') from quspin.operators import hamiltonian # Hamiltonians and operators from quspin.basis import boson_basis_1d # Hilbert space boson basis import numpy as np # generic math functions import matplotlib.pylab as plt # ## ================================== ## ## System meta-parameters ## ================================== ## L, mu =5, 0.0 # system size #basis = boson_basis_1d(L,Nb=L, sps=3) basis = boson_basis_1d(L,Nb=L, sps=3, kblock=0, pblock=1) ## ================================== ## ## Some ad-hoc functions ## ================================== ## def variance(O, V): OV = O.dot(V) VOOV = np.asscalar(O.matrix_ele(V, OV)) VOV2 = O.expt_value(V) ** 2 var = VOOV -VOV2 return var def gen_linear_ramp(v, T = 1, ymin=0, ymax=1): ramp = (lambda t: ymin + v * t) T = (ymax - ymin)/v
dynamic = dynamic_inter + dynamic_hop pot_n = [[mu, i] for i in range(L)] static = [['n', pot_n]] H = hamiltonian(static, dynamic, basis=basis, dtype=np.float64) return H, T ## ================================== ## ## Hamiltonian ## ================================== ## L, mu, v = 5, 0.0, 0.1 # system size symH = {'kblock': 0, 'pblock': 1} no_check_sym = {"check_symm": False} basis_sym = boson_basis_1d(L, Nb=L, sps=3, **symH) basis = boson_basis_1d(L, Nb=L, sps=3) H, T = gen_ramped_h(basis, v, L, mu) H_sym, T = gen_ramped_h(basis_sym, v, L, mu) ## ================================== ## ## Comparaison between sym/nosym ## Look at the GS at init, final ## Can I build the Dispersion relation?? ## ## ================================== ## n_sites = [ hamiltonian([['n', [[1.0, i]]]], [], basis=basis, dtype=np.float64,
J_zz=[[J,i,(i+1)%L] for i in range(L)] # PBC x_field=[[h,i] for i in range(L)] hopping=[[0.5*h,i] for i in range(L)] chem_pot=[[-J,i] for i in range(L)] identity=[[0.25,i] for i in range(L)] #### define spin model basis_spin = spin_basis_1d(L=L,pauli=False,a=1,kblock=0,pblock=1) static_spin =[["zz",J_zz],["x",x_field]] H_spin=hamiltonian(static_spin,[],basis=basis_spin,dtype=np.float32) E_spin=H_spin.eigvalsh() #### define hcb model basis_boson = boson_basis_1d(L=L,sps=2,a=1,kblock=0,pblock=1) static_boson =[["+",hopping],["-",hopping],["n",chem_pot],["nn",J_zz],["I",identity]] H_boson=hamiltonian(static_boson,[],basis=basis_boson,dtype=np.float32) E_boson=H_boson.eigvalsh() #print(max(abs(E_boson-E_spin))) #### np.testing.assert_allclose(E_boson-E_spin,0.0,atol=1E-5,err_msg='Failed boson and ho energies comparison!')
blocks = [dict(kblock=kblock) for kblock in range(L)] # blocks to project on to baisis_args = (L, ) # boson_basis_1d manditory arguments basis_kwargs = dict(Nb=L // 2, sps=3) # boson_basis_1d optional args get_proj_kwargs = dict(pcon=True) # set projection to full particle basis H_block = block_ops(blocks, static, dynamic, boson_basis_1d, baisis_args, np.complex128, basis_kwargs=basis_kwargs, get_proj_kwargs=get_proj_kwargs) # # setting up local Fock basis basis = boson_basis_1d(L, Nb=L // 2, sps=3) # setting up observables no_checks = dict(check_herm=False, check_symm=False, check_pcon=False) n_list = [ hamiltonian([["n", [[1.0, i]]]], [], basis=basis, dtype=np.float64, **no_checks) for i in range(L) ] # ##### time evolution # set up initial state i0 = basis.index("111000") # pick state from basis set psi = np.zeros(basis.Ns, dtype=np.float64) psi[i0] = 1.0 # print info about setup
Jb, Jf = 1.0, 1.0 # boson, fermon hopping strength Uff, Ubb, Ubf = -2.0, 0.5, 5.0 # bb, ff, bf interaction # define time-dependent perturbation A = 2.0 Omega = 1.0 def drive(t, Omega): return np.sin(Omega * t) drive_args = [Omega] # ###### create the basis # build the two bases to tensor together to a bose-fermi mixture basis_b = boson_basis_1d(L, Nb=Nb, sps=3) # boson basis basis_f = spinless_fermion_basis_1d(L, Nf=Nf) # fermion basis basis = tensor_basis(basis_b, basis_f) # BFM # ##### create model # define site-coupling lists hop_b = [[-Jb, i, (i + 1) % L] for i in range(L)] # b hopping int_list_bb = [[Ubb / 2.0, i, i] for i in range(L)] # bb onsite interaction int_list_bb_lin = [[-Ubb / 2.0, i] for i in range(L)] # bb interaction, linear term # hop_f_right = [[-Jf, i, (i + 1) % L] for i in range(L)] # f hopping right hop_f_left = [[Jf, i, (i + 1) % L] for i in range(L)] # f hopping left int_list_ff = [[Uff, i, (i + 1) % L] for i in range(L)] # ff nearest-neighbour interaction drive_f = [[A * (-1.0)**i, i] for i in range(L)] # density staggered drive
def check_getvec_boson(L, sps=2, a=1, sparse=True): dtype = np.complex128 jb = [[i, 1.0] for i in range(L)] static = [ ['nn', J(L, jb, 2)], ['+-', J(L, jb, 2)], ['-+', J(L, jb, 2)], ['nnnn', J(L, jb, 4)], ['+nn-', J(L, jb, 4)], ['-nn+', J(L, jb, 4)], ['++--', J(L, jb, 4)], ['--++', J(L, jb, 4)], ['+-+-', J(L, jb, 4)], ['-+-+', J(L, jb, 4)], ] b_full = boson_basis_1d(L, sps=sps) H1 = hamiltonian(static, [], basis=b_full, dtype=dtype) H1 = H1.todense() for k in range(-L // a, L // a): getvec_boson(L, H1, static, sps=sps, kblock=k, a=a, sparse=sparse) for j in range(-1, 2, 2): getvec_boson(L, H1, static, sps=sps, pblock=j, a=a, sparse=sparse) for k in range(-L // a, L // a): getvec_boson(L, H1, static, sps=sps, kblock=k, pblock=j, a=a, sparse=sparse) for Nb in range(L + 1): for k in range(-L // a, L // a): getvec_boson(L, H1, static, sps=sps, Nb=Nb, kblock=k, a=a, sparse=sparse) for Nb in range(0, L + 1): for j in range(-1, 2, 2): getvec_boson(L, H1, static, sps=sps, Nb=Nb, pblock=j, a=a, sparse=sparse) for k in range(-L // a, L // a): getvec_boson(L, H1, static, sps=sps, kblock=k, Nb=Nb, pblock=j, a=a, sparse=sparse)
#import scipy as scipy #import matplotlib.pyplot as plt import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt ###### define model parameters ###### N = 11 # lattice sites #N_sps=3 # states per site N_sps = 10 # states per site Nb = N # total number of bosons print("N", N) print("N_sps", N_sps) print("Nb", Nb) ###### setting up bases ###### basis_1d = boson_basis_1d(N, Nb=Nb, sps=N_sps, kblock=0, pblock=1) ###### setting up hamiltonian ###### # J0 = 0.0 # hopping matrix element U0 = 1.0 # onsite interaction hopping0 = [[-J0, j, (j + 1) % N] for j in range(N)] interaction0 = [[0.5 * U0, j, j] for j in range(N)] potential0 = [[-0.5 * U0, j] for j in range(N)] static0 = [["+-", hopping0], ["-+", hopping0], ["nn", interaction0], ["n", potential0]] dynamic0 = [] no_checks = dict(check_symm=False, check_pcon=False, check_herm=False) H0 = hamiltonian(static0, dynamic0, static_fmt="csr", basis=basis_1d,
static = [ ["+-",hop_list], # hopping ["-+",hop_list_hc], # hopping h.c. ["nn",int_list_2], # U n_i^2 ["n",int_list_1] # -U n_i ] dynamic = [] # no dynamic operators # create block_ops object blocks=[dict(kblock=kblock) for kblock in range(L)] # blocks to project on to baisis_args = (N,) # boson_basis_1d manditory arguments basis_kwargs = dict(nb=nb,sps=sps,a=2) # boson_basis_1d optional args get_proj_kwargs = dict(pcon=True) # set projection to full particle basis H_block = block_ops(blocks,static,dynamic,boson_basis_1d,baisis_args,np.complex128, basis_kwargs=basis_kwargs,get_proj_kwargs=get_proj_kwargs) # setting up local Fock basis basis = boson_basis_1d(N,nb=nb,sps=sps) # setting up observables no_checks = dict(check_herm=False,check_symm=False,check_pcon=False) n_list = [hamiltonian([["n",[[1.0,i]]]],[],basis=basis,dtype=np.float64,**no_checks) for i in range(N)] ##### do time evolution # set up initial state i0 = np.random.randint(basis.Ns) # pick random state from basis set psi = np.zeros(basis.Ns,dtype=np.float64) psi[i0] = 1.0 # print info about setup state_str = "".join(str(int((basis[i0]//basis.sps**(L-i-1)))%basis.sps) for i in range(N)) print("total H-space size: {}, initial state: |{}>".format(basis.Ns,state_str)) # setting up parameters for evolution start,stop,num = 0,30,301 # 0.1 equally spaced points times = np.linspace(start,stop,num) # calculating the evolved states
J = (lambda t: 1 - U(t)) args_U, args_J = [], [] hop = [[-1, i, (i + 1) % L] for i in range(L)] #PBC dynamic_hop = [['+-', hop, J, args_J], ['-+', hop, J, args_J]] inter_nn = [[0.5, i, i] for i in range(L)] inter_n = [[-0.5, i] for i in range(L)] dynamic_inter = [['nn', inter_nn, U, args_U], ['n', inter_n, U, args_U]] dynamic = dynamic_inter + dynamic_hop pot_n = [[mu, i] for i in range(L)] static = [['n', pot_n]] H = hamiltonian(static, dynamic, basis=basis, dtype=np.float64) return H, T ## ================================== ## ## Hamiltonian ## ================================== ## L, mu, v = 5, 0.0, 0.01 # system size symH = {'kblock': 0, 'pblock': 1} no_check_sym = {"check_symm": False} basis = boson_basis_1d(L, Nb=L, sps=3, **symH) H, T = gen_ramped_h(basis, v, L, mu) E_SF, V_SF = H.eigsh(time=0.0, k=1, which='SA', maxiter=1E10) # only GS psi_i = np.squeeze(V_SF) psi_f = H.evolve(psi_i, 0, np.arange(0, T, 1))
count_particles_args=count_particles_args, n_sectors=n_sectors) op_dict = dict(op=op, op_args=op_args) # create user basiss basis = user_basis(np.uint32, N, op_dict, allowed_ops=set("+-nI"), sps=sps, pcon_dict=pcon_dict, **maps) # # # ############ create same boson basis_1d object ############# basis_1d = boson_basis_1d(N, Nb=Np, sps=sps, kblock=0, pblock=1) # # print(basis) print(basis_1d) # ############ create Hamiltonians ############# # J = -1.0 U = +1.0 # hopping = [[+J, j, (j + 1) % N] for j in range(N)] int_bb = [[0.5 * U, j, j] for j in range(N)] int_b = [[-0.5 * U, j] for j in range(N)] # static = [["+-", hopping], ["-+", hopping], ["nn", int_bb], ["n", int_b]]
sys.path.insert(0, quspin_path) from quspin.operators import hamiltonian # Hamiltonians and operators from quspin.basis import boson_basis_1d, spin_basis_1d # Hilbert space spin basis from quspin.tools.measurements import ent_entropy import numpy as np # generic math functions ##### define model parameters ##### L = 6 # system size J = 1.0 # hopping U = np.sqrt(2) # interactions strenth # define site-coupling lists interaction = [[U / 2.0, i, i] for i in range(L)] # PBC chem_pot = [[-U / 2.0, i] for i in range(L)] # PBC hopping = [[J, i, (i + 1) % L] for i in range(L)] # PBC #### define hcb model basis = boson_basis_1d(L=L, Nb=L, sps=L + 1, kblock=0, pblock=1) # Hubbard-related model static = [["+-", hopping], ["-+", hopping], ["n", chem_pot], ["nn", interaction]] H = hamiltonian(static, [], basis=basis, dtype=np.float32) E, V = H.eigh() Sent = ent_entropy({'V_states': V}, basis, chain_subsys=range(L // 2))['Sent'] #print(Sent)
from quspin.basis import boson_basis_1d, spin_basis_1d from quspin.operators import hamiltonian, exp_op from quspin.tools.measurements import obs_vs_time import numpy as np import matplotlib.pyplot as plt N = 10 L = 2 * N start = 0 stop = 10 num = 20 endpoint = True basis = boson_basis_1d(L, Nb=N) np.random.seed() U_1 = [[1.0, i, i] for i in range(L)] U_2 = [[-1.0, i] for i in range(L)] t = [[1.0, i, (i + 1)] for i in range(L - 1)] I_list = [[(-1.0)**i, i] for i in range(L)] static = [["+-", t], ["-+", t], ["nn", U_1], ["n", U_2]] dynamic = [] static, dynamic = basis.expanded_form(static, dynamic) H0 = hamiltonian(static, dynamic, basis=basis, dtype=np.float32) I = hamiltonian([["n", I_list]], [], basis=basis, dtype=np.float32) / N