예제 #1
0
# 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

if 1:
    r = RecursionMethod(calc)
    r.run(400)
    r.write('h2o.pckl')
else:
예제 #2
0
n = size // 3  # number of cpu's per image
j = 1 + rank // n  # my image number
assert 3 * n == size

images = [initial]

for i in range(3):

    ranks = range(i * n, (i + 1) * n)
    image = initial.copy()

    if rank in ranks:

        calc = GPAW(h=0.3,
                    kpts=(2, 2, 1),
                    txt='neb%d.txt' % j,
                    communicator=ranks)

        image.set_calculator(calc)

    image.set_constraint(constraint)
    images.append(image)

images.append(final)

neb = NEB(images, parallel=True)
neb.interpolate()

qn = BFGS(neb, logfile='qn.log')

traj = PickleTrajectory('neb%d.traj' % j,
예제 #3
0
from ase import Atoms
from ase.visualize import view

atoms = Atoms(symbols=myGpaw.symstr,
              pbc=[True, True, True],
              cell=myGpaw.gcell,
              positions=myGpaw.pos)
# view(atoms)
kpts = {'size': (4, 4, 4), 'gamma': True}
calc = GPAW(#h=0.16,
            mode=PW(360),
            kpts=kpts,
            xc='PBE',
            txt=myGpaw.symstr+'_360.out',
            occupations=FermiDirac(width=0.05),
          #   nbands=-2,
            convergence={'energy': 0.0005,  # eV / electron
               'density': 1.0e-4,
               'eigenstates': 4.0e-8,  # eV^2 / electron
               'bands': 'CBM+2.0',
               'forces': float('inf')} # eV / Ang Max
            )

atoms.calc = calc
e2 = atoms.get_potential_energy()
d0 = atoms.get_distance(0, 1)

fd = open('optimization.txt', 'w')
print('experimental bond length:', file=fd)
print('hydrogen molecule energy: %5.2f eV' % e2, file=fd)
print('bondlength              : %5.2f Ang' % d0, file=fd)
예제 #4
0
파일: benzene.py 프로젝트: fuulish/fuase
from ase.structure import molecule
from gpaw import GPAW

atoms = molecule('C6H6')
atoms.center(vacuum=3.5)

calc = GPAW(h=.21, xc='PBE', txt='benzene.txt', nbands=18)
atoms.set_calculator(calc)
atoms.get_potential_energy()

calc.set(fixdensity=True,
         txt='benzene-harris.txt',
         nbands=40,
         eigensolver='cg',
         convergence={'bands': 35})
atoms.get_potential_energy()

calc.write('benzene.gpw', mode='all')
예제 #5
0
import numpy as np
from ase.build import bulk
from ase.units import Hartree, Bohr
from gpaw import GPAW, FermiDirac
from ase.dft.kpoints import monkhorst_pack

for kpt in (3, 4):
    kpts = (kpt, kpt, kpt)
    bzk_kc = monkhorst_pack(kpts)
    shift_c = []
    for Nk in kpts:
        if Nk % 2 == 0:
            shift_c.append(0.5 / Nk)
        else:
            shift_c.append(0.)
    bzk_kc += shift_c

    atoms = bulk('Si', 'diamond', a=5.431)
    calc = GPAW(h=0.2, kpts=bzk_kc)

    atoms.set_calculator(calc)
    atoms.get_potential_energy()

    kd = calc.wfs.kd
    bzq_qc = kd.get_bz_q_points()
    ibzq_qc = kd.get_ibz_q_points(bzq_qc, calc.wfs.kd.symmetry.op_scc)[0]

    assert np.abs(bzq_qc - kd.bzk_kc).sum() < 1e-8
    assert np.abs(ibzq_qc - kd.ibzk_kc).sum() < 1e-8
예제 #6
0
nk = 12
kpts = monkhorst_pack((nk, nk, nk)) + 0.5 / nk

c = ase.db.connect('gaps.db')

for name in ['Si', 'C', 'GaAs', 'MgO', 'NaCl', 'Ar']:
    id = c.reserve(name=name)
    if id is None:
        continue

    x, a = bfb[name][:2]
    atoms = bulk(name, x, a=a)
    atoms.calc = GPAW(xc='PBE',
                      mode=PW(500),
                      parallel=dict(band=1),
                      nbands=-8,
                      convergence=dict(bands=-7),
                      kpts=kpts,
                      txt='%s.txt' % name)

    if name in ['MgO', 'NaCl']:
        atoms.calc.set(eigensolver='dav')

    atoms.get_potential_energy()
    atoms.calc.write(name, mode='all')

    ibzk_kc = atoms.calc.get_ibz_k_points()
    n = int(atoms.calc.get_number_of_electrons()) // 2

    ibzk = []
    eps_kn = []
예제 #7
0
###############GROUND STATE CALCULATION####################

a = 3.57  # Lattice constant for diamond in angstrom
# Create diamond structure
diamond = bulk('C', 'diamond', a)
# Set up calculator
# Mode is plane wave with cut off 200 eV
# Exchange-correlation functional is Perdew, Burke, Ernzerhof
# Brilloin-zone will be sampled with a regular grid of 8x8x8 k-points
# Use random numbers for wave function initialization
# Occupation numbers follow Fermi-Dirac statistics with a width of 0.01 eV
# Text output sent to Di_gs.txt
calc = GPAW(mode=PW(200),
            xc='PBE',
            kpts=(8, 8, 8),
            random=True,
            occupations=FermiDirac(0.01),
            txt='Di_gs.txt')

diamond.set_calculator(calc)
diamond.get_potential_energy()
# Save the ground state to a gpaw file
calc.write('Di_gs.gpw')
efermi = calc.get_fermi_level()

###############GENERATING K-POINTS#########################

# Number of lowest bands to converge
nbands = 11
# Restart the ground state calculator and fix potential
# Include 16 electronic bands for each spin calculation
예제 #8
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'))
    calculator.set(txt=atom + '-PBE0.txt')
    work_atom.set_calculator(calculator)
    try:
        work_atom.get_potential_energy()
    except KohnShamConvergenceError:
        pass
    assert calculator.scf.converged, 'Calculation not converged'
예제 #9
0
파일: lrtddft2.py 프로젝트: yihsuanliu/gpaw
txt = '-'
txt = None
load = True
load = False

R = 0.7  # approx. experimental bond length
a = 4.0
c = 5.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=2, spinpol=False, txt=txt)
H2.set_calculator(calc)
H2.get_potential_energy()
calc.write('H2saved_wfs.gpw', 'all')
calc.write('H2saved.gpw')
wfs_error = calc.wfs.eigensolver.error

xc = 'LDA'

#print "-> starting directly after a gs calculation"
lr = LrTDDFT(calc, xc=xc, txt='-')
lr.diagonalize()

#print "-> reading gs with wfs"
gs = GPAW('H2saved_wfs.gpw', txt=txt)