예제 #1
0
import numpy as np
import numpy.random as ra
from gpaw.setup import create_setup
from gpaw.xc import XC
from gpaw.test import equal, gen

if 1:
    for functional in [
            'LDA_X', 'LDA_X+LDA_C_PW', 'LDA_X+LDA_C_VWN', 'LDA_X+LDA_C_PZ',
            'GGA_X_PBE+GGA_C_PBE', 'GGA_X_PBE_R+GGA_C_PBE',
            'GGA_X_B88+GGA_C_P86', 'GGA_X_B88+GGA_C_LYP',
            'GGA_X_FT97_A+GGA_C_LYP'
    ]:
        gen('N', xcname=functional)

tolerance = 0.000005  # libxc must reproduce old gpaw energies
# zero Kelvin: in Hartree

reference = {  # svnversion 5252
    'LDA_X+LDA_C_PW': 2.23194461135,  # 'LDA'
    'GGA_X_PBE+GGA_C_PBE': 2.28208665019,  # 'PBE'
    'GGA_X_PBE_R+GGA_C_PBE': 2.29201920843,  # 'revPBE'
}

tolerance_libxc = 0.000001  # libxc must reproduce reference libxc energies

reference_libxc = { # svnversion 5252
    'LDA_X': 1.95030600807,
    'LDA_X+LDA_C_PW': 2.23194461135,
    'LDA_X+LDA_C_VWN': 2.23297429824,
    'LDA_X+LDA_C_PZ': 2.23146045547,
예제 #2
0
파일: h2o_dks.py 프로젝트: eojons/gpaw-scme
from ase.structure import molecule
from ase.parallel import rank, barrier

from gpaw import GPAW, FermiDirac
from gpaw.test import equal, gen

# Generate setup for oxygen with a core-hole:
gen('O', name='fch1s', xcname='PBE', corehole=(1, 0, 1.0))

atoms = molecule('H2O')
atoms.center(vacuum=2.5)

calc = GPAW(xc='PBE')
atoms.set_calculator(calc)
e1 = atoms.get_potential_energy() + calc.get_reference_energy()
niter1 = calc.get_number_of_iterations()

atoms[0].magmom = 1
calc.set(charge=-1,
         setups={'O': 'fch1s'},
         occupations=FermiDirac(0.0, fixmagmom=True))
e2 = atoms.get_potential_energy() + calc.get_reference_energy()
niter2 = calc.get_number_of_iterations()

atoms[0].magmom = 0
calc.set(charge=0,
         setups={'O': 'fch1s'},
         occupations=FermiDirac(0.0, fixmagmom=True),
         spinpol=True)
e3 = atoms.get_potential_energy() + calc.get_reference_energy()
niter3 = calc.get_number_of_iterations()
예제 #3
0
    'H': {
        'HCTH407': 0.19286893273630645,
        'B3LYP': -0.11369634560501423,
        'PBE0': -0.21413764474738262,
        'PBEH': -0.14147808591211231
    },
    'N': {
        'HCTH407': 2.1354017840869268,
        'B3LYP': 0.63466589919873972,
        'PBE0': -0.33376468078480226,
        'PBEH': -0.30365500626180042
    }
}  # svnversion 5599 # -np 4

for element in ['H']:  #, 'N']:#, 'O']: # oxygen atom fails to converge
    E[element] = {}
    for xc in ['HCTH407', 'PBE0', 'B3LYP']:
        setup = data[element][xc][2]
        if data[element][xc][3] == 'hyb_gga':  # only for hybrids
            exx = True
        else:
            exx = False
        gen(element, exx=exx, xcname=setup)
        for h in [0.20]:
            for vacuum in [4.5]:
                calculate(element, h, vacuum, xc, data[element]['magmom'])
        barrier()
        if rank == 0:
            if exists(element + '.' + setup):
                remove(element + '.' + setup)
예제 #4
0
파일: h2o_dks.py 프로젝트: yihsuanliu/gpaw
from ase.data.molecules import molecule
from ase.parallel import rank, barrier

from gpaw import GPAW, FermiDirac
from gpaw.test import equal, gen

# Generate setup for oxygen with a core-hole:
gen('O', name='fch1s', xcname='PBE', corehole=(1, 0, 1.0))

atoms = molecule('H2O')
atoms.center(vacuum=2.5)

calc = GPAW(xc='PBE')
atoms.set_calculator(calc)
e1 = atoms.get_potential_energy() + calc.get_reference_energy()
niter1 = calc.get_number_of_iterations()

atoms[0].magmom = 1
calc.set(charge=-1,
         setups={'O': 'fch1s'},
         occupations=FermiDirac(0.0, fixmagmom=True))
e2 = atoms.get_potential_energy() + calc.get_reference_energy()
niter2 = calc.get_number_of_iterations()

atoms[0].magmom = 0
calc.set(charge=0,
         setups={'O': 'fch1s'},
         occupations=FermiDirac(0.0, fixmagmom=True),
         spinpol=True)
