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

Erroneous electrode setup, check out-put #535

Closed Kulka21 closed 1 year ago

Kulka21 commented 1 year ago

I was trying to do two nanotubes, one in the other, in magnetic field. However, when I try to do tbtrans calculations, I get an error: Erroneous electrode setup, check out-put. My code:

import math
import sisl
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from functools import partial
%matplotlib inline
elec_in = sisl.geom.nanotube(1, atoms=sisl.Atom(6, R=5+0.01), chirality=(6, 6))
nano_in = elec_in.tile(10, 2)
elec_out = sisl.geom.nanotube(1, atoms=sisl.Atom(6, R=5+0.01), chirality=(11, 11))
nano_out = elec_out.tile(10, 2)
elec_out = elec_out.translate([(elec_in.xyz[:, 0].max()-elec_out.xyz[:, 0].max())/2, 0, 0])
elec_out = elec_out.translate([0, (elec_in.xyz[:, 1].max()-elec_out.xyz[:, 1].max())/2, 0])
elec_out = elec_out.translate([0, 0, -elec_in.xyz[:, 2].max()])
elec = elec_in.append(elec_out, 2)
H_elec = sisl.Hamiltonian(elec)
H_elec.construct([[0.1, 1.43], [0., -2.7]])
H_elec.write('ELEC.nc')
nano_out = nano_out.translate([(nano_in.xyz[:, 0].max()-nano_out.xyz[:, 0].max())/2, 0, 0])
nano_out = nano_out.translate([0, (nano_in.xyz[:, 1].max()-nano_out.xyz[:, 1].max())/2, 0])
nano_out = nano_out.translate([0, 0, -nano_in.xyz[:, 2].max()])
device = nano_in.append(nano_out, 2)
H = sisl.Hamiltonian(device)
H.construct(([0.1, 1.43], [0., -2.7]))
H.write('DEVICE.nc')
xy = sisl.Hamiltonian(device)
for ia in device:
    edges = H.edges(ia)
Rij = device.Rij(ia, edges)
xy[ia, edges] = Rij[:, 0] * (Rij[:, 1] + 2 * device.xyz[ia, 1])
xy.finalize()
rec_phis = np.arange(1, 51, 4)
for i, rec_phi in enumerate(tqdm(rec_phis, unit="M")):
    phi = 1 / rec_phi
    dH = H * np.exp(1.0j * xy * 0.5 / rec_phi) - H
    with sisl.get_sile('M_{}.dH.nc'.format(rec_phi), mode='w') as fh:
        fh.write_delta(dH)
zerothi commented 1 year ago

Instead of backticks on every line, you can do 3 backticks at the start and 3 at the end then it looks more coherent!

zerothi commented 1 year ago

The first thing to do when doing transport calculations is to ensure that there is a supercell! So try and see if the geometries belonging to the electrodes have supercell connections along the transport direction. Also, check whether your tbtrans input makes sense, i.e. that the semi-infinite direction is aligned as you have them created.

zerothi commented 1 year ago

Did you manage to find the problem?

Kulka21 commented 1 year ago

The semi-infinite direction is aligned with the nanotube's z-axis. I changed the code so it ensures now that there is a supercell and also I moved the nanotube in a way that z-axis is along the nanotube's symmetry axis. However, I still get the previous error or "Transiesta calculation was a Gamma calculation while you request transmission k-points." My code now:

import math
import sisl
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from functools import partial
%matplotlib inline
elec_in = sisl.geom.nanotube(1, atoms=sisl.Atom(6, R=5+0.01), chirality=(6, 6))
elec_in.set_nsc(a=1,b=1,c=1)
nano_in = elec_in.tile(10, 2)
nano_in.set_nsc(a=1,b=1,c=1)
elec_out = sisl.geom.nanotube(1, atoms=sisl.Atom(6, R=5+0.01), chirality=(11, 11))
nano_out = elec_out.tile(10, 2)
elec_out = elec_out.translate([0, 0, -elec_in.xyz[:, 2].max()])
elec_out = elec_out.translate([(-elec_out.xyz[:, 0].max())/2, 0, 0])
elec_out = elec_out.translate([0, -elec_out.xyz[:, 1].max()/2, 0])
elec_in = elec_in.translate([(-elec_in.xyz[:, 0].max())/2, 0, 0])
elec_in = elec_in.translate([0, -elec_in.xyz[:, 1].max()/2, 0])
elec = elec_in.append(elec_out, 2)
elec.set_sc([2 * elec.xyz[:, 0].max() + 1., 2 * elec.xyz[:, 1].max() + 1., elec.xyz[:, 2].max()])
H_elec = sisl.Hamiltonian(elec)
H_elec.construct([[0.1, 1.43], [0., -2.7]])
H_elec.write('ELEC.nc')
elec.write('ELEC.xyz')
elec.write('ELEC.xsf')
nano_out = nano_out.translate([0, 0, -nano_in.xyz[:, 2].max()])
nano_out = nano_out.translate([(-nano_out.xyz[:, 0].max())/2, 0, 0])
nano_out = nano_out.translate([0, -nano_out.xyz[:, 1].max()/2, 0])
nano_in = nano_in.translate([(-nano_in.xyz[:, 0].max())/2, 0, 0])
nano_in = nano_in.translate([0, -nano_in.xyz[:, 1].max()/2, 0])
device = nano_in.append(nano_out, 2)
device.set_sc([2 * device.xyz[:, 0].max() + 1., 2 * device.xyz[:, 1].max() + 1., device.xyz[:, 2].max()])
H = sisl.Hamiltonian(device)
H.construct(([0.1, 1.43], [0., -2.7]))
H.write('DEVICE.nc')
device.write('DEVICE.xyz')
device.write('DEVICE.xsf')
Kulka21 commented 1 year ago

