def get_upf_groups(cls, filter_elements=None, user=None): """ Return all names of groups of type UpfFamily, possibly with some filters. :param filter_elements: A string or a list of strings. If present, returns only the groups that contains one Upf for every element present in the list. Default=None, meaning that all families are returned. :param user: if None (default), return the groups for all users. If defined, it should be either a DbUser instance, or a string for the username (that is, the user email). """ from aiida.orm import Group group_query_params = {"type_string": cls.upffamily_type_string} if user is not None: group_query_params['user'] = user if isinstance(filter_elements, basestring): filter_elements = [filter_elements] if filter_elements is not None: actual_filter_elements = {_.capitalize() for _ in filter_elements} group_query_params['node_attributes'] = { 'element': actual_filter_elements} all_upf_groups = Group.query(**group_query_params) groups = [(g.name, g) for g in all_upf_groups] # Sort by name groups.sort() # Return the groups, without name return [_[1] for _ in groups]
def get_upf_family_names(self): """ Get the list of all upf family names to which the pseudo belongs """ from aiida.orm import Group return [_.name for _ in Group.query(nodes=self, type_string=self.upffamily_type_string)]
def get_basis_family_names(self): """ Get the list of all basiset family names to which the basis belongs """ from aiida.orm import Group return [ _.name for _ in Group.query(nodes=self, type_string=self.basisfamily_type_string) ]
def get_paw_groups(cls, elements=set(), symbols=set(), user=None): from aiida.orm import Group from aiida.djsite.utils import get_automatic_user params = {'type_string': cls.group_type, 'node_attributes': { 'element': elements, 'symbol': symbols} } if user: params['user'] = user else: params['user'] = get_automatic_user() res = Group.query(**params) groups = [(g.name, g) for g in res] # Sort by name groups.sort() # Return the groups, without name return [i[1] for i in groups]
def get_paw_groups(cls, elements=None, symbols=None, user=None): """Find all paw groups containing potentials with the given attributes""" from aiida.orm import Group from aiida.backends.utils import get_automatic_user params = { 'type_string': cls.group_type, 'node_attributes': { 'element': elements, 'symbol': symbols } } if user: params['user'] = user else: params['user'] = get_automatic_user() res = Group.query(**params) groups = [(g.name, g) for g in res] # Sort by name groups.sort() # Return the groups, without name return [i[1] for i in groups]
def get_family_names(self): """List potcar families to which this instance belongs.""" return [ group.name for group in Group.query( nodes=self, type_string=self.potcar_family_type_string) ]
def runner(computer_name, test_set, group_name, potcar_family, dry_run, experiment): from aiida.orm import Code, Group, load_node from aiida.work import submit config = {} run_info_json = py_path.local('./run_info.json') cutoff = 'default' if experiment: config = read_experiment_yaml(experiment) if not computer_name: computer_name = config['computer'] if not group_name: group_name = config['group_name'] if not potcar_family: potcar_family = config['potcar_family'] if 'outfile' in config: run_info_json = py_path.local(experiment).dirpath().join( config['outfile']) test_set = test_set or config.get('test_set', 'perturbed') cutoff = config.get('cutoff', 'default') cutoff_factor = 1 if cutoff != 'default': cutoff_factor = int(cutoff) if not dry_run: run_info_json.ensure() run_info = json.loads(run_info_json.read() or '{{ "{}": {{ }} }}'.format(computer_name)) else: click.echo('run_info file would be created at {}'.format( run_info_json.strpath)) vasp_proc = calc_cls('vasp.vasp').process() inputs = vasp_proc.get_inputs_template() computer.set_options(computer=computer_name, options_template=inputs._options) inputs.code = Code.get_from_string('vasp@{}'.format(computer_name)) inputs.settings = data_cls('parameter')(dict=TEST_SETTINGS) structures_group_name = PERTURBED_SET_GROUPNAME if test_set == 'non_perturbed': structures_group_name = UNPERTURBED_SET_GROUPNAME structures_group = Group.get(name=structures_group_name) if not dry_run: calc_group, created = Group.get_or_create(name=group_name) else: created = not bool(Group.query(name=group_name)) calc_group_msg = 'Appending to {new_or_not} group {name}.' new_or_not = 'new' if created else 'existing' click.echo(calc_group_msg.format(new_or_not=new_or_not, name=group_name)) ## limit structures if given in experiment yaml structures = list(structures_group.nodes) only_formulae = config.get('only_formulae', None) if only_formulae: structures = [ structure for structure in structures if structure.get_formula() in only_formulae ] potcar_map = scf_potcar.POTCAR_MAP for structure in structures: inputs.structure = structure kpoints = data_cls('array.kpoints')() kpoints.set_cell_from_structure(structure) kpoints.set_kpoints_mesh_from_density(0.15, [0] * 3) inputs.kpoints = kpoints inputs.potential = data_cls('vasp.potcar').get_potcars_from_structure( structure=structure, family_name=potcar_family, mapping=potcar_map) ispin, magmom = magnetic_info(structure, potcar_family, potcar_map) incar_overrides = {} if ispin == 1: magnetism_string = "non-spin-polarized" elif ispin == 2: magnetism_string = "collinear-spin" incar_overrides['ispin'] = ispin else: raise Exception( "WTF" ) # This is not how you do non-collinear calcs! Set noncolin = True instead if magmom: incar_overrides['magmom'] = magmom if cutoff_factor != 1: default_enmax = cutoff_from_structure(structure=structure, potcar_family=potcar_family, mapping=potcar_map) incar_overrides['enmax'] = cutoff_factor * default_enmax inputs.parameters = scf_incar.get_scf_incar(inputs=inputs, overrides=incar_overrides) cutoff_msg = 'default' if cutoff_factor != 1: cutoff_msg = 'cutoff factor: {}'.format(cutoff_factor) if not dry_run: running_info = submit(vasp_proc, **inputs) running_calc = load_node(running_info.pid) running_calc.set_extra('magnetism', magnetism_string) running_calc.set_extra('cutoff', cutoff_msg) calc_group.add_nodes(running_calc) run_info[computer_name][inputs.structure.pk] = running_calc.pk else: click.echo('not submitting {}'.format(structure.get_formula())) from pprint import pformat click.echo(pformat({k: v for k, v in inputs.items()})) if not dry_run: with run_info_json.open('w') as run_info_fo: json.dump(run_info, run_info_fo)