http://wiki.max-centre.eu/api.php?action=feedcontributions&user=Andrea+Ferretti&feedformat=atomWiki Max - User contributions [en]2024-03-29T10:44:03ZUser contributionsMediaWiki 1.35.0http://wiki.max-centre.eu/index.php?title=Main_Page&diff=970Main Page2022-11-15T10:48:56Z<p>Andrea Ferretti: </p>
<hr />
<div>---- This page contains '''MaX-related utilities and links''', including teaching and '''training material''' for electronic structure and condensed matter problems and '''tutorials''' about MaX flagship codes.<br />
<br />
This collection is by no means complete, and represents just another virtual space to share information and training material.<br />
<br />
<!--<br />
{| cellpadding="5%"<br />
|[[Main Page]]<br />
|[[Training Material]]<br />
|[[Contacts]]<br />
|[[References]]<br />
|<br />
|}<br />
--><br />
<br />
{| cellpadding="10%" width="90%"<br />
| width="35%" |<br />
== About MaX ==<br />
*[http://www.max-centre.eu Intro]<br />
*[http://max-centre.eu/software Flagship codes and Libraries]<br />
*[http://max-centre.eu/data Data and Workflows]<br />
*[http://max-centre.eu/services Services]<br />
*[http://max-centre.eu/training Training]<br />
<br />
| width="35%" |<br />
== Tutorials ==<br />
*[http://max-centre.eu/training-material-related-max-flagship-codes MaX-Flagship codes]<br />
*[https://www.materialscloud.org/learn/sections MaterialsCloud Learn]<br />
*[http://www.yambo-code.org/wiki/index.php?title=Main_Page Yambo Educational and Tutorial]<br />
<br />
<br />
== Specific Training Material ==<br />
<br />
*[https://www.materialscloud.org/learn/sections/VNL7RL/a-gentle-introduction-to-dft-calculations-april-2020 Fireside chats for lockdown times: A gentle introduction to DFT calculations] (N. Marzari, Apr 2020) <br />
*[[LabQSM|LabQSM]] Laboratory of Quantum Simulation of Materials (A. Ferretti, A. Ruini, D. Varsano)<br />
<br />
<!--<br />
|[[File:80ac81b37f1021b24ca9125e0d7322d1442baf5b-b-chargetransfer.png |thumb|230px|right| U. G. E. Perera, et al., Phys. Rev. Lett. '''105''', 106601 (2010) .|link=https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.105.106601]]<br />
|}<br />
--><br />
|[[File:80ac81b37f1021b24ca9125e0d7322d1442baf5b-vert-chargetransfer.png |thumb|230px|right| U. G. E. Perera, et al., Phys. Rev. Lett. '''105''', 106601 (2010) .|link=https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.105.106601]]<br />
|}</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB3_hBN&diff=969Solution LAB3 hBN2022-03-15T16:11:18Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of 2D and 1D systems#Exercise 2: Hexagonal Boron Nitrite (hBN) ]]<br />
Now we do have two non-equivalent atoms<br />
*If you do not have already done, git pull the LabQSM repository to get the Boron pseudo-potential <br />
*Use the same input used for graphene inserting the two non-equivalent atoms<br />
*Relax the cell as done before (at the LDA level, a = 4.654 Bohr)<br />
*For the bulk structure the c/a cell parameter is 2.582 (including 2 hBN layers)</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB3_hBN&diff=968Solution LAB3 hBN2022-03-15T16:07:20Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of 2D and 1D systems#Exercise 2: Hexagonal Boron Nitrite (hBN) ]]<br />
Now we do have two non-equivalent atoms<br />
*If you do not have already done, git pull the LabQSM repository to get the Boron pseudo-potential <br />
*Use the same input used for graphene inserting the two non-equivalent atoms<br />
*Relax the cell as done before (at the LDA level, a = 2.582 Bohr)</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB3_hBN&diff=967Solution LAB3 hBN2022-03-15T16:03:17Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of 2D and 1D systems#Exercise 2: Hexagonal Boron Nitrite (hBN) ]]<br />
Now we do have two non-equivalent atoms<br />
*If you do not have already done, git pull the LabQSM repository to get the Boron pseudo-potential <br />
*Use the same input used for graphene inserting the two non-equivalent atoms<br />
*Relax the cell as done before<br />
*For the bulk structure the c/a cell parameter is 2.582 (including 2 hBN layers)</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Scripting&diff=966Scripting2021-11-23T14:22:58Z<p>Andrea Ferretti: /* Bash control statements */</p>
<hr />
<div><br />
<br />
* Prev: [[Warming up with Unix commands]]<br />
* Next: [[LabQSM#Link to Selected Laboratories]]<br />
<br />
<br />
[[File:Bash.png|left| 180px]]<br />
<br />
Commands (to be interpreted and executed) can be placed in a text file, called script, to be executed by means of an interpreter<br />
<br />
The interpreter is specified in the first line of the script, e.g. by:<br />
#! /bin/sh<br />
#! /bin/bash<br />
#! /bin/tcsh<br />
#! /usr/bin/awk -f<br />
#! /usr/bin/env python<br />
...<br />
(Note that while # is in all the above languages a comment, #! is actually used to identify the interpreter).<br />
<br />
== Bash scripting ==<br />
<br />
Among the many, '''bash scripting''' is particularly relevant to us (bash is also the interpreter of the command-line shell<br />
we have been using so far).<br />
<br />
Unix commands (enriched by bash built-in functions & structures) can be used in bash scripts:<br />
<br />
$> vi ./get_users.sh<br />
<br />
#! /bin/bash -x<br />
filein=/etc/passwd<br />
#<br />
# extract user names<br />
cat $filein | awk -v FS=":" '{print $1}'<br />
<br />
Note that in order to execute <code>get_users.sh</code>, we need to change its permissions,<br />
$> chmod a+x ./get_users.sh<br />
When executing, the output fo the script can also be redirected to a file, <br />
$> ./get_users.sh > users.dat<br />
<br />
Within the script, $0 corresponds to the invocation name (./get_users.sh, in the example above), $1, $2, .. $n<br />
to the n-th arguments if present. $# is the number of command line arguments passed to the script.<br />
<br />
$> cat ./get_users2.sh<br />
<br />
#! /bin/bash<br />
if [ $# == 0 ] ; then echo "Usage: ./get_users2.sh <filename>" ; exit 1 ; fi<br />
filein=$1<br />
# <br />
# extract user names<br />
cat $filein | awk -v FS=":" '{print $1}'<br />
<br />
Now, this second version of the script needs to be run as:<br />
$> ./get_users2.sh /etc/passwd<br />
<br />
== Sed & Awk ==<br />
<br />
These two commands, available almost everywhere, are extremely used in bash scripting.<br />
<br />
=== sed === <br />
substitutes regular expressions in files or strings. Examples follow:<br />
<br />
$> echo “Ciao Ciao” | sed ‘s/C/M/’<br />
-> “Miao Ciao”<br />
$> echo “Ciao Ciao” | sed ‘s/C/M/g’<br />
-> “Miao Miao” # g stands for “global substitution”<br />
<br />
Regular expressions can also be used in the search. <br />
<br />
* "." in the regular expr means all characters (wild card) and needs to be protected as \. to be treated as a regular character<br />
* \n means newline<br />
* \t tab<br />
<br />
<br />
=== awk ===<br />
line by line operations (number & strings, syntax similar to c)<br />
$> echo 10 4.0 | awk '{print $1 * sqrt($2)}'<br />
$> echo “LabQSM 2020” | awk '{print $1; print "Year", $2}'<br />
<br />
Awk has its own scripting, useful eg for parsing or data post-processing (the same operation/search is done line by line)<br />
<br />
Actions are automatically performed line by line.<br />
* NR current line number<br />
* NF current number of fields, separated by FS <br />
* FS field separator, space by default, can be changed e.g. to , or :, or tab<br />
* $1, $2, ... $NF refer to different fields in the parsed line<br />
* Arithmetic, string (and many more) operations.<br />
* next skips to the next line<br />
<br />
Take eg the file <code>apt.txt</code> with the list of tennis players that we have used in previous examples:<br />
9850, Nadal, Rafael <br />
6630, Federer, Roger<br />
3075, Berrettini, Matteo <br />
12030, Djokovic, Novak<br />
<br />
The problem can be solved by awk as follows:<br />
<br />
#! /usr/bin/awk -f<br />
BEGIN{ i=ind; nlines=0; FS="," }<br />
{<br />
if (NF != 3) next<br />
nlines++<br />
if (nlines == i) {printf "%s, %s\n", $3,$2}<br />
}<br />
END{<br />
# place here any operation to be done at the end<br />
}<br />
<br />
Run as:<br />
$> ./solution.awk -v ind=2 apt.txt<br />
<br />
Note that comma-separated columns are no longer needed, and one can avoid using commas by simply dropping the redefinition of the field-separator FS=",".<br />
<br />
== Bash control statements ==<br />
<br />
'''Conditionals'''<br />
<br />
if [ "$var1" = "$var2" ] ; then<br />
<some-statements><br />
else<br />
<some-statements><br />
fi<br />
<br />
if [ -n "$var" ] ; then echo "var is non-empty" ; fi <br />
if [ -z "$var" ] ; then echo "var is empty" ; fi<br />
if [ -e "$file" ] ; then echo "File exists" ; fi<br />
if [ ! -e "$file" ] ; then echo "File does not exist" ; fi<br />
if [ -d "$dir" ] ; then echo "Dir exists" ; fi<br />
if [ -x "$file" ] ; then echo "File exists and is exec" ; fi<br />
<br />
'''Loops'''<br />
list="item1 item2 item3"<br />
for item in $list<br />
do<br />
echo $item<br />
done<br />
<br />
'''Input from command line'''<br />
<br />
#! /bin/bash<br />
echo "number of arguments : $#"<br />
echo " command : $0"<br />
echo " 1st arg : $1"<br />
echo " 2nd arg : $2"<br />
echo " ... "<br />
echo " all args : $*"<br />
<br />
Execute as:<br />
$> ./example.sh p1 p2 p3<br />
<br />
'''Dealing with extended text'''<br />
(Useful eg to write input files)<br />
<br />
This can be used for a few lines<br />
echo line1 > file.txt <br />
echo line2 >> file.txt<br />
echo line3 >> file.txt<br />
<br />
Instead, when text becomes extended<br />
cat >file.txt << EOF<br />
line1<br />
line2<br />
line3<br />
EOF<br />
<br />
== Exercises ==<br />
<br />
=== Exercise 1 ===<br />
Job Script: Write a script (run.sh) to run <code>pw.x</code> once an input file is provided<br />
<br />
[[Solution_1_1 | Solution 1]]<br />
<br />
[[Solution_1_2 | Solution 2]]<br />
<br />
<br />
=== Exercise 2 ===<br />
<br />
* Modify the ruh.sh script of Problem 1 to loop over different lattice parameters.<br />
* Consider the grid: -3%, -2%, -1%, 0, +1%, +2%, + 3%<br />
* Keep trace of the parameters used in the file names<br />
<br />
* '''Hint1''': create a template input file, where the <code>celldm1</code> field is assigned <code>@alat@</code>, which you will substitute in the script<br />
* '''Hint2''': save both input and output files; <br />
* '''Hint3''': <code>$ basename <name>.dat .dat -> <name></code><br />
<br />
'''Solution''': have a look at <br />
* [https://github.com/max-centre/LabQSM/blob/main/LAB_1/test_diamond/run_lattice.sh LAB_1/test_diamond/run_lattice.sh] and<br />
* [https://github.com/max-centre/LabQSM/blob/main/LAB_1/test_diamond/scf.tmpl LAB_1/test_diamond/scf.tmpl]<br />
<br />
<br />
<br />
=== Exercise 3 ===<br />
<br />
Lattice parameter revised<br />
* Same at Exercise 2<br />
* Include the input file in the script, meaning that the substitution of parameters in the template input file can be done via shell variables and loops<br />
<br />
'''Solution''': have a look at <br />
* [https://github.com/max-centre/LabQSM/blob/main/LAB_1/test_diamond/run_lattice_with_input.sh LAB_1/test_diamond/run_lattice_with_input.sh]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Getting_Started&diff=965Getting Started2021-11-16T10:49:19Z<p>Andrea Ferretti: /* Machine setup */</p>
<hr />
<div><br />
* Back to the previous page: [[LabQSM#Getting Started]]<br />
<br />
==Machine setup==<br />
<br />
In order to go through this tutorial you need to have access to a Unix/Linux machine, where you can run Unix terminals. <br />
Software-wise, one needs the following: <br />
* One '''quantum engine''', i.e. a software able to run quantum mechanical DFT simulations. Here we consider [http://www.quantum-espresso.org Quantum ESPRESSO] (QE). During this class we'll be using QE-v6.5, though any version newer that 6.0 would do. <br />
* '''Structure visualization and builders''': applications like [http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA](QE compatible structure visualization) and [https://avogadro.cc Avogadro] (molecular editor) will be used in the more advanced part of the class.<br />
<br />
* General purpose '''scientific plotting tools'''. At least one of the following SW should be available: [https://plasma-gate.weizmann.ac.il/Grace/ (XM)Grace], [http://www.gnuplot.info Gnuplot], or python with [https://matplotlib.org matplotlib] support.<br />
<br />
<br />
Several options are available:<br />
* Opt0: Using the '''machines in the Lab''';<br />
* Opt1: Using the '''Quantum Mobile''' virtual machine (VM);<br />
* Opt2: Connecting to '''existing machines''', compliant with the class, as provided by the tutors<br />
* Opt3: Installing '''your own machine'''<br />
<br />
<br />
=== Opt1: Using Quantum Mobile ===<br />
<br />
Quantum mobile is a ready-to-go VM, thought to provide all MaX flagship codes (incl QE) together with AiiDA seamlessly integrated in a plug-and-play linux (Ubuntu) environment. Quantum Mobile is [https://www.materialscloud.org/work/quantum-mobile available] on the [https://www.materialscloud.org MaterialsCloud] portal.<br />
<br />
Step by step installation:<br />
* Download the latest version of Quantum Mobile, following the link here: [https://quantum-mobile.readthedocs.io/ https://quantum-mobile.readthedocs.io/]. By doing this you'll obtain a VM image.<br />
* If not available, install [https://www.virtualbox.org VirtualBox] to run the Quantum Mobile VM.<br />
* Double click on the Quantum Mobile and follow the instruction to start the VM.<br />
* At this point, after few minutes, you should see a virtualised Ubuntu OS. By opening a terminal you'll see that pw.x (and the other required executables) are available. Among others, all executables from the QE distribution, XcrySDen, Grace, gnuplot, and python are all pre-installed.<br />
* The unix accounting within the VM is as follows: <br />
user: max passwd: moritz<br />
* The Ubuntu OS comes with US language by default including US keyboard. If you have an Italian keyboard you need to select it by clicking on Setting->Region & Language -> Input source. You need to search and select the Italian language. Once you have set the Italian language, move it as first of the list and you will be able to switch to the Italian keyboard clicking on the keyboard icon in the top right of your screen<br />
* Further information about Quantum Mobile installation can be found here: [https://github.com/marvel-nccr/quantum-mobile/releases/ https://github.com/marvel-nccr/quantum-mobile/releases/].<br />
<br />
<br />
In order to use python to plot and fit data, it is also recommended to update python packages running the following:<br />
* open a terminal<br />
* become super-user typing<br />
$> sudo bash<br />
* install python modules<br />
$> pip3 install numpy<br />
$> pip3 install matplotlib<br />
$> pip3 install scipy<br />
<br />
Similarly, the visualization SW ''Avogadro'' can be installed using sudo + app-get, as described in [[Plotting_and_visualization_tools#Avogadro]].<br />
<br />
=== Opt2: Connecting to existing machines ===<br />
<br />
In order to follow this path, you need the following information:<br />
* the complete name of a running Unix/Linux machine (''<machine>'' in the following), something of the form pluto.fisica.unimo.it<br />
* a unix username (''<user>''), available on the machine<br />
* the username passwd<br />
<br />
With these info, you can login to the remote machine via the ssh protocol by issuing the following command:<br />
ssh -Y ''<user>''@''<machine>'' <br />
<br />
More info about ssh available at [[Warming up with Unix commands#More commands]].<br />
<br />
Note that it would be very useful that the QE executables were placed in the executable path, such that you can e.g. find pw.x by typing:<br />
which pw.x<br />
<br />
Make sure the required python modules (numpy, scipy, matplotlib) are installed, or asked the machine system admin.<br />
<br />
More info about usage and policies of a HPC cluster available at [[Usage of a HPC cluster]].<br />
<br />
=== Opt3: Installing the needed software in your own machine ===<br />
<br />
If you want to use your desktop or laptop, be sure you have the following software installed:<br />
<br />
* [http://www.quantum-espresso.org Quantum ESPRESSO]: <br />
Download one of the latest tarsal archives (e.g. v6.5 or v6.6 from [https://gitlab.com/QEF/q-e/-/tags]), open it, and run the configure script. From command line you can issue:<br />
$> wget https://gitlab.com/QEF/q-e/-/archive/qe-6.5/q-e-qe-6.5.tar.gz<br />
$> tar xvfz q-e-qe-6.5.tar.gz<br />
$> cd q-e-qe-6.5<br />
$> ./configure<br />
$> make pw; make pp<br />
Most of the time the configure script is able to produce a (basic) working configuration even without specifying any flags. In case you want to refine the installation or have some troubles configuring, have a look at the configure manual<br />
$> ./configure --help<br />
<br />
* General purpose '''scientific plotting tools''': python and gnuplot (and in most cases Grace as well) can be installed by using software managers such as apt-get or yum (RedHat/CentOS). For the case of gnuplot<br />
$> sudo apt-get install gnuplot (or)<br />
$> sudo yum install gnuplot (RedHat)<br />
$> brew install gnuplot (Mac Os with [https://brew.sh Homebrew] installed)<br />
* Structure visualization software ([http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA]): check out the download and installation pages of the SW webpage.<br />
<br />
* Following the indications provided for QUantumMobile, install missing python modules if needed (having numpy, scipy, matplotlib can be useful).<br />
<br />
== Training material ==<br />
In order to download the training material needed for these classes, clone the [https://github.com/max-centre/LabCQM LabQSM] repository from [https://github.com/ GitHub], by issuing the command:<br />
$> git clone https://github.com/max-centre/LabQSM.git<br />
<br />
No passed request is be prompted, and a folder called LabQSM is created locally. Inspect the contact of the folder by typing:<br />
$> ls LabQSM/<br />
LAB_1 LICENSE README.md docs tools<br />
<br />
On every new lecture, or when mentioned by the tutors, update the repository by typing:<br />
$> cd LabQSM<br />
$> git pull<br />
<br />
You are now all set and ready to start the hands-on part.<br />
<br />
'''Important notice''': do not edit any of the files contained in the repository unless requested (otherwise you may not be able to update the repository using the git pull command, the presence of local changes conflicting with this git operation).</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Getting_Started&diff=964Getting Started2021-11-16T10:49:01Z<p>Andrea Ferretti: /* Machine setup */</p>
<hr />
<div><br />
* Back to the previous page: [[LabQSM#Getting Started]]<br />
<br />
==Machine setup==<br />
<br />
In order to go through this tutorial you need to have access to a Unix/Linux machine, where you can run Unix terminals. <br />
Software-wise, one needs the following: <br />
* One '''quantum engine''', i.e. a software able to run quantum mechanical DFT simulations. Here we consider [http://www.quantum-espresso.org Quantum ESPRESSO] (QE). During this class we'll be using QE-v6.5, though any version newer that 6.0 would do. <br />
* '''Structure visualization and builders''': applications like [http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA](QE compatible structure visualization) and [https://avogadro.cc Avogadro] (molecular editor) will be used in the more advanced part of the class.<br />
<br />
* General purpose '''scientific plotting tools'''. At least one of the following SW should be available: [https://plasma-gate.weizmann.ac.il/Grace/ (XM)Grace], [http://www.gnuplot.info Gnuplot], or python with [https://matplotlib.org matplotlib] support.<br />
<br />
<br />
Several options are available:<br />
* Opt0: Using the machines in the Lab;<br />
* Opt1: Using the '''Quantum Mobile''' virtual machine (VM);<br />
* Opt2: Connecting to '''existing machines''', compliant with the class, as provided by the tutors<br />
* Opt3: Installing '''your own machine'''<br />
<br />
<br />
=== Opt1: Using Quantum Mobile ===<br />
<br />
Quantum mobile is a ready-to-go VM, thought to provide all MaX flagship codes (incl QE) together with AiiDA seamlessly integrated in a plug-and-play linux (Ubuntu) environment. Quantum Mobile is [https://www.materialscloud.org/work/quantum-mobile available] on the [https://www.materialscloud.org MaterialsCloud] portal.<br />
<br />
Step by step installation:<br />
* Download the latest version of Quantum Mobile, following the link here: [https://quantum-mobile.readthedocs.io/ https://quantum-mobile.readthedocs.io/]. By doing this you'll obtain a VM image.<br />
* If not available, install [https://www.virtualbox.org VirtualBox] to run the Quantum Mobile VM.<br />
* Double click on the Quantum Mobile and follow the instruction to start the VM.<br />
* At this point, after few minutes, you should see a virtualised Ubuntu OS. By opening a terminal you'll see that pw.x (and the other required executables) are available. Among others, all executables from the QE distribution, XcrySDen, Grace, gnuplot, and python are all pre-installed.<br />
* The unix accounting within the VM is as follows: <br />
user: max passwd: moritz<br />
* The Ubuntu OS comes with US language by default including US keyboard. If you have an Italian keyboard you need to select it by clicking on Setting->Region & Language -> Input source. You need to search and select the Italian language. Once you have set the Italian language, move it as first of the list and you will be able to switch to the Italian keyboard clicking on the keyboard icon in the top right of your screen<br />
* Further information about Quantum Mobile installation can be found here: [https://github.com/marvel-nccr/quantum-mobile/releases/ https://github.com/marvel-nccr/quantum-mobile/releases/].<br />
<br />
<br />
In order to use python to plot and fit data, it is also recommended to update python packages running the following:<br />
* open a terminal<br />
* become super-user typing<br />
$> sudo bash<br />
* install python modules<br />
$> pip3 install numpy<br />
$> pip3 install matplotlib<br />
$> pip3 install scipy<br />
<br />
Similarly, the visualization SW ''Avogadro'' can be installed using sudo + app-get, as described in [[Plotting_and_visualization_tools#Avogadro]].<br />
<br />
=== Opt2: Connecting to existing machines ===<br />
<br />
In order to follow this path, you need the following information:<br />
* the complete name of a running Unix/Linux machine (''<machine>'' in the following), something of the form pluto.fisica.unimo.it<br />
* a unix username (''<user>''), available on the machine<br />
* the username passwd<br />
<br />
With these info, you can login to the remote machine via the ssh protocol by issuing the following command:<br />
ssh -Y ''<user>''@''<machine>'' <br />
<br />
More info about ssh available at [[Warming up with Unix commands#More commands]].<br />
<br />
Note that it would be very useful that the QE executables were placed in the executable path, such that you can e.g. find pw.x by typing:<br />
which pw.x<br />
<br />
Make sure the required python modules (numpy, scipy, matplotlib) are installed, or asked the machine system admin.<br />
<br />
More info about usage and policies of a HPC cluster available at [[Usage of a HPC cluster]].<br />
<br />
=== Opt3: Installing the needed software in your own machine ===<br />
<br />
If you want to use your desktop or laptop, be sure you have the following software installed:<br />
<br />
* [http://www.quantum-espresso.org Quantum ESPRESSO]: <br />
Download one of the latest tarsal archives (e.g. v6.5 or v6.6 from [https://gitlab.com/QEF/q-e/-/tags]), open it, and run the configure script. From command line you can issue:<br />
$> wget https://gitlab.com/QEF/q-e/-/archive/qe-6.5/q-e-qe-6.5.tar.gz<br />
$> tar xvfz q-e-qe-6.5.tar.gz<br />
$> cd q-e-qe-6.5<br />
$> ./configure<br />
$> make pw; make pp<br />
Most of the time the configure script is able to produce a (basic) working configuration even without specifying any flags. In case you want to refine the installation or have some troubles configuring, have a look at the configure manual<br />
$> ./configure --help<br />
<br />
* General purpose '''scientific plotting tools''': python and gnuplot (and in most cases Grace as well) can be installed by using software managers such as apt-get or yum (RedHat/CentOS). For the case of gnuplot<br />
$> sudo apt-get install gnuplot (or)<br />
$> sudo yum install gnuplot (RedHat)<br />
$> brew install gnuplot (Mac Os with [https://brew.sh Homebrew] installed)<br />
* Structure visualization software ([http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA]): check out the download and installation pages of the SW webpage.<br />
<br />
* Following the indications provided for QUantumMobile, install missing python modules if needed (having numpy, scipy, matplotlib can be useful).<br />
<br />
== Training material ==<br />
In order to download the training material needed for these classes, clone the [https://github.com/max-centre/LabCQM LabQSM] repository from [https://github.com/ GitHub], by issuing the command:<br />
$> git clone https://github.com/max-centre/LabQSM.git<br />
<br />
No passed request is be prompted, and a folder called LabQSM is created locally. Inspect the contact of the folder by typing:<br />
$> ls LabQSM/<br />
LAB_1 LICENSE README.md docs tools<br />
<br />
On every new lecture, or when mentioned by the tutors, update the repository by typing:<br />
$> cd LabQSM<br />
$> git pull<br />
<br />
You are now all set and ready to start the hands-on part.<br />
<br />
'''Important notice''': do not edit any of the files contained in the repository unless requested (otherwise you may not be able to update the repository using the git pull command, the presence of local changes conflicting with this git operation).</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=963Usage of a HPC cluster2021-04-30T07:37:04Z<p>Andrea Ferretti: /* Environment */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The '''structure of a HPC system''' is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
* the above cluster structure is used from commodity local machines to large scale HPC architectures (as shown below for the Summit machine at Oak-Ridge Natl Lab (ORNL), TN, USA)<br />
<br />
[[File:Summit-ONL.jpg|300px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node<br />
<machine_host_name>: hostname (or IP) of the target HPC machine <br />
<br />
In order to access you need to have a working Unix username and passwd on the target machine.<br />
<br />
==Scheduler==<br />
<br />
Multiple schedulers are available. Examples include PBS Torque, IBM LoadLeveler and SLURM.<br />
Here we just cover some examples, providing the main commands to be used within the shell.<br />
<br />
===PBS Torque===<br />
* submitting a job<br />
qsub file.sh<br />
<br />
* monitoring a job<br />
qstat # general query, all jobs are shown<br />
qstat -u $USER # only my jobs<br />
qstat JID<br />
<br />
* checking queue properties<br />
qstat -q<br />
<br />
* deleting a job<br />
qdel JID<br />
<br />
JID (Job ID) is given by qstat<br />
<br />
* Interactive use on compute nodes<br />
qsub -I -q <queue_name><br />
<br />
==Environment==<br />
<br />
Use the <code>module</code> command to manage the unix environment<br />
<br />
Make sure you load a proper parallel environment (incl MPI-aware compilers)<br />
<br />
One example:<br />
<br />
module purge<br />
module load psxe_2020 # Intel 2020 compiler<br />
module load <more modules you are interested in, e.g. incl some QE distribution><br />
<br />
These commands can be also place in the .bashrc file and most of the time need to be present<br />
in submission scripts<br />
<br />
In order to enquire the module system:<br />
module list # lists loaded modules<br />
module avail # lists available modules</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=962Usage of a HPC cluster2021-04-30T07:36:18Z<p>Andrea Ferretti: /* Environment */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The '''structure of a HPC system''' is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
* the above cluster structure is used from commodity local machines to large scale HPC architectures (as shown below for the Summit machine at Oak-Ridge Natl Lab (ORNL), TN, USA)<br />
<br />
[[File:Summit-ONL.jpg|300px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node<br />
<machine_host_name>: hostname (or IP) of the target HPC machine <br />
<br />
In order to access you need to have a working Unix username and passwd on the target machine.<br />
<br />
==Scheduler==<br />
<br />
Multiple schedulers are available. Examples include PBS Torque, IBM LoadLeveler and SLURM.<br />
Here we just cover some examples, providing the main commands to be used within the shell.<br />
<br />
===PBS Torque===<br />
* submitting a job<br />
qsub file.sh<br />
<br />
* monitoring a job<br />
qstat # general query, all jobs are shown<br />
qstat -u $USER # only my jobs<br />
qstat JID<br />
<br />
* checking queue properties<br />
qstat -q<br />
<br />
* deleting a job<br />
qdel JID<br />
<br />
JID (Job ID) is given by qstat<br />
<br />
* Interactive use on compute nodes<br />
qsub -I -q <queue_name><br />
<br />
==Environment==<br />
<br />
Use the <code>module</code> command to manage the unix environment<br />
<br />
Make sure you load a proper parallel environment (incl MPI-aware compilers)<br />
<br />
Some examples:<br />
<br />
module purge<br />
module load psxe_2020<br />
<br />
These commands can be also place in the .bashrc file and most of the time need to be present<br />
in submission scripts<br />
<br />
In order to enquire the module system:<br />
module list # lists loaded modules<br />
module avail # lists available modules</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=961Usage of a HPC cluster2021-04-30T07:29:04Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The '''structure of a HPC system''' is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
* the above cluster structure is used from commodity local machines to large scale HPC architectures (as shown below for the Summit machine at Oak-Ridge Natl Lab (ORNL), TN, USA)<br />
<br />
[[File:Summit-ONL.jpg|300px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node<br />
<machine_host_name>: hostname (or IP) of the target HPC machine <br />
<br />
In order to access you need to have a working Unix username and passwd on the target machine.<br />
<br />
==Scheduler==<br />
<br />
Multiple schedulers are available. Examples include PBS Torque, IBM LoadLeveler and SLURM.<br />
Here we just cover some examples, providing the main commands to be used within the shell.<br />
<br />
===PBS Torque===<br />
* submitting a job<br />
qsub file.sh<br />
<br />
* monitoring a job<br />
qstat # general query, all jobs are shown<br />
qstat -u $USER # only my jobs<br />
qstat JID<br />
<br />
* checking queue properties<br />
qstat -q<br />
<br />
* deleting a job<br />
qdel JID<br />
<br />
JID (Job ID) is given by qstat<br />
<br />
* Interactive use on compute nodes<br />
qsub -I -q <queue_name><br />
<br />
==Environment==<br />
<br />
Use the <code>module</code> command to manage the unix environment<br />
<br />
Make sure you load a proper parallel environment (incl MPI-aware compilers)<br />
<br />
Some examples:<br />
<br />
module purge<br />
module load psxe_2015<br />
<br />
These commands can be also place in the .bashrc file and most of the time need to be present<br />
in submission scripts<br />
<br />
In order to enquire the module system:<br />
module list # lists loaded modules<br />
module avail # lists available modules</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=960Usage of a HPC cluster2021-04-30T07:17:47Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The '''structure of a HPC system''' is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
* the above cluster structure is used from commodity local machines to large scale HPC architectures (as shown below for the Summit machine at Oak-Ridge Natl Lab (ORNL), TN, USA)<br />
<br />
[[File:Summit-ONL.jpg|300px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=File:Summit-ONL.jpg&diff=959File:Summit-ONL.jpg2021-04-30T07:17:02Z<p>Andrea Ferretti: </p>
<hr />
<div></div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=958Usage of a HPC cluster2021-04-30T07:16:39Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The '''structure of a HPC system''' is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
* the above cluster structure is used from commodity local machines to large scale HPC architectures (as shown below for the Summit machine at Oak-Ridge Natl Lab (ORNL), TN, USA)<br />
<br />
[[File:Summit ORNL.jpg|300px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=957Usage of a HPC cluster2021-04-30T07:10:23Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The structure of a HPC system is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a ''login node'' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated ''scheduler'' (the ''queuing system'') dispatches computational jobs to the ''compute nodes''<br />
* computation happens therefore asynchronously (in batch mode), and not on the login node.<br />
* a specific ''software environment'' is provided on the login node and on the compute node to run parallel jobs<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=956Usage of a HPC cluster2021-04-30T07:09:43Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
The structure of a HPC system is sketched in the picture above. <br />
These are the main logical building blocks:<br />
<br />
* a 'login node' is exposed to users for access (typically via <code>ssh</code>), <br />
* a dedicated 'scheduler' (the 'queuing system') dispatches computational jobs to the 'compute nodes'<br />
* computation happens therefore asynchronously, and not on the login node.<br />
* a specific 'software environment' is provided on the login node and on the compute node to run parallel jobs<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=955Usage of a HPC cluster2021-04-30T07:03:55Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|500px|top]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=954Usage of a HPC cluster2021-04-30T07:03:35Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|300px|left]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=953Usage of a HPC cluster2021-04-30T07:03:25Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|thumb|300px|left]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=952Usage of a HPC cluster2021-04-30T06:37:50Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
<br />
* Prev: [[LabQSM#Getting Started]]<br />
* Next: [[Scripting]]<br />
<br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
[[File:Logical structure HPC cluster.png|thumb|150px|left]]<br />
<br />
<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=951Usage of a HPC cluster2021-04-30T06:37:24Z<p>Andrea Ferretti: /* Structure of a HPC cluster */</p>
<hr />
<div><br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
<br />
[[File:Logical structure HPC cluster.png|thumb|150px|left]]<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=File:Structure_HPC_cluster.png&diff=950File:Structure HPC cluster.png2021-04-30T06:35:05Z<p>Andrea Ferretti: structure of a HPC cluster. source: https://www.keralauniversity.ac.in/hpc</p>
<hr />
<div>== Summary ==<br />
structure of a HPC cluster. source: https://www.keralauniversity.ac.in/hpc</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=File:Logical_structure_HPC_cluster.png&diff=949File:Logical structure HPC cluster.png2021-04-30T06:33:48Z<p>Andrea Ferretti: Logical structure of a HPC cluster. source: https://docs.hpc.qmul.ac.uk/intro/</p>
<hr />
<div>== Summary ==<br />
Logical structure of a HPC cluster. source: https://docs.hpc.qmul.ac.uk/intro/</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=948Usage of a HPC cluster2021-04-30T06:32:22Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
==Structure of a HPC cluster==<br />
<br />
<br />
<br />
==Connecting==<br />
Unless other means are provided, you typically connect using the <code>ssh</code> protocol.<br />
<br />
From a shell terminal or a suitable app:<br />
<br />
ssh -Y <user>@<machine_host_name> or<br />
ssh -Y -l <user> <machine_host_name><br />
<br />
<user>: Unix username on the cluster login node</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Usage_of_a_HPC_cluster&diff=947Usage of a HPC cluster2021-04-30T06:24:12Z<p>Andrea Ferretti: Created page with " Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster. ** Connecting **"</p>
<hr />
<div><br />
Here we collect some general (and by no means complete) information about usage and policies of a HPC cluster.<br />
<br />
** Connecting **</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Getting_Started&diff=946Getting Started2021-04-30T06:22:49Z<p>Andrea Ferretti: /* Opt2: Connecting to existing machines */</p>
<hr />
<div><br />
* Back to the previous page: [[LabQSM#Getting Started]]<br />
<br />
==Machine setup==<br />
<br />
In order to go through this tutorial you need to have access to a Unix/Linux machine, where you can run Unix terminals. <br />
Software-wise, one needs the following: <br />
* One '''quantum engine''', i.e. a software able to run quantum mechanical DFT simulations. Here we consider [http://www.quantum-espresso.org Quantum ESPRESSO] (QE). During this class we'll be using QE-v6.5, though any version newer that 6.0 would do. <br />
* '''Structure visualization and builders''': applications like [http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA](QE compatible structure visualization) and [https://avogadro.cc Avogadro] (molecular editor) will be used in the more advanced part of the class.<br />
<br />
* General purpose '''scientific plotting tools'''. At least one of the following SW should be available: [https://plasma-gate.weizmann.ac.il/Grace/ (XM)Grace], [http://www.gnuplot.info Gnuplot], or python with [https://matplotlib.org matplotlib] support.<br />
<br />
<br />
Several options are available:<br />
* Opt1: Using the '''Quantum Mobile''' virtual machine (VM);<br />
* Opt2: Connecting to '''existing machines''', compliant with the class, as provided by the tutors<br />
* Opt3: Installing '''your own machine'''<br />
<br />
<br />
=== Opt1: Using Quantum Mobile ===<br />
<br />
Quantum mobile is a ready-to-go VM, thought to provide all MaX flagship codes (incl QE) together with AiiDA seamlessly integrated in a plug-and-play linux (Ubuntu) environment. Quantum Mobile is [https://www.materialscloud.org/work/quantum-mobile available] on the [https://www.materialscloud.org MaterialsCloud] portal.<br />
<br />
Step by step installation:<br />
* Download the latest version of Quantum Mobile, following the link here: [https://quantum-mobile.readthedocs.io/ https://quantum-mobile.readthedocs.io/]. By doing this you'll obtain a VM image.<br />
* If not available, install [https://www.virtualbox.org VirtualBox] to run the Quantum Mobile VM.<br />
* Double click on the Quantum Mobile and follow the instruction to start the VM.<br />
* At this point, after few minutes, you should see a virtualised Ubuntu OS. By opening a terminal you'll see that pw.x (and the other required executables) are available. Among others, all executables from the QE distribution, XcrySDen, Grace, gnuplot, and python are all pre-installed.<br />
* The unix accounting within the VM is as follows: <br />
user: max passwd: moritz<br />
* The Ubuntu OS comes with US language by default including US keyboard. If you have an Italian keyboard you need to select it by clicking on Setting->Region & Language -> Input source. You need to search and select the Italian language. Once you have set the Italian language, move it as first of the list and you will be able to switch to the Italian keyboard clicking on the keyboard icon in the top right of your screen<br />
* Further information about Quantum Mobile installation can be found here: [https://github.com/marvel-nccr/quantum-mobile/releases/ https://github.com/marvel-nccr/quantum-mobile/releases/].<br />
<br />
<br />
In order to use python to plot and fit data, it is also recommended to update python packages running the following:<br />
* open a terminal<br />
* become super-user typing<br />
$> sudo bash<br />
* install python modules<br />
$> pip3 install numpy<br />
$> pip3 install matplotlib<br />
$> pip3 install scipy<br />
<br />
Similarly, the visualization SW ''Avogadro'' can be installed using sudo + app-get, as described in [[Plotting_and_visualization_tools#Avogadro]].<br />
<br />
=== Opt2: Connecting to existing machines ===<br />
<br />
In order to follow this path, you need the following information:<br />
* the complete name of a running Unix/Linux machine (''<machine>'' in the following), something of the form pluto.fisica.unimo.it<br />
* a unix username (''<user>''), available on the machine<br />
* the username passwd<br />
<br />
With these info, you can login to the remote machine via the ssh protocol by issuing the following command:<br />
ssh -Y ''<user>''@''<machine>'' <br />
<br />
More info about ssh available at [[Warming up with Unix commands#More commands]].<br />
<br />
Note that it would be very useful that the QE executables were placed in the executable path, such that you can e.g. find pw.x by typing:<br />
which pw.x<br />
<br />
Make sure the required python modules (numpy, scipy, matplotlib) are installed, or asked the machine system admin.<br />
<br />
More info about usage and policies of a HPC cluster available at [[Usage of a HPC cluster]].<br />
<br />
=== Opt3: Installing the needed software in your own machine ===<br />
<br />
If you want to use your desktop or laptop, be sure you have the following software installed:<br />
<br />
* [http://www.quantum-espresso.org Quantum ESPRESSO]: <br />
Download one of the latest tarsal archives (e.g. v6.5 or v6.6 from [https://gitlab.com/QEF/q-e/-/tags]), open it, and run the configure script. From command line you can issue:<br />
$> wget https://gitlab.com/QEF/q-e/-/archive/qe-6.5/q-e-qe-6.5.tar.gz<br />
$> tar xvfz q-e-qe-6.5.tar.gz<br />
$> cd q-e-qe-6.5<br />
$> ./configure<br />
$> make pw; make pp<br />
Most of the time the configure script is able to produce a (basic) working configuration even without specifying any flags. In case you want to refine the installation or have some troubles configuring, have a look at the configure manual<br />
$> ./configure --help<br />
<br />
* General purpose '''scientific plotting tools''': python and gnuplot (and in most cases Grace as well) can be installed by using software managers such as apt-get or yum (RedHat/CentOS). For the case of gnuplot<br />
$> sudo apt-get install gnuplot (or)<br />
$> sudo yum install gnuplot (RedHat)<br />
$> brew install gnuplot (Mac Os with [https://brew.sh Homebrew] installed)<br />
* Structure visualization software ([http://www.xcrysden.org XcrySDen] or [https://jp-minerals.org/vesta/en/ VESTA]): check out the download and installation pages of the SW webpage.<br />
<br />
* Following the indications provided for QUantumMobile, install missing python modules if needed (having numpy, scipy, matplotlib can be useful).<br />
<br />
<br />
== Training material ==<br />
In order to download the training material needed for these classes, clone the [https://github.com/max-centre/LabCQM LabQSM] repository from [https://github.com/ GitHub], by issuing the command:<br />
$> git clone https://github.com/max-centre/LabQSM.git<br />
<br />
No passed request is be prompted, and a folder called LabQSM is created locally. Inspect the contact of the folder by typing:<br />
$> ls LabQSM/<br />
LAB_1 LICENSE README.md docs tools<br />
<br />
On every new lecture, or when mentioned by the tutors, update the repository by typing:<br />
$> cd LabQSM<br />
$> git pull<br />
<br />
You are now all set and ready to start the hands-on part.<br />
<br />
'''Important notice''': do not edit any of the files contained in the repository unless requested (otherwise you may not be able to update the repository using the git pull command, the presence of local changes conflicting with this git operation).</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_4&diff=783Solution LAB2 guanine 42021-03-26T11:18:47Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 4]]<br />
<br />
An example of input file for <code>pp.x</code> to plot the HOMO of guanine (pp_HOMO.in) follows:<br />
<br />
&INPUTPP<br />
prefix="guanine_DFT"<br />
outdir="./SCRATCH"<br />
plot_num=7<br />
filplot = "wfc_HOMO.pp"<br />
kband=28<br />
kpoint=1<br />
lsign=.true.<br />
/<br />
&PLOT<br />
nfile=1<br />
filepp(1)="wfc_HOMO.pp"<br />
iflag=3<br />
output_format=5<br />
fileout="wfc_HOMO.xsf"<br />
/<br />
<br />
by running as<br />
pp.x < pp_HOMO.in > pp_HOMO.out<br />
<br />
should produce as output the file <code>wfc_HOMO.xsf</code> that can be plotted using <code>xcrysden</code>.<br />
<br />
Here is a sketch of the guanine HOMO isosurface:<br />
[[File:Guanine HOMO.png|none|300px|top|]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_4&diff=782Solution LAB2 guanine 42021-03-26T11:18:35Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 4]]<br />
<br />
An example of input file for <code>pp.x</code> to plot the HOMO of guanine (pp_HOMO.in) follows:<br />
<br />
&INPUTPP<br />
prefix="guanine_DFT"<br />
outdir="./SCRATCH"<br />
plot_num=7<br />
filplot = "wfc_HOMO.pp"<br />
kband=28<br />
kpoint=1<br />
lsign=.true.<br />
/<br />
&PLOT<br />
nfile=1<br />
filepp(1)="wfc_HOMO.pp"<br />
iflag=3<br />
output_format=5<br />
fileout="wfc_HOMO.xsf"<br />
/<br />
<br />
by running as<br />
pp.x < pp_HOMO.in > pp_HOMO.out<br />
<br />
should produce as output the file <code>wfc_HOMO.xsf</code> that can be plotted using <code>xcrysden</code>.<br />
<br />
Here is a sketch of the guanine HOMO isosurface:<br />
[[File:Guanine HOMO.png|none|400px|top|]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=File:Guanine_HOMO.png&diff=781File:Guanine HOMO.png2021-03-26T11:16:12Z<p>Andrea Ferretti: plot of the guanine HOMO</p>
<hr />
<div>== Summary ==<br />
plot of the guanine HOMO</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_4&diff=780Solution LAB2 guanine 42021-03-26T10:58:50Z<p>Andrea Ferretti: Created page with " * Back to the previous page: Electronic properties of isolated molecules#Exercise 4 An example of input file for <code>pp.x</code> to plot the HOMO of guanine (pp_HOMO.i..."</p>
<hr />
<div><br />
* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 4]]<br />
<br />
An example of input file for <code>pp.x</code> to plot the HOMO of guanine (pp_HOMO.in) follows:<br />
<br />
&INPUTPP<br />
prefix="guanine_DFT"<br />
outdir="./SCRATCH"<br />
plot_num=7<br />
filplot = "wfc_HOMO.pp"<br />
kband=28<br />
kpoint=1<br />
lsign=.true.<br />
/<br />
&PLOT<br />
nfile=1<br />
filepp(1)="wfc_HOMO.pp"<br />
iflag=3<br />
output_format=5<br />
fileout="wfc_HOMO.xsf"<br />
/<br />
<br />
by running as<br />
pp.x < pp_HOMO.in > pp_HOMO.out<br />
<br />
should produce as output the file <code>wfc_HOMO.xsf</code> that can be plotted using <code>xcrysden</code>.</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=779Electronic properties of isolated molecules2021-03-26T10:56:09Z<p>Andrea Ferretti: /* Exercises */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Setup a DFT calculation with the guanine structure obtained from Avogradro (check both the amount of vacuum and the kinetic energy cutoff to be used)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
For a review on the topic see: [https://pubs.rsc.org/de/content/articlelanding/2020/cp/d0cp02564j#!divAbstract L. Krnoik and S: Kummel Piecewise linearity, freedom from self-interaction, and a Coulomb asymptotic potential: three related yet inequivalent properties of the exact density functional. Phys. Chem. Chem. Phys. 22, 16467 (2020)]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ] <br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How do the HOMO and LUMO orbitals look like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool + sumpdos.x)<br />
<br />
[[Solution_LAB2_guanine_4 | Hints]]<br />
<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=778Electronic properties of isolated molecules2021-03-26T10:44:42Z<p>Andrea Ferretti: /* Exercises */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Setup a DFT calculation with the guanine structure obtained from Avogradro (check both the amount of vacuum and the kinetic energy cutoff to be used)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
For a review on the topic see: [https://pubs.rsc.org/de/content/articlelanding/2020/cp/d0cp02564j#!divAbstract L. Krnoik and S: Kummel Piecewise linearity, freedom from self-interaction, and a Coulomb asymptotic potential: three related yet inequivalent properties of the exact density functional. Phys. Chem. Chem. Phys. 22, 16467 (2020)]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ] <br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How do the HOMO and LUMO orbitals look like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool + sumpdos.x)<br />
<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=777Electronic properties of isolated molecules2021-03-26T10:42:23Z<p>Andrea Ferretti: /* Exercise 4 */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Setup a DFT calculation with the guanine structure obtained from Avogradro (check both the amount of vacuum and the kinetic energy cutoff to be used)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
For a review on the topic see: [https://pubs.rsc.org/de/content/articlelanding/2020/cp/d0cp02564j#!divAbstract L. Krnoik and S: Kummel Piecewise linearity, freedom from self-interaction, and a Coulomb asymptotic potential: three related yet inequivalent properties of the exact density functional. Phys. Chem. Chem. Phys. 22, 16467 (2020)]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ] <br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How do the HOMO and LUMO orbitals look like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool + sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_3&diff=776Solution LAB2 guanine 32021-03-26T10:36:38Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 3]]<br />
<br />
For calculation of E(N-1) we need to set the following flags in the &SYSTEM namelist:<br />
<br />
nspin=2 ! Note, now we have unpaired electrons:<br />
tot_charge=+1 ! charged system<br />
tot_magnetization=1 ! we need to set a total magnetisation<br />
<br />
Also, the following option needs to be used for charged systems :<br />
assume_isolated="mt"<br />
<br />
Using ecutwfc=50 Ry and 35 au of cell size,<br />
E_tot(N) = -193.48101821 Ry <br />
E_tot(N-1) = -192.89782124 Ry<br />
<br />
giving <br />
IP = E_tot(N-1) - E_tot(N)<br />
= 0.58319697 Ry<br />
= 7.934861 eV<br />
<br />
now much closer to the experimental value of 8.0-8.3 eV.<br />
<br />
Interestingly, one can run the same set of calculations also using different functionals, <br />
including GGAs (PBE), meta-GGAs (eg TPSS or SCAN), hybrids (PBE0), or HF itself.<br />
<br />
In order to do this, you can force e.g. the functional from input, by using:<br />
<br />
&SYSTEM<br />
[...]<br />
input_dft="PBE0"<br />
/<br />
<br />
How do -eps_HOMO and delta-scf values compare ?</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_3&diff=775Solution LAB2 guanine 32021-03-26T10:33:38Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 3]]<br />
<br />
For calculation of E(N-1) we need to set the following flags in the &SYSTEM namelist:<br />
<br />
nspin=2 ! Note, now we have unpaired electrons:<br />
tot_charge=+1 ! charged system<br />
tot_magnetization=1 ! we need to set a total magnetisation<br />
<br />
Also, the following option needs to be used for charged systems :<br />
assume_isolated="mt"<br />
<br />
Using ecutwfc=50 Ry and 35 au of cell size,<br />
E_tot(N) = <br />
E_tot(N-1) = -192.89782124 Ry<br />
<br />
giving <br />
<br />
Interestingly, one can run the same set of calculations also using different functionals, <br />
including GGAs (PBE), meta-GGAs (eg TPSS or SCAN), hybrids (PBE0), or HF itself.<br />
<br />
In order to do this, you can force e.g. the functional from input, by using:<br />
<br />
&SYSTEM<br />
[...]<br />
input_dft="PBE0"<br />
/<br />
<br />
How do -eps_HOMO and delta-scf values compare ?</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_3&diff=774Solution LAB2 guanine 32021-03-26T09:52:37Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 3]]<br />
<br />
For calculation of E(N-1) we need to set the following flags in the &SYSTEM namelist:<br />
<br />
nspin=2 ! Note, now we have unpaired electrons:<br />
tot_charge=+1 ! charged system<br />
tot_magnetization=1 ! we need to set a total magnetisation<br />
<br />
Also, the following option needs to be used for charged systems :<br />
assume_isolated="mt"</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine_3&diff=773Solution LAB2 guanine 32021-03-26T09:52:23Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 3]]<br />
<br />
For calculation of E(N-1) we need to set the following flags in the &SYSTEM namelist:<br />
<br />
nspin=2 ! Note, now we have unpaired electrons:<br />
tot_charge=+1 ! charged system<br />
tot_magnetization=1 ! we need to set a total magnetisation<br />
<br />
Also, the following option needs to be used for charged systems :<br />
assume_isolated="mt"</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Solution_LAB2_guanine&diff=772Solution LAB2 guanine2021-03-26T09:28:22Z<p>Andrea Ferretti: </p>
<hr />
<div>* Back to the previous page: [[Electronic properties of isolated molecules#Exercise 1]]<br />
<br />
==Step 1: geometry building==<br />
* Once you have Avogadro installed, open it and let's use the molecular builder to visualise a Guanine molecule:<br />
<br />
Build --> Insert-->Fragment-->nucleobases-->guanine<br />
<br />
Click on the selection settings "arrow" and right click to visualise the molecule. <br />
<br />
Clicking on manipulate settings "hand" you can then rotate the molecule.<br />
<br />
* Now we perform a classical relaxation using an Avogadro built-in Force Filed<br />
<br />
Extension-->Molecular Mechanics and we choose a FF<br />
Extension-->Optimize geometry<br />
<br />
In few steps we have our relaxed geometry that we can save in .xyz format using:<br />
<br />
File-->Save as-->select .xyz format and save in your disk as guanine_FF.xyz<br />
<br />
The result of your FF optimisation should look like the following<br />
<br />
[[File:Snapshot avogadro.png|none|400px|top|]]<br />
<br />
==Step 2==<br />
Now we are ready to perform a DFT simulations. As a first step, update your pseudo potentials directory by using git commands:<br />
<br />
git pull<br />
<br />
new pseudo potentials (Nitrogen and Oxygen) will be downloaded in your pseudo potential directory.<br />
<br />
Create a scf input file (guanine_scf.in) paying attention to:<br />
<br />
ibrav=8 #orthorombic cell with vacuum<br />
celldm(1) = 25.00<br />
celldm(2) = 1.0<br />
celldm(3) = 0.8<br />
<br />
Set the correct number and types of atoms.<br />
Set all the atomic species using the psuedo you have downloaded:<br />
<br />
H 1.0 H.pz-vbc.UPF<br />
C 1.0 C.pz-vbc.UPF<br />
N 1.0 N.pz-vbc.UPF<br />
O 1.0 O.pz-mt.UPF<br />
<br />
insert the atomic positions in Angstrom:<br />
<br />
ATOMIC_POSITIONS (angstrom)<br />
<br />
'''Important''': <br />
* How many '''k'''-points you need?<br />
* the amount of vacuum needs to be converged<br />
* same for the kinetic energy cutoff (note that here we can use the value of the total force as a convergence parameter)<br />
<br />
# ecutwfc Ry<br />
40 Total force = 0.316709 Total SCF correction = 0.000067<br />
50 Total force = 0.315474 Total SCF correction = 0.000089<br />
60 Total force = 0.319550 Total SCF correction = 0.000100<br />
80 Total force = 0.322261 Total SCF correction = 0.000098<br />
100 Total force = 0.323131 Total SCF correction = 0.000119<br />
120 Total force = 0.323153 Total SCF correction = 0.000140<br />
<br />
Despite 60-80 Ry seem to be appropriate, here we decide to use <code>ecutwfc=50</code> in order to keep the calculation time under control.<br />
<br />
<br />
==Step 3==<br />
We can now run a QM relaxation using DFT.<br />
Edit the input file according to:<br />
&CONTROL<br />
[...]<br />
calculation="relax"<br />
etot_conv_thr=1.0D-4<br />
forc_conv_thr=1.0D-3<br />
# we set a medium-tight threshold in order not to have a too long calculation<br />
/<br />
and add the <code>&IONS</code> namelist.<br />
<br />
Run the relaxation, it will take a while to rearrange the atoms in the relaxed positions according to the threshold parameter.<br />
<br />
$> pw.x < guanine_relax.in > guanine_relax.out & <br />
<br />
One the job has converged you can compare the initial position (Force Field relaxed) with the final ones (QM relaxed). You can use xcrysden to visualise the optimisation steps.<br />
<br />
xcrysden --pwo guanine_relax.out<br />
<br />
you can reduce the dimensionality to 0D and choose the option: Display All Coordinates as Animation<br />
In this way you will have a movie of the molecule relaxation</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=771Electronic properties of isolated molecules2021-03-26T08:54:51Z<p>Andrea Ferretti: /* Exercise 1 */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Setup a DFT calculation with the guanine structure obtained from Avogradro (check both the amount of vacuum and the kinetic energy cutoff to be used)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
For a review on the topic see: [https://pubs.rsc.org/de/content/articlelanding/2020/cp/d0cp02564j#!divAbstract L. Krnoik and S: Kummel Piecewise linearity, freedom from self-interaction, and a Coulomb asymptotic potential: three related yet inequivalent properties of the exact density functional. Phys. Chem. Chem. Phys. 22, 16467 (2020)]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ] <br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=769Electronic properties of isolated molecules2021-03-18T22:14:08Z<p>Andrea Ferretti: /* Exercise 3 */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ] <br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=768Electronic properties of isolated molecules2021-03-18T22:13:38Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear (PWL).<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
Computing the IP following the above expression takes the name of Delta-scf.<br />
<br />
Because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
Here the slope of the PWL total energy curve between N-1 and N electrons correspond to the IP computed as a finite difference of total energy.<br />
Instead the slope at integer occupations corresponds to the negative of the HOMO eigenvalue.<br />
<br />
When convexity due to, e.g., LDA or PBE, is present, the HOMO eigenvalue turns out to be less negative (i.e. higher in energy) than it should. <br />
Viceversa for the LUMO (too deep). These behaviours are also connected to an over-delocalization (then leading eg also to over-hybridisation) <br />
error of the orbitals and of the charge density.<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=767Electronic properties of isolated molecules2021-03-18T22:06:28Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear.<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
and, because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear (PWL) but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|350px|top|]]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=File:PWL_plot.png&diff=766File:PWL plot.png2021-03-18T22:05:27Z<p>Andrea Ferretti: </p>
<hr />
<div></div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=765Electronic properties of isolated molecules2021-03-18T22:05:07Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear.<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
and, because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear (PWL) but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
[[File:PWL plot.png|none|500px|top|]]<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=764Electronic properties of isolated molecules2021-03-18T22:04:30Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear.<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
and, because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear (PWL) but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=763Electronic properties of isolated molecules2021-03-18T22:04:19Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear.<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
and, because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear (PWL) but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=762Electronic properties of isolated molecules2021-03-18T22:04:01Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
dE[n]/df_i = eps_i where<br />
n(r) = sum_i f_i * |psi_i(r)|^2<br />
<br />
i.e, the derivative of the total energy wrt a fractional occupation of the i-th orbital equals the i-th eigenvalue.<br />
As a total derivative, this makes sense when considering the occupation of the HOMO and gives a physical meaning to<br />
the HOMO eigenvalue.<br />
<br />
The total energy can also be extended to fractional number of electrons (making a statistical mixture of systems at N and N-1<br />
electrons), and should be piece-wise linear.<br />
<br />
The ionisation potential is defined as<br />
<br />
IP = E[N-1] -E[N]<br />
<br />
and, because of Janak's theorem, one should also have:<br />
<br />
IP = -eps_HOMO<br />
<br />
While the two methods should give the same result in exact KS-DFT, when approximate functionals are used this is<br />
no longer true. In particular, the total energy is no longer piece-wise-linear (PWL) but convex (for standard local and semi local functionals).<br />
This is depicted in the figure below.<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=761Electronic properties of isolated molecules2021-03-18T21:46:23Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<br />
&part E_tot[n]/&part f_i = &epsilon i where<br />
n(r) = &sum f_i |&psi(r)|^2<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=760Electronic properties of isolated molecules2021-03-18T21:38:58Z<p>Andrea Ferretti: /* Janak's theorem, Piece-wise Linearity, Ionization potential */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<math><br />
\frac{\partial E_{\text{tot}}[\rho]}{\partial f_i} = \epsilon_i \qquad \text{where}<br />
\rho(\mathbf{r}) = \sum_i f_i |\psi(\mathbf{r})|^2<br />
<\math><br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=759Electronic properties of isolated molecules2021-03-18T21:38:36Z<p>Andrea Ferretti: </p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
<br />
==Janak's theorem, Piece-wise Linearity, Ionization potential==<br />
<br />
Here we try to rationalise the numerical results obtained so far in the evaluation of the ionisation potential as<br />
negative of the HOMO eigenvalue.<br />
<br />
A first important result is related to Janak's theorem, Phys. Rev. B '''18''', 7165 (1978), stating that:<br />
<math><br />
\frac{\partial E_{\text{tot}}[\rho]}{\partial f_i} = \epsilon_i \qquad \text{where}<br />
\rho(\mathbf{r}) = \sum_i f_i |\psi(\mathbf{r})|^2<br />
<\math><br />
<br />
<br />
==Exercises==<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferrettihttp://wiki.max-centre.eu/index.php?title=Electronic_properties_of_isolated_molecules&diff=758Electronic properties of isolated molecules2021-03-18T21:23:53Z<p>Andrea Ferretti: /* Exercise 5 */</p>
<hr />
<div><br />
[[File:Molecule cartoon.png|none|500px|top|]]<br />
<br />
Prev:[[LabQSM#Lecture 2: DFT simulations of Molecules]]<br />
<br />
==Calculation of molecules: Intro==<br />
[[File:Molecule imaging.png|right |thumb | Originals from [http://dx.doi.org/10.1126/science.1176210 L. Gross, F. Mohn, N. Moll, P. Liljeroth, G. Meyer, ''The chemical structure of a molecule resolved by atomic force microscopy'', Science '''325''', 1110-1114 (2009)] ]]<br />
<br />
At variance with bulk crystalline systems (fully periodic in 3D), molecules are finite isolated systems, <br />
and special care needs to be put in setting up calculations, accordingly.<br />
* '''scf + nscf''': DFT calculations for molecules (or systems with reduced dimensionality in general) follow the same strategies discussed in the previous lectures, where scf calculations are followed by nscf runs (and perhaps by post-processing steps, as discussed below in [[Electronic properties of isolated molecules#Post processing tools]]).<br />
* '''isolation''': when localised basis sets are used, systems are usually treated as isolated by default (and care must be used to impose periodicity). Instead, when using plane-waves, periodic boundary conditions (PBC) are automatically enforced and molecule isolation has to be imposed. <br />
* '''vacuum''': As a preliminary step, the unit cell describing an isolated molecule has to be large enough to avoid direct ''chemical''interaction (ie chemical bonds) of atoms belonging to different replicas (given PBC, the atoms in one cell are infinitely repeated, giving rise to a lattice of replicas). <br />
* '''electrostatics''': similarly, one also wants to avoid electrostatic interactions (driven in Kohn-Sham DFT by the Hartree potential) among replicas. The presence of long range interactions (dipoles, quadrupoles...) makes convergence wrt vacuum (ie cell size) slow and dedicated techniques should be used. When using Quantum ESPRESSO, consider setting <code>assume_isolated="mt"</code> (standing for Martyna Tuckerman approach, as from [http://dx.doi.org/10.1063/1.477923 J. Chem. Phys. '''110''', 2810 (1999)]) in the <code>SYSTEM</code> namelist.<br />
* When '''charged systems''' are considered the situation is even more critical: in principle the total energy would diverge for a system in PBC, and by default a compensating uniform background is added to the system (though resulting in spurious effects in the properties of the system). In this cases the use of the Martyna-Tuckerman approach is strongly recommended.<br />
* In principle, the '''exchange-correlation''' energy and potential would also have a contribution related to the presence of replicas (long range physical contributions are also there, just consider van der Waals interactions as an example). Nevertheless, when using simple approximations to the xc functional (eg LDA, GGA, meta-GGA) long range contributions are not present and so the xc term does not pose any problems.<br />
* '''Overall''', a 10-15 Angstrom of vacuum in between replicas is typically enough to describe neutral molecules with mild dipoles to a decent accuracy. If the Martyna-Tuckerman approach is used, one needs to be very careful with the molecule separation since it needs to be at least as large as the physical dimension of the system in that direction (so for elongated molecules a large region of vacuum is actually needed).<br />
* '''Importantly''': though rules of thumb exist (see above), the amount of vacuum to be included in the system description is a '''convergence parameter''' that needs to be tested against the quantities of interested to be calculated.<br />
<br />
'''K-points and Gamma sampling'''<br />
* The '''Brillouin zone''' of a infinitely large cell subject to PBC becomes a single point, '''Gamma'''. Because of this, even when using a large but finite cell, K-point sampling should not be used. This should not be relevant in terms of results (if it is, spurious interactions are present), but would result in a waste of computational resources. The so-called '''Gamma sampling''' should then be sued.<br />
* Moreover, in view of the Gamma sampling, wave functions can be taken to be real, leading to more memory and computational time savings.<br />
* In Quantum ESPRESSO one needs to set the following:<br />
K_POINTS automatic<br />
1 1 1 0 0 0 # for Gamma sampling using complex wavefunctions<br />
# deprecated, unless for testing or debugging<br />
<br />
K_POINTS (gamma) # for proper gamma sampling using real wavefunctions<br />
<br />
==Post processing tools==<br />
Here we take the occasion to introduce some among the post processing tools of <code>Quantum ESPRESSO</code>.<br />
By post processing (PP) one means the set of tools and operations to be performed on the output data of the calculations (here the simulations performed at the DFT level). Quantum ESPRESSO provides a tool, <code>pp.x</code>, dedicated to post-processing calculations.<br />
<br />
Possible quantities that can be extracted and plotted using <code>pp.x</code>:<br />
* charge density<br />
* electrostatic potential (V_ion + V_H) <br />
* total Kohn-Sham potential (V_ion + V_H + V_xc)<br />
* selected Kohn-Sham orbitals<br />
<br />
Here is an example input file (pp.in):<br />
<br />
&INPUTPP<br />
prefix="..."<br />
outdir="..."<br />
plot_num=11 # electrost. Pot<br />
filplot = "pot.pp"<br />
/<br />
<br />
&PLOT<br />
nfile=1<br />
filepp(1)="pot.pp"<br />
iflag=3<br />
output_format=5 # xsf xcrysden fmt<br />
fileout="pot.xsf"<br />
/<br />
<br />
where <code> plot_num</code> can be chosen according to:<br />
plot_num = <br />
0 total charge<br />
1 total potential<br />
5 STM images <br />
7 KS orbitals<br />
11 electrostatic potential<br />
<br />
Usage:<br />
[mpirun -np ''num_mpi_tasks''] pp.x < pp.in > pp.out <br />
<br />
More options are available at: [https://www.quantum-espresso.org/Doc/INPUT_PP.html INPUT_PP]<br />
<br />
Another post-processing tool useful in this context is <code>average.x</code> which performs<br />
a '''planar average''' of a given input scalar field on a 3D grid. Additionally, a '''double average''' (convolution with a rolling window)<br />
is also performed.<br />
This is particularly useful, e.g., to plot the average potential, in the form v(z), in the vacuum region of the cell <br />
in order to determine the position of the vacuum level. See exercises for more details.<br />
<br />
An example of an input file (average.in) follows:<br />
<br />
1 # nfile<br />
pot.pp # filename<br />
1.0 # weight<br />
96 # n-points (FFT mesh)<br />
3 # idir <br />
1.0 # awin (width of the rolling window)<br />
<br />
Usage:<br />
average.x < average.in<br />
<br />
==Exercises==<br />
<br />
===Exercise 1===<br />
[[File:guanine1.png|200px|thumb]]<br />
[[File:guanine2.png|200px|thumb| Ball and stick model of the guanine nucleobase]]<br />
'''Structural relaxation of the Guanine molecule'''<br />
<br />
*Use a molecular builder to find the initial molecular structure. (Avogadro)<br />
*Perform classical force field (FF) relaxation (using a built-in engine)<br />
*Perform a quantum mechanical (DFT based) refinement of the relaxation (using Quantum ESPRESSO, with thr=10^-3 on forces)<br />
*Use the xcrysden software to visualize the relaxation path.<br />
<br />
[[Solution_LAB2_guanine | Hints]]<br />
<br />
===Exercise 2===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
Using the guanine atomic coordinates determined at the previous step, compute:<br />
<br />
*HOMO and LUMO frontier orbital energies <br />
*How do they depend on the supercell volume and why? <br />
*Estimate the vacuum level wrt supercell size (pp.x, average.x)<br />
*Repeat the calculation using the “assume_isolated” variable<br />
*Is -HOMO a good estimate of IP ? IP_exp=8.0-8.3 eV<br />
<br />
[[Solution_LAB2_guanine_2 | Hints]]<br />
<br />
===Exercise 3===<br />
'''Electronic properties of the Guanine molecule'''<br />
What does IP mean? [ IP = Etot(N-1)-Etot(N) ]<br />
<br />
*Let’s do this calculation explicitly (the ∆-scf procedure)<br />
*Repeat the calculation for different volumes <br />
*Repeat the above using different functionals (LDA,PBE,PBE0,HF...). <br />
Note: hybrid functionals may take very long, special care must be used in setting the parameters<br />
<br />
[[Solution_LAB2_guanine_3 | Hints]]<br />
<br />
===Exercise 4===<br />
'''Electronic properties of the Guanine molecule'''<br />
<br />
*Density, HOMO and LUMO orbitals and plot them (pp.x + xcrysden) <br />
*How the HOMO and LUMO orbitals looks like?<br />
*Density of states (dos.x tool)<br />
*The projected density of states (projwfc.x tool,sumpdos.x)<br />
<br />
===Exercise 5===<br />
'''A simple Reaction: Methane Combustion'''<br />
[[File:combustion.png|250px|thumb]]<br />
[[File:Combustion_reaction_of_methane.jpg|250px|thumb|Methane combustion chemical reaction]]<br />
<br />
Calculate the reaction Enthalpy of the methane combustion:<br />
<br />
CH<sub>4</sub>+2O<sub>2</sub> → 2H<sub>2</sub>O+CO<sub>2</sub> <br />
<br />
EXP: ∆Hc = -890 KJ/mol = 212.7151051 Kcal/mol<br />
<br />
H = U + pV <br />
<br />
∆Hc = Etot(products) -Etot(reactants) (at std p,T)<br />
<br />
because : p∆V = ∆n R T and ∆n=0<br />
<br />
*Relax and calculate tot energies for all the reactants and products using the template input<br />
*Starting atomic coordinates of the molecules are in ./LAB_2/docs/g2-97_cart_neut.txt<br />
*Pay attention to the O2 molecule (triplet)<br />
<br />
[[Solution_LAB2_guanine_5 | Hints]]</div>Andrea Ferretti