pablosanjose / Elsa.jl

Efficient lattice simulation algorithms - a Julia library
Other
18 stars 2 forks source link

Another refactor of complex eigenvalue handling #37

Closed pablosanjose closed 4 years ago

pablosanjose commented 4 years ago

This partially reverts #36 following a comment by @BacAmorim .

The idea of #36 was to wrap the work matrix for bloch! in Hermitian. When passed to diagonalize, the Hermitian wrapper signaled the intent to obtain real eigenvalues. Part of the criticism (slow diagonalization with Hermitian wrappers) does not apply in recent versions of Julia, but nevertheless, the whole Hermitian design seemed unnecessary.

In this PR we no longer force a Hermitian wrapper on the output of bloch!. We allow diagonalize to return complex or real eigenvalues (this depends on the package used). However, when grouping all eigenvalues/vectors into subbands we force a conversion of eigenvalues to their real part only if momenta are real, or make them complex if momenta are complex. The result are subband meshes with vertices (k, ϵ) of uniform type.

Of course, the usual situation is to provide bandstructure with a mesh of real momenta, so eigenvalues will typically be truncated to their real part. It is up to the user (using future API extensions) to provide a complex momentum mesh if one is dealing with bandstructures of non-hermitian Hamiltonians and one needs to preserve the information of the imaginary energies. This design seems overall more sane to me, and does not impose such a bias towards the hermitian case.

pablosanjose commented 4 years ago

I'm going to merge this as is, but please comment if you find any problem

BacAmorim commented 4 years ago

This seams like a reasonable approach to me!