|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
Helpers to extract coefficient tensors and maps from many-body operators.
This group collects free functions that decompose a many-body operator of a known structure into coefficient dictionaries and dense arrays:
Typedefs | |
| template<typename T> | |
| using | triqs::operators::utils::block_matrix_t = array<nda::matrix<T>, 1> |
| Type of a block matrix. | |
| template<typename T> | |
| using | triqs::operators::utils::dict2_t = std::map<std::tuple<indices_t, indices_t>, T> |
| Map from an index pair \( (\alpha_i, \alpha_j) \) to a coefficient of type T. | |
| template<typename T> | |
| using | triqs::operators::utils::dict4_t = std::map<std::tuple<indices_t, indices_t, indices_t, indices_t>, T> |
| Map from an index quadruple \( (\alpha_i, \alpha_j, \alpha_k, \alpha_l) \) to a coefficient of type T. | |
| template<typename T> | |
| using | triqs::operators::utils::op_t = operators::many_body_operator_generic<T> |
| Alias for triqs::operators::many_body_operator_generic. | |
| template<int N> | |
| using | triqs::operators::utils::real_or_complex_array = std::variant<array<double, N>, array<std::complex<double>, N>> |
| Variant of a rank-N array that can hold either real or complex values. | |
Functions | |
| template<typename T> | |
| block_matrix_t< T > | triqs::operators::utils::block_matrix_from_op (op_t< T > const &h, hilbert_space::gf_struct_t const &gf_struct, bool ignore_irrelevant=false) |
| Convert a block-diagonal quadratic operator into its block-matrix representation. | |
| template<typename T = double, typename D, std::size_t R = std::tuple_size_v<typename D::key_type>> | |
| array< T, R > | triqs::operators::utils::dict_to_matrix (D const &dict, hilbert_space::fundamental_operator_set const &fs) |
| Convert a coefficient dictionary into a dense rank-N array indexed by integers from a fundamental operator set. | |
| template<typename D, std::size_t R = std::tuple_size_v<typename D::key_type>> | |
| real_or_complex_array< R > | triqs::operators::utils::dict_to_variant_matrix (D const &dict, hilbert_space::fundamental_operator_set const &fs) |
| Convert a real or complex valued coefficient dictionary into a real_or_complex_array. | |
| template<typename T> | |
| dict2_t< T > | triqs::operators::utils::extract_h_dict (op_t< T > const &h, bool ignore_irrelevant=false) |
| Extract the coefficients of a normal-ordered quadratic operator. | |
| template<typename T> | |
| dict2_t< T > | triqs::operators::utils::extract_U_dict2 (op_t< T > const &h, bool ignore_irrelevant=false) |
| Extract the coefficients of a density-density interaction operator. | |
| template<typename T> | |
| dict4_t< T > | triqs::operators::utils::extract_U_dict4 (op_t< T > const &h, bool ignore_irrelevant=false) |
| Extract the coefficients of a general two-particle interaction operator. | |
| template<typename T> | |
| op_t< T > | triqs::operators::utils::filter_op (op_t< T > const &h, long len) |
| Keep only terms of a given length of a many-body operator \( \hat{h} \). | |
| template<typename T> | |
| op_t< T > | triqs::operators::utils::op_from_block_matrix (block_matrix_t< T > const &bl_mat, hilbert_space::gf_struct_t const &gf_struct) |
| Build a block-diagonal quadratic operator from its block-matrix representation. | |
| template<typename T> | |
| op_t< T > | triqs::operators::utils::quadratic_terms (op_t< T > const &h) |
| Keep only quadratic terms of a many-body operator \( \hat{h} \). | |
| template<typename T> | |
| op_t< T > | triqs::operators::utils::quartic_terms (op_t< T > const &h) |
| Keep only quartic terms of a many-body operator \( \hat{h} \). | |
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Convert a block-diagonal quadratic operator into its block-matrix representation.
Assumes that \( \hat{h} \) has the form
\[ \hat{h} = \sum_{\sigma ij} h_{\sigma ij} \hat{c}_{\sigma, i}^\dagger \hat{c}_{\sigma, j} \; , \]
where the first element of each canonical operator's index is interpreted as the block label \( \sigma \) (a string) and the second element as the in-block integer index \( i \).
If a term that is not of this form is encountered, an exception is thrown unless ignore_irrelevant is true, in which case the offending term is silently skipped.
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
| gf_struct | Block structure specifying the block labels and the size of each block. |
| ignore_irrelevant | If true, terms that do not match the expected form are skipped instead of triggering an exception. |
Definition at line 313 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Convert a coefficient dictionary into a dense rank-N array indexed by integers from a fundamental operator set.
For a dictionary mapping each key tuple \( (\alpha_{i_1}, \dots, \alpha_{i_N}) \) to a value \( x \), the result is a rank-N array of element type T whose entry at \( (\mathtt{fs}[\alpha_{i_1}], \dots, \mathtt{fs}[\alpha_{i_N}]) \) is set to \( x \). All other entries are value-initialized to T{}.
The dimension along every axis is the size of the fundamental operator set. The function throws if any index from the given dictionary is not present in the fundamental operator set.
| T | Value type of the resulting array. |
| D | Type of the input dictionary. |
| R | Rank of the resulting array (defaults to the arity of D's key tuple). |
| dict | Coefficient dictionary to convert. |
| fs | Fundamental operator set used to map each index \( \alpha_i \) to an integer. |
Definition at line 217 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Convert a real or complex valued coefficient dictionary into a real_or_complex_array.
If every coefficient in the given dictionary is purely real, the result holds a real array. Otherwise, it holds a complex array. The shape of the array follows the same convention as triqs::operators::utils::dict_to_matrix().
| D | Type of the input dictionary. |
| R | Rank of the resulting array (defaults to the arity of D's key tuple). |
| dict | Coefficient dictionary to convert. |
| fs | Fundamental operator set used to map each index \( \alpha_i \) to an integer. |
Definition at line 248 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Extract the coefficients of a normal-ordered quadratic operator.
Assumes that the operator \( \hat{h} \) has the normal-ordered quadratic form
\[ \hat{h} = \sum_{ij} h_{ij} \hat{c}_i^\dagger \hat{c}_j \; . \]
The coefficients \( h_{ij} \) are returned as a map from the index pair \( (\alpha_i, \alpha_j) \) to the value \( h_{ij} \).
If a term that is not of this form is encountered, an exception is thrown unless ignore_irrelevant is true, in which case the offending term is silently skipped.
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
| ignore_irrelevant | If true, terms that do not match the expected form are skipped instead of triggering an exception. |
Definition at line 87 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Extract the coefficients of a density-density interaction operator.
Assumes that the operator \( \hat{h} \) has the density-density form
\[ \hat{h} = \frac{1}{2} \sum_{ij} U_{ij} \hat{n}_i \hat{n}_j \; , \]
with \( \hat{n}_i = \hat{c}_i^\dagger \hat{c}_i \). Internally each input term is matched against the canonical normal-ordered pattern \( \hat{c}_i^\dagger \hat{c}_j^\dagger \hat{c}_j \hat{c}_i \) and both \( (i, j) \) and \( (j, i) \) entries are written to the output map, so that the returned dictionary is symmetric in its index pair.
If a term that is not of this form is encountered, an exception is thrown unless ignore_irrelevant is true, in which case the offending term is silently skipped.
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
| ignore_irrelevant | If true, terms that do not match the expected form are skipped instead of triggering an exception. |
Definition at line 130 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Extract the coefficients of a general two-particle interaction operator.
Assumes that the operator \( \hat{h} \) has the two-particle form
\[ \hat{h} = \frac{1}{2} \sum_{ijkl} U_{ijkl} \hat{c}_i^\dagger \hat{c}_j^\dagger \hat{c}_l \hat{c}_k \; . \]
Each input term is matched against the canonical normal-ordered pattern \( \hat{c}_i^\dagger \hat{c}_j^\dagger \hat{c}_l \hat{c}_k \) and the four index permutations equivalent under fermionic antisymmetry are written to the output map with the appropriate sign, so that the returned dictionary respects the antisymmetry of \( U_{ijkl} \) in \( (i, j) \) and in \( (k, l) \).
If a term that is not of this form is encountered, an exception is thrown unless ignore_irrelevant is true, in which case the offending term is silently skipped.
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
| ignore_irrelevant | If true, terms that do not match the expected form are skipped instead of triggering an exception. |
Definition at line 174 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Keep only terms of a given length of a many-body operator \( \hat{h} \).
Returns a copy of \( \hat{h} \) consisting of those monomials whose length (number of canonical operators) is exactly the required length.
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
| len | Required monomial length. |
Definition at line 266 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Build a block-diagonal quadratic operator from its block-matrix representation.
Given the block matrices \( h_{\sigma ij} \) and the block structure, returns
\[ \hat{h} = \sum_{\sigma ij} h_{\sigma ij} \hat{c}_{\sigma, i}^\dagger \hat{c}_{\sigma, j} \; . \]
| T | Value type of the matrices and of the coefficients in the operator. |
| bl_mat | One matrix \( h_{\sigma ij} \) per block \( \sigma \), packaged as a one-dimensional array of matrices. |
| gf_struct | Block structure specifying the block labels and the size of each block. |
Definition at line 361 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Keep only quadratic terms of a many-body operator \( \hat{h} \).
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
Definition at line 281 of file extractors.hpp.
|
nodiscard |
#include <triqs/operators/util/extractors.hpp>
Keep only quartic terms of a many-body operator \( \hat{h} \).
| T | Value type of the coefficients. |
| h | Many-body operator \( \hat{h} \). |
Definition at line 290 of file extractors.hpp.