CHGCAR unit?
Moderators: Global Moderator, Moderator
CHGCAR unit?
I am curious to know what is the unit of charges written out
in CHGCAR file. For e.g. for bcc Fe CHGCAR,
-------------------
bcc Fe
10.0000000000000000
1.000000 .000000 .000000
.000000 1.000000 .000000
.000000 .000000 1.000000
1 1
Direct
.000000 .000000 .057102
.000000 .000000 .942898
84 84 84
.41098271954E+04 .38580593547E+04 .32056173636E+04 .23907855172E+04 .16323134731E+04
.10440737881E+04 .64952106325E+03 .40394464342E+03 .25149651632E+03 .15428370958E+03
.92653834837E+02 .55483939720E+02 .34042823873E+02 .21474147940E+02 .13548327933E+02
……….
-------------------------------------------
after NGXF, NGYF, NGZF(84x84x84) what is the unit of the value .41098271954E+04? If it is in e(electron), then if we sum up
all charges at each 3D grid point, the number becomes huge, many times the nu,ber of electrons in the system.
Thanks for any help
in CHGCAR file. For e.g. for bcc Fe CHGCAR,
-------------------
bcc Fe
10.0000000000000000
1.000000 .000000 .000000
.000000 1.000000 .000000
.000000 .000000 1.000000
1 1
Direct
.000000 .000000 .057102
.000000 .000000 .942898
84 84 84
.41098271954E+04 .38580593547E+04 .32056173636E+04 .23907855172E+04 .16323134731E+04
.10440737881E+04 .64952106325E+03 .40394464342E+03 .25149651632E+03 .15428370958E+03
.92653834837E+02 .55483939720E+02 .34042823873E+02 .21474147940E+02 .13548327933E+02
……….
-------------------------------------------
after NGXF, NGYF, NGZF(84x84x84) what is the unit of the value .41098271954E+04? If it is in e(electron), then if we sum up
all charges at each 3D grid point, the number becomes huge, many times the nu,ber of electrons in the system.
Thanks for any help
Last edited by bandy on Mon Nov 06, 2006 1:31 am, edited 1 time in total.
-
- Full Member
- Posts: 201
- Joined: Thu Nov 02, 2006 4:35 pm
- License Nr.: 5-532
- Location: Ghent, Belgium
- Contact:
CHGCAR unit?
It contains the density times the Volume so you need to devide those values by the volume(in your case that is 1000A³)
VASP manual 2005-->CHGCAR file
Danny
<span class='smallblacktext'>[ Edited Mon Nov 06 2006, 09:49PM ]</span>
VASP manual 2005-->CHGCAR file
Danny
<span class='smallblacktext'>[ Edited Mon Nov 06 2006, 09:49PM ]</span>
Last edited by Danny on Mon Nov 06, 2006 8:46 pm, edited 1 time in total.
CHGCAR unit?
Hi Danny, Thanks.
But I am sorry still it is not clear to me.
charge density(r) * Vcell is CHGCAR. Then it is charge at position r i.e. charge(r). Then if I sum all charges at all r(all space over the 3D grid) I should get Total charge in the system. Am I not right?
But I am sorry still it is not clear to me.
charge density(r) * Vcell is CHGCAR. Then it is charge at position r i.e. charge(r). Then if I sum all charges at all r(all space over the 3D grid) I should get Total charge in the system. Am I not right?
Last edited by bandy on Tue Nov 07, 2006 12:34 am, edited 1 time in total.
-
- Full Member
- Posts: 201
- Joined: Thu Nov 02, 2006 4:35 pm
- License Nr.: 5-532
- Location: Ghent, Belgium
- Contact:
CHGCAR unit?
yes that should do the trick(unless I misinterpreted what the meant by Volume...if so please let me know)
Danny
Danny
Last edited by Danny on Tue Nov 07, 2006 9:49 am, edited 1 time in total.
-
- Full Member
- Posts: 201
- Joined: Thu Nov 02, 2006 4:35 pm
- License Nr.: 5-532
- Location: Ghent, Belgium
- Contact:
CHGCAR unit?
Ok i did a quick check on one of my calculations and it seems like what you get are actually the charges inside a gridcube of your system.
so in your case you have a total volume of 1000A^ 3 and 592704 gridpoints(or gridcubes) so each gridcube has a volume: 1.687e-3 A^3.
Multiplying the values of your charges with this you can sum them and find the total charge.
If you would write this out entirely you'll see that the volume the actually use seems to be the number of gridcells (ie: I misinterpreted) so the easy way of doing it is just divide the values you find in the CHGCAR file by the total number of gridpoints. Then you can sum over all of them and find the correct charge.
(If you want chargedensity in realspace(ie cubic Angstrom) you'll need to convert them)
Hmm I hope this was somewhat clear?
(I reread this post once more it isn't really clear)
Conclusion:
Vgrid=NGX*NGY*NGZ (ie the 3 integers you find above the set of "chargevalues" in CHGCAR)
in your case Vgrid=592704
Vreal=x*y*z (realspace volume in A³)
in your case Vreal=1000A³
If you want the exact chargedensity at a point:
--> divide the values of the CHGCAR file by Vreal.
the values you get should be in (e/A³)
integrating over your grid will give you the total charge inside your cell, be carefull this is not just summing over your gridpoints
If you want the exact charge at a point:
(ie: the charge in a gridcube)
---> divide the values of the CHGCAR by Vgrid.
If you sum these values over the entire grid you will get the total charge.
Danny
%-6
<span class='smallblacktext'>[ Edited Tue Nov 07 2006, 07:46PM ]</span>
so in your case you have a total volume of 1000A^ 3 and 592704 gridpoints(or gridcubes) so each gridcube has a volume: 1.687e-3 A^3.
Multiplying the values of your charges with this you can sum them and find the total charge.
If you would write this out entirely you'll see that the volume the actually use seems to be the number of gridcells (ie: I misinterpreted) so the easy way of doing it is just divide the values you find in the CHGCAR file by the total number of gridpoints. Then you can sum over all of them and find the correct charge.
(If you want chargedensity in realspace(ie cubic Angstrom) you'll need to convert them)
Hmm I hope this was somewhat clear?
(I reread this post once more it isn't really clear)
Conclusion:
Vgrid=NGX*NGY*NGZ (ie the 3 integers you find above the set of "chargevalues" in CHGCAR)
in your case Vgrid=592704
Vreal=x*y*z (realspace volume in A³)
in your case Vreal=1000A³
If you want the exact chargedensity at a point:
--> divide the values of the CHGCAR file by Vreal.
the values you get should be in (e/A³)
integrating over your grid will give you the total charge inside your cell, be carefull this is not just summing over your gridpoints
If you want the exact charge at a point:
(ie: the charge in a gridcube)
---> divide the values of the CHGCAR by Vgrid.
If you sum these values over the entire grid you will get the total charge.
Danny
%-6
<span class='smallblacktext'>[ Edited Tue Nov 07 2006, 07:46PM ]</span>
Last edited by Danny on Tue Nov 07, 2006 12:26 pm, edited 1 time in total.
CHGCAR unit?
Thanks Danny for your reply.
I am better in understanding about CHGCAR, but not fully.
According to you, elements chgcar(i,j,k), when
divided by Vreal, then integrated over all real space will give
total charge; similarly chgcar(i,j,k) elements divided by Vgrid and then summed to give total charge.
Would it be possible for anybody in the forum including Danny to send a complete simple example to my email address. indra1966in@yahoo.co.in
Thanks a lot,
I am better in understanding about CHGCAR, but not fully.
According to you, elements chgcar(i,j,k), when
divided by Vreal, then integrated over all real space will give
total charge; similarly chgcar(i,j,k) elements divided by Vgrid and then summed to give total charge.
Would it be possible for anybody in the forum including Danny to send a complete simple example to my email address. indra1966in@yahoo.co.in
Thanks a lot,
Last edited by bandy on Wed Nov 08, 2006 2:54 am, edited 1 time in total.
CHGCAR unit?
Hi Danny, I am willing to send complete CHGCAR file via email.
Would it be possibe to find total charge from that using your
utility program? Thanks alot
Would it be possibe to find total charge from that using your
utility program? Thanks alot
Last edited by bandy on Fri Nov 10, 2006 12:02 am, edited 1 time in total.
-
- Full Member
- Posts: 201
- Joined: Thu Nov 02, 2006 4:35 pm
- License Nr.: 5-532
- Location: Ghent, Belgium
- Contact:
CHGCAR unit?
As it is my code doesn't give you the entire charge(the best I can do is give you a contourplot of a specific plane of the planeaveraged valus along a line.
I do not know which programming language you use but if you want to calculate the total charge you could use following algo(some pseudo fortran)
this is a subroutine whish is very handy to get the total number of atoms without need for another file
this should give you the charge(should be the same as the number of (valence)electrons in your system)
let me know how it turns out (it should work on the CHGCAR you posted in the first post.
greetings
Danny
<span class='smallblacktext'>[ Edited Fri Nov 10 2006, 01:50AM ]</span>
I do not know which programming language you use but if you want to calculate the total charge you could use following algo(some pseudo fortran)
Code: Select all
integer :: nr,nrx,nry,nrz,maxx,maxy,maxz,maxatom
single ::totC, x,y,z, lx,ly,lz,vol,scale
character(len=255)Â ::Â line
single,allocatable ::CHgrid(:,:,:) ! dynamic 3D matrix
open(unit=100,file='CHGCAR',action='read')
read(10,*)str !reads title string
read(10,*)Â scaleÂ
read(10,*)Â x,y,z
lx= sqrt(x*x + y*y + z*z)
read(10,*)Â x,y,z
ly= sqrt(x*x + y*y + z*z)
read(10,*)Â x,y,z
lz= sqrt(x*x + y*y + z*z)
vol=lx*ly*lz*scale*scale*scale
read(10,'(A255)')str
getatmnr(str,maxatom) !subroutine to transform this string to 1 number
do nr=0,maxatom ! read the line with direct or cartesian + the list of atomcoordinates
    read(10,*)str
end do
! the next empty line does not exsist for FORTRAN, you need to check if it exsists if you use a different language --> eg PASCAL will probably find a line
read(10,*)Â maxx,maxy,maxz
totC=0.0
allocate(CHGrid(0:maxx,0:maxy,0:maxz))
read(10,*) (((CHGrid(nrx,nry,nrz),nrx=0,maxx-1),nry=0,maxy-1),nrz=0,maxz-1) !this reads the entire dataset of charges.
do nrx=0, maxx-1
   do nry=0,maxy-1
      do nrz=0,maxz-1
      totC=totC+CHgrid(nrx,nry,nrz)Â
     end do
   end do
end do
write(*,*) 'The volume of the cell is: ', Vol
write(*,*) 'The total chargedensity*Volume=', totC
write(*,*) 'The total charge=', totC/(maxx*maxy*maxz)
this is a subroutine whish is very handy to get the total number of atoms without need for another file
Code: Select all
subroutine get_atomnr(line,atomnr)Â
             character(len=255),intent(IN):: lineÂ
             integer,intent(OUT) ::atomnrÂ
 Â
       integer :: ios,nratoms,atnr,atnrposÂ
       character(len=255):: line2,atlÂ
 Â
       !a little bit more complex...read it as a line and sum till it crashesÂ
       ios=0Â
       nratoms=0Â
       line2=lineÂ
       do while (ios==0)Â
             read(line2,*,IOSTAT=ios) atnrÂ
             if (ios==0) thenÂ
                  nratoms=nratoms+atnrÂ
                  write(atl,*) atnrÂ
                  atl=ADJUSTL(atl)!remove leading blanksÂ
                  atnrpos=Index(line2,trim(atl))+len_trim(atl)Â
                  line2=" "Â
                  line2(atnrpos:255)=line(atnrpos:255)Â
                  if (len_trim(line2)<=0) thenÂ
                        ios=10Â
                  end ifÂ
             end ifÂ
       end doÂ
       atomnr=nratomsÂ
 Â
       end subroutineÂ
let me know how it turns out (it should work on the CHGCAR you posted in the first post.
greetings
Danny
<span class='smallblacktext'>[ Edited Fri Nov 10 2006, 01:50AM ]</span>
Last edited by Danny on Fri Nov 10, 2006 12:46 am, edited 1 time in total.
CHGCAR unit?
Danny, your code works perfectly fine for the CO molecule whose CHGCAR I gave here. Thanks a lot. This was ISPIN=1 case. Now I will check some ISPIN=2 cases and want to check alpha-beta CHGCAR part whether total charge comes out to be unpaired electrons i.e. N_e(alpha)-N_e(beta)=NUPDOWN. It works fine with ISPIN=2 cases too. Thanks.
Thanks a lot,
<span class='smallblacktext'>[ Edited Fri Nov 10 2006, 10:27AM ]</span>
Thanks a lot,
<span class='smallblacktext'>[ Edited Fri Nov 10 2006, 10:27AM ]</span>
Last edited by bandy on Fri Nov 10, 2006 5:31 am, edited 1 time in total.
-
- Full Member
- Posts: 201
- Joined: Thu Nov 02, 2006 4:35 pm
- License Nr.: 5-532
- Location: Ghent, Belgium
- Contact:
CHGCAR unit?
Glad to hear this
Last edited by Danny on Fri Nov 10, 2006 7:25 am, edited 1 time in total.
CHGCAR unit?
One more question. In some cases, I am getting say magnetization 2.71 for collinear calculation. How to explain this as magnetization (=n(alpha)-n(beta)) should be integers. Am I not right?
Last edited by bandy on Mon Nov 13, 2006 5:05 pm, edited 1 time in total.