triqs.gfs.block_gf.BlockGf

class triqs.gfs.block_gf.BlockGf(**kwargs)[source]

Bases: object

Block-diagonal Green’s function.

A BlockGf is an ordered, named collection of Gf blocks sharing the same mesh and underlying type — for instance one block per spin or one block per symmetry sector. Block access uses either the string block name (g['up']) or the positional integer index (g[0]). Iteration yields (name, block) pairs in construction order.

Three keyword-only constructor patterns are supported (see Examples):

  1. BlockGf(name_list=..., block_list=..., make_copies=False, name='G') — explicit list of blocks.

  2. BlockGf(mesh=..., gf_struct=..., target_rank=2, name='G') — build matrix-valued blocks from a mesh and block structure.

  3. BlockGf(name_block_generator=..., make_copies=False, name='G') — iterable of (name, block) pairs.

Parameters:
name_listlist of str, optional

Block names, e.g. ['up', 'dn']. Pattern 1 only. Defaults to ['0', '1', ...] when block_list is provided.

block_listlist of Gf, optional

One Gf per block. Pattern 1 only. All blocks must have the same Python type.

meshMesh, optional

Common mesh for every block. Pattern 2 only.

gf_structlist of (str, int), optional

(block_name, linear_size) pairs. Pattern 2 only.

target_rankint, optional

Rank of the target space of each block. Pattern 2 only. Default 2 (matrix-valued).

name_block_generatoriterable of (str, Gf), optional

Iterable of (name, block) pairs. Pattern 3 only.

make_copiesbool, optional

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

namestr, optional

Plot label. Default 'G'.

Attributes

mesh

Mesh shared by every block.

beta

Inverse temperature \(\beta\).

indices

Block names in construction order.

all_indices

Iterate over flat indices (block_name, n1, n2) for every matrix-valued block.

gf_struct

Canonical block structure.

n_blocks

Number of blocks.

real

Block-wise view of the real part.

imag

Block-wise view of the imaginary part.

name

(str) Plot label; also used as a prefix for the individual block names.

Methods

conjugate()

Complex-conjugate every block.

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_blocks)

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

density(*args, **kwargs)

Compute per-block single-particle density matrices.

inverse()

Compute the inverse of every block.

invert()

Invert each block in place.

load(filename[, no_exception])

Load each block from a text file filename_<blockname>.

save(filename[, accumulate])

Save each block to a text file filename_<blockname>.

total_density(*args, **kwargs)

Compute the total density summed over all blocks.

transpose()

Transpose every block in target space.

view_selected_blocks(selected_blocks)

Return a new BlockGf 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 lazy initializers / Green’s functions to every block; see __lshift__().

Examples

Construct a two-block matrix-valued Matsubara Green’s function and fill every block with a semicircular DOS:

>>> from triqs.gfs import BlockGf, SemiCircular
>>> from triqs.mesh import MeshImFreq
>>> mesh = MeshImFreq(beta=10.0, statistic='Fermion', n_iw=1024)
>>> G = BlockGf(mesh=mesh, gf_struct=[('up', 2), ('dn', 2)])
>>> G << SemiCircular(half_bandwidth=1.0)
>>> for name, g in G:
...     print(name, g.target_shape)