本文整理汇总了Python中pymatgen.core.sites.PeriodicSite类的典型用法代码示例。如果您正苦于以下问题:Python PeriodicSite类的具体用法?Python PeriodicSite怎么用?Python PeriodicSite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PeriodicSite类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_symmetry_operations
def test_get_symmetry_operations(self):
for sg, structure in [(self.sg, self.structure),
(self.sg4, self.structure4)]:
pgops = sg.get_point_group_operations()
fracsymmops = sg.get_symmetry_operations()
symmops = sg.get_symmetry_operations(True)
latt = structure.lattice
for fop, op, pgop in zip(fracsymmops, symmops, pgops):
self.assertArrayAlmostEqual(fop.rotation_matrix,
pgop.rotation_matrix)
for site in structure:
newfrac = fop.operate(site.frac_coords)
newcart = op.operate(site.coords)
self.assertTrue(np.allclose(latt.get_fractional_coords(newcart),
newfrac))
found = False
newsite = PeriodicSite(site.species_and_occu, newcart, latt,
coords_are_cartesian=True)
for testsite in structure:
if newsite.is_periodic_image(testsite, 1e-3):
found = True
break
self.assertTrue(found)
# Make sure this works for any position, not just the atomic
# ones.
random_fcoord = np.random.uniform(size=(3))
random_ccoord = latt.get_cartesian_coords(random_fcoord)
newfrac = fop.operate(random_fcoord)
newcart = op.operate(random_ccoord)
self.assertTrue(np.allclose(latt.get_fractional_coords(newcart),
newfrac))
开发者ID:ansobolev,项目名称:pymatgen,代码行数:33,代码来源:test_analyzer.py
示例2: setUp
def setUp(self):
self.lattice = Lattice.cubic(10.0)
self.si = Element("Si")
self.site = PeriodicSite("Fe", [0.25, 0.35, 0.45], self.lattice)
self.site2 = PeriodicSite({"Si": 0.5}, [0, 0, 0], self.lattice)
self.assertEqual(self.site2.species_and_occu, Composition({Element("Si"): 0.5}), "Inconsistent site created!")
self.propertied_site = PeriodicSite(
Specie("Fe", 2), [0.25, 0.35, 0.45], self.lattice, properties={"magmom": 5.1, "charge": 4.2}
)
self.dummy_site = PeriodicSite("X", [0, 0, 0], self.lattice)
开发者ID:Bismarrck,项目名称:pymatgen,代码行数:10,代码来源:test_sites.py
示例3: test_to_from_dict
def test_to_from_dict(self):
d = self.site2.to_dict
site = PeriodicSite.from_dict(d)
self.assertEqual(site, self.site2)
self.assertNotEqual(site, self.site)
d = self.propertied_site.to_dict
site = Site.from_dict(d)
self.assertEqual(site.magmom, 5.1)
self.assertEqual(site.charge, 4.2)
site3 = PeriodicSite({"Si": 0.5, "Fe": 0.5}, [0, 0, 0], self.lattice)
d = site3.to_dict
site = PeriodicSite.from_dict(d)
self.assertEqual(site.species_and_occu, site3.species_and_occu)
开发者ID:jesuansito,项目名称:pymatgen,代码行数:13,代码来源:test_sites.py
示例4: test_as_from_dict
def test_as_from_dict(self):
d = self.site2.as_dict()
site = PeriodicSite.from_dict(d)
self.assertEqual(site, self.site2)
self.assertNotEqual(site, self.site)
d = self.propertied_site.as_dict()
site3 = PeriodicSite({"Si": 0.5, "Fe": 0.5}, [0, 0, 0], self.lattice)
d = site3.as_dict()
site = PeriodicSite.from_dict(d)
self.assertEqual(site.species_and_occu, site3.species_and_occu)
d = self.dummy_site.as_dict()
site = PeriodicSite.from_dict(d)
self.assertEqual(site.species_and_occu, self.dummy_site.species_and_occu)
开发者ID:albalu,项目名称:pymatgen,代码行数:14,代码来源:test_sites.py
示例5: _supercell_with_defect
def _supercell_with_defect(self, scaling_matrix, defect_site):
sc = self._structure.copy()
sc.make_supercell(scaling_matrix)
oldf_coords = defect_site.frac_coords
coords = defect_site.lattice.get_cartesian_coords(oldf_coords)
newf_coords = sc.lattice.get_fractional_coords(coords)
sc_defect_site = PeriodicSite(
defect_site.species_and_occu, newf_coords, sc.lattice, properties=defect_site.properties
)
for i in range(len(sc.sites)):
# if sc_defect_site == sc.sites[i]:
if sc_defect_site.distance(sc.sites[i]) < 1e-3:
del sc[i]
return sc
raise ValueError("Something wrong if reached here")
开发者ID:richardtran415,项目名称:pymatgen,代码行数:15,代码来源:point_defects.py
示例6: test_distance_and_image
def test_distance_and_image(self):
other_site = PeriodicSite("Fe", np.array([1, 1, 1]), self.lattice)
(distance, image) = self.site.distance_and_image(other_site)
self.assertAlmostEqual(distance, 6.22494979899, 5)
self.assertTrue(([-1, -1, -1] == image).all())
(distance, image) = self.site.distance_and_image(other_site, [1, 0, 0])
self.assertAlmostEqual(distance, 19.461500456028563, 5)
# Test that old and new distance algo give the same ans for
# "standard lattices"
lattice = Lattice(np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]))
site1 = PeriodicSite("Fe", np.array([0.01, 0.02, 0.03]), lattice)
site2 = PeriodicSite("Fe", np.array([0.99, 0.98, 0.97]), lattice)
self.assertAlmostEqual(get_distance_and_image_old(site1, site2)[0],
site1.distance_and_image(site2)[0])
lattice = Lattice.from_parameters(1, 0.01, 1, 10, 10, 10)
site1 = PeriodicSite("Fe", np.array([0.01, 0.02, 0.03]), lattice)
site2 = PeriodicSite("Fe", np.array([0.99, 0.98, 0.97]), lattice)
self.assertTrue(get_distance_and_image_old(site1, site2)[0] >
site1.distance_and_image(site2)[0])
site2 = PeriodicSite("Fe", np.random.rand(3), lattice)
(dist_old, jimage_old) = get_distance_and_image_old(site1, site2)
(dist_new, jimage_new) = site1.distance_and_image(site2)
self.assertTrue(dist_old - dist_new > -1e-8,
"New distance algo should give smaller answers!")
self.assertFalse((abs(dist_old - dist_new) < 1e-8) ^
(jimage_old == jimage_new).all(),
"If old dist == new dist, images must be the same!")
latt = Lattice.from_parameters(3.0, 3.1, 10.0, 2.96, 2.0, 1.0)
site = PeriodicSite("Fe", [0.1, 0.1, 0.1], latt)
site2 = PeriodicSite("Fe", [0.99, 0.99, 0.99], latt)
(dist, img) = site.distance_and_image(site2)
self.assertAlmostEqual(dist, 0.15495358379511573)
self.assertEqual(list(img), [-11, 6, 0])
开发者ID:albalu,项目名称:pymatgen,代码行数:33,代码来源:test_sites.py
注:本文中的pymatgen.core.sites.PeriodicSite类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论