예제 #1
0
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
예제 #2
0
from ase_ext.io import PickleTrajectory
from ase_ext.neb import NEB
from ase_ext.calculators.lj import LennardJones
from ase_ext.optimize import QuasiNewton

print([a.get_potential_energy() for a in PickleTrajectory('H.traj')])
images = [PickleTrajectory('H.traj')[-1]]
for i in range(4):
    images.append(images[0].copy())
images[-1].positions[6, 1] = 2 - images[0].positions[6, 1]
neb = NEB(images)
neb.interpolate()

for image in images:
    image.set_calculator(LennardJones())

for a in neb.images:
    print(a.positions[-1], a.get_potential_energy())

dyn = QuasiNewton(neb, trajectory='mep.traj')
print(dyn.run(fmax=0.01, steps=25))
for a in neb.images:
    print(a.positions[-1], a.get_potential_energy())
예제 #3
0
print(Z[0] - Z[1])
print(Z[1] - Z[2])
print(Z[2] - Z[3])

b = 1.2
h = 2.0
slab += Atom('C', (d, 2 * y / 3, h))
slab += Atom('O', (3 * d / 2, y / 3, h))
traj = PickleTrajectory('initial.traj', 'w', slab)
dyn = QuasiNewton(slab)
dyn.attach(traj.write)
dyn.run(fmax=0.05)
#view(slab)
# Make band:
images = [slab.copy() for i in range(6)]
neb = NEB(images, climb=True)

# Set constraints and calculator:
for image in images:
    image.set_calculator(EMT())
    image.set_constraint(constraint)

# Displace last image:
images[-1].positions[-1] = (2 * d, 2 * y / 3, h)
traj = PickleTrajectory('final.traj', 'w', images[-1])
dyn = QuasiNewton(images[-1])
dyn.attach(traj.write)
dyn.run(fmax=0.05)

# Interpolate positions between initial and final states:
neb.interpolate()
예제 #4
0
dyn.run(fmax=0.05)
#view(slab)

# Make band:
images = [slab]
for i in range(6):
    image = slab.copy()
    image.set_constraint(constraint)
    image.set_calculator(EMT())
    images.append(image)
image[-2].position = image[-1].position
image[-1].x = d
image[-1].y = d / sqrt(3)
dyn = QuasiNewton(images[-1])
dyn.run(fmax=0.05)
neb = NEB(images, climb=not True)

# Set constraints and calculator:

# Displace last image:

# Relax height of Ag atom for initial and final states:

# Interpolate positions between initial and final states:
neb.interpolate()

for image in images:
    print(image.positions[-1], image.get_potential_energy())

#dyn = MDMin(neb, dt=0.4)
#dyn = FIRE(neb, dt=0.01)