Exemplo n.º 1
0
def energy(N, k, a=4.05):
    fcc = fcc100('Al', (1, 1, N), a=a, vacuum=7.5)
    fcc.center(axis=2)
    calc = GPAW(nbands=N * 3, kpts=(k, k, 1), h=0.25, txt='slab-%d.txt' % N)
    fcc.set_calculator(calc)
    e = fcc.get_potential_energy()
    calc.write('slab-%d.gpw' % N)
    return e
Exemplo n.º 2
0
Arquivo: Al100.py Projeto: qsnake/gpaw
def energy(N, k, a=4.05):
    fcc = fcc100('Al', (1, 1, N), a=a, vacuum=7.5)
    fcc.center(axis=2)
    calc = GPAW(nbands=N * 5,
                kpts=(k, k, 1),
                h=0.25,
                txt='slab-%d.txt' % N)
    fcc.set_calculator(calc)
    e = fcc.get_potential_energy()
    calc.write('slab-%d.gpw' % N)
    return e
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
0
Arquivo: neb.py Projeto: lqcata/ase
def get_atoms():
    # 2x2-Al(001) surface with 3 layers and an
    # Au atom adsorbed in a hollow site:
    slab = fcc100('Al', size=(2, 2, 3))
    add_adsorbate(slab, 'Au', 1.7, 'hollow')
    slab.center(axis=2, vacuum=4.0)

    # Fix second and third layers:
    mask = [atom.tag > 1 for atom in slab]
    slab.set_constraint(FixAtoms(mask=mask))

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

    # Initial state:
    qn = QuasiNewton(slab, logfile=None)
    qn.run(fmax=0.05)
    initial = slab.copy()

    # Final state:
    slab[-1].x += slab.get_cell()[0, 0] / 2
    qn = QuasiNewton(slab, logfile=None)
    qn.run(fmax=0.05)
    final = slab.copy()

    # Setup a NEB calculation
    constraint = FixAtoms(mask=[atom.tag > 1 for atom in initial])

    images = [initial]
    for i in range(3):
        image = initial.copy()
        image.set_constraint(constraint)
        images.append(image)

    images.append(final)

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

    def set_calculator(calc):
        i = 0
        for image in neb.images[1:-1]:
            if not mpi.parallel or mpi.rank // (mpi.size // 3) == i:
                image.set_calculator(calc)
            i += 1

    neb.set_calculator = set_calculator

    return neb
Exemplo n.º 6
0
def get_surface_slabs(symbol,
                      surfacetype,
                      surfacesize,
                      layers,
                      latticeconstants,
                      vacuum=10.0):
    images = []
    if surfacetype == 'fcc100' or surfacetype == 'fcc111':
        nlayeratoms = surfacesize[0] * surfacesize[1]
        if isinstance(latticeconstants, (list, tuple)):
            if not len(latticeconstants) == 1:
                raise ValueError("Too many latticeconstants")
            a = latticeconstants[0]
        else:
            a = latticeconstants
    elif surfacetype == 'hcp0001':
        nlayeratoms = surfacesize[0] * surfacesize[1]
        if isinstance(latticeconstants, (list, tuple)):
            if not len(latticeconstants) == 2:
                raise ValueError("Latticeconstants must be on the form [a, c]")
            a = latticeconstants[0]
            c = latticeconstants[1]
        else:
            raise ValueError("Latticeconstants must be on the form [a, c]")
    else:
        raise ValueError("Surface type '%s' is not supported" %
                         (surfacetype, ))

    for n in layers:
        size = surfacesize + (n, )
        if surfacetype == 'fcc100':
            images.append(fcc100(symbol=symbol, size=size, a=a, vacuum=vacuum))
        elif surfacetype == 'fcc111':
            images.append(
                fcc111(symbol=symbol,
                       size=size,
                       a=a,
                       vacuum=vacuum,
                       orthogonal=True))
        elif surfacetype == 'hcp0001':
            images.append(
                hcp0001(symbol=symbol,
                        size=size,
                        a=a,
                        c=c,
                        vacuum=vacuum,
                        orthogonal=True))

    return images, nlayeratoms
Exemplo n.º 7
0
Arquivo: neb.py Projeto: jboes/ase
def get_atoms():
    # 2x2-Al(001) surface with 3 layers and an
    # Au atom adsorbed in a hollow site:
    slab = fcc100('Al', size=(2, 2, 3))
    add_adsorbate(slab, 'Au', 1.7, 'hollow')
    slab.center(axis=2, vacuum=4.0)

    # Fix second and third layers:
    mask = [atom.tag > 1 for atom in slab]
    slab.set_constraint(FixAtoms(mask=mask))

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

    # Initial state:
    qn = QuasiNewton(slab, logfile=None)
    qn.run(fmax=0.05)
    initial = slab.copy()

    # Final state:
    slab[-1].x += slab.get_cell()[0, 0] / 2
    qn = QuasiNewton(slab, logfile=None)
    qn.run(fmax=0.05)
    final = slab.copy()

    # Setup a NEB calculation
    constraint = FixAtoms(mask=[atom.tag > 1 for atom in initial])

    images = [initial]
    for i in range(3):
        image = initial.copy()
        image.set_constraint(constraint)
        images.append(image)

    images.append(final)

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

    def set_calculator(calc):
        i = 0
        for image in neb.images[1:-1]:
            if not mpi.parallel or mpi.rank // (mpi.size // 3) == i:
                image.set_calculator(calc)
            i += 1
    neb.set_calculator = set_calculator

    return neb
