Commit 914041d8 authored by Tuomas Rossi's avatar Tuomas Rossi

Update and clean LCAOTDDFT tutorial

parent 76c944ac
# Simplest example of use of LCAO-TDDFT code
from ase import Atoms
from gpaw.tddft import photoabsorption_spectrum
from gpaw import PoissonSolver
# Simple example of the use of LCAO-TDDFT code
# Sodium dimer
atoms = Atoms('Na2', positions=[[0.0, 0.0, 0.0], [3.0, 0.0, 0.0]])
atoms.center(vacuum=3.5)
from ase.build import molecule
atoms = molecule('Na2')
atoms.center(vacuum=6.0)
# Poisson solver with increased accuracy and multipole corrections up to l=2
from gpaw import PoissonSolver
poissonsolver = PoissonSolver(eps=1e-20,
remove_moment=1 + 3 + 5)
# Ground-state calculation
from gpaw import GPAW
calc = GPAW(mode='lcao', h=0.3, basis='dzp',
setups={'Na': '1'},
poissonsolver=poissonsolver,
convergence={'density': 1e-8})
atoms.set_calculator(calc)
energy = atoms.get_potential_energy()
calc.write('gs.gpw', mode='all')
# Time-propagation calculation
from gpaw.lcaotddft import LCAOTDDFT
# Increase accuragy of density for ground state
convergence = {'density': 1e-7}
# Increase accuracy of Poisson Solver and apply multipole corrections up to l=1
poissonsolver = PoissonSolver(eps=1e-14, remove_moment=1 + 3)
td_calc = LCAOTDDFT(
setups={'Na': '1'}, basis='dzp', xc='LDA', h=0.3, nbands=1,
convergence=convergence, poissonsolver=poissonsolver)
atoms.set_calculator(td_calc)
# Relax the ground state
atoms.get_potential_energy()
td_calc.absorption_kick([1e-5, 0.0, 0.0])
td_calc.propagate(20, 250, 'Na2.dm')
photoabsorption_spectrum('Na2.dm', 'Na2.spec', width=0.4)
from gpaw.lcaotddft.dipolemomentwriter import DipoleMomentWriter
# Read converged ground-state file
td_calc = LCAOTDDFT('gs.gpw')
# Attach any data recording or analysis tools
DipoleMomentWriter(td_calc, 'dm.dat')
# Kick
td_calc.absorption_kick([0.0, 0.0, 1e-5])
# Propagate
td_calc.propagate(10, 3000)
# Save the state for restarting later
td_calc.write('td.gpw', mode='all')
# Analyze the results
from gpaw.tddft.spectrum import photoabsorption_spectrum
photoabsorption_spectrum('dm.dat', 'spec.dat')
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment