triqs.gfs.gf.Gf
- class triqs.gfs.gf.Gf(**kw)[source]
Bases:
objectContainer for Green’s functions and related quantities.
A
Gfis 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) orMeshProduct, 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
MeshImTimeas 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
MeshImFreqas the underlying mesh and \(T = \mathbb{C}^{N \times N}\) as the target space.
Under the hood,
Gfstores a contiguousnumpy.ndarrayof shape(*mesh_sizes, *target_shape)(seedata). What is stored and how Green’s functions are evaluated depends on the mesh.Supported features include:
Bracket lookup
g[...]and call-style evaluationg(...)(see Notes).Element-wise arithmetic (
+,-,*,/,@) and in-place variants. Scalars broadcast along the target-space diagonal for square matrix targets; mixing twoGfrequires identical meshes.Lazy initialization via
g << exprfrom descriptors (e.g.g << iOmega_n + 0.5,g << SemiCircular(1.0)). See__lshift__()andtriqs.gfs.descriptors.HDF5 read/write through
h5.HDFArchive.
- 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 withtarget_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 withdata.- is_realbool, optional
If
True(andtarget_shapeis given), allocate the data asfloat64instead ofcomplex128. Has no effect whendatais supplied. DefaultFalse.- namestr, optional
Name used for plot labels. Default
''.- indiceslist, optional
Deprecated. String indices are no longer supported; passing this argument emits a
FutureWarningand the lengths are used to derivetarget_shape.
Attributes
The mesh of the Green's function.
Raw storage of the Green's function.
Mesh rank — number of mesh axes.
Number of target-space axes.
Shape of the target space.
Real-part view sharing the underlying mesh.
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 of the Green's function.
copy()Return an independent deep copy of
self.copy_from(another)In-place copy from
anotherintoself.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).
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
Gfwith brackets[]vs. parentheses():g[x]looks up the value at an existing mesh point, withxanIdx,MeshPoint, orMatsubaraFreq.g(x)instead evaluates the Green’s function at an arbitraryxusing 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 theGf, 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