Template Class WickTheorem¶
Defined in File wick.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
template<Statistics S>
class WickTheorem¶ Applies Wick’s theorem to a sequence of normal-ordered operators.
Under a Vacuum::MultiProduct default context the operators, which need not conserve particle number, are normal-ordered relative to a multideterminantal reference that commutes with the number operator (a state of definite particle number or an ensemble of such states) and compute() applies the extended (generalized-normal-order) theorem, whose result is expressed in terms of the reference’s densities γ, η and cumulants κ.
- Template Parameters:
S – particle statistics
operator connectivity specifiers
Ensures that the given pairs of normal operators are connected; by default will not constrain connectivity
Note
under a Vacuum::MultiProduct vacuum a cumulant connects every operator its indices come from
Note
the ordinals count the NormalOperator objects of each term of an (expanded) expression input, so compute() throws on a term whose operators are fewer than an ordinal names; a term without operators is kept as it is, as under every vacuum
- param op_index_pairs:
the list of pairs of op indices to be connected in the result
- throws Exception:
if
op_index_pairscontains duplicates
-
template<typename IndexPairContainer>
inline WickTheorem &set_nop_connections(IndexPairContainer &&op_index_pairs)¶ - Template Parameters:
IndexPairContainer – a sequence of std::pair<Integer,Integer>
-
template<typename Integer = long>
inline WickTheorem &set_nop_connections(std::initializer_list<std::pair<Integer, Integer>> op_index_pairs)¶ - Template Parameters:
Integer – an integral type
avoided-connectivity specifiers
Ensures that no contraction is ever made between the given pairs of normal operators; every individual contraction attempt between an avoided pair is rejected.
Note
under a Vacuum::MultiProduct vacuum a cumulant connects every operator its indices come from
- param op_index_pairs:
the list of pairs of op indices that must not be directly contracted
- throws Exception:
if
op_index_pairscontains duplicates
-
template<typename IndexPairContainer>
inline WickTheorem &set_nop_avoided_connections(IndexPairContainer &&op_index_pairs)¶ - Template Parameters:
IndexPairContainer – a sequence of std::pair<Integer,Integer>
-
template<typename Integer = long>
inline WickTheorem &set_nop_avoided_connections(std::initializer_list<std::pair<Integer, Integer>> op_index_pairs)¶ - Template Parameters:
Integer – an integral type
specifiers of partitions composed of topologically-equivalent
normal operators
Specifies sets of topologically-equivalent indices that can be used to produce topologically-unique Wick contractions
Note
if this partitions are not given, every Index is assumed to be in its own partition
Note
not consulted under a Vacuum::MultiProduct vacuum: there the partitions are those of each input term’s topology (see use_topology())
- param op_partitions:
list of index partitions
-
template<typename IndexListContainer>
inline auto &set_nop_partitions(IndexListContainer &&nop_partitions) const¶ - Template Parameters:
IndexListContainer – a sequence of sequences of Integer types
-
template<typename Integer = long>
inline auto &set_nop_partitions(std::initializer_list<std::initializer_list<Integer>> nop_partitions) const¶ - Template Parameters:
Integer – an integral type
-
template<typename IndexListContainer>
inline auto &set_op_partitions(IndexListContainer &&op_partitions) const¶ - Template Parameters:
IndexListContainer – a sequence of sequences of Integer types
-
template<typename Integer = long>
inline auto &set_op_partitions(std::initializer_list<std::initializer_list<Integer>> op_partitions) const¶ - Template Parameters:
Integer – an integral type
-
inline auto &make_default_op_partitions() const¶
makes a default set of partitions with each Op is in its own partition
Note
not consulted under a Vacuum::MultiProduct vacuum, like set_op_partitions()
Public Functions
-
WickTheorem(WickTheorem&&) = default¶
-
WickTheorem &operator=(WickTheorem&&) = default¶
Note
the external (nonsummed) indices are the named indices of the CanonicalizeOptions of the context (for arbitrary statistics, as read by canonicalization) in effect at each use, if it has them (name every index that must survive, any other is a dummy), else the indices that appear once in the input; see external_indices()
- Parameters:
input – normal operator sequence
-
inline explicit WickTheorem(NormalOperatorSequence<S> input)¶
Note
see WickTheorem(const std::shared_ptr<NormalOperatorSequence<S>>&) for which indices are external
- Parameters:
input – normal operator sequence
-
inline explicit WickTheorem(ExprPtr expr_input)¶
Note
see WickTheorem(const std::shared_ptr<NormalOperatorSequence<S>>&) for which indices are external
- Parameters:
expr_input – input expression
-
inline explicit WickTheorem(const std::initializer_list<Op<S>> &ops)¶
Note
see WickTheorem(const std::shared_ptr<NormalOperatorSequence<S>>&) for which indices are external
- Parameters:
ops – operator sequence
-
inline WickTheorem(ExprPtr expr_input, const WickTheorem &other)¶
constructs WickTheorem from
otherwith expression input set toexpr_input
-
inline WickTheorem &full_contractions(bool fc)¶
Controls whether next call to compute() will full contractions only or all (including partial) contractions. By default compute() generates full contractions only.
- Parameters:
fc – if false, will evaluate all contractions.
- Returns:
reference to
*this, for daisy-chaining
-
inline WickTheorem &max_cumulant_rank(std::optional<std::size_t> rank)¶
Controls the largest cumulant formed by the next call to compute(); only matters under a Vacuum::MultiProduct vacuum. By default cumulants of every rank are formed.
Note
without a bound, the number of cumulant blocks tried grows combinatorially with the number of uncontracted active operators
- Parameters:
rank – the largest rank of a cumulant; std::nullopt means no bound, 0 or 1 means that no cumulant is formed
- Returns:
reference to
*this, for daisy-chaining
-
inline WickTheorem &eta_as_delta_minus_gamma(bool edmg)¶
Controls whether the next call to compute() spells every one-body hole density η as δ - γ; only matters under a Vacuum::MultiProduct vacuum. By default η is kept. A multi-body η of the input is kept either way.
- Parameters:
edmg – if true, will rewrite every one-body η as δ - γ
- Returns:
reference to
*this, for daisy-chaining
-
inline WickTheorem &spinfree(bool sf)¶
Controls whether next call to compute() will assume spin-free or spin-orbital normal-ordered operators By default compute() assumes spin-orbital operators.
- Parameters:
sf – if true, will complete full contractions only.
- Throws:
Exception – if
sfdoes not match the contents of get_default_context().spbasis()
-
inline WickTheorem &use_topology(bool ut)¶
Controls whether:
Op’s of the same type within each NormalOperator are assumed topologically equivalent, and
(if an Expr is given as input) NormalOperator objects attached to Tensor objects are considered equivalent. (If a NormalOperatorSequence is given as input, such use of topological equivalence if enabled by invoking set_nop_partitions() ).
This is useful to to eliminate the topologically-equivalent contractions when fully-contracted result (i.e. the vacuum average) is sought. By default the use of topology is enabled.
Note
two Op objects are treated as equivalent only if swapping them alone is a symmetry of the input
Note
under a Vacuum::MultiProduct vacuum the equivalences are those of each input term, in which an index shared by two operators is a dummy
- Parameters:
ut – if true, will utilize the topology to minimize work.
-
ExprPtr compute(bool count_only = false, bool skip_input_canonicalization = false)¶
Computes and returns the result
Note
the canonicalization method is controlled by the default Context
Note
under a Vacuum::MultiProduct vacuum the input is always canonicalized
Warning
this is not reentrant, but is optionally threaded internally
- Parameters:
count_only – if true, will return the total number of terms, as a Constant; the default is false.
skip_input_canonicalization – whether to skip initial canonicalization of the input expression; the default is false.
- Throws:
Exception – if input’s vacuum does not match the current context vacuum
Exception – under a Vacuum::MultiProduct vacuum if
count_onlyis true,Sis Statistics::BoseEinstein or the context’s SPBasis is Spinfree
- Returns:
the result of applying Wick’s theorem; either a Constant, a Product, or a Sum
-
inline const Stats &stats() const¶
Statistics accessor
- Returns:
statistics of compute calls since creation, or since the last call to reset_stats()
-
inline Stats &stats()¶
Statistics accessor
- Returns:
statistics of compute calls since creation, or since the last call to reset_stats()
-
inline void reset_stats()¶
Statistics reset.
-
virtual ~WickTheorem()¶
Public Static Functions
-
static inline ExprPtr contraction_value(const Index &bra, const Index &ket, bool left_is_annihilator, Vacuum vacuum)¶
the value of a single contraction between
bra(the annihilator’s index) andket(the creator’s index), both already projected onto the common quasiparticle space; this is where a spin-free variant would substitute its own tensors
Public Static Attributes
-
static constexpr const Statistics statistics = S¶
Friends
- friend struct access_by
-
template<class T>
struct access_by¶