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);