for helium version of Exciting
Purpose: In this tutorial you will learn how to set up and execute a series of calculations for a crystal in the diamond structure, where the second atom in the unit cell is displaced along the cube diagonal. Additionally, it will be explained how to obtain the phonon frequency of the optical modes at q=0 (Γ point), by calculating the derivatives of the energyvsdisplacement and forcevsdisplacement curves at zero displacement.
Table of Contents

1. Define relevant shell variables and download scripts
Very important: Before starting, the following shell variables must be set by the user:
EXCITINGROOT = Directory where exciting has been downloaded, e.g.: /home/user/exciting .
EXCITINGRUNDIR = Directory where the user runs all the calculations (must be existing!!), e.g.: /home/user/tempdir .
EXCITINGSCRIPTS = Directory where the scripts are downloaded (not necessary if the downloaded files are copied in /usr/bin), e.g.: /home/user/scriptsdir .
The setting of these variables can be done in a bash shell by typing (from now on the symbol $ will indicate the shell prompt):
$ export EXCITINGROOT=/local_path_to_exciting_root
$ export EXCITINGRUNDIR=/local_run_directory
$ export EXCITINGSCRIPTS=/local_tutorial_scripts_bin_directory
$ export PATH=$PATH:$EXCITINGSCRIPTS
The directory names /local_path_to_exciting_root, /local_run_directory, and /local_tutorial_scripts_bin_directory are dummy names which must be explicitly changed by the user to the appropriate ones.
As a second step, it is necessary to download the scripts which are used in this tutorial. Here is a list of these scripts with a short description, click on the script name to download it:
 SETUPdiamondgammaphonon.py: Python script for generating structures with displaced atoms.
 EXECUTEdiamondgammaphonon.sh: (Bash) shell script for running a series of exciting calculations.
 CHECKFITenergyvsdisplacement.py: Python script for extracting the derivatives at zero displacement of the energyvsdisplacement curves.
 CHECKFITforcevsdisplacement.py: Python script for extracting the derivatives at zero displacement of the forcevsdisplacement curves.
 GNUenergy: Gnuplot visualization tool for the energyvsdisplacement curves.
 GNUuforce: Gnuplot visualization tool for the forcevsdisplacement curves.
 GNUstatus: Gnuplot visualization tool for the RMS deviations of the SCF potential as a function of the iteration number during the SCF loop.
 GNUcheck: Gnuplot visualization tool for the fit of the derivatives of the energyvsdisplacement curves at zero displacement.
 GNUfcheck: Gnuplot visualization tool for the fit of the derivatives of the forcesvsdisplacement curves at zero displacement.
All the downloaded scrips must be executable, if this is not the case use, e.g.:
$ chmod u+x SETUPdiamondgammaphonon.py
Requirements: Bash shell. Python numpy, lxml, and sys libraries. Gnuplot (visualization tools).
2. Set up the calculations
i) Preparation of the input file
The first step is to create a directory for each system that you want to investigate. In this tutorial, we consider as an example the calculation of the energyvsdisplacement curves for carbon in the diamond structure. Thus, we will create a directory diamond and we move inside it:
$ mkdir diamond
$ cd diamond
Inside this directory, we create (or copy from a previous calculation) the file input.xml corresponding to a calculation for the equilibrium structure of diamond.
This file could look like the following:
<?xml version="1.0" encoding="UTF8"?> <?xmlstylesheet href="inputtohtml.xsl" type="text/xsl"?> <input xsi:noNamespaceSchemaLocation="/local_path_to_exciting_root/xml/excitinginput.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsltpath="/local_path_to_exciting_root/xml/"> <title>Diamond: equilibrium structure</title> <structure speciespath="/local_path_to_exciting_root/species"> <crystal scale="6.7468"> <basevect> 0.5 0.5 0.0 </basevect> <basevect> 0.5 0.0 0.5 </basevect> <basevect> 0.0 0.5 0.5 </basevect> </crystal> <species speciesfile="C.xml" rmt="1.25"> <atom coord="0.00 0.00 0.00" /> <atom coord="0.25 0.25 0.25" /> </species> </structure> <groundstate ngridk="8 8 8" xctype="GGAPerdewBurkeErnzerhof" stype= "MethfesselPaxton 1" swidth="0.001" gmaxvr="18" lmaxvr="8" rgkmax="7.0" lradstep="2" tforce="true"> </groundstate> </input>
Please, remind that the input file for an exciting calculation must be always called input.xml.
Be sure to:
 set the correct path for the species directory (/local_path_to_exciting_root) to the one pointing to the place where the exciting directory is placed:
