コード例 #1
0
ファイル: spglib.py プロジェクト: zhuligs/spglib
def get_symmetry_dataset(bulk, symprec=1e-5, angle_tolerance=-1.0):
    """
    number: International space group number
    international: International symbol
    hall: Hall symbol
    transformation_matrix:
      Transformation matrix from lattice of input cell to Bravais lattice
      L^bravais = L^original * Tmat
    origin shift: Origin shift in the setting of 'Bravais lattice'
    rotations, translations:
      Rotation matrices and translation vectors
      Space group operations are obtained by
        [(r,t) for r, t in zip(rotations, translations)]
    wyckoffs:
      Wyckoff letters
    """
    positions = np.array(bulk.get_scaled_positions(),
                         dtype='double',
                         order='C')
    lattice = np.array(bulk.get_cell().T, dtype='double', order='C')
    numbers = np.array(bulk.get_atomic_numbers(), dtype='intc')

    keys = ('number', 'hall_number', 'international', 'hall',
            'transformation_matrix', 'origin_shift', 'rotations',
            'translations', 'wyckoffs', 'equivalent_atoms', 'brv_lattice',
            'brv_types', 'brv_positions')
    dataset = {}
    for key, data in zip(
            keys,
            spg.dataset(lattice, positions, numbers, symprec,
                        angle_tolerance)):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['transformation_matrix'] = np.array(
        dataset['transformation_matrix'], dtype='double', order='C')
    dataset['origin_shift'] = np.array(dataset['origin_shift'], dtype='double')
    dataset['rotations'] = np.array(dataset['rotations'],
                                    dtype='intc',
                                    order='C')
    dataset['translations'] = np.array(dataset['translations'],
                                       dtype='double',
                                       order='C')
    letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'],
                                           dtype='intc')
    dataset['brv_lattice'] = np.array(np.transpose(dataset['brv_lattice']),
                                      dtype='double',
                                      order='C')
    dataset['brv_types'] = np.array(dataset['brv_types'], dtype='intc')
    dataset['brv_positions'] = np.array(dataset['brv_positions'],
                                        dtype='double',
                                        order='C')

    return dataset
コード例 #2
0
def get_symmetry_dataset(structure, symprec=1e-3, angle_tolerance=-1.0):
    """
    Return a full set of symmetry information from a given input structure.

    Mapping values:
        number: International space group number
        international: International symbol
        hall: Hall symbol
        transformation_matrix:
          Transformation matrix from lattice of input cell to Bravais lattice
          L^bravais = L^original * Tmat
        origin shift: Origin shift in the setting of 'Bravais lattice'
        rotations, translations:
          Rotation matrices and translation vectors
          Space group operations are obtained by
            [(r,t) for r, t in zip(rotations, translations)]
        wyckoffs:
          Wyckoff letters

    Examples::

        >>> from qmpy.io import read
        >>> from qmpy.analysis.symmetry import get_symmetry_dataset
        >>> structure = read('POSCAR')
        >>> get_symmetry_dataset(structure)

    """
    keys = ('number', 'international', 'hall', 'transformation_matrix',
            'origin_shift', 'rotations', 'translations', 'wyckoffs',
            'equivalent_atoms')

    cell = structure.cell.T.copy()
    coords = np.array(structure.site_coords)
    comps = structure.site_compositions
    numbers = [comps.index(c) for c in comps]
    numbers = np.array(numbers, dtype='intc')

    dataset = {}
    for key, data in zip(
            keys, spg.dataset(cell, coords, numbers, symprec,
                              angle_tolerance)):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['transformation_matrix'] = np.array(
        dataset['transformation_matrix']).T
    dataset['origin_shift'] = np.array(dataset['origin_shift'])
    dataset['rotations'] = np.array(dataset['rotations'])
    dataset['translations'] = np.array(dataset['translations'])
    letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'])
    return dataset
コード例 #3
0
ファイル: spglib.py プロジェクト: cryos/spglib
def get_symmetry_dataset(bulk, symprec=1e-5, angle_tolerance=-1.0):
    """
    number: International space group number
    international: International symbol
    hall: Hall symbol
    transformation_matrix:
      Transformation matrix from lattice of input cell to Bravais lattice
      L^bravais = L^original * Tmat
    origin shift: Origin shift in the setting of 'Bravais lattice'
    rotations, translations:
      Rotation matrices and translation vectors
      Space group operations are obtained by
        [(r,t) for r, t in zip(rotations, translations)]
    wyckoffs:
      Wyckoff letters
    """
    positions = np.array(bulk.get_scaled_positions(), dtype='double', order='C')
    lattice = np.array(bulk.get_cell().T, dtype='double', order='C')
    numbers = np.array(bulk.get_atomic_numbers(), dtype='intc')
    
    keys = ('number',
            'international',
            'hall',
            'transformation_matrix',
            'origin_shift',
            'rotations',
            'translations',
            'wyckoffs',
            'equivalent_atoms')
    dataset = {}
    for key, data in zip(keys, spg.dataset(lattice,
                                           positions,
                                           numbers,
                                           symprec,
                                           angle_tolerance)):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['transformation_matrix'] = np.array(
        dataset['transformation_matrix'], dtype='double', order='C')
    dataset['origin_shift'] = np.array(dataset['origin_shift'], dtype='double')
    dataset['rotations'] = np.array(dataset['rotations'],
                                    dtype='intc', order='C')
    dataset['translations'] = np.array(dataset['translations'],
                                       dtype='double', order='C')
    letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'],
                                           dtype='intc')

    return dataset