Exemplo n.º 8
0
def facet_setup(host,fac,c,lat,root=None):
    if fac == 111:
        if root:
            atoms = fcc111_root(host, root=root, a=lat, size=(c[0],c[1],4),
                                vacuum = 12.0)
        else:
            atoms = fcc111(host, a=lat, size=(c[0],c[1],4),
                           vacuum=12.0)
    elif fac == 100:
        atoms = fcc100(host, a=lat, size=(c[0],c[1],4),
                       vacuum=12.0)

    elif fac == 211:
        atoms = fcc211(host, a=lat, size=(c[0],c[1],4),
                       vacuum=12.0)

    return atoms
Exemplo n.º 9
0
def slabCalculation():
    slab = fcc100("Al", size=(2, 2, 3))
    add_adsorbate(slab, "Au", 1.7, "hollow")
    slab.center(axis=2, vacuum=4.0)

    # Make sure the structure is correct:
    # from ase.visualize import view
    # view(slab)

    # Fix second and third layers:
    mask = [atom.tag > 1 for atom in slab]
    # print mask
    fixlayers = FixAtoms(mask=mask)

    # Constrain the last atom (Au atom) to move only in the yz-plane:
    plane = FixedPlane(-1, (1, 0, 0))

    slab.set_constraint([fixlayers, plane])

    print(slab.cell / Bohr)
Exemplo n.º 10
0
def slabCalculation():
    slab = fcc100('Al', size=(2, 2, 3))
    add_adsorbate(slab, 'Au', 1.7, 'hollow')
    slab.center(axis=2, vacuum=4.0)

    # Make sure the structure is correct:
    #from ase.visualize import view
    #view(slab)

    # Fix second and third layers:
    mask = [atom.tag > 1 for atom in slab]
    #print mask
    fixlayers = FixAtoms(mask=mask)

    # Constrain the last atom (Au atom) to move only in the yz-plane:
    plane = FixedPlane(-1, (1, 0, 0))

    slab.set_constraint([fixlayers, plane])

    print(slab.cell / Bohr)
Exemplo n.º 11
0
def aual100(site, height, calc=None):

    slab = fcc100('Al', size=(2, 2, 1))
    add_adsorbate(slab, 'Au', height, site)
    slab.center(axis=2, vacuum=3.0)
    mask = [atom.symbol == 'Al' for atom in slab]
    fixlayer = FixAtoms(mask=mask)
    slab.set_constraint(fixlayer)

    if calc is None:
        calc = GPAW(h=0.25, kpts=(2, 2, 1), xc='PBE', txt=site + '.txt')

    slab.set_calculator(calc)
    qn = QuasiNewton(slab, trajectory=site + '.traj')
    qn.run(fmax=0.05)

    if isinstance(calc, GPAW):
        calc.write(site + '.gpw')

    return slab.get_potential_energy()
Exemplo n.º 12
0
def get_surface_slabs(symbol, surfacetype, surfacesize, layers, latticeconstants,
                      vacuum=10.0):
    images = []
    if surfacetype == 'fcc100' or surfacetype == 'fcc111':
        nlayeratoms = surfacesize[0] * surfacesize[1]
        if isinstance(latticeconstants, (list, tuple)):
            if not len(latticeconstants) == 1:
                raise ValueError("Too many latticeconstants")
            a = latticeconstants[0]
        else:
            a = latticeconstants
    elif surfacetype == 'hcp0001':
        nlayeratoms = surfacesize[0] * surfacesize[1]
        if isinstance(latticeconstants, (list, tuple)):
            if not len(latticeconstants) == 2:
                raise ValueError("Latticeconstants must be on the form [a, c]")
            a = latticeconstants[0]
            c = latticeconstants[1]
        else:
            raise ValueError("Latticeconstants must be on the form [a, c]")
    else:
        raise ValueError("Surface type '%s' is not supported" % (surfacetype,))


    for n in layers:
        size = surfacesize + (n,)
        if surfacetype == 'fcc100':
            images.append(fcc100(symbol=symbol, size=size, a=a, vacuum=vacuum))
        elif surfacetype == 'fcc111':
            images.append(fcc111(symbol=symbol, size=size, a=a, vacuum=vacuum,
                                 orthogonal=True))
        elif surfacetype == 'hcp0001':
            images.append(hcp0001(symbol=symbol, size=size, a=a, c=c,
                                  vacuum=vacuum, orthogonal=True))

    return images, nlayeratoms
