Page 1 of 2

Visualize the Wavefunction

Posted: Mon Aug 17, 2009 10:03 am
by okuno
Dear Vasp Users.

I want to visualize calculated wave function, for example, the
lowest state of conduction band, or the highest state of valence
band.

Are there any 3D viewers suitable for VASP ?

Sincerely.

Visualize the Wavefunction

Posted: Mon Oct 12, 2009 3:03 pm
by admin
sorry, we have no plotting utilities for the wavefunction

Visualize the Wavefunction

Posted: Mon Nov 09, 2009 5:07 am
by panda
You can parse the binary WAVECAR file knowing the DFT mesh and then format for a viewer like XCRYSDEN, this could give you the Fermi Surface, which would tell you the 3D band structure information. I am working on a script to automate this in python, if I have any success I will be happy to show you how to do this.

Visualize the Wavefunction

Posted: Mon Nov 09, 2009 11:44 am
by asija
panda - it would be grate. Where can I find your script if you make it?

I'm not sure what exactly you mean by "3D band structure", it is already stored in eigenvalues for each k-point, or not?

I'd like just simple real-space projection of molecular orbitals for simple molecules. May be just gamma k-point is enought.

Visualize the Wavefunction

Posted: Mon Nov 09, 2009 4:11 pm
by panda
well "3D band structure" would actually be from the charge density, and the wave function could be mapped onto that surface. I have been meaning to set up a blog with some utilities but have been really busy lately. I have not completed this task by any means though, only a small portion.

Visualize the Wavefunction

Posted: Wed Nov 11, 2009 1:59 am
by panda
OK, here is a start. I used python. You can perform some simple pack/unpack statements at the python interactive shell to get an idea of how to read a binary file. You can also google "python parsing binary file" and tons of hits will come up.

Something like this:

#!/usr/bin/python

import sys
from struct import unpack, pack

f = open('/path/to/WAVECAR/file, 'rb')
line = f.read()

Then you could do something like this to unpack the values:

for i in [j for j in r if j % 4 == 0 and j + 4 <= len(line)]:
print i

val = unpack('f', line[i:i+4])
val = val[0]

After that its up to you, specify your mesh, put it into a matrix, plot it, and away you go. OK, maybe not THAT simple, but at least this gives you some idea.

Disclaimer: **This is by no means a completed script and is meant only to serve as an example. Python formatting may not be correct :D

Visualize the Wavefunction

Posted: Thu Nov 12, 2009 1:21 am
by okuno
Dear panda.

Thank you for reply.

If you made a python script for plotting WAVECAR file by
XCrysden, can you open the scripts for vasp users ?

Sincerely.

Visualize the Wavefunction

Posted: Thu Nov 12, 2009 10:25 pm
by panda
I will use it actually for calculating partially occupied Wannier Functions, and was planning on using matplotlib for plotting, but we can easily write a conversion utility for XCrysDen format. I will work on putting together a blog this weekend with the source code. Do you use python also? I am just now also learning Erlang and so plan to do more with it in the future, but so many nice utilities already exist for math and science in python.

Visualize the Wavefunction

Posted: Tue May 24, 2011 6:42 pm
by cmuhich
Hi Everyone,

this looks like it could be a great help to a lot of people, Panda did you ever get the script working?

Thanks
Chris

Visualize the Wavefunction

Posted: Tue Aug 16, 2011 10:38 pm
by tomic
I don't want to open the new thread so I'll ask my questions here.

I am trying to parse the WAVECAR file, and by unpacking every 8 bytes to double precision floats I was able to to cast WAVECAR contents into a large array of floating point data.

Now I have a problem of parsing it. Usually, when WAVECAR is broken up, I would have large chunks of data, separated by large blocks of 0s and it is then not hard to parse it since for every k-point and every band, block holding corresponding wavefunction coefficients is between blocks of zeros, but sometimes it happens that blocks holding coefficients for different bands gets merged together, and the size of the block is larger then number_of_plane_waves(k) x number_of_bands(k) so I don't have simple way to separate them out.

Can anyone help me with this?

Thanks

Visualize the Wavefunction

Posted: Wed Aug 17, 2011 6:21 pm
by tomic
OK, I think I've figured out the structure so far. First 8 bytes specify the length of the record and record length is equal to the maximum number of plane waves for a k-point, as specified in the OUTCAR file. Though, what is puzzling is that first eight bytes are not long integers, as one would expect for size, but are double floats.

If I break WAVECAR into records I get some bytes at the end of the file as a remainder. Do those mean something, or I assume wrongly that WAVECAR is evenly broken up into records of same length?

Thanks
<span class='smallblacktext'>[ Edited Wed Aug 17 2011, 06:23PM ]</span>

Visualize the Wavefunction

Posted: Wed Aug 31, 2011 4:36 pm
by admin
just to remind you: WAVECAR gives the wave function COEFFICIENTS, not the wavefunctions

Visualize the Wavefunction

Posted: Thu Sep 01, 2011 6:53 pm
by panda
yes, but if you get the coefficients of the wavefunction (C1, C2, etc.) then you can use those to calculate the Wannier functions, right?... correct me if I am wrong please, but this is what I thought you could do. However, I don't really understand the structure of the WAVECAR and where to parse to find the coefficients. I have the same problem as tomic - I can get the binary data into an array, but because I don't know the format of the file I don't know what to do with the data. Admin, could you shed some light on this please?

Visualize the Wavefunction

Posted: Thu Jul 05, 2012 9:17 pm
by widom
Tools for reading and evaluating wavefunctions have been posted on the web at http://www.andrew.cmu.edu/user/feenstra/wavetrans/
Documentation at this site describes the format of the binary WAVECAR file. A Fortran program is given to read the WAVECAR and write a text file containing the wavefunction coefficients and their associated basis functions. An alternative program shows how to extract a specific wavefunction and evaluate it in real space.

Visualize the Wavefunction

Posted: Mon Mar 18, 2013 3:51 pm
by xcid
[quote="panda"]You can parse the binary WAVECAR file knowing the DFT mesh and then format for a viewer like XCRYSDEN, this could give you the Fermi Surface, which would tell you the 3D band structure information. I am working on a script to automate this in python, if I have any success I will be happy to show you how to do this. [/quote]
I want to draw fermi surface within VASP. Could you help me with the script.