CSC Spring School 2019

How To Analyze The Electronic Density

An Introduction To Some Useful Tools

Michael Patzschke Institute for Resource Ecology HZDR

22.03.2019

Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de To get started …

• “. . .with its help, debates can be resolved forever, if they can be settled on the basis of some data; and if one took the pen it would be enough for the two disputing men to say to one another: Let’s calculate.” Leibniz in a letter to P. J. Spener, 1687

Page 2 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de The Codes

• All codes are available for free • All codes on run on MacOS, Linux and Windows • One useful tool is needed: Molden2AIM – Short intro is included • Extra visualisation via and VMD

Page 3 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de The Codes

• Mep.py – a python script for calculating MEP – Works with orca – Needs numpy • JANPA – three programs to perform NBO analysis – Needs a molden input file – e.g. from orca – Calculates NBO charges and occupations – Generates molden files of NAO • NCIPLOT – Freely available, compiles effortlessly – Needs wfn files – Creates cube files and a vmd script • MultiWFN – Powerful tool - actively developed – Needs wfn or molden file (or fchk …) – Performs QTAIM analyses and much much more

Page 4 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Learning Outcome

• Creating a mapped electrostatic potential maps – Generating and visualising MEP’s • Using JANPA – Perform NBO analysis based on DFT and higher correlated wf-based methods – Generate NAO files and visualise them with molden • Generating wfn files using Molden2AIM • Creating NCI plots – Generating input files – Comparing promolecular and abinitio approaches • Using MultiWFN – Performing QTAIM analysis – Visualising the ELF – Basin integration

Page 5 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de MEP

• Mapped electrostatic potentials are a useful representation • Can be produced with gabedit, this might be problematic • Guaranteed way of doing it with orca: python script mep.py • Prerequisites: – orca calculation including the keyword “KeepDens” !PBE def2-TZVPP KeepDens Opt – .xyz file of the molecule with same basename * xyz 0 1 (generated e.g. by an optimisation with orca) O 0.564501 0.503101 -0.072285 – Python and numpy installed H 0.800576 0.654590 0.856423 – Script mep.py in the current folder H 0.067510 1.292215 -0.339691 – El. density cube file (obtained e.g. from orca_plot) F -1.017604 -1.594064 -0.243508 • Run the provided orca input file by H -0.414983 -0.855845 -0.200937 issuing in a terminal: * orca h2o_hf.inp > h2o_hf.out • This generates the necessary .xyz, .scfp and .gbw files

Page 6 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de MEP

• Now we generate the electron density using orca_plot • In a terminal write: orca_plot h2o_hf.gbw –i type 1 and choose 2 (electron density) type 4 and type 80 (changes resolution) type 5 and choose 7 (gaussian cube format) type 10 to start the generation process type 11 to exit the program We get the cube file h2o_hf.eldens.cube • Now we have everything we need! So lets proceed … python2 mep.py h2o_hf 80 • After a minute we get the cube file h2o_hf.mep.cube • Visualisation with vmd: vmd h2o_hf.eldens.cube h2o_hf.mep.cube

Page 7 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de JANPA

• Prerequisite: molden input file, molde2molden.jar and janpa.jar in current folder • Molden format described here: http://www.cmbi.ru.nl/molden/molden_format.html

• Generated in orca with: orca_2mkl “base_name” –molden (base_name here: h2o_hf): orca_2mkl h2o_hf –molden

• Many programs generate sloppy molden files • Therefore first step: java -jar molden2molden.jar -i h2o_hf.molden.input -o h2o_hf.pure.molden -fromorca3bf -orca3signs

• Next step, perform actual analysis: java -jar janpa.jar -i h2o_hf.pure.molden > h2o_hf.janpa

• Lets look at the output file! less h2o_hf.janpa

Page 8 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de JANPA • Output shows charges, occupations, bind orders and CLPO analysis

• Many additional options exist, look at the top of the output file • Lets visualise natural atomic orbitals using molden: java -jar janpa.jar –i h2o_hf.pure.molden -CLPO_Molden_File CLPO.molden > h2o_hf.janpa

• Visualise using molden (or better gmolden) gmolden CLPO.molden

• Visualize the LP’s and bonding and antibonding orbitals!

Page 9 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de JANPA

• Correlated densities can also be used, example CCSD ! CCSD def2-TZVPP

