def shift_x(normalised_length, length_1, length_2, angle, layer='1st_layer', Use_optimised_structure=False): name = 'Au38_Octa_' + str(length_1) + '_' + str(length_2) + '_' + str( angle) angle = float(radians(float(angle))) if Use_optimised_structure: cluster = copy.deepcopy(cluster_main_Opt) cluster.set_calculator(None) name += '_Opt' else: cluster = copy.deepcopy(cluster_main) x_neighbour_length = cluster[16].x - cluster[32].x z_neighbour_length = cluster[37].z - cluster[23].z #neighbour_length = (x_neighbour_length**2.0 + z_neighbour_length**2.0)**0.5 neighbour_length = normalised_length layer_1 = [24, 19, 21, 35] layer_2 = [23, 22, 3, 18, 17, 34, 36, 37, 20] for index in layer_1: cluster[index].x += length_1 * cos(angle) * neighbour_length cluster[index].z += length_1 * sin(angle) * neighbour_length #if layer == '2nd_layer': for index in layer_2: cluster[index].x += length_2 * cos(angle) * neighbour_length cluster[index].z += length_2 * sin(angle) * neighbour_length ASE_write(name + '.traj', cluster, 'traj') return name
def optimise(cluster_name): cluster = ASE_read(cluster_name + '.traj') cluster_optimised = RunMinimisation(cluster).get_cluster() cluster_optimised.set_calculator(None) cluster_name_opt = cluster_name + '_Opt' ASE_write(cluster_name_opt + '.traj', cluster_optimised) return cluster_name_opt, cluster_optimised
def rotate_top(angle,atom_to_remove,name,only_rotate_second_later=False,Optimise=False): angle = radians(float(angle)) angle = float(angle) if not Optimise: cluster = copy.deepcopy(cluster_main) else: cluster = copy.deepcopy(cluster_main_optimised) rotate_around_x = cluster[3].x; rotate_around_y = cluster[3].y; first_layer_to_rotate = [9,6,18,15,12] second_layer_to_rotate = [24,22,20,38,36,34,32,30,28,26] rotate_atoms = second_layer_to_rotate if not only_rotate_second_later: rotate_atoms += first_layer_to_rotate for atom in atom_to_remove: del cluster[atom] for index2 in range(len(rotate_atoms)): if atom < rotate_atoms[index2]: rotate_atoms[index2] -= 1 if Optimise: cluster = RunMinimisation(cluster).get_cluster() cluster.set_calculator(None) for index in rotate_atoms: old_x = cluster[index].x - rotate_around_x; old_y = cluster[index].y - rotate_around_y new_x = old_x*cos(angle) - old_y*sin(angle) + (rotate_around_x) new_y = old_x*sin(angle) + old_y*cos(angle) + (rotate_around_y) cluster[index].x = new_x; cluster[index].y = new_y #view(cluster) #import pdb; pdb.set_trace() if Optimise: name += '_Opt' ASE_write(name+'.traj',cluster,'traj')
def makeMotif(motif_inputs, latticeconstant, remove_atoms=[]): if isinstance(motif_inputs, int) or len(motif_inputs) == 1: if isinstance(motif_inputs, int): motif_inputs = [motif_inputs] cluster = Icosahedron(symbol, motif_inputs[0], latticeconstant=latticeconstant) name = 'Ico' elif len(motif_inputs) == 2: cluster = Octahedron(symbol, motif_inputs[0], motif_inputs[1], latticeconstant=latticeconstant) name = 'Octa' elif len(motif_inputs) == 3: cluster = Decahedron(symbol, motif_inputs[0], motif_inputs[1], motif_inputs[2], latticeconstant=latticeconstant) name = 'Deca' else: print "Error" import pdb pdb.set_trace() exit() remove_atoms.sort(reverse=True) if any(remove_atoms.count(x) > 1 for x in remove_atoms): print 'You have got two of the same atom entered in to this list, check this.' print 'remove_atoms = ' + str(remove_atoms) import pdb pdb.set_trace() exit() for remove_atom_index in remove_atoms: del cluster[remove_atom_index] name += '_' + symbol + str(len(cluster)) motif_details = '' for motif_input in motif_inputs: motif_details += str(motif_input) + '_' motif_details = motif_details[:-1] name += '_' + motif_details if not remove_atoms == []: name += '_atoms_removed_' + str(len(remove_atoms)) + '_cluster_' counter = 1 while True: if not name + str(counter) + '.traj' in os.listdir('.'): name += str(counter) break counter += 1 ASE_write(name + '.traj', cluster, 'traj') return name
output_cluster[index].position = new_atom_position return output_cluster rCut_low = 2.8840 rCut_high = round(rCut_low * (2.0)**0.5, 4) rCut_resolution = 0.0005 mode = 'total' symbol = 'Au' latticeconstant = rCut_high cluster_main = Octahedron(symbol, 4, 1, latticeconstant=latticeconstant) cluster_main = move_cluster_to_COM(cluster_main) original_cluster_name = 'Au39_original' ASE_write(original_cluster_name + '.traj', cluster_main) original_cluster_name_opt = optimise(original_cluster_name) def run_CNA_program(Cluster_1_name, Cluster_2_name): Cluster_1 = ASE_read(Cluster_1_name + '.traj') print 'Made ' + str(Cluster_1_name) Cluster_2 = ASE_read(Cluster_2_name + '.traj') print 'Made ' + str(Cluster_2_name) Structural_Recognition_Program(Cluster_1, Cluster_2, rCut_low, rCut_high, rCut_resolution, mode, name_1=Cluster_1_name,
index].x + Shearing_Matrix[2][1] * output_cluster[ index].y + Shearing_Matrix[2][2] * output_cluster[index].z return output_cluster rCut_low = 2.8840 rCut_high = round(rCut_low * (2.0)**0.5, 4) rCut_resolution = 0.0005 mode = 'total' symbol = 'Au' latticeconstant = rCut_high cluster_main = Decahedron(symbol, 3, 2, 0, latticeconstant=latticeconstant) cluster_main = move_cluster_to_COM(cluster_main) original_cluster_name = 'Au39_original' ASE_write(original_cluster_name + '.traj', cluster_main) original_cluster_name_Opt, cluster_main_Opt = optimise(original_cluster_name) def run_CNA_program(Cluster_1_name, Cluster_2_name): Cluster_1 = ASE_read(Cluster_1_name + '.traj') print 'Made ' + str(Cluster_1_name) Cluster_2 = ASE_read(Cluster_2_name + '.traj') print 'Made ' + str(Cluster_2_name) CNA_run = Structural_Recognition_Program(Cluster_1, Cluster_2, rCut_low, rCut_high, rCut_resolution, mode, name_1=Cluster_1_name,
def optimise(cluster, cluster_name): cluster_optimised = RunMinimisation(cluster).get_cluster() cluster_name_opt = cluster_name + '_Opt' ASE_write(cluster_name_opt + '.traj', cluster_optimised) return cluster_name_opt
####################################################################### # Ico Structures Vs lots of other Ico structures ####################################################################### ####################################################################### ####################################################################### Main_CNA_signatures_to_monitor = [[5, 5, 5], [4, 2, 1], [4, 2, 2]] CNA_signatures_for_defect_icos = [[5, 4, 4], [4, 3, 3]] CNA_signatures_for_111_surfaces = [[3, 2, 2], [3, 1, 1], [3, 0, 0]] CNA_signatures_for_100_surfaces = [[2, 1, 1]] CNA_signatures_for_110_surfaces = [[2, 0, 0]] CNA_signatures_to_monitor = Main_CNA_signatures_to_monitor + CNA_signatures_for_defect_icos + CNA_signatures_for_111_surfaces + CNA_signatures_for_100_surfaces + CNA_signatures_for_110_surfaces # 55 ico vs ico cluster - Rosette structure motif_inputs = 3 cluster_main_ico, original_cluster_name_ico = makeMotif( motif_inputs, latticeconstant) ASE_write(original_cluster_name_ico + '.traj', cluster_main_ico) Cluster_CNA_profile(original_cluster_name_ico, CNA_signatures_to_monitor) vertex_atom = 18 atoms_around_vertex = [42, 36, 35, 46, 17] rosette_cluster = makeRossetteReconstruction(cluster_main_ico, vertex_atom, atoms_around_vertex) rosette_cluster_name_ico = original_cluster_name_ico + '_rosette' ASE_write(rosette_cluster_name_ico + '.traj', rosette_cluster) run_CNA_program(original_cluster_name_ico, rosette_cluster_name_ico) Cluster_CNA_profile(rosette_cluster_name_ico, CNA_signatures_to_monitor) ### Optimized original_cluster_name_ico_opt = optimise(cluster_main_ico, original_cluster_name_ico) Cluster_CNA_profile(original_cluster_name_ico_opt, CNA_signatures_to_monitor) rosette_cluster_name_ico_opt = optimise(rosette_cluster, rosette_cluster_name_ico)
cluster_optimised = RunMinimisation(cluster).get_cluster() cluster_name_opt = cluster_name + '_Opt' ASE_write(cluster_name_opt+'.traj',cluster_optimised) return cluster_name_opt ####################################################################### ####################################################################### ####################################################################### # Ico Structures Vs lots of other structures ####################################################################### ####################################################################### ####################################################################### # 55 ico vs ico cluster - Rosette structure motif_inputs = 3 cluster_main_ico, original_cluster_name_ico = makeMotif(motif_inputs,latticeconstant) ASE_write(original_cluster_name_ico+'.traj',cluster_main_ico) vertex_atom = 18 atoms_around_vertex = [42,36,35,46,17] rosette_cluster = makeRossetteReconstruction(cluster_main_ico,vertex_atom,atoms_around_vertex) rosette_cluster_name_ico = original_cluster_name_ico + '_rosette' ASE_write(rosette_cluster_name_ico+'.traj',rosette_cluster) run_CNA_program(original_cluster_name_ico,rosette_cluster_name_ico) ### Optimized original_cluster_name_ico_opt = optimise(cluster_main_ico, original_cluster_name_ico) rosette_cluster_name_ico_opt = optimise(rosette_cluster, rosette_cluster_name_ico) run_CNA_program(original_cluster_name_ico_opt,rosette_cluster_name_ico_opt) ####################################################################### # 55 deca vs ico cluster - Rosette structure cluster_main_deca, original_cluster_name_deca = makeMotif([3,3,0],latticeconstant) ASE_write(original_cluster_name_deca+'.traj',cluster_main_deca) run_CNA_program(original_cluster_name_deca, rosette_cluster_name_ico)
delete() print '---------------------------' def move_cluster_to_COM(cluster): COM = cluster.get_center_of_mass() for atom in cluster: atom.position -= COM return cluster symbol = 'Au' cluster_main = Octahedron(symbol, 4, 1) cluster_main = move_cluster_to_COM(cluster_main) original_cluster_name = 'Au38_original' ASE_write(original_cluster_name + '.traj', cluster_main) rCut_low = 2.8840 rCut_high = round(rCut_low * (2.0)**0.5, 4) rCut_resolution = 0.0005 mode = 'total' def run_CNA_program(Cluster_1_name, Cluster_2_name): Cluster_1 = ASE_read(Cluster_1_name + '.traj') print 'Made ' + str(Cluster_1_name) Cluster_2 = ASE_read(Cluster_2_name + '.traj') print 'Made ' + str(Cluster_2_name) Structural_Recognition_Program(Cluster_1, Cluster_2, rCut_low,