# 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 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')
# Calculate ground state in LCAO mode calc = GPAW(xc='GLLBSC', basis='GLLBSC.dz', h=0.3, nbands=352, mode='lcao', convergence=convergence, poissonsolver=poissonsolver, occupations=FermiDirac(0.1), parallel={ 'sl_default': (8, 6, 32), 'band': 2 }) atoms.set_calculator(calc) # Relax the ground state atoms.get_potential_energy() # Save the intermediate ground state result to a file calc.write('ag55_gs.gpw', mode='all') # Time propagation td_calc = LCAOTDDFT('ag55_gs.gpw', parallel={ 'sl_default': (8, 6, 32), 'band': 2 }) DipoleMomentWriter(td_calc, 'ag55.dm') td_calc.absorption_kick([1e-5, 0.0, 0.0]) td_calc.propagate(20, 500) photoabsorption_spectrum('ag55.dm', 'ag55.spec', width=0.2)
xc='oldLDA', poissonsolver=PoissonSolver(eps=1e-16), convergence={'density': 1e-8}, txt='gs.out') atoms.set_calculator(calc) energy = atoms.get_potential_energy() calc.write('gs.gpw', mode='all') # Time-propagation calculation td_calc = LCAOTDDFT('gs.gpw', txt='td.out') DipoleMomentWriter(td_calc, 'dm.dat') td_calc.absorption_kick([0, 0, 1e-5]) td_calc.propagate(30, 150) photoabsorption_spectrum('dm.dat', 'spec.dat', e_max=10, width=0.5, delta_e=0.1) # LrTDDFT2 calculation calc = GPAW('gs.gpw', txt='lr.out') lr = LrTDDFT2('lr2', calc, fxc='LDA') lr.calculate() lr.get_spectrum('lr_spec.dat', 0, 10.1, 0.1, width=0.5) world.barrier() # Scale spectra due to slightly different definitions spec1_ej = np.loadtxt('spec.dat') data1_e = spec1_ej[:, 3] data1_e[1:] /= spec1_ej[1:, 0] spec2_ej = np.loadtxt('lr_spec.dat')
from gpaw.tddft.spectrum import photoabsorption_spectrum photoabsorption_spectrum('dm.dat', 'spec.dat', folding='Gauss', width=0.1, e_min=0.0, e_max=10.0, delta_e=0.01)
setups=dict(Na='1'), basis='dzp', mode='lcao', poissonsolver=PoissonSolver('fd', eps=1e-16), convergence={'density': 1e-8}, txt='gs.out') atoms.set_calculator(calc) energy = atoms.get_potential_energy() calc.write('gs.gpw', mode='all') # Time-propagation calculation td_calc = LCAOTDDFT('gs.gpw', txt='td.out') DipoleMomentWriter(td_calc, 'dm.dat') td_calc.absorption_kick(np.ones(3) * 1e-5) td_calc.propagate(20, 3) photoabsorption_spectrum('dm.dat', 'spec.dat', delta_e=5) world.barrier() # Test dipole moment data_i = np.loadtxt('dm.dat')[:, 2:].ravel() if 0: from gpaw.test import print_reference print_reference(data_i, 'ref_i', '%.12le') ref_i = [ 4.786589735249e-15, 6.509942495725e-15, 3.836848815869e-14, 4.429061708370e-15, 7.320865686028e-15, 2.877243538173e-14, 1.967175332445e-05, 1.967175332505e-05, 1.805003047148e-05, 3.799528613595e-05, 3.799528613766e-05, 3.602504333467e-05, 5.371491630029e-05, 5.371491629857e-05, 5.385043148270e-05 ]
WaveFunctionWriter(td_calc, 'wf.ulm') WaveFunctionWriter(td_calc, 'wf_split.ulm', split=True) td_calc.absorption_kick(np.ones(3) * 1e-5) td_calc.propagate(20, 3) td_calc.write('td.gpw', mode='all') td_calc.propagate(7, 3) # Restart from the restart point td_calc = LCAOTDDFT('td.gpw', txt='td2.out') DipoleMomentWriter(td_calc, 'dm.dat') WaveFunctionWriter(td_calc, 'wf.ulm') WaveFunctionWriter(td_calc, 'wf_split.ulm') td_calc.propagate(20, 3) td_calc.propagate(20, 3) td_calc.propagate(10, 3) photoabsorption_spectrum('dm.dat', 'spec.dat') world.barrier() ref_i = np.loadtxt('spec.dat').ravel() # Replay both wf*.ulm files for tag in ['', '_split']: td_calc = LCAOTDDFT('gs.gpw', txt='rep%s.out' % tag) DipoleMomentWriter(td_calc, 'dm_rep%s.dat' % tag) td_calc.replay(name='wf%s.ulm' % tag, update='density') photoabsorption_spectrum('dm_rep%s.dat' % tag, 'spec_rep%s.dat' % tag) world.barrier() # Check the spectrum files # Do this instead of dipolemoment files in order to see that the kick
energy = atoms.get_potential_energy() calc.write('gs.gpw', mode='all') # Time-propagation calculation td_calc = LCAOTDDFT('gs.gpw', txt='td.out') dmat = DensityMatrix(td_calc) freqs = frequencies(range(0, 31, 5), 'Gauss', 0.1) fdm = FrequencyDensityMatrix(td_calc, dmat, frequencies=freqs) DipoleMomentWriter(td_calc, 'dm.dat') kick_v = np.ones(3) * 1e-5 td_calc.absorption_kick(kick_v) td_calc.propagate(20, 3) fdm.write('fdm.ulm') # Calculate reference spectrum photoabsorption_spectrum('dm.dat', 'spec.dat', delta_e=5, width=0.1) world.barrier() ref_wv = np.loadtxt('spec.dat')[:, 1:] # Calculate ground state with full unoccupied space calc = GPAW('gs.gpw', nbands='nao', fixdensity=True, txt='unocc.out') atoms = calc.get_atoms() energy = atoms.get_potential_energy() calc.write('unocc.gpw', mode='all') # Construct KS electron-hole basis ksd = KohnShamDecomposition(calc) ksd.initialize(calc) ksd.write('ksd.ulm') # Load the objects