• Look at the input file: h2o_hf_ccsd.inp %mdci citype CCSD • Important: mdci block for relaxed densities! Denmat orbopt • Run it: density orbopt end orca h2o_hf_ccsd.inp > h2o_hf_ccsd.out * xyz 0 1 • Notice the file h2o_hf_ccsd.mdci.optorb – it is a .gbw file! O 0.564501 0.503101 -0.072285 H 0.800576 0.654590 0.856423 • This file contains the actual CCSD wavefunction information H 0.067510 1.292215 -0.339691 F -1.017604 -1.594064 -0.243508 • Therefore do the following: H -0.414983 -0.855845 -0.200937 cp h2o_hf_ccsd.mdci.optorb h2o_hf_ccsd.mdci.optorb.gbw * orca_2mkl h2o_hf_ccsd.mdci.optorb.gbw -molden java -jar molden2molden.jar –i h2o_hf_ccsd.mdci.optorb.molden.input -o h2o_hf_ccsd.pure.molden -fromorca3bf -orca3signs java -jar janpa.jar -i h2o_hf_ccsd.pure.molden -CLPO_Molden_File CLPO.molden > h2o_hf_ccsd.janpa

• Compare DFT and CCSD – here only small differences!

Page 10 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Generating a .wfn File

• WFN files are needed for many types of analysis • Can be generated by orca directly (add WFN in input line) • Better: generate with Molden2Aim code • In a terminal enter m2a (or molden2aim) • Molden files generated by many codes can be used • Small changes necessary – for orca see 7) 7) ORCA (insert [PROGRAM] ORCA into MOLDEN file) • Please insert [PROGRAM] ORCA into the h2o_hf.molden.input file (e.g. as first line) • Now run m2a again, this time press “Enter” to continue • Type or paste the name of the molden file you just edited • Program presents you with three questions, answer first with yes, second and third with no • Inspect the h2o_hf.molden.wfn file! • This file is needed for NCIPLOT and can be used by MultiWFN

Page 11 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Interlude: AIM, Charges & NCIplots

