Пример #1
0
slab = fcc111('Pt', size=(1, 2, 3), orthogonal=True)
add_adsorbate(slab, 'C', 2.0, 'ontop')
add_adsorbate(slab, 'O', 3.15, 'ontop')
slab.center(axis=2, vacuum=4.0)

view(slab)

molecule = slab.copy()

del molecule[:-2]

# Molecule
molecule.set_calculator(c_mol)
molecule.get_potential_energy()

# H**o wavefunction
wf_u = [kpt.psit_nG[4] for kpt in c_mol.wfs.kpt_u]

# H**o projector overlaps
mol = range(len(slab))[-2:]
p_uai = [
    dict([(mol[a], P_ni[4]) for a, P_ni in kpt.P_ani.items()])
    for kpt in c_mol.wfs.kpt_u
]

# Slab with adsorbed molecule
slab.set_calculator(calc)
orbital = dscf.AEOrbital(calc, wf_u, p_uai, Estart=-100.0, Eend=0.0)
dscf.dscf_calculation(calc, [[-1.0, orbital, 1]], slab)
slab.get_potential_energy()
Пример #2
0
         for k in range(len(c_mol.wfs.weight_k))]
wf2_k = [c_mol.get_pseudo_wave_function(band=6, kpt=k, spin=1)
         for k in range(len(c_mol.wfs.weight_k))]

band_k = []
for k in range(len(c_mol.wfs.weight_k)):
    
    wf1 = reshape(wf1_k[k], -1)
    wf2 = reshape(wf2_k[k], -1)
    p1 = abs(dot(wf1, lumo))
    p2 = abs(dot(wf2, lumo))
    if p1 > p2:
        band_k.append(5)
    else:
        band_k.append(6)

#Lumo wavefunction
wf_u = [kpt.psit_nG[band_k[kpt.k]] for kpt in c_mol.wfs.kpt_u]

#Lumo projector overlaps
mol = range(len(slab))[-2:]
p_uai = [dict([(mol[a], P_ni[band_k[kpt.k]]) for a, P_ni in kpt.P_ani.items()])
         for kpt in c_mol.wfs.kpt_u]

#   Slab with adsorbed molecule
#-----------------------------------
slab.set_calculator(calc)
orbital = dscf.AEOrbital(calc, wf_u, p_uai)
dscf.dscf_calculation(calc, [[1.0, orbital, 1]], slab)
slab.get_potential_energy()
Пример #3
0
        # state which is to be occupied. n=5,6 is the 2pix and 2piy orbitals
        n = 5
        molecule = [0, 1]
        wf_u = [kpt.psit_nG[n].copy() for kpt in calc.wfs.kpt_u]
        p_uai = [
            dict([(molecule[a], P_ni[n].copy())
                  for a, P_ni in kpt.P_ani.items()]) for kpt in calc.wfs.kpt_u
        ]

        #calc = GPAW(h=0.2, nbands=10, xc='PBE', spinpol=True,
        #            convergence={'bands': -2, 'eigenstates': 1.0e-9},
        #            occupations=FermiDirac(0.1), txt=name + '_es.txt')
        #atoms.set_calculator(calc)

        lumo = AEOrbital(calc, wf_u, p_uai)
        dscf_calculation(calc, [[1.0, lumo, 1]], atoms)
        e2 = atoms.get_potential_energy()
        if world.rank == 0:
            print('e1:', e1, 'e2:', e2, 'de:', e2 - e1)
        calc.write(name + '_es.gpw', mode='all')
        del wf_u, p_uai, lumo, calc, atoms
        time.sleep(10)

    while not os.path.isfile(name + '_es.gpw'):
        print('Node %d waiting for %s...' % (world.rank, name + '_es.gpw'))
        time.sleep(10)
    world.barrier()

    if not os.path.isfile(name + '_esx.gpw'):
        calc = GPAW(name + '_es.gpw',
                    txt=name + '_esx.txt',
Пример #4
0
molecule = [0,1]
wf_u = [kpt.psit_nG[n] for kpt in calc_mol.wfs.kpt_u]
p_uai = [dict([(molecule[a], P_ni[n]) for a, P_ni in kpt.P_ani.items()])
         for kpt in calc_mol.wfs.kpt_u]

# Excited state calculations
#--------------------------------------------
calc_1 = GPAW(nbands=8, h=0.2, xc='PBE', spinpol=True,
              convergence={'energy': 100,
                           'density': 100,
                           #'eigenstates': 1.0e-9,
                           'bands': -1})
CO.set_calculator(calc_1)
weights = {0: [0.,0.,0.,1.], 1: [0.,0.,0.,-1.]}
lumo = dscf.MolecularOrbital(calc_1, weights=weights)
dscf.dscf_calculation(calc_1, [[1.0, lumo, 1]], CO)
E_es1 = CO.get_potential_energy()
niter_es1 = calc_1.get_number_of_iterations()
calc_1.write('dscf_CO_es1.gpw', mode='all')

calc_2 = GPAW(nbands=8, h=0.2, xc='PBE', spinpol=True,
              convergence={'energy': 100,
                          'density': 100,
                           #'eigenstates': 1.0e-9,
                           'bands': -1})
CO.set_calculator(calc_2)
lumo = dscf.AEOrbital(calc_2, wf_u, p_uai)
dscf.dscf_calculation(calc_2, [[1.0, lumo, 1]], CO)
E_es2 = CO.get_potential_energy()
niter_es2 = calc_2.get_number_of_iterations()
calc_2.write('dscf_CO_es2.gpw', mode='all')
Пример #5
0
                       'density': 100,
                       'eigenstates': 1.0e-9,
                       'bands': -1
                   })

    n = 5  # LUMO
    molecule = [0, 1]
    wf_u = [kpt.psit_nG[n] for kpt in calc_gs.wfs.kpt_u]
    p_uai = [
        dict([(molecule[a], P_ni[n]) for a, P_ni in kpt.P_ani.items()])
        for kpt in calc_gs.wfs.kpt_u
    ]

    atoms.set_calculator(calc_es)
    lumo = dscf.AEOrbital(calc_es, wf_u, p_uai)
    dscf.dscf_calculation(calc_es, [[1.0, lumo, 1]], atoms)

    E1.append(atoms.get_potential_energy())
    if i == 1:
        F1 = atoms.get_forces()

