QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: hejun8035 on March 31, 2012, 09:53

Title: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: hejun8035 on March 31, 2012, 09:53
Dear Prof.
I am a user of ATK. I just want to obtain the electronic matrix elements of the Hamiltonian and overlap which can calculate in the "Siesta". Can it obtain from the ATK and how to operate? thanks!
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: Anders Blom on March 31, 2012, 23:00
Technically yes, but not in a format that is documented or possible to easily use. It would probably be more fruitful if you describe what you wish to do with these quantities, and formulate it as a feature request if it's something that is currently not available in ATK.
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: kstokbro on April 2, 2012, 10:13
The format we use is a sparse format, in the example below is illustrated how you can print it out.
For it to be useful, we should provide some documentation and converter functions to compact formats,
this might be available later on.

However, here is how to print out the current format, not sure if it is useful.


from NanoLanguage import *
configuration = nlread("benzene.nc", object_id = "gID000")[0]
calculator = configuration.calculator()

dm_calculator = calculator._densityMatrixCalculator()

sparse_overlap = dm_calculator.overlap()
sparse_hamiltonian = dm_calculator.hamiltonian()
sparse_dm = dm_calculator.densityMatrix()

#print spin components (NLEngine.UPUP, NLEngine.DOWNDOWN)
sparse_overlap._print(NLEngine.UPUP)
# convert to a python object, an printout the sparse python object
numpy_overlap = NLEngine.sparseSpinMatrixToNumpy(sparse_overlap)
print numpy_overlap
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: Anders Blom on May 21, 2012, 14:45
The sparse matrices can be a little bit hard to use. Here is a script which gives the dense matrices.
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: kstokbro on April 8, 2014, 21:24
Attached is a script which prints out the sparse matrix entries, sometimes it is handy with the real space hamiltonian and overlap
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: waynebeibei on June 8, 2014, 15:53
When I run HS.py, I always meet the error:

    K = NLEngine.Cartesian3D(ka,kb,kc)
AttributeError: 'module' object has no attribute 'Cartesian3D'


Anyone know the reason? My version is 13.8.1
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: Anders Blom on June 8, 2014, 22:56
The original HS.py code is written for 12.8. In 13.8 use the attached version instead.

Note, however, that both of these versions are unsupported, and just provided as-is. If they work for your purpose, great. If not, sorry. In ATK 2014, however, there will be officially supported ways to extract a lot of quantities, like the self-energies, Hamiltonian, etc.
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: waynebeibei on June 9, 2014, 11:00
Thanks for your help! Now I got the Hamiltonian matrix as you suggested :
[[-0.01471202+0.j  0.00000000+0.j -0.00675525+0.j ...,  0.00000000+0.j
   0.00000000+0.j  0.00000000+0.j]
 [ 0.00000000+0.j -0.01471202+0.j  0.00000000+0.j ...,  0.00000000+0.j
   0.00000000+0.j  0.00000000+0.j]
 [ 0.00000000+0.j  0.00000000+0.j -0.01471202+0.j ...,  0.00000000+0.j
   0.00000000+0.j  0.00000000+0.j]
 ...,
 [ 0.00000000+0.j  0.00000000+0.j  0.00000000+0.j ..., -0.01471202+0.j
  -0.11215793+0.j  0.00000000+0.j]
 [ 0.00000000+0.j  0.00000000+0.j  0.00000000+0.j ...,  0.00000000+0.j
  -0.01471202+0.j  0.00000000+0.j]
 [ 0.00000000+0.j  0.00000000+0.j  0.00000000+0.j ...,  0.00000000+0.j
   0.00000000+0.j -0.01471202+0.j]]
[[ 1.+0.j  0.+0.j  0.+0.j ...,  0.+0.j  0.+0.j  0.+0.j]
 [ 0.+0.j  1.+0.j  0.+0.j ...,  0.+0.j  0.+0.j  0.+0.j]
 [ 0.+0.j  0.+0.j  1.+0.j ...,  0.+0.j  0.+0.j  0.+0.j]
 ...,
 [ 0.+0.j  0.+0.j  0.+0.j ...,  1.+0.j  0.+0.j  0.+0.j]
 [ 0.+0.j  0.+0.j  0.+0.j ...,  0.+0.j  1.+0.j  0.+0.j]
 [ 0.+0.j  0.+0.j  0.+0.j ...,  0.+0.j  0.+0.j  1.+0.j]]
Matrix size:  (32L, 32L)

It has been truncated and how to show its full text?
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: Anders Blom on June 9, 2014, 11:20
Please use Google and you shall find
Search: "numpy print array"
http://stackoverflow.com/questions/2891790/pretty-printing-of-numpy-array
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: PR on September 30, 2014, 08:27
Hello,
I am using ATK 2014 version.
Can you please tell me how can I extract these matrix elements, Hamiltonian and overlapping, from GUI.
If not directly from GUI then can you please provide some script for the same.



Thanks
PR.
Title: Re: How to obtain the electron matrix elements of the Hamiltonian and overlap?
Post by: Umberto Martinez on September 30, 2014, 09:24
Check the Accessing ATK internal variables (http://quantumwise.com/publications/tutorials/item/816-accessing-atk-internal-variables) tutorial.

direct link http://quantumwise.com/documents/tutorials/latest/LowLevelEntities/index.html