def test_is_compatible(self): cubic = Lattice.cubic(1) hexagonal = Lattice.hexagonal(1, 2) rhom = Lattice.rhombohedral(3, 80) tet = Lattice.tetragonal(1, 2) ortho = Lattice.orthorhombic(1, 2, 3) msg = MagneticSpaceGroup("Fm-3m") self.assertTrue(msg.is_compatible(cubic)) self.assertFalse(msg.is_compatible(hexagonal)) msg = MagneticSpaceGroup("Pnma") self.assertTrue(msg.is_compatible(cubic)) self.assertTrue(msg.is_compatible(tet)) self.assertTrue(msg.is_compatible(ortho)) self.assertFalse(msg.is_compatible(rhom)) self.assertFalse(msg.is_compatible(hexagonal)) msg = MagneticSpaceGroup("P2/c") self.assertTrue(msg.is_compatible(cubic)) self.assertTrue(msg.is_compatible(tet)) self.assertTrue(msg.is_compatible(ortho)) self.assertFalse(msg.is_compatible(rhom)) self.assertFalse(msg.is_compatible(hexagonal)) msg = MagneticSpaceGroup("P-1") self.assertTrue(msg.is_compatible(cubic)) self.assertTrue(msg.is_compatible(tet)) self.assertTrue(msg.is_compatible(ortho)) self.assertTrue(msg.is_compatible(rhom)) self.assertTrue(msg.is_compatible(hexagonal))
def test_is_compatible(self): cubic = Lattice.cubic(1) hexagonal = Lattice.hexagonal(1, 2) rhom = Lattice.rhombohedral(3, 80) tet = Lattice.tetragonal(1, 2) ortho = Lattice.orthorhombic(1, 2, 3) sg = SpaceGroup("Fm-3m") self.assertTrue(sg.is_compatible(cubic)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("R-3mH") self.assertFalse(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(hexagonal)) sg = SpaceGroup("R-3m") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("Pnma") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("P12/c1") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("P-1") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertTrue(sg.is_compatible(rhom)) self.assertTrue(sg.is_compatible(hexagonal))
def test_is_periodic_image(self): other = PeriodicSite("Fe", np.array([1.25, 2.35, 4.45]), self.lattice) self.assertTrue(self.site.is_periodic_image(other), "This other site should be a periodic image.") other = PeriodicSite("Fe", np.array([1.25, 2.35, 4.46]), self.lattice) self.assertFalse(self.site.is_periodic_image(other), "This other site should not be a periodic image.") other = PeriodicSite("Fe", np.array([1.25, 2.35, 4.45]), Lattice.rhombohedral(2, 60)) self.assertFalse(self.site.is_periodic_image(other), "Different lattices should not be periodic images.")
def setUp(self): self.lattice = Lattice.cubic(10.0) self.cubic = self.lattice self.tetragonal = Lattice.tetragonal(10, 20) self.orthorhombic = Lattice.orthorhombic(10, 20, 30) self.monoclinic = Lattice.monoclinic(10, 20, 30, 66) self.hexagonal = Lattice.hexagonal(10, 20) self.rhombohedral = Lattice.rhombohedral(10, 77) family_names = ["cubic", "tetragonal", "orthorhombic", "monoclinic", "hexagonal", "rhombohedral"] self.families = {} for name in family_names: self.families[name] = getattr(self, name)
def test_is_compatible(self): cubic = Lattice.cubic(1) hexagonal = Lattice.hexagonal(1, 2) rhom = Lattice.rhombohedral(3, 80) tet = Lattice.tetragonal(1, 2) ortho = Lattice.orthorhombic(1, 2, 3) sg = SpaceGroup("Fm-3m") self.assertTrue(sg.is_compatible(cubic)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("R-3m:H") self.assertFalse(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(hexagonal)) sg = SpaceGroup("R-3m:R") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("Pnma") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("P12/c1") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup("P-1") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertTrue(sg.is_compatible(rhom)) self.assertTrue(sg.is_compatible(hexagonal)) sg = SpaceGroup("Pmmn:2") self.assertTrue(sg.is_compatible(cubic)) self.assertTrue(sg.is_compatible(tet)) self.assertTrue(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertFalse(sg.is_compatible(hexagonal)) sg = SpaceGroup.from_int_number(165) self.assertFalse(sg.is_compatible(cubic)) self.assertFalse(sg.is_compatible(tet)) self.assertFalse(sg.is_compatible(ortho)) self.assertFalse(sg.is_compatible(rhom)) self.assertTrue(sg.is_compatible(hexagonal))