def GULPRelaxation(inputStr): ##for gulp to work. gulp folder must be in the same folder as the script environ["GULP_LIB"] = "\"" + getcwd() + "/Gulp_40/Libraries/\"" environ["ASE_GULP_COMMAND"] = "\"" + getcwd( ) + "/Gulp_40/Exe/gulp.exe\" < PREFIX.gin > PREFIX.got" ##takes string inputStr and turns it into stepNb, shouldRestartFromScratch listOfAtoms if len(inputStr) % 4 != 2: print("Args nb " + str(len(inputStr))) print(inputStr) print( "Not enough args. Args order : stepNb, shouldRestartFromScratch (0 or 1), \n atom list formatted as Name Xpos Ypos Zpos for each atom (example CO2 would be C 0 0 0 O 0 1 1 O 0 1 -1)" ) return "", False atomNames = [] atomXYZ = [] stepNb = int(inputStr[0]) shouldRestartFromScratch = int(inputStr[1]) #if restart from scratch, destroy previously known trajectory if (shouldRestartFromScratch == 1): my_file = Path('tmp.pckl') if my_file.is_file(): remove('tmp.pckl') #create Atoms object to optimize for i in range(0, math.floor(len(inputStr) / 4)): atomNames.append(inputStr[4 * i + 2]) atomXYZ.append((float(inputStr[4 * i + 3]), float(inputStr[4 * i + 4]), float(inputStr[4 * i + 5]))) atoms = Atoms(atomNames, positions=atomXYZ) c = Conditions(atoms) #attach calculator calc = GULP(keywords='conp', library="./Gulp_40/Libraries/reaxff.lib") atoms.calc = calc calc.set(keywords='conp opti') #optimize opt = calc.get_optimizer(atoms) opt.run(fmax=0.05) #io.write('../MoleculeLibrary/tmp.xyz', atoms, format='xyz') pos = atoms.get_positions() outStr = "" for i in range(0, len(atomNames)): outStr += atomNames[i] + " " outStr += str(pos[i][0]) + " " outStr += str(pos[i][1]) + " " outStr += str(pos[i][2]) + " " return outStr, True
[ 2.958884, 0.51505 , -1.556651], [ 1.73983 , -3.161794, -0.356577], [ 2.131519, -2.336982, 0.996026], [ 0.752313, -1.788039, 1.687183], [-0.142347, 1.685301, -1.12086 ], [ 2.32407 , -1.845905, -2.588202], [-2.571557, -1.937877, 2.604727], [ 2.556369, -4.551103, -3.2836 ], [ 3.032586, 0.591698, -4.896276], [-1.67818 , 2.640745, -3.27092 ], [ 5.145483, 0.775188, 0.95687 ], [-2.81059 , -3.4492 , -2.650319], [ 2.558023, -3.594544, 2.845928], [ 0.400993, 3.469148, 1.733289]])) c = Conditions(cluster) c.min_distance_rule('O', 'H', ifcloselabel1='O2', ifcloselabel2='H', elselabel1='O1') calc = GULP(keywords='conp', shel=['O1', 'O2'], conditions=c) # Single point calculation cluster.calc = calc print(cluster.get_potential_energy()) # Optimization using the internal optimizer of GULP calc.set(keywords='conp opti') opt = calc.get_optimizer(cluster) opt.run(fmax=0.05) print(cluster.get_potential_energy())