How to get charge density from CHGCAR?

Bader charge density analysis

Moderator: moderators

Post Reply
Hanmei_Tang
Posts: 7
Joined: Wed Jan 27, 2016 6:26 pm

How to get charge density from CHGCAR?

Post by Hanmei_Tang »

Hi all,

I currently want to get charge density according to CHGCAR file by some code. What I found in VASP manual is charge density is written using 'WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC)'. My understanding is that in CHGCAR the line after all sites coordinates is grid number in 3 directions.

===============================Samle_of_CHGCAR==========================================
unknown system
1.00000000000000
8.353340 0.000000 0.000000
-4.176670 7.234204 0.000000
0.000000 0.000000 21.634955
XX XX XX XX
6 12 18 72
Direct
0.000000 0.000000 0.500000
0.000000 0.000000 0.000000
.....
128 128 324

0.15480122421E+05 0.15223404129E+05 0.14470521529E+05 0.13272915918E+05 0.11714678513E+05
0.99086396293E+04 0.79885705331E+04 0.60965594050E+04 0.43661574090E+04 0.29039650959E+04
.....
augmentation occupancies 1 33
0.8794940E-05 0.5316093E-05 0.2173084E-05 -0.2059185E-05 -0.1103712E-05
0.6578136E-06 -0.3839548E-05 -0.1598532E-05 0.7331360E-06 0.3627926E-05
....
==========================================================================================
For example, the above is part of CHGCAR file and there should be 128X128X324 = 5308416 grid totally. That means there should be 5308416 lines following the line '128 128 324'. However, there are only 2099525 lines in CHGCAR, much less than 5308416, only a half actually. I am wondering if I misunderstood anything... How can I extract charge density from CHGCAR? Also, what is the meaning of the last 2 columns?
graeme
Site Admin
Posts: 2291
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: How to get charge density from CHGCAR?

Post by graeme »

There should be 5.3M numbers, not 5.3M lines since each line contains 5 entries. The charge density will be written in roughly 1M lines. The reason you see about 2M is probably because your calculation is spin polarized and so there is a second data set corresponding to the spin density.
Hanmei_Tang
Posts: 7
Joined: Wed Jan 27, 2016 6:26 pm

Re: How to get charge density from CHGCAR?

Post by Hanmei_Tang »

Aha, I got it. Thank you so much, Dr. Graeme!
Hanmei_Tang
Posts: 7
Joined: Wed Jan 27, 2016 6:26 pm

Re: How to get charge density from CHGCAR?

Post by Hanmei_Tang »

I actually have a very stupid question... CHGCAR mesh is based on Cartesian coordinates or crystal coordinates??
graeme
Site Admin
Posts: 2291
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: How to get charge density from CHGCAR?

Post by graeme »

The grid is along the lattice vectors, which may not be Cartesian.
Hanmei_Tang
Posts: 7
Joined: Wed Jan 27, 2016 6:26 pm

Re: How to get charge density from CHGCAR?

Post by Hanmei_Tang »

Thank you!
Post Reply