sisl
sisl copied to clipboard
Find closests energies to retrieve band-gap etc.
Describe the feature
It would be cool if eigenstate objects (or eigenvalue objects) have a method to find the n
closests values to a given value.
I assume something like this interface would do:
# the variable is called .c == coefficient
eigs.close_coeff(value, n=1, method=?)
The method could be, numerically closests, explicit-sign (for n
numbers below+above and filling the returned array with np.nan
for not found).
In this way finding band-gaps would be much easier.
@pfebrer comments here about interface would be appropriate. This would be ideal to use in your plotting functionality for extracting bandgap (indirect and direct).
I don't understand how you would search for a band gap easily using this. Since each eigenvalue object corresponds to a K point, you'd have to use the method for all objects and then do some extra operations to find the actual gap, right?
The way it's done currently in the visualization module is using xarray
functionalities. From all the different entry points, we always end up with a Dataset
containing all the k resolved information (eigenvalues, spin moment, etc...). xarray
datasets are then very easy to query with lots of possibilities, including the different methods that you propose.
This is not the first time that I think incorporating xarray
/pandas
could be very useful. It has come up in other issues. Don't you think it is worth it to use them instead of implementing our own querying functionality? Their APIs are probably more robust than we could ever make them (because that's basically the reason these packages exist) and probably it would be more approachable by users (they are not learning sisl
specific stuff, they are learning skills that will be transferable to other coding they might do. Plus they might already be familiar with the packages).