TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
139 stars 72 forks source link

BrillouinZone interpolation with different mesh define (iw,k) or (k,iw) #888

Closed weiyiguo9 closed 1 year ago

weiyiguo9 commented 1 year ago

Hi All,

It seems the BrillouinZone interpolation doesn't work well if the MeshProduct defined as the same as (k,iw)

I first found this when I use TPRF with function lattice_dyson_g0_wk(). Therefore I checked the different order of k and iw for mesh product, and the behevious when interpolation over k-point. From my side, the BrillouinZone interpolation of meshed GF only works if I use MeshProduct(k_mesh,iw_mesh)

Steps to Reproduce

  1. Error case If I run the following code,
    
    from triqs.lattice import BravaisLattice, BrillouinZone
    from triqs.gf import Gf, MeshProduct, MeshBrZone, MeshImFreq
    import numpy as np
    from math import cos, pi

beta = 2 # Inverse temperature t = 1.0 # Hopping (unit of energy) mu = 0 # Chemical potential

def eps(k): return -2t (cos(k[0]) + cos(k[1]))

BL = BravaisLattice([(1,0,0), (0,1,0)]) # Two unit vectors in R3 BZ = BrillouinZone(BL)

n_k denotes the number of k-points for each dimension

n_k = 3 k_mesh = MeshBrZone(bz=BZ, n_k=n_k)

iw_mesh = MeshImFreq(beta=beta, S='Fermion', n_iw=128) k_iw_mesh = MeshProduct(iw_mesh,k_mesh)

G = Gf(mesh=k_iw_mesh, target_shape=[])

for iw, k in G.mesh: G[iw,k] = 1/(iw + mu - eps(k))

G(2,(0.1,0.1,0))


There will be error prompted, 

TypeError Traceback (most recent call last) Cell In[17], line 1 ----> 1 G(2,(0.1,0.1,0))

File /opt/triqs/lib/python3.11/site-packages/triqs/gf/gf.py:421, in Gf.call(self, args) 419 def call(self, args) : 420 assert self._c_proxy, " no proxy" --> 421 return self._c_proxy(*args)

TypeError: CallProxyNone.call() takes 2 positional arguments but 3 were given

2. Worked case 
If I run, instead of above code,
```python
iw_mesh = MeshImFreq(beta=beta, S='Fermion', n_iw=128)
k_iw_mesh = MeshProduct(iw_mesh,k_mesh)

G = Gf(mesh=k_iw_mesh, target_shape=[])

for iw, k in G.mesh:
    G[iw,k] = 1/(iw + mu - eps(k))

G(2,(0.1,0.1,0))

The returned value is normal

  1. [and so on...]

Expected behavior: These two mesh define should gave identical value for BZ interpolation

Actual behavior: When the mesh defined as (iw,k), the interpolation doesn't work at all.

Versions

Please provide the version of the TRIQS library that you used.

You are using the TRIQS library version 3.1.1
You are using the git hash 3c27b35ffbdf0309989e85883344b91c39a98567

I'm running on MacOS 13.2.1

Additional Information

I attached the following files for reproducing the problem: example_error.txt example_normal.txt

Is there any workaround since I'm using the function lattice_dyson_g0_wk() from TPRF?

Thanks for your help. Best regards.

Weiyi

Wentzell commented 1 year ago

Thank you @weiyiguo9 for pointing this out. The evaluation capabilities were extended in bb6886907, which will be part of the next release.

weiyiguo9 commented 1 year ago

Thank you @weiyiguo9 for pointing this out. The evaluation capabilities were extended in bb68869, which will be part of the next release.

Thanks for letting me know this bug fix. I have compiled the latest unstable branch and everything works.