コード例 #1
0
ファイル: constraint.py プロジェクト: statt8900/ksb_scripts
 def output(self, extraConstraint='1'):
     dom = db.queryCol('fwid',
                       pp.AND([extraConstraint, self.detail1constraint]))
     pairs = db.query(['id0', 'id1'], self.detail2constraint, 'pairs')
     if self.detail1constraint == '1' and extraConstraint == '1':
         return pairs
     return [(x, y) for (x, y) in pairs if (x in dom) and (y in dom)]
コード例 #2
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def addAdsorbate(constraint="1"):
    constrnts = AND([COMPLETED, RELAX, SURFACE, SYMMETRIC(False), constraint])

    ads = {'H': ['O1']}
    details.load('finaltraj_pckl', constrnts)
    output = dbase.query(['fwid', 'params_json', 'finaltraj_pckl'], constrnts)
    question = 'Are you sure you want to add adsorbates to %d slabs?' % len(
        output)

    if ask(question):
        for fw, paramStr, ftraj in output:
            params = json.loads(paramStr)

            newsurf = surfFuncs.adsorbedSurface(
                ftraj, json.loads(params['facet_json']), ads)
            if jobs.assignJob(params).spinpol():
                newsurf.set_initial_magnetic_moments([
                    3 if e in misc.magElems else 0
                    for e in newsurf.get_chemical_symbols()
                ])
            ase.visualize.view(newsurf)

            params['name'] += '_' + printAds(ads)
            params['surfparent'] = fw
            params['inittraj_pckl'] = pickle.dumps(newsurf)
            params['adsorbates_json'] = json.dumps(ads)
            job = jobs.assignJob(params)
            if job.new():
                viz.view(newsurf)
                question = 'Does this structure look right?\n' + abbreviateDict(
                    params)
                if ask(question):
                    job.check()
                    job.submit()
        misc.launch()
コード例 #3
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def getVibs(constraint="1"):
    cons = AND([QE, COMPLETED, RELAXORLAT, NONMETAL, constraint])
    details.load('finaltraj_pckl', cons)
    output = dbase.query(
        ['fwid', 'params_json', 'finaltraj_pckl', 'natoms', 'numbers_pckl'],
        cons)

    question = 'Are you sure you want to calculate vibrations for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, paramStr, ftraj, n, ns in output:
            param = json.loads(paramStr)
            nums = zip(range(n), pickle.loads(ns))
            nonmetal = [x for x, y in nums if y in misc.nonmetals
                        ]  #default do vibrations only on nonmetal atoms

            if len(nonmetal) > 0:
                param['jobkind'] = 'vib'
                param['relax'] = fwid
                param['inittraj_pckl'] = misc.restoreMagmom(ftraj)
                param['vibids_json'] = json.dumps(nonmetal)
                param['delta'] = 0.04
                job = jobs.assignJob(param)

                print abbreviateDict(param)

                if job.new(): newjbs.append(job)

        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.check()
                j.submit()
            misc.launch()
コード例 #4
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def calculateBulkModulus(constraint="1"):

    details.load(['finaltraj_pckl'], incomplete=False)

    cons = AND([COMPLETED, LATTICEOPT,
                constraint])  # necessary for bulkmodulus calc to be valid

    output = dbase.query(['fwid', 'params_json', 'finaltraj_pckl'], cons)
    question = 'Are you sure you want to calculate bulk modulus for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, paramStr, ftraj in output:
            param = json.loads(paramStr)
            del param['xtol']
            param['jobkind'] = 'bulkmod'
            param['strain'] = 0.03
            param['relax'] = fwid
            param['inittraj_pckl'] = misc.restoreMagmom(ftraj)
            job = jobs.assignJob(param)
            if job.new(): newjbs.append(job)
        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.check()
                j.submit()
            misc.launch()
コード例 #5
0
def setWalltimeUnder40():
	""" If too much time was requested accidentally (such that job is stuck in READY), use this to modify the job"""
	details.load(['walltime'])
	output = db.query(['fwid','queueadapter'],QOVER40)
	print "Resetting walltime for %d jobs"%len(output)
	for fw,fwpckl in output:
		q=pickle.loads(fwpckl)['spec']['_queueadapter']
		q['walltime'] = '39:59' + ':00' if q['walltime'].count(':')>1 else ''
		lpad.update_spec([fw],{'_queueadapter':q})
	misc.launch()