... <input xsi:noNamespaceSchemaLocation="/local_path_to_exciting_root/xml/excitinginput.xsd" ... xsltpath="/local_path_to_exciting_root/xml/"> ... <structure speciespath="/local_path_to_exciting_root/species"> ...
 do not perform any structural optimization.
 perform the calculation of the force acting on the atoms by adding the tforce="true" attribute to the groundstate element:
... <groundstate ... tforce="true"> </groundstate> ...
ii) Generation of input files for the different structures
In order to generate input files for a series of different structure you have to run the script SETUPdiamondgammaphonon, which will produce the following output on the screen:
$ SETUPdiamondgammaphonon.py
Enter maximum displacement umax [u/(lat. parameter)] >>>> 0.03
Enter the number of displacements in [umax,umax] >>>> 13
$
In this example, the (on screen) input entries are preceded by the symbol »». The entry values must be typed on the screen when requested. The first entry (in our example 0.03) represents the absolute value of the maximum displacement (for each component in crystal coordinates) for which we want to perform the calculation. The second entry (13) is the number of structures equally spaced in the displacement of the second atom, which are generated between the maximum negative displacement and the maximum positive one.
After running the script, a directory called workdir is created, which contains the input files corresponding to the different displacements.
Notice that the directory workdir will be overwritten each time you execute the script SETUPdiamondgammaphonon.py. Therefore, before setting up a new run please rename the workdir directory to a different name, e.g.:
$ mv workdir resultslabel
3. Execute the calculations
To execute the series of calculation with input files created by SETUPdiamondgammaphonon.py you have to run the script EXECUTEdiamondgammaphonon.sh:
$ EXECUTEdiamondgammaphonon.sh
Running exciting for file input01.xml 
...
Run completed for file input13.xml 
$
After the complete run, the results of the calculation for the input file workdir/input.xmli are contained in the subdirectory workdir/rundiri where i is running from 01 to the total number of strain values. The data for the energyvsdisplacement and forcevsdisplacement curves are contained in the files workdir/energyvsdisplacement and workdir/forcevsdisplacement, respectively. More precisely, the file workdir/forcevsdisplacement contains the x component of the force acting on the second atom in the unit cell as a function of the displacement.
4. Postprocessing: Extract energy derivatives
In order to analyse the results of the calculations, you first have to move to the working directory.
$ cd workdir
At this point, you can use the python script CHECKFITenergyvsdisplacement.py for extracting the derivatives of the energyvsdisplacement curves at zero displacement:
$ CHECKFITenergyvsdisplacement.py
Enter maximum displacement for the interpolation >>>> 0.03
Enter the order of derivative >>>> 2
Enter atomic mass in [amu] >>>> 12.01
#############################################
Fit data
Maximum value of the displacement ==> 0.030
Number of displacement values used ==> 13
Fit results for the derivative of order 2
Polynomial of order 2 ==> 1286.80 [cm1]
Polynomial of order 3 ==> 1286.80 [cm1]
Polynomial of order 4 ==> 1290.36 [cm1]
Polynomial of order 5 ==> 1290.36 [cm1]
Polynomial of order 6 ==> 1289.15 [cm1]
Polynomial of order 7 ==> 1289.15 [cm1]
Polynomial of order 2 ==> 38.5774 [THz]
Polynomial of order 3 ==> 38.5774 [THz]
Polynomial of order 4 ==> 38.6841 [THz]
Polynomial of order 5 ==> 38.6841 [THz]
Polynomial of order 6 ==> 38.6477 [THz]
Polynomial of order 7 ==> 38.6477 [THz]
$
In this example, the input entries are preceded by the symbol »». The entry values must be typed on the screen when requested. The first entry (in our example 0.03) represents the absolute value of the maximum displacement for which we want to perform the calculation. The second entry (2) is the order of the derivative that we want to obtain. Finally, the third entry (12.01) is the atomic mass of carbon in units of [amu].
NOTICE that, in this example, the values which are given above as output on the screen are not directly the actual second derivative of the energyvsdisplacement curves, but a combination involving the square root of such quantities (see Section 7. for the explanation).
The script generates the output files checkenergyderivatives and orderofderivative, which can be used in the postprocessing analysis.
5. Postprocessing: Extract force derivatives
The procedure for extracting the derivatives of the forcevsdisplacement curves is very similar to the one exposed in the previous Section for the energyvsdisplacement curves. You can use the python script CHECKFITforcevsdisplacement.py for extracting the derivatives of the forcevsdisplacement curves at zero displacement. The input entries and the screen output for this script are the same as for CHECKFITenergyvsdisplacement.py (see above). The only difference is that the derivative which one has to calculate in order to extract the phonon frequencies is the first one.
6. Postprocessing: Visualization tools
All the scripts mentioned here must be executed in the directory where the energyvsdisplacement, forcevsdisplacement, checkenergyderivatives, and orderofderivative files are located. The PostScript output file is always named gnu.ps.
i) GNUenergy
This script allows for the visualization of the energyvsdisplacement curve. It is executed as follows:
$ GNUenergy
The script generates the PostScript file gnu.ps. In the following, we display the result for the example mentioned above (carbon in the diamond structure, displacements up to 3% in units of the cubic lattice constant):
ii) GNUuforce
This script allows for the visualization of the forcevsdisplacement curve. It is executed as follows:
$ GNUuforce
An example of the script output is the following:
iii) GNUcheck
This is a very important script that allows to represent the dependence of the calculated derivatives of the energyvsdisplacement curve on
 the range of points included in the fitting procedure,
 the maximum degree of the polynomial used in the fitting procedure.
