Thursday, March 2, 2017

Exchange to IMAP Gateway

I am one of this users that is still using client mail like Thunderbird. Do not get me wrong, I use and like Gmail, but I still need more control over my mail in few cases. Anyway, from time to time the University Exchange server is updated/reconfigured and I loose access to the provided IMAP access. Since this became recurrent event and the suggested solutions from the support team were somewhat random guesses I looked for alternative solution.

Here is what I am using right now, while I can not access my mail box after the last upgrade.


Saturday, January 14, 2017

Discrete histogram

The usual histogram is a graphical representation of the distribution of numerical data. It also implies that you have regular intervals for the resulting distribution. What happens if you are looking for distribution over discrete elements, like day of the week, month, or any possible word...

Here is an example.
  • How many coins are gold or silver?
  • How many coins from each country we have?
  • ... year?
   gold     1    1986  USA                 American Eagle
   gold     1    1908  Austria-Hungary     Franz Josef 100 Korona
   silver  10    1981  USA                 ingot
   gold     1    1984  Switzerland         ingot
   gold     1    1979  RSA                 Krugerrand
   gold     0.5  1981  RSA                 Krugerrand
   gold     0.1  1986  PRC                 Panda
   silver   1    1986  USA                 Liberty dollar
   gold     0.25 1986  USA                 Liberty 5-dollar piece
   silver   0.5  1986  USA                 Liberty 50-cent piece
   silver   1    1987  USA                 Constitution dollar
   gold     0.25 1987  USA                 Constitution 5-dollar piece
   gold     1    1988  Canada              Maple Leaf

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.