My RUN.fdf file is:


TBT.HS DEVICE.nc
TBT.k [10 10 10]
TBT.DOS.Gf true
TBT.DOS.A true
%block TBT.Elec.Left
  HS ELEC.nc
  semi-inf-direction -A3
  electrode-position 1
%endblock TBT.Elec.Left
%block TBT.Elec.Right
  HS ELEC.nc
  semi-inf-direction +A3
  electrode-position end -1
%endblock TBT.Elec.Right
zerothi commented 1 year ago

Please do remind your self what set_nsc(1, 1, 1) means for the supercell connections? This is where you do something wrong.

Kulka21 commented 1 year ago

Then what should be here? nsc is a number of supercells. I think it should be (1, 1, Z). How can I set Z so it is correct?

zerothi commented 1 year ago

Have you followed the transiesta sisl tutorial material? The initial presentations discuss this, and why it is important. See here (and links to YouTube). See here https://github.com/zerothi/ts-tbt-sisl-tutorial/releases/tag/v2021.05

Kulka21 commented 1 year ago

I watched it, but maybe I missed the part that answers my question. I am watching it again now. I am also wondering if I am using set_sc correctly or here I also do something wrong?

zerothi commented 1 year ago

Your device set_sc isn't important, the problem is your electrodes. The part about self energies are very important!

Kulka21 commented 1 year ago

Ok, thank you. I am listening to all the tutorials again in hope of finding the answer to correct set_nsc. I also did a junction of two nanotubes. This seems to be working. However, when I calculate the transmission through such a junction it turns out to be zero even though all the atoms are connected. Do you think there is also the same problem with set_nsc?

import math
import sisl
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from functools import partial
%matplotlib inline
elec = sisl.geom.nanotube(1.43, atoms=sisl.Atom(6, R=5+0.01), chirality=(6, 6))
H_elec = sisl.Hamiltonian(elec)
H_elec.construct([[0.1, 1.43], [0., -2.7]])
H_elec.write('ELEC.nc')
nano_left = elec.tile(10, 2)
nano_right = elec.tile(10, 2)
nano_right = nano_right.translate([0, nano_right.xyz[:, 1].max() + 1.5, -nano_right.xyz[:, 2].max()/2])
device = nano_left.append(nano_right, 2)
H = sisl.Hamiltonian(device)
H.construct(([0.1, 1.43], [0., -2.7]))
H.write('DEVICE.nc')
device.write('DEVICE.xyz')
device.write('DEVICE.xsf')
zerothi commented 1 year ago

Ok, thank you. I am listening to all the tutorials again in hope of finding the answer to correct set_nsc. I also did a junction of two nanotubes. This seems to be working. However, when I calculate the transmission through such a junction it turns out to be zero even though all the atoms are connected. Do you think there is also the same problem with set_nsc?

It is zero because there is no connection between orbitals 1-240 and the other segment 241-480. Whether or not that is intended is not clear to me. This problem is not related to set_nsc.

Kulka21 commented 1 year ago

Shouldn't be there a small tunnelling between two nanotubes even if there is no connection between orbitals? However, the intention was to connect orbitals 1-240 with 241-480, so should I increase R or what should I do?

zerothi commented 1 year ago

If there is no hopping between two orbitals, then how can an electron jump? Even in the tunneling regime there is a small hopping element.

It depends on what you want, increasing R might also introduce some hopping elements you don't want. You have to check and verify the physics you want to calculate.

Kulka21 commented 1 year ago

Do you mean introducing next nearest neighbour interaction?

zerothi commented 1 year ago

Yes, that could be the case, it is up to you to understand the implications of increasing R.

zerothi commented 1 year ago

The answer is that nsc should be 3 along the semi infinite direction for the electrodes. One should never change this manually, but rather tile the electrode until nsc is correct.