lumo.py 2.24 KB
Newer Older
1 2 3
from numpy import reshape, dot

from ase.visualize import view
4
from ase.build import fcc111, add_adsorbate
5 6
from gpaw import GPAW
from gpaw.mixer import MixerSum
Jens Jørgen Mortensen's avatar
Jens Jørgen Mortensen committed
7
import gpaw.dscf as dscf
tolsen's avatar
tolsen committed
8

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
9
filename = 'lumo'
tolsen's avatar
tolsen committed
10

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
11 12 13 14
c_mol = GPAW(nbands=9,
             h=0.2,
             xc='RPBE',
             kpts=(8, 6, 1),
tolsen's avatar
tolsen committed
15 16 17 18
             spinpol=True,
             convergence={'energy': 100,
                          'density': 100,
                          'eigenstates': 1.0e-9,
Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
19 20
                          'bands': -2},
             txt='CO_lumo.txt')
tolsen's avatar
tolsen committed
21

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
22 23 24 25
calc = GPAW(nbands=80,
            h=0.2,
            xc='RPBE',
            kpts=(8, 6, 1),
tolsen's avatar
tolsen committed
26 27 28 29 30 31
            eigensolver='cg',
            spinpol=True,
            mixer=MixerSum(nmaxold=5, beta=0.1, weight=100),
            convergence={'energy': 100,
                         'density': 100,
                         'eigenstates': 1.0e-7,
Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
32 33
                         'bands': -10},
            txt=filename + '.txt')
tolsen's avatar
tolsen committed
34

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
35
# Import Slab with relaxed CO
tolsen's avatar
tolsen committed
36 37 38 39 40
slab = fcc111('Pt', size=(1, 2, 3), orthogonal=True)
add_adsorbate(slab, 'C', 2.0, 'ontop')
add_adsorbate(slab, 'O', 3.15, 'ontop')
slab.center(axis=2, vacuum=4.0)

41
view(slab)
tolsen's avatar
tolsen committed
42 43 44

molecule = slab.copy()

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
45
del molecule[:-2]
tolsen's avatar
tolsen committed
46

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
47
# Molecule
48
molecule.calc = c_mol
tolsen's avatar
tolsen committed
49 50
molecule.get_potential_energy()

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
51
# Find band corresponding to lumo
52
lumo = c_mol.get_pseudo_wave_function(band=5, kpt=0, spin=1)
tolsen's avatar
tolsen committed
53 54
lumo = reshape(lumo, -1)

55
wf1_k = [c_mol.get_pseudo_wave_function(band=5, kpt=k, spin=1)
56
         for k in range(c_mol.wfs.kd.nibzkpts)]
57
wf2_k = [c_mol.get_pseudo_wave_function(band=6, kpt=k, spin=1)
58
         for k in range(c_mol.wfs.kd.nibzkpts)]
tolsen's avatar
tolsen committed
59 60

band_k = []
61 62
for k in range(c_mol.wfs.kd.nibzkpts):

tolsen's avatar
tolsen committed
63 64 65 66 67 68 69 70 71
    wf1 = reshape(wf1_k[k], -1)
    wf2 = reshape(wf2_k[k], -1)
    p1 = abs(dot(wf1, lumo))
    p2 = abs(dot(wf2, lumo))
    if p1 > p2:
        band_k.append(5)
    else:
        band_k.append(6)

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
72
# Lumo wavefunction
73
wf_u = [kpt.psit_nG[band_k[kpt.k]] for kpt in c_mol.wfs.kpt_u]
tolsen's avatar
tolsen committed
74

Jens Jørgen Mortensen's avatar
PEP8  
Jens Jørgen Mortensen committed
75
# Lumo projector overlaps
76 77 78
mol = range(len(slab))[-2:]
p_uai = [dict([(mol[a], P_ni[band_k[kpt.k]]) for a, P_ni in kpt.P_ani.items()])
         for kpt in c_mol.wfs.kpt_u]
tolsen's avatar
tolsen committed
79 80

#   Slab with adsorbed molecule
81
slab.calc = calc
82
orbital = dscf.AEOrbital(calc, wf_u, p_uai)
tolsen's avatar
tolsen committed
83
dscf.dscf_calculation(calc, [[1.0, orbital, 1]], slab)
tolsen's avatar
tolsen committed
84
slab.get_potential_energy()