structure_comp package¶
Submodules¶
structure_comp.comparators module¶
structure_comp.remove_duplicates module¶
structure_comp.rmsd module¶
-
structure_comp.rmsd.
attempt_supercell
(atoms1, atoms2)¶ Checks if the lattice vectors of one cell are integer multiples of the other cell. For this to be meaningful, the lattices should be Niggli reduced.
To get the order of the check correct without to many checks, we use the volume. :param atoms1: :type atoms1: ase atoms object :param atoms2: :type atoms2: ase atoms object
Returns:
-
structure_comp.rmsd.
centroid
(X)¶ Centroid is the mean position of all the points in all of the coordinate directions, from a vectorset X.
https://en.wikipedia.org/wiki/Centroid
C = sum(X)/len(X)
- Parameters
X (array) – (N,D) matrix, where N is points and D is dimension.
- Returns
C – centroid
- Return type
float
-
structure_comp.rmsd.
hungarian
(A, B)¶ Hungarian reordering. Assume A and B are coordinates for atoms of SAME type only
-
structure_comp.rmsd.
kabsch
(P, Q)¶ Using the Kabsch algorithm with two sets of paired point P and Q, centered around the centroid. Each vector set is represented as an NxD matrix, where D is the the dimension of the space.
The algorithm works in three steps: - a centroid translation of P and Q (assumed done before this function
call)
the computation of a covariance matrix C
computation of the optimal rotation matrix U
For more info see http://en.wikipedia.org/wiki/Kabsch_algorithm
- Parameters
P (array) – (N,D) matrix, where N is points and D is dimension.
Q (array) – (N,D) matrix, where N is points and D is dimension.
- Returns
U – Rotation matrix (D,D)
- Return type
matrix
-
structure_comp.rmsd.
kabsch_rmsd
(P, Q, translate=False)¶ Rotate matrix P unto Q using Kabsch algorithm and calculate the RMSD.
- Parameters
P (array) – (N,D) matrix, where N is points and D is dimension.
Q (array) – (N,D) matrix, where N is points and D is dimension.
translate (bool) – Use centroids to translate vector P and Q unto each other.
- Returns
rmsd – root-mean squared deviation
- Return type
float
-
structure_comp.rmsd.
kabsch_rotate
(P, Q)¶ Rotate matrix P unto matrix Q using Kabsch algorithm.
- Parameters
P (array) – (N,D) matrix, where N is points and D is dimension.
Q (array) – (N,D) matrix, where N is points and D is dimension.
- Returns
P – (N,D) matrix, where N is points and D is dimension, rotated
- Return type
array
-
structure_comp.rmsd.
parse_periodic_case
(file_1, file_2, try_supercell: bool = True, pymatgen: bool = False, get_reduced_structure: bool = True)¶ - Parser for periodic structures, handles two possible cases:
Structures are supercells (within tolerance), then one cell is multiplied by the scaling factors
(2) Structures are not supercells of each other, then we rescale on cell to the volume of the other cell to make sure we have meaningful comparisons.
- Parameters
file_1 (str/pymatgen structure object) – path to first file, in on format that ASE can parse, pymatgen structure object in case pymatgen=True
file_2 (str/pymatgen structure object) – path to second file, pymatgen structure object in case pymatgen=True
try_supercell (bool) – if true, we attempt to build a supercell, default: True
pymatgen (bool) – if true, then file_1 and file_2 take pymatgen structure objects
get_reduced_structure (bool) – if true (default) it gets the Niggli reduced cell.
- Returns
atomic symbols (list), cartesian positions (list) of structure 1, atomic symbols (list), cartesian positions (list) of structure 2
-
structure_comp.rmsd.
reorder_hungarian
(p_atoms, q_atoms, p_coord, q_coord)¶ Re-orders the input atom list and xyz coordinates using the Hungarian method (using optimized column results) :param p_atoms: (N,1) matrix, where N is points holding the atoms’ names :type p_atoms: array :param p_atoms: (N,1) matrix, where N is points holding the atoms’ names :type p_atoms: array :param p_coord: (N,D) matrix, where N is points and D is dimension :type p_coord: array :param q_coord: (N,D) matrix, where N is points and D is dimension :type q_coord: array
- Returns
view_reorder – (N,1) matrix, reordered indexes of atom alignment based on the coordinates of the atoms
- Return type
array
-
structure_comp.rmsd.
rescale_periodic_system
(atoms1, atoms2)¶ Scales two periodic systems to the same size. Not the most efficient implementation yet.
For a first implementation, I assume that the number of atoms in both cells is the same. Later, I will create supercells to fix this.
- Parameters
atoms1 (ASE atoms object) –
atoms2 (ASE atoms object) –
- Returns
atoms1_copy (ASE atoms object)
atoms2 (ASE atoms object)
-
structure_comp.rmsd.
rmsd
(V: numpy.array, W: numpy.array)¶ Calculate Root-mean-square deviation from two sets of vectors V and W.
- Parameters
V (array) – (N,D) matrix, where N is points and D is dimension.
W (array) – (N,D) matrix, where N is points and D is dimension.
- Returns
rmsd – Root-mean-square deviation between the two vectors
- Return type
float