示例#1
0
def diamond_110_001(el, a0, n, crack_surface=[1,1,0], crack_front=[0,0,1],
            skin_x=1.0, skin_y=1.0, vac=5.0):
    nx, ny, nz = n
    third_dir = np.cross(crack_surface, crack_front)
    directions = [ third_dir, crack_surface, crack_front ]
    if np.linalg.det(directions) < 0:
        third_dir = -third_dir
    directions = [ third_dir, crack_surface, crack_front ]
    a = Diamond(el, latticeconstant = a0, size = [ nx,ny,nz ], 
                directions = directions)
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([a0/100,a0/100,a0/100])
    a.set_scaled_positions(a.get_scaled_positions())
    a.center()

    lx  = skin_x*sx/nx
    ly  = skin_y*sy/ny
    r   = a.get_positions()
    g   = np.where(
        np.logical_or(
            np.logical_or(
                np.logical_or(
                    r[:, 0] < lx, r[:, 0] > sx-lx),
                r[:, 1] < ly),
            r[:, 1] > sy-ly),
        np.zeros(len(a), dtype=int),
        np.ones(len(a), dtype=int))
    a.set_array('groups', g)

    a.set_cell([sx+2*vac, sy+2*vac, sz])
    a.translate([vac, vac, 0.0])
    a.set_pbc([False, False, True])

    return a
示例#2
0
def dia_100_2x1(sym, a0):
    sym = string2symbols(sym)
    if len(sym) == 1:
        a = Diamond(sym[0],
                    size             = [2*nx, nx, nz],
                    latticeconstant  = a0,
                    directions=[ [1,-1,0], [1,1,0], [0,0,1] ]
                    )
    else:
        a = B3(sym,
               size             = [2*nx, nx, nz],
               latticeconstant  = a0,
               directions=[ [1,-1,0], [1,1,0], [0,0,1] ]
               )
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([sx/(8*nx), sy/(8*nx), sz/(8*nz)])

    bulk = a.copy()
    
    for i in a:
        if i.z < sz/(4*nz) or i.z > sz-sz/(4*nz):
            if i.x < sx/2:
                i.x = i.x+0.5
            else:
                i.x = i.x-0.5

    return bulk, a
def dia_111(sym, a0):
    sym = string2symbols(sym)
    if len(sym) == 1:
        a = Diamond(sym[0],
                    size=[nx, nx, nz],
                    latticeconstant=a0,
                    directions=[[1, -1, 0], [1, 1, -2], [1, 1, 1]])
    else:
        a = B3(sym,
               size=[nx, nx, nz],
               latticeconstant=a0,
               directions=[[1, -1, 0], [1, 1, -2], [1, 1, 1]])
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([sx / (12 * nx), sy / (4 * nx), sz / (12 * nz)])
    return a
示例#4
0
def dia_111_pandey(sym, a0, nx=nx, ny=nx, nz=nz):
    """2x1 Pandey reconstructed (111) surface."""
    sym = string2symbols(sym)
    if len(sym) == 1:
        a = Diamond(sym[0],
                    size             = [nx, ny, nz],
                    latticeconstant  = a0,
                    directions=[ [1,-1,0], [1,1,-2], [1,1,1] ]
                    )
    else:
        a = B3(sym,
               size             = [nx, ny, nz],
               latticeconstant  = a0,
               directions=[ [1,-1,0], [1,1,-2], [1,1,1] ]
               )
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([sx/(12*nx), sy/(4*ny), sz/(6*nz)])
    a.set_scaled_positions(a.get_scaled_positions()%1.0)

    bulk = a.copy()

    bondlen = a0*sqrt(3)/4

    x, y, z = a.positions.T
    mask = np.abs(z-z.max()) < 0.1*a0
    top1, top2 = np.arange(len(a))[mask].reshape(-1, 2).T
    mask = np.logical_and(np.abs(z-z.max()) < bondlen, np.logical_not(mask))
    topA, topB = np.arange(len(a))[mask].reshape(-1, 2).T
    y[topA] += bondlen/3
    y[topB] -= bondlen/3
    y[top1] += bondlen
    x[top1] += a.cell[0,0]/(2*nx)
    x[top2] += a.cell[0,0]/(2*nx)

    mask = np.abs(z-z.min()) < 0.1*a0
    bot1, bot2 = np.arange(len(a))[mask].reshape(-1, 2).T
    mask = np.logical_and(np.abs(z-z.min()) < bondlen, np.logical_not(mask))
    botA, botB = np.arange(len(a))[mask].reshape(-1, 2).T
    y[botA] += bondlen/3
    y[botB] -= bondlen/3
    y[bot2] -= bondlen
    x[bot2] += a.cell[0,0]/(2*nx)
    x[bot1] += a.cell[0,0]/(2*nx)

    a.set_scaled_positions(a.get_scaled_positions()%1.0)

    return bulk, a
def dia_111(sym, a0):
    sym = string2symbols(sym)
    if len(sym) == 1:
        a = Diamond(sym[0],
                    size             = [nx, nx, nz],
                    latticeconstant  = a0,
                    directions=[ [1,-1,0], [1,1,-2], [1,1,1] ]
                    )
    else:
        a = B3(sym,
               size             = [nx, nx, nz],
               latticeconstant  = a0,
               directions=[ [1,-1,0], [1,1,-2], [1,1,1] ]
               )
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([sx/(12*nx), sy/(4*nx), sz/(12*nz)])
    return a
