zerothi / ts-tbt-sisl-tutorial

Tutorials for the sisl-TBtrans-TranSiesta suite
Creative Commons Attribution Share Alike 4.0 International
33 stars 30 forks source link

About tutorial #4

Closed yuefei-huang closed 4 years ago

yuefei-huang commented 4 years ago

Hello Nick, I met some problems running the sisl tutorials. In TB_01:

for ia, io in H:

You intended to enumerate atomic and orbital indices, but actually when using for i in H:, it enumerates the indices of nonzero terms in H, for example running:

graphene = sisl.geom.graphene()
H = sisl.Hamiltonian(graphene)
H[0, 0] = 0.0
H[1, 1] = 0.0
H[0, 1] = -2.7
H[1, 0] = -2.7
H[0, 1, (-1, 0)] = -2.7
H[0, 1, (0, -1)] = -2.7
H[1, 0, (1, 0)] = -2.7
H[1, 0, (0, 1)] = -2.7
for ia, io in H:
    print(ia,io)

Output is:

0 0
0 1
0 9
0 5
1 1
1 0
1 10
1 14

In TB_04 about edge atom indice:

for ia in device.close(device.center(what='cell'), R=14.):
    if len(device.close(ia, R=1.43)) < 4:
        edge.append(ia + 1) # + 1 to get fortran indices

Why do you use fortran indices in the following code? When you plot the edge atom DOS later, and call tbt.DOS(atom=edge, norm='atom'), should you use python indices here?

In TB_05,


dangling = [ia for ia in H.geom.close(H.geom.center(what='cell'), R=14.)
                if len(H.edges(ia)) < 2]
H = H.remove(dangling)
# + 1 to get fortran indices
edge = [ia + 1 for ia in H.geom.close(H.geom.center(what='cell'), R=14.)
         if len(H.edges(ia)) < 3]

Should the two inequality be <3 and <4, as in TB_04? Since H.edges(ia) returns itself too.

Thank you!

zerothi commented 4 years ago

Thanks.

Indeed I haven't updated the 2020 tutorial to reflect changes in sisl.

I have been postponing this and will get to it now, thanks!

zerothi commented 4 years ago

In TB_04 about edge atom indice:

for ia in device.close(device.center(what='cell'), R=14.):
    if len(device.close(ia, R=1.43)) < 4:
        edge.append(ia + 1) # + 1 to get fortran indices

Why do you use fortran indices in the following code? When you plot the edge atom DOS later, and call tbt.DOS(atom=edge, norm='atom'), should you use python indices here?

You are correct. The reason I did this was to get 1-based indices in the pretty-printed list to be used for sdata.
But for sure it should be python indices further down. Thanks for catching this.

In TB_05,


dangling = [ia for ia in H.geom.close(H.geom.center(what='cell'), R=14.)
                if len(H.edges(ia)) < 2]
H = H.remove(dangling)
# + 1 to get fortran indices
edge = [ia + 1 for ia in H.geom.close(H.geom.center(what='cell'), R=14.)
         if len(H.edges(ia)) < 3]

Should the two inequality be <3 and <4, as in TB_04? Since H.edges(ia) returns itself too.

Agreed! Leftover from last edit... Thanks!

zerothi commented 4 years ago

@yuefei-huang I have updated the 2020 branch to reflect the required changes.

Could you please check?

yuefei-huang commented 4 years ago

Yes, I think the problems I have encountered have all been fixed. Thank you!