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.Operator
SpinAdaptedSecondQuantization.Operator
julia> SASQ.Operator # Equivalent for convenience
SpinAdaptedSecondQuantization.Operator
Types
SpinAdaptedSecondQuantization.BosonOperator
— TypeBoson Operators
The basic boson type operator.
SpinAdaptedSecondQuantization.Constraints
— TypeConstraints = SortedDict{Int,Int}
Type alias for container of Index constraints
SpinAdaptedSecondQuantization.KroneckerDelta
— TypeKroneckerDelta
Type representing a Kronecker delta of two or more MO-indices.
SpinAdaptedSecondQuantization.Operator
— TypeOperator
Abstact operator type which all concrete operator types (i.e. Epq, a†p) must extend.
SpinAdaptedSecondQuantization.SingletExcitationOperator
— TypeSingletExcitationOperator
The basic E_pq type operator.
SpinAdaptedSecondQuantization.Spin
— TypeSpin
Enum type to represent spin up (α) and down (β)
SpinAdaptedSecondQuantization.TripletExcitationOperator
— TypeSingletExcitationOperator
The T_pq type operator.
Functions
Base.:==
— MethodBase.:==(::Operator, ::Operator)
This has to be explicitly implemented for each operator type.
Base.:^
— MethodBase.:(^)(ex::Expression, n::Integer)
Computes ex^n
by repeated multiplication.
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)
Base.adjoint
— MethodBase.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)
Base.isless
— MethodBase.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.
Base.show
— MethodBase.show(::IO, ::Tuple{Operator,Constraints,IndexTranslation})
All typed extending Operator
must overload this function.
SpinAdaptedSecondQuantization.compact_deltas
— Methodcompact_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
SpinAdaptedSecondQuantization.do_tensor_replacement
— Methoddo_tensor_replacement(t::Term, transformer)
Function that takes a term and produces the term you get by transforming its tensors according to the transformer.
SpinAdaptedSecondQuantization.exchange_indices
— Methodexchange_indices(d::KroneckerDelta, mapping)
Returns a new KroneckerDelta
with indices exchanged according to the mapping
SpinAdaptedSecondQuantization.exchange_indices
— Methodexchange_indices(::Operator, mapping)
All typed extending Operator
must overload this function. It should return a new operator where all indices have been exchanged according to the mapping
.
SpinAdaptedSecondQuantization.find_illegal_operator_chains
— Methodfind_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
andq
inE_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.
- Looks for three "true" excitations, where the index constraints of
See simplify
for example of use.
SpinAdaptedSecondQuantization.get_all_indices
— Methodget_all_indices(::Operator)
All typed extending Operator
must overload this function. It should return an iteratable over all the MO-indices contained in the operator in order.
SpinAdaptedSecondQuantization.nested_commutator
— Methodcommutator(A, Bs)
Computes nested commutator with all expressions in iteratable Bs.
$[...[[[A], B_1], B_2], ...]$
SpinAdaptedSecondQuantization.reductive_commutator
— Methodreductive_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.
SpinAdaptedSecondQuantization.split_indices
— Methodsplit_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)
SpinAdaptedSecondQuantization.try_add_constraints
— Methodtry_add_constraints(ex::Expression)
Looks for pairs of terms differing only in index constraints and scalar prefactors, and tries to combine them. See simplify
for example.
SpinAdaptedSecondQuantization.try_add_constraints
— Methodtry_add_constraints(a::Term, b::Term)
Checks if the pair of terms are differing only in index constraints and scalar prefactors, and tries to combine them. See simplify
for example.