Beispiel #1
0
def gpawRestart(calc):
    from gpaw import restart, PW, Davidson, Mixer, MixerSum, FermiDirac
    return restart(
        'preCalc_inp.gpw',
        mode=PW(calc.pw),
        xc=calc.xc,
        kpts={
            'density': calc.kpt,
            'gamma': True
        } if isinstance(calc.kpt, int) else calc.kpt,
        spinpol=calc.magmom > 0,
        convergence={'energy': calc.eConv}  #eV/electron
        ,
        mixer=((MixerSum(beta=calc.mixing, nmaxold=calc.nmix, weight=100))
               if calc.magmom > 0 else
               (Mixer(beta=calc.mixing, nmaxold=calc.nmix, weight=100))),
        maxiter=calc.maxsteps,
        nbands=-1 * calc.nbands,
        occupations=FermiDirac(calc.sigma),
        setups='sg15'  #(pspDict[calc.psp]).pthFunc[cluster]
        ,
        eigensolver=Davidson(5),
        poissonsolver=
        None  # {'dipolelayer': 'xy'} if isinstance(self,SurfaceJob) else None
        ,
        txt=str(calc) + '.txt',
        symmetry={'do_not_symmetrize_the_density':
                  True}  #ERROR IN LI bcc 111 surface
    )
Beispiel #2
0
 def PBEcalc(self):
     from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac
     return GPAW(
         mode=PW(self.pw())  #eV
         ,
         xc='PBE',
         kpts=self.kpt(),
         spinpol=self.spinpol(),
         convergence={'energy': self.econv()}  #eV/electron
         ,
         mixer=(
             (MixerSum(beta=self.mixing(), nmaxold=self.nmix(), weight=100))
             if self.spinpol() else
             (Mixer(beta=self.mixing(), nmaxold=self.nmix(), weight=100))),
         maxiter=self.maxstep(),
         nbands=self.nbands(),
         occupations=FermiDirac(self.sigma()),
         setups=self.psp(),
         eigensolver=Davidson(5),
         poissonsolver=
         None  # {'dipolelayer': 'xy'} if isinstance(self,SurfaceJob) else None
         ,
         txt='%d_%s.txt' % (self.pw(), self.xc()),
         symmetry={'do_not_symmetrize_the_density':
                   True})  #ERROR IN LI bcc 111 surface
Beispiel #3
0
    def gpawRestart(self):
        from gpaw import restart, PW, Davidson, Mixer, MixerSum, FermiDirac

        spinpol = any([x > 0 for x in self.magmomsinit()])

        return restart(
            'preCalc_inp.gpw',
            mode=PW(self.pw),
            xc=self.xc,
            kpts=self.kpt(),
            spinpol=spinpol,
            convergence={'energy': self.econv()}  #eV/electron
            ,
            mixer=(
                (MixerSum(beta=self.mixing(), nmaxold=self.nmix(), weight=100))
                if spinpol else
                (Mixer(beta=self.mixing(), nmaxold=self.nmix(), weight=100))),
            maxiter=self.maxstep(),
            nbands=self.nbands(),
            occupations=FermiDirac(self.sigma()),
            setups=self.psp  #(pspDict[calc.psp]).pthFunc[cluster]
            ,
            eigensolver=Davidson(5),
            poissonsolver=
            None  # {'dipolelayer': 'xy'} if isinstance(self,SurfaceJob) else None
            ,
            txt='%d_%s.txt' % (self.pw, self.xc),
            symmetry={'do_not_symmetrize_the_density':
                      True})  #ERROR IN LI bcc 111 surface
