Esempio n. 1
0
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()
Esempio n. 2
0
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()
Esempio n. 3
0
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()
Esempio n. 4
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()
Esempio n. 5
0
def main():
    print "STARTING PLOT:"

    load = True  ### Only do this once (if database doesn't change
    if load:
        d.load(d.staticcol, incomplete=False, pairs=True)

    fig, (ax) = plt.subplots(nrows=1, ncols=1)
    #(fig,ax) = plt.subplots(nrows=1,ncols=1)
    plotDict(interstitialEnergy, ax)

    plt.show()
Esempio n. 6
0
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()
Esempio n. 7
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()
Esempio n. 8
0
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()
Esempio n. 9
0
 def test_costs(self):
     csv_file = path('detailed_with_tags.csv')
     total = details.load(csv_file)
     cols = total.columns
     for col in cols:
         self.assertIn(col, COLUMNS)
     for col in COLUMNS:
         self.assertIn(col, cols)
     values = total.values('ProductName')
     for value in values:
         self.assertIn(value, SERVICES)
     for value in SERVICES:
         self.assertIn(value, values)
     self.assertEqual(total.cost, decimal.Decimal('0.08805964'))
     self.assertEqual(total.unblended_cost, decimal.Decimal('0.08805964'))
     self.assertEqual(total.blended_cost, decimal.Decimal('0.08805964'))
     ec2 = total.filter([('ProductName', '.*Elastic Compute.*')])
     self.assertEqual(ec2.cost, decimal.Decimal('0.08800464'))
     s3dt = total.filter([('ProductName', '.*Storage.*'),
                          ('UsageType', '.*DataTransfer.*')])
     self.assertEqual(s3dt.cost, decimal.Decimal('0.00005964'))
Esempio n. 10
0
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()
Esempio n. 11
0
def resetDB():
	if ask('Do you want to reset all tables?'):
		print 'wiping db'
		db.wipeDB();
		print 'loading details'
		details.load('status err_A err_BM')