pyxtal.tolerance module

class pyxtal.tolerance.Tol_matrix(*tuples, prototype='atomic', factor=1.0)[source]

Bases: object

Class for variable distance tolerance checking. Used within random_crystal and molecular_crystal to verify whether atoms are too close. Stores a matrix of atom-atom pair tolerances. Note that the matrix’s indices correspond to atomic numbers, with the 0th entries being 0 (there is no atomic number 0).

Parameters:
  • prototype – a string representing the type of radii to use (atomic, molecular, vdW or metallic)

  • factor – a float to scale the distances by.

  • tuples – a list or tuple of tuples, which define custom tolerance values. Each tuple should be of the form (specie1, specie2, value), where value is the tolerance in Angstroms, and specie1 and specie2 can be strings, integers, Element objects, or pymatgen Specie objects. Custom values may also be set using set_tol

classmethod from_file(filename)[source]
classmethod from_matrix(matrix, prototype='atomic', factor=1.0, begin_with=0)[source]

Given a tolerance matrix, returns a Tol_matrix object. Matrix indices correspond to the atomic number (with 0 pointing to Hydrogen by default). For atoms with atomic numbers not included in the matrix, the default value (specified by prototype) will be used, up to element 96. Note that if the matrix is asymmetric, only the value below the diagonal will be used.

Parameters:
  • matrix – a 2D matrix or list of tolerances between atomic species pairs. The indices correspond to atomic species (see begin_with variable description)

  • prototype – a string representing the type of radii to use (“atomic”, “molecular”)

  • factor – a float to scale the distances by. A smaller value means a smaller tolerance for distance checking

  • begin_with – the index which points to Hydrogen within the matrix. Default 0

Returns:

a Tol_matrix object

classmethod from_radii(radius_list, prototype='atomic', factor=1.0, begin_with=0)[source]

Given a list of atomic radii, returns a Tol_matrix object. For atom-atom pairs, uses the average radii of the two species as the tolerance value. For atoms with atomic numbers not in the radius list, the default value (specified by prototype) will be used, up to element 96.

Parameters:
  • radius_list – a list of atomic radii (in Angstroms), beginning with Hydrogen

  • prototype – a string representing the type of radii to use (“atomic”, “molecular”)

  • factor – a float to scale the distances by. A smaller value means a smaller tolerance for distance checking

  • begin_with – the index which points to Hydrogen within the list. Default 0

Returns:

a Tol_matrix object

classmethod from_single_value(value)[source]

Creates a Tol_matrix which only has a single tolerance value. Using get_tol will always return the same value.

Parameters:

value – the tolerance value to use

Returns:

a Tol_matrix object

get_tol(specie1, specie2)[source]

Returns the tolerance between two species.

Parameters:

specie1/2 – atomic number (int or float), name (str), symbol (str), an Element object, or a pymatgen Specie object

Returns:

the tolerance between the provided pair of atomic species

set_tol(specie1, specie2, value)[source]

Sets the distance tolerance between two species.

Parameters:
  • specie1/2 – atomic number (int or float), name (str), symbol (str), an Element object, or a pymatgen Specie object

  • value – the tolerance (in Angstroms) to set to

to_file(filename=None)[source]

Creates a file with the given filename.

Parameters:

filename – the file path

Returns:

Nothing. Creates a file at the specified path