示例#1
0
 def get_structure(self, entry_id):
     entry = self.get_entry(entry_id)
     if 'structure' not in entry:
         raise ValueError('structure is not present on %s' % entry_id)
     if entry['structure'] is None:
         raise ValueError('structure is None for %s' % entry_id)
     return Structure.from_dict(entry['structure'])
示例#2
0
 def get_structure(self, entry_id):
     entry = self.get_entry(entry_id)
     if 'structure' not in entry:
         raise ValueError('structure is not present on %s' % entry_id)
     if entry['structure'] is None:
         raise ValueError('structure is None for %s' % entry_id)
     return Structure.from_dict(entry['structure'])
示例#3
0
    def find_composition(self, composition):
        """
        Search for structures with a pseudo-composition expressed as dictionary
        where symbols that are not atomic symbols such as A or X can be used to
        represent arbitrary atoms

        :return: (list) List of ids for all the structures that fulfill
                 the conditions
        """
        ret = []
        for entry in self.entries.find({'nspecies': len(composition)}):
            comp = Structure.from_dict(entry['structure']).get_composition()
            valid = True
            if sum(comp.composition.values()) % sum(composition.values()) != 0:
                valid = False
            vect1 = np.float64(np.sort(comp.composition.values()))
            vect2 = np.float64(np.sort(composition.values()))
            v12 = vect1 / vect2
            if not np.all(v12 == v12[0]):
                valid = False
            for ispecie in composition:
                if ispecie in atomic_symbols and ispecie not in comp.species:
                    valid = False

            if valid:
                print(comp.composition)
                ret.append(entry['_id'])
        return ret
示例#4
0
文件: db.py 项目: apayne9/PyChemia
    def find_composition(self, composition):
        """
        Search for structures with a pseudo-composition expressed as dictionary
        where symbols that are not atomic symbols such as A or X can be used to
        represent arbitrary atoms

        :return: (list) List of ids for all the structures that fulfill
                 the conditions
        """
        ret = []
        for entry in self.entries.find({'nspecies': len(composition)}):
            comp = Structure.from_dict(entry['structure']).get_composition()
            valid = True
            if sum(comp.composition.values()) % sum(composition.values()) != 0:
                valid = False
            vect1 = np.float64(np.sort(comp.composition.values()))
            vect2 = np.float64(np.sort(composition.values()))
            v12 = vect1 / vect2
            if not np.all(v12 == v12[0]):
                valid = False
            for ispecie in composition:
                if ispecie in atomic_symbols and ispecie not in comp.species:
                    valid = False

            if valid:
                print(comp.composition)
                ret.append(entry['_id'])
        return ret
示例#5
0
    def get_structure(self, entry_id):
        """
        Return the structure in the entry with id 'entry_id'

        :rtype : Structure
        """
        entry = self.entries.find_one({'_id': entry_id})
        return Structure.from_dict(entry['structure'])
示例#6
0
文件: db.py 项目: apayne9/PyChemia
    def get_structure(self, entry_id):
        """
        Return the structure in the entry with id 'entry_id'

        :rtype : Structure
        """
        entry = self.entries.find_one({'_id': entry_id})
        return Structure.from_dict(entry['structure'])
示例#7
0
文件: vasp.py 项目: apayne9/PyChemia
 def fromdict(self, vj_dict):
     self.structure = Structure.from_dict(vj_dict['structure'])
     self.potcar_pspfiles = vj_dict['potcar_pspfiles']
     self.potcar_setup = vj_dict['potcar_setup']
     self.workdir = vj_dict['workdir']
     self.input_variables = InputVariables(variables=vj_dict['variables'])
     self.kpoints = vj_dict['kpoints']
     self.poscar_setup = vj_dict['poscar_setup']
     self.potcar_pspdir = vj_dict['potcar_pspdir']
示例#8
0
文件: queue.py 项目: apayne9/PyChemia
    def get_structure(self, entry_id, location):
        """
        Return the structure in the entry with id 'entry_id'

        :rtype : Structure
        """
        assert (location in ['input', 'output'])
        entry = self.db.pychemia_entries.find_one({'_id': entry_id}, {location: 1})
        return Structure.from_dict(entry[location]['structure'])