コード例 #6
0
def relaunch(cnst = '1',expiration_secs=80000,skip_load=False):
	"""Relaunch timed out jobs and unconverged GPAW jobs"""
	lpad.detect_lostruns(expiration_secs=expiration_secs, fizzle=True)
	lpad.detect_unreserved(expiration_secs=3600*24*7, rerun=True)

	if not skip_load: details.load('status fwpckl status trace',NOTCOMPLETED) 

	unconverged = AND([NOTCOMPLETED,KOHNSHAM,cnst])
	timedout 	= AND([TIMEOUT,NOTKOHN,cnst])
	launchflag	= False
	tOutput 	= db.query(['fwid','fwpckl'],timedout)
	uOutput 	= db.query(['fwid','params_json'],unconverged)
	tQuestion 	= "Do you want to relaunch %d timed out runs?"%len(tOutput)
	uQuestion 	= "Do you want to relaunch %d unconverged jobs?"%len(uOutput)

	if ask(tQuestion):
		launchflag = True
		for fid,fwpckl in tOutput:
			if lpad.get_fw_dict_by_id(fid)['state']=='FIZZLED':
				q 				= pickle.loads(fwpckl)['spec']['_queueadapter']
				wallT  			= q['walltime']
				q['walltime'] 	=  doubleTime(wallT)
				lpad.update_spec([fid],{'_queueadapter':q})
				lpad.rerun_fw(fid)
			else: print ("Wait up to 24 hours to relaunch fwid %d, or change default expiration time for detect_lostruns"%(fid))

	if ask(uQuestion):
		launchflag = True
		for fw,paramstr in uOutput:
			p = json.loads(paramstr)
			p['sigma'] 	+= 0.1 
			p['mixing'] = p['mixing']*0.5
			job= jobs.assignJob(p)
			if job.new():
				job.check();job.submit()
				delete(FWID(fw),check=False)
		readJobs.readJobs()

	if launchflag: 
		misc.launch()
		duplicates()
コード例 #7
0
ファイル: plotJobs.py プロジェクト: statt8900/ksb_scripts
 def makeTriples(self, idgroups, labelName):
     args = [db.query(self.cols, FWIDS(x))
             for x in idgroups]  #[[(ARG1,ARG2,...)]]
     labels = [db.queryCol(labelName, FWIDS(x))
               for x in idgroups]  #[[STRING]]
     xy = [self.func(*zip(*arg)) for arg in args]  #[[(FLOAT,FLOAT))
     xy_l = [(zip(xy, l)) for xy, l in zip(xy, labels)]
     filtered = [[(xyl[0][0], xyl[0][1], xyl[1]) for xyl in xyls
                  if not (xyl[0][0] is None or xyl[0][1] is None)]
                 for xyls in xy_l]
     sortd = [sorted(x) for x in filtered if len(x) > 0]
     return [zip(*x) for x in sortd]