Exemplo n.º 13
0
from winak.curvilinear.Coordinates import DelocalizedCoordinates as DC
from winak.globaloptimization.delocalizer import *
from winak.curvilinear.InternalCoordinates import icSystem, Periodic_icSystem
from winak.curvilinear.InternalCoordinates import ValenceCoordinateGenerator as VCG 
from winak.curvilinear.InternalCoordinates import PeriodicValenceCoordinateGenerator as PVCG 

from ase.lattice.cubic import FaceCenteredCubic as fcc
from ase.lattice.surface import fcc100, fcc111
import cPickle as pickle
import numpy as np

i = 2
j = 2
k = 3

system = fcc100('Pd', (i,j,k), a=3.94, vacuum=10.)

natoms =len(system) 
np.set_printoptions(threshold=np.nan)
import time
start=time.time()
print start

iclist = None
iclist = pickle.load(open("iclist.p", "rb"))

print 'delocalizer '

d = Delocalizer(system, icList=iclist, periodic=True, dense=False, \
        weighted=False, add_cartesians = True)
e1 = []
Exemplo n.º 14
0
ncpus = 4
from ase.lattice.surface import fcc100
from gpaw import GPAW
atoms = fcc100(symbol='Ni', size=(1, 1, 9), a=3.52, vacuum=5.5)
atoms.set_initial_magnetic_moments([0.6] * len(atoms))
atoms.calc = GPAW(h=0.18, kpts=(8, 8, 1), xc='PBE')
Exemplo n.º 15
0

l=options.lattice
p=options.periods
v=options.vaccuum
e=options.element

atoms = []
if(options.bravais == 'fcc'):
    if(options.hkl == '111'):
        #atoms = fcc111(e, size=p,a=l, vacuum=v, orthogonal=False)
        atoms = fcc111(e, size=p,a=l, vacuum=v, orthogonal=options.ortogonal)
    elif(options.hkl == '110'):
        atoms = fcc110(e, size=p,a=l, vacuum=v)
    elif(options.hkl == '100'):
        atoms = fcc100(e, size=p,a=l, vacuum=v)
elif(options.bravais == 'MoS2'):
    atoms = mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19, size=(1, 1, 1), vacuum=7.5)
#c=atoms.get_cell()
#c[1][0] += l*math.sqrt(2)*0.5
#atoms.set_cell(c)

#atoms.translate([0.0,0.0,-14.9999999999999982])


if(options.cell != None):
    to_remove = []
    for i, atom in enumerate(atoms):
        r = atom.position.astype(float)
        print i, atom, r
Exemplo n.º 16
0
from ase.visualize import view
from ase.constraints import FixAtoms
from ase.optimize import QuasiNewton
from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW

# Initial state:
# 2x2-Al(001) surface with 1 layer and an
# Au atom adsorbed in a hollow site:
slab = fcc100("Al", size=(2, 2, 1))
add_adsorbate(slab, "Au", 1.6, "hollow")
slab.center(axis=2, vacuum=3.0)

# Make sure the structure is correct:
view(slab)

# Fix the Al atoms:
mask = [atom.symbol == "Al" for atom in slab]
print mask
fixlayer = FixAtoms(mask=mask)
slab.set_constraint(fixlayer)

# Use GPAW:
calc = GPAW(h=0.25, kpts=(2, 2, 1), xc="PBE", txt="hollow.txt")
slab.set_calculator(calc)

qn = QuasiNewton(slab, trajectory="hollow.traj")

# Find optimal height.  The stopping criterion is: the force on the
# Au atom should be less than 0.05 eV/Ang
qn.run(fmax=0.05)
Exemplo n.º 17
0
from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW
from gpaw.poisson import PoissonSolver
from gpaw.dipole_correction import DipoleCorrection

slab = fcc100('Al', (2, 2, 2), a=4.05, vacuum=7.5)
add_adsorbate(slab, 'Na', 4.0)
slab.center(axis=2)

slab.calc = GPAW(txt='zero.txt', xc='PBE', setups={'Na': '1'}, kpts=(4, 4, 1))
e1 = slab.get_potential_energy()
slab.calc.write('zero.gpw')

slab.pbc = True
slab.calc.set(txt='periodic.txt')
e2 = slab.get_potential_energy()
slab.calc.write('periodic.gpw')

slab.pbc = (True, True, False)
slab.calc.set(poissonsolver=DipoleCorrection(PoissonSolver(), 2),
              txt='corrected.txt')
e3 = slab.get_potential_energy()
slab.calc.write('corrected.gpw')
from ase.lattice.surface import fcc100, add_adsorbate
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.dimer import DimerControl, MinModeAtoms, MinModeTranslate

# Set up a small "slab" with an adatoms
atoms = fcc100("Pt", size=(2, 2, 1), vacuum=10.0)
add_adsorbate(atoms, "Pt", 1.611, "hollow")

# Freeze the "slab"
mask = [atom.tag > 0 for atom in atoms]
atoms.set_constraint(FixAtoms(mask=mask))

# Calculate using EMT
atoms.set_calculator(EMT())
relaxed_energy = atoms.get_potential_energy()

