Creating a dislocation in a slab

This is an example of how to set up a dislocation. It creates a screw dislocation in a slab with (111) surfaces. The dislocation is set up as two partial dislocations separated by a stacking fault. Common Neighbor Analysis (CNA) is used to identify the atoms in the dislocation core.

The system is quite large, almost a million atoms, and is intended for parallel simulations (see next example). If you run out of memory during the CNA, either reduce the system size or skip the CNA and the plotting.

MakeDislocation.py

#!/usr/bin/env python

from numpy import *
from asap3 import *
from asap3.analysis import CNA
from ase.lattice.cubic import FaceCenteredCubic
from asap3.detup.dislocation import Dislocation
from ase.visualize.primiplotter import *
from ase.io import write

print_version(1)

splitting = 5
size = (50, 88, 35)
#size = (30, 25, 7)

Gold = "Au"
slab = FaceCenteredCubic(directions=((1,1,-2), (-1,1,0), (1,1,1)),
                         size=size, symbol=Gold, pbc=False)
basis = slab.get_cell()
print basis
print "Number of atoms:", len(slab)

center = 0.5 * array([basis[0,0], basis[1,1], basis[2,2]]) + array([0.1, 0.1, 0.1])
offset = 0.5 * splitting * slab.miller_to_direction((-1,0,1))
print center

d1 = Dislocation(center - offset, slab.miller_to_direction((-1,-1,0)),
                 slab.miller_to_direction((-2,-1,1))/6.0)
d2 = Dislocation(center + offset, slab.miller_to_direction((1,1,0)),
                 slab.miller_to_direction((1,2,1))/6.0)
atoms = Atoms(slab)
(d1+d2).apply_to(atoms)
del slab

print "Now attempting CNA"
atoms.set_calculator(EMT(EMTRasmussenParameters()))
c = CNA(atoms)
atoms.set_tags(c)

for i in range(3):
    print i, sum(equal(c, i))

y = array(atoms.get_positions()[:,1])
z = array(atoms.get_positions()[:,2])
invis1 = equal(c, 0) + less(y, 5) + greater(y, basis[1,1] - 5)
invis2 = equal(c, 0) + less(z, 5) + greater(z, basis[2,2] - 5)

write("initial.traj", atoms)

p1 = PrimiPlotter(atoms)
p1.set_rotation([-88,0,0])
p1.set_invisible(invis1)

p2 = PrimiPlotter(atoms)
p2.set_invisible(invis2)

for i, p in enumerate((p1,p2)):
    p.set_colors({0:"red", 1:"yellow", 2:"blue"})
    p.set_output(X11Window())
    p.set_output(GifFile("init{0}_".format(i)))
    p.plot()

Asap: Creating a dislocation in a slab (last edited 2016-10-12 14:27:51 by JakobSchiøtz)