using chgdiff.pl

Vasp transition state theory tools

Moderator: moderators

Post Reply
rafter
Posts: 2
Joined: Tue Sep 02, 2008 9:16 pm

using chgdiff.pl

Post by rafter »

I would like to calculate chg diff in (PtCo_slab+1 water)-(PtCo_slab)-(1 water). I'm not sure if I can use chgdiff when number of atoms in 2 chgcar are different? Thank you.
graeme
Site Admin
Posts: 2256
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: using chgdiff.pl

Post by graeme »

Oh, there may be a problem with the atomic coordinates, but maybe not. In the worst case, you can modify the header with the atomic coordinates so that they are the same in both files. But it also might just work as is. Perhaps you could let us know - if there is a problem, I'm sure it would not be too hard to change the script so it works.
Phani Kanth
Posts: 7
Joined: Fri May 28, 2010 10:28 am

Re: using chgdiff.pl

Post by Phani Kanth »

Hi,

I too have the same question. One more addition to that. If the KPOINTS are different, though atomic coordinates are same, will it work?

Could you please post, what happened when different atomic coordinates are taken for both files generation?

Thanks and Regards,
Phani Kanth
Phani Kanth
Posts: 7
Joined: Fri May 28, 2010 10:28 am

Re: using chgdiff.pl

Post by Phani Kanth »

Hi,

