# pymatgen.core.operations module¶

class MagSymmOp(affine_transformation_matrix, time_reversal, tol=0.01)[source]

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_dict()[source]
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]
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. 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. 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. 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) – 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.

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)[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. True if self.operate(point_a) == point_b or vice versa.
as_dict()[source]
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. SymmOp for a rotation about given axis and translation.
classmethod from_dict(d)[source]
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. 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. 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. SymmOp
inverse

Returns inverse of transformation.

static inversion(origin=(0, 0, 0))[source]

Parameters: origin (3x1 array) – Origin of the inversion operation. Defaults to [0, 0, 0]. SymmOp representing an inversion operation about the origin.
operate(point)[source]

Apply the operation on a point.

Parameters: point – Cartesian coordinate. Coordinates of point after operation.
operate_multi(points)[source]

Apply the operation on a list of points.

Parameters: points – List of Cartesian coordinates 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. SymmOp for the reflection about the plane
rotation_matrix

A 3x3 numpy.array representing the rotation matrix.

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). Roto-reflection operation
transform_tensor(tensor)[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 Transformed tensor.
translation_vector

A rank 1 numpy.array of dim 3 representing the translation vector.