Helper functions

Block/index helpers for many-body operators and Green’s functions.

triqs.operators.util.op_struct.get_mkind(off_diag, map_operator_structure)[source]

Build the index function that maps a (spin, orbital) pair to an operator/GF-block index.

Parameters:
off_diagbool

If True, the operators and Green’s-function blocks are denoted by ('spin', 'orbital'); otherwise by ('spin_orbital', 0).

map_operator_structuredict

Mapping of GF-block names from one convention to another, e.g. {('up', 0): ('up_0', 0), ('down', 0): ('down_0', 0)}. If provided, the operators and blocks are labelled by the image of ('spin', 'orbital') under this mapping.

Returns:
callable

Function mkind(spin_name, orbital_name) returning a tuple suitable for indexing c() / c_dag() and the GF blocks.

triqs.operators.util.op_struct.set_operator_structure(spin_names, n_orb, off_diag)[source]

Build the operator block structure for the given spin and orbital names.

The shape of the structure follows the same convention as get_mkind(): one block per spin when off_diag is True, one block per (spin, orbital) pair otherwise.

Parameters:
spin_nameslist of str

Names of the spins, e.g. ['up', 'down'].

n_orbint

Number of orbitals.

off_diagbool

If True, blocks carry orbital off-diagonal elements; otherwise the blocks are pure ('spin_orbital', 0) blocks of size one.

Returns:
list

Block structure of the operators in the form [[block_name, block_size], ...].