Multicomponent
Opened this issue · 4 comments
@epolack and @LaurentVidal95 need support for multicomponent (psi(x) is a vector) for twisted bilayer graphene
It would also be nice to have for
- non collinear spin
- solving maxwell equations (and making dftk do photonics!)
- multicomponent Bose Einstein condensates
-...?
Main design points is how we represent things like psi, rho and V, hopefully without rewriting everything, destroying code readability or performance. Doesn't sound easy but let's try. Maybe this is the time where we'll need to switch to custom data structures rather than plain arrays...
I'll write up in more details the use cases I know of, so we can try to find a good design
@epolack @LaurentVidal95 can you also write a few words on what data structures you use right now and how well it works?
Puh sounds tough, but I'm curious. It feels like project in size and annoyance related to the bloch / supercell issue.
Probably simpler than bloch/supercell. It's "just" making everything vectors. The tricky bit is doing it properly...
So, after discussion with Etienne and Laurent: we take the representation psi[iG][sigma]
, with Vector{SVector}, so that it's easy to convert to linear indices. We introduce a new field n_components in Model (possibly a type parameter? Will see), and a n_dof, equal to length(G_vectors) * n_components, in both PWBasis and Kpoint. A number of routines will have to be modified, but Etienne says it's not too bad. As a first attempt we don't modify the density building: later, we will probably want rho[i,j,k][sigma,sigma']
. Etienne and Laurent will test on TBG; later, we should try to refactor the spin code to allow for noncollinear magnetism.