def get(c01): """Compute entropy""" fc = fermionchain.Fermionic_Chain(n) h = 0 for i in range(n - 1): c = 1.0 # default coupling h = h - fc.C[i] * fc.Cdag[i] h = h + h.get_dagger() # add the Hermitian conjugate fc.set_hamiltonian(h) wf = fc.get_gs() # compute ground state s = wf.get_pair_entropy(0, None) # entropy of the sites (0,1) with the rest return s
def get(U): n = 6 # number of spinful fermionic sites fc = fermionchain.Fermionic_Chain(n) # create the chain h = 0 for i in range(n - 1): # hopping h = h + fc.Cdag[i] * fc.C[i + 1] h = h + U * (fc.N[i] - .5) * (fc.N[i + 1] - .5) h = h + h.get_dagger() ############################## # Setup the Many Body Hamiltonian fc.maxm = 40 fc.nsweeps = 10 fc.set_hamiltonian(h) # set the hoppings fc.get_gs(mode="ED") return fc.get_correlation_entropy()
def get_fc(mu): fc = fermionchain.Fermionic_Chain(n) # create the chain ####### Input matrices ####### # Array with the hoppings and with hubbard couplings # These are the matrices that you have to modify hopping = np.zeros((n, n)) hubbard = np.zeros((n, n)) for i in range(n - 1): hopping[i, i + 1] = 1. hopping[i + 1, i] = 1. for i in range(n - 3): hopping[i, i + 3] = 1. / 3. hopping[i + 3, i] = 1. / 3. for i in range(n): U = 4.0 hubbard[i, i] = U / 2. hopping[i, i] = -U + mu # The implemented Hamiltonian is # H = \sum_ij hopping[i,j] c^dagger_i c_j + hubbard[i,j] n_i n_j # with n_i = c^\dagger_{i,up} c_{i,up} + c^\dagger_{i,dn} c_{i,dn} # the previous matrices are for a half filled Hubbard chain ############################## # Setup the Many Body Hamiltonian fc.set_hoppings(lambda i, j: hopping[i, j]) # set the hoppings fc.set_hubbard(lambda i, j: hubbard[i, j]) # set the hubbard constants #fc.set_fields(lambda i: [0.,0.,0.2]) # set the hubbard constants #fc.nsweeps = 7 # Compute the dynamical correlator defined by # <0|c_i^dagger \delta(H-E_0-\omega) c_j |0> i = 0 # first index of the dynamical correlator j = 0 # second index of the dynamical correlator delta = 0.1 # energy resolution (approximate) fc.nsweeps = 14 fc.kpmmaxm = 20 # maximum bond dimension in KPM return fc
def get(V=0.0,c=1.0): """Return non-Hermitian eigenvalues V in the interaction c is the coupling between first and last sites""" n = 2 # number of tetramers ns = 4*n # total number of sites mh = np.zeros((ns,ns),dtype=np.complex) # TB matrix for i in range(ns-1): mh[i,i+1] = 1.0 mh[i+1,i] = 1.0 mh[ns-1,0] = c mh[0,ns-1] = c eta = 1.0 for i in range(n): mh[4*i,4*i] = 1j*eta mh[4*i+1,4*i+1] = -1j*eta mh[4*i+2,4*i+2] = -1j*eta mh[4*i+3,4*i+3] = 1j*eta fc = fermionchain.Fermionic_Chain(ns) # create the fermion chain h = 0 # initialize Hamiltonian # put all the hoppings for i in range(ns): for j in range(ns): h = h + mh[i,j]*fc.Cdag[i]*fc.C[j] for i in range(ns-1): h = h + V*(fc.N[i]-0.5)*(fc.N[i+1]-0.5) fc.set_hamiltonian(h) nex = 10 # lowest states # the following methods target the states with minimum Re(E) # use this if you wanted to use MPS # es,wfs = mpsalgebra.lowest_energy_non_hermitian_arnoldi(fc,h,verbose=1,n=nex,maxit=7) # this method is just for ED es,wfs = fc.get_excited_states(mode="ED",n=nex) # get excited states return es - es[0] # return energies
def get_fc(U): n = ns * 2 fc = fermionchain.Fermionic_Chain(n) # create the chain C = fc.C Cdag = fc.Cdag N = fc.N # add the Hamiltonian h = 0 # add hopping for i in range(ns - 1): for j in range(2): h = h + Cdag[2 * i + j] * C[2 * (i + 1) + j] # add Hubbard h = h + h.get_dagger() for i in range(ns): d = 0 for j in range(2): d = d + N[2 * i + j] h = h + U * (d * d - 2 * d) # Hubbard term fc.set_hamiltonian(h) print("Doing", U) return fc
# Add the root path of the dmrgpy library import os import sys sys.path.append(os.getcwd() + '/../../src') import numpy as np from dmrgpy import fermionchain ns = np.array(range(4, 30, 2)) es = [] n = 8 fc = fermionchain.Fermionic_Chain(n) # create the chain h = 0 for i in range(n - 1): h = h + fc.Cdag[i] * fc.C[i + 1] #for i in range(n-1): h = h +fc.Cdag[i]*fc.Cdag[i+1] for i in range(n - 1): h = h + 4 * fc.N[i] * fc.N[i + 1] h = h + h.get_dagger() fc.set_hamiltonian(h) A = fc.Cdag[0] B = fc.N[0] nt = 1e3 # number of time steps dt = 1e-2 # time step from dmrgpy import timedependent (x, y) = timedependent.evolution_ABA(fc, nt=nt, dt=dt, mode="ED", A=A, B=B) (x1, y1) = timedependent.evolution_ABA(fc, nt=nt, dt=dt, mode="DMRG", A=A, B=B) import matplotlib.pyplot as plt
# Add the root path of the dmrgpy library import os import sys sys.path.append(os.getcwd() + '/../../src') import numpy as np import matplotlib.pyplot as plt from dmrgpy import fermionchain from dmrgpy import multioperator n = 8 fc = fermionchain.Fermionic_Chain(n, spinful=False) # create the chain m = np.matrix(np.random.random((n, n)) + 1j * np.random.random((n, n))) m = m + m.H def ft(i, j): return m[i, j] if abs(j - i) == 1: return 1.0 return 0.0 fc.set_hoppings(ft) # hoppings den = 0 for i in range(n): # loop over sites deni = multioperator.obj2MO([["N", i]]) den = den + deni print("Total density with DMRG", fc.excited_vev(den, mode="DMRG", n=4).real) print("Total density with ED", fc.excited_vev(den, mode="ED", n=4).real)
import numpy as np from dmrgpy import fermionchain nf = 10 # number of different spinless fermionic orbitals fc = fermionchain.Fermionic_Chain(nf) # create the object C = fc.C # annihilation Cdag = fc.Cdag # creation H = 0 # initialize Hamiltonian # random Hamiltonian for i in range(nf-1): H = H + Cdag[i]*C[i+1]*np.random.random() # random first neigh. hopping H = H + C[i]*C[i+1]*np.random.random() # random first neigh. pairing # random first neigh. interaction H = H + Cdag[i]*C[i]*Cdag[i+1]*C[i+1]*np.random.random() H = H + H.get_dagger() # make it Hermitian fc.set_hamiltonian(H) # set the Hamiltonian print("Energy with DMRG",fc.gs_energy(mode="DMRG")) # energy with DMRG print("Energy with ED",fc.gs_energy(mode="ED")) # energy with exact diag.