This tutorial can be downloaded link.

1.0 Getting Started: Ground State

We are going to generate an input file for the QuantumEspresso code or Qbox. Each code will compute the ground state electronic stucture for the methane molecule using Density Functional Theory.

Step 1: Load westpy

[1]:
from westpy import *

 _    _ _____ _____ _____
| |  | |  ___/  ___|_   _|
| |  | | |__ \ `--.  | |_ __  _   _
| |/\| |  __| `--. \ | | '_ \| | | |
\  /\  / |___/\__/ / | | |_) | |_| |
 \/  \/\____/\____/  \_/ .__/ \__, |
                       | |     __/ |
                       |_|    |___/

WEST version     :  3.1.1
Today            :  2018-09-19 15:21:13.244247

Step 2: Geometry

[2]:
geom = Geometry()

Let’s define a cubic cell of edge 25 Bohr.

[3]:
geom.setCell((25,0,0),(0,25,0),(0,0,25))

We load the atomic positions from a XYZ file, available online.

[4]:
geom.addAtomsFromOnlineXYZ( "https://west-code.org/doc/training/methane/CH4.xyz" )

We associate pseudopotential files to each species.

[5]:
geom.addSpecies( "C", "http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.0.upf")
geom.addSpecies( "H", "http://www.quantum-simulation.org/potentials/sg15_oncv/upf/H_ONCV_PBE-1.0.upf")

Step 3.1: Ground State

The ground state calculation is defined by the geometry, a choice of the exchange-correlation functional, and by setting an energy cutoff for the wavefunctions.

[6]:
gs = GroundState(geom,xc="PBE",ecut=40.0)

We are now able to generate the input file for QuantumEspresso.

[7]:
gs.generateInputPW()

Generated file:  pw.in

We can inspect the file pw.in

[8]:
with open("pw.in","r") as file :
    data = file.read()
    print(data)
&CONTROL
calculation       = 'scf'
restart_mode      = 'from_scratch'
pseudo_dir        = './'
outdir            = './'
prefix            = 'calc'
wf_collect        = .TRUE.
/
&SYSTEM
ibrav             = 0
nat               = 5
ntyp              = 2
ecutwfc           = 40.0
nbnd              = 8
input_dft         = 'PBE'
nosym             = .TRUE.
noinv             = .TRUE.
/
&ELECTRONS
diago_full_acc = .TRUE.
conv_thr       = 1.d-8
/
ATOMIC_SPECIES
C 12.011 C_ONCV_PBE-1.0.upf
H 1.008 H_ONCV_PBE-1.0.upf
ATOMIC_POSITIONS {bohr}
C 0.0 0.0 0.0
H 1.185992116575257 -1.185803143962673 1.185992116575257
H -1.185992116575257 1.185992116575257 1.185992116575257
H -1.185992116575257 -1.185992116575257 -1.185992116575257
H 1.185992116575257 1.185992116575257 -1.185992116575257
K_POINTS {gamma}
CELL_PARAMETERS {bohr}
25.0 0.0 0.0
0.0 25.0 0.0
0.0 0.0 25.0

We can optionally also download the pseudopotentials files.

[9]:
gs.downloadPseudopotentials()
Downloaded file:  C_ONCV_PBE-1.0.upf , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.0.upf
Downloaded file:  H_ONCV_PBE-1.0.upf , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/upf/H_ONCV_PBE-1.0.upf

Step 3.2: Ground State with Qbox

To generate the input for Qbox we can simply update Species to use the xml formats.

[10]:
gs.updateSpecies("C", "http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml")
gs.updateSpecies("H", "http://www.quantum-simulation.org/potentials/sg15_oncv/xml/H_ONCV_PBE-1.0.xml")

We are now able to generate the input file for QuantumEspresso.

[11]:
gs.generateInputQbox()

Generated file:  qbox.in

We can inspect the file qbox.in

[12]:
with open("qbox.in","r") as file :
    data = file.read()
    print(data)
set cell 25.0 0.0 0.0 0.0 25.0 0.0 0.0 0.0 25.0
species Carbon http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml
species Hydrogen http://www.quantum-simulation.org/potentials/sg15_oncv/xml/H_ONCV_PBE-1.0.xml
atom C1 Carbon 0.0 0.0 0.0
atom H2 Hydrogen 1.185992116575257 -1.185803143962673 1.185992116575257
atom H3 Hydrogen -1.185992116575257 1.185992116575257 1.185992116575257
atom H4 Hydrogen -1.185992116575257 -1.185992116575257 -1.185992116575257
atom H5 Hydrogen 1.185992116575257 1.185992116575257 -1.185992116575257
set ecut 40.0
set wf_dyn JD
set xc PBE
set scf_tol 1.e-8
randomize_wf
run -atomic_density 0 100 5
save gs.xml

We can optionally also download the pseudopotentials files.

[13]:
gs.downloadPseudopotentials()
Downloaded file:  C_ONCV_PBE-1.0.xml , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/xml/C_ONCV_PBE-1.0.xml
Downloaded file:  H_ONCV_PBE-1.0.xml , from url:  http://www.quantum-simulation.org/potentials/sg15_oncv/xml/H_ONCV_PBE-1.0.xml
[ ]: