Multivariable Green’s functions

Warning

This part of the library is largely experimental and subject to API breaks

TRIQS comes with multivariable Green’s functions such as \(G_{\sigma,\sigma',I}(i\omega,i\Omega)\) or \(\gamma(i\omega,i\omega',i\Omega)\).

They come with properties similar to the single-variable Greens functions, namely:

  • they have a mesh (which is the cartesian product of two one-dimensional meshes)
  • they have data (a numpy array of shape dim_var1 x dim_var2 x ... x dim_target_1 x dim_target_2 x ...)
  • they can be stored in a HDF5 archive
  • they can be broadcast, reduced
  • they can be sliced in the target space, one can access e.g. the element \(G_{\uparrow,\downarrow,z}(i\omega,i\Omega)\) in the example above

The main additional feature is the ability to slice the Greens function with respect to its frequency arguments. This is done via the functions ``slice_at_const_w1(n)``, ``slice_at_const_w2(n)``… where n is the Matsubara index of the first, second, … argument, respectively.

For instance, if G is the object representing \(\gamma(i\omega,i\omega',i\Omega)\), ``G.slice_at_const_w3(10).slice_at_const_w2(4)`` is the function \(i\omega_n \rightarrow \gamma(i\omega_n,i\omega'_4,i\Omega_{10})\)

The construction and use of these functions is illustrated for the following vertex function:

\[G^{\eta=\mathrm{ch},\mathrm{sp}}_{\sigma,\sigma',I}(i\omega,i\Omega) = \frac{U^2}{4}\frac{1}{(i\omega+i\Omega)(i\omega)}\]

This is a block function whose two blocks are defined on a product of two Matsubara frequency meshes, and are tensor-valued of rank 3: the blocks are encoded by objects of the type ``GfImFreq_x_ImFreqTv3``.

from triqs.gf.multivar import *
from triqs.gf import *
from h5 import *
from triqs.plot.mpl_interface import *
from matplotlib.gridspec import GridSpec
from math import pi

##construct the mesh
beta=50.0
n_max=100
m1=MeshImFreq(beta=beta, S="Fermion", n_max=n_max) #fermionic Matsubara frequency mesh
m2=MeshImFreq(beta=beta, S="Boson", n_max=n_max) # bosonic
mprod=MeshImFreqImFreq(m1,m2) # mesh product of m1 and m2

##construct the Gf
U=1.0
l_block=GfImFreq_x_ImFreqTv3(mesh=mprod, shape=[1,1,1]) #instantiation of the function
Lambda=BlockGf(name_list = ["ch","sp"],block_list = [l_block,l_block])

##fill with expression
g_om = GfImFreq(mesh=m1, shape=[1,1])
w=lambda n: 2*n*pi/beta*1j
for n in range(-n_max+1,n_max):
    g_om << U**2/4*inverse(iOmega_n+w(n))*inverse(iOmega_n)
    Lambda["ch"].data[:,n+n_max-1,0,0,0]=g_om.data[:,0,0]

###plot
gs=GridSpec(1,2)

plt.subplot(gs[0], aspect="equal")
oplot(Lambda["ch"][0,0,0], type="contourf")
plt.xlim(-2,2)
plt.ylim(-2,2)
plt.colorbar()

plt.subplot(gs[1])
for n in [0,5,10]:
 oplot(Lambda["ch"][0,0,0].slice_at_const_w2(n), mode="R", x_window=(-2,2), label=r"$\Lambda^\mathrm{ch}(i\omega, i\Omega_{%s})$"%n)
plt.ylabel("");
plt.legend(loc="best")
plt.tight_layout()
plt.show()

(Source code)