示例#1
0
def test_autoneb(asap3):
    EMT = asap3.EMT
    fmax = 0.02

    # Pt atom adsorbed in a hollow site:
    slab = fcc211('Pt', size=(3, 2, 2), vacuum=4.0)
    add_adsorbate(slab, 'Pt', 0.5, (-0.1, 2.7))

    # Fix second and third layers:
    slab.set_constraint(FixAtoms(range(6, 12)))

    # Use EMT potential:
    slab.calc = EMT()

    # Initial state:
    qn = QuasiNewton(slab, trajectory='neb000.traj')
    qn.run(fmax=fmax)

    # Final state:
    slab[-1].x += slab.get_cell()[0, 0]
    slab[-1].y += 2.8
    qn = QuasiNewton(slab, trajectory='neb001.traj')
    qn.run(fmax=fmax)

    # Stops PermissionError on Win32 for access to
    # the traj file that remains open.
    del qn

    def attach_calculators(images):
        for i in range(len(images)):
            images[i].calc = EMT()

    autoneb = AutoNEB(attach_calculators,
                      prefix='neb',
                      optimizer='BFGS',
                      n_simul=3,
                      n_max=7,
                      fmax=fmax,
                      k=0.5,
                      parallel=False,
                      maxsteps=[50, 1000])
    autoneb.run()

    nebtools = NEBTools(autoneb.all_images)
    assert abs(nebtools.get_barrier()[0] - 0.937) < 1e-3
示例#2
0
def test_surface():
    import numpy as np

    from ase import Atoms, Atom
    from ase.build import fcc111, fcc211, add_adsorbate, bulk, surface
    import math

    atoms = fcc211('Au', (3, 5, 8), vacuum=10.)
    assert len(atoms) == 120

    atoms = atoms.repeat((2, 1, 1))
    assert np.allclose(atoms.get_distance(0, 130), 2.88499566724)

    atoms = fcc111('Ni', (2, 2, 4), orthogonal=True)
    add_adsorbate(atoms, 'H', 1, 'bridge')
    add_adsorbate(atoms, Atom('O'), 1, 'fcc')
    add_adsorbate(atoms, Atoms('F'), 1, 'hcp')

    # The next test ensures that a simple string of multiple atoms cannot be used,
    # which should fail with a KeyError that reports the name of the molecule due
    # to the string failing to work with Atom().
    failed = False
    try:
        add_adsorbate(atoms, 'CN', 1, 'ontop')
    except KeyError as e:
        failed = True
        assert e.args[0] == 'CN'
    assert failed

    # This test ensures that the default periodic behavior remains unchanged
    cubic_fcc = bulk("Al", a=4.05, cubic=True)
    surface_fcc = surface(cubic_fcc, (1,1,1), 3)

    assert list(surface_fcc.pbc) == [True, True, False]
    assert surface_fcc.cell[2][2] == 0

    # This test checks the new periodic option
    cubic_fcc = bulk("Al", a=4.05, cubic=True)
    surface_fcc = surface(cubic_fcc, (1,1,1), 3, periodic=True)

    assert (list(surface_fcc.pbc) == [True, True, True])
    expected_length = 4.05*3**0.5 #for FCC with a=4.05
    assert math.isclose(surface_fcc.cell[2][2], expected_length)
示例#3
0
from ase.build import fcc211, add_adsorbate
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.optimize import QuasiNewton
from ase.neb import NEBTools
from ase.autoneb import AutoNEB

# Pt atom adsorbed in a hollow site:
slab = fcc211('Pt', size=(3, 2, 2), vacuum=4.0)
add_adsorbate(slab, 'Pt', 0.5, (-0.1, 2.7))

# Fix second and third layers:
slab.set_constraint(FixAtoms(range(6, 12)))

# Use EMT potential:
slab.set_calculator(EMT())

# Initial state:
qn = QuasiNewton(slab, trajectory='neb000.traj')
qn.run(fmax=0.05)

# Final state:
slab[-1].x += slab.get_cell()[0, 0]
slab[-1].y += 2.8
qn = QuasiNewton(slab, trajectory='neb001.traj')
qn.run(fmax=0.05)

# Stops PermissionError on Win32 for access to
# the traj file that remains open.
del qn
示例#4
0
 def opt_fcc211(self) -> None:
     ''' Optimize fcc211 slab '''
     slab = fcc211(self.symbol, self.repeats_surface, self.a, self.vacuum)
     self.prepare_slab_opt(slab)
