triqs.operators.util.hamiltonians.diagonal_part

triqs.operators.util.hamiltonians.diagonal_part(H)[source]

Extract the density part from a many-body operator.

The density part is the sum of all monomials of \(\hat{H}\) that are products of occupation number operators \(\hat{n}_1 \hat{n}_2 \hat{n}_3 \ldots\).

Parameters:
HOperator

The operator from which the density part is extracted.

Returns:
Operator

The density part of \(\hat{H}\).