コード例 #4
0
ファイル: spglib_adaptor.py プロジェクト: chenweis/pymatgen
    def get_symmetry_dataset(self):
        """
        Returns the symmetry dataset as a dict.
        
        Returns:
            number: 
                International space group number
            international: 
                International symbol
            hall: 
                Hall symbol
            transformation_matrix: 
                Transformation matrix from lattice of input cell to Bravais lattice
                L^bravais = L^original * Tmat
            origin shift: 
                Origin shift in the setting of 'Bravais lattice'
            rotations, translations:
                Rotation matrices and translation vectors. 
                Space group operations are obtained by
                [(r,t) for r, t in zip(rotations, translations)]
            wyckoffs:
                  Wyckoff letters
        """
        keys = ('number',
                'international',
                'hall',
                'transformation_matrix',
                'origin_shift',
                'rotations',
                'translations',
                'wyckoffs',
                'equivalent_atoms')
        dataset = {}
        for key, data in zip(keys, spg.dataset(self._lattice.transpose().copy(), self._positions, self._numbers, self._symprec, self._angle_tol)):
            dataset[key] = data

        dataset['international'] = dataset['international'].strip()
        dataset['hall'] = dataset['hall'].strip()
        dataset['transformation_matrix'] = np.array(dataset['transformation_matrix'])
        dataset['origin_shift'] = np.array(dataset['origin_shift'])
        dataset['rotations'] = np.array(dataset['rotations'])
        dataset['translations'] = np.array(dataset['translations'])
        letters = "abcdefghijklmnopqrstuvwxyz"
        dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
        dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'])

        return dataset
コード例 #5
0
def get_symmetry_dataset(structure, symprec=1e-3, angle_tolerance=-1.0):
    """
    Return a full set of symmetry information from a given input structure.

    Mapping values:
        number: International space group number
        international: International symbol
        hall: Hall symbol
        transformation_matrix:
          Transformation matrix from lattice of input cell to Bravais lattice
          L^bravais = L^original * Tmat
        origin shift: Origin shift in the setting of 'Bravais lattice'
        rotations, translations:
          Rotation matrices and translation vectors
          Space group operations are obtained by
            [(r,t) for r, t in zip(rotations, translations)]
        wyckoffs:
          Wyckoff letters

    Examples::

        >>> from qmpy.io import read
        >>> from qmpy.analysis.symmetry import get_symmetry_dataset
        >>> structure = read('POSCAR')
        >>> get_symmetry_dataset(structure)

    """
    keys = ('number',
            'hall_number',
            'international',
            'hall',
            'transformation_matrix',
            'origin_shift',
            'rotations',
            'translations',
            'wyckoffs',
            'equivalent_atoms',
            'std_lattice',
            'std_types',
            'std_positions',
            'pointgroup_number',
            'pointgroup')

    cell = structure.cell.T.copy()
    coords = np.array(structure.site_coords)
    comps = structure.site_compositions
    numbers = [ comps.index(c) for c in comps ]
    numbers = np.array(numbers, dtype='intc')

    dataset = {}
    for key, data in zip(keys, spg.dataset(cell,
                                           coords,
                                           numbers,
                                           symprec,
                                           angle_tolerance)):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['transformation_matrix'] = np.array(dataset['transformation_matrix'], dtype='double', order='C')
    dataset['origin_shift'] = np.array(dataset['origin_shift'], dtype='double')
    dataset['rotations'] = np.array(dataset['rotations'], dtype='intc', order='C')
    dataset['translations'] = np.array(dataset['translations'], dtype='double', order='C')
    letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'], dtype='intc')
    dataset['std_lattice'] = np.array(np.transpose(dataset['std_lattice']), dtype='double', order='C')
    dataset['std_types'] = np.array(dataset['std_types'], dtype='intc')
    dataset['std_positions'] = np.array(dataset['std_positions'], dtype='double', order='C')
    dataset['pointgroup'] = dataset['pointgroup'].strip()

    return dataset
