Purpose: In this tutorial you will learn how to set up and execute a series of calculations at different volumes for a cubic crystal. Additionally, it will be explained how to fit the energy-vs-volume curves with polynomial of various degree in order to obtain the corresponding equilibrium volume.
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 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 .
DISPLAY (needed for running CHECKFIT-energy-vs-volume.py, only for remote calculations).
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 $ export DISPLAY=0.0
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:
- SETUP-volume-optimization.py: Python script for generating structures at different volumes.
- EXECUTE-volume-optimization.sh: (Bash) shell script for running a series of exciting calculations.
- CHECKFIT-energy-vs-volume.py: Python script for fitting the energy-vs-volume curves.
All the downloaded scrips must be executable, if this is not the case use, e.g.:
$ chmod u+x SETUP-volume-optimization.py
Requirements: Bash shell. Python numpy, lxml, matplotlib.pyplot, and sys libraries.
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 energy-vs-volume curves for silver in the fcc cubic structure. Thus, we will create a directory silver and we move inside it:
$ mkdir silver $ cd silver
Inside this directory, we create (or copy from a previous calculation) the file input.xml corresponding to a SCF calculation at a reference lattice constant for silver. A possible choice for this reference value is the experimental lattice constant of 7.729 [Bohr].
This file could look like the following:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="inputtohtml.xsl" type="text/xsl"?> <input xsi:noNamespaceSchemaLocation="/local_path_to_exciting_root/xml/excitinginput.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsltpath="/local_path_to_exciting_root/xml/"> <title>Silver</title> <structure speciespath="/local_path_to_exciting_root/species"> <crystal scale="7.729"> <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="Ag.xml" rmt="2.0"> <atom coord="0.00 0.00 0.00" /> </species> </structure> <groundstate ngridk="8 8 8" swidth="0.01" rgkmax="8.0"> </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 exciting root 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">
ii) Generation of input files for different volumes
In order to generate input files for a series of volumes you have to run the script SETUP-volume-optimization, which will produce the following output on the screen:
$ SETUP-volume-optimization.py Enter the number of volume values >>>> 11 $
In this example, the (on screen) input entry is preceded by the symbol »». The entry value must be typed on the screen when requested. This entry (in our example 11) is the number of structures which are generated with equally spaced intervals of the lattice constant with a variation of between -5% and +5% from the reference lattice constant.
After running the script, a directory called workdir is created, which contains the input files for the different volumes.
Notice that the directory workdir will be overwritten each time you execute the script SETUP-volume-optimization.py. Therefore, before setting up a new run please rename the workdir directory to a different name, e.g.:
$ mv workdir results-test-0
3. Execute the calculations
To execute the series of calculation with input files created by SETUP-volume-optimization.py you have to run the script EXECUTE-volume-optimization.sh:
$ EXECUTE-volume-optimization.sh Running exciting for file input-01.xml ---------------------------------- ... Run completed for file input-11.xml ------------------------------------- $
After the complete run, the results of the calculation for the input file workdir/input.xml-i are contained in the subdirectory workdir/rundir-i where i is running from 01 to the total number of volumes. The data for the energy-vs-volume curve are contained in the file workdir/energy-vs-volume.
4. Post-processing: Calculating the optimal volume
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 CHECKFIT-energy-vs-volume.py for performing the polynomial fit and extracting the equilibrium volume:
$ CHECKFIT-energy-vs-volume.py Enter the order of polynomial to be used in the fit >>>> 2 ########################################### Optimal volume = 110.64397427 [Bohr^3] ########################################### $
In this example, the input entry is preceded by the symbol »». The entry values must be typed on the screen when requested. The entry (in our example 2) represents the order of the polynomial for the fit.
The script generates the PostScript output file gnu.ps, which can be used to visualize the fitting results. An example of the script output is the following:
5. Additional exercises
- Improve the accuracy of the fit by adding additional data points.
- Calculate the cubic lattice constant at the optimal volume.
- Choose as a new reference lattice constant a value corresponding to the optimal volume.