grid2cube (and g2c_ng)

The original grid2cube and the new, more capable g2c_ng (for “grid2cube next generation”) convert grid-based files produced by Siesta (like .RHO, .DRHO, .LDOS, etc) into the .cube format originating in the Gaussian suite of programs, which can be read by tools such as Vesta and Ovito. This format contains both atomic coordinates and grid magnitudes (e.g. charge density), so the plots preserve the structural context.

We will focus on g2c_ng in this how-to. To use this tool you need a .STRUCT_OUT file with your system’s structure (usually a default output of SIESTA), and a file with the property calculated on the grid, the most common being a .RHO file or a .LDOS file.

Note

g2c_ng does not work with NetCDF files (.nc) yet.

Note

In principle, it is possible to use g2c_ng with any kind of grid-based SIESTA output: .DRHO, .VH, .VT., etc. See the manual for more information on these files.

The code itself can offer information about its interface:

terminal>  g2c_ng -h

 Usage: g2c_ng [-dht] [-n NSKIP]  -s STRUCT_FILE -g GRIDFILE
-n NSKIP : stride in file
-t : translate coordinates to [0,1)
-x : supercell factor along 1st lattice vector
-y : supercell factor along 2nd lattice vector
-z : supercell factor along 3rd lattice vector
-t : translate coordinates to [0,1)
-d : debug
  • The stride refers to the ability to use only a fraction of points in the file. A NSKIP value of 2 will use ony every other point.

  • The supercell factors enable to use mutiples of the unit cell for better visualization.

  • The “-t” option might not do anything in common cases.

  • The grid file should be, for example, SystemLabel.RHO

  • The STRUCT_FILE should be, for example, SystemLabel.STRUCT_OUT

The output will be written to a .cube file with name “Grid.cube” (it is advisable to rename it to something more meaningful). In the case of spin, four files are produced, with both spins individually, and the sum and difference, with names such as Up-Down.cube.