f0 = np.sqrt(((F0[1, :] - F0[0, :])**2).sum()) * 0.5
f0b = (E0[1] - E0[0]) / delta  # backward gradient
f0f = (E0[2] - E0[1]) / delta  # forward gradient
if rank == 0:
    print('Ground state')
    print(E0)
    print(f0b, '<', f0, '<', f0f)
assert f0 > f0b
assert f0 < f0f
Пример #6
0
                   txt = None,
                   mixer = MixerSum(beta=0.1, nmaxold=5, weight=50.0),
                   convergence = {'energy': 100,
                                  'density': 100,
                                  'eigenstates': 1.0e-9,
                                  'bands': -1})

    n = 5 # LUMO
    molecule = [0, 1]
    wf_u = [kpt.psit_nG[n] for kpt in calc_gs.wfs.kpt_u]
    p_uai = [dict([(molecule[a], P_ni[n]) for a, P_ni in kpt.P_ani.items()])
             for kpt in calc_gs.wfs.kpt_u]

    atoms.set_calculator(calc_es)
    lumo = dscf.AEOrbital(calc_es, wf_u, p_uai)
    dscf.dscf_calculation(calc_es, [[1.0, lumo, 1]], atoms)

    E1.append(atoms.get_potential_energy())
    if i==1:
        F1 = atoms.get_forces()

f0 = np.sqrt(((F0[1,:] - F0[0,:])**2).sum()) * 0.5
f0b = (E0[1] - E0[0]) / delta     # backward gradient
f0f = (E0[2] - E0[1]) / delta     # forward gradient
if rank == 0:
    print 'Ground state'
    print E0
    print f0b, '<', f0, '<', f0f
assert f0 > f0b
assert f0 < f0f 
Пример #7
0
        # Obtain the pseudowavefunctions and projector overlaps of the
        # state which is to be occupied. n=5,6 is the 2pix and 2piy orbitals
        n = 5
        molecule = [0, 1]
        wf_u = [kpt.psit_nG[n].copy() for kpt in calc.wfs.kpt_u]
        p_uai = [dict([(molecule[a], P_ni[n].copy()) for a, P_ni in 
                 kpt.P_ani.items()]) for kpt in calc.wfs.kpt_u]

        #calc = GPAW(h=0.2, nbands=10, xc='PBE', spinpol=True,
        #            convergence={'bands': -2, 'eigenstates': 1.0e-9},
        #            occupations=FermiDirac(0.1), txt=name + '_es.txt')
        #atoms.set_calculator(calc)

        lumo = AEOrbital(calc, wf_u, p_uai)
        dscf_calculation(calc, [[1.0, lumo, 1]], atoms)
        e2 = atoms.get_potential_energy()
        if world.rank == 0:
            print 'e1:', e1, 'e2:', e2, 'de:', e2-e1
        calc.write(name + '_es.gpw', mode='all')
        del wf_u, p_uai, lumo, calc, atoms
        time.sleep(10)

    while not os.path.isfile(name + '_es.gpw'):
        print 'Node %d waiting for %s...' % (world.rank, name + '_es.gpw')
        time.sleep(10)
    world.barrier()

    if not os.path.isfile(name + '_esx.gpw'):
        calc = GPAW(name + '_es.gpw', txt=name + '_esx.txt', parallel={'band': 1})
        calc.set_positions()