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

use of sisl in the Hamiltonian modification #129

Closed SanRG closed 5 years ago

SanRG commented 5 years ago

I am working on the modification of the Hamiltonian matrix, corresponding to a molecular junction using the sisl tool; with the aim to shift the eigenvalues and re-calculate the transmission spectrum with TBtrans. I have read the full Hamiltonian from the Transiesta output .TSHS file, and I have created a sub-matrix corresponding only to the central molecule atoms.

My idea is to diagonalize first the sub-matrix (Hmol), and modify the eigenvalues in the Diagonal matrix (D), and then carry out a second diagonalization in the inverse order: using the modifed matrix D', and extract the Hmol' ....

Due to siesta considers the [3,3,3] supercell, my sub-matrix(Hmol) is not squared. I have 500 columns corresponding to the orbitals in the unit cell, and 13500 rows corresponding to the orbitals in the supercell. A total of 27 sub-matrices of 500x500 together. My question is: Could I cut the Hmol in 27 squared sub-matrices and diagonalize them all?, or only the part corresponding to the unit cell?

Thanks in advance,

zerothi commented 5 years ago

Could you show the code you have?

Any kind of:

Hsub = H.sub(range(10, 70))
Hsub.eigh()

would work. Using the above method will retain all supercell connections between the atoms you have retained in the Hmol geometry.
If you want to further remove supercell connections, simply do:

Hmol.set_nsc([1] * 3)

which forces the supercell connections to be 0 along all directions.

Note that no matrix from Siesta (except Gamma-only calculations) have square matrices since the non-square parts relates the supercell connections.

SanRG commented 5 years ago

I am using:

TSHS=get_sile ('siesta.TSHS')
H=TSHS.read_hamiltonian()
print (H)
print (H.shape)

#Sub-matrix corresponding to the molecule atoms
H_mol=H.sub(range(201,253))
print (H_mol.shape)
print (H_mol)

es=H_mol.eigenvalue()

First, I do not know why in the full Hamiltonian appears: He, Li as species, when I have Au, C and S. The rest, na and number of each specie are right:

