Beispiel #1
0
def get_symmetry_dataset(cell, 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)
    """

    lattice, positions, numbers, _ = _expand_cell(cell)
    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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
def get_symmetry_dataset(cell, symprec=1e-5, angle_tolerance=-1.0):
    """Search symmetry dataset from an input cell.

    Args:
        cell, symprec, angle_tolerance:
            See the docstring of get_symmetry.

    Return:
        A dictionary is returned.

        number:
            int: International space group number
        international:
            str: International symbol
        hall:
            str: Hall symbol
        choice:
            str: Centring, origin, basis vector setting
        transformation_matrix:
            3x3 float matrix:
                Transformation matrix from input lattice to standardized lattice
                L^original = L^standardized * Tmat
        origin shift:
            float vecotr: Origin shift from standardized to input origin
        rotations, translations:
            3x3 int matrix, float vector:
                Rotation matrices and translation vectors. Space group
                operations are obtained by
                [(r,t) for r, t in zip(rotations, translations)]
        wyckoffs:
            List of characters: Wyckoff letters
        std_lattice, std_positions, std_types:
            3x3 float matrix, Nx3 float vectors, list of int:
                Standardized unit cell
        pointgroup:
            str: Pointgroup symbol

        If it fails, None is returned.
    """
    _set_no_error()

    lattice, positions, numbers, _ = _expand_cell(cell)
    if lattice is None:
        return None

    keys = ('number',
            'hall_number',
            'international',
            'hall',
            'choice',
            'transformation_matrix',
            'origin_shift',
            'rotations',
            'translations',
            'wyckoffs',
            'equivalent_atoms',
            'std_lattice',
            'std_types',
            'std_positions',
            # 'pointgroup_number',
            'pointgroup')
    spg_ds = spg.dataset(lattice, positions, numbers, symprec, angle_tolerance)
    if spg_ds is None:
        _set_error_message()
        return None

    dataset = {}
    for key, data in zip(keys, spg_ds):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['choice'] = dataset['choice'].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()

    _set_error_message()
    return dataset
Beispiel #5
0
def get_symmetry_dataset(cell, symprec=1e-5, angle_tolerance=-1.0):
    """Search symmetry dataset from an input cell.

    Args:
        cell, symprec, angle_tolerance:
            See the docstring of get_symmetry.

    Return:
        A dictionary is returned.

        number:
            int: International space group number
        international:
            str: International symbol
        hall:
            str: Hall symbol
        choice:
            str: Centring, origin, basis vector setting
        transformation_matrix:
            3x3 float matrix:
                Transformation matrix from input lattice to standardized lattice
                L^original = L^standardized * Tmat
        origin shift:
            float vecotr: Origin shift from standardized to input origin
        rotations, translations:
            3x3 int matrix, float vector:
                Rotation matrices and translation vectors. Space group
                operations are obtained by
                [(r,t) for r, t in zip(rotations, translations)]
        wyckoffs:
            List of characters: Wyckoff letters
        std_lattice, std_positions, std_types:
            3x3 float matrix, Nx3 float vectors, list of int:
                Standardized unit cell
        pointgroup:
            str: Pointgroup symbol

        If it fails, None is returned.
    """
    _set_no_error()

    lattice, positions, numbers, _ = _expand_cell(cell)
    if lattice is None:
        return None

    keys = (
        'number',
        'hall_number',
        'international',
        'hall',
        'choice',
        'transformation_matrix',
        'origin_shift',
        'rotations',
        'translations',
        'wyckoffs',
        'equivalent_atoms',
        'std_lattice',
        'std_types',
        'std_positions',
        # 'pointgroup_number',
        'pointgroup')
    spg_ds = spg.dataset(lattice, positions, numbers, symprec, angle_tolerance)
    if spg_ds is None:
        _set_error_message()
        return None

    dataset = {}
    for key, data in zip(keys, spg_ds):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['choice'] = dataset['choice'].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()

    _set_error_message()
    return dataset
Beispiel #6
0
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
def get_symmetry_dataset(cell,
                         symprec=1e-5,
                         angle_tolerance=-1.0,
                         hall_number=0):
    """Search symmetry dataset from an input cell.

    Args:
        cell, symprec, angle_tolerance:
            See the docstring of get_symmetry.
        hall_number: If a serial number of Hall symbol (>0) is given,
                     the database corresponding to the Hall symbol is made.

    Return:
        A dictionary is returned. Dictionary keys:
            number (int): International space group number
            international (str): International symbol
            hall (str): Hall symbol
            choice (str): Centring, origin, basis vector setting
            transformation_matrix (3x3 float):
                Transformation matrix from input lattice to standardized
                lattice:
                    L^original = L^standardized * Tmat
            origin shift (3 float):
                Origin shift from standardized to input origin
            rotations (3x3 int), translations (float vector):
                Rotation matrices and translation vectors. Space group
                operations are obtained by
                [(r,t) for r, t in zip(rotations, translations)]
            wyckoffs (n char): Wyckoff letters
            equivalent_atoms (n int): Symmetrically equivalent atoms
            mapping_to_primitive (n int):
                Original cell atom index mapping to primivie cell atom index
            Idealized standardized unit cell:
                std_lattice (3x3 float, row vectors),
                std_positions (Nx3 float), std_types (N int)
            std_rotation_matrix:
                Rigid rotation matrix to rotate from standardized basis
                vectors to idealized standardized basis vectors
                    L^idealized = R * L^standardized
            std_mapping_to_primitive (m int):
                std_positions index mapping to those of primivie cell atoms
            pointgroup (str): Pointgroup symbol

        If it fails, None is returned.

    """
    _set_no_error()

    lattice, positions, numbers, _ = _expand_cell(cell)
    if lattice is None:
        return None

    spg_ds = spg.dataset(lattice, positions, numbers, hall_number, symprec,
                         angle_tolerance)
    if spg_ds is None:
        _set_error_message()
        return None

    keys = (
        'number',
        'hall_number',
        'international',
        'hall',
        'choice',
        'transformation_matrix',
        'origin_shift',
        'rotations',
        'translations',
        'wyckoffs',
        'site_symmetry_symbols',
        'equivalent_atoms',
        'mapping_to_primitive',
        'std_lattice',
        'std_types',
        'std_positions',
        'std_rotation_matrix',
        'std_mapping_to_primitive',
        # 'pointgroup_number',
        'pointgroup')
    dataset = {}
    for key, data in zip(keys, spg_ds):
        dataset[key] = data

    dataset['international'] = dataset['international'].strip()
    dataset['hall'] = dataset['hall'].strip()
    dataset['choice'] = dataset['choice'].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['site_symmetry_symbols'] = [
        s.strip() for s in dataset['site_symmetry_symbols']
    ]
    dataset['equivalent_atoms'] = np.array(dataset['equivalent_atoms'],
                                           dtype='intc')
    dataset['mapping_to_primitive'] = np.array(dataset['mapping_to_primitive'],
                                               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['std_rotation_matrix'] = np.array(dataset['std_rotation_matrix'],
                                              dtype='double',
                                              order='C')
    dataset['std_mapping_to_primitive'] = np.array(
        dataset['std_mapping_to_primitive'], dtype='intc')
    dataset['pointgroup'] = dataset['pointgroup'].strip()

    _set_error_message()
    return dataset