triqs.gfs.block_gf.BlockGf
- class triqs.gfs.block_gf.BlockGf(**kwargs)[source]
Bases:
objectBlock-diagonal Green’s function.
A
BlockGfis an ordered, named collection ofGfblocks 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):
BlockGf(name_list=..., block_list=..., make_copies=False, name='G')— explicit list of blocks.BlockGf(mesh=..., gf_struct=..., target_rank=2, name='G')— build matrix-valued blocks from a mesh and block structure.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', ...]whenblock_listis provided.- block_listlist of Gf, optional
One
Gfper 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. DefaultFalse.- namestr, optional
Plot label. Default
'G'.
Attributes
Mesh shared by every block.
Inverse temperature \(\beta\).
Block names in construction order.
Iterate over flat indices
(block_name, n1, n2)for every matrix-valued block.Canonical block structure.
Number of blocks.
Block-wise view of the real part.
Block-wise view of the imaginary part.
name
(str) Plot label; also used as a prefix for the individual block names.
Methods
Complex-conjugate every block.
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_blocks)Return a new
BlockGfcontaining 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 every block in target space.
view_selected_blocks(selected_blocks)Return a new
BlockGfcontaining 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)