triqs.gfs.block2_gf.Block2Gf

class triqs.gfs.block2_gf.Block2Gf(name_list1, name_list2, block_list, **kwargs)[source]

Bases: object

Two-index block-diagonal Green’s function.

A Block2Gf is a rectangular, named collection of Gf blocks 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)) of Gf blocks, or a callable f(bn1, bn2) -> Gf invoked for every name pair.

make_copiesbool, optional

If True, store deep copies of the blocks; otherwise store the references. Default False.

namestr, optional

Plot label. Default ''.

Attributes

indices

Iterate over (bn1, bn2) pairs in row-major order.

indices1

Iterate over the first-index block names.

indices2

Iterate over the second-index block names.

all_indices

Iterate over flat indices (bn1, bn2, i, j, ...) for every target-space entry of every block.

n_blocks

Total number of blocks.

real

Block-wise view of the real part of every block.

imag

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 G2 into self block by block.

copy_selected_blocks(selected_blocks1, ...)

Return a new Block2Gf containing deep copies of the named blocks.

view_selected_blocks(selected_blocks1, ...)

Return a new Block2Gf containing 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)