Closed tfrederiksen closed 2 years ago
True, I think this was a leftover from an old limitation when writing the file... So definitely should be looked into!
As a side note. This is because tbtrans expects diagonal values. And if you change the sparsity and read it in again, they won't be the same! Quite unexpectedly for some users I guess?
Could the solution be a flag tbtrans=True
(or fill_diag
?) for write
where eventual missing diagonal elements are added (at the expense of changing sparsity)?
In my case I only want to construct a Hamiltonian once to be able to quickly read it in many subsequent runs. It is no problem if sparsity is modified, but on the other hand it seems unnecessary.
Could the solution be a flag
tbtrans=True
(orfill_diag
?) forwrite
where eventual missing diagonal elements are added (at the expense of changing sparsity)?In my case I only want to construct a Hamiltonian once to be able to quickly read it in many subsequent runs. It is no problem if sparsity is modified, but on the other hand it seems unnecessary.
I am somewhat hesitant coming to think of it. The file formats TSHS
and nc
are generally Siesta/TBtrans specific. And there is no error handling from tbtrans side to check that the diagonal entries are set. Every calculation done with such a file would be wrong. So while the fileformats could be used by 3rd party libraries I think they should still uphold the standard of defining all diagonal entries.
This is about safe-guarding users ;)
If anything it should always change the sparsity pattern to contain the diagonals, without possibilities to not store them.
I encountered some unexpected behaviour trying to write a simple Hamiltonian to netcdf, say with this simple script:
which produces this error:
As is clearly stated in this message, the behaviour is related to the fact that the whole overlap matrix is not explicitly given.
If I uncomment the line in my script above (ie. setting the matrix element also for the first atom) then things are OK and the file is correctly produced.
Now, wouldn't it not be better if sisl handled this situation internally? Is there a reason to force the user to set all diagonal matrix elements even when working with an orthogonal basis?