def symmetry_ops(self): """ Retrieve magnetic symmetry operations of the space group. :return: List of :class:`pymatgen.core.operations.MagSymmOp` """ ops = [op_data['op'] for op_data in self._data['bns_operators']] # add lattice centerings centered_ops = [] lattice_vectors = [l['vector'] for l in self._data['bns_lattice']] for vec in lattice_vectors: if not (np.array_equal(vec, [1, 0, 0]) or np.array_equal(vec, [0, 1, 0]) or np.array_equal(vec, [0, 0, 1])): for op in ops: new_vec = op.translation_vector + vec new_op = MagSymmOp.from_rotation_and_translation_and_time_reversal(op.rotation_matrix, translation_vec=new_vec, time_reversal=op.time_reversal) centered_ops.append(new_op) ops = ops+centered_ops return ops
def _parse_operators(b): '''Parses compact binary representation into list of MagSymmOps.''' if len(b) == 0: # e.g. if magtype != 4, OG setting == BNS setting, and b == [] for OG symmops return None raw_symops = [b[i:i+6] for i in range(0, len(b), 6)] symops = [] for r in raw_symops: point_operator = _get_point_operator(r[0]) translation_vec = [r[1]/r[4], r[2]/r[4], r[3]/r[4]] time_reversal = r[5] op = MagSymmOp.from_rotation_and_translation_and_time_reversal(rotation_matrix=point_operator['matrix'], translation_vec=translation_vec, time_reversal=time_reversal) # store string representation, e.g. (2x|1/2,1/2,1/2)' seitz = '({0}|{1},{2},{3})'.format(point_operator['symbol'], Fraction(translation_vec[0]), Fraction(translation_vec[1]), Fraction(translation_vec[2])) if time_reversal == -1: seitz += '\'' symops.append({'op': op, 'str': seitz}) return symops
def transform_symmop( self, symmop: Union[SymmOp, MagSymmOp]) -> Union[SymmOp, MagSymmOp]: """ Takes a symmetry operation and transforms it. :param symmop: SymmOp or MagSymmOp :return: """ W = symmop.rotation_matrix w = symmop.translation_vector Q = np.linalg.inv(self.P) W_ = np.matmul(np.matmul(Q, W), self.P) I = np.identity(3) w_ = np.matmul(Q, (w + np.matmul(W - I, self.p))) w_ = np.mod(w_, 1.0) if isinstance(symmop, MagSymmOp): return MagSymmOp.from_rotation_and_translation_and_time_reversal( rotation_matrix=W_, translation_vec=w_, time_reversal=symmop.time_reversal, tol=symmop.tol, ) if isinstance(symmop, SymmOp): return SymmOp.from_rotation_and_translation(rotation_matrix=W_, translation_vec=w_, tol=symmop.tol) raise RuntimeError
def symmetry_ops(self): """ Retrieve magnetic symmetry operations of the space group. :return: List of :class:`pymatgen.core.operations.MagSymmOp` """ ops = [op_data["op"] for op_data in self._data["bns_operators"]] # add lattice centerings centered_ops = [] lattice_vectors = [l["vector"] for l in self._data["bns_lattice"]] for vec in lattice_vectors: if not (np.array_equal(vec, [1, 0, 0]) or np.array_equal( vec, [0, 1, 0]) or np.array_equal(vec, [0, 0, 1])): for op in ops: new_vec = op.translation_vector + vec new_op = MagSymmOp.from_rotation_and_translation_and_time_reversal( op.rotation_matrix, translation_vec=new_vec, time_reversal=op.time_reversal, ) centered_ops.append(new_op) ops = ops + centered_ops # apply jones faithful transformation ops = [self.jf.transform_symmop(op) for op in ops] return ops
def _parse_operators(b): """Parses compact binary representation into list of MagSymmOps.""" if len( b ) == 0: # e.g. if magtype != 4, OG setting == BNS setting, and b == [] for OG symmops return None raw_symops = [b[i:i + 6] for i in range(0, len(b), 6)] symops = [] for r in raw_symops: point_operator = _get_point_operator(r[0]) translation_vec = [r[1] / r[4], r[2] / r[4], r[3] / r[4]] time_reversal = r[5] op = MagSymmOp.from_rotation_and_translation_and_time_reversal( rotation_matrix=point_operator["matrix"], translation_vec=translation_vec, time_reversal=time_reversal, ) # store string representation, e.g. (2x|1/2,1/2,1/2)' seitz = "({0}|{1},{2},{3})".format( point_operator["symbol"], Fraction(translation_vec[0]), Fraction(translation_vec[1]), Fraction(translation_vec[2]), ) if time_reversal == -1: seitz += "'" symops.append({"op": op, "str": seitz}) return symops
def symmetry_ops(self): """ Retrieve magnetic symmetry operations of the space group. :return: List of :class:`pymatgen.core.operations.MagSymmOp` """ ops = [op_data['op'] for op_data in self._data['bns_operators']] # add lattice centerings centered_ops = [] lattice_vectors = [l['vector'] for l in self._data['bns_lattice']] for vec in lattice_vectors: if not (np.array_equal(vec, [1, 0, 0]) or np.array_equal( vec, [0, 1, 0]) or np.array_equal(vec, [0, 0, 1])): for op in ops: new_vec = op.translation_vector + vec new_op = MagSymmOp.from_rotation_and_translation_and_time_reversal( op.rotation_matrix, translation_vec=new_vec, time_reversal=op.time_reversal) centered_ops.append(new_op) ops = ops + centered_ops return ops
def transform_symmop(self, symmop): # type: (Union[SymmOp, MagSymmOp]) -> Union[SymmOp, MagSymmOp] """ Takes a symmetry operation and transforms it. :param symmop: SymmOp or MagSymmOp :return: """ W = symmop.rotation_matrix w = symmop.translation_vector Q = np.linalg.inv(self.P) W_ = np.matmul(np.matmul(Q, W), self.P) I = np.identity(3) w_ = np.matmul(Q, (w + np.matmul(W - I, self.p))) if isinstance(symmop, MagSymmOp): return MagSymmOp.from_rotation_and_translation_and_time_reversal(rotation_matrix=W_, translation_vec=w_, time_reversal=symmop.time_reversal, tol=symmop.tol) elif isinstance(symmop, SymmOp): return SymmOp.from_rotation_and_translation(rotation_matrix=W_, translation_vec=w_, tol=symmop.tol)