コード例 #1
0
 def _query(idn=None, formula=None):
     """Make the actual query."""
     importer = CodDbImporter()
     if idn is not None:
         return importer.query(id=idn)
     if formula is not None:
         return importer.query(formula=formula)
     return None
コード例 #2
0
    def _COD_search(self):
        from .search.cod import cod_check
        from aiida.tools.dbimporters.plugins.cod import CodDbImporter
        """
        Deals with the retrieval of a structure
        from the COD database, according to the request dictionary
        Returns a database search object (array of arrays of structures)
        """

        kwords = cod_check(Dict(dict=self.ctx.db))
        self.ctx.db_valid = kwords.dict.valid
        self.ctx.db_invalid = kwords.dict.invalid

        # empty dictionary
        if not bool(self.ctx.db_valid):
            self.report('No valid keywords in search tag in json')
            return self.exit_codes.ERROR_MISSING_KEY
        # query the database for structures
        importer = CodDbImporter()
        self.ctx.allcifs = importer.query(**self.ctx.db_valid)
        self.ctx.n_structures = len(self.ctx.allcifs)
        if self.ctx.n_structures == 0:
            self.report('No structure retrieved')
            self.ctx.cif = None
            return self.exit_codes.ERROR_NO_STRUCTURE
        else:
            s = self.ctx.allcifs[0].get_aiida_structure()
            s.store()
            self.ctx.cif = s
            if self.ctx.n_structures >= 2:
                self.report('{} structure satisfy the request'.format(
                    self.ctx.n_structures))
コード例 #3
0
def create_spinel_structurelist():
    from aiida.tools.dbimporters.plugins.cod import CodDbImporter
    from icet.tools import get_primitive_structure

    # Import the ordered MgAl2O4 from COD db
    importer = CodDbImporter()
    mgalo = importer.query(id=1010129)[0]

    ase_mgalo = mgalo.get_ase_structure()
    primitive_structure = get_primitive_structure(ase_mgalo)

    chemical_symbols = [['Mg', 'Al'] for i in range(6)] + [['O']
                                                           for i in range(8)]

    # The concentration of A is 2/14 \in (0.1428, 0.1429)
    concentration_restrictions = {'Mg': (0.1428, 0.1429)}

    ase_structurelist = []
    for structure in enumerate_structures(
            primitive_structure,
            range(1, 3),
            chemical_symbols,
            concentration_restrictions=concentration_restrictions):
        ase_structurelist.append(structure)

    return ase_structurelist
コード例 #4
0
ファイル: cod.py プロジェクト: d-tomerini/aiida-post
def cod_query(cod_values):
    """
    performs a search of any CIF structure that is provided
    according to the data coming from the input JSON request
    returns a list of structures and an error code if there is
    something wrong with things
    """
    qlist = cod_values.get_dict()
    importer = CodDbImporter()
    found = importer.query(**qlist)
    found_list = found.fetch_all()
    x = [i.source['id'] for i in found_list]
    # returned list of retrieved structures

    return List(list=x)
コード例 #5
0
#     1010301,

1010348,
1010404,
1010406,
1010407,
1010419,
1010420,
1010424,
1010425,
1010652,
1010653,

    ]:

    r = codi.query(id=entry)
    cif = r[0].get_cif_node(store=True)

    try:
        struct = cif._get_aiida_structure(store=True)
    except KeyError:
        print('{}: unable to construct AiiDA structure -- structure '
              'possibly contains deuterium'.format(entry))
        continue

    elements = parse_formula(cif.get_formulae()[0])

    ecutwfc_max = 0
    ecutrho_max = 0

    try: