spglib#

Python bindings for C library for finding and handling crystal.

Module Contents#

Classes#

SpglibError

Error message why spglib failed.

Functions#

get_version

Return version number of spglib with tuple of three numbers.

spg_get_version

Get the X.Y.Z version of the detected spglib C library.

spg_get_version_full

Get the full version of the detected spglib C library.

spg_get_commit

Get the commit of the detected spglib C library.

get_symmetry

Find symmetry operations from a crystal structure and site tensors.

get_magnetic_symmetry

Find magnetic symmetry operations from a crystal structure and site tensors.

get_symmetry_dataset

Search symmetry dataset from an input cell.

get_magnetic_symmetry_dataset

Search magnetic symmetry dataset from an input cell. If it fails, return None.

get_spacegroup

Return space group in international table symbol and number as a string.

get_spacegroup_type

Translate Hall number to space group type information. If it fails, return None.

get_spacegroup_type_from_symmetry

Return space-group type information from symmetry operations.

get_magnetic_spacegroup_type

Translate UNI number to magnetic space group type information.

standardize_cell

Return standardized cell. When the search failed, None is returned.

refine_cell

Return refined cell. When the search failed, None is returned.

find_primitive

Primitive cell is searched in the input cell. If it fails, None is returned.

get_symmetry_from_database

Return symmetry operations corresponding to a Hall symbol. If fails, return None.

get_magnetic_symmetry_from_database

Return magnetic symmetry operations from UNI number between 1 and 1651.

get_ir_reciprocal_mesh

Return k-points mesh and k-point map to the irreducible k-points.

delaunay_reduce

Run Delaunay reduction. When the search failed, None is returned.

niggli_reduce

Run Niggli reduction. When the search failed, None is returned.

get_error_message

Return error message why spglib failed.

get_hall_number_from_symmetry

Hall number is obtained from a set of symmetry operations. If fails, return None.

Data#

spglib_error

API#

class spglib.SpglibError#

Error message why spglib failed.

message#

‘no error’

spglib.spglib_error#

‘SpglibError(…)’

spglib.get_version()[source]#

Return version number of spglib with tuple of three numbers.

Added in version 1.8.3.

Deprecated since version 2.3.0: Use spg_get_version() and spglib.__version__ instead

spglib.spg_get_version()[source]#

Get the X.Y.Z version of the detected spglib C library.

Added in version 2.3.0.

Returns:

version string

spglib.spg_get_version_full()[source]#

Get the full version of the detected spglib C library.

Added in version 2.3.0.

Returns:

full version string

spglib.spg_get_commit()[source]#

Get the commit of the detected spglib C library.

Added in version 2.3.0.

Returns:

commit string

spglib.get_symmetry(cell, symprec=1e-05, angle_tolerance=-1.0, mag_symprec=-1.0, is_magnetic=True)[source]#

Find symmetry operations from a crystal structure and site tensors.

Warning

get_symmetry() with is_magnetic=True is deprecated at version 2.0.

Use get_magnetic_symmetry() for magnetic symmetry search.

Parameters#

celltuple

Crystal structure given in tuple. It has to follow the following form, (basis vectors, atomic points, types in integer numbers, …)

  • basis vectorsarray_like

    shape=(3, 3), order=’C’, dtype=’double’

    [[a_x, a_y, a_z],
    [b_x, b_y, b_z],
    [c_x, c_y, c_z]]
    
  • atomic pointsarray_like

    shape=(num_atom, 3), order=’C’, dtype=’double’

    Atomic position vectors with respect to basis vectors, i.e., given in fractional coordinates.

  • typesarray_like

    shape=(num_atom, ), dtype=’intc’

    Integer numbers to distinguish species.

  • optional data :
    case-I: Scalar

    shape=(num_atom, ), dtype=’double’

    Each atomic site has a scalar value. With is_magnetic=True, values are included in the symmetry search in a way of collinear magnetic moments.

    case-II: Vectors

    shape=(num_atom, 3), order=’C’, dtype=’double’

    Each atomic site has a vector. With is_magnetic=True, vectors are included in the symmetry search in a way of non-collinear magnetic moments.

symprecfloat

