Closed AsymmetryChou closed 10 months ago
Thanks for opening this issue.
Indeed that is a bug, it should be fixed. However, if what you want to do is something like:
sisl.Hamiltonian[:, :] = hamil_block
Then you can more easily do it via something like this:
import scipy.sparse as sps
csr = sps.csr_matrix(hamil_block)
H = sisl.Hamiltonian.fromsp(geometry, csr)
it should also be much faster.
Thanks for your reply!
I would take scipy.sparse to my code. In this method, how should I label the lattice vector to describe the interaction between unit cells?
For now I do this by
H[0,1,(0,0,1)] = hopping
to describe the interaction between the first orbital in unit cell(0,0,0) and the second orbital in unit cell(0,0,1)
When using the new method, where should I label this information?
import scipy.sparse as sps
csr = sps.csr_matrix(hamil_block)
H = sisl.Hamiltonian.fromsp(geometry, csr)
PS: hamil_block is the interaction between atom A's all orbtials and atom B's all orbitals. The Hamiltonian is in real-space representation.
Internally this is represented by offsets, for instance:
H[0, 1, (0, 0, 1)] = hopping
# is equivalent to
off = H.geometry.sc_index([0, 0, 1]) * H.geometry.no
H[0, 1 + off] = hopping
Hence your sparse matrix can be constructed by simple means of appending various CSR matrices.
Which code are you trying to extract the information from?
Thank you for your kind help!
My friends and I are trying to design a neural network to predict the TB hamiltonian for some materials and calculate their transport properties by TBtrans.
Sounds cool! :)
Sounds cool! :)
Thanks~
Hope we could literally make something interesting!
This should hopefully be fixed in the latest commit, try it out
Describe the issue Dear developers:
I use sisl.physics.hamiltonian in TB model calculation. It seems that in sisl the hamiltonian matrix element has to be given one by one. If I use slice operation as follows:
there comes the error:
My question: Is there any faster operation helping me give the hamiltonian matrix element to Hamil_sisl, something like slice operation in numpy ?
Because my hamiltonian matrix element is determined by some other code and tranlated into sisl.physics.hamiltonian for TBtrans input, it seems to be unconvenient to use H.constrcut or H.tile method to construct Hamiltonian in sisl. If I can do slice operation to give values to Hamil_sisl, it would be best~
Thank you!
Version details Run the below code and add to issue (if an issue is relevant for the issue):