Why total charge calculating by hand is quite different from my system?

Bader charge density analysis

Moderator: moderators

Post Reply
zhibin
Posts: 4
Joined: Fri Sep 08, 2017 1:49 am

Why total charge calculating by hand is quite different from my system?

Post by zhibin »

Dear VASP users and admin,

In CHGCAR file, the format is: WRITE(IU,FORM) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYZ),NZ=1,NGZC) according to the manual.
However, I made a summation of the total charge is largely different from the electrons in my system. My script is:

c--- read the charge density
open(4,file='CHGCAR',status='old')
read(4,*) (((C(NX,NY,NZ),NX=1,NGXC),NY=1,NGYC),NZ=1,NGZC)

c---- I have opened the CHGCAR file and on each axis, there are 160 grids.
do Nx=1,160
do Ny=1,160
do Nz=1,160
totalcharge = totalcharge + C(Nx,Ny,Nz)/volume
enddo
enddo
enddo

open(15,file='Charge_total.dat')
write(15,*) totalcharge

My result is 40959.9999. But in fact, my system only has two atoms. It is a CO module. I am very confused about my result but I cannot figure it out. I just read the data and make a summation. Could someone give me a hint or suggestion? Thanks!


Best wishes,
Zhibin
zhibin
Posts: 4
Joined: Fri Sep 08, 2017 1:49 am

Re: Why total charge calculating by hand is quite different from my system?

Post by zhibin »

I have solved it. Thanks a lot.
zhibin
Posts: 4
Joined: Fri Sep 08, 2017 1:49 am

Re: Why total charge calculating by hand is quite different from my system?

Post by zhibin »

You should divide the qgrid in FFT. Then you will get the right value.
Post Reply