Chapter 3
Plotting and analysis tools

Additional tools and programs are available to help automate post-processing analysis and plotting of the results of phonon calculations.

Two programs and analyse the .castep or .phonon files, read the phonon information and can generate plots of phonon dispersion curves across the Brillouin Zone, and of phonon densities of states respectively1 . These programs are written in the PERL language which is almost universally available on modern operating systems. Generation of the graphics output is handled by the “xmgrace” program ( (the perl programs generate an xmgrace script and invoke it automatically). On linux systems xmgrace can usually be found as a contributed package and installed using the system package manager. Xmgrace is also available for Microsoft Windows systems as part of the “cygwin” suite of programs ( along with shells, the PERL interpreter and an X-windows server (Xmgrace is an X-windows program and requires a running X server to display).


The program can read either a .castep or a .phonon file and generate a phonon density of states plot. Arguments are given in “unix style” following a minus sign (dash). The command -xg -w 10 <seedname>.phonon

will generate a phonon density of states using a Gaussian broadening with a FWHM of 10 cm-1, and invoked xmgrace to generate the plot. The DOS is constructed as a weighted average over all q-points present in the file, using the weights generated by CASTEP in the case of PHONON_KPOINT_MP_GRID, or read from the .cell file if %BLOCK PHONON_KPOINT_LIST was used.

The options -np, -ps, -eps change the default output and write an xmgrace file, a PostScript or Encapsulated PostScript file respectively. These files are written to standard output so use a shell redirect (>) to name your plot file. The option -ir option weights the computed DOS by the computed infra-red intensity in the .castep or .phonon file. This simple algorithm is not a fully realistic model of an infrared powder spectrum, and should be regarded as a simple approximation only.2 Likewise the -raman option extracts raman intensities and computes the weighted spectrum. The computed spectrum does include the frequency-dependent and Stokes thermal factors, and is therefore a more realistic model spectrum than in the infrared case. The -lorentz option switches from Gaussian to a Lorentzian broadening and the -temp T option sets the temperature for the Stokes thermal population term in Kelvin.

Figure 3.1 shows an example derived from the output produced by using on the example run of figure 2.3.


Figure 3.1: Example output from based on the run of figure 2.3. Infrared spectrum and DOS curves based on just the TO modes or TO plus LO have been combined into into one plot with a slightly shifted baseline, scaled, and legends added.


The program can read either a .castep or a .phonon file and generate a dispersion curve plot using xmgrace. Unlike the behaviour of there is an important difference between the behaviour when reading these two different output files concerning the detection of branch crossings. A high-quality dispersion plot requires that phonon branches are drawn as continuous lines even when two branches cross in between the computed wavevectors. contains an algorithm based on matching of eigenvectors at adjacent points to determine branch connectivity. Only the .phonon file contains eigenvector information, so only in this case is crossing detection enabled. The algorithm can be time consuming and take several minutes to complete in large cases, so patience is sometimes required. The -nj option (“no-join”) disables the crossing detection even when the input file is a .phonon one.

The options -np, -ps, -eps behave exactly as for One useful output option is -symmetry <symm> which attempts to label the high symmetry points using the conventional Brillouin zone notation of Bradley and Cracknell. The symmetry keywords cubic, fcc, bcc, tetragonal, tetragonal, tetragonal-I, orthorhombic, hexagonal, trigonal, trigonal-h (and minor variants) are understood.

Figure 3.2 demonstrates the effect of the flags and the branch joining algorithm. The plots were produced from a Fourier interpolation calculation of fcc RbBr using the commands -xg -symmetry fcc RbBr.phonon

and -xg -symmetry fcc -nj RbBr.phonon



Figure 3.2: Phonon dispersion curve plots of RbBr generated using the script and xmgrace. The Brillouin zone labelling is generated using the -symmetry fcc option. The left-hand plot was generated using the default branch crossing detection algorithm, which was disabled using the -nj option for the right-hand plot. The algorithm has discriminated between modes which do cross and the four genuine avoided crossings in the left-hand plot

3.3 mode_follow

mode_follow is one of the Fortran tools suite in the CASTEP source, which is compiled using the command make tools. As the name implies its function is to generate new “frozen phonon” configurations based on perturbation by a mode generated from a previous phonon calculation, which it outputs by writing one or mode new .cell files. In fact it has two modes of operation.

  1. To generate a sequence of .cell files perturbed by the a frozen phonon at a range of amplitudes, which may be used to explore the energy profile along the mode it is invoked as

    mode follow -mode mode_num -namp num_amplitudes -amp max_amplitude -qpoint qx qy qz <seedname>|<seedname>.phonon

    which reads the .phonon and corresponding .cell files and generates a sequence of N + 1 files seedname-i.cell containing structures perturbed by the selected eigenvector scaled by a non-dimensional amplitude factor f = Ai∕N,i = 0..N. The arguments are
    is the integer index number selecting which mode to use (default 1)
    qx qy qz
    is the q-point to extract from the .phonon file (default (0,0,0))
    is A the non-dimensional scale of the eigenvectors used to create the (largest) displacement
    is N, one less than the number of configurations to generate (default 2).
    is the seed name of a previous, successful phonon run.

    The file seedname.phonon must exist and be readable. If mode_follow is invoked without the .phonon extension, it will also attempt to read seedname.cell file if it exists and will copy most other cell parameters and settings to its output .cell files.

    As an alternative to specifying the arguments on the command line mode_follow will also attempt to read them from a file named seedname.mode-param if it exists. This file should contain a Fortran namelist named freeze, whose entries are the identical to the command-line argument names. For example


    To produce a frozen phonon configuration for a nonzero q-vector it is also necessary to generate a supercell which is commensurate with a frozen phonon at wavevector q. This supercell may be specified in the .cell file using the usual PHONON_SUPERCELL_MATRIX block, or by the entry supercell in namelist freeze in the .mode-param file. (There is no corresponding command line argument). For example a .mode-param file requesting a zone-boundary phonon might contain


  2. Mode_follow’s second mode of operation is to generate output files with the structure perturbed by a frozen phonon at the same amplitude but a progressive sequence of phases, which could be used for an animation of the mode. In that case the num_amplitudes argument should be omitted, and the alternative nframes argument given instead (either on the command line or in the .mode-param file). This will generate a sequence of N frames with phases separated by 2π∕N. Otherwise the arguments and behaviour are identical.

    One of the scripts in the cteprouts package, e.g.  cell2xtl, cell2pdb, cell2xyz may be then be used to convert the .cell files to a form suitable for visualisation.

3.4 phonons

The program phonons, one of the CASTEP tools suite is a general purpose phonon post-processing tool. It can read all of the dynamical matrix or force constant matrix data from a .check or .castep_bin file generated in any phonon calculation and re-generate the final phonon output with changes to one or several “finalisation” options, without needing to repeat the expensive “electronic” DFPT or supercell parts of a lattice dynamics calculation. For example, an acoustic sum-rule correction may be applied to a calculation where this was not chosen initially.

phonons is invoked exactly as is CASTEP and reads a .cell and a .param file exactly as CASTEP does. These may be identical to or near copies of the original calculation, but the .param file must contain the continuation keyword which must point to the .check or .castep_bin file which contains the dynamical matrix data. If the run is successful it will write a log file with the extension .phonon_out and a new .phonon file. In this respect a run of phonons on a continuation deck is very similar to re-running castep on the same deck. However it will not attempt to perform any “electronic” calculation and will ignore any attempt to try. For example, if the parameter elec_energy_tol was changed castep would discard the saved dynamical matrix data and restart from the beginning. phonons will ignore this and process the saved data as a continuation run.

This post-processing can be used for a number of tasks, including

All of the above could also be performed using castep rather than phonons provided care is taken not to change any parameters which control the properties of the “electronic” part of the calculation. However phonons can also perform some additional processing which castep can not, most notably isotopically substituted lattice dynamics calculations.