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))
statusOK,nops = meshc.pack(latticevecs,reciplatt,totatoms,aTypes,postype,transpose(positions),targetNmesh,meshtype,dir,params) os.chdir(lastDir) return statusOK,nops #script: # os.chdir('/fslhome/bch/cluster_expansion/vcmesh/semiconductors/10OctRnosearchPerp/r0/Si_/bcc_6') os.chdir('/fslhome/bch/cluster_expansion/vcmesh/semiconductors/sc_SiLP/r0/Si_/bcc_5') # os.chdir('/fslhome/bch/cluster_expansion/vcmesh/test/r0/Al_1/bcc_5') # os.chdir('/fslhome/bch/cluster_expansion/vcmesh/semiconductors/28SepRelaxVoidsFine/r2/Si_/bcc_13') ntarget = 5 type = 'bcc' paramLabels = ['wallClose','useVoids', 'rcutoff', 'tooClose','tooPlanar' 'rvCutoff','vwPower','wallPower','relax','interPower','wallFactor','wallOffset'] params = ['0.05', '0', '3.0', '-1', '-1', '4.0' , '3.0' , '2.0' , '1', '5.0', '1.3', '0.0'] #0.50 3.00 1.00 0.500. 1. 3. -1. -1. 3. 3. 3. 1. 6. 0.5 0. '''Best Si from master branch: params0 = [ 5.0 ] params1 = [ 2.0 ]#wallPower params2 = [ 1.3 ] #wallfactor params3 = [ 0.05] #wallClose params4 = [ 0.0 ] #wallOffset params5 = [ 0.5 ] #dw''' statusOK,nops = getVCmesh(os.getcwd(),ntarget,type,params) if statusOK: writefile([],'OK') elif os.path.exists('OK'): os.system('rm OK')
from kmeshroutines import nstrip, readposcar,create_poscar,readfile,writefile import dynamicPacking7 def getVCmesh(dir,targetNmesh,meshtype,params) : lastDir = os.getcwd() meshc = dynamicPacking7.dynamicPack() #instance [descriptor, scale, latticevecs, reciplatt, natoms, postype, positions] = readposcar('POSCAR',dir) # create_poscar('POSCAR',descriptor, scale, latticevecs, natoms, postype, positions, path) #just to remove the scale problem os.chdir(dir) totatoms = sum(natoms) atype = 1 aTypes = [] for natom in natoms: for i in range(natom): aTypes.append(atype) atype += 1 aTypes = array(aTypes) statusOK,nops = meshc.pack(latticevecs,reciplatt,totatoms,aTypes,postype,transpose(positions),targetNmesh,meshtype,dir,params) os.chdir(lastDir) return statusOK,nops #script: ntarget = int(sys.argv[1]) type = sys.argv[2] params = sys.argv[3:] statusOK,nops = getVCmesh(os.getcwd(),ntarget,type,params) if statusOK: writefile([],'OK') elif os.path.exists('OK'): os.system('rm OK')