Difference between revisions of "Yambopy tutorial: Yambo databases"

From The Yambo Project
Jump to navigation Jump to search
Line 6: Line 6:
* Dipole matrix elements (Yambo databases: ndb.dipoles, Yambopy class: YamboDipolesDB).
* Dipole matrix elements (Yambo databases: ndb.dipoles, Yambopy class: YamboDipolesDB).
* Exciton wavefunctions, energy and spectra (Yambo databases: ndb.BS_diago_Q*, Yambopy class: YamboExcitonDB).
* Exciton wavefunctions, energy and spectra (Yambo databases: ndb.BS_diago_Q*, Yambopy class: YamboExcitonDB).
We will also check the command line instructions to quickly generate yambo SAVE folders.
The scripts of the tutorial, but not the databases, can be found in the yambopy directory:
cd tutorial/databases_yambopy
The full tutorial, including the Quantum espresso and Yambo databases that we will read, can be downloaded and extracted from the yambo website:
wget XXXX
tar -xvf databases_tutorial.tar
cd databases_tutorial
We will work with monolayer hexagonal boron nitride results obtained on a <code>12x12x1</code> kpoint grid. Beware that these are certainly not converged.
=== Generating the Yambo SAVE using command line options ===
Yambopy offers a set of command line options. In order to review them, you can type
$yambopy
which will print the output
yambopy
Available commands are:
      plotem1s ->    Plot em1s calculation
      analysebse ->    Using ypp, you can study the convergence of BSE calculations in 2 ways:
      analysegw ->    Study the convergence of GW calculations by looking at the change in band-gap value.
  plotexcitons ->    Plot excitons calculation
          addqp ->    Add corrections from QP databases.
        mergeqp ->    Merge QP databases
          save ->    Produce a SAVE folder
          gkkp ->    Produce a SAVE folder including elph_gkkp databases
          bands ->    Script to produce band structure data and visualization from QE.
        serial ->    Script to update serial numbers of yambo ndb.* databases in order to import them to new calculations.
          test ->    Run yambopy tests
For this tutorial, we weill need the <code>save</code> and <code>gkkp</code> options.
By typing in one of these, additional information about how to run the commands will be printed, e.g.:
$yambopy save
Produce a SAVE folder
Arguments are:
  -nscf, --nscf_dir  -> Path to nscf save folder
  -y, --yambo_dir    -> <Optional> Path to yambo executables
The quantum espresso save for hBN is provided in the directory <code>BSE_saves/QE_saves/hBN.save</code> (you can check the contents of the various folders).
Then, following the instructions printed on screen, we can generate a yambo SAVE from the hBN.save by typing
$yambopy save -nscf BSE_saves/QE_saves/hBN.save
This should produce a SAVE folder in the current directory.
=== YamboLatticeDB intro: plot k-point coordinates in IBZ/BZ ===
For this section we will use the script <code>bz_plot.py</code>.
By inspecting the SAVE folder we have just generated, we will find the <code>ns.db1</code> database which contains all the geometry and lattice information.
We are now going to read it in python by using the Yambopy class <code>YamboLatticeDB</code>, which can be instanced like this:
from yambopy import *
ylat = YamboLatticeDB.from_db_file(filename="PATH/TO/SAVE/ns.db1")
The <code>ylat</code> object now contains many useful information as attributes, such as the k-points in Cartesian or crystal coordinates, the system symmetries, lattice constants and basis vectors in real and reciprocal space, etc.
The k-points are also automatically expanded in the full Brillouin zone from the irreducible one (you can turn this off with the option <code>Expand=False</code>.
Directly printing the object with
print(ylat)
will also give us some general parameters related to the database.
Now check the <code>bz_plot.py</code> script. You will see that it performs three plots:
* Scatterplot of the k-points in Cartesian coordinates with both expanded and unexpanded grids, with annotated indices [<code>Cartesian_Plot=True</code>].
* Scatterplot of the k-points in crystal coordinates [<code>Crystal_Plot=True</code>].
* Manual transformation of a customly chosen k-points from irreducible to full Brillouin zone (you can change the index <code>i_k</code> in the script to check different cases) [<code>Symmetry_Plot=True</code>].

Revision as of 09:13, 1 April 2022

In this tutorial we will see some on how to read and analyse the data contained in the Yambo netCDF databases, which are not readily available as human readable outputs.

In particular we will take a look at:

  • Lattice geometry data (Yambo database: ns.db1, Yambopy class: YamboLatticeDB).
  • Electron-phonon matrix elements (Yambo databases: ndb.elph_gkkp*, Yambopy class: YamboElectronPhononDB).
  • Dipole matrix elements (Yambo databases: ndb.dipoles, Yambopy class: YamboDipolesDB).
  • Exciton wavefunctions, energy and spectra (Yambo databases: ndb.BS_diago_Q*, Yambopy class: YamboExcitonDB).

We will also check the command line instructions to quickly generate yambo SAVE folders.

The scripts of the tutorial, but not the databases, can be found in the yambopy directory:

cd tutorial/databases_yambopy

The full tutorial, including the Quantum espresso and Yambo databases that we will read, can be downloaded and extracted from the yambo website:

wget XXXX
tar -xvf databases_tutorial.tar
cd databases_tutorial

We will work with monolayer hexagonal boron nitride results obtained on a 12x12x1 kpoint grid. Beware that these are certainly not converged.

Generating the Yambo SAVE using command line options

Yambopy offers a set of command line options. In order to review them, you can type

$yambopy

which will print the output

yambopy
Available commands are:

      plotem1s ->     Plot em1s calculation
     analysebse ->     Using ypp, you can study the convergence of BSE calculations in 2 ways:
     analysegw ->     Study the convergence of GW calculations by looking at the change in band-gap value.
  plotexcitons ->     Plot excitons calculation
         addqp ->     Add corrections from QP databases.
       mergeqp ->     Merge QP databases
          save ->     Produce a SAVE folder
          gkkp ->     Produce a SAVE folder including elph_gkkp databases
         bands ->     Script to produce band structure data and visualization from QE.
        serial ->     Script to update serial numbers of yambo ndb.* databases in order to import them to new calculations.
          test ->     Run yambopy tests

For this tutorial, we weill need the save and gkkp options. By typing in one of these, additional information about how to run the commands will be printed, e.g.:

$yambopy save
Produce a SAVE folder

Arguments are:
  -nscf, --nscf_dir  -> Path to nscf save folder
  -y, --yambo_dir    -> <Optional> Path to yambo executables

The quantum espresso save for hBN is provided in the directory BSE_saves/QE_saves/hBN.save (you can check the contents of the various folders). Then, following the instructions printed on screen, we can generate a yambo SAVE from the hBN.save by typing

$yambopy save -nscf BSE_saves/QE_saves/hBN.save

This should produce a SAVE folder in the current directory.

YamboLatticeDB intro: plot k-point coordinates in IBZ/BZ

For this section we will use the script bz_plot.py.

By inspecting the SAVE folder we have just generated, we will find the ns.db1 database which contains all the geometry and lattice information. We are now going to read it in python by using the Yambopy class YamboLatticeDB, which can be instanced like this:

from yambopy import *
ylat = YamboLatticeDB.from_db_file(filename="PATH/TO/SAVE/ns.db1")

The ylat object now contains many useful information as attributes, such as the k-points in Cartesian or crystal coordinates, the system symmetries, lattice constants and basis vectors in real and reciprocal space, etc. The k-points are also automatically expanded in the full Brillouin zone from the irreducible one (you can turn this off with the option Expand=False.

Directly printing the object with

print(ylat)

will also give us some general parameters related to the database.

Now check the bz_plot.py script. You will see that it performs three plots:

  • Scatterplot of the k-points in Cartesian coordinates with both expanded and unexpanded grids, with annotated indices [Cartesian_Plot=True].
  • Scatterplot of the k-points in crystal coordinates [Crystal_Plot=True].
  • Manual transformation of a customly chosen k-points from irreducible to full Brillouin zone (you can change the index i_k in the script to check different cases) [Symmetry_Plot=True].