Example #1
0
def gen_interface():
    """Selects an interfacial region of a bicrystal
    based on common neighbour analysis. The width of the interfacial region
    is equal to 2*(gb_max-gb_min) where gb_max is the z-coordinate of the highest
    non-bcc atom, and gb_min is the lowest non-bcc atom.

    The method creates a file `interface.xyz` in the working directory,
    with the interface centered in a unit cell with 1 angstrom vacuum
    on each side.

    Returns:
      :class:`ase.Atoms`: Atoms object of the interfacial slab in same
      coordinates as original bicrystal.
    """
    #output.xyz must have structure_type property attached.
    ats = Atoms('output.xyz')
    cell_midpoint = ats.get_cell()[2,2]/2.0
    #select non-BCC sites are 0 otherwise 3.
    struct_type = np.array(ats.properties['structure_type'])
    struct_mask = [not struct for struct in struct_type]
    interface = ats.select(struct_mask)
    #select upper interface to decorate.
    interface = interface.select([at.position[2] > cell_midpoint for at in interface])
    z_vals = [at.position[2] for at in interface]
    z_min = min(z_vals)
    z_max = max(z_vals)
    #take slice of interface max uncoordinated with min uncoordinated.
    z_width = (z_max-z_min)/2.0
    z_center = z_width + z_min
    gb_max = z_max + 1.0*z_width
    gb_min = z_min - 1.0*z_width
    zint = ats.select([(gb_min <= at.position[2] <= gb_max) for at in ats])
    #make a copy to return
    int_ats = zint.copy()
    zint.center(vacuum=1.0, axis=2)
    zint.write('interface.xyz')
    #Write POSCAR to use interstitial site generator:
    ats = Atoms('interface.xyz')
    #vasp_args=dict(xc='PBE', amix=0.01, amin=0.001, bmix=0.001, amix_mag=0.01, bmix_mag=0.001,
    #             kpts=[3, 3, 3], kpar=9, lreal='auto', ibrion=-1, nsw=0, nelmdl=-15, ispin=2,
    #             nelm=100, algo='VeryFast', npar=24, lplane=False, lwave=False, lcharg=False, istart=0,
    #             voskown=0, ismear=1, sigma=0.1, isym=2)
    #vasp = Vasp(**vasp_args)
    #vasp.initialize(ats)
    #write_vasp('POSCAR', vasp.atoms_sorted, symbol_count=vasp.symbol_count, vasp5=True)
    return int_ats
Example #2
0
  crack_dict= pickle.load(f)
print 'G: {}, H_d: {}, sim_T {}'.format(crack_dict['initial_G']*(units.m**2/units.J),
                                        crack_dict['H_d'], crack_dict['sim_T']/units.kB)
h_list  = hydrify.hydrogenate_gb(ats, mode='CrackTip', d_H=crack_dict['H_d'][0], tetrahedral=True, crackpos_fix=ats.params['CrackPos'])
for h in h_list:
  ats.add_atoms(h,1)

#ats.wrap()
ats.write('crackH.xyz')
ats = None
ats = Atoms('crackH.xyz')
ats.set_cutoff(2.4)
ats.calc_connect()
ats.calc_dists()
filter_mask = (ats.get_atomic_numbers()==1)
h_atoms     = ats.select(filter_mask, orig_index=True)
rem=[]
u = np.zeros(3)
for i in h_atoms.orig_index:
  print 'hindex', i
  print 'nneighbs', ats.n_neighbours(i)
  for n in range(ats.n_neighbours(i)):
    j = ats.neighbour(i, n+1, distance=2.4, diff=u)
    print 'neighb index', j
    if ats.distance_min_image(i,j) < 1.1 and j!=i:
      rem.append(i)
rem = list(set(rem))
if len(rem) > 0:
  print 'Removing {} H atoms'.format(len(rem))
  ats.remove_atoms(rem)
else: