Page 1 of 1

How to get charge density from CHGCAR?

Posted: Thu Apr 07, 2016 4:01 am
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?

Re: How to get charge density from CHGCAR?

Posted: Fri Apr 08, 2016 1:04 pm
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.

Re: How to get charge density from CHGCAR?

Posted: Fri Apr 15, 2016 5:07 pm
by Hanmei_Tang
Aha, I got it. Thank you so much, Dr. Graeme!

Re: How to get charge density from CHGCAR?

Posted: Sat Apr 30, 2016 3:57 am
by Hanmei_Tang
I actually have a very stupid question... CHGCAR mesh is based on Cartesian coordinates or crystal coordinates??

Re: How to get charge density from CHGCAR?

Posted: Sat Apr 30, 2016 12:58 pm
by graeme
The grid is along the lattice vectors, which may not be Cartesian.

Re: How to get charge density from CHGCAR?

Posted: Sat Apr 30, 2016 9:22 pm
by Hanmei_Tang
Thank you!