l Atoms in molecules (Bader) - Density is analysed topologically (max, min, saddle points) - Start with first derivative of the density: d⇢ d⇢ d⇢ = ~0, at critical points and ⇢ = i + j + k 1 r dx dy dz (= ~0, otherwise 6 - There are three first and nine second derivatives – Hessian matrix: @2⇢ @2⇢ @2⇢ @x2 @x@y @x@z 2 2 2 H(r )= @ ⇢ @ ⇢ @ ⇢ c 0 @y@x @y2 @y@z 1 @2⇢ @2⇢ @2⇢ B @z@x @z@y @z2 C @ A - The Hessian can be diagonalized (real and symmteric): @2⇢ 2 00 @x0 1 00 1 @2⇢ U HU = ⇤ = 0 2 0 = 0 2 0 0 @y0 1 2 0 1 @ ⇢ 003 00 2 B @z0 C @ A @ A

Page 12 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de AIM

l Atoms in molecules (Bader) - The λ are the curvatures of the density - Critical points (or cp) are categorized as (rank,signature) Where rank is the number of λ≠0 and signature is the sum of the signs of λ - The following cases exist: (3,-3) = NCP (nuclear critical point) (3,-1) = BCP (bond critical point) (3,+1) = RCP (ring critical point) (3,+3) = CCP (cage critical point)

- Example: cubane (bond paths drawn in black)

- Hopf-Poincaré criterium: =1, for isolated molecules nNCP nBCP + nRCP nCCP = (=0, for infinite crystals

Page 13 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de AIM

l Atoms in molecules (Bader) - AIM analysis is insensitive to level of theory and basis-set size - AIM charges tend to be high - Non-nuclear attractors might appear, e.g. in metal clusters • Useful additional parameters can be calculated • Example Delocalisation Index – related to Mayer bond order: N ↵ DI = 2F (⌦, ⌦0)=2 F (⌦, ⌦0)+F (⌦, ⌦0) = 2 S (⌦)S (⌦0) i,j i,j i,j – F = Fermi correlation⇥ energy ⇤ X – Ω = atomic basin – S = overlap integral of two atomic orbitals (i,j) over an atomic basin • DI is a measure of number of electrons that are shared between basins of two atoms

Page 14 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Basis Sets and Charges

• Test case 1,1-difluoroethylene C(2) C(1) • Based on DFT calculation with the PBE functional • Geometry optimised at def2-TZVPP/PBE level

Mulliken Mulliken Löwdin Löwdin AIM AIM NBO Hirshfeld VDD SVP aug-cc- SVP aug-cc- SVP aug-cc- SVP SVP SVP pVQZ pVQZ pVQZ

C(1) 0.29 1.06 0.11 -1.32 0.99 1.02 0.69 0.16 0.156 C(2) -0.14 -1.09 -0.16 0.61 0.01 0.03 -0.61 -0.14 -0.166

H 0.06 0.44 0.05 -0.39 0.11 0.10 0.23 0.06 0.07 F -0.13 -0.43 -0.02 0.75 -0.62 -0.63 -0.28 -0.07 -0.06

AIM – Atoms in Molecules NBO – Natural Bond Orbitals VDD – Voronoi Deformation Density

Page 15 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de NCI

l Interesting new tool: NCI-plots (Johnson 2010) – in a way related to AIM (see above)

l Plot reduces gradient versus density

l Reduced gradients are fundamental in DFT describing deviations from homogenous electron distributions

l In density tails it has high values

l For weak and strong bonding interactions it approaches zero

l Three types of weak interaction can be identified with the electron density Hessian, which has three eigenvalues: 2 1 2 3 and = 1 + 2 + 3   r

l At nuclei: density maximum, all λ negative

l For bonds 2 of 3 λ are negative

l For weak interactions: - λ Weak bonding: 2 is negative (example hydrogen bonds) - λ Very weak interaction: 2 is negative close to zero (methane dimer) - λ Non-bonding interaction: 2 is positive

Page 16 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de NCI

© Johnson et al. JACS, 2010, 132, 18, 6498-6506

Page 17 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de NCI

© Johnson et al. JACS, 2010, 132, 18, 6498-6506

Page 18 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de NCI

© Johnson et al. JACS, 2010, 132, 18, 6498-6506

Page 19 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de How To Run NCIPLOT

1 • Very simple input file is needed h2o_hf.nci: h2o_hf.molden.wfn • Instead of the radius a cube can be used RADIUS 0. 0. 0. 3. • How to get the cube or sphere dimension: – Inspect the coordinates, fit them in the cube or sphere – Run orca_plot and see what cube it suggests, use same • Now run nciplot: nciplot h2o_hf.nci • This generates 5 files, most important here: The .vmd script file • Start this with vmd by typing: vmd -e h2o_hf.molden.vmd • Change values in vmd as needed

Page 20 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de MultiWFN

• Needs a .wfn file, preferably generated by molden2aim • Start by typing Multiwfn • Dialogue driven like orca_plot or Gromacs gmx energy • Start by typing the name of the .wfn file you want to study or “o” to reopen last file • Look at the different menu points • In this tutorial we are looking at: 0,1,2,3,4,5,11 and 17 and submenues therein • MultiWFN is fast, reliable, actively developed and free But: visualisation could be better • Use VMD when possible!

Page 21 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Load File & Visualise Structure

• Make sure you have a wfn file in your Multiwfn folder • Start Multiwfn • Write the name of the .wfn file e.g. use h2o_hf.molden.wfn • Press “0” • New window opens – look around • You get: – the numbering of the atoms – Simple viw of MO’s – Notice the information displayed in the terminal window • Close the graphics window (Return button)

Page 22 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Information for Specific Points

• Back in the main window press 1 • Either coordinates or atom numbers can be given • Lets try: a5 (for atom 5) • Enter q to return

Page 23 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de QTAIM Analysis • Press “2” to enter the Topology menu • Locate critical points (use options 2,3,4,5) • Check after “2” whether all NCP’s have been found • If not: – Enter “-1” – Increase the search criteria “3” and “4” up to a factor 1000 – Enter “0” to return to topology menu – repeat NCP search “2” • Calculate bond paths “8” and “9” • Visualise with “0”

Page 24 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de QTAIM Analysis • Look at information in terminal window (Poincare-Hopf criterium)

• Press “RETURN” to get back • Better visualisation with vmd: – Export CP’s in “-4”, “6” and “0” – Export paths with “-5” , “6” and “0” – Two files (always CPs.pdb and paths.pdb” are created – change name in new terminal if necessary – Start vmd with both pdb files “vmd –m CPs.pdb paths.pdb” – Change visualisation as required e.g. CP’s as points size 18 paths as points size 5 Render Mode: Normal • Type “-10” to get back to main menu

Page 25 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Visualising Properties

• Visualisation possible in 1D (line), 2D or 3D (cube file for vmd) • Example here ELF in 2D • Enter “4” in main menu • Enter “9” then “1” for colour-filled map • Choose plane, e.g. by giving the indices of three atoms

Page 26 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Basin Analysis

• Type “17” in main menu • Choose “1” to generate basins • Choose a real space functions to fins basins in • We use “1” the electron density • Choose a grid (here “3”) • Now we have many options to continue • Try “4” for DI, answer question with y • Calculate AIM charges with “7” and then “3” followed by “1” • Visualize basins (“topological atoms” in this case) with “-5”, then e.g. “3” the oxygen atom • Writes cube files – visualise with VMD

Page 27 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de UV-Vis spectra

• Orca output files can be visualised directly, even multiple files simultaniously • To do that you need a txt file containing the names (and paths) of all output files and possibly a name – look at the provided example “multiple.txt” • Put the following files in the MultiWFN directory: multiple.txt, tddft.out and stddft.out • Now start MultiWFN and open multiple.txt • Type “11” to visualise spectra – in this case UV-Vis, so type “3” • Change units with “10” • Change broadening with “6” • Change resolution with “8” • Finally plot spectrum with “0” • And save with “1”

Page 28 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Density Differences

• Density differences are a useful tool to understand intermolecular interactions • Lets try or water-hydrogen-fluoride example again • This time we run three orca calculations 1) The dimer 2) The water molecule 3) The HF molecule

