Page 1 of 1
how to plot the spin polarized charge density
Posted: Tue Sep 30, 2008 8:59 am
by ktao
Dear all,
Now I have a spin polarized CHGCAR. I want to plot the charge density of the minority part of the system. Could you give me some suggestion? Any comments would be appreciated.
how to plot the spin polarized charge density
Posted: Tue Sep 30, 2008 11:36 am
by forsdan
The total electron density (n_up + n_down) together with the spin density (n_up - n_down) are written to the CHGCAR. So what you can do is to write a short script that extracts the data for both densities and then solve for the minority part.
Also take a look on Danny's reply under:
http://cms.mpi.univie.ac.at/vasp-forum/ ... php?4.3865
Best regards
/Dan
how to plot the spin polarized charge density
Posted: Wed Dec 09, 2009 5:53 am
by opiskelija
I have read the reference page Forsdan gave. However I still do not understand what each of the 5 columns in my spin-polarized CHGCAR means.
CHGCAR
----------------------------------------------
(atomic coordinates)
192 224 112
192 224 112
.12542222513E+05 .12213572381E+05 .11298386482E+05 .99763507522E+04 .84629759086E+04
.69366683044E+04 .55043910496E+04 .42140592276E+04 .30916561151E+04 .21692365805E+04
.14821362350E+04 .10409059658E+04 .80534617144E+03 .68642090177E+03 .60010389775E+03
.53117179024E+03 .47509541801E+03 .42780548751E+03 .38723828847E+03 .35338109943E+03
and so on.
-----------------------------------------------------------------------
It is said that the first 3 columns are the xyz coordinates, but that seems highly unlikely. In addition, the last two columns should be (up+down) and (up-down) density, but they are too similar!
Moreover, they are even negative sometimes.
-----------------------------------------------------------------
.83381916774E-02 .70080672785E-02 .57031021424E-02 .29671948525E-02 -.22348724298E-02
-.99440048147E-02 -.19170029961E-01 -.28343486293E-01 -.35960803345E-01 -.41116494947E-01
-.43760714333E-01 -.44664180455E-01 -.45139094350E-01 -.46593663890E-01 -.50047799650E-01
-.55788268741E-01 -.63311428748E-01 -.71558593652E-01 -.79283147982E-01 -.85346826640E-01
-.88876159170E-01 -.89392545553E-01 -.87056677573E-01 -.82968370189E-01 -.79210796015E-01
-.78316696564E-01 -.82189608432E-01 -.91015853313E-01 -.10291812018E+00 -.11474812271E+00
----------------------------------------------------------------------
Does my calculation have a serious problem or something? What should I do to plot the charge density for each spin? Any comments would be appreciated.
how to plot the spin polarized charge density
Posted: Sun Dec 27, 2009 8:04 pm
by metosa
copy below script to your bin directory, make it executable, run script by typing "script CHGCAR" and visualize the CHGCAR-u-d by VESTA.
#!/usr/bin/env bash
filename=`echo $1 | sed 's/PARCHG./CHGCAR-/' | sed 's/.ALLK//'`
rastgele=$RANDOM
natoms=`awk "NR==6" $1 | awk '{print ($1+$2+$3+$4+$5+$6+$7+$8+$9)}'`
ngrid=`mm $natoms+9`
grid=`awk "NR==$ngrid" $1`
nupd_b=`echo $ngrid | awk '{print ($1+1)}'`
nupd_e=`grep -n "$grid" $1 | awk "NR==2" | awk -F ":" '{print $1}'`
awk "NR<$nupd_b" $1 > title.$rastgele
cat title.$rastgele > $filename-u-d.$rastgele ; awk "NR>$nupd_e" $1 >> $filename-u-d.$rastgele
awk "NR>=$nupd_b" $filename-u-d.$rastgele > u-d1.$rastgele ; awk "NF==10" u-d1.$rastgele > u-d.$rastgele
mv $filename-u-d.$rastgele $filename-u-d
rm -rf *.$rastgele
how to plot the spin polarized charge density
Posted: Sun Dec 27, 2009 8:12 pm
by metosa
sorry, you should replace
ngrid=`mm $natoms+9`
line
with
ngrid=`let ngrid=$natoms+9 : echo $ngrid`
how to plot the spin polarized charge density
Posted: Sun Dec 27, 2009 8:13 pm
by metosa
sorry x 2 ;
ngrid=`let ngrid=$natoms+9 : echo $ngrid`
should be
ngrid=`let ngrid=$natoms+9 ; echo $ngrid`
how to plot the spin polarized charge density
Posted: Thu Dec 31, 2009 4:29 am
by panda
You could also use vmd, it's a free viewer and you can visualize CHGCAR there
http://www.ks.uiuc.edu/Research/vmd/
Although in the case of spin polarization I am not sure if it will help you at all, you can select spin up or spin down components for plotting, but writing your own script for plotting does always allow for the most flexibility in all cases.