CHGCAR file

Bader charge density analysis

Moderator: moderators

Post Reply
rinochek
Posts: 3
Joined: Wed Sep 14, 2016 3:22 pm

CHGCAR file

Post by rinochek »

Hello all,
I know that question was disscussed several times.
I would like to make a modification in CHGCAR file based on the simulations from other method.
I need to understand how charge density is written.
If I have NGX, NGY, NGZ - 52 112 64
Does it mean that first 36 lines will be related to charge density at NGY from 1 to 112 and NGZ from 1 to 64, where NGX=1?
And then the same with NGY=1 and NGZ=1.
Did I understand it correctly?


Thank you!
graeme
Site Admin
Posts: 2281
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: CHGCAR file

Post by graeme »

Here is the description from the vasp guys:

In VASP, the density is written using the following commands in Fortran:

WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC)

The x index is the fastest index, and the z index the slowest index. The file can be read format-free, because at least in new versions, it is guaranteed that spaces separate each number. Please do not forget to divide by the volume before visualizing the file!
rinochek
Posts: 3
Joined: Wed Sep 14, 2016 3:22 pm

Re: CHGCAR file

Post by rinochek »

Thank you, but I did not fully understand this description.
Could you explain what is C(NX,NY,NZ)?

Thank you very much!
graeme
Site Admin
Posts: 2281
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: CHGCAR file

Post by graeme »

C(NX,NY,NZ) is a 3d fortran array containing the charge density values C at points NX,NY,NZ
rinochek
Posts: 3
Joined: Wed Sep 14, 2016 3:22 pm

Re: CHGCAR file

Post by rinochek »

Thank you very much!
pranoy
Posts: 2
Joined: Tue Jun 22, 2021 7:17 am

Re: CHGCAR file

Post by pranoy »

May I ask what is the pattern in which the data is stored? I understand that it is a 3D Fortran array but why are there 5 columns wrt NX, NY and NZ? Shouldn't there be 3 columns? What are the 2 extra columns for? I know this might be a dumb question, but I request you to please help me with it.

Also, is there any definite methodology to better understand the data we get in a CHGCAR file? I know that Vesta helps us visualize the electron clouds present, but is there any way to better process the 5-column data we get in a CHGCAR file for compact handling and eventually better understanding? For example, I have a CHGCAR file on a 64x64x64 grid. But it is a 5 column dataset as shown in the attached picture. Is there any other way to convert this data into a 3D Matrix of shape (64,64,64)?
Attachments
Screen Shot 2021-06-22 at 3.22.20 AM.png
Screen Shot 2021-06-22 at 3.22.20 AM.png (209.87 KiB) Viewed 122943 times
graeme
Site Admin
Posts: 2281
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: CHGCAR file

Post by graeme »

If you look at my previous posts in the thread, you can see the format by which this data is written. It is a 64x64x64 data set written with 5 values per line. You could make a 64x64x64 array and read the values back in using the same type of format statement. But generally we read this data into a program such as vesta and visualize the change density, or process it with a program like the bader charge analysis to see how much charge there is on each atom.
pranoy
Posts: 2
Joined: Tue Jun 22, 2021 7:17 am

Re: CHGCAR file

Post by pranoy »

Thank you for your reply. That info was very beneficial. But how does VESTA rearrange the data for visualization? I am just trying to understand the ground reality of post processing the CHGCAR data, and will be personally looking for methods to improve it.
graeme
Site Admin
Posts: 2281
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: CHGCAR file

Post by graeme »

There is no post process or rearranging. A statement such as:

READ(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC)

will load all the data into the 64x64x64 array C.

Vesta will show either isosurfaces of the data or contour plot slices through the dataset.
Post Reply