示例#5
0
文件: autoneb.py 项目: thonmaker/gpaw
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Run with even number of cores

from gpaw import GPAW, Mixer, PoissonSolver
import ase.parallel as mpi
from ase.build import fcc211, add_adsorbate
from ase.constraints import FixAtoms
from ase.optimize import QuasiNewton
from ase.neb import NEBtools
from ase.autoneb import AutoNEB

size = mpi.world.size
rank = mpi.world.rank

slab = fcc211('Ag', size=(3, 2, 1), vacuum=3.0)
add_adsorbate(slab, 'Ag', 0.5, (-0.1, 2.7))

slab.set_constraint(FixAtoms(range(6)))
slab.pbc = 1


def getcalc(**kwargs):
    kwargs1 = dict(
        xc='oldLDA',
        gpts=(32, 24, 32),
        setups={'Ag': '11'},
        #h=0.24,
        poissonsolver=PoissonSolver(relax='GS'),
        mixer=Mixer(0.5, 5, 50.0),
        mode='lcao',
示例#6
0
from ase.build import fcc211, add_adsorbate
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.optimize import QuasiNewton
from ase.neb import NEBTools
from ase.autoneb import AutoNEB

# Pt atom adsorbed in a hollow site:
slab = fcc211('Pt', size=(3, 2, 2), vacuum=4.0)
add_adsorbate(slab, 'Pt', 0.5, (-0.1, 2.7))

# Fix second and third layers:
slab.set_constraint(FixAtoms(range(6, 12)))

# Use EMT potential:
slab.set_calculator(EMT())

# Initial state:
qn = QuasiNewton(slab, trajectory='neb000.traj')
qn.run(fmax=0.05)

# Final state:
slab[-1].x += slab.get_cell()[0, 0]
slab[-1].y += 2.8
qn = QuasiNewton(slab, trajectory='neb001.traj')
qn.run(fmax=0.05)

# Stops PermissionError on Win32 for access to
# the traj file that remains open.
del qn
示例#7
0
文件: surface.py 项目: wes-amat/ase
import numpy as np

from ase import Atoms, Atom
from ase.build import fcc111, fcc211, add_adsorbate, bulk, surface
import math

atoms = fcc211('Au', (3, 5, 8), vacuum=10.)
assert len(atoms) == 120

atoms = atoms.repeat((2, 1, 1))
assert np.allclose(atoms.get_distance(0, 130), 2.88499566724)

atoms = fcc111('Ni', (2, 2, 4), orthogonal=True)
add_adsorbate(atoms, 'H', 1, 'bridge')
add_adsorbate(atoms, Atom('O'), 1, 'fcc')
add_adsorbate(atoms, Atoms('F'), 1, 'hcp')

# The next test ensures that a simple string of multiple atoms cannot be used,
# which should fail with a KeyError that reports the name of the molecule due
# to the string failing to work with Atom().
failed = False
try:
    add_adsorbate(atoms, 'CN', 1, 'ontop')
except KeyError as e:
    failed = True
    assert e.args[0] == 'CN'
assert failed

# This test ensures that the default periodic behavior remains unchanged
cubic_fcc = bulk("Al", a=4.05, cubic=True)
surface_fcc = surface(cubic_fcc, (1,1,1), 3)
示例#8
0
import numpy as np

from ase import Atoms, Atom
from ase.build import fcc111, fcc211, add_adsorbate

atoms = fcc211('Au', (3, 5, 8), vacuum=10.)
assert len(atoms) == 120

atoms = atoms.repeat((2, 1, 1))
assert np.allclose(atoms.get_distance(0, 130), 2.88499566724)

atoms = fcc111('Ni', (2, 2, 4), orthogonal=True)
add_adsorbate(atoms, 'H', 1, 'bridge')
add_adsorbate(atoms, Atom('O'), 1, 'fcc')
add_adsorbate(atoms, Atoms('F'), 1, 'hcp')

# The next test ensures that a simple string of multiple atoms cannot be used,
# which should fail with a KeyError that reports the name of the molecule due
# to the string failing to work with Atom().
failed = False
try:
    add_adsorbate(atoms, 'CN', 1, 'ontop')
except KeyError as e:
    failed = True
    assert e.args[0] == 'CN'
assert failed