triqs.gfs.block2_gf.Block2Gf
- class triqs.gfs.block2_gf.Block2Gf(name_list1, name_list2, block_list, **kwargs)[source]
Bases:
objectTwo-index block-diagonal Green’s function.
A
Block2Gfis a rectangular, named collection ofGfblocks indexed by a pair(bn1, bn2)drawn from two — possibly distinct — sets of block names. It is the natural container for two-particle / four-leg quantities such as susceptibilities and vertex functions. Block access uses tuple indexing (g['up', 'dn']). Iteration yields((bn1, bn2), block)pairs in row-major order.- Parameters:
- name_list1sequence of hashable
Block names of the first index.
- name_list2sequence of hashable
Block names of the second index.
- block_listlist of lists of Gf, or callable
Either a 2D nested list of shape
(len(name_list1), len(name_list2))ofGfblocks, or a callablef(bn1, bn2) -> Gfinvoked for every name pair.- make_copiesbool, optional
If
True, store deep copies of the blocks; otherwise store the references. DefaultFalse.- namestr, optional
Plot label. Default
''.
Attributes
Iterate over
(bn1, bn2)pairs in row-major order.Iterate over the first-index block names.
Iterate over the second-index block names.
Iterate over flat indices
(bn1, bn2, i, j, ...)for every target-space entry of every block.Total number of blocks.
Block-wise view of the real part of every block.
Block-wise view of the imaginary part of every block.
name
(str) Plot label; also used as a prefix for the individual block names.
Methods
copy(*args)Return an independent deep copy of
self(every block is copied).copy_from(G2)Copy the data of
G2intoselfblock by block.copy_selected_blocks(selected_blocks1, ...)Return a new
Block2Gfcontaining deep copies of the named blocks.view_selected_blocks(selected_blocks1, ...)Return a new
Block2Gfcontaining views of the named blocks.zero()Set every block's data to zero, in place.
Notes
All blocks must be of the same Python type (e.g. all
Gf).The
<<operator broadcasts initializers to every block; see__lshift__().
Examples
Construct a 2x2 block susceptibility on a bosonic Matsubara mesh and iterate over the blocks:
>>> from triqs.gfs import Block2Gf, Gf >>> from triqs.mesh import MeshImFreq >>> mesh = MeshImFreq(beta=10.0, statistic='Boson', n_iw=64) >>> chi = Block2Gf(['up', 'dn'], ['up', 'dn'], ... lambda b1, b2: Gf(mesh=mesh, target_shape=[1, 1]), ... name='chi') >>> for (bn1, bn2), g in chi: ... print(bn1, bn2, g.target_shape)