Esempio n. 1
0
    def operate_magmom(self, magmom):
        """
        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

        Args:
            magmom: Magnetic moment as electronic_structure.core.Magmom
            class or as list or np array-like

        Returns:
            Magnetic moment after operator applied as Magmom class
        """

        magmom = Magmom(magmom)  # type casting to handle lists as input

        transformed_moment = (self.apply_rotation_only(magmom.global_moment) *
                              np.linalg.det(self.rotation_matrix) *
                              self.time_reversal)

        # retains input spin axis if different from default
        return Magmom.from_global_moment_and_saxis(transformed_moment,
                                                   magmom.saxis)
Esempio n. 2
0
 def test_init(self):
     # backwards compatibility for scalar-like magmoms
     magmom = Magmom(2.0)
     self.assertEqual(float(magmom), 2.0)
     # backwards compatibility for list-like magmoms
     magmom2 = Magmom([1, 2, 3])
     self.assertEqual(list(magmom2), [1, 2, 3])
     self.assertEqual(magmom2.global_moment.tolist(), [1, 2, 3])
     # non-default saxis, normalized internally
     magmom3 = Magmom([1, 2, 3], saxis=[1, 1, 1])
     self.assertTrue(np.allclose(magmom3.saxis, [np.sqrt(1/3.)]*3))
     # test construction from known global moment and desired, non-default saxis
     magmom4 = Magmom.from_global_moment_and_saxis([1, 2, 3], saxis=[1, 0, 0])
     self.assertTrue(np.allclose(magmom4.moment, [-3, 2, 1]))
     # test global moments with non-default saxis
     magmom5 = Magmom([-3, 2, 1], saxis=[1, 0, 0])
     self.assertTrue(np.allclose(magmom5.global_moment, [1, 2, 3]))
Esempio n. 3
0
 def test_init(self):
     # backwards compatibility for scalar-like magmoms
     magmom = Magmom(2.0)
     self.assertEqual(float(magmom), 2.0)
     # backwards compatibility for list-like magmoms
     magmom2 = Magmom([1, 2, 3])
     self.assertEqual(list(magmom2), [1, 2, 3])
     self.assertEqual(magmom2.global_moment.tolist(), [1, 2, 3])
     # non-default saxis, normalized internally
     magmom3 = Magmom([1, 2, 3], saxis=[1, 1, 1])
     self.assertTrue(np.allclose(magmom3.saxis, [np.sqrt(1/3.)]*3))
     # test construction from known global moment and desired, non-default saxis
     magmom4 = Magmom.from_global_moment_and_saxis([1, 2, 3], saxis=[1, 0, 0])
     self.assertTrue(np.allclose(magmom4.moment, [-3, 2, 1]))
     # test global moments with non-default saxis
     magmom5 = Magmom([-3, 2, 1], saxis=[1, 0, 0])
     self.assertTrue(np.allclose(magmom5.global_moment, [1, 2, 3]))
Esempio n. 4
0
    def operate_magmom(self, magmom):
        """
        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

        Args:
            magmom: Magnetic moment as electronic_structure.core.Magmom
            class or as list or np array-like

        Returns:
            Magnetic moment after operator applied as Magmom class
        """

        magmom = Magmom(magmom)  # type casting to handle lists as input

        transformed_moment = self.apply_rotation_only(magmom.global_moment) * \
            np.linalg.det(self.rotation_matrix) * self.time_reversal

        # retains input spin axis if different from default
        return Magmom.from_global_moment_and_saxis(transformed_moment, magmom.saxis)