def getEng(strpth): def getENG_GPAW(log): return float(parseLine(log, 'Extrapolated:', -1).split()[-1]) def getENG_QE(log): return float(parseLine(log, 'total energy', -2).split()[-2]) dftcode = getDFTcode(strpth) if dftcode == 'gpaw': return getENG_GPAW(readOnSherOrSlac(strpth + 'log')) elif dftcode == 'quantumespresso': return getENG_QE(readOnSherOrSlac(strpth + 'log')) else: return None
def getPSPpath(storagepath, dftcode): def getPSPpath_QE(log): return parseLine(log, 'pseudo_dir').split("='")[1][:-2] def getPSPpath_GPAW(log): return parseLine(log, 'setups').split(': ')[-1].strip() if dftcode == 'gpaw': return getPSPpath_GPAW(readOnSherOrSlac(storagepath + 'log')) elif dftcode == 'quantumespresso': return getPSPpath_QE(readOnSherOrSlac(storagepath + 'pw.inp')) else: raise NotImplementedError, 'unknown dftcode?'
def varies(constraint, param, rang): """ varies("xc='BEEF' and name like '%Pd%'",'pw',range(500,1000,100)) --> create jobs varying planewave_cutoff (500,600,...,1000) for all BEEF jobs with Pd """ jbs = [] defaults = RELAXORLAT cnst = AND(defaults, constraint) output = db.queryCol('storage_directory', cnst) existing = manage.listOfIncompleteJobStrs() if ask('Do you want to vary %s over range %s for %d jobs?' % (param, str(rang), len(output))): for stordir in output: params = json.loads(misc.readOnSherOrSlac(stordir + 'params.json')) for v in rang: ps = copy.deepcopy(params) assert not (jobs.Job(ps).new( )), 'varying a job that isn\'t complete or doesn\'t exist' ps[param] = v job = jobs.Job(ps) if job.new(existing): jbs.append(job) if ask('Do you want to launch %d new jobs?' % len(jbs)): for j in jbs: j.submit() misc.launch()
def getAtoms(storedpath): import pickle return pickle.loads(readOnSherOrSlac(storedpath + 'raw.pckl'))
def getDFTcode(strpth): if 'espresso' in readOnSherOrSlac(strpth + 'log'): return 'quantumespresso' elif 'gpaw' in readOnSherOrSlac(strpth + 'log'): return 'gpaw' else: raise NotImplementedError, 'Vasp?'
def getTPS(user, jobkind, storedpath, fwid): if user != 'ksb' or jobkind not in ['latticeopt', 'relax']: return None n = readOnSherOrSlac(storedpath + 'qn.log').count('BFGS') return lastLaunch(fwid)['runtime_secs'] / float(n)
def getFWID(user, storedpath): if user != 'ksb': return None out = readOnSherOrSlac(storedpath + 'FW_submit.script') return int(parseLine(out, '--fw_id').split()[-1]) raise ValueError, 'No fw_id found in FW_submit.script: \n\n%s' % out
def makeStrJob(user, storedpath): if user != 'ksb': return None import jobs, json params = json.loads(readOnSherOrSlac(storedpath + 'params.json')) return str(jobs.Job(params))
def result(storagepath, key): import json return json.loads(readOnSherOrSlac(storagepath + 'result.json'))[key]
def getBareSlab(constraint="1", check=True): """Create a bare slab for some set of relaxed bulk structures. Alter parameters below as necessary""" cons = AND(RELAXORLAT, BULK, MBEEF, PAWPSP, BCC, PW(1500), KPTDEN(2), constraint) facet = [1, 0, 0] xy = [1, 1] layers = 6 constrained = 2 symmetric = 1 vacuum = 10 vacancies = [] output = db.query([ 'fwid', 'storage_directory', 'job_name', 'structure_ksb', 'planewave_cutoff', 'xc', 'kptden_ksb', 'psp_ksb', 'dwrat_ksb', 'econv_ksb', 'mixing_ksb', 'nmix_ksb', 'maxstep_ksb', 'nbands_ksb', 'sigma_ksb', 'fmax_ksb', 'dftcode' ], cons) question = 'Are you sure you want to create bare slabs for %d structures?' % len( output) if ask(question): existing = manage.listOfIncompleteJobStrs() newjbs = [] for fwid, stor_dir, name, structure, pw, xc, kptden, psp, dwrat, econv, mixing, nmix, maxstep, nbands, sigma, fmax, dftcode in output: ftraj = misc.readOnSherOrSlac(stor_dir + 'raw.pckl') surf, img = surfFuncs.bulk2surf(ftraj, facet, xy, layers, constrained, symmetric, vacuum, vacancies) name += '_' + ','.join(map(str, facet)) + '_' + 'x'.join( map(str, (xy + [layers]))) params = { 'jobkind': 'relax', 'inittraj_pckl': pickle.dumps(surf), 'name': name, 'kind': 'surface', 'dftcode': dftcode, 'structure': structure # don't need bulk vacancies/scale? , 'pw': pw, 'xc': xc, 'kptden': kptden, 'psp': psp, 'bulkparent': fwid, 'dwrat': dwrat, 'econv': econv, 'mixing': mixing, 'nmix': nmix, 'maxstep': maxstep, 'nbands': nbands, 'sigma': sigma, 'fmax': fmax, 'sites_base64': img, 'facet_json': json.dumps(facet), 'xy_json': json.dumps(xy), 'layers': layers, 'constrained': constrained, 'symmetric': symmetric, 'vacuum': vacuum, 'vacancies_json': json.dumps(vacancies), 'adsorbates_json': json.dumps({}) } job = jobs.Job(params) if job.new(existing): if check: viz.view(surf) question = 'Does this structure look right?\n' + misc.abbreviateDict( params) if not check or ask(question): job.submit() misc.launch()