numericalEFT / GreenFunc.jl

Toolbox to study quantum many-body problem at the treelevel
https://numericaleft.github.io/GreenFunc.jl/
MIT License
11 stars 1 forks source link

Triqs example #28

Closed kunyuan closed 1 year ago

kunyuan commented 2 years ago

The following code is an example from Triqs to create a Green's function for the Hubbard model, we may learn from them how to design the Greenfunc API.

from triqs.gf import *
from triqs.lattice import *
from triqs.lattice.tight_binding import *
from numpy import cos, pi

BL = BravaisLattice(units = [(1,0,0) , (0,1,0) ]) #square lattice
nk=20
mk = MeshBrillouinZone(BrillouinZone(BL), nk)
miw=MeshImFreq(beta=1., S="Fermion", n_max=100) #grid number : 201
mprod = MeshProduct(mk, miw) 

G_w = GfImFreq(mesh=miw, target_shape=[1,1]) #G_w.data.shape will be [201, 1, 1]
G_k_w = GfImFreq(mesh=mprod, target_shape=[1,1]) #G_k_w.data.shape will be [400, 201, 1, 1]

t=1.0
U=4.0

####### fill the Green's function with data ################
ik=0
for k in G_k_w.mesh.components[0]:
  G_w << inverse(iOmega_n-2*t*(cos(k[0])+cos(k[1])))
  G_k_w.data[ik,:,0,0]=G_w.data[:,0,0]
  ik+=1
kunyuan commented 1 year ago

julia implementation added to the example folder