ipymd.data_input.spacegroup package¶
Submodules¶
ipymd.data_input.spacegroup.cell module¶
-
ipymd.data_input.spacegroup.cell.
cell_to_cellpar
(cell)[source]¶ Returns the cell parameters [a, b, c, alpha, beta, gamma] as a numpy array.
-
ipymd.data_input.spacegroup.cell.
cellpar_to_cell
(cellpar, ab_normal=(0, 0, 1), a_direction=None)[source]¶ Return a 3x3 cell matrix from cellpar = [a, b, c, alpha, beta, gamma]. The returned cell is orientated such that a and b are normal to ab_normal and a is parallel to the projection of a_direction in the a-b plane.
Default a_direction is (1,0,0), unless this is parallel to ab_normal, in which case default a_direction is (0,0,1).
The returned cell has the vectors va, vb and vc along the rows. The cell will be oriented such that va and vb are normal to ab_normal and va will be along the projection of a_direction onto the a-b plane.
Example:
>>> cell = cellpar_to_cell([1, 2, 4, 10, 20, 30], (0,1,1), (1,2,3)) >>> np.round(cell, 3) array([[ 0.816, -0.408, 0.408], [ 1.992, -0.13 , 0.13 ], [ 3.859, -0.745, 0.745]])
ipymd.data_input.spacegroup.spacegroup module¶
Definition of the Spacegroup class.
This module only depends on NumPy and the space group database.
-
class
ipymd.data_input.spacegroup.spacegroup.
Spacegroup
(spacegroup, setting=1, datafile=None)[source]¶ Bases:
object
Returns a new Spacegroup instance.
Parameters:
- spacegroup : int | string | Spacegroup instance
- The space group number in International Tables of Crystallography or its Hermann-Mauguin symbol. E.g. spacegroup=225 and spacegroup=’F m -3 m’ are equivalent.
- setting : 1 | 2
- Some space groups have more than one setting. setting determines Which of these should be used.
- datafile : None | string
- Path to database file. If None, the the default database will be used.
-
__eq__
(other)[source]¶ Chech whether self and other refer to the same spacegroup number and setting.
-
__str__
()[source]¶ Return a string representation of the space group data in the same format as found the database.
-
centrosymmetric
¶ Whether a center of symmetry exists.
-
equivalent_reflections
(hkl)[source]¶ Return all equivalent reflections to the list of Miller indices in hkl.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.equivalent_reflections([[0, 0, 2]]) array([[ 0, 0, -2], [ 0, -2, 0], [-2, 0, 0], [ 2, 0, 0], [ 0, 2, 0], [ 0, 0, 2]])
-
equivalent_sites
(scaled_positions, ondublicates='error', symprec=0.001)[source]¶ Returns the scaled positions and all their equivalent sites.
Parameters:
- scaled_positions: list | array
- List of non-equivalent sites given in unit cell coordinates.
- ondublicates : ‘keep’ | ‘replace’ | ‘warn’ | ‘error’
Action if scaled_positions contain symmetry-equivalent positions:
- ‘keep’
- ignore additional symmetry-equivalent positions
- ‘replace’
- replace
- ‘warn’
- like ‘keep’, but issue an UserWarning
- ‘error’
- raises a SpacegroupValueError
- symprec: float
- Minimum “distance” betweed two sites in scaled coordinates before they are counted as the same site.
Returns:
- sites: array
- A NumPy array of equivalent sites.
- kinds: list
- A list of integer indices specifying which input site is equivalent to the corresponding returned site.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sites, kinds = sg.equivalent_sites([[0, 0, 0], [0.5, 0.0, 0.0]]) >>> sites array([[ 0. , 0. , 0. ], [ 0. , 0.5, 0.5], [ 0.5, 0. , 0.5], [ 0.5, 0.5, 0. ], [ 0.5, 0. , 0. ], [ 0. , 0.5, 0. ], [ 0. , 0. , 0.5], [ 0.5, 0.5, 0.5]]) >>> kinds [0, 0, 0, 0, 1, 1, 1, 1]
-
get_op
()[source]¶ Returns all symmetry operations (including inversions and subtranslations), but unlike get_symop(), they are returned as two ndarrays.
-
get_symop
()[source]¶ Returns all symmetry operations (including inversions and subtranslations) as a sequence of (rotation, translation) tuples.
-
lattice
¶ Lattice type: P primitive I body centering, h+k+l=2n F face centering, h,k,l all odd or even A,B,C single face centering, k+l=2n, h+l=2n, h+k=2n R rhombohedral centering, -h+k+l=3n (obverse); h-k+l=3n (reverse)
-
no
¶ Space group number in International Tables of Crystallography.
-
nsubtrans
¶ Number of cell-subtranslation vectors.
-
nsymop
¶ Total number of symmetry operations.
-
reciprocal_cell
¶ Tree Miller indices that span all kinematically non-forbidden reflections as a matrix with the Miller indices along the rows.
-
rotations
¶ Symmetry rotation matrices. The invertions are not included for centrosymmetrical crystals.
-
scaled_primitive_cell
¶ Primitive cell in scaled coordinates as a matrix with the primitive vectors along the rows.
-
setting
¶ Space group setting. Either one or two.
-
subtrans
¶ Translations vectors belonging to cell-sub-translations.
-
symbol
¶ Hermann-Mauguin (or international) symbol for the space group.
-
symmetry_normalised_reflections
(hkl)[source]¶ Returns an array of same size as hkl, containing the corresponding symmetry-equivalent reflections of lowest indices.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.symmetry_normalised_reflections([[2, 0, 0], [0, 2, 0]]) array([[ 0, 0, -2], [ 0, 0, -2]])
-
symmetry_normalised_sites
(scaled_positions)[source]¶ Returns an array of same size as scaled_positions, containing the corresponding symmetry-equivalent sites within the unit cell of lowest indices.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.symmetry_normalised_sites([[0.0, 0.5, 0.5], [1.0, 1.0, 0.0]]) array([[ 0., 0., 0.], [ 0., 0., 0.]])
-
tag_sites
(scaled_positions, symprec=0.001)[source]¶ Returns an integer array of the same length as scaled_positions, tagging all equivalent atoms with the same index.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.tag_sites([[0.0, 0.0, 0.0], ... [0.5, 0.5, 0.0], ... [1.0, 0.0, 0.0], ... [0.5, 0.0, 0.0]]) array([0, 0, 0, 1])
-
translations
¶ Symmetry translations. The invertions are not included for centrosymmetrical crystals.
-
unique_reflections
(hkl)[source]¶ Returns a subset hkl containing only the symmetry-unique reflections.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.unique_reflections([[ 2, 0, 0], ... [ 0, -2, 0], ... [ 2, 2, 0], ... [ 0, -2, -2]]) array([[2, 0, 0], [2, 2, 0]])
-
unique_sites
(scaled_positions, symprec=0.001, output_mask=False)[source]¶ Returns a subset of scaled_positions containing only the symmetry-unique positions. If output_mask is True, a boolean array masking the subset is also returned.
Example:
>>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.unique_sites([[0.0, 0.0, 0.0], ... [0.5, 0.5, 0.0], ... [1.0, 0.0, 0.0], ... [0.5, 0.0, 0.0]]) array([[ 0. , 0. , 0. ], [ 0.5, 0. , 0. ]])