Template Class OpMaker

Nested Relationships

Nested Types

Class Documentation

template<Statistics S>
class OpMaker

makes a tensor-level many-body operator

A many-body operator has the following generic form: \( \frac{1}{P} T_{b_1 b_2 \dots b_B}^{k_1 k_2 \dots k_K} A^{b_1 b_2 \dots b_B}_{k_1 k_2 \dots k_K} \) where \( \{B,K\} \) are number of bra/ket indices of \( T \) or, equivalently, the number of creators/annihilators of normal-ordered (w.r.t. the default vacuum) operator \( A \). Hence \( \{ b_i \} \) / \( \{ k_i \} \) are (quasi)particle creation/annihilation indices. For example, for fermionic operators relative to Fermi vacuum these are:

  • (pure) excitation: (active) unoccupied/occupied, respectively;

  • (pure) deexcitation: occupied/unoccupied, respectively; For generic operators (neither excitation nor deexcitation) complete basis indices are assumed by default.

    \( P \) is the “normalization” factor and depends on the vacuum used to define \( A \), and indices \( \{ b_i \} \) / \( \{ k_i \} \).

Note

The choice of computational basis can be controlled by the default Context. See SeQuant/core/context.hpp and SeQuant/mbpt/context.hpp

Warning

Tensor \( T \) will be antisymmetrized if get_default_context().spbasis() == SPBasis::Spinor, else it will be particle-symmetric; the latter is only valid if # of bra and ket indices coincide.

Public Types

enum class UseDepIdx

Values:

enumerator Bra

bra/cre indices depend on ket

enumerator Ket

ket/ann indices depend on bra

enumerator None

use plain indices

Public Functions

template<typename IndexSpaceTypeRange1, typename IndexSpaceTypeRange2>
inline OpMaker(const std::wstring &label, const cre<IndexSpaceTypeRange1> &cre_list, const ann<IndexSpaceTypeRange2> &ann_list, size_t order = 0)
Parameters:
  • op – [in] the operator type

  • cre_list – [in] list of creator indices

  • ann_list – [in] list of annihilator indices

OpMaker(const std::wstring &label, ncre nc, nann na)
Parameters:
  • op – [in] the operator type

  • nc – [in] number of bra indices/creators

  • na – [in] number of ket indices/annihilators

OpMaker(const std::wstring &label, std::size_t rank)

creates a particle-conserving replacement operator

Parameters:
  • op – [in] the operator type

  • rank – [in] particle rank of the operator (# of creators = # of annihilators = rank )

OpMaker(const std::wstring &label, ncre nc, nann na, const cre<IndexSpace> &cre_space, const ann<IndexSpace> &ann_space)
Parameters:
  • op – [in] the operator type

  • nc – [in] number of bra indices/creators

  • na – [in] number of ket indices/annihilators

  • cre_space – [in] IndexSpace referred to be the creator

  • ann_space – [in] IndexSpace referred to be the annihilators

OpMaker(const std::wstring &label, ncre nc, nann na, const OpParams &params)

Creates operator from OpParams.

Parameters:
  • op – [in] the operator type

  • nc – [in] number of bra indices/creators

  • na – [in] number of ket indices/annihilators

  • params – [in] named parameters for operator construction

ExprPtr operator()(std::optional<UseDepIdx> dep_opt = {}, std::optional<Symmetry> opsymm_opt = {}, std::optional<std::wstring> grants_of = {}) const
Parameters:
  • dep_opt – [in] if given, controls whether bra (*dep_opt == UseDepIdx::Bra) / ket (*dep_opt == UseDepIdx::Ket) indices are dependent on the, respectively, ket/bra indices (i.e., use them as protoindices); if (*dep_opt == UseDepIdx::None) then plain indices are used; if dep_opt is not given then the default is determined by the MBPT context.

  • opsymm_opt – [in] if given, controls whether (anti)symmetric tensor is returned; if opsymm_opt is not given then the default is determined by the MBPT context.

  • grants_of – [in] the operator label whose basis grants (see OpRegistry::grant_basis) the legs carry; if not given, this operator’s own (perturbation-order decorated) label

Public Static Functions

static inline OpInfo build_op_info(const IndexSpaceContainer &cre_spaces, const IndexSpaceContainer &ann_spaces, UseDepIdx dep = UseDepIdx::None, const BasisGrant &grant = {})

Creates an OpInfo struct containing creator and annihilator indices, normalization factor, symmetry, and dependency information.

Parameters:
  • cre_spaces – A container of IndexSpace objects representing the creator indices

  • ann_spaces – A container of IndexSpace objects representing the annihilator indices

  • dep – An optional parameter specifying the dependency of indices.

  • grant – the basis instance of each minted index, by its space

Returns:

An OpInfo struct containing the created indices, normalization factor, symmetry, and dependency information.

template<typename TensorGenerator>
static inline ExprPtr make(OpClass opclass, const IndexSpaceContainer &cre_spaces, const IndexSpaceContainer &ann_spaces, TensorGenerator &&tensor_generator, UseDepIdx dep = UseDepIdx::None, const BasisGrant &grant = {})
Template Parameters:

TensorGenerator – callable with signature TensorGenerator(range<Index>, range<Index>, Symmetry) that returns a Tensor with the respective bra/cre and ket/ann indices and of the given symmetry

Parameters:
  • opclass – [in] the class of the operator, which selects the prefactor under the active NormalizationConvention; the tensor label is set by tensor_generator

  • cre_spaces – [in] creator IndexSpaces

  • ann_spaces – [in] annihilator IndexSpaces

  • tensor_generator – [in] the callable that generates the tensor

  • dep – [in] whether to use dependent indices

  • grant – [in] the basis instance of each minted index, see build_op_info

Protected Functions

OpMaker(const std::wstring &op)
inline auto ncreators() const
inline auto nannihilators() const

Protected Attributes

std::wstring label_
size_t order_ = 0
IndexSpaceContainer cre_spaces_
IndexSpaceContainer ann_spaces_
std::optional<IndexContainer> batch_indices_ = std::nullopt
struct OpInfo

struct to hold the information about the operator

Public Members

container::svector<Index> creidxs

creator indices

container::svector<Index> annidxs

annihilator indices

sequant::intmax_t mult

normalization factor

Symmetry opsymm

symmetry of the operator

UseDepIdx dep

dependency of the bra/ket indices