Beispiel #1
0
def asesurf2xxyz(symb, lattice, index, size=(1,1,3), vac=15.0, orthogonal=0):
    """
    An interface function for ase.lattice.surface

    Usage:
    >>> atoms = asesurf2xxyz(symb, lattice, index, size, 
                             vac=15.0, orthogonal=0))

    Parameters:
    symb: atomic symbol
    lattice: 'fcc', 'bcc', or 'hcp0001'
    index: '100', '111' or '110' (if lattice is 'hcp0001', this will not work.)
    size: the number of atoms per each vector
    
    Optional Parameters:
    vac (default: 15.0 angstron): the thickness of space normal to the surface
    orthogonal (default: False) : if True, two lateral cell vectors will be 
    orthogonal.

    Example:
    >>> Fe_100_1x1 = asesurf2xxyz('Fe', 'bcc', '100', (1,1,2))
    >>> Au_111_2x2 = asesurf2xxyz('Au', 'fcc', '111', (1,1,3))
    """
    if lattice == 'fcc':
        if index   == '100': at_ase = AS.fcc100(symb, size, vacuum=vac)
        elif index == '111': at_ase = AS.fcc111(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        elif index == '110': at_ase = AS.fcc110(symb, size, vacuum=vac)
        else: raise ValueError("100, 111, or 110 surface is supported.")
    elif lattice == 'bcc':
        if index   == '100': at_ase = AS.bcc100(symb, size, vacuum=vac)
        elif index == '111': at_ase = AS.bcc111(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        elif index == '110': at_ase = AS.bcc110(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        else: raise ValueError("100, 111, or 110 surface is supported.")
    elif lattice == 'hcp0001':
        at_ase = AS.hcp0001(symb, size, orthogonal=orthogonal, vacuum=vac)
    else: raise ValueError("fcc, bcc, or hcp0001 surface is supported.")
    
    symbols = at_ase.get_chemical_symbols()
    posits  = at_ase.get_positions()
    cell    = at_ase.get_cell()
    pbc     = at_ase.get_pbc()
    atoms = []; i=0
    for sym in symbols:
        temp_at = Atom(sym, list(posits[i]))
        atoms.append(temp_at.copy()); i+=1
    at_xxyz = AtomsSystem(atoms, cell=cell, pbc=pbc)
    return at_xxyz
Beispiel #2
0
def asesurf2xxyz(symb, lattice, index, size=(1,1,3), vac=15.0, orthogonal=0):
    """
    An interface function for ase.lattice.surface

    Usage:
    >>> atoms = asesurf2xxyz(symb, lattice, index, size, 
                             vac=15.0, orthogonal=0))

    Parameters:
    symb: atomic symbol
    lattice: 'fcc', 'bcc', or 'hcp0001'
    index: '100', '111' or '110' (if lattice is 'hcp0001', this will not work.)
    size: the number of atoms per each vector
    
    Optional Parameters:
    vac (default: 15.0 angstron): the thickness of space normal to the surface
    orthogonal (default: False) : if True, two lateral cell vectors will be 
    orthogonal.

    Example:
    >>> Fe_100_1x1 = asesurf2xxyz('Fe', 'bcc', '100', (1,1,2))
    >>> Au_111_2x2 = asesurf2xxyz('Au', 'fcc', '111', (1,1,3))
    """
    if lattice == 'fcc':
        if index   == '100': at_ase = AS.fcc100(symb, size, vacuum=vac)
        elif index == '111': at_ase = AS.fcc111(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        elif index == '110': at_ase = AS.fcc110(symb, size, vacuum=vac)
        else: raise ValueError, "100, 111, or 110 surface is supported."
    elif lattice == 'bcc':
        if index   == '100': at_ase = AS.bcc100(symb, size, vacuum=vac)
        elif index == '111': at_ase = AS.bcc111(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        elif index == '110': at_ase = AS.bcc110(symb, size,
                                                orthogonal=orthogonal,
                                                vacuum=vac)
        else: raise ValueError, "100, 111, or 110 surface is supported."
    elif lattice == 'hcp0001':
        at_ase = AS.hcp0001(symb, size, orthogonal=orthogonal, vacuum=vac)
    else: raise ValueError, "fcc, bcc, or hcp0001 surface is supported."
    
    symbols = at_ase.get_chemical_symbols()
    posits  = at_ase.get_positions()
    cell    = at_ase.get_cell()
    pbc     = at_ase.get_pbc()
    atoms = []; i=0
    for sym in symbols:
        temp_at = Atom(sym, list(posits[i]))
        atoms.append(temp_at.copy()); i+=1
    at_xxyz = AtomsSystem(atoms, cell=cell, pbc=pbc)
    return at_xxyz
Beispiel #3
0
'''
adapted from https://listserv.fysik.dtu.dk/pipermail/campos/2004-September/001155.html
'''
from ase import *
from ase.io import write
from ase.lattice.surface import bcc111, add_adsorbate
from ase.constraints import FixAtoms
# the bcc111 function automatically tags atoms
slab = bcc111('W',
              a=3.92,       # W lattice constant
              size=(2,2,6), # 6-layer slab in 2x2 configuration
              vacuum=10.0)
#reset tags to be powers of two so we can use binary math
slab.set_tags([2**a.get_tag() for a in slab])
# we had 6 layers, so we create new tags starting at 7
# Note you must use powers of two for all the tags!
LAYER1 = 2
ADSORBATE = 2**7
FREE = 2**8
NEARADSORBATE = 2**9
# let us tag LAYER1 atoms to be FREE too. we can address it by LAYER1 or FREE
tags = slab.get_tags()
for i,tag in enumerate(tags):
    if tag == LAYER1:
        tags[i] += FREE
slab.set_tags(tags)
#create a CO molecule
co= Atoms([Atom('C',[0., 0., 0. ], tag=ADSORBATE),
           Atom('O',[0., 0., 1.1], tag=ADSORBATE+FREE)]) #we will relax only O
add_adsorbate(slab,co,height=1.2,position='hollow')
#the adsorbate is centered between atoms 20, 21 and 22 (use
Beispiel #4
0
'''
adapted from https://listserv.fysik.dtu.dk/pipermail/campos/2004-September/001155.html
'''
from ase import *
from ase.io import write
from ase.lattice.surface import bcc111, add_adsorbate
from ase.constraints import FixAtoms
# the bcc111 function automatically tags atoms
slab = bcc111(
    'W',
    a=3.92,  # W lattice constant
    size=(2, 2, 6),  # 6-layer slab in 2x2 configuration
    vacuum=10.0)
#reset tags to be powers of two so we can use binary math
slab.set_tags([2**a.get_tag() for a in slab])
# we had 6 layers, so we create new tags starting at 7
# Note you must use powers of two for all the tags!
LAYER1 = 2
ADSORBATE = 2**7
FREE = 2**8
NEARADSORBATE = 2**9
# let us tag LAYER1 atoms to be FREE too. we can address it by LAYER1 or FREE
tags = slab.get_tags()
for i, tag in enumerate(tags):
    if tag == LAYER1:
        tags[i] += FREE
slab.set_tags(tags)
#create a CO molecule
co = Atoms([
    Atom('C', [0., 0., 0.], tag=ADSORBATE),
    Atom('O', [0., 0., 1.1], tag=ADSORBATE + FREE)