Symmetry search tolerance in the unit of length.

angle_tolerancefloat

Symmetry search tolerance in the unit of angle deg. Normally it is not recommended to use this argument. See a bit more detail at angle_tolerance. If the value is negative, an internally optimized routine is used to judge symmetry.

mag_symprecfloat

Tolerance for magnetic symmetry search in the unit of magnetic moments. If not specified, use the same value as symprec.

is_magneticbool

When optional data (4th element of cell tuple) is given in case-II, the symmetry search is performed considering magnetic symmetry, which may be corresponding to that for non-collinear calculation. Default is True, but this does nothing unless optional data is supplied.

Returns#

symmetry: dict

Rotation parts and translation parts of symmetry operations are represented with respect to basis vectors. When the search failed, None is returned.

  • ‘rotations’ndarray

    shape=(num_operations, 3, 3), order=’C’, dtype=’intc’

    Rotation (matrix) parts of symmetry operations

  • ‘translations’ndarray

    shape=(num_operations, 3), dtype=’double’

    Translation (vector) parts of symmetry operations

  • ‘time_reversals’: ndarray (exists when the optional data is given)

    shape=(num_operations, ), dtype=’bool_’

    Time reversal part of magnetic symmetry operations. True indicates time reversal operation, and False indicates an ordinary operation.

  • ‘equivalent_atoms’ndarray

    shape=(num_atoms, ), dtype=’intc’

    A mapping table of atoms to symmetrically independent atoms. This is used to find symmetrically equivalent atoms. The numbers contained are the indices of atoms starting from 0, i.e., the first atom is numbered as 0, and then 1, 2, 3, … np.unique(equivalent_atoms) gives representative symmetrically independent atoms. A list of atoms that are symmetrically equivalent to some independent atom (here for example 1 is in equivalent_atom) is found by np.where(equivalent_atom=1)[0].

Notes#

The orders of the rotation matrices and the translation vectors correspond with each other, e.g. , the second symmetry operation is organized by the set of the second rotation matrix and second translation vector in the respective arrays. Therefore a set of symmetry operations may obtained by

[(r, t) for r, t in zip(dataset['rotations'], dataset['translations'])]

The operations are given with respect to the fractional coordinates (not for Cartesian coordinates). The rotation matrix and translation vector are used as follows:

new_vector[3x1] = rotation[3x3] * vector[3x1] + translation[3x1]

The three values in the vector are given for the a, b, and c axes, respectively.

spglib.get_magnetic_symmetry(cell, symprec=1e-05, angle_tolerance=-1.0, mag_symprec=-1.0, is_axial=None, with_time_reversal=True)[source]#

Find magnetic symmetry operations from a crystal structure and site tensors.

Parameters#

celltuple

Crystal structure given either in tuple. In the case given by a tuple, it has to follow the form below,

(basis vectors, atomic points, types in integer numbers, …)

  • basis vectorsarray_like

    shape=(3, 3), order=’C’, dtype=’double’

    [[a_x, a_y, a_z],
    [b_x, b_y, b_z],
    [c_x, c_y, c_z]]
    
  • atomic pointsarray_like

    shape=(num_atom, 3), order=’C’, dtype=’double’

    Atomic position vectors with respect to basis vectors, i.e., given in fractional coordinates.

  • typesarray_like

    shape=(num_atom, ), dtype=’intc’

    Integer numbers to distinguish species.

  • magmoms:
    case-I: Scalar

    shape=(num_atom, ), dtype=’double’

    Each atomic site has a scalar value. With is_magnetic=True, values are included in the symmetry search in a way of collinear magnetic moments.

    case-II: Vectors

    shape=(num_atom, 3), order=’C’, dtype=’double’

    Each atomic site has a vector. With is_magnetic=True, vectors are included in the symmetry search in a way of non-collinear magnetic moments.

symprecfloat

Symmetry search tolerance in the unit of length.

angle_tolerancefloat

Symmetry search tolerance in the unit of angle deg. Normally it is not recommended to use this argument. See a bit more detail at angle_tolerance. If the value is negative, an internally optimized routine is used to judge symmetry.

mag_symprecfloat