Beispiel #4
0
def gpawCalc(calc, restart=False, surf=False):
    """
	Accepts a job (either Surface or Bulk) and returns a Calculator
	"""
    from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac

    return GPAW(
        mode=PW(calc.pw)  #eV
        ,
        xc=calc.xc,
        kpts={
            'density': calc.kpt,
            'gamma': True
        } if isinstance(calc.kpt, int) else calc.kpt,
        spinpol=calc.magmom > 0,
        convergence={'energy': calc.eConv}  #eV/electron
        ,
        mixer=((MixerSum(beta=calc.mixing, nmaxold=calc.nmix, weight=100))
               if calc.magmom > 0 else
               (Mixer(beta=calc.mixing, nmaxold=calc.nmix, weight=100))),
        maxiter=calc.maxsteps,
        nbands=-1 * calc.nbands,
        occupations=FermiDirac(calc.sigma),
        setups='sg15',
        eigensolver=Davidson(5),
        poissonsolver=
        None  # {'dipolelayer': 'xy'} if isinstance(self,SurfaceJob) else None
        ,
        txt=str(calc) + '.txt',
        symmetry={'do_not_symmetrize_the_density':
                  True}  #ERROR IN LI bcc 111 surface
    )
Beispiel #5
0
    def makeGPAWcalc():
        from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac, setup_paths

        if p['psp'] == 'oldpaw':
            setup_paths.insert(
                0, '/scratch/users/ksb/gpaw/oldpaw/gpaw-setups-0.6.6300/')
            psp = 'paw'
        else:
            psp = p['psp']

        return GPAW(
            mode=PW(p['pw']),
            xc=p['xc'],
            kpts=json.loads(p['kpts']),
            spinpol=p['spinpol'],
            convergence={'energy': p['econv']}  #eV/electron
            ,
            mixer=((MixerSum(beta=p['mixing'], nmaxold=p['nmix'], weight=100))
                   if p['spinpol'] else
                   (Mixer(beta=p['mixing'], nmaxold=p['nmix'], weight=100))),
            maxiter=p['maxstep'],
            nbands=p['nbands'],
            occupations=FermiDirac(p['sigma']),
            setups=psp,
            eigensolver=Davidson(5),
            poissonsolver=None,
            txt='log',
            symmetry={'do_not_symmetrize_the_density': True})
Beispiel #6
0
 def makeGPAWcalc(p):
     from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac
     return GPAW(
         mode=PW(p['pw']),
         xc=p['xc'],
         kpts=kpt,
         spinpol=spinpol,
         convergence={'energy': p['econv']}  #eV/electron
         ,
         mixer=((MixerSum(beta=p['mixing'], nmaxold=p['nmix'], weight=100))
                if spinpol else
                (Mixer(beta=p['mixing'], nmaxold=p['nmix'], weight=100))),
         maxiter=p['maxstep'],
         nbands=p['nbands'],
         occupations=FermiDirac(p['sigma']),
         setups=p['psp'],
         eigensolver=Davidson(5),
         poissonsolver=None,
         txt='log',
         symmetry={'do_not_symmetrize_the_density': True})
Beispiel #7
0
 def gpawCalc(self, xc, spinpol):
     from gpaw import GPAW, PW, Davidson, Mixer, MixerSum, FermiDirac
     return GPAW(
         mode=PW(self.pw)  #eV
         ,
         xc=xc,
         kpts=self.kpt,
         spinpol=spinpol,
         convergence={'energy': self.econv}  #eV/electron
         ,
         mixer=((MixerSum(beta=self.mixing, nmaxold=self.nmix, weight=100))
                if spinpol else
                (Mixer(beta=self.mixing, nmaxold=self.nmix, weight=100))),
         maxiter=self.maxstep,
         nbands=-1 * self.nbands,
         occupations=FermiDirac(self.sigma),
         setups='sg15',
         eigensolver=Davidson(5),
         poissonsolver=
         None  # {'dipolelayer': 'xy'} if isinstance(self,SurfaceJob) else None
         ,
         txt='%d_%s.txt' % (self.pw, xc),
         symmetry={'do_not_symmetrize_the_density':
                   True})  #ERROR IN LI bcc 111 surface
Beispiel #8
0
# this test should coverage the save and restore of
# fermi-levels when using fixmagmom:
#
# yes, fermi-level-splitting sounds a little bit strange
import numpy as np

from ase import Atoms
from gpaw import GPAW, FermiDirac, MixerSum
from gpaw.test import equal

calc = GPAW(occupations=FermiDirac(width=0.1, fixmagmom=True),
            mixer=MixerSum(beta=0.05, nmaxold=3, weight=50.0),
            convergence={
                'energy': 0.1,
                'eigenstates': 1.e-4,
                'density': 1.e-2
            })
