if hasattr(params, 'surface'): surface = params.surface else: # Make a surface unit cell by repllcating and adding some vaccum along y surface = unit_slab * [1, params.surf_ny, 1] surface.center(params.vacuum, axis=1) # ********** Surface energy ************ # Calculate surface energy per unit area surface.set_calculator(params.calc) if hasattr(params, 'relax_bulk') and params.relax_bulk: print('Minimising surface unit cell...') surface = relax_structure(surface) E_surf = surface.get_potential_energy() E_per_atom_bulk = a.get_potential_energy() / len(a) # volume is not get_volume() because it's not a solid 3D system! volume = np.prod([np.ptp(vect) for vect in a.get_positions().T]) area = volume / np.ptp(a.get_positions()[:,1]) gamma = ((E_surf - E_per_atom_bulk * len(surface)) / (2.0 * area)) print('Surface energy of %s surface %.4f J/m^2\n' % (params.cleavage_plane, gamma / (units.J / units.m ** 2))) # ***** Setup crack slab supercell ***** crack_slab = unit_slab
buffer_hops = 8 deltay_tip = 1.05 ##### OTHER STUFF, LEAVE UNCHANGED UNLESS NECESSARY ##### cluster_vacuum = 12.0 crack_slab = ase.io.read('crack.xyz', format='extxyz') ring_size = int(raw_input('Size of ring at crack tip:')) pre_optim = True try: pre_optim = (sys.argv[1] in [' ', 't', 'T', 'True', 'true', 'y', 'yes']) except: print("") # it's alright if pre_optim: crack_slab = relax_structure(crack_slab) folder = 'ring%1d_strain%.03f' % (ring_size, strain) try: os.mkdir(folder) except: print("Folder already existing. Overwrite?") sig = raw_input() if sig not in ['y', 'yes']: exit core_ring = np.loadtxt('tip_4ring.csv', dtype='int') try: xy_ring = np.loadtxt('xy_ring.csv', dtype='int') temp = set(xy_ring) for idx in xy_ring: