def gen_properties( cryinp, natoms, kpath, denom, projs, get_ef=1, nprint=0, title='blank', above=5, below=8, kresfactor=20, eres=200, npoly=25, ): """ User-friendly properties input generator, for bandstructure and DOS. TODO: negative DOSS projections (onto atoms) Factor "denom" out of kpath to make it integer. projs = projections onto certain orbitals. See CRYSTAL manual "DOSS" and "NPROJ" above = number of bands above Ef below = number of bands below Ef ..res.. = resolution controls. npoly = number of polynomials < 25 used for expanding DOS. """ inp = read_cryinp(cryinp) shrink = inp['kdens'] epera = array(inp['effchg']) # This may only make sense when the spin channels are equal. filled = int(round(dot(array(natoms), epera))) / 2 newklines = [['NEWK']] newklines.append([shrink, shrink * 2]) newklines.append([get_ef, nprint]) nline = len(kpath) kres = kresfactor * nline highest = filled + above lowest = filled - below outtofile = 1 printevals = 0 bandlines = [['BAND']] bandlines.append([title]) bandlines.append( [nline, denom, kres, lowest, highest, outtofile, printevals]) for si in range(len(kpath) - 1): bandlines.append(kpath[si] + [' '] + kpath[si + 1]) bandlines.append(kpath[-1] + [' '] + kpath[0]) nproj = len(projs) printopts = 0 doslines = [['DOSS']] doslines.append( [nproj, eres, lowest, highest, outtofile, npoly, printopts]) for pi in range(len(projs)): doslines.append([len(projs[pi]), ' '] + projs[pi]) outlines = newklines + bandlines + newklines + doslines + [["END"]] return lines2str(outlines)
def gen_properties(cryinp,natoms,kpath,denom,projs, get_ef=1,nprint=0,title='blank', above=5,below=8, kresfactor=20,eres=200, npoly=25,): """ User-friendly properties input generator, for bandstructure and DOS. TODO: negative DOSS projections (onto atoms) Factor "denom" out of kpath to make it integer. projs = projections onto certain orbitals. See CRYSTAL manual "DOSS" and "NPROJ" above = number of bands above Ef below = number of bands below Ef ..res.. = resolution controls. npoly = number of polynomials < 25 used for expanding DOS. """ inp = read_cryinp(cryinp) shrink = inp['kdens'] epera = array(inp['effchg']) # This may only make sense when the spin channels are equal. filled = int(round(dot(array(natoms),epera))) / 2 newklines = [['NEWK']] newklines.append([shrink,shrink*2]) newklines.append([get_ef,nprint]) nline = len(kpath) kres = kresfactor*nline highest = filled + above lowest = filled - below outtofile = 1 printevals = 0 bandlines = [['BAND']] bandlines.append([title]) bandlines.append([nline,denom,kres,lowest,highest,outtofile,printevals]) for si in range(len(kpath)-1): bandlines.append(kpath[si]+[' ']+kpath[si+1]) bandlines.append(kpath[-1]+[' ']+kpath[0]) nproj = len(projs) printopts = 0 doslines = [['DOSS']] doslines.append([nproj,eres,lowest,highest,outtofile,npoly,printopts]) for pi in range(len(projs)): doslines.append([len(projs[pi]),' ']+projs[pi]) outlines = newklines + bandlines + newklines + doslines + [["END"]] return lines2str(outlines)
if "234" == line[0]: spot = (li,3) val = float(line[3]) break for li in range(len(baselines)): line = baselines[li] if [] == line: print "Didn't find hybrid spot." break else: if "HYBRID" == line[0]: hyb_spot = li+1 break with open('base.d12','w') as outf: outf.write(lines2str(baselines)) for hy in hyb_list: for dx in dx_list: dr = 'hy_%d_dx_%.2f'%(hy,dx) baselines[spot[0]][spot[1]] = val+dx baselines[hyb_spot][0] = hy if not os.path.exists(dr): os.makedirs(dr) with open('{dr}/{dr}.d12'.format(dr=dr),'w') as outf: outf.write(lines2str(baselines)) loc = '/'.join((os.getcwd(),dr)) pc = ['module load openmpi/1.4-gcc+ifort', 'cp {dr}.d12 INPUT'.format(dr=dr)] fc = ['rm *.pe[0-9] *.pe[0-9][0-9]']
if "234" == line[0]: spot = (li, 3) val = float(line[3]) break for li in range(len(baselines)): line = baselines[li] if [] == line: print "Didn't find hybrid spot." break else: if "HYBRID" == line[0]: hyb_spot = li + 1 break with open('base.d12', 'w') as outf: outf.write(lines2str(baselines)) for hy in hyb_list: for dx in dx_list: dr = 'hy_%d_dx_%.2f' % (hy, dx) baselines[spot[0]][spot[1]] = val + dx baselines[hyb_spot][0] = hy if not os.path.exists(dr): os.makedirs(dr) with open('{dr}/{dr}.d12'.format(dr=dr), 'w') as outf: outf.write(lines2str(baselines)) loc = '/'.join((os.getcwd(), dr)) pc = [ 'module load openmpi/1.4-gcc+ifort', 'cp {dr}.d12 INPUT'.format(dr=dr)