Sunday, September 4, 2016

Extracting Frequency data from a Gaussian 09 calculation

This small awk script was inspired by the Python solution I found on this excellent blog [ Lindqvist - a blog about Linux and Science. Mostly. ] You can find my solution in the comments section of the blog.

So, I would like to extract/collect the results from a Gaussian09 harmonic frequency calculation.
Since collecting the rest of the data from the Gaussian output is pretty much identical I have done it anyway.

#!/bin/awk -f

/Frequencies/ { for (i=3;i<=NF; i++) { im++; freq[im ]=$i } }
/Frc consts/  { for (i=NF;i>=4; i--)     fc[im-(NF-i)]=$i   }
/IR Inten/    { for (i=NF;i>=4; i--)     ir[im-(NF-i)]=$i   }

END { for (i=1;i<=im;i++) print freq[i],fc[i],ir[i] }

This will print the collected values in three columns, identical to the Python script.

Wednesday, May 11, 2016

OCTAVE: read/write VASP POSCAR, CHGCAR

Here you can find several functions that will help you to read and write VASP POSCAR and CHCAR files in Octave. The files are commented and fairly easy to understand. Current version of the read_POSCAR handles the old and the new POSCAR  format (the new format contains labels for the species). All gathered information is stored in one object "Structure". This makes extremely easy the addition of any new properties. Note hat it read_CHGCAR reads only the total density. If you need the difference, please change the code or the data.

Test example:
#!/usr/bin/octave -q

# Read CHGCAR file
Struct = read_CHGCAR("CHGCAR");

# Print all gathered values
Struct

# Do something
# Struct.Dens=circshift(Struct.Dens,[0 0 20]);

# Write the new Density
write_CHGCAR("CHGCAR-new",Struct);

Thursday, April 21, 2016

VASP CHGCAR difference and 2D plane cut through it

This post content is a copy from my awk workshop "Case studies" section.

From time to time, I need to calculate electron charge difference that is tabulated on a regular 3D grid. Common examples in my field will be Gaussian .cube files or VASP CHGCAR files. One can find some scripts, tools and programs that can do this in one way or another. In my case, again, I need something slightly different and... Well, doing it with awk is so simple that I never use other tools but the one I will mention here. With small changes I am able to subtract 6 files at the same time, and since the files tend to be large, I keep them compressed.