Debian Codegraph @

doc/tutorialsexercises/energetics/rpa_ex/si_pbe_exx.py

raw symbols SCIP
1 from ase.build import bulk
2 from gpaw import GPAW, FermiDirac
3 from gpaw import PW
4 from gpaw.hybrids.energy import non_self_consistent_energy as nsc_energy
5
6 from ase.parallel import paropen
7
8 resultfile = paropen('si.pbe+exx.results.txt', 'a')
9
10 # Plane wave cutoff
11 pwcutoff = 400.0
12
13 # NxNxN k-point sampling, gamma-centred grid
14 k = 6
15
16 # Si lattice constant
17 alat = 5.421
18
19 # Do the bulk calculation
20
21 bulk_crystal = bulk('Si', 'diamond', a=alat)
22 bulk_calc = GPAW(mode=PW(pwcutoff),
23 kpts={'size': (k, k, k), 'gamma': True},
24 xc='PBE',
25 occupations=FermiDirac(0.01),
26 txt='si.pbe+exx.pbe_output.txt',
27 parallel={'band': 1}
28 )
29
30 bulk_crystal.calc = bulk_calc
31 e0_bulk_pbe = bulk_crystal.get_potential_energy()
32
33 # Write to file
34 bulk_calc.write('bulk.gpw', mode='all')
35
36 # Now the exact exchange
37 e0_bulk_exx = nsc_energy('bulk.gpw', 'EXX').sum()
38
39 s = str(alat)
40 s += ' '
41 s += str(k)
42 s += ' '
43 s += str(pwcutoff)
44 s += ' '
45 s += str(e0_bulk_pbe)
46 s += ' '
47 s += str(e0_bulk_exx)
48 s += '\n'
49 resultfile.write(s)