Tutorial:Visualization
In this tutorial we will explain how to visualize outputs from Octopus. Several different file formats are available in Octopus that are suitable for a variety of visualization software. We will not cover all of them here. See Manual:Visualization for more information.
Benzene molecule
As an example, we will use the benzene molecule. At this point, the input should be quite familiar to you:
CalculationMode
= gsUnitsOutput
= eV_AngstromRadius
= 5*angstromSpacing
= 0.15*angstromOutput
= wfs + density + elf + potentialOutputFormat
= cube + xcrysden + dx + axis_x + plane_zXYZCoordinates
= "benzene.xyz"
Coordinates are in this case given in the benzene.xyz file. This file should look like:
12 Geometry of benzene (in Angstrom) C 0.000 1.396 0.000 C 1.209 0.698 0.000 C 1.209 0.698 0.000 C 0.000 1.396 0.000 C 1.209 0.698 0.000 C 1.209 0.698 0.000 H 0.000 2.479 0.000 H 2.147 1.240 0.000 H 2.147 1.240 0.000 H 0.000 2.479 0.000 H 2.147 1.240 0.000 H 2.147 1.240 0.000
Here we have used two new input variables:

Output
: this tells Octopus what quantities to output. 
OutputFormat
: specifies the format of the output files.
In this case we ask Octopus to output the wavefunctions (wfs), the density, the electron localization function (elf) and the KohnSham potential. We ask Octopus to generate this output in several formats, that are requires for the different visualization tools that we mention below. If you want to save some disk space you can just keep the option that corresponds to the program you will use. Take a look at the documentation on variables Output
and OutputFormat
for the full list of possible quantities to output and formats to visualize them in.
If you now run Octopus with this input file, you should get the following files in the static directory:
%ls static convergence forces vh.z=0 wfst0001.cube wfst0003.dx wfst0005.xsf wfst0007.y=0,z=0 wfst0009.z=0 wfst0012.cube wfst0014.dx density.cube info vks.cube wfst0001.dx wfst0003.xsf wfst0005.y=0,z=0 wfst0007.z=0 wfst0010.cube wfst0012.dx wfst0014.xsf density.dx v0.cube vks.dx wfst0001.xsf wfst0003.y=0,z=0 wfst0005.z=0 wfst0008.cube wfst0010.dx wfst0012.xsf wfst0014.y=0,z=0 density.xsf v0.dx vks.xsf wfst0001.y=0,z=0 wfst0003.z=0 wfst0006.cube wfst0008.dx wfst0010.xsf wfst0012.y=0,z=0 wfst0014.z=0 density.y=0,z=0 v0.xsf vks.y=0,z=0 wfst0001.z=0 wfst0004.cube wfst0006.dx wfst0008.xsf wfst0010.y=0,z=0 wfst0012.z=0 wfst0015.cube density.z=0 v0.y=0,z=0 vks.z=0 wfst0002.cube wfst0004.dx wfst0006.xsf wfst0008.y=0,z=0 wfst0010.z=0 wfst0013.cube wfst0015.dx elf_rs.cube v0.z=0 vxc.cube wfst0002.dx wfst0004.xsf wfst0006.y=0,z=0 wfst0008.z=0 wfst0011.cube wfst0013.dx wfst0015.xsf elf_rs.dx vh.cube vxc.dx wfst0002.xsf wfst0004.y=0,z=0 wfst0006.z=0 wfst0009.cube wfst0011.dx wfst0013.xsf wfst0015.y=0,z=0 elf_rs.xsf vh.dx vxc.xsf wfst0002.y=0,z=0 wfst0004.z=0 wfst0007.cube wfst0009.dx wfst0011.xsf wfst0013.y=0,z=0 wfst0015.z=0 elf_rs.y=0,z=0 vh.xsf vxc.y=0,z=0 wfst0002.z=0 wfst0005.cube wfst0007.dx wfst0009.xsf wfst0011.y=0,z=0 wfst0013.z=0 elf_rs.z=0 vh.y=0,z=0 vxc.z=0 wfst0003.cube wfst0005.dx wfst0007.xsf wfst0009.y=0,z=0 wfst0011.z=0 wfst0014.cube
Visualization
Gnuplot
Visualization of the fields in 3dimensions is complicated. In many cases it is more useful to plot part of the data, for example the values of a scalar field along a line of plane that can be displayed as a 1D or 2D plot.
The gnuplot program is very useful for making these types of plots (and many more) and can directly read Octopus output. First type gnuplot to enter the program's command line. Now to plot a the density along a line (the X axis in this case) type
plot "static/density.y=0,z=0" w l
To plot a 2D field, for example the density in the plane z=0, you can use the command
splot "static/density.z=0" w l
If you want to get a color scale for the values of the field use "w pm3d" instead of "w l".
VisIt
The program VisIt is an opensource data visualizer developed by Lawrence Livermore National Laborartory. It supports multiple platforms including Linux, OS X and Windows, most likely you can download a precompiled version for your platform here.
For this tutorial you need to have Visit installed and running. VisIt can read several formats, the most convenient for Octopus data is the cube format: OutputFormat
= cube. This is a common format that can be read by several visualization and analysis programs, it has the advantage that includes both the requested scalar field and the geometry in the same file. Visit can also read other formats that Octopus can generate like xyz, XSF (partial support), and VTK.
The following video contains the instruction on how to open a cube file in VisIt. Note that the video has subtitles in case you don't have audio in your current location, you can enable them by clicking the "CC" button.
XCrySDen
Atomic coordinates (finite or periodic), forces, and functions on a grid can be plotted with the free program XCrySDen. Its XSF format also can be read by V_Sim and Vesta. Beware, these all probably assume that your output is in Angstrom units (according to the specification), so use UnitsOutput
= eV_Angstrom, or your data will be misinterpreted by the visualization software.
UCSF Chimera
Those .dx files can be also be opened by UCSF Chimera.
Once having UCSF Chimera installed and opened, open the benzene.xyz file from File > Open.
To open the .dx file, go to Tools > Volume Data > Volume Viewer. A new window opens. There go to File > Open and select static/density.dx.
To "color" the density go to Tools > Surface Color. A new dialog opens and there choose Browse to open the vh.dx file. Then click Color and you should have an image similar to the below one.