Tutorial 1

Preparation of atomic structure and electron density dataset.

From the LRZ Summer of Simulation 2017 project Photocatalytic water-splitting with carbon nitride materials: Combining the condensed matter and molecular approaches (Johannes Ehrmaier)

Data preparation

We begin with a cube file:


The cube file contains information about heptazine in a water box as a periodic system and the charge response of the bright pipi^* state of heptazine.


We will start by visualizing the atoms in the system to obtain a spatial view of the atomic distribution.


atomscaling 1
repetitions 2 2 2
cubefile drho-of-eign-3.cube

background 0 0 0

Isosurface extraction

We open drho-of-eign-3.cube in Paraview

We select "Gridded data"

We extract an isosurface at 0.004 using the "Contour filter"

We save the isosurface using "File -> Export scene" and save as "VRML files (*.vrml).

The procedure can be scripted if required (see Tutorial 3).

Isosurface conversion

We process the isosurface in meshlab.

-Rename the isosurface to 1-04.wrl (Paraview saves VRML2 files by default which meshlab expects as *.wrl)

-Optional: Mesh simplification using Filters -> Remeshing, Simplification and Reconstruction -> "Quadric Edge Collapse Decimation" with "Percentage Reduction" set to 0.5 (50% reduction), then Apply

-Export as 1-04.ply using File -> Export Mesh as -> Stanford Polygon File Format (*.ply). Select Vert->Normals and "Binary encoding".

The procedure can be scripted if required (Filters -> Show Current Filter Script -> Save Script).

Optional: extraction of other isosurfaces

The procedure in the previous two sections can be repeated using the isovalue -0.004 and filenames 1--04.wrl and 1--04.ply.

To prepare the new isosurfaces, change the value in the contour filter, click apply, then save.

Optional: simplification of the cube file

Since we now have the isosurface, we do not need the volumetric data in the cube file.

We open the cube file in an editor such as notepad++, and delete the volumetric data (discard lines 383 to the end of the file).

Final cube and ply



Final ncfg


atomscaling 1
repetitions 1 1 1
cubefile drho-of-eign-3-header.cube

isos 1
values "04"
colours 0.186 0.806 0.286 0.5

background 0 0 0

2-isosurface ncfg

Replace these lines from the ncfg above:

isos 2
values "04" "-04"
colours 1 0.5 0 0.5      0 0.25 0.4 0.5

Multiple timesteps

If you have multiple timesteps, the ply files are prefixed by the timestep. Change 1- in the example above to the correct value for timesteps 2 and above.

To visualize the atomic information, convert the cube files to xyz using for example VMD, and concatenate all the xyz files into a final xyz file. This file can be loaded in the ncfg by using

xyzfile "final.xyz"

Add a suitable unit cell definition. For our cube file, the header is

Cubfile created from PWScf calculation
Total SCF Density
376 0.000000 0.000000 0.000000
192 0.173038 0.000000 0.000000
192 0.000000 0.173038 0.000000
144 0.000000 0.000000 0.166637

The first column 192, 192, 144 being positive means the cube file uses Bohr units, and therefore the unit cell parameters (lower right 3x3 matrix of the header above) should be multiplied by 0.52918 to obtain Ångström.

The unit cell parameter is

abc 0.09156824884 0 0 0 0.09156824884 0 0 0 0.08818096766

See Tutorial 4 for details.

Visualization in VR tools


Using only one isovalue at +0.004

HTC Vive

Using only one isovalue at +0.004

Google Cardboard

Using only one isovalue at +0.004

Using two isovalues at +0.004 and -0.004

Desktop tool

VMD visualization using two isovalues at +0.004 and -0.004:


Dataset provided by Johannes Ehrmaier.