joselado / dmrgpy

DMRGPy is a Python library to compute quasi-one-dimensional spin chains and fermionic systems using matrix product states with DMRG as implemented in ITensor. Most of the computations can be performed both with DMRG and exact diagonalization for small systems, which allows one to benchmark the results.
GNU General Public License v3.0
84 stars 20 forks source link

confusing example in README.md #2

Closed oroszl closed 4 years ago

oroszl commented 4 years ago

Let me just start by saying that I RALLY like the package, nice interface to DMRG!

I think the example "Spin and charge correlator of the 1D Hubbard model " in the README.md has some typos. specifically, I think it should be I noted corrections with NOTE

from dmrgpy import fermionchain
n = 20 # number of sites
fc = fermionchain.Spinful_Fermionic_Chain(n)
# first neighbor hopping
h = 0
for i in range(n-1):
  h = h+fc.Cdagup[i]*fc.Cup[i+1]            # NOTE  h = h+... instead just h = ...
  h = h+fc.Cdagdn[i]*fc.Cdn[i+1]
h = h.get_dagger() # Make Hermitian
# Hubbard term
for i in range(n):  # NOTE  range should go for all sites
  h = 2.*(fc.Nup[i]-.5)*(fc.Ndn[i]-.5)    # NOTE Ndn instead of Cup[i+1]
fc.set_hamiltonian(h) # initialize the Hamiltonian
pairs = [(0,i) for i in range(n)]
# compute the two correlators
zz = [fc,vev(fc.Sz[0]*fc.Sz[i]).real for i in range(n)]
cc = [fc,vev(fc.Cdagup[0]*fc.Cup[i]).real for i in range(n)]
print("Spin correlators",zz)
print("Site correlators",cc)

Am I correct? I was not sure if this warranted a pull request.. :)

joselado commented 4 years ago

Fixed, thanks!

oroszl commented 4 years ago

I forgot this one h = h.get_dagger() # Make Hermitian this should be h = h + h.get_dagger() # Make Hermitian

joselado commented 4 years ago

Thanks a lot! I also fixed that one.