e3 = atoms.get_potential_energy() + calc.get_reference_energy()
niter3 = calc.get_number_of_iterations()
예제 #5
0
파일: si.py 프로젝트: Huaguiyuan/gpawDFT
from __future__ import print_function
from ase import Atom, Atoms
from gpaw import GPAW, FermiDirac
from gpaw.xas import XAS, RecursionMethod
from gpaw.test import gen

# Generate setup for oxygen with half a core-hole:
gen('Si', name='hch1s', corehole=(1, 0, 0.5), gpernode=30)
a = 2.6
si = Atoms('Si', cell=(a, a, a), pbc=True)

import numpy as np
calc = GPAW(nbands=None,
            h=0.25,
            occupations=FermiDirac(width=0.05),
            setups={0: 'hch1s'})
def stopcalc():
    calc.scf.converged = 1
calc.attach(stopcalc, 1)
si.set_calculator(calc)
e = si.get_potential_energy()
niter = calc.get_number_of_iterations()
calc.write('si.gpw')

# restart from file
calc = GPAW('si.gpw')

import gpaw.mpi as mpi
if mpi.size == 1:
    xas = XAS(calc)
    x, y = xas.get_spectra()
예제 #6
0
from __future__ import print_function
from ase import Atom, Atoms
from gpaw import GPAW, FermiDirac
from gpaw.xas import XAS, RecursionMethod
from gpaw.test import gen

# Generate setup for oxygen with half a core-hole:
gen('Si', name='hch1s', corehole=(1, 0, 0.5))

a = 4.0
b = a / 2
c = b / 2
d = b + c
si = Atoms([Atom('Si', (0, 0, 0)),
            Atom('Si', (c, c, c)),
            Atom('Si', (b, b, 0)),
            Atom('Si', (d, d, c)),
            Atom('Si', (b, 0, b)),
            Atom('Si', (d, c, d)),
            Atom('Si', (0, b, b)),
            Atom('Si', (c, d, d))],
           cell=(a, a, a), pbc=True)

import numpy as np
calc = GPAW(nbands=None,
            h=0.25,
            occupations=FermiDirac(width=0.05),
            setups={0: 'hch1s'})
si.set_calculator(calc)
e = si.get_potential_energy()
niter = calc.get_number_of_iterations()
예제 #7
0
from gpaw import GPAW, restart, FermiDirac, PoissonSolver
from ase import Atoms
from gpaw.test import equal, gen
import os
from gpaw.mpi import world

gen('Si', xcname='GLLBSC')

e = {}
niter = {}

energy_tolerance = 0.0001
niter_tolerance = 0

e_ref = {'LDA': {'restart': -5.5728768784094758},
         'GLLBSC': {'restart': -5.4458036264351}} # svnversion 5252
niter_ref = {'LDA': {'restart': 16},
             'GLLBSC': {'restart': 16}} # svnversion 5252

