def decorate_interface(): ats = Atoms('interface.xyz') dataset = spglib.get_symmetry_dataset(ats, symprec=1e-5) with open('unique_lattice_sites.json', 'w') as f: json.dump([ list(ats[site_num].position) for site_num in np.unique(dataset['equivalent_atoms']) ], f) unique_atoms = [] for at in ats: unique_atoms.append(at.position) voronoi = Voronoi(limits=tuple(np.diag(ats.cell)), periodic=(True, True, False)) cntr = voronoi.compute_voronoi(unique_atoms) ints_list = [] for site_num in np.unique(dataset['equivalent_atoms']): for vert in voronoi.get_vertices(site_num, cntr): ints_list.append(vert.tolist()) for unique in ints_list: ats.add_atoms(unique, 1) for i in range(len(ats)): ats.id[i] = i #remove voronoi duplicates print 'Fe_H atoms', len(ats) ats.wrap() del_ats = aseAtoms() for at in ats: del_ats.append(at) geometry.get_duplicate_atoms(del_ats, cutoff=0.2, delete=True) ats = del_ats.copy() print 'Fe_H atoms remove duplicates', len(ats) #select unique hydrogens #for i in range(len(ats)): # ats.id[i] = i ints_list = [at.position for at in ats if at.number == 1] with open('unique_h_sites.json', 'w') as f: json.dump([list(u) for u in ints_list], f) ats.write('hydrogenated_grain.xyz')
args = parser.parse_args() DOUBLE_CELL = args.double_cell ats = Atoms('crack.xyz') if DOUBLE_CELL: ats = ats*(1,1,2) ats.info['adsorbate_info']=None with open('crack_info.pckl','r') as f: 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)
from quippy import Atoms from imeall.calc_inter_ener import get_interface_bounds with open('unique_h_sites.json','r') as f: h_sites = json.load(f) print 'There are ', len(h_sites), 'H interstitials' ats = Atoms('output.xyz') gb_min, gb_max, z_width, at_min = get_interface_bounds(ats) h_ats = ats.copy() for h_site in h_sites: h_site_tmp = list(h_site) #remove vacuum restore min position h_site_tmp[2] += gb_min - 1.0 + at_min h_ats.add_atoms(h_site_tmp, 1) h_int_ats = Atoms('interface.xyz') for h_site in h_sites: h_site_tmp = list(h_site) h_int_ats.add_atoms(h_site_tmp, 1) for i in range(0,len(h_ats)): h_ats.id[i] = i for i in range(0, len(h_int_ats)): h_int_ats.id[i] = i h_ats.write('decorated.xyz') h_int_ats.write('int_decorated.xyz')
r'\[\s+([\-0-9\.]+)\s+([\-0-9\.]+)\s+([\-0-9\.]+)\s?\s?\]\s+([\-0-9\.]+)\s+([\-0-9\.]+)', re.S) with open(args.input_file) as f: lines = h_line_re.findall(f.read()) interstitials = [] for line in lines: site = map(float, [line[0], line[1], line[2]]) energy = float(line[4]) interstitials.append(Particle(site, 'H', energy)) interstitials.sort(key=lambda x: x.energy) for int_ in interstitials: print int_.site, int_.energy ats = Atoms('output.xyz') num_fe = len(ats) for int_ in interstitials: ats.add_atoms(np.array(int_.site), 1) for i in range(len(ats)): ats.id[i] = i ats.add_property('locen', 0.0) for i, at in enumerate(interstitials): ats.properties['locen'][i + num_fe] = at.energy ats.write('h_energetics.xyz')