def get_fc(mu): fc = fermionchain.Fermionic_Hamiltonian(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_fc(U): n = ns*2 fc = fermionchain.Fermionic_Hamiltonian(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 import matplotlib.pyplot as plt from dmrgpy import fermionchain n = 4 fc = fermionchain.Fermionic_Hamiltonian(n) # create the chain m = np.matrix(np.random.random((n, n)) + 1j * np.random.random((n, n))) m = m + m.H # Make it Hermitian def ft(i, j): return m[i, j] def fu(i, j): if abs(i - j) == 1: return 1.0 else: return 0.0 # Initialize the Hamiltonian fc.set_hoppings(ft) # hoppings fc.set_hubbard(fu) # hubbard e0 = fc.gs_energy(mode="ED") # energy with exact diagonalization e1 = fc.gs_energy(mode="DMRG") # energy with DMRG print("Energy with ED", e0) print("Energy with DMRG", e1)
# 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 n = 10 fc = fermionchain.Fermionic_Hamiltonian(n, spinful=False) # create the chain def ft(i, j): if abs(j - i) == 1: return 1.0 if i == j: return 0.5 return 0.0 fc.set_hoppings(ft) # hoppings e = fc.gs_energy() # energy with DMRG print("Ground state energy", e) import matplotlib.pyplot as plt # Now compute the ground state correlator pairs = [(0, i) for i in range(n)] cs0 = fc.get_correlator(pairs=pairs, mode="DMRG") cs1 = fc.get_correlator(pairs=pairs, mode="ED") x = np.array(range(len(cs0))) # distances plt.plot(x, cs0, c="blue", label="DMRG")
import numpy as np from dmrgpy import fermionchain nf = 10 # number of different spinless fermionic orbitals fc = fermionchain.Fermionic_Hamiltonian(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.