# Set up the dimer
d_control = DimerControl(
    initial_eigenmode_method="displacement", displacement_method="vector", logfile=None, mask=[0, 0, 0, 0, 1]
)
d_atoms = MinModeAtoms(atoms, d_control)

# Displace the atoms
displacement_vector = [[0.0] * 3] * 5
displacement_vector[-1][1] = -0.1
d_atoms.displace(displacement_vector=displacement_vector)

# Converge to a saddle point
dim_rlx = MinModeTranslate(d_atoms, trajectory="dimer_method.traj", logfile=None)
dim_rlx.run(fmax=0.001)
Exemplo n.º 19
0
    def get_structure(self, name, elements, a=None, c=None, l=None):
        # Check number of elements
        if name[:3] in ['fcc', 'hcp']:
            if len(elements) != 1:
                raise ValueError("Tuple of elements must be of length one")
        if name[:3] in ['l12', 'l10'] or name[:2] == 'B2':
            if len(elements) != 2:
                raise ValueError("Tuple of elements must be of length two")

        # Get lattice constants
        if a is None:
            if name[:2] == 'B2':
                a = self.get_lattice_constant_a(name[:2], elements)
            elif name[:3] in ['fcc', 'hcp', 'bcc', 'l12', 'l10']:
                a = self.get_lattice_constant_a(name[:3], elements)

        if c is None:
            if name[:3] in ['hcp', 'l10']:
                c = self.get_lattice_constant_c(name[:3], elements)

        # Get size
        if name in ['fcc', 'hcp', 'bcc', 'l12', 'l10', 'B2']:
            size = self.properties[name + '_size']
        elif name in ['fcc100', 'fcc111', 'hcp0001']:
            size = self.properties[name + '_size'][:2] + (l, )

        # Make structure
        if name == 'fcc':
            atoms = FaceCenteredCubic(symbol=elements[0],
                                      size=size,
                                      latticeconstant=a)
        elif name == 'hcp':
            atoms = HexagonalClosedPacked(symbol=elements[0],
                                          size=size,
                                          directions=[[2, -1, -1, 0],
                                                      [0, 1, -1, 0],
                                                      [0, 0, 0, 1]],
                                          latticeconstant=(a, c))
        elif name == 'bcc':
            atoms = BodyCenteredCubic(symbol=elements[0],
                                      size=size,
                                      latticeconstant=a)
        elif name == 'B2':
            atoms = B2(symbol=elements, size=size, latticeconstant=a)
        elif name == 'l12':
            atoms = L1_2(symbol=elements, size=size, latticeconstant=a)
        elif name == 'l10':
            atoms = L1_0(symbol=elements, size=size, latticeconstant=(a, c))
        elif name == 'fcc100':
            atoms = fcc100(symbol=elements[0], size=size, a=a, vacuum=10.0)
        elif name == 'fcc111':
            atoms = fcc111(symbol=elements[0],
                           size=size,
                           a=a,
                           vacuum=10.0,
                           orthogonal=True)
        elif name == 'hcp0001':
            atoms = hcp0001(symbol=elements[0],
                            size=size,
                            a=a,
                            c=c,
                            vacuum=10.0,
                            orthogonal=True)
        elif name == 'hcp1010A':
            raise ValueError("Structure '%s' not supported" % (name, ))
            atoms = None
        elif name == 'hcp1010B':
            raise ValueError("Structure '%s' not supported" % (name, ))
            atoms = None
        elif name == 'l12100':
            n = (l + 1) / 2
            atoms = L1_2(symbol=elements, size=(8, 8, n), latticeconstant=a)
            atoms.set_pbc([True, True, False])
            # Remove layers
            atoms = atoms[atoms.get_positions()[:, 2] > 0.1 * a]
            # Set vacuum
            atoms.center(axis=2, vacuum=10.0)
        elif name == 'l12111':
            if l % 3 == 0:
                n = l / 3
                c = 0
            else:
                n = l / 3 + 1
                c = 3 - l % 3
            atoms = L1_2(
                symbol=elements,
                size=(8, 4, n),
                #directions=[[1,-1,0],[1,0,-1],[1,1,1]], latticeconstant=a)
                directions=[[1, -1, 0], [1, 1, -2], [1, 1, 1]],
                latticeconstant=a)
            atoms.set_pbc([True, True, False])
            # Wrap positions
            scpos = atoms.get_scaled_positions()
            scpos[scpos > (1.0 - 1e-12)] = 0.0
            atoms.set_scaled_positions(scpos)
            # Remove layers
            if c > 0:
                atoms = atoms[atoms.get_positions()[:, 2] > (c - 0.5) * a /
                              np.sqrt(3.0)]
            # Set vacuum
            atoms.center(axis=2, vacuum=10.0)
        else:
            raise ValueError("Structure '%s' not supported" % (name, ))
        return atoms
Exemplo n.º 20
0
import ase
import ase.lattice.surface as surf
from ase.visualize import view
import jlgh as jl

