Open pablosanjose opened 5 months ago
What are the features we need out of Operator
?
LatticeOperator
T
(usually some subtype of AbstractArray) for each cell distance dn::SVector{L,Int}
. It should then be LatticeOperator{T,L}
o[dn]
to give the actual T
for that dn
view(o, dn)
Dict
or Dictionary
, yielding pairs dn => view(o, dn)
insert!
, delete!
and set!
, just like Dictionary
. Should it then probably be implemented internally as a Dictionary
?sum!(f::Function, m::T, o::LatticeOperator{T})
, where f(dn) = cis(-dot(dn, ϕs))
. Functionally this should just do for (dn, m´) in o; m .+= f(dn) .* m´; end; m
. mul!
, so that mul!(o, o1, o2, α, β; grow = true)
updates o::LatticeOperator
, so that o[dn] = α Σ_k o1[k] * o2[dn-k] + βo[dn]
. If grow
, new entries dn
should be generated in o
from the ones in o1
and o2
. Otherwise, the number of entries in o
should not change and the operation should be allocation free, as long as mul!
over T
s is allocation freemul!
based on FFT, as it is essentially an L
-dimensional convolution?We note that an equilibrium density matrix will eventually be a LatticeOperator{Matrix{Complex{T}}, L}
. This will be used e.g. in real-time equations of motion. For this application it is crucial that mul!
is made as efficient as possible. This could inform about the best internal representation. A Dictionary
from Dictionaries.jl? With what key order?
Also, we must consider if a state, or ket, should be a special case of operator. Conceptually, they are not, but functionally, they behave very similarly.
We currently have
Operator
(anAbstractHamiltonian
wrapper, created e.g. withcurrent(h; direction = ...)
, with scalar eltype),BarebonesOperator
(a container of sparse Bloch harmonics of arbitrary eltype) andharmonics::Vector{<:HybridSparseMatrix}
(insideHamiltonian
).This is screaming for unification. We should create a single
Operator
type that holds aLattice
and any type ofAbstractMatrix
orHybridSparseMatrix
(should the latter be anAbstractSparseMatrix
also?).Hamiltonian
is then anOrbitalOperator <: Operator
, withOrbtialElementType
.current(h)
andposition(w)
should beVectorSparseOperator <: Operator
s, withSVector
type.supercell
and many other functions should be simplified to operate on any operator, unless their eltype makes it impossible.This is a rather major refactor, but would simplify things considerably, and would allow us to place
AbstractHamiltonian
's and otherOperator
s on the same footing. Perhaps a post-v1.1 undertaking.