Template Class WickTheorem

Nested Relationships

Nested Types

Class Documentation

template<Statistics S>
class WickTheorem

Applies Wick’s theorem to a sequence of normal-ordered operators.

Template Parameters:

S – particle statistics

operator connectivity specifiers

Ensures that the given pairs of normal operators are connected; by default will not constrain connectivity

param op_index_pairs:

the list of pairs of op indices to be connected in the result

throws std::invalid_argument:

if op_index_pairs contains 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

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

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

Public Functions

WickTheorem(WickTheorem&&) = default
WickTheorem &operator=(WickTheorem&&) = default
inline explicit WickTheorem(const std::shared_ptr<NormalOperatorSequence<S>> &input)
inline explicit WickTheorem(const NormalOperatorSequence<S> &input)
inline explicit WickTheorem(ExprPtr expr_input)
inline WickTheorem(ExprPtr expr_input, const WickTheorem &other)

constructs WickTheorem from other with expression input set to expr_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 &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:

std::invalid_argument – if sf does not match the contents of get_default_context().spbasis()

inline WickTheorem &use_topology(bool ut)

Controls whether:

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 not enabled.

Parameters:

ut – if true, will utilize the topology to minimize work.

template<typename IndexContainer>
inline WickTheorem &set_external_indices(IndexContainer &&external_indices)

Specifies the external indices; by default assume all indices are summed over

Parameters:

external_indices – external (nonsummed) indices

Throws:

std::logic_error – if WickTheorem::set_external_indices or WickTheorem::compute had already been invoked

ExprPtr compute(bool count_only = false, bool skip_input_canonicalization = false)

Computes and returns the result

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:

std::logic_error – if input’s vacuum does not match the current context vacuum

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()
void reduce(ExprPtr &expr) const
Parameters:

expr[inout] on input, Wick’s theorem result, on output the result of reducing the overlaps

Public Static Functions

static inline bool can_contract(const Op<S> &left, const Op<S> &right, Vacuum vacuum = get_default_context().vacuum())
static inline ExprPtr contract(const Op<S> &left, const Op<S> &right, Vacuum vacuum = get_default_context().vacuum())

Public Static Attributes

static constexpr const Statistics statistics = S

Friends

friend struct access_by
template<class T>
struct access_by
class Stats

Collects compute statistics.

Public Functions

inline Stats()
inline Stats(const Stats &other) noexcept
inline Stats &operator=(const Stats &other) noexcept
inline void reset()
inline Stats &operator+=(const Stats &other)

Public Members

std::atomic<size_t> num_attempted_contractions
std::atomic<size_t> num_useful_contractions