pymatgen.core.operations module¶
This module provides classes that operate on points or vectors in 3D space.
-
class
MagSymmOp
(affine_transformation_matrix, time_reversal, tol=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
()[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)[source]¶ - Parameters
d – dict
- Returns
MagneticSymmOp from dict representation.
-
static
from_rotation_and_translation_and_time_reversal
(rotation_matrix=1, 0, 0, 0, 1, 0, 0, 0, 1, translation_vec=0, 0, 0, time_reversal=1, tol=0.1)[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)[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)[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, 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.
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)[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
()[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, angle, angle_in_radians=False, translation_vec=0, 0, 0)[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.
-
static
from_origin_axis_angle
(origin, axis, angle, angle_in_radians=False)[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=1, 0, 0, 0, 1, 0, 0, 0, 1, translation_vec=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)[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
-
static
inversion
(origin=0, 0, 0)[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, origin=0, 0, 0)[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
-
static
rotoreflection
(axis, angle, origin=0, 0, 0)[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