Debian Codegraph @

doc/tutorialsexercises/energetics/rpa_ex/atom/si.atom.pbe+exx.py

raw symbols SCIP
1 from ase import Atoms
2 from gpaw import GPAW, FermiDirac, Mixer
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 # This calculation is too heavy to run as an exercise!!
9
10 myresults = paropen('si.atom.pbe_and_exx_energies.txt', 'a')
11
12 # Plane wave cutoff
13 pwcutoff = 400.0
14
15 # Do the isolated calculation
16
17 for L in [6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]:
18 isolated_silicon = Atoms(
19 symbols=['Si'],
20 positions=[[0.5 * L, 0.5 * L, 0.5 * L]],
21 cell=[L + 0.1, L, L - 0.1],
22 pbc=(1, 1, 1))
23
24 isolated_calc = GPAW(
25 mode=PW(pwcutoff, force_complex_dtype=True),
26 xc='PBE',
27 txt='si_isolated_pbe.txt',
28 occupations=FermiDirac(0.01),
29 spinpol=True,
30 hund=True,
31 # convergence={'density': 1.e-6},
32 mixer=Mixer(beta=0.05, nmaxold=5, weight=50.0))
33
34 isolated_silicon.calc = isolated_calc
35
36 e0_isolated_pbe = isolated_silicon.get_potential_energy()
37 isolated_calc.write('si.pbe+exx.isolated.gpw', mode='all')
38
39 # Now the exact exchange
40 si_isolated_exx = nsc_energy('si.pbe+exx.isolated.gpw',
41 'EXX').sum()
42
43 s = str(L)
44 s += ' '
45 s += str(e0_isolated_pbe)
46 s += ' '
47 s += str(si_isolated_exx)
48 s += '\n'
49 myresults.write(s)