Debian Codegraph @

doc/tutorialsexercises/opticalresponse/tddft/lrtddft2/lr2_restart.py

raw
1 # web-page: lr2_with_08.00eV.out
2 # web-page: spectrum_with_08.00eV.dat
3 # web-page: transitions_with_08.00eV.dat
4 # Start
5 from gpaw.mpi import world
6 from gpaw import GPAW
7 from gpaw.lrtddft2 import LrTDDFT2
8 from gpaw.lrtddft2.lr_communicators import LrCommunicators
9
10 # Maximum energy difference for Kohn-Sham transitions
11 # included in the calculation
12 max_energy_diff = 8.0 # eV
13
14 # Set parallelization
15 dd_size = 2 * 2 * 2
16 eh_size = world.size // dd_size
17 assert eh_size * dd_size == world.size
18 lr_comms = LrCommunicators(world, dd_size, eh_size)
19
20 calc = GPAW('unocc.gpw',
21 communicator=lr_comms.dd_comm)
22 lr = LrTDDFT2('lr2', calc,
23 fxc='LDA',
24 max_energy_diff=max_energy_diff,
25 recalculate=None, # Change this to force recalculation
26 lr_communicators=lr_comms,
27 txt='lr2_with_%05.2feV.out' % max_energy_diff)
28
29 # This is the expensive part triggering the calculation!
30 lr.calculate()
31
32 # Get and write spectrum
33 spec = lr.get_spectrum('spectrum_with_%05.2feV.dat'
34 % max_energy_diff,
35 min_energy=0,
36 max_energy=10,
37 energy_step=0.01,
38 width=0.1)
39
40 # Get and write transitions
41 trans = lr.get_transitions('transitions_with_%05.2feV.dat'
42 % max_energy_diff,
43 min_energy=0.0,
44 max_energy=10.0)