triqs.operators.util.extractors

Extract coefficients (matrices and tensors) from many-body operators.

Given a Operator, the extract_* functions recover the coefficient dictionaries of a normally ordered operator that matches a specific structural pattern:

  • extract_h_dict() — quadratic part \(\sum_{ij} h_{ij} \hat{c}_i^\dagger \hat{c}_j\),

  • extract_U_dict2() — density-density interaction \(\frac{1}{2} \sum_{ij} U_{ij} \hat{n}_i \hat{n}_j\),

  • extract_U_dict4() — general two-body interaction \(\frac{1}{2} \sum_{ijkl} U_{ijkl} \hat{c}_i^\dagger \hat{c}_j^\dagger \hat{c}_l \hat{c}_k\).

The returned dictionaries map tuples of single-particle indices to the corresponding coefficient, and can be converted to dense arrays via dict_to_matrix() (given a Green’s-function block structure). The companion functions quadratic_terms(), quartic_terms(), block_matrix_from_op() and op_from_block_matrix() filter and round-trip block-diagonal quadratic operators between the operator and matrix representations.

Functions

block_matrix_from_op

Convert a block-diagonal quadratic operator into its block-matrix representation.

dict_to_matrix

Convert a coefficient dictionary to a matrix, given a GF structure.

extract_U_dict2

Extract the density-density interaction \(\frac{1}{2} \sum_{ij} U_{ij} \hat{n}_i \hat{n}_j\) from a

extract_U_dict4

Extract the two-body interaction part from a many-body operator.

extract_h_dict

Extract the quadratic part \(\sum_{ij} h_{ij} \hat{c}^\dagger_i \hat{c}_j\) from a many-body operator.

op_from_block_matrix

Build a block-diagonal quadratic operator from its block-matrix representation.

quadratic_terms

Keep only quadratic terms of a many-body operator \(\hat{h}\).

quartic_terms

Keep only quartic terms of a many-body operator \(\hat{h}\).