for xc in ['LDA','GLLBSC']:
    a = 4.23
    bulk = Atoms('Si2', cell=(a, a, a), pbc=True,
              scaled_positions=[[0, 0, 0], [0.5, 0.5, 0.5]])
    calc = GPAW(h=0.25,
                nbands=8,
                poissonsolver=PoissonSolver(nn='M'),
                occupations=FermiDirac(width=0.01),
                kpts=(3, 3, 3),
                convergence={'eigenstates': 9.2e-11,
                             'bands': 8},
                xc=xc,
from __future__ import print_function
from gpaw import GPAW, restart, FermiDirac, PoissonSolver
from ase import Atoms
from gpaw.test import equal, gen
import os
from gpaw.mpi import world

gen("Si", xcname="GLLBSC")

e = {}
niter = {}

energy_tolerance = 0.0001
niter_tolerance = 0

e_ref = {"LDA": {"restart": -5.5728768784094758}, "GLLBSC": {"restart": -5.4458036264351}}  # svnversion 5252
niter_ref = {"LDA": {"restart": 16}, "GLLBSC": {"restart": 16}}  # svnversion 5252

for xc in ["LDA", "GLLBSC"]:
    a = 4.23
    bulk = Atoms("Si2", cell=(a, a, a), pbc=True, scaled_positions=[[0, 0, 0], [0.5, 0.5, 0.5]])
    calc = GPAW(
        h=0.25,
        nbands=8,
        poissonsolver=PoissonSolver(nn="M"),
        occupations=FermiDirac(width=0.01),
        kpts=(3, 3, 3),
        convergence={"eigenstates": 9.2e-11, "bands": 8},
        xc=xc,
        eigensolver="cg",
    )
예제 #9
0
파일: ivo_hft.py 프로젝트: thonmaker/gpaw
from gpaw import GPAW, setup_paths
from gpaw.mpi import world
from gpaw.occupations import FermiDirac
from gpaw.test import equal, gen
from gpaw.eigensolvers import RMMDIIS
from gpaw.cluster import Cluster
from gpaw.lrtddft import LrTDDFT

h = 0.3  # Gridspacing
e_singlet = 4.3
e_singlet_lr = 4.3

if setup_paths[0] != '.':
    setup_paths.insert(0, '.')

gen('Na', xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.40)
gen('Cl', xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.40)

c = {'energy': 0.005, 'eigenstates': 1e-2, 'density': 1e-2}
mol = Cluster(molecule('NaCl'))
mol.minimal_box(5.0, h=h)
calc = GPAW(txt='NaCl.txt',
            xc='LCY-PBE:omega=0.40:excitation=singlet',
            eigensolver=RMMDIIS(),
            h=h,
            occupations=FermiDirac(width=0.0),
            spinpol=False,
            convergence=c)
mol.set_calculator(calc)
mol.get_potential_energy()
(eps_homo, eps_lumo) = calc.get_homo_lumo()
예제 #10
0
파일: si.py 프로젝트: yihsuanliu/gpaw
from gpaw import GPAW, restart
from ase import *
from ase.calculators import numeric_force
from gpaw.test import equal
from gpaw.test import gen
from ase.structure import bulk

gen('Si', xcname='GLLB')

def diamond2(symbol, a):
    return bulk(symbol, 'diamond', a=a)

def diamond4(symbol, a):
    """Zinc Blende - Zinc Sulfide"""
    atoms = Atoms(symbols='%s4' % (symbol), pbc=True,
                  positions=[(.0, .0, .0),
                             (.5, .5, .5),
                             (.0, .5, .75),
                             (.5, .0, .25),])
    atoms.set_cell([a / sqrt(2), a / sqrt(2), a], scale_atoms=True)
    return atoms


def diamond8(symbol, a):
    atoms = Atoms(symbols='%s8' % (symbol), pbc=True,
                  positions=[(0, 0, 0),
                             (0, 0.5, 0.5),
                             (0.5, 0, 0.5),
                             (0.5, 0.5, 0),
                             (0.25, 0.25, 0.25),
                             (0.25, 0.75, 0.75),
예제 #11
0
파일: Cu.py 프로젝트: thonmaker/gpaw
from ase import Atoms
from ase.units import Hartree
from gpaw import GPAW
from gpaw.test import equal, gen
import gpaw.mpi as mpi

# Generate non-scalar-relativistic setup for Cu:
setup = gen('Cu', scalarrel=False)

a = 8.0
c = a / 2
Cu = Atoms('Cu', [(c, c, c)], magmoms=[1], cell=(a, a, a), pbc=0)

calc = GPAW(h=0.2, setups={'Cu': setup})
Cu.set_calculator(calc)
e = Cu.get_potential_energy()
niter = calc.get_number_of_iterations()

e_4s_major = calc.get_eigenvalues(spin=0)[5] / Hartree
e_3d_minor = calc.get_eigenvalues(spin=1)[4] / Hartree
print(mpi.rank, e_4s_major, e_3d_minor)

#
# The reference values are from:
#
#   http://physics.nist.gov/PhysRefData/DFTdata/Tables/29Cu.html
#
if mpi.rank == 0:
    print(e_4s_major - e_3d_minor, -0.184013 - -0.197109)
    assert abs(e_4s_major - e_3d_minor - (-0.184013 - -0.197109)) < 0.001
예제 #12
0
h = 0.18
a = 10.0
c = a / 2
d = 1.8

elements = ['C']
results = [0.0168960169771]
electrons = [6]
lambda_coeff = 2.0

for symbol in elements:
    xcname = '1.0_LDA_K_TF+1.0_LDA_X'
    g = gen(symbol,
            xcname=xcname,
            scalarrel=False,
            orbital_free=True,
            tw_coeff=lambda_coeff)

for element, result, e in zip(elements, results, electrons):
    atom = Atoms(element, positions=[(c, c, c)], cell=(a, a, a))

    mixer = Mixer(0.3, 5, 1)
    eigensolver = CG(tw_coeff=lambda_coeff)
    calc = GPAW(h=h,
                txt='-',
                xc=xcname,
                maxiter=240,
                mixer=mixer,
                eigensolver=eigensolver)
예제 #13
0
import os
from math import pi, cos, sin
from ase import Atom, Atoms
from ase.parallel import rank, barrier
from gpaw import GPAW, FermiDirac
from gpaw.test import equal, gen
from gpaw.xas import XAS, RecursionMethod

# Generate setup for oxygen with half a core-hole:
gen('Si', name='hch1s', corehole=(1, 0, 0.5))

a = 4.0
b = a / 2
c = b / 2
d = b + c
si = Atoms([
    Atom('Si', (0, 0, 0)),
    Atom('Si', (c, c, c)),
    Atom('Si', (b, b, 0)),
    Atom('Si', (d, d, c)),
    Atom('Si', (b, 0, b)),
    Atom('Si', (d, c, d)),
    Atom('Si', (0, b, b)),
    Atom('Si', (c, d, d))
],
           cell=(a, a, a),
           pbc=True)

import numpy as np

calc = GPAW(nbands=None,
예제 #14
0
파일: lxc_xcatom.py 프로젝트: qsnake/gpaw
import numpy as np
import numpy.random as ra
from gpaw.setup import create_setup
from gpaw.xc import XC
from gpaw.test import equal, gen

if 1:
    for functional in [
        'LDA_X', 'LDA_X+LDA_C_PW', 'LDA_X+LDA_C_VWN', 'LDA_X+LDA_C_PZ',
        'GGA_X_PBE+GGA_C_PBE', 'GGA_X_PBE_R+GGA_C_PBE',
        'GGA_X_B88+GGA_C_P86', 'GGA_X_B88+GGA_C_LYP',
        'GGA_X_FT97_A+GGA_C_LYP'
        ]:
        gen('N', xcname=functional)
        
tolerance = 0.000005 # libxc must reproduce old gpaw energies
# zero Kelvin: in Hartree

reference = { # svnversion 5252
    'LDA_X+LDA_C_PW': 2.23194461135, # 'LDA'
    'GGA_X_PBE+GGA_C_PBE': 2.28208665019, # 'PBE'
    'GGA_X_PBE_R+GGA_C_PBE': 2.29201920843, # 'revPBE'
    }

tolerance_libxc = 0.000001 # libxc must reproduce reference libxc energies

reference_libxc = { # svnversion 5252
    'LDA_X': 1.95030600807,
    'LDA_X+LDA_C_PW': 2.23194461135,
    'LDA_X+LDA_C_VWN': 2.23297429824,
    'LDA_X+LDA_C_PZ': 2.23146045547,
예제 #15
0
from ase import Atoms
from ase.dft.bee import BEEFEnsemble, readbee
from gpaw import GPAW
from gpaw.test import equal, gen
from gpaw.mpi import world
import _gpaw

newlibxc = _gpaw.lxcXCFuncNum("MGGA_X_MBEEF") is not None

c = {"energy": 0.001, "eigenstates": 1, "density": 1}
d = 0.75

gen("H", xcname="PBEsol")

for xc, E0, dE0 in [("mBEEF", 4.86, 0.16), ("BEEF-vdW", 5.13, 0.20), ("mBEEF-vdW", 4.74, 0.36)]:
    print(xc)
    if not newlibxc and xc[0] == "m":
        print("Skipped")
        continue

    # H2 molecule:
    h2 = Atoms("H2", [[0, 0, 0], [0, 0, d]])
    h2.center(vacuum=2)
    h2.calc = GPAW(txt="H2-" + xc + ".txt", convergence=c)
    h2.get_potential_energy()
    h2.calc.set(xc=xc)
    h2.get_potential_energy()
    h2.get_forces()
    ens = BEEFEnsemble(h2.calc)
    e_h2 = ens.get_ensemble_energies()
예제 #16
0
"""Calculate diamond with various parallelizations with GLLBSC."""
from __future__ import print_function
from ase.build import bulk
from ase.units import Ha
from gpaw import GPAW, restart
from gpaw.test import gen
from gpaw import setup_paths

xc = 'GLLBSC'
gen('C', xcname=xc)
setup_paths.insert(0, '.')

KSb = []
dxcb = []

eigensolver = 'rmm-diis'

for band in [1, 2, 4]:
    # Calculate ground state
    atoms = bulk('C', 'diamond', a=3.567)
    calc = GPAW(h=0.15,
                kpts=(4, 4, 4),
                xc=xc,
                nbands=8,
                eigensolver=eigensolver,
                parallel={'band': band})
    atoms.set_calculator(calc)
    atoms.get_potential_energy()
    calc.write('Cgs.gpw')

    # Calculate accurate KS-band gap from band structure
예제 #17
0
파일: ofdft.py 프로젝트: thonmaker/gpaw
from gpaw.test import equal
from gpaw.test import gen

a = 6.0
c = a / 2
#d = 1.8

elements = ['C', 'Be']
results = [0.245393619863, 9.98114719239]
electrons = [6, 3]
charges = [0,1]


for symbol in elements:
    xcname = '1.0_LDA_K_TF+1.0_LDA_X'
    g = gen(symbol, xcname=xcname, scalarrel=False, orbital_free=True,
            gpernode=75)

for element, result, e, charge in zip(elements, results, electrons, charges):
    atom = Atoms(element,
                 positions=[(c, c, c)],
                 cell=(a, a, a))

    mixer = Mixer(0.3, 5, 1)
    calc = GPAW(gpts=(32, 32, 32),
                txt='-', xc=xcname,
                poissonsolver=PoissonSolver(eps=1e-6),
                eigensolver='cg', mixer=mixer, charge=charge)

    atom.set_calculator(calc)

    E = atom.get_total_energy()
예제 #18
0
파일: si.py 프로젝트: qsnake/gpaw
from gpaw import GPAW, restart
from ase import *
from ase.calculators import numeric_force
from gpaw.test import equal
from gpaw.test import gen
from ase.structure import bulk

gen("Si", xcname="GLLB")


def diamond2(symbol, a):
    return bulk(symbol, "diamond", a=a)


def diamond4(symbol, a):
    """Zinc Blende - Zinc Sulfide"""
    atoms = Atoms(
        symbols="%s4" % (symbol),
        pbc=True,
        positions=[(0.0, 0.0, 0.0), (0.5, 0.5, 0.5), (0.0, 0.5, 0.75), (0.5, 0.0, 0.25)],
    )
    atoms.set_cell([a / sqrt(2), a / sqrt(2), a], scale_atoms=True)
    return atoms


def diamond8(symbol, a):
    atoms = Atoms(
        symbols="%s8" % (symbol),
        pbc=True,
        positions=[
            (0, 0, 0),
예제 #19
0
파일: si_xas.py 프로젝트: qsnake/gpaw
import os
from math import pi, cos, sin
from ase import Atom, Atoms
from ase.parallel import rank, barrier
from gpaw import GPAW, FermiDirac
from gpaw.test import equal, gen
from gpaw.xas import XAS, RecursionMethod

# Generate setup for oxygen with half a core-hole:
gen("Si", name="hch1s", corehole=(1, 0, 0.5))

a = 4.0
b = a / 2
c = b / 2
d = b + c
si = Atoms(
    [
        Atom("Si", (0, 0, 0)),
        Atom("Si", (c, c, c)),
        Atom("Si", (b, b, 0)),
        Atom("Si", (d, d, c)),
        Atom("Si", (b, 0, b)),
        Atom("Si", (d, c, d)),
        Atom("Si", (0, b, b)),
        Atom("Si", (c, d, d)),
    ],
    cell=(a, a, a),
    pbc=True,
)

import numpy as np
예제 #20
0
파일: h2o.py 프로젝트: thonmaker/gpaw
from __future__ import print_function
import numpy as np
from math import pi, cos, sin
from ase import Atom, Atoms
# from ase.parallel import rank, barrier
from gpaw import GPAW
from gpaw.poisson import FDPoissonSolver
from gpaw.xas import XAS
from gpaw.test import equal, gen

# Generate setup for oxygen with half a core-hole:
gen('O', name='hch1s', corehole=(1, 0, 0.5))

a = 5.0
d = 0.9575
t = pi / 180 * 104.51
H2O = Atoms([Atom('O', (0, 0, 0)),
             Atom('H', (d, 0, 0)),
             Atom('H', (d * cos(t), d * sin(t), 0))],
            cell=(a, a, a), pbc=False)
H2O.center()
calc = GPAW(nbands=10, h=0.2, setups={'O': 'hch1s'},
            experimental={'niter_fixdensity': 2},
            poissonsolver=FDPoissonSolver(use_charge_center=True))
H2O.set_calculator(calc)
e = H2O.get_potential_energy()
niter = calc.get_number_of_iterations()

import gpaw.mpi as mpi

if mpi.size == 1:
예제 #21
0
파일: Cu.py 프로젝트: qsnake/gpaw
import os
from ase import Atoms
from ase.units import Hartree
from gpaw import GPAW
from gpaw.test import equal, gen
import gpaw.mpi as mpi

# Generate non-scalar-relativistic setup for Cu:
gen('Cu', scalarrel=False)

a = 8.0
c = a / 2
Cu = Atoms('Cu', [(c, c, c)], magmoms=[1],
           cell=(a, a, a), pbc=0)

calc = GPAW(h=0.2, lmax=0)# basis='sz')
Cu.set_calculator(calc)
e = Cu.get_potential_energy()
niter = calc.get_number_of_iterations()

e_4s_major = calc.get_eigenvalues(spin=0)[5] / Hartree
e_3d_minor = calc.get_eigenvalues(spin=1)[4] / Hartree
print mpi.rank, e_4s_major, e_3d_minor

#
# The reference values are from:
#
#   http://physics.nist.gov/PhysRefData/DFTdata/Tables/29Cu.html
#
if mpi.rank == 0:
    print e_4s_major - e_3d_minor, -0.184013 - -0.197109
예제 #22
0
파일: rsf_gamma.py 프로젝트: thonmaker/gpaw
from ase import Atoms
from gpaw import GPAW, setup_paths
from gpaw.poisson import PoissonSolver
from gpaw.eigensolvers import RMMDIIS
from gpaw.occupations import FermiDirac
from gpaw.test import equal, gen

# IP for CO using LCY-PBE with gamma=0.81 after
# dx.doi.org/10.1021/acs.jctc.8b00238
IP = 14.31

if setup_paths[0] != '.':
    setup_paths.insert(0, '.')

for atom in ['C', 'O']:
    gen(atom, xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.81)

h = 0.30
co = Atoms('CO', positions=[(0, 0, 0), (0, 0, 1.15)])
co.minimal_box(5)

# c = {'energy': 0.005, 'eigenstates': 1e-4}  # Usable values
c = {'energy': 0.1, 'eigenstates': 3, 'density': 3}  # Values for test

calc = GPAW(txt='CO.txt',
            xc='LCY-PBE:omega=0.81',
            convergence=c,
            eigensolver=RMMDIIS(),
            h=h,
            poissonsolver=PoissonSolver(use_charge_center=True),
            occupations=FermiDirac(width=0.0),
예제 #23
0
            equal(dHf_298, data[element][xc][1], 2.15, msg=xc+': ') # kcal/mol
        equal(de, E_ref[element][xc], 0.06, msg=xc+': ') # kcal/mol

E = {}

E_ref = {'H': {'HCTH407': 0.19286893273630645,
               'B3LYP': -0.11369634560501423,
               'PBE0': -0.21413764474738262,
               'PBEH': -0.14147808591211231},
         'N': {'HCTH407': 2.1354017840869268,
               'B3LYP': 0.63466589919873972,
               'PBE0': -0.33376468078480226,
               'PBEH': -0.30365500626180042}} # svnversion 5599 # -np 4

for element in ['H']:#, 'N']:#, 'O']: # oxygen atom fails to converge
    E[element] = {}
    for xc in ['HCTH407', 'PBE0', 'B3LYP']:
        setup = data[element][xc][2]
        if data[element][xc][3] == 'hyb_gga': # only for hybrids
            exx = True
        else:
            exx = False
        gen(element, exx=exx, xcname=setup)
        for h in [0.20]:
            for vacuum in [4.5]:
                calculate(element, h, vacuum, xc, data[element]['magmom'])
        barrier()
        if rank == 0:
            if exists(element+'.'+setup):
                remove(element+'.'+setup)
예제 #24
0
"""Check for tunability of gamma for yukawa potential."""
from ase import Atoms
from gpaw import GPAW, setup_paths
from gpaw.cluster import Cluster
from gpaw.eigensolvers import RMMDIIS
from gpaw.xc.hybrid import HybridXC
from gpaw.occupations import FermiDirac
from gpaw.test import equal, gen

if setup_paths[0] != '.':
    setup_paths.insert(0, '.')

for atom in ['Be']:
    gen(atom, xcname='PBE', scalarrel=True, exx=True,
        yukawa_gamma=0.83, gpernode=149)

h = 0.35
be = Cluster(Atoms('Be', positions=[[0, 0, 0]]))
be.minimal_box(3.0, h=h)

c = {'energy': 0.05, 'eigenstates': 0.05, 'density': 0.05}

IP = 8.79

xc = HybridXC('LCY-PBE', omega=0.83)
fname = 'Be_rsf.gpw'

calc = GPAW(txt='Be.txt', xc=xc, convergence=c,
            eigensolver=RMMDIIS(), h=h,
            occupations=FermiDirac(width=0.0), spinpol=False)
be.set_calculator(calc)
예제 #25
0
from gpaw import GPAW, setup_paths
from gpaw.mpi import world
from gpaw.occupations import FermiDirac
from gpaw.test import equal, gen
from gpaw.eigensolvers import RMMDIIS
from gpaw.cluster import Cluster
from gpaw.lrtddft import LrTDDFT

h = 0.35  # Gridspacing
e_singlet = 4.61
e_singlet_lr = 5.54

if setup_paths[0] != '.':
    setup_paths.insert(0, '.')

gen('Mg', xcname='PBE', scalarrel=True, exx=True, yukawa_gamma=0.38)

c = {'energy': 0.05, 'eigenstates': 3, 'density': 3}
na2 = Cluster(Atoms('Mg', positions=[[0, 0, 0]]))
na2.minimal_box(2.5, h=h)
calc = GPAW(txt='mg_ivo.txt',
            xc='LCY-PBE:omega=0.38:excitation=singlet',
            eigensolver=RMMDIIS(),
            h=h,
            occupations=FermiDirac(width=0.0),
            spinpol=False,
            convergence=c)
na2.set_calculator(calc)
na2.get_potential_energy()
(eps_homo, eps_lumo) = calc.get_homo_lumo()
e_ex = eps_lumo - eps_homo
예제 #26
0
import os
from math import pi, cos, sin
from ase import Atom, Atoms
from ase.parallel import rank, barrier
from gpaw import GPAW
from gpaw.test import equal, gen
import numpy as np

# Generate setup for oxygen with half a core-hole:
gen('O', name='hch1s', corehole=(1, 0, 0.5))

if 1:
    a = 5.0
    d = 0.9575
    t = pi / 180 * 104.51
    H2O = Atoms([Atom('O', (0, 0, 0)),
                 Atom('H', (d, 0, 0)),
                 Atom('H', (d * cos(t), d * sin(t), 0))],
                cell=(a, a, a), pbc=False)
    H2O.center()
    calc = GPAW(nbands=10, h=0.2, setups={'O': 'hch1s'})
    H2O.set_calculator(calc)
    e = H2O.get_potential_energy()
    niter = calc.get_number_of_iterations()
    calc.write('h2o.gpw')
else:
    calc = GPAW('h2o.gpw')
    calc.initialize_positions()

from gpaw.xas import RecursionMethod
예제 #27
0
파일: si.py 프로젝트: eojons/gpaw-scme
from gpaw import GPAW, restart
from ase import *
from ase.calculators import numeric_force
from gpaw.test import equal
from gpaw.test import gen
from ase.lattice import bulk

gen('Si', xcname='GLLB')

def diamond2(symbol, a):
    return bulk(symbol, 'diamond', a=a)

def diamond4(symbol, a):
    """Zinc Blende - Zinc Sulfide"""
    atoms = Atoms(symbols='%s4' % (symbol), pbc=True,
                  positions=[(.0, .0, .0),
                             (.5, .5, .5),
                             (.0, .5, .75),
                             (.5, .0, .25),])
    atoms.set_cell([a / sqrt(2), a / sqrt(2), a], scale_atoms=True)
    return atoms


def diamond8(symbol, a):
    atoms = Atoms(symbols='%s8' % (symbol), pbc=True,
                  positions=[(0, 0, 0),
                             (0, 0.5, 0.5),
                             (0.5, 0, 0.5),
                             (0.5, 0.5, 0),
                             (0.25, 0.25, 0.25),
                             (0.25, 0.75, 0.75),
예제 #28
0
from gpaw.test import equal
from gpaw.test import gen

h = 0.18
a = 8
c = a / 2
d = 1.8

elements = ['C']
results = [0.0256218846668]
electrons = [6]


for symbol in elements:
    xcname = '1.0_LDA_K_TF+1.0_LDA_X'
    g = gen(symbol, xcname=xcname, scalarrel=False, orbital_free=True)

for element, result, e in zip(elements, results, electrons):
    atom = Atoms(element,
                 positions=[(c, c, c)],
                 cell=(a, a, a))

    mixer = Mixer(0.3, 5, 1)
    calc = GPAW(h=h, txt='-', xc=xcname, maxiter=240,
                eigensolver='cg', mixer=mixer)

    atom.set_calculator(calc)

    E = atom.get_total_energy()
    n = calc.get_all_electron_density()
예제 #29
0
from __future__ import division
import numpy as np
from ase.build import bulk
from ase.dft.bee import BEEFEnsemble, readbee
from gpaw import GPAW, Mixer, PW
from gpaw.test import gen
from gpaw.mpi import world
import _gpaw

newlibxc = _gpaw.lxcXCFuncNum('MGGA_X_MBEEF') is not None

gen('Si', xcname='PBEsol')

results = {'mBEEF': (5.450319626557848, 0.056),
           'BEEF-vdW': (5.483, 0.071),
           'mBEEF-vdW': (5.426, 0.025)}

for xc in ['mBEEF', 'BEEF-vdW', 'mBEEF-vdW']:
    print(xc)
    if not newlibxc and xc[0] == 'm':
        print('Skipped', xc)
        continue

    if xc == 'mBEEF-vdW':
        # Does not work with libxc-4
        continue

    E = []
    V = []
    for a in np.linspace(5.4, 5.5, 3):
        si = bulk('Si', a=a)
예제 #30
0
from __future__ import print_function
from ase.build import bulk

from gpaw.atom.generator import Generator
from gpaw import GPAW, Davidson, Mixer, PW
from gpaw.xc.libvdwxc import vdw_mbeef

from gpaw.test import gen

setup = gen('Si', xcname='PBEsol')

system = bulk('Si')
calc = GPAW(mode=PW(200),
            xc=vdw_mbeef(),
            kpts=(2, 2, 2),
            nbands=4,
            convergence=dict(density=1e-6),
            mixer=Mixer(1.0),
            eigensolver=Davidson(4),
            setups={'Si': setup})
system.calc = calc
e = system.get_potential_energy()

ref = -60.50368932260335
err = abs(e - ref)
print('e=%r ref=%r err=%r' % (e, ref, err))
assert err < 1e-6
예제 #31
0
from __future__ import print_function
from gpaw import GPAW, restart, FermiDirac
from ase import Atoms
from gpaw.test import equal, gen
import os
from gpaw.mpi import world

gen('Si', xcname='GLLBSC')

e = {}

energy_tolerance = 0.0002

e_ref = {
    'LDA': {
        'restart': -5.583306128278814
    },
    'GLLBSC': {
        'restart': -5.458520154765278
    }
}

for xc in ['LDA', 'GLLBSC']:
    a = 4.23
    bulk = Atoms('Si2',
                 cell=(a, a, a),
                 pbc=True,
                 scaled_positions=[[0, 0, 0], [0.5, 0.5, 0.5]])
    calc = GPAW(h=0.25,
                nbands=8,
                occupations=FermiDirac(width=0.01),
예제 #32
0
from ase import Atoms
from ase.dft.bee import BEEFEnsemble, readbee
from gpaw import GPAW
from gpaw.test import equal, gen
from gpaw.mpi import world
import _gpaw

newlibxc = _gpaw.lxcXCFuncNum('MGGA_X_MBEEF') is not None

c = {'energy': 0.001, 'eigenstates': 1, 'density': 1}
d = 0.75

gen('H', xcname='PBEsol')

for xc, E0, dE0 in [('mBEEF', 4.86, 0.16), ('BEEF-vdW', 5.13, 0.20),
                    ('mBEEF-vdW', 4.74, 0.36)]:
    print(xc)
    if not newlibxc and xc[0] == 'm':
        print('Skipped')
        continue

    # H2 molecule:
    h2 = Atoms('H2', [[0, 0, 0], [0, 0, d]])
    h2.center(vacuum=2)
    h2.calc = GPAW(txt='H2-' + xc + '.txt', convergence=c)
    h2.get_potential_energy()
    h2.calc.set(xc=xc)
    h2.get_potential_energy()
    h2.get_forces()
    ens = BEEFEnsemble(h2.calc)
    e_h2 = ens.get_ensemble_energies()
예제 #33
0
파일: N.py 프로젝트: yihsuanliu/gpaw
# creates: N.LDA
import os
from gpaw.test import gen
gen('N')
os.system('cp N.LDA ../_build')
예제 #34
0
import os
from ase import Atoms
from ase.units import Hartree
from gpaw import GPAW
from gpaw.test import equal, gen
import gpaw.mpi as mpi

# Generate non-scalar-relativistic setup for Cu:
gen('Cu', scalarrel=False)

a = 8.0
c = a / 2
Cu = Atoms('Cu', [(c, c, c)], magmoms=[1], cell=(a, a, a), pbc=0)

calc = GPAW(h=0.2, lmax=0)  # basis='sz')
Cu.set_calculator(calc)
e = Cu.get_potential_energy()
niter = calc.get_number_of_iterations()

e_4s_major = calc.get_eigenvalues(spin=0)[5] / Hartree
e_3d_minor = calc.get_eigenvalues(spin=1)[4] / Hartree
print mpi.rank, e_4s_major, e_3d_minor

#
# The reference values are from:
#
#   http://physics.nist.gov/PhysRefData/DFTdata/Tables/29Cu.html
#
if mpi.rank == 0:
    print e_4s_major - e_3d_minor, -0.184013 - -0.197109
    assert abs(e_4s_major - e_3d_minor - (-0.184013 - -0.197109)) < 0.001
예제 #35
0
파일: ofdft_pbc.py 프로젝트: thonmaker/gpaw
from ase.build import bulk
from gpaw import GPAW
from gpaw.mixer import Mixer
from gpaw.test import equal
from gpaw.test import gen


symbol = 'C'
result = -224.200276535
electrons = 48

xcname = 'LDA_K_TF+LDA_X'
g = gen(symbol, xcname=xcname, scalarrel=False, orbital_free=True)
h = 0.14
a = 2.8
atoms = bulk(symbol, 'diamond', a=a, cubic=True)   # Generate diamond
mixer = Mixer(0.1, 5)
        
calc = GPAW(h=h,
            xc=xcname,
            maxiter=120,
            eigensolver = 'cg',
            mixer=mixer)


atoms.set_calculator(calc)

e = atoms.get_potential_energy()

n = calc.get_all_electron_density()
예제 #36
0
from gpaw.test import gen
from gpaw import setup_paths

import os

"""This calculation has the following structure.
1) Calculate the ground state of Diamond.
2) Calculate the band structure of diamond in order to obtain accurate KS band gap for Diamond.
3) Calculate ground state again, and calculate the potential discontinuity using accurate band gap.
4) Calculate band structure again, and apply the discontinuity to CBM.

Compare to reference.
"""

xc = 'GLLBSC'
gen('C',xcname=xc)
setup_paths.insert(0, '.')

# Calculate ground state
atoms = bulk('C', 'diamond', a=3.567)
calc = GPAW(h=0.15, kpts=(4,4,4), xc=xc, nbands = 6,
            eigensolver=Davidson(niter=2))
atoms.set_calculator(calc)
atoms.get_potential_energy()
calc.write('Cgs.gpw')

# Calculate accurate KS-band gap from band structure
points = ibz_points['fcc']

# CMB is in G-X
G = points['Gamma']
예제 #37
0
from gpaw.poisson import PoissonSolver
from gpaw.occupations import FermiDirac
from gpaw.test import gen
from gpaw.eigensolvers import RMMDIIS
from gpaw.cluster import Cluster

if setup_paths[0] != '.':
    setup_paths.insert(0, '.')

h = 0.3

# No energies - simpley convergence test, esp. for 3d TM

# for atom in ['F', 'Cl', 'Br', 'Cu', 'Ag']:
for atom in ['Ti']:
    gen(atom, xcname='PBE', scalarrel=False, exx=True)
    work_atom = Cluster(Atoms(atom, [(0, 0, 0)]))
    work_atom.minimal_box(4, h=h)
    work_atom.translate([0.01, 0.02, 0.03])
    work_atom.set_initial_magnetic_moments([2.0])
    calculator = GPAW(convergence={
        'energy': 0.01,
        'eigenstates': 3,
        'density': 3
    },
                      eigensolver=RMMDIIS(),
                      poissonsolver=PoissonSolver(use_charge_center=True),
                      occupations=FermiDirac(width=0.0, fixmagmom=True),
                      h=h,
                      maxiter=35)  # Up to 24 are needed by now
    calculator.set(xc=HybridXC('PBE0'))