def Minimisation_Function(cluster): cluster.pbc = False # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] #Au_parameters = {'Au': [10.229, 4.0360, 0.2061, 1.7900, 2.884]} r0 = 4.07/(2.0 ** 0.5) Au_parameters = {'Au': [10.53, 4.30, 0.2197, 1.855, r0]} # Baletto Gupta_parameters = Au_parameters cutoff = 1000 calculator = Gupta(Gupta_parameters, cutoff=cutoff, debug=False) cluster.set_calculator(calculator) original_cluster = cluster.copy() dyn = FIRE(cluster,logfile=None) converged = False try: dyn.run(fmax=0.01,steps=5000) converged = dyn.converged() if not converged: cluster_name = 'issue_cluster.xyz' errorMessage = 'The optimisation of cluster ' + str(original_cluster) + ' did not optimise completely.\n' errorMessage += 'The cluster of issue before optimisation has been saved as: '+str(cluster_name) write(cluster_name,original_cluster) raise Exception(errorMessage) except Exception as exception_message: cluster_name = 'issue_cluster.xyz' errorMessage = 'The optimisation of cluster ' + str(original_cluster) + ' did not optimise completely.\n' errorMessage += 'The cluster of issue before optimisation has been saved as: '+str(cluster_name)+'\n' errorMessage += exception_message write(cluster_name,original_cluster) raise Exception(errorMessage) return cluster
def relax(atoms, cellbounds=None): # Performs a variable-cell relaxation of the structure calc = EMT() atoms.set_calculator(calc) converged = False niter = 0 while not converged and niter < 10: if cellbounds is not None: cell = atoms.get_cell() if not cellbounds.is_within_bounds(cell): niggli_reduce(atoms) cell = atoms.get_cell() if not cellbounds.is_within_bounds(cell): # Niggli reduction did not bring the unit cell # within the specified bounds; this candidate should # be discarded so we set an absurdly high energy finalize(atoms, 1e9) return ecf = ExpCellFilter(atoms) dyn = FIRE(ecf, maxmove=0.2, logfile=None, trajectory=None) dyn.run(fmax=1e-3, steps=100) converged = dyn.converged() niter += 1 dyn = FIRE(atoms, maxmove=0.2, logfile=None, trajectory=None) dyn.run(fmax=1e-2, steps=100) e = atoms.get_potential_energy() f = atoms.get_forces() s = atoms.get_stress() finalize(atoms, energy=e, forces=f, stress=s)
def Minimisation_Function(cluster, collection, cluster_name): cluster.pbc = False #################################################################################################################### # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] Gupta_parameters = {'Cu': [10.960, 2.2780, 0.0855, 1.224, 2.556]} cluster.set_calculator(Gupta(Gupta_parameters, cutoff=1000, debug=False)) dyn = FIRE(cluster, logfile=None) startTime = time.time() converged = False try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: errorMessage = 'The optimisation of cluster ' + str( cluster_name) + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except: print('Local Optimiser Failed for some reason.') endTime = time.time() #################################################################################################################### # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info["INFO.txt"] += ("Cluster converged?: " + str(dyn.converged()) + '\n') #################################################################################################################### return cluster, converged, Info
def adjust_z_axis(self, cluster): if self.surface == None: return ''' surface_constraints = [] for atom in self.surface: surface_constraints.append(MyConstraint(atom.index,(0,0,1))) ''' surface_constraints = [] #surface_constraints.append(ExternalForce(0, 0, 10)) all_bonds = [] all_angles = [] all_dihedrals = [] for index_1 in range(len(self.surface)): for index_2 in range(index_1+1,len(self.surface)): bonds_distance = get_distance(self.surface[index_1],self.surface[index_2]) bond = [bonds_distance, [index_1,index_2]] all_bonds.append(bond) """ for index_3 in range(index_2+1,len(self.surface)): angle_indices = [[index_1,index_2,index_3],[index_3,index_1,index_2],[index_2,index_3,index_1]] for angle_indice in angle_indices: angle = [self.surface.get_angle(*angle_indice) * pi / 180, angle_indice] all_angles.append(angle) ''' for index_4 in range(index_3+1,len(self.surface)): dihedral_indices = [[index_1,index_2,index_3,index_4],[index_1,index_2,index_3,index_4],[index_1,index_2,index_3,index_4]] for dihedral_indice in dihedral_indices: dihedral = [self.surface.get_dihedral(*dihedral_indice) * pi / 180, dihedral_indice] all_dihedrals.append(dihedral) ''' """ surface_constraints.append(FixInternals(bonds=all_bonds, angles=all_angles, dihedrals=all_dihedrals)) #self.surface.set_constraint(surface_constraints) c = FixAtoms(indices=range(len(self.surface),len(self.surface)+len(cluster))) cluster_constraints = [c] #cluster.set_constraint(cluster_constraints) for atom in self.surface: atom.z -= 40.0 system = self.surface + cluster system.set_calculator(EMT()) system.set_constraint(surface_constraints+cluster_constraints) dyn = FIRE(system) converged = False import pdb; pdb.set_trace() try: dyn.run(fmax=0.01,steps=5000) converged = dyn.converged() if not converged: import os name = os.path.basename(os.getcwd()) errorMessage = 'The optimisation of cluster ' + name + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except: print('Local Optimiser Failed for some reason.') import pdb; pdb.set_trace()
def Minimisation_Function(cluster): cluster.pbc = False # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] Pt_parameters = {'Pt': [10.71, 3.845, 0.27443, 2.6209, 2.77]} Gupta_parameters = Pt_parameters cutoff = 1000 calculator = Gupta(Gupta_parameters, cutoff=cutoff, debug=False) cluster.set_calculator(calculator) original_cluster = cluster.copy() dyn = FIRE(cluster, logfile=None) #startTime = time.time(); converged = False try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: cluster_name = 'issue_cluster.xyz' errorMessage = 'The optimisation of cluster ' + str( original_cluster) + ' did not optimise completely.\n' errorMessage += 'The cluster of issue before optimisation has been saved as: ' + str( cluster_name) write(cluster_name, original_cluster) raise Exception(errorMessage) except Exception as exception_message: cluster_name = 'issue_cluster.xyz' errorMessage = 'The optimisation of cluster ' + str( original_cluster) + ' did not optimise completely.\n' errorMessage += 'The cluster of issue before optimisation has been saved as: ' + str( cluster_name) + '\n' errorMessage += exception_message write(cluster_name, original_cluster) raise Exception(errorMessage) #endTime = time.time() return cluster
def Minimisation_Function(cluster,collection,cluster_name): #################################################################################################################### cluster.pbc = False #################################################################################################################### # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] #Gupta_parameters = {'Au': [10.529999999999999, 4.2999999999999998, 0.21970000000000001, 1.855, 2.8779245994292486]} Gupta_parameters = {'Pd': [10.867, 3.742, 0.1746, 1.718, 2.7485], 'Au': [10.229, 4.036, 0.2061, 1.79, 2.884], ('Au','Pd'): [10.54, 3.89, 0.19, 1.75, 2.816]} cluster.set_calculator(Gupta(Gupta_parameters, cutoff=1000, debug=False)) dyn = FIRE(cluster,logfile=None) startTime = time.time(); converged = False try: dyn.run(fmax=0.01,steps=5000) converged = dyn.converged() if not converged: errorMessage = 'The optimisation of cluster ' + str(cluster_name) + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except Exception: print('Local Optimiser Failed for some reason.') endTime = time.time() #################################################################################################################### # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info["INFO.txt"] += ("Cluster converged?: " + str(dyn.converged()) + '\n') #################################################################################################################### return cluster, converged, Info
def Minimisation_Function(cluster, collection, cluster_dir): cluster.pbc = False rCut = 1000 #sigma = 1; epsilon = 1; lj_calc = LennardJones(sigma=sigma, epsilon=epsilon,rc=rCut) elements = [atomic_numbers[cluster[0].symbol]] sigma = [1] epsilon = [1] lj_calc = LennardJones(elements, epsilon, sigma, rCut=rCut, modified=True) cluster.set_calculator(lj_calc) dyn = FIRE(cluster, logfile=None) startTime = time.time() converged = False try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: errorMessage = 'The optimisation of cluster ' + str( cluster_dir) + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except Exception: print('Local Optimiser Failed for some reason.') endTime = time.time() # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info.write("Cluster converged?: " + str(dyn.converged()) + '\n') return cluster, converged, Info
def Minimisation_Function(cluster, calculator): cluster.pbc = False cluster.set_calculator(calculator) from ase.optimize import FIRE dyn = FIRE(cluster, logfile=None) try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: errorMessage = 'The optimisation of cluster ' + str( cluster_name) + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except Exception: print('Local Optimiser Failed for some reason.') return cluster
def optimse_Cu(cluster): Cu_parameters = {'Cu': [10.960, 2.2780, 0.0855, 1.2240, 2.556]} cluster.set_calculator(Gupta(Cu_parameters, cutoff=1000, debug=True)) dyn = FIRE(cluster) try: import time startTime = time.time() dyn.run(fmax=0.01, steps=5000) endTime = time.time() if not dyn.converged(): import os name = os.path.basename(os.getcwd()) errorMessage = 'The optimisation of cluster ' + name + ' did not optimise completely.' print >> sys.stderr, errorMessage print errorMessage except: print('Local Optimiser Failed for some reason.')
def Minimisation_Function(cluster,collection,cluster_dir): #################################################################################################################### # Read the BeforeOpt file and record the elements, the # number of each element in the cluster and their positions #cluster = ase_read("BeforeOpt",format='vasp') cluster.pbc = False #################################################################################################################### #Construct atoms using the ASE class "Atoms". #################################################################################################################### # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] rCut = 1000 #sigma = 1; epsilon = 1; lj_calc = LennardJones(sigma=sigma, epsilon=epsilon,rc=rCut) elements = [atomic_numbers[cluster[0].symbol]]; sigma = [1]; epsilon = [1]; lj_calc = LennardJones(elements, epsilon, sigma, rCut=rCut, modified=True) cluster.set_calculator(lj_calc) dyn = FIRE(cluster,logfile=None) startTime = time.time(); converged = False try: dyn.run(fmax=0.01,steps=5000) converged = dyn.converged() if not converged: import os name = os.path.basename(os.getcwd()) errorMessage = 'The optimisation of cluster ' + name + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except: print('Local Optimiser Failed for some reason.') endTime = time.time() #ase_write('AfterOpt.traj',cluster) #################################################################################################################### # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info.write("Cluster converged?: " + str(dyn.converged()) + '\n') #################################################################################################################### return cluster, converged, Info
def Minimisation_Function(cluster, collection, cluster_dir): #################################################################################################################### # Read the BeforeOpt file and record the elements, the # number of each element in the cluster and their positions #cluster = ase_read("BeforeOpt",format='vasp') cluster.pbc = False #################################################################################################################### #Construct atoms using the ASE class "Atoms". #################################################################################################################### # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] Gupta_parameters = {'Cu': [10.960, 2.2780, 0.0855, 1.224, 2.556]} cluster.set_calculator(Gupta(Gupta_parameters, cutoff=1000, debug=False)) dyn = FIRE(cluster, logfile=None) startTime = time.time() converged = False try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: import os name = os.path.basename(os.getcwd()) errorMessage = 'The optimisation of cluster ' + name + ' did not optimise completely.' #print sys.stderr >> errorMessage print(errorMessage) except: print('Local Optimiser Failed for some reason.') endTime = time.time() #ase_write('AfterOpt.traj',cluster) #################################################################################################################### # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info.write("Cluster converged?: " + str(dyn.converged()) + '\n') #################################################################################################################### return cluster, converged, Info
def Minimisation_Function(cluster, collection, cluster_name): ####################################################################################### cluster.pbc = False # make sure that the periodic boundry conditions are set off ####################################################################################### # Perform the local optimisation method on the cluster. # Parameter sequence: [p, q, a, xi, r0] # # RGL parameters below from: # Crossover among structural motifs in transition and noble-metal clusters # F. Baletto, R. Ferrando, A. Fortunelli, F. Montalenti and C. Mottet, J. Chem. Phys., 2002, 116, 3856–3863. # https://doi.org/10.1063/1.1448484 r0 = 4.07 / (2.0**0.5) Gupta_parameters = {'Au': [10.53, 4.30, 0.2197, 1.855, r0]} cluster.set_calculator(Gupta(Gupta_parameters, cutoff=1000, debug=False)) dyn = FIRE(cluster, logfile=None) startTime = time.time() converged = False try: dyn.run(fmax=0.01, steps=5000) converged = dyn.converged() if not converged: errorMessage = 'The optimisation of cluster ' + str( cluster_name) + ' did not optimise completely.' print(errorMessage, file=sys.stderr) print(errorMessage) except Exception: print('Local Optimiser Failed for some reason.') endTime = time.time() #################################################################################################################### # Write information about the algorithm Info = {} Info["INFO.txt"] = '' Info["INFO.txt"] += ("No of Force Calls: " + str(dyn.get_number_of_steps()) + '\n') Info["INFO.txt"] += ("Time (s): " + str(endTime - startTime) + '\n') #Info["INFO.txt"] += ("Cluster converged?: " + str(dyn.converged()) + '\n') #################################################################################################################### return cluster, converged, Info