本文整理汇总了Python中pymatgen.core.sites.Site类的典型用法代码示例。如果您正苦于以下问题:Python Site类的具体用法?Python Site怎么用?Python Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Site类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.ordered_site = Site("Fe", [0.25, 0.35, 0.45])
self.disordered_site = Site({"Fe": 0.5, "Mn": 0.5},
[0.25, 0.35, 0.45])
self.propertied_site = Site("Fe2+", [0.25, 0.35, 0.45],
{'magmom': 5.1, 'charge': 4.2})
self.dummy_site = Site("X", [0, 0, 0])
示例2: SiteTest
class SiteTest(PymatgenTest):
def setUp(self):
self.ordered_site = Site("Fe", [0.25, 0.35, 0.45])
self.disordered_site = Site({"Fe": 0.5, "Mn": 0.5},
[0.25, 0.35, 0.45])
self.propertied_site = Site("Fe2+", [0.25, 0.35, 0.45],
{'magmom': 5.1, 'charge': 4.2})
self.dummy_site = Site("X", [0, 0, 0])
def test_properties(self):
self.assertRaises(AttributeError, getattr, self.disordered_site,
'specie')
self.assertIsInstance(self.ordered_site.specie, Element)
self.assertEqual(self.propertied_site.properties["magmom"], 5.1)
self.assertEqual(self.propertied_site.properties["charge"], 4.2)
def test_to_from_dict(self):
d = self.disordered_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.properties["magmom"], 5.1)
self.assertEqual(site.properties["charge"], 4.2)
d = self.dummy_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.species, self.dummy_site.species)
def test_hash(self):
self.assertEqual(self.ordered_site.__hash__(), 26)
self.assertEqual(self.disordered_site.__hash__(), 51)
def test_cmp(self):
self.assertTrue(self.ordered_site > self.disordered_site)
def test_distance(self):
osite = self.ordered_site
self.assertAlmostEqual(np.linalg.norm([0.25, 0.35, 0.45]),
osite.distance_from_point([0, 0, 0]))
self.assertAlmostEqual(osite.distance(self.disordered_site), 0)
def test_pickle(self):
o = pickle.dumps(self.propertied_site)
self.assertEqual(pickle.loads(o), self.propertied_site)
def test_setters(self):
self.disordered_site.species = "Cu"
self.assertEqual(self.disordered_site.species, Composition("Cu"))
self.disordered_site.x = 1.25
self.disordered_site.y = 1.35
self.assertEqual(self.disordered_site.coords[0], 1.25)
self.assertEqual(self.disordered_site.coords[1], 1.35)
def set_bad_species():
self.disordered_site.species = {"Cu": 0.5, "Gd": 0.6}
self.assertRaises(ValueError, set_bad_species)
示例3: test_to_from_dict
def test_to_from_dict(self):
d = self.disordered_site.to_dict
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.to_dict
site = Site.from_dict(d)
self.assertEqual(site.magmom, 5.1)
self.assertEqual(site.charge, 4.2)
示例4: test_to_from_dict
def test_to_from_dict(self):
d = self.disordered_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.magmom, 5.1)
self.assertEqual(site.charge, 4.2)
d = self.dummy_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.species_and_occu, self.dummy_site.species_and_occu)
示例5: test_to_from_dict
def test_to_from_dict(self):
d = self.disordered_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.properties["magmom"], 5.1)
self.assertEqual(site.properties["charge"], 4.2)
d = self.dummy_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.species, self.dummy_site.species)
示例6: SiteTest
class SiteTest(PymatgenTest):
def setUp(self):
self.ordered_site = Site("Fe", [0.25, 0.35, 0.45])
self.disordered_site = Site({"Fe": 0.5, "Mn": 0.5},
[0.25, 0.35, 0.45])
self.propertied_site = Site("Fe2+", [0.25, 0.35, 0.45],
{'magmom': 5.1, 'charge': 4.2})
self.dummy_site = Site("X", [0, 0, 0])
def test_properties(self):
self.assertRaises(AttributeError, getattr, self.disordered_site,
'specie')
self.assertIsInstance(self.ordered_site.specie, Element)
self.assertEqual(self.propertied_site.magmom, 5.1)
self.assertEqual(self.propertied_site.charge, 4.2)
def test_to_from_dict(self):
d = self.disordered_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.magmom, 5.1)
self.assertEqual(site.charge, 4.2)
d = self.dummy_site.as_dict()
site = Site.from_dict(d)
self.assertEqual(site.species_and_occu, self.dummy_site.species_and_occu)
def test_hash(self):
self.assertEqual(self.ordered_site.__hash__(), 26)
self.assertEqual(self.disordered_site.__hash__(), 51)
def test_cmp(self):
self.assertTrue(self.ordered_site > self.disordered_site)
def test_distance(self):
osite = self.ordered_site
self.assertAlmostEqual(np.linalg.norm([0.25, 0.35, 0.45]),
osite.distance_from_point([0, 0, 0]))
self.assertAlmostEqual(osite.distance(self.disordered_site), 0)
def test_pickle(self):
o = pickle.dumps(self.propertied_site)
self.assertEqual(pickle.loads(o), self.propertied_site)
示例7: SiteTest
class SiteTest(unittest.TestCase):
def setUp(self):
self.ordered_site = Site(Element("Fe"), [0.25, 0.35, 0.45])
self.disordered_site = Site({Element("Fe"): 0.5, Element("Mn"): 0.5},
[0.25, 0.35, 0.45])
self.propertied_site = Site(Specie("Fe", 2), [0.25, 0.35, 0.45],
{'magmom': 5.1, 'charge': 4.2})
def test_init(self):
self.assertRaises(ValueError, Site, Specie("Fe", 2),
[0.25, 0.35, 0.45], {'mag': 5.1})
def test_properties(self):
self.assertRaises(AttributeError, getattr, self.disordered_site,
'specie')
self.assertIsInstance(self.ordered_site.specie, Element)
self.assertEqual(self.propertied_site.magmom, 5.1)
self.assertEqual(self.propertied_site.charge, 4.2)
def test_to_from_dict(self):
d = self.disordered_site.to_dict
site = Site.from_dict(d)
self.assertEqual(site, self.disordered_site)
self.assertNotEqual(site, self.ordered_site)
d = self.propertied_site.to_dict
site = Site.from_dict(d)
self.assertEqual(site.magmom, 5.1)
self.assertEqual(site.charge, 4.2)
def test_hash(self):
self.assertEqual(self.ordered_site.__hash__(), 26)
self.assertEqual(self.disordered_site.__hash__(), 25.5)
def test_cmp(self):
self.assertTrue(self.ordered_site > self.disordered_site)
def test_distance(self):
osite = self.ordered_site
self.assertAlmostEqual(np.linalg.norm([0.25, 0.35, 0.45]),
osite.distance_from_point([0, 0, 0]))
self.assertAlmostEqual(osite.distance(self.disordered_site), 0)
def test_pickle(self):
o = pickle.dumps(self.propertied_site)
self.assertEqual(pickle.loads(o), self.propertied_site)
示例8: setUp
def setUp(self):
self.ordered_site = Site(Element("Fe"), [0.25, 0.35, 0.45])
self.disordered_site = Site({Element("Fe"): 0.5, Element("Mn"): 0.5},
[0.25, 0.35, 0.45])
self.propertied_site = Site(Specie("Fe", 2), [0.25, 0.35, 0.45],
{'magmom': 5.1, 'charge': 4.2})
示例9: setUp
def setUp(self):
self.ordered_site = Site("Fe", [0.25, 0.35, 0.45])
self.disordered_site = Site({"Fe": 0.5, "Mn": 0.5}, [0.25, 0.35, 0.45])
self.propertied_site = Site("Fe2+", [0.25, 0.35, 0.45], {"magmom": 5.1, "charge": 4.2})