slab = surf.fcc100('Pd',[1,1,4],vacuum = 10)
# view(slab*[2,2,1])
# raise SystemExit()

h0 = max([at.position[2] for at in slab]) / slab.cell[2][2]

sites = [ jl.Site(name='hollow', pos=[.5,.5,h0]),
          jl.Site(name='top', pos=[.0,.0,h0]),
          jl.Site(name='br1', pos=[.5,.0,h0]),
          jl.Site(name='br2', pos=[.0,.5,h0]),
            ]

ucell = jl.SurfUnitCell(slab,sites_list=sites)

COatoms = ase.Atoms('CO',positions=[[0.0,0.0,1.0],[0.0,0.0,2.0]])
Oatoms = ase.Atoms('O',positions=[[0.0,0.0,1.0],])

COads = jl.Adsorbate('CO',COatoms,center=[0.,0.,0.])
Oads = jl.Adsorbate('O',Oatoms,center=[0.,0.,0.])

# species_coords = [ 'O@hollow.(0,0,0)', 'O@hollow.(1,0,0)']
# species_coords = [ 'O@hollow.(0,0,0)', 'O@hollow.(1,0,0)','O@hollow.(1,1,0)']
species_coords = [ 'O@hollow.(0,0,0)', 'O@hollow.(1,0,0)','O@hollow.(1,1,0)','O@hollow.(0,1,0)']
species_coords = [ 'O@hollow.(0,0,0)', 'CO@br2.(1,1,0)']
species_coords = [ 'O@hollow.(0,0,0)', 'O@hollow.(1,0,0)','CO@br2.(1,1,0)']
conf = jl.Config(size = [2,2],species_coords = species_coords)
Exemplo n.º 21
0
from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW
from gpaw.poisson import PoissonSolver
from gpaw.dipole_correction import DipoleCorrection

slab = fcc100('Al', (2, 2, 2), a=4.05, vacuum=7.5)
add_adsorbate(slab, 'Na', 4.0)
slab.center(axis=2)

slab.calc = GPAW(txt='zero.txt',
                 xc='PBE',
                 setups={'Na': '1'},
                 kpts=(4, 4, 1))
e1 = slab.get_potential_energy()
slab.calc.write('zero.gpw')

slab.pbc = True
slab.calc.set(txt='periodic.txt')
e2 = slab.get_potential_energy()
slab.calc.write('periodic.gpw')

slab.pbc = (True, True, False)
slab.calc.set(poissonsolver=DipoleCorrection(PoissonSolver(), 2),
              txt='corrected.txt')
e3 = slab.get_potential_energy()
slab.calc.write('corrected.gpw')
Exemplo n.º 22
0
from winak.curvilinear.Coordinates import PeriodicCoordinates as PC
from winak.curvilinear.Coordinates import DelocalizedCoordinates as DC
from winak.globaloptimization.delocalizer import *
from winak.curvilinear.InternalCoordinates import icSystem, Periodic_icSystem
from winak.curvilinear.InternalCoordinates import ValenceCoordinateGenerator as VCG 
from winak.curvilinear.InternalCoordinates import PeriodicValenceCoordinateGenerator as PVCG 

from ase.lattice.cubic import FaceCenteredCubic as fcc
from ase.lattice.surface import fcc100, fcc111
import numpy as np

system = fcc100('Pd', (2,2,4), a=3.94, vacuum=10.)

natoms =len(system) 
np.set_printoptions(threshold=np.nan)
import time
start=time.time()
print start

#constraints need to be satisfied on two levels
#first we need to partition our active coordinate space 
#into constrained and unconstrained coordinates, this part 
#happens in the Delocalizer
#secondly the backiteration needs to remove components of 
#constrained coordinates. For cartesian or lattice coordinates this 
#amounts to zeroing columns of the Bmatrix (passed to the backIteration 
#        via biArgs col_constraints=[column1, column2]
#For internal coordinates we zero the rows of the Bmatrix, passed by 
#row_constraints=[row1,row2]

#pic example
Exemplo n.º 23
0
from ase import Atoms, Atom
from gpaw import GPAW, Mixer
from ase.lattice.surface import fcc100
from gpaw.transport.jstm import dump_hs, dump_lead_hs

calc = GPAW(h=0.2, 
            mixer=Mixer(0.03, 5, weight=140.0),
            width=0.1, 
            mode='lcao',
            basis='szp(dzp)',
            txt='dumphs.txt',
            usesymm=False)

# surface calculation
a = 4.0 
srf = fcc100('Al', size=(2, 2, 10), vacuum=8.0)
srf.translate([0, 0, -4]) 
srf.pbc= (1, 1, 0)
srf += Atom('H', (a / 2**.5, a / 2**.5, srf.positions[-1][2] + 1.55))

srf.set_calculator(calc)
srf.get_potential_energy()
calc.write('srf')

# Dump the overlap matrix and the Hamiltonian matrix to the local directory. 
# Here the keyword 'cvl' refers  to the number of basis functions in the 
# in the convergence layer, i.e. for the present system four atomic layers are used.
dump_hs(calc, 'srf', region='surface', cvl=4*4*9) 
                                                 
