本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.find_primitive方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.find_primitive方法的具体用法?Python SpacegroupAnalyzer.find_primitive怎么用?Python SpacegroupAnalyzer.find_primitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.find_primitive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_partial_disorder
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import find_primitive [as 别名]
def test_partial_disorder(self):
s = Structure.from_file(filename=os.path.join(test_dir, "garnet.cif"))
a = SpacegroupAnalyzer(s, 0.1)
prim = a.find_primitive()
s = prim.copy()
s["Al3+"] = {"Al3+": 0.5, "Ga3+": 0.5}
adaptor = EnumlibAdaptor(s, 1, 1, enum_precision_parameter=0.01)
adaptor.run()
structures = adaptor.structures
self.assertEqual(len(structures), 7)
for s in structures:
self.assertEqual(s.formula, 'Ca12 Al4 Ga4 Si12 O48')
s = prim.copy()
s["Ca2+"] = {"Ca2+": 1/3, "Mg2+": 2/3}
adaptor = EnumlibAdaptor(s, 1, 1, enum_precision_parameter=0.01)
adaptor.run()
structures = adaptor.structures
self.assertEqual(len(structures), 20)
for s in structures:
self.assertEqual(s.formula, 'Ca4 Mg8 Al8 Si12 O48')
s = prim.copy()
s["Si4+"] = {"Si4+": 1/3, "Ge4+": 2/3}
adaptor = EnumlibAdaptor(s, 1, 1, enum_precision_parameter=0.01)
adaptor.run()
structures = adaptor.structures
self.assertEqual(len(structures), 18)
for s in structures:
self.assertEqual(s.formula, 'Ca12 Al8 Si4 Ge8 O48')
示例2: test_find_primitive
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import find_primitive [as 别名]
def test_find_primitive(self):
"""
F m -3 m Li2O testing of converting to primitive cell
"""
parser = CifParser(os.path.join(test_dir, 'Li2O.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure)
primitive_structure = s.find_primitive()
self.assertEqual(primitive_structure.formula, "Li2 O1")
# This isn't what is expected. All the angles should be 60
self.assertAlmostEqual(primitive_structure.lattice.alpha, 60)
self.assertAlmostEqual(primitive_structure.lattice.beta, 60)
self.assertAlmostEqual(primitive_structure.lattice.gamma, 60)
self.assertAlmostEqual(primitive_structure.lattice.volume,
structure.lattice.volume / 4.0)
示例3: test_primitive
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import find_primitive [as 别名]
def test_primitive(self):
s = Structure.from_spacegroup("Fm-3m", np.eye(3) * 3, ["Cu"],
[[0, 0, 0]])
a = SpacegroupAnalyzer(s)
self.assertEqual(len(s), 4)
self.assertEqual(len(a.find_primitive()), 1)
示例4: calc_shiftk
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import find_primitive [as 别名]
def calc_shiftk(self, symprec=0.01, angle_tolerance=5):
"""
Find the values of `shiftk` and `nshiftk` appropriated for the sampling of the Brillouin zone.
When the primitive vectors of the lattice do NOT form a FCC or a BCC lattice,
the usual (shifted) Monkhorst-Pack grids are formed by using nshiftk=1 and shiftk 0.5 0.5 0.5 .
This is often the preferred k point sampling. For a non-shifted Monkhorst-Pack grid,
use `nshiftk=1` and `shiftk 0.0 0.0 0.0`, but there is little reason to do that.
When the primitive vectors of the lattice form a FCC lattice, with rprim::
0.0 0.5 0.5
0.5 0.0 0.5
0.5 0.5 0.0
the (very efficient) usual Monkhorst-Pack sampling will be generated by using nshiftk= 4 and shiftk::
0.5 0.5 0.5
0.5 0.0 0.0
0.0 0.5 0.0
0.0 0.0 0.5
When the primitive vectors of the lattice form a BCC lattice, with rprim::
-0.5 0.5 0.5
0.5 -0.5 0.5
0.5 0.5 -0.5
the usual Monkhorst-Pack sampling will be generated by using nshiftk= 2 and shiftk::
0.25 0.25 0.25
-0.25 -0.25 -0.25
However, the simple sampling nshiftk=1 and shiftk 0.5 0.5 0.5 is excellent.
For hexagonal lattices with hexagonal axes, e.g. rprim::
1.0 0.0 0.0
-0.5 sqrt(3)/2 0.0
0.0 0.0 1.0
one can use nshiftk= 1 and shiftk 0.0 0.0 0.5
In rhombohedral axes, e.g. using angdeg 3*60., this corresponds to shiftk 0.5 0.5 0.5,
to keep the shift along the symmetry axis.
Returns:
Suggested value of shiftk.
"""
# Find lattice type.
sym = SpacegroupAnalyzer(self, symprec=symprec, angle_tolerance=angle_tolerance)
lattice_type, spg_symbol = sym.get_lattice_type(), sym.get_spacegroup_symbol()
# Check if the cell is primitive
is_primitve = len(sym.find_primitive()) == len(self)
# Generate the appropriate set of shifts.
shiftk = None
if is_primitve:
if lattice_type == "cubic":
if "F" in spg_symbol:
# FCC
shiftk = [0.5, 0.5, 0.5,
0.5, 0.0, 0.0,
0.0, 0.5, 0.0,
0.0, 0.0, 0.5]
elif "I" in spg_symbol:
# BCC
shiftk = [0.25, 0.25, 0.25,
-0.25, -0.25, -0.25]
#shiftk = [0.5, 0.5, 05])
elif lattice_type == "hexagonal":
# Find the hexagonal axis and set the shift along it.
for i, angle in enumerate(self.lattice.angles):
if abs(angle - 120) < 1.0:
j = (i + 1) % 3
k = (i + 2) % 3
hex_ax = [ax for ax in range(3) if ax not in [j,k]][0]
break
else:
raise ValueError("Cannot find hexagonal axis")
shiftk = [0.0, 0.0, 0.0]
shiftk[hex_ax] = 0.5
elif lattice_type == "tetragonal":
if "I" in spg_symbol:
# BCT
shiftk = [0.25, 0.25, 0.25,
-0.25, -0.25, -0.25]
if shiftk is None:
# Use default value.
shiftk = [0.5, 0.5, 0.5]
return np.reshape(shiftk, (-1,3))