The script is executed as follows:
$ GNUcheck
An example of the script output is the following:
The most appropriate value for the derivative in this example is represented by the horizontal plateau (at about 1289.5 cm^{1}) of the curves corresponding to the highest order fits.
NOTICE that, in this example, the values which are plotted in the picture above are not directly the actual second derivative of the energyvsdisplacement curves, but a combination involving the square root of such quantities (see Section 7. for the explanation).
iv) GNUfcheck
Same as GNUcheck, but for derivatives of the forcevsdisplacement curve. To be used after running CHECKFITforcevsdisplacement.py. The script is executed as follows:
$ GNUfcheck
An example of the script output is the following:
The most appropriate value for the derivative in this example is represented by the horizontal plateau (at about 1290.0 cm^{1}) of the curves corresponding to the highest order fits.
NOTICE that, in this example, the values which are plotted in the picture above are not directly the actual first derivative of the forcevsdisplacement curves, but a combination involving the square root of such quantities (see Section 7. for the explanation).
v) GNUstatus
Gnuplot visualization tool for the RMS deviations of the effective SCF potential as a function of the iteration number during the SCF loop. It is executed as follows:
$ GNUstatus
Enter label [r or 01,02,...] >>>> 01
$
In this example, the input entry, preceded by the symbol »» (in our example 01) represents the label of the calculation for which you would like to plot the RMS deviations. In particular, the choice r refers to the currently running calculation and, e.g., 02 to the calculation already saved in the directory workdir/rundir02. An example of the script output is the following:
Remark on the visualization scripts
All the visualization scripts accept two onthecommandline entries specifying the yaxis limiting values. So that, e.g., the command
$ GNUcheck 1280 1300
will visualize the results for the derivative in the yaxis range between 1280 and 1300 cm^{1} .
7. Postprocessing: How to derive the optical phonon frequency at q=0 (Γ point)
i) Using the energyvsdisplacement curves
The total energy per unit cell of a crystal where the atoms are displaced by their equilibrium positions can be written as
E({u}) = E_{0} + 1/2 Σ_{R,R'} u(R) Φ(R,R') u(R') + O(u^{3})
where E_{0} is the energy corresponding to the equilibrium structure, u(R) is an atomic displacement in the cell R, and Φ(R,R') is the interatomic forceconstants matrix. For small displacements, terms beyond the harmonic approximation (which retains only terms that are quadratic in u) can be neglected. For the diamond structure and a phonon pattern corresponding to the optical phonon at the Γ point, the displacements of the 2 atoms in the unit cell can be given as
u_{1}(R) = (0, 0, 0)
u_{2}(R) = a (u, u, u)
where a is the lattice constant. The same displacements hold in all unit cells of the crystal. Therefore, for an optical phonon at q=0, the total energy per unit cell of the crystal can be written as:
E({u}) = E_{0} + 3/4 m a^{2} (ω_{opt})^{2} u^{2}
Using appropriate values for m and a and their units, the phonon frequency of the optical mode at the Γ point for the diamond structure is given directly from the square root of the second derivative of the energyvsdisplacement curves. This is the output of the fit procedure exposed above if the order of the derivative is taken equal to 2. One obtains in our case
ω_{opt} = 1290.36 cm^{1} = 38.6841 THz
if the order of the fitting polynomial used for the fit is 4 and 13 different displacements equally spaced between 0.03 and +0.03 are considered. If the (more realistic) plateau value is used, as explained above, the value
ω_{opt} = 1289.5 cm^{1} = 38.658 THz
is obtained.
ii) Using the forcevsdisplacement curves
Using the same phonon displacement pattern as above, the component in the x direction of the force acting on the second atom is (within the harmonic approximation):
F_{2x}({u}) = 1/2 m a (ω_{opt})^{2} u
This force obviously vanishes in the equilibrium configuration (u=0). Similarly to the previous case, the frequency obtained from the plateau value of the first order derivative at zero displacement of the forcevsdisplacement curves is
ω_{opt} = 1290.0 cm^{1} = 38.673 THz.