示例#6
0
def diamond_110_110(el, a0, n, crack_surface=[1,1,0],
                    crack_front=[1,-1,0],
                    skin_x=0.5, skin_y=1.0,
                    central_x=-1.0, central_y=-1.0,
                    vac=5.0):
    nx, ny, nz = n
    third_dir = np.cross(crack_surface, crack_front)
    a = Diamond(el,
            latticeconstant = a0,
            size = [nx, ny, nz], 
            directions = [third_dir, crack_surface, crack_front]
            )
    sx, sy, sz = a.get_cell().diagonal()
    a.translate([sx/(8*nx), sy/(4*ny), sz/(4*nz)])
    a.set_scaled_positions(a.get_scaled_positions())

    skin_x = skin_x*sx/nx
    skin_y = skin_y*sy/ny
    r = a.get_positions()
    g = np.where(
        np.logical_or(
            np.logical_or(
                np.logical_or(
                    r[:, 0] < skin_x, r[:, 0] > sx-skin_x),
                r[:, 1] < skin_y),
            r[:, 1] > sy-skin_y),
        np.zeros(len(a), dtype=int),
        np.ones(len(a), dtype=int))

    g = np.where(
        np.logical_or(
            np.logical_or(
                np.logical_or(
                    r[:, 0] < sx/2-central_x, r[:, 0] > sx/2+central_x),
                r[:, 1] < sy/2-central_y),
            r[:, 1] > sy/2+central_y),
        g,
        2*np.ones(len(a), dtype=int))
    a.set_array('groups', g)

    a.set_cell([sx+2*vac, sy+2*vac, sz])
    a.translate([vac, vac, 0.0])
    a.set_pbc([False, False, True])

    return a
示例#7
0
    def test_pbc(self):
        a = Diamond('Si', latticeconstant=5.432, size=[2,2,2])
        sx, sy, sz = a.get_cell().diagonal()
        a.set_calculator(Tersoff())
        e1 = a.get_potential_energy()

        a.set_pbc([True,True,False])
        e2 = a.get_potential_energy()

        a.set_pbc(True)
        a.set_cell([sx,sy,2*sz])
        e3 = a.get_potential_energy()

        self.assertEqual(e2, e3)

        # This should give the unrelaxed surface energy
        esurf = (e2-e1)/(2*sx*sy) * Jm2
        self.assertTrue(abs(esurf-2.309) < 0.001)
示例#8
0
    def test_pbc(self):
        a = Diamond('Si', latticeconstant=5.432, size=[2,2,2])
        sx, sy, sz = a.get_cell().diagonal()
        a.set_calculator(Tersoff())
        e1 = a.get_potential_energy()

        a.set_pbc([True,True,False])
        e2 = a.get_potential_energy()

        a.set_pbc(True)
        a.set_cell([sx,sy,2*sz])
        e3 = a.get_potential_energy()

        self.assertEqual(e2, e3)

        # This should give the unrelaxed surface energy
        esurf = (e2-e1)/(2*sx*sy) * Jm2
        self.assertTrue(abs(esurf-2.309) < 0.001)
示例#9
0
# set of utility routines specific this this model/testing framework
from utilities import relax_atoms, relax_atoms_cell

# the current model
import model

a0 = 5.44 # initial guess at lattice constant, cell will be relaxed below
fmax = 0.01 # maximum force following relaxtion [eV/A]

# set up the a
bulk = Diamond(symbol='Si', latticeconstant=a0, directions=[[1,-1,0],[0,0,1],[1,1,0]])

# specify that we will use model.calculator to compute forces, energies and stresses
bulk.set_calculator(model.calculator)
# flip coord system for ASE (precon minim?)
c = bulk.get_cell()
t_v = c[0,:].copy()
c[0,:] = c[1,:]
c[1,:] = t_v
bulk.set_cell(c)

# use one of the routines from utilities module to relax the initial
# unit cell and atomic positions
bulk = relax_atoms_cell(bulk, tol=fmax, traj_file=None)

# set up supercell
bulk *= (1, 1, 5)

ase.io.write(sys.stdout, bulk, format='extxyz')

def surface_energy(bulk, z_offset, opening):
示例#10
0
fmax = 0.01 # maximum force following relaxtion [eV/A]

if not hasattr(model, 'bulk_reference'):
    print("Did not find bulk_reference, recalculating bulk")
    # set up the a
    bulk = Diamond(symbol='Si', latticeconstant=a0)

    # specify that we will use model.calculator to compute forces, energies and stresses
    bulk.set_calculator(model.calculator)

    # use one of the routines from utilities module to relax the initial
    # unit cell and atomic positions
    bulk = relax_atoms_cell(bulk, tol=fmax, traj_file=None)
else:
    bulk = model.bulk_reference.copy()
    print("Found bulk_reference, lattice constant", bulk.get_cell()[0,0] )
    bulk.set_calculator(model.bulk_reference.calc)

a0 = bulk.cell[0,0] # get lattice constant from relaxed bulk
e0 = bulk.get_potential_energy()/8.0
print "got a0 ", a0
print "got e0 ", e0


def defect_energy(a0, e0, filename):

    
    tmp = ase.io.read(os.path.dirname(__file__)+"/"+filename, index=':', format='extxyz')
    defect = tmp[0]
    
    # adjust lattice constant