def history(cls, last=0, vaspclass=None): q = QueryTool() q.set_class(JobCalculation) l = filter(lambda c: 'vasp' in str(c.__class__), q.run_query()) l.sort(cls.cmp_ctime) res = l[-last:] res.reverse() tab = [cls.table_element(c) for c in res] print cls.str_table(tab)
def status(cls, vaspclass=None): q = QueryTool() q.set_class(JobCalculation) st = [ 'TOSOBMIT', 'SUBMITTING', 'WITHSCHEDULER', 'COMPUTED', 'PARSING', 'RETRIEVING' ] l = filter(lambda c: cls.cstate(c) in st, q.run_query()) l.sort(cls.cmp_ctime) l.reverse() tab = [cls.table_element(c) for c in l] print cls.str_table(tab)
def load_paw(cls, **kwargs): ''' py:method:: load_paw([family=None][, element=None][, symbol=None]) Load PawData nodes from the databank. Use kwargs to filter. :return: a list of PawData instances :rtype: list :key str family: Filter by family :key str element: Filter by chemical symbol :key str symbol: Filter by PAW symbol (example: As vs. As_d) :raises ValueError: if no PAWs are found ''' usage_msg = 'use import_family or from_folder to import PAWs' error_msg = 'no PAWs found for the given kwargs!\n'+usage_msg group = kwargs.pop('group', None) family = kwargs.pop('family', None) silent = kwargs.pop('silent', None) if not (group or family): q = QueryTool() q.set_class(cls) for k, v in kwargs.iteritems(): q.add_attr_filter(k, '=', v) res = list(q.run_query()) else: if family: group, created = cls.get_or_create_famgroup(family) elif group: created = not group._is_stored try: paw_filter = cls._node_filter(**kwargs) res = filter(paw_filter, group.nodes) except ValueError as e: if silent: res = [] elif created: raise NotExistent('No family with that name exists') else: raise e if not res and not silent: raise ValueError(error_msg) return res
def get_cifs_with_name(filename): q = QueryTool() q.set_class(DataFactory('cif')) q.add_attr_filter('filename', '=', filename) return q.run_query()
def load_paw(cls, **kwargs): q = QueryTool() q.set_class(cls) for k, v in kwargs.iteritems(): q.add_attr_filter(k, '=', v) return list(q.run_query())
from aiida.orm.calculation.job.vasp.maker import VaspMaker import sys cifname = sys.argv[1] mkcalc = VaspMaker(structure=cifname) mkcalc.code = Code.get_from_string('asevasp@monch') mkcalc.kpoints.set_kpoints_mesh([8, 8, 8]) mkcalc.add_settings(system=mkcalc.structure.filename, npar=8) mkcalc.recipe = 'test_sc' mkcalc.computer = Computer.get('monch') mkcalc.queue = 'dphys_compute' v5 = mkcalc.new() v5.set_resources({'num_machines': 8, 'num_mpiprocs_per_machine': 2}) # ~ v5.set_max_memory_kb(8000000) tag = sys.argv[2] q = QueryTool() q.set_class(mkcalc.calc_cls) q.add_extra_filter('tag', '=', tag) ql = map(lambda c: c.get_extra('test-nr'), q.run_query()) last_tn = ql and max(ql) or 0 v5.store_all() v5.set_extras({'tag': tag, 'test-nr': last_tn + 1}) print 'pk: {}, test-nr: {}'.format(v5.pk, last_tn + 1) v5.submit()
def get_eligible_scf(): from aiida.orm.querytool import QueryTool from aiida.orm import Calculation q = QueryTool() q.set_class(Calculation) return filter(has_scf_output, q.run_query())
from aiida.orm.querytool import QueryTool from aiida.orm.data.structure import StructureData from aiida.orm.data.parameter import ParameterData from aiida.orm import Group import os, sys, stat structure_grp = 'test_structures' # 'Cottenier_structures', struct_q = QueryTool() struct_q.set_class(StructureData) struct_q.set_group(structure_grp, exclude=False) symbols = [] for node in struct_q.run_query(): for s in node.get_symbols_set(): if not s in symbols: symbols.append(s) fout = open("run.x", "w") for s in symbols: t = sys.argv[1] if len(sys.argv) >= 2 else " --type=lo1+lo2+lo3+LO1" fout.write("./atom --symbol=" + s + t + "\n") fout.close() os.chmod("run.x", os.stat("run.x").st_mode | stat.S_IEXEC)