Author Topic: Gaussian Cube Files  (Read 14461 times)

0 Members and 1 Guest are viewing this topic.

Offline davalenciah

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Reputation: 0
    • View Profile
Gaussian Cube Files
« on: September 26, 2011, 18:10 »
Hello,

I am interested in to know the effective potential for a simple configuration
and I exported my data to a grid file ( The grid is written as a Gaussian Cube File              |
 (http://local.wasp.uwa.edu.au/~pbourke/dataformats/cube))
but it is not clear for me how the grid data  is arranged?

can someone suggest me a tutorial to this topic
or explain  me how the data is arranged 


Thanks  ???


Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: Gaussian Cube Files
« Reply #1 on: September 26, 2011, 21:35 »
In a sense it's hard to explain it better than the link you provided :) But I guess a concrete example would be illustrative. Let us assume our data takes values f(x,y,z) = x+y+z, and we have a grid of 5x5x5 values, positioned at x=(1,2,3,4,5), y=(10,20,30,40,50), z=(100,200,300,400,500), then the Cube file header will look like this:
Code
CUBE FILE.
OUTER LOOP: X, MIDDLE LOOP: Y, INNER LOOP: Z
    0    1.000000    10.00000    100.0000
    5    1.000000    0.000000    0.000000
    5    0.000000    10.00000    0.000000
    5    0.000000    0.000000    100.0000
This indicates that we have an origin at (1,10,100) (the first point) and the spacing between points in X is 1, in Y it is 10, and in Z it is 100. (The zero on the 3rd line is the number of atoms, we don't use that feature in our Cube files.) (I cannot guarantee this file format is 100.0% correct with respect to columns and whitespace, I don't know how sensitive Cube file readers are regarding that, or if it's mandated by the format that you must have the data with a certain number of decimals etc.) Next comes the data. With our carefully designed data set it becomes easy to see how the points are arranged ;)
Code
111 211 311 411 511
121 221 321 421 521
131 231 331 431 531
141 241 341 441 541
151 251 351 451 551
112 212 312 412 512
122 222 322 422 522
132 232 332 432 532
142 242 342 442 542
152 252 352 452 552
113 213 313 413 513
...
In a real cube file you will for sure see scientific notation (%e) like 1.00000e+02 instead of the %g format (100) used here. The line breaks are not too important, but can be inserted after 5 or 6 columns to not get too wide lines (normally you want to keep it within 80 characters, for historical reasons). In the example above I have made line breaks each time the Y coordinate changes, for clarity. The algorithm (which is described in detail at the page you linked to) is that we pick the first X point, the first Y point, then loop over Z, then the next Y point (still first X point), loop over Z, then next Y point until no more, then next X point, and loop over Y (and over Z for each Y) again.

Offline davalenciah

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Reputation: 0
    • View Profile
Re: Gaussian Cube Files
« Reply #2 on: September 26, 2011, 22:14 »
  In my specif case I got a cube file with the header
 
     0 0.000000e+00 0.000000e+00 0.000000e+00
   17 2.369151e-01 1.367830e-01 0.000000e+00
   17 2.369151e-01-1.367830e-01 0.000000e+00
  132 0.000000e+00 0.000000e+00 2.863223e-01

-4.80474e-01 -4.72573e-01 -4.51097e-01 -4.19110e-01 -3.80846e-01 -3.40833e-01 .......

It means that the effective potential should be the  other lines.
In that way,  the  first values are the potential in (0.0,0)
and x will be increase 2.369151e-01,  Y  1.367830e-01 and
Z 2.863223e-01. in that way the second term  points will be the effective potential in which point?


Thanks

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: Gaussian Cube Files
« Reply #3 on: September 26, 2011, 23:27 »
It might be easiest to reverse engineer the x,y,z values. If I may make a dummy file instead, with header
Code
   0 0.0 0.0 0.0
   5 0.2 0.1 0.0
   5 0.2 -0.1 0.0
  12 0.0 0.0 0.3
then we have 12 data points with x = 0.0, y = 0.0, z = 0, 0.3, 0.6, ... Then 12 data points with x = 0.2, y = -0.1, z = 0, 0.3, 0.6, ... Then 12 data points with x = 0.4, y = -0.2, z = 0, 0.3, 0.6, ... and so on (increasing x by 0.2 and y by -0.1 for each block of 12) After 60 data points, we move to x = 0.2, y = 0.1, z = 0, 0.3, 0.6, ... (12 points) x = 0.4, y = 0.0, z = 0, 0.3, 0.6, ... (12 points) x = 0.6, y = -0.1, z = 0, 0.3, 0.6, ... (12 points) and so on (again increasing x by 0.2 and y by -0.1 for each block of 12) After another 60 data points, we move to x = 0.4, y = 0.2, z = 0, 0.3, 0.6, ... (12 points) x = 0.6, y = 0.1, z = 0, 0.3, 0.6, ... (12 points) x = 0.8, y = 0.0, z = 0, 0.3, 0.6, ... (12 points) and so on. I have attached 2 codes, one which prints the x,y,z coordinates for the points in my dummy example (cube_rev_eng_1.py), and another which does it for your header (cube_rev_eng_2.py). WARNING: the second code generates a lot of output, you will want to pipe the output to a file! Finally, I attach a general tool (cube_rev_eng.py) which can read a general Cube file (well, at least those produced by ATK) and print the values in the following format: X Y Z value Again, this generates a lot of output!
« Last Edit: September 26, 2011, 23:34 by Anders Blom »

Offline davalenciah

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Reputation: 0
    • View Profile
Re: Gaussian Cube Files
« Reply #4 on: September 27, 2011, 22:26 »
Thanks for your answer, now I understand better
how is arranged the Gaussian cube file, however
I tried to use the file cube_rev_eng.py to convert my cube file
into a x,y,z file, but it does not work.
I attached my cube file produced by ATK
 ;D ;D ;D

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: Gaussian Cube Files
« Reply #5 on: September 28, 2011, 09:42 »
It works fine for me...

atkpython cube_rev_eng.py GS.dat > datafile


Offline davalenciah

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Reputation: 0
    • View Profile
Re: Gaussian Cube Files
« Reply #6 on: September 12, 2012, 22:04 »
Hello

I am using the script posted here for a bloch function in a silicon structure  getting in atk 12.2.2 (bloch.cubeR.dat)
and I got this result.  Do you know what I have to change in the script to get the xyz arrange?

Thank you

+------------------------------------------------------------------------------+
|                                                                              |
| Atomistix ToolKit 12.2.2 [Build 144eba5]                                     |
|                                                                              |
+------------------------------------------------------------------------------+
Traceback (most recent call last):
  File "cube_rev_eng.py", line 25, in <module>
    header_data[0].append(int(line[0:5].strip()))
ValueError: invalid literal for int() with base 10: ''[/font][/glow]

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5429
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: Gaussian Cube Files
« Reply #7 on: September 13, 2012, 01:35 »
It looks like your file has been edited since exported from ATK (blank lines have been added). This may have been accidental as part of a file transfer or conversion from DOS to Unix format. (If not, you may want to report it separately.) The CUBE file format is rather strict, and so the script assumes that the file format is exactly obeyed.

So, the solution is to remove the extra blank lines at the top.

I also revised the script to be more tolerant to such things (and which may fix an unrelated bug in the original script too).

Offline davalenciah

  • Heavy QuantumATK user
  • ***
  • Posts: 26
  • Reputation: 0
    • View Profile
Re: Gaussian Cube Files
« Reply #8 on: September 13, 2012, 01:45 »
It worked pretty well

Thank you Anders ;D ;D

Offline krishn

  • New QuantumATK user
  • *
  • Posts: 1
  • Country: in
  • Reputation: 0
    • View Profile
Re: Gaussian Cube Files
« Reply #9 on: December 18, 2015, 13:10 »
Dear Sir,

Once I get the "X Y Z  data value" file
How can i draw the charge density in matlab?