I have done calculations for LiCoO2 - CoO2 system (which is a layered hexagonal system with R-3m space group). If I need to see the charge transfer from Li to Co and O when lithium is inserted into CoO2 structure (i.e., difference in CHGCAR files of both compounds), the chgdiff.pl code works without any problem, when I calculated CHGCAR for CoO2 from SCF calculation after removing the Lithium atoms from optimized LiCoO2 structure. I mean to say that the cell size should be same, but the number of atoms and kpoints can be different in both cases, for chgdiff.pl to work.
However, the syntax should be like this:
chgdiff.pl CoO2-CHGCAR LiCoO2-CHGCAR (i.e. the ordering of CHGCAR files matter, I don't understand why?)

So, in your case chgdiff.pl might work with the following steps, but I am not sure, If it can provide a meaningful result all times:
1. Calculate the optimized geometry for PtCo-slab+Water and get the CHGCAR file called as CHGCAR1
2. Remove water coordinates (i.e. water molecule) from the above optimized geometry and just do SCF calculation but not relaxation (because relaxation changes cell size and then CHGCARs cannot be compared with chgdiff.pl) and get the CHGCAR file called as CHGCAR2
3. Then CHGCAR_diff can be obtained with the following command line: chgdiff.pl CHGCAR2 CHGCAR1

Please post, if that kind of charge difference calculation is meaningful at least to some extent.

Thanks and Regards,
Phani Kanth
graeme
Site Admin
Posts: 2256
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: using chgdiff.pl

Post by graeme »

That sounds reasonable. You might also want to add the charge density for a single Li atom at the relaxed position in LiCoO2 to the CoO2 CHGCAR. Then, if you take the difference with the LiCoO2 CHGCAR, you can see how the charge of a Li atom relaxes in the CoO2 crystal.

You can also use the Bader charge analysis to quantify where the charge is partitioned in the system.
Phani Kanth
Posts: 7
Joined: Fri May 28, 2010 10:28 am

Re: using chgdiff.pl

Post by Phani Kanth »

Dear Sir,

Thanks for suggestions.

Could you please tell me, if it is sufficient to relax a single atom of Li (with ISIF=2 ) in a large box where the influence of periodic images are nullified and then get that CHGCAR file? In LiCoO2-CoO2 system, we have 3 formula units in Unit Cell. So.. would it be fine to repeat this CHG density data three times in the CHGCAR file of CoO2 system, where original Li atoms are relaxed in LiCoO2?

However, I am not clear about adding CHG densities of this isolated Li atom to CHGCAR file of CoO2.

In my case, it might be easier to add CHG densities at the beginning of the file, since Li atoms are located in the first position in POSCAR file. But.. what if they are somewhere in between (other atoms)?
I mean.. how to distinguish the charge density or distribution at different coordinates in CHGCAR file? I am not able to find a link to the CHG densities and atomic coordinates in CHGCAR file.
( I see here the ordering/positioning of atoms is important while adding CHG densities, if we subsequently want to use chgdiff.pl for (Li-isolated)CoO2 and LiCoO2. )

Thanks and Regards,
Phani Kanth
imcnab
Posts: 14
Joined: Sat Jul 24, 2010 4:15 pm

PROBLEMS with chgdiff.pl and chgsum.pl

Post by imcnab »

Dear All,

I have recently encountered some strange results using chgdiff.pl and chgsum.pl, as follows.

I am trying to subtract TWO parts from a whole in this way:

CHGCAR_total - CHGCAR_surface - CHGCAR_molecule.

I have done this as follows
chgdiff.pl CHGCAR_total CHGCAR_surface
mv CHGCAR_diff CHGCAR_total-surface
chgdiff.pl CHGCAR_total-surface CHGCAR_molecule
mv CHGCAR_diff CHGCAR_total-surface-molecule

I then viewed the output file in VMD (with VASP plugins), the output looked totally different from that produced using OPENDX, which subtracts the densities within the program.

(2) I then attempted the same manipulations using the script chgsum.pl with factors 1.0 and -1.0.
I thought this would give the same output as chgdiff.
In fact the outputs differ considerably. The output generated with chgsum appear STRIPEY, as if viewed through a venetian blind, but still very different
from that created with OPENDX.

(3) I wrote a 20 line fortran program to do the subtraction, and used it in the same way as above, this time the output viewed in VMD agrees exactly
with the output viewed from OPENDX.

Incidentally, the OPENDX /my fortran program output appears to agree more understandably with the results of a BADER charge analysis which was made using your plugins for VASP.

Are there known problems with chgdiff.pl and chgsum.pl ?
Am I the first to notice these problems ?
Is it possible that my CHGCARs are pathological in some way ?

I have tested the two scripts on both a linux platform, and under windows XP x64 using Active_Perl for windows xp x64.
I get the same strange results on both platforms.

Perhaps I am using the scripts incorrectly ?

All help would be most gratefully received.

thanks for your time (and for the scripts, which are wonderful, and have saved me weeks of effort),
best regards... Iain
graeme
Site Admin
Posts: 2256
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: using chgdiff.pl

Post by graeme »

We clearly need to track down this problem. Can you try a quick test and see if the problem resolves when you use the chgsumf.pl script instead of the chgsum.pl?

In some files with very large (or small, maybe) charge densities, the fortran formatted numbers which are 5E18.11 can overflow their space and run into the previous number. With the normal chgsum.pl, the two entries are interpreted as a single number. This could give rise to the striped effect because the entries become out of place between lines. In the chgsumf.pl script, a library which reads with proper fortran formatting is used. It is slower, but it should correct the problem that I mentioned.

And if it is something else, we would like to see the files to help debug the problem and fix the scripts.

Thanks for the note!
imcnab
Posts: 14
Joined: Sat Jul 24, 2010 4:15 pm

Re: using chgdiff.pl

Post by imcnab »

Hi, Graeme,
Thanks for the swift response.
I have significant good news. I downloaded the current version of the scripts and tried again.

chgdiff still appears to give an incorrect charge difference after two operations,
However,
chgsum with factors 1/-1 or 1.0/-1.0 gives the correct answer (different from chgdiff) - I cannot now reproduce the tiger stripes of my previous attempts - I don't know if this has been updated recently, or something else has changed on my system.

I tried chgsumf.pl but the output was unreadable by VMD. When I looked, many of the lines in the resulting output file contained fewer than five numbers.

If you want to trouble-shoot chgdiff, then the best I can do is to send you the CHGCARs, together with the difference files produced by chgdiff and chgsum, so that you can see the difference. Sorry that I can't be much help, but I don't speak fluent perl, I can barely understand simple conversation.

These files will be big, even when zipped.
How can I best get these to you?

best regards... Iain
graeme
Site Admin
Posts: 2256
Joined: Tue Apr 26, 2005 4:25 am
Contact:

Re: using chgdiff.pl

Post by graeme »

Yes, we would like to take a look. You should be able to upload a zipped CHGCAR as an attachment on this forum.
imcnab
Posts: 14
Joined: Sat Jul 24, 2010 4:15 pm

Re: using chgdiff.pl

Post by imcnab »

Dear Graeme,
sorry for the long delay. I am not having much success uploading my files to this site. My zipped chgcar's are 37 Mb. I am now trying to upload them one at a time. This is the first file.
Attachments
CHGCAR_2mol.rar
(36 MiB) Downloaded 1200 times
imcnab
Posts: 14
Joined: Sat Jul 24, 2010 4:15 pm

Re: using chgdiff.pl

Post by imcnab »

That worked, now the next file(s) as possible:
Attachments
CHGCAR_t-s-2m_chgdiff.rar
total - surface - two_molecules, created using chgdiff.pl
(36.99 MiB) Downloaded 1273 times
CHGCAR_total.rar
(33.82 MiB) Downloaded 1284 times
CHGCAR_surf.rar
(32.77 MiB) Downloaded 1277 times
imcnab
Posts: 14
Joined: Sat Jul 24, 2010 4:15 pm

Re: using chgdiff.pl

Post by imcnab »

And here is the last file:

Hope this is some interest,
thanks again for your time and for the scripts, which we do greatly appreciate.
best regards... Iain
Attachments
CHGCAR_t-s-2m_chgsum_1.0_-1.0.rar
as before, created using chgsum with factors 1.0 and -1.0 (using integers 1 and -1 gives same result)
(36.57 MiB) Downloaded 1353 times
Post Reply