Class Context

Nested Relationships

Nested Types

Class Documentation

class Context

Specifies second quantization context, such as vacuum choice, whether index spaces are orthonormal, sizes of index spaces, etc.

Public Functions

explicit Context(std::shared_ptr<IndexSpaceRegistry> isr_sptr, Vacuum vac = Defaults::vacuum, IndexSpaceMetric m = Defaults::metric, BraKetSymmetry bks = Defaults::braket_symmetry, SPBasis spb = Defaults::spbasis, std::size_t fdio = Defaults::first_dummy_index_ordinal)

standard full-form constructor

Parameters:
  • isr_sptr – a shared_ptr to an IndexSpaceRegistry object

  • vac – a Vacuum object

  • m – an IndexSpaceMetric object

  • bks – a BraKetSymmetry object

  • spb – single-particle basis (spin-free or spin-dependent)

  • fdio – first dummy index ordinal

explicit Context(IndexSpaceRegistry isr, Vacuum vac = Defaults::vacuum, IndexSpaceMetric m = Defaults::metric, BraKetSymmetry bks = Defaults::braket_symmetry, SPBasis spb = Defaults::spbasis, std::size_t fdio = Defaults::first_dummy_index_ordinal)

same as the standard ctor, using IndexSpaceRegistry passed by value

Parameters:
  • isr – an IndexSpaceRegistry object

  • vac – a Vacuum object

  • m – an IndexSpaceMetric object

  • bks – a BraKetSymmetry object

  • spb – single-particle basis (spin-free or spin-dependent)

  • fdio – first dummy index ordinal

explicit Context(Vacuum vac, IndexSpaceMetric m = Defaults::metric, BraKetSymmetry bks = Defaults::braket_symmetry, SPBasis spb = Defaults::spbasis, std::size_t fdio = Defaults::first_dummy_index_ordinal)

same as the standard ctor, using default-constructed IndexSpaceRegistry

Parameters:
  • vac – a Vacuum object

  • m – an IndexSpaceMetric object

  • bks – a BraKetSymmetry object

  • spb – single-particle basis (spin-free or spin-dependent)

  • fdio – first dummy index ordinal

Context() = default

default constructor, equivalent to Context(Vacuum::Physical,

IndexSpaceMetric::Unit, BraKetSymmetry::conjugate,

sequant::SPBasis::spinorbital, 100)

Warning

default constructor does not create an IndexSpaceRegistry, thus this->index_space_registry() will return nullptr

~Context() = default
Context(const Context&) = default
Context &operator=(const Context&) = default
Vacuum vacuum() const
Returns:

Vacuum of this context

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

SPBasis spbasis() const
Returns:

SPBasis 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

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

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

struct Defaults

Public Static Attributes

static constexpr auto vacuum = Vacuum::Physical
static constexpr auto metric = IndexSpaceMetric::Unit
static constexpr auto braket_symmetry = BraKetSymmetry::conjugate
static constexpr auto spbasis = sequant::SPBasis::spinorbital
static constexpr auto first_dummy_index_ordinal = 100