pablosanjose / Quantica.jl

Simulation of quantum systems on a lattice
Other
69 stars 8 forks source link

Taking Operators seriously #265

Open pablosanjose opened 5 months ago

pablosanjose commented 5 months ago

We currently have Operator (an AbstractHamiltonian wrapper, created e.g. with current(h; direction = ...), with scalar eltype), BarebonesOperator (a container of sparse Bloch harmonics of arbitrary eltype) and harmonics::Vector{<:HybridSparseMatrix} (inside Hamiltonian).

This is screaming for unification. We should create a single Operator type that holds a Lattice and any type of AbstractMatrix or HybridSparseMatrix (should the latter be an AbstractSparseMatrix also?). Hamiltonian is then an OrbitalOperator <: Operator, with OrbtialElementType. current(h) and position(w) should be VectorSparseOperator <: Operators, with SVector 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 other Operators on the same footing. Perhaps a post-v1.1 undertaking.

pablosanjose commented 4 months ago

What are the features we need out of Operator?

pablosanjose commented 4 months ago

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.