コード例 #8
0
def delete(constraint,check=True,comment=None):
	output = db.query(['fwid','launchdir'],constraint)
	question = 'Are you sure you want to delete %d jobs? (selected by constraint: %s)'%(len(output),constraint)
	if (not check) or ask(question):
		for fwid,launchdir in output:
			db.updateDB('deleted','fwid',fwid,1,'job')
			db.updateDB('status','fwid',fwid,'deleted','job')
			if comment is not None: db.updateDB('comments','fwid',fwid,comment,'job')
			if 'scratch' in launchdir: 
				with open(launchdir+'/deleted','w') as f: f.write('')
			else:
				subprocess.Popen(['ssh','*****@*****.**', 'touch %s/deleted'%launchdir], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			lpad.archive_wf(fwid)
コード例 #9
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def getBareSlab(constraint="1",
                facet=[1, 1, 1],
                xy=[1, 1],
                layers=4,
                constrained=2,
                symmetric=0,
                vacuum=10,
                vacancies=[]):

    cons = AND([COMPLETED, LATTICEOPT, constraint])
    details.load('finaltraj_pckl', cons)
    output = dbase.query(['fwid', 'params_json', 'finaltraj_pckl'], cons)

    question = 'Are you sure you want to create bare slabs for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, paramStr, ftraj in output:
            param = json.loads(paramStr)

            surf, img = surfFuncs.bulk2surf(ftraj, facet, xy, layers,
                                            constrained, symmetric, vacuum,
                                            vacancies)

            param['jobkind'] = 'relax'
            param['kind'] = 'surface'
            param['name'] += '_' + ','.join(map(str, facet)) + '_' + 'x'.join(
                map(str, (xy + [layers])))
            param['relax'] = 0
            param['bulkparent'] = fwid
            param['inittraj_pckl'] = pickle.dumps(surf)
            param['sites_base64'] = img
            param['facet_json'] = json.dumps(facet)
            param['xy_json'] = json.dumps(xy)
            param['layers'] = layers
            param['constrained'] = constrained
            param['symmetric'] = symmetric
            param['vacuum'] = vacuum
            param['vacancies_json'] = json.dumps(vacancies)
            param['adsorbates_json'] = json.dumps({})

            job = jobs.assignJob(param)
            if job.new():
                viz.view(surf)
                question = 'Does this structure look right?\n' + abbreviateDict(
                    param)
                if ask(question):
                    job.check()
                    job.submit()
        misc.launch()
コード例 #10
0
def duplicates(cnst='1',deleteFlag=False):
	output = db.query(['fwid','strjob'],cnst)
	rptDict={}
	for fwid,strjob in output:
		for f,s in output:
			if strjob == s and f!=fwid: 
				if fwid not in list(itertools.chain.from_iterable(rptDict.values())):
					if fwid in rptDict.keys(): rptDict[fwid].append(f)
					else: rptDict[fwid] = [f]
	print 'FWIDs with equal strjob entries: \n',abbreviateDict(rptDict)
	if deleteFlag:
		delfws = list(itertools.chain.from_iterable(rptDict.values()))
		if ask('Are you sure you want to delete %d duplicates?'%len(delfws)):
			for f in delfws: delete(FWID(f),False)
コード例 #11
0
ファイル: plotJobs.py プロジェクト: statt8900/ksb_scripts
def barResults(ax, summaryFunc, labelFunc, eq, const='1'):
    #Plots summaries of data as a bar graph
    ids = [list(x) for x in eq.classes(extraConstraint=const)]
    xs = [db.query1(labelFunc, 'fwid', i[0], 'job') for i in ids]  # [String]
    raw_ys = [db.query(summaryFunc.details, FWIDS(i))
              for i in ids]  # [[a,b,c,...]]
    col_ys = zip(summaryFunc.details * len(raw_ys), raw_ys)
    ys = [
        summaryFunc.kind(summaryFunc.details, args) for cols, args in col_ys
    ]  # [Float]

    y_pos = np.arange(len(ids))  # bar locations

    ax.bar(y_pos, ys, align='center', alpha=0.5)
    ax.set_ylabel(summaryFunc.name)
    ax.set_xticks(y_pos)
    ax.set_xticklabels(xs)
コード例 #12
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def getXCcontribs(constraint="1"):
    details.load(['finaltraj_pckl'], incomplete=False)
    cons = AND([COMPLETED, GPAW, RELAXORLAT, constraint])
    output = dbase.query(['fwid', 'params_json', 'finaltraj_pckl'], cons)
    question = 'Are you sure you want to calculate XC contributions for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, paramStr, ftraj in output:
            param = json.loads(paramStr)
            param['jobkind'] = 'xc'
            param['inittraj_pckl'] = misc.restoreMagmom(ftraj)
            param['relax'] = fwid

            job = jobs.assignJob(param)
            if job.new(): newjbs.append(job)
        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.check()
                j.submit()
            misc.launch()
コード例 #13
0
ファイル: gendata.py プロジェクト: statt8900/ksb_scripts
def addInterstitial(constraint="1", load=True, emttol=0.2):

    inter, num = 'H', 2

    cons = AND([COMPLETED, LATTICEOPT, QE, constraint])

    if load: details.load(['finaltraj_pckl'], cons)
    else: readJobs.readJobs()

    output = dbase.query(['fwid', 'params_json', 'finaltraj_pckl'], cons)

    question = 'Are you sure you want to add interstitials to %d structures?' % len(
        output)
    if ask(question):
        jbs = []
        for fwid, paramStr, ftraj in output:
            param = json.loads(paramStr)
            spnpl = jobs.assignJob(param).spinpol()

            param['structure'] = 'triclinic'
            param['jobkind'] = 'vcrelax'
            param['relaxed'] = fwid
            if 'xtol' in param.keys(): del param['xtol']

            trajs = [[(pickle.loads(ftraj), '')]]

            for i in range(num):

                lastround = trajs[-1]
                trajs.append([])
                for inputtraj, strname in lastround:

                    for newtraj, newname in interstitialFuncs.getInterstitials(
                            inputtraj, inter, spnpl):

                        trajs[-1].append((newtraj, strname + newname))

            def modParams(par, trj, nam):
                p = copy.deepcopy(par)
                p['name'] += nam
                p['inittraj_pckl'] = pickle.dumps(trj)
                return p

            onelevel = [item for sublist in trajs[1:] for item in sublist]

            tentativejoblist = [
                jobs.assignJob(modParams(param, t, n)) for t, n in onelevel
            ]
            addJobs, efilt = [], 0
            for j in tentativejoblist:
                if any([abs(j.emt() - x.emt()) < emttol for x in addJobs]):
                    efilt += 1
                else:
                    addJobs.append(j)
            jbs.extend(addJobs)

        newjbs = [j for j in jbs if j.new()]
        for j in newjbs:
            print j.symbols(), j.emt()
        check = ask(
            'Do you want to check %d/%d new jobs? (%d filtered by emt)' %
            (len(newjbs), len(jbs) + efilt, efilt))
        if not check and ask('Do you want to exit?'): return 0
        for jb in newjbs:

            question = 'Does this structure look right?\n' + abbreviateDict(
                j.params)
            if check: viz.view(newtraj)
            if not check or ask(question):
                jb.check()
                jb.submit()
        misc.launch()
コード例 #14
0
def fix():
	output = db.query(['fwid','fwpckl'],AND([LATTICEOPT,GPAW]))
	for fw,fwpckl in output:
		q=pickle.loads(fwpckl)['spec']['_queueadapter']
		q['pre_rocket'] = q['pre_rocket'].replace(';;',';')
		lpad.update_spec([fw],{'_queueadapter':q})