示例#1
0
    def move_random(self, entry_id, factor=0.2, in_place=False, kind='move'):

        entry = self.get_entry(entry_id)
        pos = np.array(entry['structure']['positions']).reshape((-1, 3))
        # Unit Vectors
        uv = unit_vectors(2 * np.random.rand(*pos.shape) - 1)
        new_pos = generic_serializer(pos + factor * uv)

        structure = Structure(positions=new_pos, symbols=entry['structure']['symbols'], periodicity=False)

        if in_place:
            self.update_properties(entry_id=entry_id, new_properties={})
            return self.set_structure(entry_id, structure)
        else:
            structure = Structure(positions=new_pos, symbols=entry['structure']['symbols'], periodicity=False)
            return self.new_entry(structure, active=False)
示例#2
0
    def move_random(self, entry_id, factor=0.2, in_place=False, kind='move'):

        entry = self.get_entry(entry_id)
        pos = np.array(entry['structure']['positions']).reshape((-1, 3))
        # Unit Vectors
        uv = unit_vectors(2 * np.random.rand(*pos.shape) - 1)
        new_pos = generic_serializer(pos + factor * uv)

        structure = Structure(positions=new_pos,
                              symbols=entry['structure']['symbols'],
                              periodicity=False)

        if in_place:
            self.update_properties(entry_id=entry_id, new_properties={})
            return self.set_structure(entry_id, structure)
        else:
            structure = Structure(positions=new_pos,
                                  symbols=entry['structure']['symbols'],
                                  periodicity=False)
            return self.new_entry(structure, active=False)
示例#3
0
文件: input.py 项目: kvlvn/PyChemia
    def from_structure(self, structure):
        """
        Set input variables for a given structure

        :param structure: (pychemia.Structure) Structure to set ABINIT input variables
        :return:
        """
        natom = structure.natom
        ntypat = len(structure.species)
        znucl = atomic_number(structure.species)
        typat_dict = {}
        index = 1
        for ispec in structure.species:
            typat_dict[ispec] = index
            index += 1
        typat = [typat_dict[i] for i in structure.symbols]
        xcart = angstrom_bohr * structure.positions.flatten()
        acell = angstrom_bohr * np.array(structure.lattice.lengths)
        rprim = unit_vectors(structure.cell).T.flatten()
        for i in ['natom', 'ntypat', 'znucl', 'typat', 'xcart', 'acell', 'rprim']:
            self.set_value(i, eval(i))
示例#4
0
    def from_structure(self, structure):
        """
        Set input variables for a given structure

        :param structure: (pychemia.Structure) Structure to set ABINIT input variables
        :return:
        """
        natom = structure.natom
        ntypat = len(structure.species)
        znucl = atomic_number(structure.species)
        typat_dict = {}
        index = 1
        for ispec in structure.species:
            typat_dict[ispec] = index
            index += 1
        typat = [typat_dict[i] for i in structure.symbols]
        xcart = angstrom_bohr * structure.positions.flatten()
        acell = angstrom_bohr * np.array(structure.lattice.lengths)
        rprim = unit_vectors(structure.cell).T.flatten()
        for i in ['natom', 'ntypat', 'znucl', 'typat', 'xcart', 'acell', 'rprim']:
            self.set_value(i, eval(i))