示例#9
0
    def get_structure(self, entry_id, location):
        """
        Return the structure in the entry with id 'entry_id'

        :rtype : Structure
        """
        assert (location in ['input', 'output'])
        entry = self.db.pychemia_entries.find_one({'_id': entry_id}, {location: 1})
        return Structure.from_dict(entry[location]['structure'])
示例#10
0
 def fromdict(self, vj_dict):
     self.structure = Structure.from_dict(vj_dict['structure'])
     self.potcar_pspfiles = vj_dict['potcar_pspfiles']
     self.potcar_setup = vj_dict['potcar_setup']
     self.workdir = vj_dict['workdir']
     self.input_variables = VaspInput(variables=vj_dict['variables'])
     self.kpoints = vj_dict['kpoints']
     self.poscar_setup = vj_dict['poscar_setup']
     self.potcar_pspdir = vj_dict['potcar_pspdir']
示例#11
0
    def find_AnBm(self, specie_a=None, specie_b=None, n=1, m=1):
        """
        Search for structures with a composition expressed as AnBm
        where one and only one between A or B is fixed and the numbers
        amounts n and m are both fixed

        :param specie_a: (str) atom symbol for the first specie
        :param specie_b: (str) atom symbol for the second specie
        :param n: number of atoms for specie 'a'
        :param m: number of atoms for specie 'b'
        :return:
        :return: (list) List of ids for all the structures that fulfill
                 the conditions
        """
        if specie_a is None and specie_b is None:
            raise ValueError("Enter a specie for A or B")
        elif specie_a is not None and specie_b is not None:
            raise ValueError("Only enter A or B, not both")
        elif specie_a is not None:
            atom_fixed = specie_a
            number_fixed = n
            number_unfixed = m
            assert (specie_a in atomic_symbols)
        else:
            atom_fixed = specie_b
            number_fixed = m
            number_unfixed = n
            assert (specie_b in atomic_symbols)

        ret = []
        for entry in self.entries.find({
                'structure.nspecies': 2,
                'structure.formula': {
                    '$regex': atom_fixed
                }
        }):
            comp = Structure.from_dict(entry['structure']).get_composition()
            if atom_fixed in comp.composition and comp.composition[
                    atom_fixed] % number_fixed == 0:
                species = comp.species
                species.remove(atom_fixed)
                other_specie = species[0]
                # See if the fraction n/m is correct for A and B
                if number_unfixed * float(
                        comp.composition[atom_fixed]) == number_fixed * float(
                            comp.composition[other_specie]):
                    ret.append(entry['_id'])
        return ret
示例#12
0
文件: db.py 项目: apayne9/PyChemia
    def find_AnBm(self, specie_a=None, specie_b=None, n=1, m=1):
        """
        Search for structures with a composition expressed as AnBm
        where one and only one between A or B is fixed and the numbers
        amounts n and m are both fixed

        :param specie_a: (str) atom symbol for the first specie
        :param specie_b: (str) atom symbol for the second specie
        :param n: number of atoms for specie 'a'
        :param m: number of atoms for specie 'b'
        :return:
        :return: (list) List of ids for all the structures that fulfill
                 the conditions
        """
        if specie_a is None and specie_b is None:
            raise ValueError("Enter a specie for A or B")
        elif specie_a is not None and specie_b is not None:
            raise ValueError("Only enter A or B, not both")
        elif specie_a is not None:
            atom_fixed = specie_a
            number_fixed = n
            number_unfixed = m
            assert (specie_a in atomic_symbols)
        else:
            atom_fixed = specie_b
            number_fixed = m
            number_unfixed = n
            assert (specie_b in atomic_symbols)

        ret = []
        for entry in self.entries.find({'nspecies': 2, 'formula': {'$regex': atom_fixed}}):
            comp = Structure.from_dict(entry['structure']).get_composition()
            if atom_fixed in comp.composition and comp.composition[atom_fixed] % number_fixed == 0:
                species = comp.species
                species.remove(atom_fixed)
                other_specie = species[0]
                # See if the fraction n/m is correct for A and B
                if number_unfixed * float(comp.composition[atom_fixed]) == number_fixed * float(
                        comp.composition[other_specie]):
                    ret.append(entry['_id'])
        return ret
示例#13
0
 def get_structure(self, entry_id):
     entry = self.get_entry(entry_id)
     return Structure.from_dict(entry['structure'])
示例#14
0
 def get_structure(self, entry_id):
     entry = self.get_entry(entry_id)
     return Structure.from_dict(entry['structure'])