コード例 #6
0
ファイル: spglib.py プロジェクト: CarstenTUBT/spglib
def get_symmetry_dataset(bulk, symprec=1e-5, angle_tolerance=-1.0):
    """
    number: International space group number
    international: International symbol
    hall: Hall symbol
    transformation_matrix:
      Transformation matrix from input lattice to standardized lattice
      L^original = L^standardized * Tmat
    origin shift: Origin shift from standardized to input origin 
    rotations, translations:
      Rotation matrices and translation vectors
      Space group operations are obtained by
        [(r,t) for r, t in zip(rotations, translations)]
    wyckoffs:
      Wyckoff letters
    std_lattice, std_types, std_positions:
      Standardized unit cell
    pointgroup_number, pointgroup_symbol: Point group number (see get_pointgroup)
    """
    positions = np.array(bulk.get_scaled_positions(), dtype='double', order='C')
    lattice = np.array(bulk.get_cell().T, dtype='double', order='C')
    numbers = np.array(bulk.get_atomic_numbers(), dtype='intc')
    
    keys = ('number',
            'hall_number',
            'international',
            'hall',
            'transformation_matrix',
            'origin_shift',
            'rotations',
            'translations',
            'wyckoffs',
            'equivalent_atoms',
            'std_lattice',
            'std_types',
            'std_positions',
            'pointgroup_number',
            'pointgroup')
    dataset = {}
    for key, data in zip(keys, spg.dataset(lattice,
                                           positions,
                                           numbers,
                                           symprec,
                                           angle_tolerance)):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['transformation_matrix'] = np.array(
        dataset['transformation_matrix'], dtype='double', order='C')
    dataset['origin_shift'] = np.array(dataset['origin_shift'], dtype='double')
    dataset['rotations'] = np.array(dataset['rotations'],
                                    dtype='intc', order='C')
    dataset['translations'] = np.array(dataset['translations'],
                                       dtype='double', order='C')
    letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'],
                                           dtype='intc')
    dataset['std_lattice'] = np.array(np.transpose(dataset['std_lattice']),
                                      dtype='double', order='C')
    dataset['std_types'] = np.array(dataset['std_types'], dtype='intc')
    dataset['std_positions'] = np.array(dataset['std_positions'],
                                        dtype='double', order='C')
    dataset['pointgroup'] = dataset['pointgroup'].strip()

    return dataset
コード例 #7
0
ファイル: bookkeeping.py プロジェクト: peteboyd/net_discovery
    def refine_cell(self):
        """
        get refined data from symmetry finding
        """
        if self.sym:
            # Temporary storage of structure info
            _lattice = self._lattice.T.copy()
            _scaled_coords = self._scaled_coords.copy()
            _symprec = self._symprec
            _angle_tol = self._angle_tol
            _numbers = self._numbers.copy()
            
            keys = ('number',
                    'international',
                    'hall',
                    'transformation_matrix',
                    'origin_shift',
                    'rotations',
                    'translations',
                    'wyckoffs',
                    'equivalent_atoms')
            dataset = {}

            dataset['number'] = 0
            while dataset['number'] == 0:

                # refine cell
                num_atom = len(_scaled_coords)
                ref_lattice = _lattice.copy()
                ref_pos = np.zeros((num_atom * 4, 3), dtype=float)
                ref_pos[:num_atom] = _scaled_coords.copy()
                ref_numbers = np.zeros(num_atom * 4, dtype=int)
                ref_numbers[:num_atom] = _numbers.copy()
                num_atom_bravais = spg.refine_cell(ref_lattice,
                                           ref_pos,
                                           ref_numbers,
                                           num_atom,
                                           _symprec,
                                           _angle_tol)
                for key, data in zip(keys, spg.dataset(ref_lattice.copy(),
                                        ref_pos[:num_atom_bravais].copy(),
                                    ref_numbers[:num_atom_bravais].copy(),
                                                _symprec,
                                                _angle_tol)):
                    dataset[key] = data

                _symprec = _symprec * 0.5

            # an error occured with met9, org1, org9 whereby no
            # symmetry info was being printed for some reason.
            # thus a check is done after refining the structure.

            if dataset['number'] == 0:
                warning("WARNING - Bad Symmetry found!")
                self.sym = False
            else:

                self.dataset['number'] = dataset['number']
                self.dataset['international'] = dataset['international'].strip()
                self.dataset['hall'] = dataset['hall'].strip()
                self.dataset['transformation_matrix'] = np.array(dataset['transformation_matrix'])
                self.dataset['origin_shift'] = np.array(dataset['origin_shift'])
                self.dataset['rotations'] = np.array(dataset['rotations'])
                self.dataset['translations'] = np.array(dataset['translations'])
                letters = "abcdefghijklmnopqrstuvwxyz"
                self.dataset['wyckoffs'] = [letters[x] for x in dataset['wyckoffs']]
                self.dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'])
                self._lattice = ref_lattice.T.copy()
                self._scaled_coords = ref_pos[:num_atom_bravais].copy()
                self._numbers = ref_numbers[:num_atom_bravais].copy()
                self._element_symbols = [ATOMIC_NUMBER[i] for 
                    i in ref_numbers[:num_atom_bravais]]