triqs.gfs.gf.Gf

class triqs.gfs.gf.Gf(**kw)[source]

Bases: object

Container for Green’s functions and related quantities.

A Gf is a container for generic functions defined on meshes:

\[G : \mathcal{M} \to T .\]

Here, \(\mathcal{M}\) is the domain of the function, determined entirely by the underlying mesh (see triqs.mesh.meshes) or MeshProduct, and \(T\) is the target space, which determines what quantities are stored at each mesh point (real/complex scalars, matrices, tensors).

Typical use cases include

  • scalar-valued imaginary time Green’s functions

    \[G(\tau) \equiv - \mathcal{T} \langle c(\tau) c^{\dagger} (0)\rangle \qquad \text{ for } 0 \leq \tau \leq \beta \; ,\]

    with MeshImTime as the underlying mesh and \(T = \mathbb{R}\) as the target space.

  • matrix-valued Matsubara Green’s functions

    \[G_{\alpha \beta} (i \omega_n) \equiv \int_0^\beta G_{\alpha \beta}(\tau) e^{i \omega_n \tau} d\tau \; ,\]

    with MeshImFreq as the underlying mesh and \(T = \mathbb{C}^{N \times N}\) as the target space.

Under the hood, Gf stores a contiguous numpy.ndarray of shape (*mesh_sizes, *target_shape) (see data). What is stored and how Green’s functions are evaluated depends on the mesh.

Supported features include:

  • Bracket lookup g[...] and call-style evaluation g(...) (see Notes).

  • Element-wise arithmetic (+, -, *, /, @) and in-place variants. Scalars broadcast along the target-space diagonal for square matrix targets; mixing two Gf requires identical meshes.

  • Lazy initialization via g << expr from descriptors (e.g. g << iOmega_n + 0.5, g << SemiCircular(1.0)). See __lshift__() and triqs.gfs.descriptors.

  • HDF5 read/write through h5.HDFArchive.

  • Target-space slicing and real / imag views.

Parameters:
meshMesh or MeshProduct

Mesh on which the Green’s function is defined.

datanumpy.ndarray, optional

Raw storage of shape (*mesh_sizes, *target_shape). Mutually exclusive with target_shape.

target_shapelist of int, optional

Shape of the target space (e.g. [2, 2] for a 2x2 matrix Green’s function, [] for a scalar). Mutually exclusive with data.

is_realbool, optional

If True (and target_shape is given), allocate the data as float64 instead of complex128. Has no effect when data is supplied. Default False.

namestr, optional

Name used for plot labels. Default ''.

indiceslist, optional

Deprecated. String indices are no longer supported; passing this argument emits a FutureWarning and the lengths are used to derive target_shape.

Attributes

mesh

The mesh of the Green's function.

data

Raw storage of the Green's function.

rank

Mesh rank — number of mesh axes.

target_rank

Number of target-space axes.

target_shape

Shape of the target space.

real

Real-part view sharing the underlying mesh.

imag

Imaginary-part view sharing the underlying mesh.

name

(str) Plot label.

Methods

__call__(*args)

Evaluate the Green's function at the given point(s).

conjugate()

Conjugate of the Green's function.

copy()

Return an independent deep copy of self.

copy_from(another)

In-place copy from another into self.

density(*args, **kwargs)

Compute the single-particle density matrix.

enforce_discontinuity(*args, **kw)

Enforce a prescribed jump at \(\tau = 0\) for a Legendre Green's function.

fit_hermitian_tail(*args, **kw)

Fit the high-frequency tail of a Green's function, imposing hermitian symmetry on the fitted moments.

fit_hermitian_tail_on_window(*args, **kw)

Fit the high-frequency tail on a restricted window, imposing hermitian moment matrices.

fit_tail(*args, **kw)

Fit the high-frequency tail of a Green's function using a least-squares procedure.

fit_tail_on_window(*args, **kw)

Fit the high-frequency tail of a Matsubara Green's function on a restricted frequency window.

from_L_G_R(L, G, R)

Matrix transform of the target space of a matrix valued Green's function.

inverse()

Computes the inverse of the Green's function.

invert()

Inverts the Green's function (in place).

is_gf_hermitian(*args, **kw)

Test whether a Green's function satisfies the hermitian symmetry up to a tolerance \(\epsilon\).

is_gf_real_in_tau(*args, **kw)

Test whether a Matsubara Green's function corresponds to a real imaginary-time Green's function.

rebinning_tau(*args, **kw)

Rebin an imaginary-time Green's function onto a coarser uniform mesh.

replace_by_tail(*args, **kw)

Overwrite the high-frequency tail of a Matsubara Green's function.

replace_by_tail_in_fit_window(*args, **kw)

Overwrite the high-frequency portion of a Matsubara Green's function with the tail expansion.

set_from_fourier(*args, **kw)

Fourier transform a Green's function in place from one mesh to its conjugate.

set_from_imfreq(*args, **kw)

Project a Matsubara Green's function onto the Legendre basis of the output.

set_from_imtime(*args, **kw)

Project an imaginary-time Green's function onto the Legendre basis of the output.

set_from_legendre(*args, **kw)

Project a Legendre Green's function onto the Matsubara mesh of the output.

set_from_pade(*args, **kw)

Analytically continue a Matsubara Green's function to the real-frequency axis using a Pade approximant.

tau_L2_norm(*args, **kw)

Calculate the \(L^2\) norm of a DLR Green's function.

total_density(*args, **kwargs)

Compute the total density (trace of the density matrix).

transpose()

Take the transpose of a matrix valued Green's function.

x_data_view([x_window, flatten_y])

Helper method for getting a view of the data.

zero()

Set all values to zero.

Notes

There are subtle differences when accessing a Gf with brackets [] vs. parentheses ():

  • g[x] looks up the value at an existing mesh point, with x an Idx, MeshPoint, or MatsubaraFreq.

  • g(x) instead evaluates the Green’s function at an arbitrary x using the interpolation rule the mesh declares – linear in imaginary time, exact in Matsubara, k-linear on the Brillouin zone, basis expansion on DLR / Legendre, etc. The mesh, not the Gf, decides what “evaluation” means.

Examples

Construct a scalar imaginary-time Green’s function and a 2x2 matrix-valued Matsubara Green’s function:

>>> from triqs.gfs import Gf
>>> from triqs.mesh import MeshImTime, MeshImFreq
>>> tau_mesh = MeshImTime(beta=10.0, statistic='Fermion', n_tau=2049)
>>> g_tau    = Gf(mesh=tau_mesh, target_shape=[])
>>> iw_mesh  = MeshImFreq(beta=10.0, statistic='Fermion', n_iw=1024)
>>> g_iw     = Gf(mesh=iw_mesh, target_shape=[2, 2])

Initialize lazily from a descriptor expression:

>>> from triqs.gfs import iOmega_n, SemiCircular
>>> g_iw  << iOmega_n + 0.5
>>> g_tau << SemiCircular(half_bandwidth=1.0)

Access the raw storage as a numpy array:

>>> g_iw.data.shape
(2048, 2, 2)
>>> g_iw.data[:] = 0.0                  # zero in place