def createdirs(poscarsDir, maindir, vaspinputdir): '''makes dir in maindir for each structure in poscarsDir''' potcarDir = "/fslhome/bch/vaspfiles/src/potpaw_PBE" for file in os.listdir(poscarsDir): info = file.split('_') struct = '_'.join(info[1:3]) structDir = '{}/{}'.format(maindir, struct) atom = info[1] if not os.path.isdir(structDir): os.system('mkdir {}'.format(structDir)) #structure is in os.system('cp {}/{} {}/POSCAR'.format(poscarsDir, file, structDir)) print 'atom', atom try: potcar = readfile('{}/{}/POTCAR'.format(potcarDir, atom)) except: try: potcar = readfile('{}/{}_pv/POTCAR'.format(potcarDir, atom)) except: potcar = readfile('{}/{}_sv/POTCAR'.format(potcarDir, atom)) potcar += potcar #multiple atoms in POSCAR have only one POTCAR, so they are really all pure cases writefile(potcar, '{}/POTCAR'.format(structDir)) os.system('cp {}/INCAR {}'.format(vaspinputdir, structDir)) modIncar(structDir) os.system('cp -P {}/vasp.x {}'.format(vaspinputdir, structDir)) return
def createStructDirs(dir,poscarsDir,vaspinputdir): '''makes struct folder in dir for each structure in poscarsDir''' potcarDir = "/fslhome/bch/vaspfiles/src/potpaw_PBE" for file in os.listdir(poscarsDir): info = file.split('_') struct = '_'.join(info[1:3]) structDir = '{}/{}'.format(dir,struct) atom = info[1] if os.path.isdir(structDir): # os.system('rm -r -f {}'.format(structDir)) output = subprocess.check_output(['rm','-r','-f',structDir]) os.system('mkdir {}'.format(structDir)) #structure is in meshDet = open('{}/meshDetails.csv'.format(structDir),'w') meshDet.write('Ntarget,Nmesh,std/mean,energy/N,pack frac\n') meshDet.close() os.system('cp {}/{} {}/POSCAR'.format(poscarsDir,file,structDir)) try: potcar = readfile('{}/{}/POTCAR'.format(potcarDir,atom)) except: try: potcar = readfile('{}/{}_pv/POTCAR'.format(potcarDir,atom)) except: potcar = readfile('{}/{}_sv/POTCAR'.format(potcarDir,atom)) potcar += potcar #multiple atoms in POSCAR have only one POTCAR, so they are really all pure cases writefile(potcar,'{}/POTCAR'.format(structDir)) os.system ('cp {}/INCAR {}'.format(vaspinputdir,structDir)) modIncar(structDir) os.system ('cp -P {}/vasp.x {}'.format(vaspinputdir,structDir)) return
def createdirs(poscarsDir,maindir,vaspinputdir): '''makes dir in maindir for each structure in poscarsDir''' potcarDir = "/fslhome/bch/vaspfiles/src/potpaw_PBE" for file in os.listdir(poscarsDir): info = file.split('_') struct = '_'.join(info[1:3]) structDir = '{}/{}'.format(maindir,struct) atom = info[1] if not os.path.isdir(structDir): os.system('mkdir {}'.format(structDir)) #structure is in os.system('cp {}/{} {}/POSCAR'.format(poscarsDir,file,structDir)) print 'atom',atom try: potcar = readfile('{}/{}/POTCAR'.format(potcarDir,atom)) except: try: potcar = readfile('{}/{}_pv/POTCAR'.format(potcarDir,atom)) except: potcar = readfile('{}/{}_sv/POTCAR'.format(potcarDir,atom)) potcar += potcar #multiple atoms in POSCAR have only one POTCAR, so they are really all pure cases writefile(potcar,'{}/POTCAR'.format(structDir)) os.system ('cp {}/INCAR {}'.format(vaspinputdir,structDir)) modIncar(structDir) os.system ('cp -P {}/vasp.x {}'.format(vaspinputdir,structDir)) return
def modIncar(newdir): lines = readfile('{}/INCAR'.format(newdir)) plines = readfile('{}/POTCAR'.format(newdir)) for line in plines: if 'ENMAX' in line: enmax = 1.4 * float(line.split()[2].replace(';', '')) break for i, line in enumerate(deepcopy(lines)): if 'ENMAX' in line: lines[i] = 'ENMAX = {}\n'.format(enmax) break writefile(lines, '{}/INCAR'.format(newdir)) return
def modIncar(newdir): lines = readfile('{}/INCAR'.format(newdir)) plines = readfile('{}/POTCAR'.format(newdir)) for line in plines: if 'ENMAX' in line: enmax = 1.4*float(line.split()[2].replace(';','')) break for i,line in enumerate(npcopy(lines)): if 'ENMAX' in line: lines[i] = 'ENMAX = {}\n'.format(enmax) break writefile(lines,'{}/INCAR'.format(newdir)) return
def aflowCreatePoscars(structs,aNonPrim,atomic,finalDir): nsubmit = 50 #number of structures to submit in each execution of aflow for i in range(len(structs)/nsubmit+1): if (i+1)*nsubmit < len(structs)-1: sublist = structs[i*nsubmit:(i+1)*nsubmit] else: sublist = structs[i*nsubmit:] for struc in sublist: strucstr = 'f%s'% struc try: # commstr= 'aconvasp --aflow_proto ' + strucstr+ ':%s' % atomic commstr = 'aconvasp --proto={} {} | aconvasp --poscar>POSCAR'.format(strucstr,atomic) #for POSCAR creation print commstr os.system(commstr) except: print 'Error in executing %s' % commstr structDir = '{}/{}'.format(finalDir,strucstr) if not os.path.isdir(structDir): os.mkdir(structDir) pscr = readfile('POSCAR') pscr[1] = '{}\n'.format(float(pscr[1])*aNonPrim**3) writefile(pscr,'POSCAR') os.system('mv POSCAR {}'.format(structDir))