Class Context¶
Defined in File context.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class Context¶
Specifies SeQuant context, such as vacuum choice, whether index spaces are orthonormal, sizes of index spaces, etc.
SeQuant context contains the following information:
a IndexSpaceRegistry object: contains information about the known IndexSpace objects and their attributes; managed by shared_ptr and can be shared by multiple contexts.
vacuum: the vacuum state used to define normal ordering ofNormalOperatorsmetric: whether the plain basis of vector space (ket) modes are orthonormal to their dual (bra) counterparts (IndexSpaceMetric::Unit) or not (IndexSpaceMetric::General); this affects the value of Wick contractions.braket_symmetry: whether the primal (ket) and dual (bra) vector space bases are “equivalent” (homogenous to each other;BraKetSymmetry::Symm), “conjugate to each other” (conjugate-homogenous to each other;BraKetSymmetry::Conjugate) or are “nonequivalent” (not homogeneous;BraKetSymmetry::Nonsymm)spbasis: whether the bra/ket bases are spinor (SPBasis::Spinor) or spin-free (SPBasis::Spinfree).first_dummy_index_ordinal: during its operation SeQuant will generate temporary indices with orbitals greater or equal to this; to avoid duplicates user Index objects should have ordinals smaller than thiscanonicalization_options: if set, this specifies the default options to use for canonicalization of expressions.braket_typesetting: whetherto_latex()typesets tensor indices of ket (covariant, primal) modes as superscript (BraKetTypesetting::KetSuper, default)braket_slot_typesetting: whetherto_latex()typesets tensor indices usingtensorLaTeX package (BraKetSlotTypesetting::TensorPackage, default) or native typesetting (BraKetSlotTypesetting::Naive); the former is preferred for alignment of superscript with subscript slots.
Public Functions
-
Context(Options options = make_default_options())¶
standard named-parameter constructor
Warning
default constructor does not create an IndexSpaceRegistry, thus
this->index_space_registry()will return nullptr Example:Context ctx({.vacuum = Vacuum::SingleReference, .spbasis = SPBasis::Spinfree});
-
~Context() = default¶
-
Context(const Context &ctx) = default¶
copy constructor
See also
Warning
created Context uses the same index space registry as
ctx- Parameters:
ctx – [in] a Context
-
Context &operator=(const Context &ctx) = default¶
copy assignment
See also
Warning
this object will use the same index space registry as
ctx- Parameters:
ctx – [in] a Context
- Returns:
reference to this object
-
Context clone() const¶
clones this object AND its index space registry
Note
created Context does not use this object’s index space registry
-
std::shared_ptr<const IndexSpaceRegistry> index_space_registry() const¶
Warning
can be null when user did not provide one to Context (i.e., it was default constructed)
- Returns:
a constant pointer to the IndexSpaceRegistry for this context
-
std::shared_ptr<IndexSpaceRegistry> mutable_index_space_registry() const¶
- Throws:
std::logic_error – if the IndexSpaceRegistry is null
- Returns:
a pointer to the IndexSpaceRegistry for this context.
-
IndexSpaceMetric metric() const¶
- Returns:
IndexSpaceMetric of this context
-
BraKetSymmetry braket_symmetry() const¶
- Returns:
BraKetSymmetry of this context
-
std::size_t first_dummy_index_ordinal() const¶
- Returns:
first ordinal of the dummy indices generated by calls to Index::next_tmp_index when this context is active
-
std::optional<CanonicalizeOptions> canonicalization_options() const¶
- Returns:
canonicalization options to use by default, if nonnull
-
BraKetTypesetting braket_typesetting() const¶
- Returns:
BraKetTypesetting of this context; if this returns BraKetTypesetting::ContraSub covariant (ket, creation) and contravariant (bra, annihilation) indices are typeset in superscript and subscript LaTeX, respectively.
-
BraKetSlotTypesetting braket_slot_typesetting() const¶
- Returns:
BraKetSlotTypesetting of this context; see BraKetSlotTypesetting for the meaning of the possible values
-
Context &set(Vacuum vacuum)¶
Sets the Vacuum for this context, convenient for chaining
- Parameters:
vacuum – Vacuum
- Returns:
ref to
*this, for chaining
-
Context &set(IndexSpaceRegistry ISR)¶
sets the IndexSpaceRegistry for this context
- Parameters:
ISR – an IndexSpaceRegistry
- Returns:
ref to ‘*this’ for chaining
sets the IndexSpaceRegistry for this context
- Parameters:
ISR – a IndexSpaceRegistry shared_ptr
- Returns:
ref to ‘*this’ for chaining
-
Context &set(IndexSpaceMetric metric)¶
Sets the IndexSpaceMetric for this context, convenient for chaining
- Parameters:
metric – IndexSpaceMetric
- Returns:
ref to
*this, for chaining
-
Context &set(BraKetSymmetry braket_symmetry)¶
Sets the BraKetSymmetry for this context, convenient for chaining
- Parameters:
braket_symmetry – BraKetSymmetry
- Returns:
ref to
*this, for chaining
-
Context &set(SPBasis spbasis)¶
Sets the SPBasis for this context, convenient for chaining
- Parameters:
spbasis – SPBasis
- Returns:
ref to
*this, for chaining
-
Context &set_first_dummy_index_ordinal(std::size_t first_dummy_index_ordinal)¶
Sets the first dummy index ordinal for this context, convenient for chaining
- Parameters:
first_dummy_index_ordinal – the first dummy index ordinal
- Returns:
ref to
*this, for chaining
-
Context &set(CanonicalizeOptions copt)¶
Specifies the canonicalization options
- Returns:
ref to
*this, for chaining
-
Context &set(BraKetTypesetting braket_typeset)¶
Sets the BraKetTypesetting for this context, convenient for chaining
- Parameters:
braket_typeset – BraKetTypesetting
- Returns:
ref to
*this, for chaining
-
Context &set(BraKetSlotTypesetting braket_slot_typeset)¶
Sets the BraKetSlotTypesetting for this context, convenient for chaining
- Parameters:
braket_slot_typeset – BraKetSlotTypesetting
- Returns:
ref to
*this, for chaining
-
struct Defaults¶
Public Static Attributes
-
static constexpr auto metric = IndexSpaceMetric::Unit¶
-
static constexpr auto braket_symmetry = BraKetSymmetry::Conjugate¶
-
static constexpr auto first_dummy_index_ordinal = 100¶
-
static constexpr auto braket_typesetting = BraKetTypesetting::ContraSub¶
-
static constexpr auto braket_slot_typesetting = BraKetSlotTypesetting::TensorPackage¶
-
static constexpr auto metric = IndexSpaceMetric::Unit¶
-
struct Options¶
helper for the named-parameter constructor of Context
see the Context documentation for detailed description
Public Members
a shared_ptr to an IndexSpaceRegistry object
-
std::optional<IndexSpaceRegistry> index_space_registry = std::nullopt¶
an IndexSpaceRegistry object; used if index_space_registry_shared_ptr is null and it is nonnull
-
IndexSpaceMetric metric = Defaults::metric¶
the IndexSpaceMetric object
-
BraKetSymmetry braket_symmetry = Defaults::braket_symmetry¶
the BraKetSymmetry object
-
std::size_t first_dummy_index_ordinal = Defaults::first_dummy_index_ordinal¶
the first dummy index ordinal
-
std::optional<CanonicalizeOptions> canonicalization_options = std::nullopt¶
the default canonicalization options
-
BraKetTypesetting braket_typesetting = Defaults::braket_typesetting¶
the BraKetTypesetting object
-
BraKetSlotTypesetting braket_slot_typesetting = Defaults::braket_slot_typesetting¶
the BraKetSlotTypesetting object