def get_fc(u): fc = fermionchain.Spinful_Fermionic_Chain(n) # create the chain h = 0 for i in range(n - 1): h = h + fc.Cdagup[i] * fc.Cup[i + 1] h = h + fc.Cdagdn[i] * fc.Cdn[i + 1] for i in range(n): h = h + u * (fc.Nup[i] - 0.5) * (fc.Ndn[i] - 0.5) h = h + h.get_dagger() fc.set_hamiltonian(h) # Compute the dynamical correlator defined by # <0|c_i^dagger \delta(H-E_0-\omega) c_j |0> fc.nsweeps = 6 fc.maxm = 20 # maximum bond dimension in KPM return fc
# Add the root path of the dmrgpy library import os import sys sys.path.append(os.getcwd() + '/../../src') # for example PATH = /home/jose/programs/dmrgpy/src #PATH = PATH_TO_DMRGPY_LIBRARY import numpy as np import matplotlib.pyplot as plt from dmrgpy import fermionchain from dmrgpy import spinchain n = 6 # number of spin sites # first let us create a Hubabrd model fc = fermionchain.Spinful_Fermionic_Chain(n) # create the object fc.maxm = 20 U = 6.0 def ft(i, j): if abs(i // 2 - j // 2) == 1 and i % 2 == j % 2: return 1.0 # first neighbor coupling if i == j: return -2 * U # set to half filling return 0.0 def fu(i, j): if i == j: return U return 0.0
# 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.Spinful_Fermionic_Chain(n//2) # 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) # hoppings fc.set_swave_pairing(lambda i: 0.2) 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) ### Compute the dyamical correlator ###