zerothi / sisl

Electronic structure Python package for post analysis and large scale tight-binding DFT/NEGF calculations
https://zerothi.github.io/sisl
Mozilla Public License 2.0
182 stars 58 forks source link

Cannot read Hamiltonian with certain atomic coordinates #610

Closed Connor-Herring closed 1 year ago

Connor-Herring commented 1 year ago

I am calculating the overlap matrix for simple systems (just 3 atoms) after running a single scf step with siesta. These simulations consist of N2 interacting with a single atom (either Cu, Ru, Re, Mo, Ti). I am able to read the Hamiltonian and calculate the overlap matrix for all cases except Ti. In this case I get the following error:

"sisl.io.SileError: hsxSileSiesta(siesta_1.HSX, base=.).read_hamiltonian could not read Hamiltonian sizes. (ierr=-1)"

I've found if I just slightly adjust the coordinates of the Ti atom and rereun the scf step then the python code runs fine; however, I need to get it working with the correct atomic coordinates. Below is my python code but in the cases where I get the above error it is stopping during the "read_hamiltonian()" call.

Reproducable code

fdf = get_sile('RUN.fdf')
geom = fdf.read_geometry()
H = fdf.read_hamiltonian(geometry=geom)

hList = H.Hk() #Defaults to Gamma point
denseH = hList.todense()
denseH_arr = asarray(denseH)
save('denseH.npy', denseH_arr)
sList = H.Sk() #Defaults to Gamma point
denseS = sList.todense()

denseS_arr = asarray(denseS)
save('denseS.npy', denseS_arr)

Version details Run the below code and add to bug-report:

import sys
print(sys.version)
import sisl
print(sisl.__version__)

Output from above:

3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) [GCC 10.3.0] 0.0.0.dev+eacb8351ff416ad9f7f93732777c3d7931c5f711

I am using siesta version 4.1 and I believe sisl is finding the .HSX file.

zerothi commented 1 year ago

Hi, thanks for reporting. Generally I would advice against using the HSX file format. It is incomplete is various ways. And if you are insisting on the exact same coordinates, then your only choice is to use the TSHS file format. Simply add TS.HS.Save to your fdf file, and use that file (you shouldn't need to change your script as the fdf file will prefer the TSHS file if present).

Lastly, some comments.

zerothi commented 1 year ago

@Connor-Herring did it fix your problem?

Connor-Herring commented 1 year ago

@zerothi Yes, thank you! I had been trying to write the TSHS before but it was not working. I realized it's because it only gets written if the scf loop converges and I was previously just running 1 step. Anyway, using the TSHS file is working for me now (with all coordinates).