Tolerance for magnetic symmetry search in the unit of magnetic moments. If not specified, use the same value as symprec.

is_axial: None or bool

Set is_axial=True if magmoms does not change their sign by improper rotations. If not specified, set is_axial=False when magmoms.shape==(num_atoms, ), and set is_axial=True when magmoms.shape==(num_atoms, 3). These default settings correspond to collinear and non-collinear spins.

with_time_reversal: bool

Set with_time_reversal=True if magmoms change their sign by time-reversal operations. Default is True.

Returns#

symmetry: dict or None

Rotation parts and translation parts of symmetry operations represented with respect to basis vectors and atom index mapping by symmetry operations.

  • ‘rotations’ndarray

    shape=(num_operations, 3, 3), order=’C’, dtype=’intc’

    Rotation (matrix) parts of symmetry operations

  • ‘translations’ndarray

    shape=(num_operations, 3), dtype=’double’

    Translation (vector) parts of symmetry operations

  • ‘time_reversals’: ndarray

    shape=(num_operations, ), dtype=’bool_’

    Time reversal part of magnetic symmetry operations. True indicates time reversal operation, and False indicates an ordinary operation.

  • ‘equivalent_atoms’ndarray

    shape=(num_atoms, ), dtype=’intc’

Notes#

Added in version 2.0.

spglib.get_symmetry_dataset(cell, symprec=1e-05, angle_tolerance=-1.0, hall_number=0)[source]#

Search symmetry dataset from an input cell.

Parameters#

cell, symprec, angle_tolerance:

See get_symmetry().

hall_numberint

If a serial number of Hall symbol (>0) is given, the database corresponding to the Hall symbol is made.

