Preparation and Installation Issues

Info on compilation issues and tutorial setup

Compiling CPMD

The first and (sometimes quite high) hurdle for doing calculations with CPMD, is to get the software compiled. CPMD is currently distributed (at no cost for non-commercial users) via the CPMD consortium homepage as a source code package only.

For this tutorial a generic, serial executable should be sufficient, although, for personal convenience, I have been testing all the exercises using a mpi parallel executable, compiled for Power7 (tested as well for OS/X). Keep also in mind, that most serious applications of CPMD will necessarily need a larger amount of CPU hours, i.e. a big parallel machine or cluster. To take full advantage of your (large) machine you thus need to compile a custom executable from the source code, which is compatible to and specifically optimized for your local machine. CPMD is well parallelized using a distributed memory MPI-based parallelization plus an optional and independent OpenMP parallelization for SMP nodes. Particularly the compilation of parallel executables will very much depend on the individual installation and configuration.

Please check out the CPMD manual on how to do that. Some hints and tricks for compiling CPMD on Linux machines (which is particularly troublesome) can be found on the mailing list.

Running CPMD

The following examples assume, that you create a separate subdirectory for each group of calculations containing the input file(s). In order to preserve the files generated in each run each input file of each group of calculation will be run in a separated directory. The pseudopotential file(s) will be stored in a separate folder, named Files.

The suggestion is to download the CPMD tutorial folder, and expand the archive in your favourite location. Upon decompression, you will have the following structure:

drwxr-xr-x 21 teo mcs 16384 2011-07-25 14:47 01-h2
drwxr-xr-x  7 teo mcs 16384 2011-07-25 14:47 02-h2o_pbc
drwxr-xr-x 10 teo mcs 16384 2011-07-25 14:47 03-nh3
drwxr-xr-x  8 teo mcs 16384 2011-07-25 14:47 04-gly
drwxr-xr-x 12 teo mcs 16384 2011-07-25 14:47 05-si_bulk
drwxr-xr-x 11 teo mcs 16384 2011-07-25 14:47 10-h2o_single
drwxr-xr-x  7 teo mcs 16384 2011-07-25 14:47 11-h3op_h2o
drwxr-xr-x 20 teo mcs 16384 2011-07-25 14:47 12-triade

which contains the input files for the different group of calculations. And

-rw-r--r--  1 teo mcs   553 2011-07-25 14:48 cpmd_tutorial.conf
-rwxr-xr-x  1 teo mcs  1349 2011-07-25 17:27

which are two files. The first one will have to be configured specifying the proper location of cpmd and cpmd2cube, if you plan to run the jobs using the scripts provided. The second file is a bash script to measure the memory and execution time. At the moment it works OK only when used for serial runs.

If you do not plan to use the execution scripts provided in the directory trees, be sure at least that you have a usable CPMD executable in your search path under the name cpmd.x.

You can then run the calculations in that directory by typing something like:

 cpmd.x example.inp  > example.out

or for parallel execution:

mpirun -np 8 cpmd.x example.inp ../Files/ -hostfile ../Files/myhost > example.out

or using the script provided in each directory, typing:


remember in this case to configure the file cpmd_tutorial.conf in the root directory.

Again, please check out the manual for more details and further options (e.g. using PP_LIBRARY_PATH to load pseudopotentials from a central pseudopotential repository) and the purpose of the generated files.

In several occasion, you will find also an additional Analysis directory. There we provide simple bash scripts to help you extract data from the calculations. These assume that you are working in a unix-like environment and they were (usually only) tested on a UNIX machine (PWRLinux, OS/X).

Running cpmd2cube

cpmd2cube.tar.gz (cpmd2cube.x) is a companion program to CPMD and is used to convert volumetric data written by CPMD to realspace 3-dimensional gridded data in the .cube format as it also is produced by the Gaussian program package. These cube files can then be post-processed and visualized in the same way and with the same tools as for Gaussian calculations.

The cpmd2cube program has many options, most of them you will rarely need.  Most importantly are the “-rho” and “-psi” option which will depend on the type of data (e.g. wave function or density). The program will try to autodetect, but this does not always work.

# ./cpmd2cube.x -h

cpmd2cube: Convert CPMD's Wannier-function files to cube
usage is: cpmd2cube [options] Wannier_file [Wannier_file...]
   If you specify more than one Wannier file, they MUST have the
   same g-vectors and (for the moment) atom positions
   The program will create one cube file for each Wannier file
   and one pdb file with the atom positions
   cpmd2cube WANNIER_1.*
possible options are
      write Bader density to a file
   -v :
       is 0-3 (default is 1)
      Read the density in double precision (default is single)
      create full mesh cube file (default is -halfmesh)
      leave out half the grid points in each direction.
      Reduces the file size by 1/8th
   -trim :
      write a minimal cube file including all data points which have an
      absolute value above . Can reduce the file size dramatically
      for isolated molecules and localized orbitals.
      correct for the fact, that the integrated electrostatic potential.
      is not zero. To be used when converting ELPOT files
      do not output any coordinates to the cube file. only puts a dummy 
      atom at the origin, since some codes need at least one atom.
      main application is to generate small files on QM/MM runs.
   -n   :
      change the REAL-space mesh. Default is to take the same mesh as CPMD
   -o :
      specify the prefix of the name used for the cube and pdb-files
   -rep   :
      replicate the cell n times along the -th direction by periodicity
   -shift   :
      shift cube density by r1*a1+r2*a2+r3*a3
      centre density around centre of mass of system.
      put atoms inside unit cell centred around origin
      convert a density instead of a wavefunction into a cube file.
      convert a wavefunction instead of a density into a cube file.
      last option. Useful if you have a file with the same name as an option
   -h  or  -?  or  -help  or  --help  or no files:
      write this help