Hello,
I started recently to look at Kwant from under the hood, and I have a
question to address you.
My current understanding is that the wavefunction is defined as a 1D
array of complex values, the orbitals for each site being a contiguous
chunk in the array, that can be accessed through book-keeping.
What I was expecting was a simple compilable representation that uses
for example an array of pointers to tinyarrays:
`ta.array[:] wavefunction' or maybe `std::vector wavefunction`
Accessing the number of orbitals in a given site would then be a simple
call to a `size()` member function:
`wavefunction[i].size()'.
The benefit I am seeing to this approach is shorter and more readable
code, from the developer point of view, because we would use for
example tinarray’s functions for expectation values of operators, for
example for the hamiltonian:
`ta.dot(ta.conjugate(ta.transpose(wavefunction(i)),
ta.dot(syst.hamiltonian(i,j, params), wavefunction[j])`
If the * operator is defined between tinyarray, and with a member
function `dagger’, we could even write:
`wavefunction[i].dagger() * syst.hamiltonian(i,j, params) *
wavefunction[j]`
And if one really needs to access orbitals, only an additionnal bracket
is needed:
`wavefunction[site] [orb]'
Using C++ vectors or Cython arrays of `ta.array`s to represent wave
functions would be as fast as the current representation, or am I wrong
?What were your reasons against such an approach ?
Have a nice day!
Adel