# tip calculation 
a = 0.75 # lattice constant
Exemplo n.º 24
0
from ase.lattice.surface import fcc100, add_adsorbate
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.dimer import DimerControl, MinModeAtoms, MinModeTranslate

# Set up a small "slab" with an adatoms
atoms = fcc100('Pt', size = (2, 2, 1), vacuum = 10.0)
add_adsorbate(atoms, 'Pt', 1.611, 'hollow')

# Freeze the "slab"
mask = [atom.tag > 0 for atom in atoms]
atoms.set_constraint(FixAtoms(mask = mask))

# Calculate using EMT
atoms.set_calculator(EMT())
relaxed_energy = atoms.get_potential_energy()

# Set up the dimer
d_control = DimerControl(initial_eigenmode_method = 'displacement', \
                         displacement_method = 'vector', logfile = None, \
                         mask = [0, 0, 0, 0, 1])
d_atoms = MinModeAtoms(atoms, d_control)

# Dispalce the atoms
displacement_vector = [[0.0]*3]*5
displacement_vector[-1][1] = -0.1
d_atoms.displace(displacement_vector = displacement_vector)

# Converge to a saddle point
dim_rlx = MinModeTranslate(d_atoms, trajectory = 'dimer_method.traj', \
                           logfile = None)
Exemplo n.º 25
0

############ dimer ##############################
path = os.path.dirname(os.path.abspath(__file__))
print(path)
starttime = time.strftime("%y%m%d%H%M%S")
a=3.9242
# Setting up the initial image:
# initial = fcc111('Pt', size=(4, 4, 2), a=3.9242, vacuum=10.0)
# add_adsorbate(initial, 'Pt', 1.611, 'hollow')
"""Pt_atoms = FaceCenteredCubic(directions=[[0,1,0], [0,0,1,], [1,0,0]],
                            size=(4,4,1),latticeconstant=a,
                            symbol='Pt', pbc=(1,1,1))
initial = surface(Pt_atoms, (0,0,1), 3)
# [1,-1,0], [1,1,-2], [1,1,1]], # for 111 surface"""
initial = fcc100('Pt', size=(4, 4, 5), a=a)
add_adsorbate(initial, 'Pt', 1.611, 'hollow')  #add adatom on surface
at = initial[len(initial)-6]
at_pos = at.position
at_ind = at.index
print(at)
print(at_pos)
print(at_ind)
# del initial[len(initial)-7]  # delete first atom ie create vacancy
initial.center(vacuum=10.0, axis=2)
# Save it
# write('Molecule-%s-%s-start.xyz' % (str(11), str(1)), initial)
N = len(initial)  # number of atoms

# Freeze the "slab"
# Make a mask of zeros and ones that select fixed atoms - the two
Exemplo n.º 26
0
def initlatticepositions(params, nlayers):
    """
    Return nlayers of positions according to lattice type/plane and
    shift positions so that no atoms are on the edges of the box.
    """

    lxsurf = params['lxsurf']
    lysurf = params['lysurf']
    alat = params['alat']

    if params['surftype'] == 'fcc':

        if params['plane'] == '111':
            surf = ase.fcc111('O',
                              a=alat,
                              size=(lxsurf, lysurf, nlayers),
                              orthogonal=True)
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + (alat / 2.0**0.5) / 4.0
            positions[:, 1] = (positions[:, 1] + (1.0 / 2.0) * (3.0**0.5) *
                               (alat / 2.0**0.5) / 4.0)

        elif params['plane'] == '100':
            surf = ase.fcc100('O', a=alat, size=(lxsurf, lysurf, nlayers))
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + (alat / 2.0**0.5) / 4.0
            positions[:, 1] = positions[:, 1] + (alat / 2.0**0.5) / 4.0

        elif params['plane'] == '110':
            surf = ase.fcc110('O', a=alat, size=(lxsurf, lysurf, nlayers))
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + alat / 4.0
            positions[:, 1] = positions[:, 1] + (alat / 2.0**0.5) / 4.0

    elif params['surftype'] == 'bcc':

        if params['plane'] == '100':
            surf = ase.bcc100('O', a=alat, size=(lxsurf, lysurf, nlayers))
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + alat / 2.0
            positions[:, 1] = positions[:, 1] + alat / 2.0

    elif params['surftype'] == 'hcp':

        clat = params['clat']
        if params['plane'] == '0001':
            surf = ase.hcp0001('O',
                               a=alat,
                               c=clat,
                               size=(lxsurf, lysurf, nlayers),
                               orthogonal=True)
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + alat / 4.0
            positions[:,
                      1] = positions[:,
                                     1] + (1.0 / 2.0) * (3.0**0.5) * alat / 4.0

        elif params['plane'] == '1010':
            surf = ase.hcp10m10('O',
                                a=alat,
                                c=clat,
                                size=(lxsurf, lysurf, nlayers))
            positions = surf.positions
            positions[:, 0] = positions[:, 0] + alat / 4.0
            positions[:, 1] = positions[:, 1] + clat / 4.0

    return positions
