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(OpType op, const cre<IndexSpaceTypeRange1> &cre_list, const ann<IndexSpaceTypeRange2> &ann_list)
Parameters:
  • op[in] the operator type

  • cre_list[in] list of creator indices

  • ann_list[in] list of annihilator indices

OpMaker(OpType op, 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(OpType op, 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(OpType op, 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(OpType op, 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 = {}) 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.

Public Static Functions

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

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.

Returns:

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

template<typename TensorGenerator>
static inline ExprPtr make(const IndexSpaceContainer &cre_spaces, const IndexSpaceContainer &ann_spaces, TensorGenerator &&tensor_generator, UseDepIdx dep = UseDepIdx::None)
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:
  • 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

template<typename TensorGenerator>
static inline ExprPtr make(std::initializer_list<IndexSpace::Type> cre_spaces, std::initializer_list<IndexSpace::Type> ann_spaces, TensorGenerator &&tensor_generator, UseDepIdx csv = UseDepIdx::None)
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:
  • cre_spaces[in] creator IndexSpaces as an initializer list

  • ann_spaces[in] annihilator IndexSpaces as an initializer list

  • tensor_generator[in] the callable that generates the tensor

  • csv[in] whether to use dependent indices

template<typename TensorGenerator>
static inline ExprPtr make(const IndexSpaceContainer &cre_spaces, const IndexSpaceContainer &ann_spaces, const IndexContainer &batch_indices, TensorGenerator &&tensor_generator, UseDepIdx dep = UseDepIdx::None)
Template Parameters:

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

Parameters:
  • cre_spaces[in] creator IndexSpaces

  • ann_spaces[in] annihilator IndexSpaces

  • batch_indices[in] batch indices

  • tensor_generator[in] the callable that generates the tensor

  • dep[in] whether to use dependent indices

template<typename TensorGenerator>
static inline ExprPtr make(std::initializer_list<IndexSpace::Type> creators, std::initializer_list<IndexSpace::Type> annihilators, std::initializer_list<Index> batch_indices, TensorGenerator &&tensor_generator, UseDepIdx csv = UseDepIdx::None)
Template Parameters:

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

Parameters:
  • creators[in] creator IndexSpaces as an initializer list

  • annihilators[in] annihilator IndexSpaces as an initializer list

  • batch_indices[in] batch indices as an initializer list

  • tensor_generator[in] the callable that generates the tensor

  • csv[in] whether to use dependent indices

Protected Functions

OpMaker(OpType op)
inline auto ncreators() const
inline auto nannihilators() const

Protected Attributes

OpType op_
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