Hamiltonian{non-zero: 2230375, orthogonal: False,
 Spin{unpolarized, kind=f},
 Geometry{na: 429, no: 3893,
  Atoms{species: 3,
   Atom{He, Z: 2, mass(au): 4.00260, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 377,
   Atom{Li, Z: 3, mass(au): 6.94100, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 30,
   Atom{H, Z: 1, mass(au): 1.00794, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 22,
  },
  maxR: -1.00000,
  SuperCell{volume: 1.1167e+04, nsc: [3 3 3]}
 }
}
(3893, 105111, 2)

Second, I extract the Molecular Hamiltonian and the corresponding eigenvalues with es=H_mol.eigenvalue().

Hmol shape
(500, 13500, 2)
Hamiltonian{non-zero: 144320, orthogonal: False,
 Spin{unpolarized, kind=f},
 Geometry{na: 52, no: 500,
  Atoms{species: 3,
   Atom{He, Z: 2, mass(au): 4.00260, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 0,
   Atom{Li, Z: 3, mass(au): 6.94100, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 30,
   Atom{H, Z: 1, mass(au): 1.00794, maxR: -1.00000,
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0},
    Orbital{R: -1.00000, q0: 0.0}
   }: 22,
  },
  maxR: -1.00000,
  SuperCell{volume: 1.1167e+04, nsc: [3 3 3]}
 }
}
[-18.68147581 -18.39862797 -18.14539799 -17.54516142 -17.27724659
 -16.96188585 -16.35154956 -16.19922977 -15.37333086 -15.19365247
 -15.13218812 -15.01937813 -14.79441139 -14.751866   -13.86540924
 -13.29720805 -12.80727612 -12.38785366 -11.97929001 -11.80455373
 -11.6730195  -11.55767531 -11.06318607 -10.98961344 -10.57324505
  -9.83682814  -9.48396531  -9.42017116  -9.24955785  -8.56723386
  -8.34884295  -8.14931225  -7.98722113  -7.81052894  -7.80038315
  -7.77233197  -7.69170191  -7.56707496  -7.51392478  -7.29795138
  -7.21030384  -7.05548449  -7.01269976  -6.92006875  -6.82556011
  -6.6255032   -6.45516291  -6.35598665  -6.24725332  -6.03088931
  -5.9496327   -5.84044184  -5.72416245  -5.62477008  -5.48526693
  -5.42719117  -5.23406205  -5.17168986  -4.95909105  -4.83982237
  -4.67348401  -4.22999207  -4.14838423  -4.0123007   -3.8748377
  -3.70824226  -3.26534568  -3.08038047  -2.83763828  -2.64883797
  -2.43691965  -2.20194794  -1.37516845   0.78723768   1.73724681
   1.81128686   1.90655689   2.00473508   2.19781908   2.59061721
   2.69840272   2.9941532    3.3906541    3.87003127   3.89851625
   4.17256946   4.98136889   4.99222246   5.36962489   5.46280645
   5.60812475   5.63357817   5.68576081   5.73156326   5.73907927
   5.98430625   6.13994823   6.16043638   6.24873685   6.31527271
   6.48286325   6.52651515   6.74888028   6.85587617   7.12321111
   7.23500442   7.28827745   7.48709935   7.52313221   7.66717093
   7.91247151   7.95653585   8.06189466   8.38355846   8.50622719
   8.6391073    8.89864823   8.96546603   9.1004681    9.20856552
   9.26621179   9.40093997   9.49015075   9.60035667   9.78837944
   9.91961513  10.00805403  10.07442669  10.2186863   10.26740924
  10.37631936  10.42148345  10.63061773  10.66797769  10.72566085
  10.91402513  11.0254906   11.12529278  11.25665859  11.48145298
  11.48828241  11.62353444  11.84281735  11.88571663  12.04113609
  12.25714881  12.31085408  12.42493786  12.52447219  12.62250518
  12.76692823  12.91902101  13.05492433  13.28406914  13.36936547
  13.40687306  13.52119912  13.56563961  13.58502898  13.65881685
  13.92651473  14.01785094  14.09245665  14.10126806  14.21273914
  14.31127242  14.34477521  14.4154722   14.57481934  14.60102818
  14.78069458  14.82712378  14.89866487  14.96070673  15.01364272
  15.13341932  15.38402008  15.4990649   15.68969543  15.82230883
  15.97276608  16.09112799  16.19364559  16.35030612  16.40138978
  16.42698939  16.59829072  16.73542457  16.82891156  16.89200349
  16.9692249   17.18397362  17.37685244  17.4053312   17.66099265
  17.77002827  17.89769042  17.93562646  18.07989625  18.20888482
  18.3684685   18.46097962  18.54493271  18.80646041  19.14986284
  19.27249179  19.34469541  19.49740394  19.61443343  19.77290385
  20.02742189  20.50056031  20.76638664  20.8519508   20.97444113
  21.06492189  21.09626764  21.13502862  21.19866639  21.22722082
  21.33194553  21.45738664  21.50449856  21.55997686  21.63379599
  21.75641895  21.86277557  21.90292027  22.00636152  22.03240657
  22.14912594  22.39429164  22.41759896  22.42377785  22.46503208
  22.5747219   22.64194925  22.79962507  22.86149134  22.9625223
  23.06076359  23.10784497  23.13754118  23.29895577  23.52997818
  23.73670235  23.76179282  23.83373821  24.06693543  24.1008803
  24.19396161  24.31912315  24.39535888  24.45925261  24.50114249
  24.72966909  24.86767367  25.09405812  25.14505486  25.24996383
  25.28960405  25.71754148  25.88349634  26.02915158  26.27355649
  26.31917259  26.37645699  26.60104186  26.7809888   27.08308408
  27.1436985   27.15831856  27.283399    27.3229067   27.43079201
  27.57921817  27.6422481   27.68437949  27.97597289  28.23420304
  28.35874355  28.58872937  28.66410744  29.12897522  29.51157641
  29.5591146   29.71923307  29.82909231  30.02515384  30.30156682
  30.63432019  30.89349022  31.05156162  31.17635004  32.09659847
  32.52068935  32.57870783  32.80396075  32.84150824  33.12317439
  33.58386207  33.76747804  34.03533602  34.28407399  34.33181018
  34.44833551  34.86285839  35.26729155  35.70890751  35.76945346
  36.005193    36.03866423  36.25915194  36.31804788  36.65510072
  36.77999043  36.9142272   37.19533487  37.44989441  37.65504445
  37.84221865  38.22262441  38.30070717  38.55963422  38.71976851
  38.922233    39.10412939  39.23825836  39.60103857  39.79600559
  40.08291717  40.5183905   40.55499468  40.64255486  40.90351485
  41.10674762  41.25107065  41.36972582  41.51988354  41.69115829
  41.8936127   42.46842414  42.60541191  42.97702831  43.1659436
  43.2819042   43.41697575  43.5217405   43.5474401   43.77857011
  44.06839761  44.67246934  44.7838819   45.27483125  45.39579019
  45.6237293   45.86491794  46.25336371  46.50596273  46.6972956
  47.52839177  47.72641311  47.80346118  48.45200192  48.66478628
  48.88035023  49.00858192  49.22944775  49.2783864   49.57944699
  50.41623039  50.63436288  50.73936345  50.88617263  51.10248398
  51.17063792  51.27357383  51.31909447  51.5587128   51.59830517
  51.93283952  52.07902582  52.51053359  52.7787704   53.51651875
  53.62249572  53.70475199  53.85253387  54.10751295  54.2527552
  54.38033592  54.86970082  55.30511222  55.43757935  55.63970869
  56.10965302  56.6216276   57.60337523  57.79564794  57.99533404
  58.21647801  58.3844557   58.59554228  58.67563204  59.25515293
  59.56904746  59.69495645  60.13285411  60.39393664  60.44252703
  60.8968628   61.37386745  61.42921213  62.4634012   62.72615742
  62.93057688  63.27498889  63.37125026  63.64077073  63.77873165
  64.12267207  64.2295912   64.83108507  65.26865606  65.37486793
  65.56924739  65.97634183  66.31783375  66.36926741  66.46012942
  66.83899185  66.91952306  67.10114575  67.27154463  67.44203998
  67.55044374  67.65134001  68.28982961  68.58041396  69.75326964
  70.23264143  70.46431387  71.2385392   72.06899746  72.23438136
  74.62771246  75.32645511  76.03252747  76.58716043  78.27521232
  79.15067045  79.62880509  80.33696353  80.62624254  81.72399799
  82.66964128  83.03986351  84.69420206  84.8440597   85.24059921
  85.30122701  85.43605431  86.5083223   86.73567454  87.08778598
  87.48145161  87.8206952   88.69402101  89.62669171  90.73508131
  91.37696566  92.38612207  93.17103677  94.57419741  94.9207919
  95.95464919  97.14393123  98.81825087  99.74078963 100.76110157
 101.35127944 101.95046524 104.31158732 104.66105825 105.26299849
 109.42077397 112.32432347 117.20508266 123.55834697 125.75276781
 126.07775053 128.88533396 129.38930595 130.64425022 137.02125242
 137.28284924 143.31695655 146.46243464 150.94189603 160.62911205]

Now. I can modify the eigenvalues, but how I go back to introduce the new D' matrix inside of the H_mol or in the full Hamiltonian?, if i can not diagonalize H_mol.... or how I create a delta Hamiltonian file with the new information? Because If I cut the H_mol in 27 squared matrices for diagonalizing each one, to later append them in a new D', I am in the same point....

Thanks for your help,

zerothi commented 5 years ago

1) The TSHS does not contain the information about which atom is what. It doesn't matter for anything but appearance. 2) I don't understand your final questions? D'? You have to be really specific! ;) 3) Doing H_mol.eigenvalue() does a diagonalization of H_mol. 4) If you want to generate a delta-H you shouldn't do sub, then something like:

dH = sisl.get_sile('siesta.TSHS').read_hamiltonian()
dH.empty()
dH[io, io] = 1.
dH.write('delta.dH.nc')

This would create a delta-H with 1 eV onsite on the io orbital.

SanRG commented 5 years ago

Thanks for your reply,

  1. Ok, its good to know it!!!

  2. My main idea was first to extract the molecular hamiltonian for diagonalizing it (D), and obtain the corresponding eigenvalues ( I understand that the diagonal values in D are the hamiltonian eigenvalues). At this point, I could modify the eigenvalues and create a D' matrix with these new eigenvalues, to go back and obtain a molecular hamiltonian modified (H'mol). Now I can use the H'mol to re-calculate the transmission. Well, I can not do the initial diagonalization of the molecular hamiltonian because this matrix is not squared. So, my final question is: Should I cut this Hmol in 27 squared sub-matrices, and diagonalize each one?, or will be enough diagonalize the H'mol corresponding to the first unit cell?

  3. Right!!

4.- You mean that, if I want to create a delta-H.nc file, I should work on the full hamiltonian, right?

Other 2 questions: 1.- If I want to save the molecular sub Hamiltonian extracted from the full Hamiltonian, in a readable file (i.e., txt) ,using sisl, how must I do?

    • I would like to print the sub-matrix corresponding to H_mol with sisl, keeping its own form. I have tried the next:
      for i in range (0, 499).
      for j in range (0, 499):
      print (Hmol[i,j])

      But I see a list of 1 column with two values [[ Hamiltonian Overlap]] and (i x j) rows. I can not see the squared shape of the matrix.

Thank you so much for everything!!

zerothi commented 5 years ago
  1. Ok
  2. But... The Hmol matrix is square. The non-square elements is a way to handle supercell connections in a single matrix format. You have to decide whether your molecule has supercell connections or whether it shouldn't. For the record you cannot and should never diagonalize the 27 matrices individually, it does not make sense except the unit-cell matrix. The unit-cell matrix is what is left after you do Hmol.set_nsc([1] * 3)
  3. Ok
  4. Yes.
  5. You could write it using Hmol.write('test.ham') which writes a semi-readable text file with Hamiltonian couplings in eV together with the overlap matrix.
  6. If you just want to see the elements then you could do: Hmol.Hk(format='array') which creates the dense matrices. This will fold in the supercell connections (with no phases) so you should take this into account.
zerothi commented 5 years ago

@SanRG are you still having problems, or can I close this?

SanRG commented 5 years ago

For the time being, I have not been able to advance further on this issue; even so, thank you very much for your help and guidance. You can close it!!