Exemplo n.º 27
0
from ase import Atoms, Atom
from gpaw import GPAW, Mixer
from ase.lattice.surface import fcc100
from gpaw.transport.jstm import dump_hs, dump_lead_hs

calc = GPAW(h=0.2,
            mixer=Mixer(0.03, 5, weight=140.0),
            width=0.1,
            mode='lcao',
            basis='szp(dzp)',
            txt='dumphs.txt',
            usesymm=False)

# surface calculation
a = 4.0
srf = fcc100('Al', size=(2, 2, 10), vacuum=8.0)
srf.translate([0, 0, -4])
srf.pbc = (1, 1, 0)
srf += Atom('H', (a / 2**.5, a / 2**.5, srf.positions[-1][2] + 1.55))

srf.set_calculator(calc)
srf.get_potential_energy()
calc.write('srf')

# Dump the overlap matrix and the Hamiltonian matrix to the local directory.
# Here the keyword 'cvl' refers  to the number of basis functions in the
# in the convergence layer, i.e. for the present system four atomic layers are used.
dump_hs(calc, 'srf', region='surface', cvl=4 * 4 * 9)

# tip calculation
a = 0.75  # lattice constant
Exemplo n.º 28
0
from ase.lattice.surface import fcc100, add_adsorbate
from ase.constraints import FixAtoms
from ase.calculators.emt import EMT
from ase.dimer import DimerControl, MinModeAtoms, MinModeTranslate

# Set up a small "slab" with an adatoms
atoms = fcc100('Pt', size = (2, 2, 1), vacuum = 10.0)
add_adsorbate(atoms, 'Pt', 1.611, 'hollow')

# Freeze the "slab"
mask = [atom.tag > 0 for atom in atoms]
atoms.set_constraint(FixAtoms(mask = mask))

# Calculate using EMT
atoms.set_calculator(EMT())
relaxed_energy = atoms.get_potential_energy()

# Set up the dimer
d_control = DimerControl(initial_eigenmode_method = 'displacement', \
                         displacement_method = 'vector', logfile = None, \
                         mask = [0, 0, 0, 0, 1])
d_atoms = MinModeAtoms(atoms, d_control)

# Dispalce the atoms
displacement_vector = [[0.0]*3]*5
displacement_vector[-1][1] = -0.1
d_atoms.displace(displacement_vector = displacement_vector)

# Converge to a saddle point
dim_rlx = MinModeTranslate(d_atoms, trajectory = 'dimer_method.traj', \
                           logfile = None)
# *** An error occurred in MPI_Recv
# *** on communicator MPI COMMUNICATOR 36 DUP FROM 28
# *** MPI_ERR_TRUNCATE: message truncated
# *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)

# works with 'sl_default': (2, 2, 32)

from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW, ConvergenceError
from gpaw.mpi import world
from gpaw.utilities import compiled_with_sl

assert world.size == 4

slab = fcc100('Cu', size=(2, 2, 4))
add_adsorbate(slab, 'O', 1.1, 'hollow')
slab.center(vacuum=3.0, axis=2)

calc = GPAW(
    mode='lcao',
    kpts=(2, 2, 1),
    txt='-',
    maxiter=1,
)

if compiled_with_sl():
    calc.set(parallel={'domain': (1, 1, 4), 'sl_default': (2, 2, 64)})

slab.set_calculator(calc)
try:
    slab.get_potential_energy()
# {   -1,   -1}:  On entry to PDLASRT parameter number    9 had an illegal value

# works with 'sl_default': (2, 2, 32)

from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW, ConvergenceError
from gpaw.mpi import world
from gpaw.utilities import compiled_with_sl

assert world.size == 4

slab = fcc100('Cu', size=(2, 2, 2))
add_adsorbate(slab,'O', 1.1, 'hollow')
slab.center(vacuum=3.0, axis=2)

calc = GPAW(mode='lcao',
            kpts=(2, 2, 1),
            txt='-',
            maxiter=1,)

if compiled_with_sl():
    calc.set(parallel={'domain': (1, 1, 4), 'sl_default': (2, 2, 64)})

slab.set_calculator(calc)
try:
    slab.get_potential_energy()
except ConvergenceError:
    pass
Exemplo n.º 31
0
from jlgh import *
import numpy as np
import ase.lattice.surface as surf
from ase.constraints import FixAtoms
from ase.utils.geometry import get_layers

Pd_latconst = 3.937211
slab = surf.fcc100("Pd", a=Pd_latconst, size=[1, 1, 4], vacuum=10)
slab.set_constraint(FixAtoms(indices=[il[0] for il in enumerate(get_layers(slab, (0, 0, 1))[0]) if il[1] < 2]))

h0 = max([at.position[2] for at in slab]) / slab.cell[2][2]

sites = [Site(name="hollow", pos=[0.5, 0.5, h0])]

E_2x2 = -56199.75241886