The mapping from Hall symbols to a space-group-type is the many-to-one mapping. Without specifying this option (i.e., in the case of hall_number=0), always the first one (the smallest serial number corresponding to the space-group-type in [list of space groups (Seto’s web site)](https://yseto.net/?page_id=29%3E)) among possible choices and settings is chosen as default. This argument is useful when the other choice (or setting) is expected to be hooked.

This affects to the obtained values of international, hall, choice, transformation_matrix, origin shift, wyckoffs, std_lattice, std_positions, std_types and std_rotation_matrix, but not to rotations and translations since the later set is defined with respect to the basis vectors of user’s input (the cell argument).

See also Space group type.

Returns#

dataset: dict

If it fails, None is returned. Otherwise a dictionary is returned. More details are found at Spglib dataset.

  • numberint

    International space group number.

  • internationalstr

    International symbol.

  • hallstr

    Hall symbol.

  • choicestr

    Centring, origin, basis vector setting.

  • hall_number: int

    Hall number. This number is used in get_symmetry_from_database() and get_spacegroup_type().

  • transformation_matrixndarray

    shape=(3, 3), order=’C’, dtype=’double’

    Transformation matrix from input lattice to standardized lattice:

    L^original = L^standardized * Tmat.
    

    See the detail at Transformation matrix and origin shift.

  • origin shiftndarray

    shape=(3,), dtype=’double’

    Origin shift from standardized to input origin. See the detail at Transformation matrix and origin shift.

  • rotationsndarray

    shape=(n_operations, 3, 3), order=’C’, dtype=’intc’

    Matrix (rotation) parts of space group operations. Space group operations are obtained by

    [(r,t) for r, t in zip(rotations, translations)]
    

    See also get_symmetry().

  • translationsndarray

    shape=(n_operations, 3), order=’C’, dtype=’double’

    Vector (translation) parts of space group operations. Space group operations are obtained by

    [(r,t) for r, t in zip(rotations, translations)]
    

    See also get_symmetry().

  • wyckoffslist[str]

    Wyckoff letters corresponding to the space group type.

  • site_symmetry_symbolslist[str]

    Site symmetry symbols corresponding to the space group type.

  • equivalent_atomsndarray

    shape=(n_atoms,), dtype=’intc’

    Symmetrically equivalent atoms, where ‘symmetrically’ means found symmetry operations. In spglib, symmetry operations are given for the input cell. When a non-primitive cell is inputted and the lattice made by the non-primitive basis vectors breaks its point group, the found symmetry operations may not correspond to the crystallographic space group type.

  • crystallographic_orbitsndarray

    shape=(n_atoms,), dtype=’intc’

    Symmetrically equivalent atoms, where ‘symmetrically’ means the space group operations corresponding to the space group type. This is very similar to equivalent_atoms. See the difference explained in equivalent_atoms

  • Primitive cell :
    • primitive_latticendarray

      shape=(3, 3), order=’C’, dtype=’double’

      Basis vectors a, b, c of a primitive cell in row vectors. This is the primitive cell found inside spglib before applying standardization. Therefore, the values are distorted with respect to found space group type.

    • mapping_to_primitivendarray

      shape=(n_atoms), dtype=’intc’

      Atom index mapping from original cell to the primitive cell of primitive_lattice.

  • Idealized standardized unit cell :
    • std_latticendarray

      shape=(3, 3), order=’C’, dtype=’double’

      Basis vectors a, b, c of a standardized cell in row vectors.

    • std_positionsndarray

      shape=(n_atoms, 3), order=’C’, dtype=’double’

      Positions of atoms in the standardized cell in fractional coordinates.

    • std_typesndarray

      shape=(n_atoms,), dtype=’intc’

      Identity numbers of atoms in the standarzied cell.

  • std_rotation_matrixndarray

    shape=(3, 3), order=’C’, dtype=’double’

    Rigid rotation matrix to rotate from standardized basis vectors to idealized standardized basis vectors. Orthonormalized.

    L^idealized = R * L^standardized.
    

    See the detail at Standardized crystal structure after idealization.

  • std_mapping_to_primitive :

    dtype=’intc’

    std_positions index mapping to those of atoms of the primitive cell in the standardized cell.

  • pointgroupstr

    Pointgroup symbol in Hermann-Mauguin notation.

Notes#

Added in version 1.9.4: The member ‘choice’ is added.

spglib.get_magnetic_symmetry_dataset(cell, is_axial=None, symprec=1e-05, angle_tolerance=-1.0, mag_symprec=-1.0)[source]#

Search magnetic symmetry dataset from an input cell. If it fails, return None.

The description of its keys is given at Magnetic Spglib dataset (Experimental).

Parameters#

cell, is_axial, symprec, angle_tolerance, mag_symprec:

See get_magnetic_symmetry().

Returns#

datasetdict or None

Dictionary keys are as follows:

Magnetic space-group type
  • uni_number: int

    UNI number between 1 to 1651

  • msg_type: int

    Magnetic space groups (MSG) is classified by its family space group (FSG) and maximal space subgroup (XSG). FSG is a non-magnetic space group obtained by ignoring time-reversal term in MSG. XSG is a space group obtained by picking out non time-reversal operations in MSG.

    • msg_type==1 (type-I):

      MSG, XSG, FSG are all isomorphic.

    • msg_type==2 (type-II):

      XSG and FSG are isomorphic, and MSG is generated from XSG and pure time reversal operations.

    • msg_type==3 (type-III):

      XSG is a proper subgroup of MSG with isomorphic translational subgroups.

    • msg_type==4 (type-IV):

      XSG is a proper subgroup of MSG with isomorphic point group.

  • hall_number: int

    For type-I, II, III, Hall number of FSG; for type-IV, that of XSG

  • tensor_rank: int

Magnetic symmetry operations
  • n_operations: int

  • rotations: array, (n_operations, 3, 3)

    Rotation (matrix) parts of symmetry operations

  • translations: array, (n_operations, 3)

    Translation (vector) parts of symmetry operations

  • time_reversals: array, (n_operations, )

    Time reversal part of magnetic symmetry operations. True indicates time reversal operation, and False indicates an ordinary operation.

Equivalent atoms
  • n_atoms: int

  • equivalent_atoms: array

    See the docstring of get_symmetry_dataset

Transformation to standardized setting
  • transformation_matrix: array, (3, 3)

    Transformation matrix from input lattice to standardized

  • origin_shift: array, (3, )

    Origin shift from standardized to input origin

Standardized crystal structure
  • n_std_atoms: int

    Number of atoms in standardized unit cell

  • std_lattice: array, (3, 3)

    Row-wise lattice vectors

  • std_types: array, (n_std_atoms, )

  • std_positions: array, (n_std_atoms, 3)

  • std_tensors: array

    (n_std_atoms, ) for collinear magnetic moments. (n_std_atoms, 3) for vector non-collinear magnetic moments.

  • std_rotation_matrix

    Rigid rotation matrix to rotate from standardized basis vectors to idealized standardized basis vectors

Intermediate data in symmetry search
  • primitive_lattice: array, (3, 3)

Notes#

Added in version 2.0.

spglib.get_spacegroup(cell, symprec=1e-05, angle_tolerance=-1.0, symbol_type=0)[source]#

Return space group in international table symbol and number as a string.

With symbol_type=1, Schoenflies symbol is given instead of international symbol.

If it fails, None is returned.

spglib.get_spacegroup_type(hall_number)[source]#

Translate Hall number to space group type information. If it fails, return None.

This function allows to directly access to the space-group-type database in spglib (spg_database.c). To specify the space group type with a specific choice, hall_number is used. The definition of hall_number is found at Space group type.

Parameters#

hall_numberint

Hall symbol ID.

Returns#

spacegroup_type: dict or None

Dictionary keys are as follows:

  • numberint

    International space group number

  • international_shortstr

    International short symbol. Equivalent to dataset['international'] of get_symmetry_dataset().

  • international_fullstr

    International full symbol.

  • internationalstr

    International symbol.

  • schoenfliesstr

    Schoenflies symbol.

  • hall_numberint

    Hall symbol ID number.

  • hall_symbolstr

    Hall symbol. Equivalent to dataset['hall'] of get_symmetry_dataset,

  • choicestr

    Centring, origin, basis vector setting.

  • pointgroup_international :

    International symbol of crystallographic point group. Equivalent to dataset['pointgroup_symbol'] of get_symmetry_dataset().

  • pointgroup_schoenflies :

    Schoenflies symbol of crystallographic point group.

  • arithmetic_crystal_class_numberint

    Arithmetic crystal class number

  • arithmetic_crystal_class_symbolstr

    Arithmetic crystal class symbol.

Notes#

Added in version 1.9.4.

Changed in version 2.0: hall_number member is added.

spglib.get_spacegroup_type_from_symmetry(rotations, translations, lattice=None, symprec=1e-05)[source]#

Return space-group type information from symmetry operations.

See also get_spacegroup_type() for space-group type information.

This is expected to work well for the set of symmetry operations whose distortion is small. The aim of making this feature is to find space-group-type for the set of symmetry operations given by the other source than spglib. The parameter lattice is used as the distance measure for symprec. If this is not given, the cubic basis vector whose lengths are one is used.

Parameters#

rotationsarray_like

Matrix parts of space group operations. shape=(n_operations, 3, 3), order=’C’, dtype=’intc’

translationsarray_like

Vector parts of space group operations. shape=(n_operations, 3), order=’C’, dtype=’double’

latticearray_like, optional

Basis vectors a, b, c given in row vectors. This is used as the measure of distance. Default is None, which gives unit matrix. shape=(3, 3), order=’C’, dtype=’double’

symprec: float

See get_symmetry().

Returns#

spacegroup_typedict or None

If it fails, None is returned. Otherwise a dictionary is returned. Dictionary keys are as follows:

  • numberint

    International space group number

  • international_shortstr

    International short symbol.

  • international_fullstr

    International full symbol.

  • internationalstr

    International symbol.

  • schoenfliesstr

    Schoenflies symbol.

  • hall_numberint

    Hall symbol ID number.

  • hall_symbolstr

    Hall symbol.

  • choicestr

    Centring, origin, basis vector setting.

  • pointgroup_international :

    International symbol of crystallographic point group.

  • pointgroup_schoenflies :

    Schoenflies symbol of crystallographic point group.

  • arithmetic_crystal_class_numberint

    Arithmetic crystal class number

  • arithmetic_crystal_class_symbolstr

    Arithmetic crystal class symbol.

Notes#

Added in version 2.0.

This is the replacement of get_hall_number_from_symmetry().

spglib.get_magnetic_spacegroup_type(uni_number)[source]#

Translate UNI number to magnetic space group type information.

If fails, return None.

Parameters#

uni_numberint

UNI number between 1 to 1651

Returns#

magnetic_spacegroup_type: dict

See spg_get_magnetic_spacegroup_type for these descriptions.

  • uni_number

  • litvin_number

  • bns_number

  • og_number

  • number

  • type

Notes#

Added in version 2.0.

spglib.standardize_cell(cell, to_primitive=False, no_idealize=False, symprec=1e-05, angle_tolerance=-1.0)[source]#

Return standardized cell. When the search failed, None is returned.

Parameters#

cell, symprec, angle_tolerance:

See the docstring of get_symmetry.

to_primitivebool

If True, the standardized primitive cell is created.

no_idealizebool

If True, it is disabled to idealize lengths and angles of basis vectors and positions of atoms according to crystal symmetry.

Returns#

The standardized unit cell or primitive cell is returned by a tuple of (lattice, positions, numbers). If it fails, None is returned.

Notes#

Added in version 1.8.

Now refine_cell() and find_primitive() are shorthands of this method with combinations of these options. About the default choice of the setting, see the documentation of hall_number argument of get_symmetry_dataset(). More detailed explanation is shown in the spglib (C-API) document.

spglib.refine_cell(cell, symprec=1e-05, angle_tolerance=-1.0)[source]#

Return refined cell. When the search failed, None is returned.

The standardized unit cell is returned by a tuple of (lattice, positions, numbers).

Notes#

Changed in version 1.8.

The detailed control of standardization of unit cell can be done using standardize_cell().

spglib.find_primitive(cell, symprec=1e-05, angle_tolerance=-1.0)[source]#

Primitive cell is searched in the input cell. If it fails, None is returned.

The primitive cell is returned by a tuple of (lattice, positions, numbers).

Notes#

Changed in version 1.8.

The detailed control of standardization of unit cell can be done using standardize_cell().

spglib.get_symmetry_from_database(hall_number)[source]#

Return symmetry operations corresponding to a Hall symbol. If fails, return None.

Parameters#

hall_numberint

The Hall symbol is given by the serial number in between 1 and 530. The definition of hall_number is found at Space group type.

Returns#

symmetrydict
  • rotations

    Rotation parts of symmetry operations corresponding to hall_number.

  • translations

    Translation parts of symmetry operations corresponding to hall_number.

spglib.get_magnetic_symmetry_from_database(uni_number, hall_number=0)[source]#

Return magnetic symmetry operations from UNI number between 1 and 1651.

If fails, return None.

Optionally alternative settings can be specified with Hall number.

Parameters#

uni_numberint

UNI number between 1 and 1651.

hall_numberint, optional

The Hall symbol is given by the serial number in between 1 and 530.

Returns#

symmetrydict
  • ‘rotations’

  • ‘translations’

  • ‘time_reversals’

    0 and 1 indicate ordinary and anti-time-reversal operations, respectively.

Notes#

Added in version 2.0.

spglib.get_ir_reciprocal_mesh(mesh, cell, is_shift=None, is_time_reversal=True, symprec=1e-05, is_dense=False)[source]#

Return k-points mesh and k-point map to the irreducible k-points.

The symmetry is searched from the input cell.

Parameters#

mesharray_like

Uniform sampling mesh numbers. dtype=’intc’, shape=(3,)

cellspglib cell tuple

Crystal structure.

is_shiftarray_like, optional

[0, 0, 0] gives Gamma center mesh and value 1 gives half mesh shift. Default is None which equals to [0, 0, 0]. dtype=’intc’, shape=(3,)

is_time_reversalbool, optional

Whether time reversal symmetry is included or not. Default is True.

symprecfloat, optional

Symmetry tolerance in distance. Default is 1e-5.

is_densebool, optional

grid_mapping_table is returned with dtype=’uintp’ if True. Otherwise its dtype=’intc’. Default is False.

Returns#

grid_mapping_tablendarray

Grid point mapping table to ir-gird-points. dtype=’intc’ or ‘uintp’, shape=(prod(mesh),)

grid_addressndarray

Address of all grid points. dtype=’intc’, shape=(prod(mesh), 3)

spglib.delaunay_reduce(lattice, eps=1e-05)[source]#

Run Delaunay reduction. When the search failed, None is returned.

The transformation from original basis vectors \(( \mathbf{a} \; \mathbf{b} \; \mathbf{c} )\) to final basis vectors \(( \mathbf{a}' \; \mathbf{b}' \; \mathbf{c}' )\) is achieved by linear combination of basis vectors with integer coefficients without rotating coordinates. Therefore the transformation matrix is obtained by \(\mathbf{P} = ( \mathbf{a} \; \mathbf{b} \; \mathbf{c} ) ( \mathbf{a}' \; \mathbf{b}' \; \mathbf{c}' )^{-1}\) and the matrix elements have to be almost integers.

The algorithm is found in the international tables for crystallography volume A.

Parameters#

lattice: ndarray, (3, 3)

Lattice parameters in the form of

[[a_x, a_y, a_z],
    [b_x, b_y, b_z],
    [c_x, c_y, c_z]]
eps: float

Tolerance parameter, but unlike symprec the unit is not a length. Tolerance to check if volume is close to zero or not and if two basis vectors are orthogonal by the value of dot product being close to zero or not.

Returns#

delaunay_lattice: ndarray, (3, 3)

Reduced lattice parameters are given as a numpy ‘double’ array:

[[a_x, a_y, a_z],
 [b_x, b_y, b_z],
 [c_x, c_y, c_z]]

Notes#

Added in version 1.9.4.

spglib.niggli_reduce(lattice, eps=1e-05)[source]#

Run Niggli reduction. When the search failed, None is returned.

The transformation from original basis vectors \(( \mathbf{a} \; \mathbf{b} \; \mathbf{c} )\) to final basis vectors \(( \mathbf{a}' \; \mathbf{b}' \; \mathbf{c}' )\) is achieved by linear combination of basis vectors with integer coefficients without rotating coordinates. Therefore the transformation matrix is obtained by \(\mathbf{P} = ( \mathbf{a} \; \mathbf{b} \; \mathbf{c} ) ( \mathbf{a}' \; \mathbf{b}' \; \mathbf{c}' )^{-1}\) and the matrix elements have to be almost integers.

The algorithm detail is found at https://atztogo.github.io/niggli/ and the references are there in.

Parameters#

lattice: ndarray

Lattice parameters in the form of

[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]
eps: float

Tolerance parameter, but unlike symprec the unit is not a length. This is used to check if difference of norms of two basis vectors is close to zero or not and if two basis vectors are orthogonal by the value of dot product being close to zero or not. The detail is shown at https://atztogo.github.io/niggli/.

Returns#

niggli_lattice: ndarray, (3, 3)
if the Niggli reduction succeeded:

Reduced lattice parameters are given as a numpy ‘double’ array:

[[a_x, a_y, a_z],
[b_x, b_y, b_z],
[c_x, c_y, c_z]]

otherwise None is returned.

Notes#

Added in version 1.9.4.

spglib.get_error_message()[source]#

Return error message why spglib failed.

Warning

This method is not thread safe, i.e., only safely usable when calling one spglib method per process.

Notes#

Added in version 1.9.5.

spglib.get_hall_number_from_symmetry(rotations, translations, symprec=1e-05)[source]#

Hall number is obtained from a set of symmetry operations. If fails, return None.

Deprecated since version 2.0: Replaced by {func}`get_spacegroup_type_from_symmetry`.

Return one of hall_number corresponding to a space-group type of the given set of symmetry operations. When multiple hall_number exist for the space-group type, the smallest one (the first description of the space-group type in International Tables for Crystallography) is chosen. The definition of hall_number is found at Space group type and the corresponding space-group-type information is obtained through {func}`get_spacegroup_type`.

This is expected to work well for the set of symmetry operations whose distortion is small. The aim of making this feature is to find space-group-type for the set of symmetry operations given by the other source than spglib.

Note that the definition of symprec is different from usual one, but is given in the fractional coordinates and so it should be small like 1e-5.