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

Mulliken's total charge seems to be only half of the real total charge #611

Closed AsymmetryChou closed 1 year ago

AsymmetryChou commented 1 year ago

Describe the issue I use Mulliken analysis on a system with 120 shell electrons(60 up and 60 down) using spin polarization. However, through DM.mulliken operation which outputs [Total, Sz], I only find total charge is 60 sumed in all atoms.

PS: In #501, I found the definiton(consistent with me) Total = up + down (So in this case Total should be 120?) z = up - down

# spin polarization case
DM = sisl.get_sile('../test_mol/mol/+2_tshs/sta.fdf').read_density_matrix()
print(DM.shape)
mul_charge = DM.mulliken(projection='atom')
print(mul_charge.shape)

print('Total:', mul_charge[0,:].sum())

#(296, 296, 3)
#(2, 44)
#Total: 60.00020554917267

Here I have 2 questions:

  1. what 's the meaning of the last number 3 in (296, 296, 3). Apart from spin up and spin down,what's the third dimension?
  2. When I sum up the charge in all atoms, I only got half of the total eletrons(60,not 120). I carefully look up at the output file of Siesta where doing an Mulliken analysis, the total mulliken charge for up and down is both 60, which is consistent with my initial analysis but is different from sisl output Total in [Total, Sz]. It really bothers me.

I am a beginner in Sisl so maybe there are some naive mistakes above. Thanks!

Version details Run the below code and add to issue (if an issue is relevant for the issue):

import sys
print(sys.version)
import sisl
print(sisl.__version__)

3.9.17 (main, Jul  5 2023, 20:41:20) 
[GCC 11.2.0]
0.0.0.dev+851d78c55d40d1f7aa1f5d8320aae1d3364064b8
zerothi commented 1 year ago

thanks for your report, could you share the folder with the content so I can debug it! :)

zerothi commented 1 year ago

I believe you are correct. I think I am missing a copy, hence the update happens in the same array.

zerothi commented 1 year ago

This will only affect spin-polarized calculations.

As for the 3, it is because the current way the matrices are built up is by having the density matrices in the first elements, and the last one (in this case 3) will be the overlap matrix.

AsymmetryChou commented 1 year ago

thanks for your report, could you share the folder with the content so I can debug it! :)

OK! Which way do you prefer, by email or something else?

AsymmetryChou commented 1 year ago

This will only affect spin-polarized calculations.

As for the 3, it is because the current way the matrices are built up is by having the density matrices in the first elements, and the last one (in this case 3) will be the overlap matrix.

Thanks! I get it!

zerothi commented 1 year ago

I am playing a bit now, perhaps I don't need it, lets wait and see. I'll ping you for more information, if needed! :) Thanks!

AsymmetryChou commented 1 year ago

I am playing a bit now, perhaps I don't need it, lets wait and see. I'll ping you for more information, if needed! :) Thanks!

Ok, no problem!

zerothi commented 1 year ago

Ok, I have now fixed the bug! thanks for discovering!

Could you please install the latest sisl development version, then you should have the fix! Let me know!

AsymmetryChou commented 1 year ago

Ok, I have now fixed the bug! thanks for discovering!

Could you please install the latest sisl development version, then you should have the fix! Let me know!

Successfully running!! I get the right total charge in Mulliken's analysis. Thanks!

zerothi commented 1 year ago

Thanks for returning! I'll close this issue then!