Internals

Auto generated docs for functions and types that are not exported. Mostly for development use. To directly access any of these functions/types from outside of the package you need to prepend the package name SpinAdaptedSecondQuantization. or the exported acronym SASQ., for example

julia> using SpinAdaptedSecondQuantization
julia> SpinAdaptedSecondQuantization.OperatorSpinAdaptedSecondQuantization.Operator
julia> SASQ.Operator # Equivalent for convenienceSpinAdaptedSecondQuantization.Operator

Types

SpinAdaptedSecondQuantization.KroneckerDeltaType
KroneckerDelta

Type representing a Kronecker delta of two or more MO-indices.

Note

When constructing a KroneckerDelta it will return the integer 1 if the delta does not include two or more distinkt indices.

source

Functions

Base.:==Method
Base.:==(::Operator, ::Operator)

This has to be explicitly implemented for each operator type.

source
Base.:^Method
Base.:(^)(ex::Expression, n::Integer)

Computes ex^n by repeated multiplication.

Warning

n must be a non negative integer

Examples

julia> using SpinAdaptedSecondQuantization

julia> h = ∑(real_tensor("h", 1, 2) * E(1, 2) * electron(1, 2), 1:2)
∑_pq(h_pq E_pq)

julia> h^2
∑_pqrs(h_pq h_rs E_pq E_rs)

julia> h^3
∑_pqrstu(h_pq h_rs h_tu E_pq E_rs E_tu)
source
Base.adjointMethod
Base.adjoint(ex::Expression)

Termwise adjoint ex. Equivalent to the postfix notation ex'

Examples

julia> using SpinAdaptedSecondQuantization

julia> Eai(a, i) = E(a, i) * occupied(i) * virtual(a)
Eai (generic function with 1 method)

julia> T2 = 1//2 * ∑(psym_tensor("t", 1:4...) * Eai(1, 2) * Eai(3, 4), 1:4)
1/2 ∑_aibj(t_aibj E_ai E_bj)

julia> adjoint(T2)
1/2 ∑_aibj(t_aibj E_jb E_ia)

julia> T2'
1/2 ∑_aibj(t_aibj E_jb E_ia)

julia> simplify(ans)
1/2 ∑_iajb(t_aibj E_ia E_jb)
source
Base.islessMethod
Base.isless(::Operator, ::Operator)

All operator types must implement how they should be sorted among themselves (isless(::O, ::O)) and with respect to all other operator types that it is expected to be used together with (isless(::A, ::B)).

The implementation for how it sorts among the same operator type should be implemented in the definition file for that operator type.

The implementation for how the type sorts compared to other operator types should be added to the src/operators/sorting.jl file. These should be dummy routines that simply return true or false, and do not depend on the contents of the operators.

Note

Only one order needs to be implemented, meaning if isless(::A, ::B) is implemented, there is no need to also implement isless(::B, ::A)

source
Base.showMethod
Base.show(::IO, ::Tuple{Operator,Constraints,IndexTranslation})

All typed extending Operator must overload this function.

source
SpinAdaptedSecondQuantization.compact_deltasMethod
compact_deltas(deltas::Vector{KroneckerDelta})

Returns a new reduced Vector{KroneckerDelta} where there exists only one delta per group of equal indices.

Example:

δ_pq δ_qr δ_st -> δ_pqr δst
source
SpinAdaptedSecondQuantization.find_illegal_operator_chainsMethod
find_illegal_operator_chains(t::Term)

Looks for chains of operators that equals zero such as

$E_{ai} E_{aj} E_{ak} = 0$

and

$a_{pσ} a_{pσ} = 0$

The routine focuses on having "safe" simplifications that are easy to formulate and fast to check for rather than having an exhaustive check.

Currently implemented simplifications include:

  • No consecutive fermion creation/annihilation operators that are equal as this would try to fill/empty two electrons in/out of the same spin orbital.
  • Illegal tripplets of SingletExcitationOperator:
    • Looks for three "true" excitations, where the index constraints of p and q in E_pq are disjoint, as this means that an electron is actually moved and not put back by the same operator.
    • It then looks for either the first index to be equal for all three operators, or the last index of all three operators.

See simplify for example of use.

source
SpinAdaptedSecondQuantization.reductive_commutatorMethod
reductive_commutator(::Operator, ::Operator)

Defines how operators commute. This will act as either a commutator or anticommutator depending on which reduces the rank of the resulting operators.

Returns a Tuple{Int,Expression} which gives the type of commutator used and the resulting expression. The type is signaled by returning 1 or -1 as the first element of the tuple. This represents the sign change by commutation which is 1 for a normal commutator $([A, B] = 0 ⇒ AB == BA)$ and -1 for an anticommutator $([A, B]_+ = 0 ⇒ AB = -BA)$

This should be implemented for all pairs of operators types that are expected to show up in the same expression. The implementations should be put in the src/operators/commutation_relations.jl file.

Note

Only one order needs to be implemented, meaning if reductive_commutator(::A, ::B) is implemented, there is no need to also implement reductive_commutator(::B, ::A)

source
SpinAdaptedSecondQuantization.split_indicesMethod
split_indices(ex::Expression, mapping)

Splits the indices of each term according to the given mapping.

julia> using SpinAdaptedSecondQuantization

julia> h = ∑(real_tensor("h", 1, 2) * E(1, 2) * electron(1, 2), 1:2)
∑_pq(h_pq E_pq)

julia> SASQ.split_indices(h,GeneralOrbital => (OccupiedOrbital, VirtualOrbital))
∑_ab(h_ab E_ab)
+ ∑_ai(h_ai E_ai)
+ ∑_ia(h_ia E_ia)
+ ∑_ij(h_ij E_ij)
source