Skip to content

Draft: Add option to discard static external potential in time-propagation TDDFT

This MR will add an option for TDDFT and LCAOTDDFT to discard the static external potential used in the GPAW calculator preparing the initial state. This enables modeling the dynamics resulting from a sudden switching off of the potential.

Note: The same code is duplicated in TDDFT and LCAOTDDFT classes, highlighting the need for #408.

MWE

This script prepares an initial state with a weak constant electric field and then switches the field off for time propagation (alternative way of calculating photoabsorption spectrum instead of delta-kick).

from ase.build import molecule
from ase.units import Hartree, Bohr
from gpaw import GPAW
from gpaw.external import ConstantElectricField
from gpaw.tddft import DipoleMomentWriter

mode = 'lcao'

if mode == 'lcao':
    from gpaw.lcaotddft import LCAOTDDFT as RTTDDFT
else:
    from gpaw.tddft import TDDFT as RTTDDFT


atoms = molecule('Na2')
atoms.center(vacuum=6.0)

cef = ConstantElectricField(1e-5 * Hartree / Bohr, [0, 0, 1])

calc = GPAW(mode=mode, h=0.4, basis='sz(dzp)',
            setups={'Na': '1'},
            external=cef,
            convergence={'density': 1e-12},
            txt='gs.out'
            )
atoms.calc = calc
energy = atoms.get_potential_energy()
calc.write('gs.gpw', mode='all')

# RTTDDFT
td_calc = RTTDDFT('gs.gpw',
                  keep_static_external_potential=False,
                  txt='td.out')
DipoleMomentWriter(td_calc, 'dm.dat')
td_calc.propagate(30, 100)
td_calc.write('td.gpw', mode='all')

# RTTDDFT restart
td_calc = RTTDDFT('td.gpw',
                  txt='tdc.out')
DipoleMomentWriter(td_calc, 'dm.dat')
td_calc.propagate(30, 100)
td_calc.write('td.gpw', mode='all')
For reference: same script using delta-kick.
from ase.build import molecule
from gpaw import GPAW
from gpaw.tddft import DipoleMomentWriter

mode = 'lcao'

if mode == 'lcao':
    from gpaw.lcaotddft import LCAOTDDFT as RTTDDFT
else:
    from gpaw.tddft import TDDFT as RTTDDFT


atoms = molecule('Na2')
atoms.center(vacuum=6.0)

calc = GPAW(mode=mode, h=0.4, basis='sz(dzp)',
            setups={'Na': '1'},
            convergence={'density': 1e-12},
            txt='gs1.out'
            )
atoms.calc = calc
energy = atoms.get_potential_energy()
calc.write('gs1.gpw', mode='all')

td_calc = RTTDDFT('gs1.gpw',
                  txt='td1.out')
DipoleMomentWriter(td_calc, 'dm1.dat')
td_calc.absorption_kick([0.0, 0.0, 1e-5])
td_calc.propagate(30, 100)
td_calc.write('td1.gpw', mode='all')


td_calc = RTTDDFT('td1.gpw',
                  txt='tdc1.out')
DipoleMomentWriter(td_calc, 'dm1.dat')
td_calc.propagate(30, 100)
td_calc.write('td1.gpw', mode='all')

Merge request reports