Bader: Oxidation States
This tutorial provides a basic example of calculating oxidation states using Quantum Espresso and BaderKit.
Quantum ESPRESSO¶
-
Create an input file for an electronic relaxation. Here we provide an example for the NaCl structure which we named
scf.inon our system. While you can use any name, we like to use the.insuffix for clarity.&CONTROL calculation = 'scf' etot_conv_thr = 2.0000000000d-04 forc_conv_thr = 1.0000000000d-03 outdir = './scf' prefix = 'nacl' pseudo_dir = '.' tprnfor = .true. tstress = .true. verbosity = 'high' / &SYSTEM degauss = 2.7500000000d-02 ecutrho = 320.0 ecutwfc = 70.0 ibrav = 0 nat = 2 nosym = .false. ntyp = 2 occupations = 'fixed' / &ELECTRONS conv_thr = 8.0000000000d-10 electron_maxstep = 80 mixing_beta = 4.0000000000d-01 / ATOMIC_SPECIES Cl 35.453 Cl.pbesol-n-kjpaw_psl.1.0.0.UPF Na 22.98977 Na.pbesol-spn-kjpaw_psl.1.0.0.UPF ATOMIC_POSITIONS crystal Na 0.0000000000 0.0000000000 0.0000000000 Cl 0.5000000000 0.5000000000 0.5000000000 K_POINTS automatic 7 7 7 0 0 0 CELL_PARAMETERS angstrom 3.4220145992 0.0000000000 1.9757010500 1.1406715331 3.2263063045 1.9757010500 0.0000000000 0.0000000000 3.9514021000Make sure you have appropriate pseudopotentials and point
pseudo_dirto their location. We copy the pseudopotentials into the active directory so that BaderKit can automatically parse them. For this tutorial, we used PPs generated from pslibrary v1.0.0. -
Run the scf calculation. On our system we use the following command.
mpirun -np 12 pw.x -in scf.in -
We need the valence charge density produced by the calculation as well as the 'all-electron' (valence and core) density. To generate these, we must run the post-processing package,
pp.x, once for each file. Here we provide the inputs for both which we named 'chg.in' and 'tot_chg.in' respectively.&INPUTPP prefix = 'nacl', outdir = './scf/', plot_num = 0 / &PLOT nfile = 1 iflag = 3 output_format = 6 fileout = 'chg.cube' /&INPUTPP prefix = 'nacl', outdir = './scf/', plot_num = 21 / &PLOT nfile = 1 iflag = 3 output_format = 6 fileout = 'tot_chg.cube' / -
Run the post-processing on each file to produce the required cube files.
This should printmpirun -np 12 pp.x -in chg.in mpirun -np 12 pp.x -in tot_chg.in.cubefiles for the valence and total charge densities.
Tip
We have also added functionality for XCrySDen's .xsf format if you prefer. Note that we currently only parse the first density grid in the file.
BaderKit¶
-
If you would like to follow along, open your preferred IDE in an environment with BaderKit installed. Alternatively, the complete python script from this tutorial is available at the end of this page.
-
Import the main Bader class.
from baderkit import Bader -
Create the Bader class instance.
bader = Bader.from_cube( charge_grid="chg.cube", total_charge_grid="tot_chg.cube", ) -
Finally, we can print the oxidation states to console.
print(bader.oxidation_states)You should see logging information as BaderKit runs, then the oxidation states of each atom in the structure:
array([ 0.86352566 -0.86353298])
Tip
If you get None BaderKit likely can't find your pseudopotentials. Made sure they are in the active directory or you point to them using the pseudopotential_filename tag.
-
If you are using an environment manager, load your baderkit environment. For conda:
conda activate baderkit -
Run the Bader analysis.
baderkit bader chg.cube -tot tot_chg.cubeYou should see logging information printed to the console and once complete a
bader.jsonfile will be written which summarizes the results of the calculation.
And that's it! Try playing around with what else the Bader class offers.
Download Resources¶
Tutorial Script: oxidation_states.py
VASP Inputs/Outputs: NaCl_qe.zip