atoms = Atoms('Cr', pbc=False)
atoms.center(vacuum=4)
mm = [1] * 1
mm[0] = 6.
atoms.set_initial_magnetic_moments(mm)
atoms.set_calculator(calc)
atoms.get_potential_energy()

ef1 = calc.occupations.get_fermi_levels_mean()
efsplit1 = calc.occupations.get_fermi_splitting()

ef3 = calc.occupations.get_fermi_levels()
calc.write("test.gpw")
Beispiel #9
0
d0 = 1.4
delta = 0.05
for i in range(3):
    d = d0 + (i - 1) * delta
    atoms = Atoms('N2', [[0.5 * L, 0.5 * L, 0.5 * L - 0.5 * d],
                         [0.5 * L, 0.5 * L, 0.5 * L + 0.5 * d]])
    atoms.set_cell([L, L, L])

    calc_gs = GPAW(h=0.2,
                   nbands=-5,
                   xc=xc,
                   width=0.05,
                   eigensolver=eigensolver,
                   spinpol=True,
                   txt=None,
                   mixer=MixerSum(beta=0.1, nmaxold=5, weight=50.0),
                   convergence={
                       'energy': 100,
                       'density': 100,
                       'eigenstates': 1.0e-9,
                       'bands': -1
                   })
    atoms.set_calculator(calc_gs)

    E0.append(atoms.get_potential_energy())
    if i == 1:
        F0 = atoms.get_forces()

    calc_es = GPAW(h=0.2,
                   nbands=-5,
                   xc=xc,
Beispiel #10
0
from __future__ import print_function
from ase import Atoms
from ase.units import Hartree
from gpaw import GPAW, PoissonSolver, FermiDirac, Davidson, MixerSum
from gpaw.test import equal

a = 5.0
n = 24
li = Atoms('Li', magmoms=[1.0], cell=(a, a, a), pbc=True)

calc = GPAW(gpts=(n, n, n), nbands=1, xc='PBE',
            poissonsolver=PoissonSolver(nn='M', relax='GS'),
            mixer=MixerSum(0.3, 5, 10.0),
            eigensolver=Davidson(12),
            convergence=dict(eigenstates=4.5e-8),
            occupations=FermiDirac(0.0))
li.set_calculator(calc)
e = li.get_potential_energy() + calc.get_reference_energy()
niter_PBE = calc.get_number_of_iterations()
equal(e, -7.462 * Hartree, 1.4)

calc.set(xc='revPBE')
erev = li.get_potential_energy() + calc.get_reference_energy()
niter_revPBE = calc.get_number_of_iterations()

equal(erev, -7.487 * Hartree, 1.3)
equal(e - erev, 0.025 * Hartree, 0.002 * Hartree)

print(e, erev)
energy_tolerance = 0.0002
niter_tolerance = 0
Beispiel #11
0
def getkwargs():
    return dict(eigensolver=Davidson(4), mixer=MixerSum(0.5, 5, 10.0))
Beispiel #12
0
from __future__ import print_function
from ase import Atoms
from ase.units import Hartree
from gpaw import GPAW, PoissonSolver, FermiDirac, Davidson, MixerSum
from gpaw.test import equal

a = 5.0
n = 24
li = Atoms('Li', magmoms=[1.0], cell=(a, a, a), pbc=True)

calc = GPAW(gpts=(n, n, n),
            nbands=1,
            xc=dict(name='oldPBE', stencil=1),
            poissonsolver=PoissonSolver(),
            mixer=MixerSum(0.6, 5, 10.0),
            eigensolver=Davidson(4),
            convergence=dict(eigenstates=4.5e-8),
            occupations=FermiDirac(0.0))
li.set_calculator(calc)
e = li.get_potential_energy() + calc.get_reference_energy()
niter_PBE = calc.get_number_of_iterations()
equal(e, -7.462 * Hartree, 1.4)

calc.set(xc=dict(name='revPBE', stencil=1))
erev = li.get_potential_energy() + calc.get_reference_energy()
niter_revPBE = calc.get_number_of_iterations()

equal(erev, -7.487 * Hartree, 1.3)
equal(e - erev, 0.025 * Hartree, 0.002 * Hartree)

print(e, erev)
Beispiel #13
0
if not os.path.exists('bs_dft.json'):
    from ase.dft.kpoints import bandpath
    from ase.dft.band_structure import get_band_structure
    from gpaw import GPAW, PW, MixerSum, FermiDirac
    from gpaw.eigensolvers import CG

    calc = GPAW(
        mode=PW(400),
        maxiter=250,
        spinpol=True,
        kpts=(3, 3, 3),
        xc='LDA',
        txt='-',
        occupations=FermiDirac(0.02, fixmagmom=True),
        mixer=MixerSum(0.02, 5, 100),
    )
    atoms.set_calculator(calc)
    atoms.get_potential_energy()
    efermi = calc.get_fermi_level().max()
    Nk = len(calc.get_ibz_k_points())
    Ns = calc.get_number_of_spins()
    eigval = np.array(
        [[calc.get_eigenvalues(kpt=k, spin=s) for k in range(Nk)]
         for s in range(Ns)])
    evbm = np.max(eigval[eigval < efermi])

    calc.set(
        nbands=8,  # 4 occupied and 4 unoccupied bands
        fixdensity=True,
        eigensolver=CG(niter=5),
Beispiel #14
0
                      (5.730, 3.938, 6.371), (7.367, 3.948, 6.324),
                      (6.587, 4.124, 7.778), (3.946, 5.728, 6.360),
                      (3.946, 7.364, 6.360), (4.138, 6.546, 7.789),
                      (5.730, 9.153, 6.371), (7.368, 9.143, 6.324),
                      (6.587, 8.967, 7.778), (9.152, 5.726, 6.339),
                      (9.152, 7.365, 6.339), (8.981, 6.546, 7.770),
                      (7.052, 5.724, 4.128), (7.052, 7.367, 4.128),
                      (5.627, 6.546, 4.105), (6.608, 6.631, 9.102),
                      (4.108, 4.248, 4.703)]
molecule += Atom('Cl', (8.72, 9.04, 4.6))
molecule.center(vacuum=4.0)
molecule.set_constraint(FixAtoms(indices=[0]))
molecule[0].magmom = 1
# Calculator
name = 'osam5cl3'
mixer = MixerSum(0.05, 5, weight=100.0)
calc = GPAW(
    h=0.18,
    xc='PBE',
    #nbands=-5,
    txt=name + '.txt',
    maxiter=200,
    stencils=(3, 3),
    width=0.1,
    mixer=mixer)
molecule.set_calculator(calc)
molecule.get_potential_energy()
calc.set(width=0.05)
# Relaxation of the Cl atom, and calculations...
qn = QuasiNewton(molecule, trajectory=name + '.traj')
qn.run(fmax=0.05)
Beispiel #15
0
    if rank == 0 and atom not in setups:
        g = Generator(atom, 'LB94', nofiles=True, txt=txt)
        g.run(**parameters[atom])
        setups[atom] = 1
    barrier()

    SS = Atoms(atom, magmoms=[magmom], cell=(7, 7, 7), pbc=False)
    SS.center()
    # fine grid needed for convergence!
    c = GPAW(h=0.2,
             xc='LB94',
             nbands=-2,
             spinpol=True,
             hund=True,
             eigensolver=Davidson(3),
             mixer=MixerSum(0.5, 7, 50.0),
             occupations=FermiDirac(0.0, fixmagmom=True),
             txt=txt)
    c.calculate(SS)
    # find H**O energy
    eps_n = c.get_eigenvalues(kpt=0, spin=0) / 27.211
    f_n = c.get_occupation_numbers(kpt=0, spin=0)
    for e, f in zip(eps_n, f_n):
        if f < 0.99:
            break
        e_homo = e
    e_homo = int(e_homo * 10000 + .5) / 10.
    diff = e_ref + e_homo
    print('%2s %8g %6.1f %4.1f' % (atom, e_ref, -e_homo, diff))
    assert abs(diff) < 15