base_cell = BaseCell(slab, site_list=sites, energy=E_2x2 / 4.0)


Oatoms = ase.Atoms("O", positions=[[0.0, 0.0, 1.0]])
Oads = Adsorbate("O", Oatoms, center=[0.0, 0.0, 0.0], binding_energy=-439.4812229)

V_O_O_1NN_defs = [("O@hollow.(0,0,0)", "O@hollow.(1,0,0)"), ("O@hollow.(0,0,0)", "O@hollow.(0,1,0)")]
V_O_O_1NN = ClusterGroup("V_O_O_1NN", 0.3, V_O_O_1NN_defs)

V_O_O_2NN_defs = [("O@hollow.(0,0,0)", "O@hollow.(1,1,0)"), ("O@hollow.(0,0,0)", "O@hollow.(1,-1,0)")]
V_O_O_2NN = ClusterGroup("V_O_O_2NN", 0.07, V_O_O_2NN_defs)

enes_defs = [
    (-57077.82959288, ("O@hollow.(0,0,0)", "O@hollow.(1,0,0)")),
    (-57078.30630942, ("O@hollow.(0,0,0)", "O@hollow.(1,1,0)")),
Exemplo n.º 32
0
from winak.curvilinear.Coordinates import PeriodicCoordinates as PC
from winak.curvilinear.Coordinates import DelocalizedCoordinates as DC
from winak.globaloptimization.delocalizer import *
from winak.curvilinear.InternalCoordinates import icSystem, Periodic_icSystem
from winak.curvilinear.InternalCoordinates import ValenceCoordinateGenerator as VCG 
from winak.curvilinear.InternalCoordinates import PeriodicValenceCoordinateGenerator as PVCG 

from ase.lattice.cubic import FaceCenteredCubic as fcc
from ase.lattice.surface import fcc100, fcc111
import numpy as np

system = fcc100('Pd', (3,3,4), a=3.94, vacuum=10.)

natoms =len(system) 
np.set_printoptions(threshold=np.nan)
import time
start=time.time()
print start

d = Delocalizer(system, periodic=True, dense=False, weighted=False, \
                    add_cartesians = False)

print 'timing 1 ',time.time() - start

coords = PC(d.x_ref.flatten(),d.masses,unit=1.0,atoms=d.atoms,ic=d.ic, Li=d.get_U(),
        biArgs={'iclambda':1e-8, 'RIIS': True, 'maxiter': 900, 'eps': 1e-6, 'maxEps':1e-6})
        #biArgs={'RIIS': True, 'maxiter': 900, 'eps': 1e-6, 'maxEps':1e-6})

print len(d.ww)
print d.ww
Exemplo n.º 33
0
from __future__ import print_function
from ase.visualize import view
from ase.constraints import FixAtoms
from ase.optimize import QuasiNewton
from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import GPAW, PW

# Initial state:
# 2x2-Al(001) surface with 1 layer and an
# Au atom adsorbed in a hollow site:
slab = fcc100('Al', size=(2, 2, 2))
slab.center(axis=2, vacuum=3.0)
add_adsorbate(slab, 'Au', 1.6, 'hollow')

# Make sure the structure is correct:
view(slab)

# Fix the Al atoms:
mask = [atom.symbol == 'Al' for atom in slab]
print(mask)
fixlayer = FixAtoms(mask=mask)
slab.set_constraint(fixlayer)

# Use GPAW:
calc = GPAW(mode=PW(200), kpts=(2, 2, 1), xc='PBE', txt='hollow.txt')
slab.set_calculator(calc)

qn = QuasiNewton(slab, trajectory='hollow.traj')

# Find optimal height.  The stopping criterion is: the force on the
# Au atom should be less than 0.05 eV/Ang
Exemplo n.º 34
0
from ase import *
from ase.lattice.surface import fcc100, add_adsorbate
from gpaw import *
from gpaw import dscf
from gpaw.utilities import equal

atoms = fcc100('Pt', (1,1,2))
add_adsorbate(atoms, 'C', 2.00, 'ontop')
add_adsorbate(atoms, 'O', 3.15, 'ontop')
atoms.center(axis=2, vacuum=3)

calc_1 = GPAW(h=0.24,
              nbands=20,
              xc='PBE',
              kpts=[4,4,1],
              convergence={'energy': 0.001,
                           'density': 0.001,
                           'eigenstates': 1.0e-7,
                           'bands': -3})
atoms.set_calculator(calc_1)
E_gs = atoms.get_potential_energy()

# Dscf calculation based on the MolecularOrbital class
calc_1.set(nbands=25, spinpol=True)
weights = {2: [0.,0.,0.,1.], 3: [0.,0.,0.,-1.]}
lumo = dscf.MolecularOrbital(calc_1, weights=weights)
dscf.dscf_calculation(calc_1, [[1.0, lumo, 1]], atoms)
E_es1 = atoms.get_potential_energy()
equal(E_es1, E_gs + 4.55, 0.1)

# Dscf calculation based on the AEOrbital class. Two new calculators