示例#1
0
def addAdsorbate(constraint="1"):
    constrnts = AND(COMPLETED, RELAX, SURFACE, SYMMETRIC(False), constraint)

    ads = {'H': ['O1']}

    output = db.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.Job(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.Job(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()
示例#2
0
def vary(constraint, param, rang, check=True):
    # verify that constraint uniquely picks out a job
    readJobs.readJobs()
    defaults = RELAXORLAT
    output = dbase.queryCol('params_json', AND([defaults, constraint]))
    assert len(
        output
    ) == 1, 'Constraint %s is not specific enough, the following sets of params are returned: %s' % (
        constraint, '\n\n'.join([abbreviateDict(z) for z in output]))
    params = json.loads(output[0])
    assert param in params.keys(), 'param %s not in keys: %s' % (
        abbreviateDict(param), params.keys())
    print 'Param dict with %s being varied over the range %s: %s' % (
        param, str(rang), abbreviateDict(params))

    jbs = []
    for v in rang:
        ps = copy.deepcopy(params)
        assert not (jobs.assignJob(ps).new()
                    ), 'varying a job that isn\'t complete or doesn\'t exist'
        ps[param] = v
        job = jobs.assignJob(ps)
        if job.new(): jbs.append(job)

    if not check or ask('Do you want to launch %d new jobs?' % len(jbs)):
        for j in jbs:
            j.check()
            j.submit()
        if check: misc.launch()
示例#3
0
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()
示例#4
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()
示例#5
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()
示例#6
0
def relaunch(predicate=lambda x: True):
    """Relaunch timed out jobs and unconverged GPAW jobs"""
    fizzleLostRuns()
    lpad.detect_unreserved(expiration_secs=3600 * 24 * 7, rerun=True)
    timeouts, unconvergeds = filter(predicate, errFWIDS('timeout')), filter(
        predicate, errFWIDS('kohnsham'))
    tQuestion = "Do you want to relaunch %d timed out runs?" % len(timeouts)
    uQuestion = "Do you want to relaunch %d unconverged jobs?" % len(
        unconvergeds)
    if misc.ask(tQuestion):
        for fwid in timeouts:
            q = lpad.get_fw_dict_by_id(fwid)['spec']['_queueadapter']
            q['walltime'] = misc.doubleTime(q['walltime'])
            lpad.update_spec([fwid], {'_queueadapter': q})
            lpad.rerun_fw(fwid)
            if q['walltime'][:2] == '40':
                print 'warning, 40h job with fwid ', fwid
    if misc.ask(uQuestion):
        inc = listOfIncompleteJobStrs()

        for fwid in unconvergeds:
            p = fwid2params(fwid)
            p['sigma'] += 0.05
            p['mixing'] *= 0.5
            job = jobs.Job(p)
            lpad.archive_wf(fwid)
            if job.new(inc): job.submit()

    misc.launch()
示例#7
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()
示例#8
0
def calculateBulkModulus(constraint="1"):

    cons = AND(LATTICEOPT,
               constraint)  # necessary for bulkmodulus calc to be valid
    output = db.query([
        'fwid', 'storage_directory', 'job_name', 'structure_ksb',
        'bulkvacancy_ksb', 'bulkscale_ksb', 'system_type_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)
    existing = manage.listOfIncompleteJobStrs()

    question = 'Are you sure you want to calculate bulk modulus for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, stor_dir, name, structure, bvj, bsj, kind, pw, xc, kptden, psp, dwrat, econv, mixing, nmix, maxstep, nbands, sigma, fmax, dftcode in output:

            params = {
                'jobkind': 'bulkmod',
                'strain': 0.03,
                'inittraj_pckl':
                misc.restoreMagmom(misc.storageDir2pckl(stor_dir)),
                'name': name + '_bulkmod',
                'structure': structure,
                'bulkvacancy_json': bvj,
                'bulkscale_json': bsj,
                'kind': kind,
                'dftcode': dftcode,
                'pw': pw,
                'xc': xc,
                'kptden': kptden,
                'psp': psp,
                'dwrat': dwrat,
                'econv': econv,
                'mixing': mixing,
                'nmix': nmix,
                'maxstep': maxstep,
                'nbands': nbands,
                'sigma': sigma,
                'fmax': fmax,
                'parent': fwid
            }
            job = jobs.Job(params)

            if job.new(existing): newjbs.append(job)
        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.submit()
            misc.launch()
示例#9
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()
示例#10
0
文件: api.py 项目: rhs2132/conda
def app_launch(fn, prefix=config.root_dir, additional_args=None):
    """
    Launch the application `fn` (with optional additional command line
    arguments), in the prefix (which defaults to the root environment).
    Returned is the process object (the one returned by subprocess.Popen),
    or None if the application `fn` is not installed in the prefix.
    """
    from misc import launch

    return launch(fn, prefix, additional_args)
示例#11
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()
示例#12
0
def molecule(molname=None):
    readJobs.readJobs()
    for name, m in gas.aseMolDict.items():
        if molname is None or name == molname:
            mol = pickle.dumps(m)
            variableParams = {
                'pw': 500,
                'xc': 'RPBE',
                'psp': 'gbrv15pbe',
                'fmax': 0.05,
                'dftcode': 'quantumespresso'
            }

            defaultParams = {
                'jobkind': 'relax',
                'inittraj_pckl': mol,
                'comments': 'created by gendata.molecule()',
                'trajcomments': '',
                'name': name,
                'relaxed': 0,
                'kind': 'molecule',
                'kptden':
                1  #doesn't matter, will be ignored. Use 1 to be safe.
                ,
                'dwrat': 10,
                'econv': 5e-4,
                'mixing': 0.1,
                'nmix': 10,
                'maxstep': 500,
                'nbands': -12,
                'sigma': 0.1
            }
            p = misc.mergeDicts([variableParams, defaultParams])
            if molname is None or ask(
                    'Do you want to run a gas phase calculation with these params?\n%s'
                    % (abbreviateDict(p))):
                j = jobs.assignJob(p)
                if j.new():
                    j.check()
                    j.submit()
    misc.launch()
示例#13
0
def getXCcontribs(constraint="1"):
    """NOT YET DEBUGGED"""
    cons = AND(GPAW, RELAXORLAT, constraint)
    output = db.query([
        'fwid', 'storage_directory', 'job_name', 'system_type_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 calculate XC contributions for %d structures?' % len(
        output)
    if ask(question):
        newjbs = []
        for fwid, stor_dir, name, kind, pw, xc, kptden, psp, dwrat, econv, mixing, nmix, maxstep, nbands, sigma, fmax, dftcode in output:
            params = {
                'jobkind': 'xc',
                'inittraj_pckl': storageDir2pckl(stor_dir),
                'name': name + '_xc',
                'kind': kind,
                'dftcode': dftcode,
                'pw': pw,
                'xc': xc,
                'kptden': kptden,
                'psp': psp,
                'dwrat': dwrat,
                'econv': econv,
                'mixing': mixing,
                'nmix': nmix,
                'maxstep': maxstep,
                'nbands': nbands,
                'sigma': sigma,
                'fmax': fmax,
                'parent': fwid
            }
            job = jobs.Job(params)
            if job.new() and ask('does this look right %s' % str(params)):
                newjbs.append(job)
        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.submit()
            misc.launch()
示例#14
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()
示例#15
0
def molecule(molname=None):
    """
	Give molecule name to choose initial structure, modify dictionary parameters for relaxation job
	"""

    existing = manage.listOfIncompleteJobStrs()

    for name, m in gas.aseMolDict.items():
        if molname is None or name == molname:
            mol = pickle.dumps(m)
            params = {
                'pw': 500,
                'xc': 'BEEF',
                'psp': 'gbrv15pbe',
                'fmax': 0.05,
                'dftcode': 'quantumespresso',
                'jobkind': 'relax',
                'inittraj_pckl': mol,
                'name': name,
                'relaxed': 0,
                'kind': 'molecule',
                'kptden':
                1  #doesn't matter, will be ignored. Use 1 to be safe.
                ,
                'dwrat': 10,
                'econv': 5e-4,
                'mixing': 0.1,
                'nmix': 10,
                'maxstep': 500,
                'nbands': -12,
                'sigma': 0.1
            }

            if molname is None or ask(
                    'Do you want to run a gas phase calculation with these params?\n%s'
                    % (misc.abbreviateDict(params))):
                jobs.Job(params).submit(existing)

    misc.launch()
示例#16
0
def varies(constraint, param, rang):
    readJobs.readJobs()
    jbs = []
    defaults = RELAXORLAT
    cnst = AND([defaults, constraint])
    output = dbase.queryCol('params_json', cnst)

    if ask('Do you want to vary %s over range %s for %d jobs?' %
           (param, str(rang), len(output))):
        for params in map(json.loads, output):
            for v in rang:
                ps = copy.deepcopy(params)
                assert not (jobs.assignJob(ps).new(
                )), 'varying a job that isn\'t complete or doesn\'t exist'
                ps[param] = v
                job = jobs.assignJob(ps)
                if job.new(): jbs.append(job)

        if ask('Do you want to launch %d new jobs?' % len(jbs)):
            for j in jbs:
                j.check()
                j.submit()
            misc.launch()
示例#17
0
def toDo():
	params = db.queryCol('params_json',VIB,deleted=True)
	for p in params:
		j = jobs.assignJob(json.loads(p))
		if j.new(): j.check();j.submit()
	misc.launch()
示例#18
0
def addInterstitial(constraint="1", emttol=0.2, vischeck=True, limit=1):
    """
	Specify an interstitial and the number (up to which) you want to add them to the cell
	Filter duplicates via EMT-calculated energy (stipulate a tolerance)
	Assume final structure is triclinic
	"""

    inter, num = 'H', 2

    cons = AND(LATTICEOPT, QE, PW(500), KPTDEN(2), constraint)

    output = db.query(
        [
            'fwid',
            'storage_directory',
            'job_name',
            'system_type_ksb'  # generic parameters
            ,
            'planewave_cutoff',
            'xc',
            'kptden_ksb',
            'psp_ksb',
            'dwrat_ksb',
            'econv_ksb',
            'mixing_ksb',
            'nmix_ksb',
            'maxstep_ksb',
            'nbands_ksb',
            'sigma_ksb',
            'fmax_ksb',
            'dftcode'  # calc parameters
            ,
            'bulkvacancy_ksb',
            'bulkscale_ksb'
        ],
        cons,
        limit=limit)  # bulk parameters

    existing = manage.listOfIncompleteJobStrs(
    )  # check currently running/fizzled jobs to avoid duplicates

    if ask('Are you sure you want to create interstitials for %d structures?' %
           len(output)):
        newjbs, totJbs, totStruct = [], 0, 0  #initialize variables

        for fwid, stor_dir, name, kind, pw, xc, kptden, psp, dwrat, econv, mixing, nmix, maxstep, nbands, sigma, fmax, dftcode, bv, bs in output:

            params = {
                'jobkind': 'vcrelax',
                'kind': 'bulk',
                'dftcode': dftcode,
                'name': name,
                '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,
                'structure': 'triclinic',
                'bulkvacancy_json': bv,
                'bulkscale_json': bs
            }  #bulk

            ftraj = misc.storageDir2pckl(stor_dir)
            spnpl = any([
                x > 0
                for x in pickle.loads(ftraj).get_initial_magnetic_moments()
            ])

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

            for i in range(num):

                lastround = trajs[
                    -1]  # for all structures with n - 1 interstitials (note: initially there is only one, with 0 interstitials)
                trajs.append(
                    []
                )  # initialize container for all new structures with n interstitials
                for inputtraj, strname in lastround:
                    for newtraj, newname in interstitialFuncs.getInterstitials(
                            inputtraj, inter, spnpl):
                        trajs[-1].append(
                            (newtraj, strname + newname)
                        )  # add all new trajs found for all previous structures (append suffix to name)

            def modParams(
                    par, trj, nam
            ):  # For a given new traj and name, create input parameters
                p = copy.deepcopy(
                    par)  # All parameters common to all of these jobs
                p['name'] += nam  # Unique job name
                p['inittraj_pckl'] = pickle.dumps(trj)  # Initial structure
                return p

            def getEMT(x):
                a = pickle.loads(x['inittraj_pckl'])
                a.set_calculator(emt.EMT())
                return a.get_potential_energy()

            onelevel = [
                modParams(params, item[0], item[1]) for sublist in trajs[1:]
                for item in sublist
            ]  #collapse list of lists to a single list of input parameters

            emtPairs = sorted(
                zip(map(getEMT, onelevel),
                    onelevel))  # pairs of (Energy,Params) ordered by energy

            emtCounter, jbs = 0, []
            for e, p in emtPairs:
                if e - emtCounter > emttol:
                    jbs.append(jobs.Job(p))
                    emtCounter = e

            newjbs.extend([x for x in jbs if x.new(existing)])
            totJbs += len(jbs)
            totStruct += len(onelevel)

        check = ask(
            'Do you want to check %d/%d new jobs? (%d filtered by emt)' %
            (len(newjbs), totStruct, totStruct - totJbs))
        if not check and ask('Do you want to exit?'): return 0
        for jb in newjbs:
            question = 'Does this structure look right?\n' + misc.abbreviateDict(
                jb.params)
            if vischeck: viz.view(pickle.loads(jb.params['inittraj_pckl']))
            if not vischeck or ask(question): jb.submit()
        misc.launch()
示例#19
0
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()
示例#20
0
def getVibs(constraint="1"):
    """
	Launch vibration calculation for all latticeopt or (vc-)relax jobs that meet some (SQL) constraint in the shared database
	Only (and all) nonmetal atoms will be vibrated (defined in misc.py)
	"""

    existing = manage.listOfIncompleteJobStrs()

    cons = AND(
        QE, RELAXORLAT, constraint
    )  #could we add a column to quickly filter things with nonmetals?

    output = db.query(
        [
            'fwid',
            'storage_directory',
            'job_name',
            'system_type_ksb'  # generic parameters
            ,
            'planewave_cutoff',
            'xc',
            'kptden_ksb',
            'psp_ksb',
            'dwrat_ksb',
            'econv_ksb',
            'mixing_ksb',
            'nmix_ksb',
            'maxstep_ksb',
            'nbands_ksb',
            'sigma_ksb',
            'fmax_ksb',
            'dftcode'  # calc parameters
            ,
            'structure_ksb',
            'bulkvacancy_ksb',
            'bulkscale_ksb'  # possible bulk parameters
            ,
            'facet_ksb',
            'xy_ksb',
            'layers_ksb',
            'constrained_ksb',
            'symmetric_ksb',
            'vacuum_ksb',
            'vacancies_ksb',
            'adsorbates_ksb',
            'sites_ksb'
        ],
        cons)  # possible surf parameters

    question = 'Are you sure you want to calculate vibrations for %d structures?' % len(
        output)

    if ask(question):
        newjbs = []
        for fwid, stor_dir, name, kind, pw, xc, kptden, psp, dwrat, econv, mixing, nmix, maxstep, nbands, sigma, fmax, dftcode, structure, bv, bs, facet, xy, lay, const, sym, vac, vacan, ads, sites in output:
            inittraj_pckl = storageDir2pckl(stor_dir)
            atoms = pickle.loads(inittraj_pckl)

            nonmetal_inds = [
                i for i, x in enumerate(atoms.get_chemical_symbols())
                if x in misc.nonmetalSymbs
            ]

            if len(nonmetal_inds) > 0:
                params = {
                    'jobkind': 'vib',
                    'inittraj_pckl': inittraj_pckl,
                    'name': name + '_vib',
                    'kind': kind,
                    'dftcode': dftcode,
                    'structure': structure,
                    'pw': pw,
                    'xc': xc,
                    'kptden': kptden,
                    'psp': psp,
                    'dwrat': dwrat,
                    'econv': econv,
                    'mixing': mixing,
                    'nmix': nmix,
                    'maxstep': maxstep,
                    'nbands': nbands,
                    'sigma': sigma,
                    'fmax': fmax,
                    'structure': structure,
                    'bulkvacancy_json': bv,
                    'bulkscale_json': bs,
                    'facet_json': facet,
                    'xy_json': xy,
                    'layers': lay,
                    'constrained': const,
                    'symmetric': sym,
                    'vacuum': vac,
                    'vacancies_json': vacan,
                    'adsorbates_json': ads,
                    'sites_base64': sites,
                    'parent': fwid,
                    'vibids_json': json.dumps(nonmetal_inds),
                    'delta': 0.04
                }

                job = jobs.Job(params)

                if job.new() and ask('does this look right %s' % str(params)):
                    newjbs.append(job)

        if ask("launch %d new jobs?" % len(newjbs)):
            for j in newjbs:
                j.submit(existing)
            misc.launch()
示例#21
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()
示例#22
0
def rerun(cnstrt='1'):
	fwids = db.queryCol('fwid',AND([FIZZLED,cnstrt]))
	question='Do you want to rerun %d  fizzled jobs selected by %s?'%(len(fwids),cnstrt)
	if ask(question):
		for f in fwids: lpad.rerun_fw(f)
		misc.launch()