pymatgen.core.operations module¶
This module provides classes that operate on points or vectors in 3D space.
-
class
MagSymmOp
(affine_transformation_matrix: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], time_reversal: int, tol: float = 0.01)[source]¶ Bases:
pymatgen.core.operations.SymmOp
Thin wrapper around SymmOp to extend it to support magnetic symmetry by including a time reversal operator. Magnetic symmetry is similar to conventional crystal symmetry, except symmetry is reduced by the addition of a time reversal operator which acts on an atom’s magnetic moment.
Initializes the MagSymmOp from a 4x4 affine transformation matrix and time reversal operator. In general, this constructor should not be used unless you are transferring rotations. Use the static constructors instead to generate a SymmOp from proper rotations and translation.
- Parameters
affine_transformation_matrix (4x4 array) – Representing an affine transformation.
time_reversal (int) – 1 or -1
tol (float) – Tolerance for determining if matrices are equal.
-
as_xyzt_string
() → str[source]¶ Returns a string of the form ‘x, y, z, +1’, ‘-x, -y, z, -1’, ‘-y+1/2, x+1/2, z+1/2, +1’, etc. Only works for integer rotation matrices
-
classmethod
from_dict
(d: dict) → pymatgen.core.operations.MagSymmOp[source]¶ - Parameters
d – dict
- Returns
MagneticSymmOp from dict representation.
-
static
from_rotation_and_translation_and_time_reversal
(rotation_matrix: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = ((1, 0, 0), (0, 1, 0), (0, 0, 1)), translation_vec: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0), time_reversal: int = 1, tol: float = 0.1) → pymatgen.core.operations.MagSymmOp[source]¶ Creates a symmetry operation from a rotation matrix, translation vector and time reversal operator.
- Parameters
rotation_matrix (3x3 array) – Rotation matrix.
translation_vec (3x1 array) – Translation vector.
time_reversal (int) – Time reversal operator, +1 or -1.
tol (float) – Tolerance to determine if rotation matrix is valid.
- Returns
MagSymmOp object
-
classmethod
from_symmop
(symmop, time_reversal) → pymatgen.core.operations.MagSymmOp[source]¶ Initialize a MagSymmOp from a SymmOp and time reversal operator.
- Parameters
symmop (SymmOp) – SymmOp
time_reversal (int) – Time reversal operator, +1 or -1.
- Returns
MagSymmOp object
-
static
from_xyzt_string
(xyzt_string: str) → pymatgen.core.operations.MagSymmOp[source]¶ - Parameters
xyz_string – string of the form ‘x, y, z, +1’, ‘-x, -y, z, -1’, ‘-2y+1/2, 3x+1/2, z-y+1/2, +1’, etc.
- Returns
MagSymmOp object
-
operate_magmom
(magmom)[source]¶ Apply time reversal operator on the magnetic moment. Note that magnetic moments transform as axial vectors, not polar vectors.
See ‘Symmetry and magnetic structures’, Rodríguez-Carvajal and Bourée for a good discussion. DOI: 10.1051/epjconf/20122200010
- Parameters
magmom – Magnetic moment as electronic_structure.core.Magmom
or as list or np array-like (class) –
- Returns
Magnetic moment after operator applied as Magmom class
-
class
SymmOp
(affine_transformation_matrix: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], tol=0.01)[source]¶ Bases:
monty.json.MSONable
A symmetry operation in cartesian space. Consists of a rotation plus a translation. Implementation is as an affine transformation matrix of rank 4 for efficiency. Read: http://en.wikipedia.org/wiki/Affine_transformation.
-
affine_matrix
¶ A 4x4 numpy.array representing the symmetry operation.
Initializes the SymmOp from a 4x4 affine transformation matrix. In general, this constructor should not be used unless you are transferring rotations. Use the static constructors instead to generate a SymmOp from proper rotations and translation.
- Parameters
affine_transformation_matrix (4x4 array) – Representing an affine transformation.
tol (float) – Tolerance for determining if matrices are equal.
-
apply_rotation_only
(vector: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray])[source]¶ Vectors should only be operated by the rotation matrix and not the translation vector.
- Parameters
vector (3x1 array) – A vector.
Checks if two points are symmetrically related.
- Parameters
point_a (3x1 array) – First point.
point_b (3x1 array) – Second point.
tol (float) – Absolute tolerance for checking distance.
- Returns
True if self.operate(point_a) == point_b or vice versa.
-
as_xyz_string
() → str[source]¶ Returns a string of the form ‘x, y, z’, ‘-x, -y, z’, ‘-y+1/2, x+1/2, z+1/2’, etc. Only works for integer rotation matrices
-
static
from_axis_angle_and_translation
(axis: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], angle: float, angle_in_radians: bool = False, translation_vec: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0)) → pymatgen.core.operations.SymmOp[source]¶ Generates a SymmOp for a rotation about a given axis plus translation.
- Parameters
axis – The axis of rotation in cartesian space. For example, [1, 0, 0]indicates rotation about x-axis.
angle (float) – Angle of rotation.
angle_in_radians (bool) – Set to True if angles are given in radians. Or else, units of degrees are assumed.
translation_vec – A translation vector. Defaults to zero.
- Returns
SymmOp for a rotation about given axis and translation.
-
classmethod
from_dict
(d) → pymatgen.core.operations.SymmOp[source]¶ - Parameters
d – dict
- Returns
SymmOp from dict representation.
-
static
from_origin_axis_angle
(origin: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], axis: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], angle: float, angle_in_radians: bool = False) → pymatgen.core.operations.SymmOp[source]¶ Generates a SymmOp for a rotation about a given axis through an origin.
- Parameters
origin (3x1 array) – The origin which the axis passes through.
axis (3x1 array) – The axis of rotation in cartesian space. For example, [1, 0, 0]indicates rotation about x-axis.
angle (float) – Angle of rotation.
angle_in_radians (bool) – Set to True if angles are given in radians. Or else, units of degrees are assumed.
- Returns
SymmOp.
-
static
from_rotation_and_translation
(rotation_matrix: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = ((1, 0, 0), (0, 1, 0), (0, 0, 1)), translation_vec: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0), tol=0.1)[source]¶ Creates a symmetry operation from a rotation matrix and a translation vector.
- Parameters
rotation_matrix (3x3 array) – Rotation matrix.
translation_vec (3x1 array) – Translation vector.
tol (float) – Tolerance to determine if rotation matrix is valid.
- Returns
SymmOp object
-
static
from_xyz_string
(xyz_string: str) → pymatgen.core.operations.SymmOp[source]¶ - Parameters
xyz_string – string of the form ‘x, y, z’, ‘-x, -y, z’, ‘-2y+1/2, 3x+1/2, z-y+1/2’, etc.
- Returns
SymmOp
-
property
inverse
¶ Returns inverse of transformation.
-
static
inversion
(origin: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0)) → pymatgen.core.operations.SymmOp[source]¶ Inversion symmetry operation about axis.
- Parameters
origin (3x1 array) – Origin of the inversion operation. Defaults to [0, 0, 0].
- Returns
SymmOp representing an inversion operation about the origin.
-
operate
(point)[source]¶ Apply the operation on a point.
- Parameters
point – Cartesian coordinate.
- Returns
Coordinates of point after operation.
-
operate_multi
(points)[source]¶ Apply the operation on a list of points.
- Parameters
points – List of Cartesian coordinates
- Returns
Numpy array of coordinates after operation
-
static
reflection
(normal: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], origin: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0)) → pymatgen.core.operations.SymmOp[source]¶ Returns reflection symmetry operation.
- Parameters
normal (3x1 array) – Vector of the normal to the plane of reflection.
origin (3x1 array) – A point in which the mirror plane passes through.
- Returns
SymmOp for the reflection about the plane
-
property
rotation_matrix
¶ A 3x3 numpy.array representing the rotation matrix.
-
static
rotoreflection
(axis: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray], angle: float, origin: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray] = (0, 0, 0)) → pymatgen.core.operations.SymmOp[source]¶ Returns a roto-reflection symmetry operation
- Parameters
axis (3x1 array) – Axis of rotation / mirror normal
angle (float) – Angle in degrees
origin (3x1 array) – Point left invariant by roto-reflection. Defaults to (0, 0, 0).
- Returns
Roto-reflection operation
-
transform_tensor
(tensor: numpy.ndarray)[source]¶ Applies rotation portion to a tensor. Note that tensor has to be in full form, not the Voigt form.
- Parameters
tensor (numpy array) – a rank n tensor
- Returns
Transformed tensor.
-
property
translation_vector
¶ A rank 1 numpy.array of dim 3 representing the translation vector.
-