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
181 stars 58 forks source link

Example of adding delta H/delta Sigma in tbtrans calculation #45

Closed KitchenSong closed 6 years ago

KitchenSong commented 6 years ago

In this paper (Computer Physics Communications, 212, pp.8-24), there is a section regarding adding a correction term $\delta H$ in the Hamiltonian. In practice, I guess that you can generate a 'delta.nc' file and add tag 'TBT.dH delta.nc' in the input file for tbtrans.

Meanwhile, I realize this python code is capable of adding $delta H$ or $delta \Sigma$ term as well, which is nice. I assume this can be realized by defining class sisl.io.tbtrans.deltancSileTBtransare.

My question is given that I have a 'device.TBT.nc' file from a standard tbtrans calculation, how to properly generate this delta H/Sigma class, say e.g. a k-dependent E-dependent delta Sigma, such that I can further calculate the transmission based on the modified Hamiltonian. Or do I have to re-run the tbtrans code to get the transport properties of interest based on the modified Hamiltonian?

zerothi commented 6 years ago

It can be done by following the example in the documentation (just added).

So for instance if you already have a device.TBT.nc one may do the following which adds $1 \mathrm{eV}$ on the diagonal terms for all orbitals on atoms 10, 11, 12 and 13:

import numpy as np
import sisl
# The important thing is that we should know the number of orbitals per atom
geom = sisl.get_sile('device.TBT.nc').read_geometry()
dH = sisl.Hamiltonian(geom, dtype=np.complex128)
orb_diag = geom.a2o(range(10, 14), all=True)
for o in orb_diag:
    dH[o, o] = 1.j
sisl.get_sile('delta.dH.nc', 'w').write_delta(dH)

Let me know if you have other inquiries.

KitchenSong commented 6 years ago

I test it and think it is working. This code explains a lot. Thank you.

zerothi commented 6 years ago

Great, will mark as resolved.

KitchenSong commented 6 years ago

Sorry for not doing the test carefully. I do get the delta.dH.nc fil. However, when redoing the tbtrans calculation, I get

tbtrans: Using buffer atoms with dH method. tbtrans: Ensure no buffer orbitals used in dH!

and

Error occured in NCDF: NetCDF: Invalid argument Status number: -36 ncdf: Stopped due to error in NetCDF file ncdf-Node 0

I checked the atom index and I thought it should not be in the buffer atom list. Just wondering what leads to this problem.

zerothi commented 6 years ago

It most definitely is in the buffer list.

Remember, when you do programming in Python it is 0-based indexing, while in the input it is 1-based.

zerothi commented 6 years ago

However, note that in future versions of tbtrans, this check has been removed because it is not important. However, it should still run.

KitchenSong commented 6 years ago

Hmm, I do check the atom and orbital index carefully... Even I only assign delta to only an atom and looped the index of this atom, the same error exists. I notice the file delta.dH.nc is not large, can I print all the file contents to see if anything is going wrong?

The error message posted:

`Error occured in NCDF: Retrieving information about: RedH in file: delta.dH.nc

Error occured in NCDF: Retrieving information about: RedH in file: delta.dH.nc

Error occured in NCDF: NetCDF: Variable not found Status number: -49 NetCDF: Variable not found Status number: -49 NetCDF: Variable not found Status number: -49 ncdf: Stopped due to error in NetCDF file ncdf-Node 8 ncdf: Stopped due to error in NetCDF file ncdf-Node 2`

zerothi commented 6 years ago

Ah, yes.

This is my mistake.

I would suggest you to download the latest commit for siesta-4.1 and use the TBtrans in that version.

https://bazaar.launchpad.net/~siesta-maint/siesta/rel-4.1/tarball/846

The reason is that I found out that the $\delta H$ term should have been expressed in two separate terms: $\delta H$ and $\delta \Sigma$. The first contributes to bond-currents, while the last term does not. This is a necessity and is enabled in the coming 4.1-b4 release. As for sisl, I quickly adopted this convention, hence the variable name change.

So, please download the latest 4.1 commit and use that.

KitchenSong commented 6 years ago

I used 4.1-b3. Will have a try on the new version.

zerothi commented 6 years ago

Exactly. ;)

KitchenSong commented 6 years ago

That version you mentioned works properly.