Пример #1
0
    c = 4.0
    H2 = Atoms([Atom('H', (a / 2, a / 2, (c - R) / 2)),
                Atom('H', (a / 2, a / 2, (c + R) / 2))],
               cell=(a, a, c))
    calc = GPAW(xc='PBE', nbands=3, spinpol=False, txt=txt)
    H2.set_calculator(calc)
    H2.get_potential_energy()

    xc='LDA'

    # without spin
    lr = LrTDDFT(calc, xc=xc)
    lr.diagonalize()
    t1 = lr[0]
    lr_calc = lr
    ex = ExcitedState(lr, 0)
    den = ex.get_pseudo_density() * Bohr**3

    # course grids
    for finegrid in [1,0]:
        lr = LrTDDFT(calc, xc=xc, finegrid=finegrid)
        lr.diagonalize()
        t3 = lr[0]
        parprint('finegrid, t1, t3=', finegrid, t1 ,t3)
        equal(t1.get_energy(), t3.get_energy(), 5.e-4)

    # with spin
    
    lr_vspin = LrTDDFT(calc, xc=xc, nspins=2)
    singlet, triplet = lr_vspin.singlets_triplets()
    lr_vspin.diagonalize()
Пример #2
0
a = 3.0
c = 4.0
H2 = Atoms([
    Atom('H', (a / 2, a / 2, (c - R) / 2)),
    Atom('H', (a / 2, a / 2, (c + R) / 2))
],
           cell=(a, a, c))
calc = GPAW(xc='PBE', h=0.25, nbands=3, spinpol=False, txt=txt)
H2.set_calculator(calc)

xc = 'LDA'
lr = LrTDDFT(calc, xc=xc)

# excited state with forces
accuracy = 0.015
exst = ExcitedState(lr, 0, d=0.01, parallel=2, txt=sys.stdout)

t0 = time.time()
parprint("########### first call to forces --> calculate")
forces = exst.get_forces(H2)
parprint("time used:", time.time() - t0)
for c in range(2):
    equal(forces[0, c], 0.0, accuracy)
    equal(forces[1, c], 0.0, accuracy)
equal(forces[0, 2] + forces[1, 2], 0.0, accuracy)

parprint("########### second call to potential energy --> just return")
t0 = time.time()
E = exst.get_potential_energy()
parprint("E=", E)
parprint("time used:", time.time() - t0)
box = 5.     # box dimension
h = 0.25     # grid spacing
width = 0.01 # Fermi width
nbands = 6   # bands in GS calculation
nconv = 4    # bands in GS calculation to converge
R = 2.99     # starting distance
iex = 1      # excited state index
d = 0.01     # step for numerical force evaluation
exc = 'LDA'  # xc for the linear response TDDFT kernel

s = Cluster([Atom('Na'), Atom('Na', [0, 0, R])])
s.minimal_box(box, h=h)

c = GPAW(h=h, nbands=nbands, eigensolver='cg',
         occupations=FermiDirac(width=width),
         setups={'Na': '1'},
         convergence={'bands':nconv})
c.calculate(s)
lr = LrTDDFT(c, xc=exc, eps=0.1, jend=nconv-1)

ex = ExcitedState(lr, iex, d=d)
s.set_calculator(ex)

ftraj='relax_ex' + str(iex)
ftraj += '_box' + str(box) + '_h' + str(h)
ftraj += '_d' + str(d) + '.traj'
traj = io.PickleTrajectory(ftraj, 'w', s)
dyn = optimize.FIRE(s)
dyn.attach(traj.write)
dyn.run(fmax=0.05)
Пример #4
0
R=0.7 # approx. experimental bond length
a = 3.0
c = 4.0
H2 = Atoms([Atom('H', (a / 2, a / 2, (c - R) / 2)),
            Atom('H', (a / 2, a / 2, (c + R) / 2))],
           cell=(a, a, c))
calc = GPAW(xc='PBE', h=0.25, nbands=3, spinpol=False, txt=txt)
H2.set_calculator(calc)

xc='LDA'
lr = LrTDDFT(calc, xc=xc)

# excited state with forces
accuracy = 0.015
exst = ExcitedState(lr, 0, d=0.01,
        parallel=2,
        txt=sys.stdout,
      )

t0 = time.time()
parprint("########### first call to forces --> calculate")
forces = exst.get_forces(H2)
parprint("time used:", time.time() - t0)
for c in range(2):
    equal(forces[0,c], 0.0, accuracy)
    equal(forces[1,c], 0.0, accuracy)
equal(forces[0, 2] + forces[1, 2], 0.0, accuracy)


parprint("########### second call to potential energy --> just return")
t0 = time.time()
E = exst.get_potential_energy()
Пример #5
0
    calc = GPAW(xc='PBE',
                poissonsolver={'name': 'fd'},
                nbands=3,
                spinpol=False,
                txt=txt)
    H2.set_calculator(calc)
    H2.get_potential_energy()

    xc = 'LDA'

    # without spin
    lr = LrTDDFT(calc, xc=xc)
    lr.diagonalize()
    t1 = lr[0]
    lr_calc = lr
    ex = ExcitedState(lr, 0)
    den = ex.get_pseudo_density() * Bohr**3

    # velocity from
    for ozr, ozv in zip(t1.get_oscillator_strength(),
                        t1.get_oscillator_strength('v')):
        equal(ozr, ozv, 0.1)

    # course grids
    for finegrid in [1, 0]:
        lr = LrTDDFT(calc, xc=xc, finegrid=finegrid)
        lr.diagonalize()
        t3 = lr[0]
        parprint('finegrid, t1, t3=', finegrid, t1, t3)
        equal(t1.get_energy(), t3.get_energy(), 5.e-4)