!PBE def2-TZVPP !PBE def2-TZVPP !PBE def2-TZVPP * xyz 0 1 * xyz 0 1 * xyz 0 1 O 0.564558 0.502959 -0.072226 O 0.564558 0.502959 -0.072226 F -1.017498 -1.594045 -0.243488 H 0.800593 0.654706 0.856387 H 0.800593 0.654706 0.856387 H -0.415093 -0.855600 -0.201038 H 0.067441 1.291977 -0.339632 H 0.067441 1.291977 -0.339632 * F -1.017498 -1.594045 -0.243488 * H -0.415093 -0.855600 -0.201038 * • Important: The position of the fragments must be the same as in the dimer! • Run the orca calculations and prepare the molden files: orca h2o_hf.inp > h2o_hf.out orca h2o.inp > h2o.out orca hf.inp > hf.out orca_2mkl h2o_hf -molden orca_2mkl h2o -molden orca_2mkl hf -molden

Page 29 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Density Differences

• Now start MultiWFN with the molden file of the dimer! MultiWFN h2o_hf.molden.input • Type “5” to visualise a volume • The choose “0” to set a custom operation • Now you have to choose how many additional molden files you need • So type “2” • Now write the operation and then the name of the molden file: -,h2o.molden.input -,hf.molden.input • Then choose the real-space function you desire – in the case “1” for the electron density • You are asked for a grid size, choose “3” • Three grids are calculated and then the requested operations are performed • Now press “2” to generate a cube file

Page 30 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Density Differences

• The cube file “density.cub” is written • Visualize it using vmd

Page 31 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de MEP’s again … • MultiWFN can do MEP’s as well • Let’s take our dimer MultiWFN h20_hf.molen.input • Choose “5” to visualise a property in 3D • Choose “1” electronic density, use “2” as gridsize, then type “2” to export the data into a cube file • “0” to get back to the main menu • “5” for 3D property again, this time choose “12” for ESP, use “2” as gridsize, then type “2” to export the data into a cube file • Now visualize as in the example above • Things to note: – ESP calc. takes quite some time – Standard file names are used by MultiWFN (e.g. ESP in totesp.cub) – So copy important files, lest they are overwritten – ESP and Dens must be on the same grid! – To avoid crashes, you might need to add this to .bashrc or .profile

Page 32 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de 4 9 MultiWFN 1

4 4,10,17 -2 • MultiWFN can be scripted! 20,20,0.1 4 • Needs a “stream” containing all numbers you would enter 4 • Look at example and try to figure out what it does: 0 • Use stream e.g. like this: MultiWFN h2o_hf.molden.input < stream > mult.out

• For automated tasks it is problematic that MultiWFN stops at pictures it created • Workaround: change “settings.ini” • Change “isilent” to 1

• MultiWFN can also do NCI plots …

• Maybe try “7“ then “12“ to enter CHELPG ESP fitting charges calculation

Page 33 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Scripting in MultiWFN

• What scripting can do:

Page 34 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de MultiWFN

• Rest of the time: Play around and explore • Ask if you want to achieve something in particular • Have fun!

• MultiWFN is updated frequently check homepage: http://sobereva.com/multiwfn/

• Developer is extremely helpful and willing to integrate new functionality – use the forum to contact him (Tian Lu (卢天))

Page 35 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de Thank You For Your Attention

Page 36 Member of the Helmholtz Association Dr. Michael Patzschke I Institute for Resource Ecology I www.hzdr.de