本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.get_symmetry_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.get_symmetry_dataset方法的具体用法?Python SpacegroupAnalyzer.get_symmetry_dataset怎么用?Python SpacegroupAnalyzer.get_symmetry_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.get_symmetry_dataset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_structure
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def from_structure(cls, structure, has_timerev=True, symprec=1e-5, angle_tolerance=5):
"""
Takes a :class:`Structure` object. Uses spglib to perform various symmetry finding operations.
Args:
structure: :class:`Structure` object
has_timerev: True is time-reversal symmetry is included.
symprec: Tolerance for symmetry finding
angle_tolerance: Angle tolerance for symmetry finding.
.. warning::
AFM symmetries are not supported.
"""
# Call spglib to get the list of symmetry operations.
spga = SpacegroupAnalyzer(structure, symprec=symprec, angle_tolerance=angle_tolerance)
data = spga.get_symmetry_dataset()
return cls(
spgid=data["number"],
symrel=data["rotations"],
tnons=data["translations"],
symafm=len(symrel) * [1],
has_timerev=has_timerev,
inord="C",
)
示例2: get_unique_site_indices
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def get_unique_site_indices(structure):
sa = SpacegroupAnalyzer(structure)
symm_data = sa.get_symmetry_dataset()
# equivalency mapping for the structure
# i'th site in the struct equivalent to eq_struct[i]'th site
eq_atoms = symm_data["equivalent_atoms"]
return np.unique(eq_atoms).tolist()
示例3: cif2geom_sym2
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def cif2geom_sym2(cif):
parser=CifParser.from_string(cif)
struct=parser.get_structures()[0]
sg = SpacegroupAnalyzer(struct)
struct = sg.get_conventional_standard_structure()
sg = SpacegroupAnalyzer(struct)
geomlines=["CRYSTAL"]
geomlines += ["0 0 1"]
geomlines += [str(sg.get_spacegroup_number())]
cry_sys = sg.get_crystal_system()
lattice = struct.lattice
if cry_sys == 'trigonal' or cry_sys == 'hexagonal' or cry_sys == 'tetragonal':
geomlines += ["%s %s" %(lattice.a,lattice.c)]
elif cry_sys == 'cubic':
geomlines += ["%s" %(lattice.a)]
elif cry_sys == 'triclinic':
geomlines += ["%s %s %s %s %s %s" %(lattice.a,lattice.b,lattice.c,lattice.alpha,lattice.beta,lattice.gamma)]
elif cry_sys == 'monoclinic':
geomlines += ["%s %s %s %s" %(lattice.a,lattice.b,lattice.c,lattice.beta)]
elif cry_sys == 'orthorhombic':
geomlines += ["%s %s %s" %(lattice.a,lattice.b,lattice.c)]
else:
print('Error printing symmetrized structure.')
quit()
ds = sg.get_symmetry_dataset()
eq_sites = np.unique(ds['equivalent_atoms'])
geomlines += [str(len(eq_sites))]
for eq_site in eq_sites:
site = struct.sites[eq_site]
geomlines += ["%s %s %s %s" %(site.specie.Z+200,site.a,site.b,site.c)]
return geomlines,struct
示例4: determine_symmetry_positions
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def determine_symmetry_positions(st, element):
"""
determine non-equivalent positions for atoms of type *element*
element (str) - name of element, for example Li
return list of lists - atom numbers for each non-equivalent position
"""
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
stp = st.convert2pymatgen()
spg = SpacegroupAnalyzer(stp)
info = spg.get_symmetry_dataset()
positions = {}
for i, (el, pos) in enumerate(zip(st.get_elements(), info['equivalent_atoms'])):
if el == element and pos not in positions:
positions[pos] = []
if el == element:
positions[pos].append(i)
printlog('I have found ', len(positions), 'non-equivalent positions for', element, ':',positions.keys(), imp = 'y', end = '\n')
printlog('Atom numbers: ', positions, imp = 'y')
sorted_keys = sorted(list(positions.keys()))
pos_lists = [positions[key] for key in sorted_keys ]
return pos_lists
示例5: analyze_symmetry
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def analyze_symmetry(args):
tolerance = args.symmetry
t = []
for filename in args.filenames:
s = Structure.from_file(filename, primitive=False)
finder = SpacegroupAnalyzer(s, tolerance)
dataset = finder.get_symmetry_dataset()
t.append([filename, dataset["international"], dataset["number"],
dataset["hall"]])
print(tabulate(t, headers=["Filename", "Int Symbol", "Int number", "Hall"]))
示例6: __init__
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def __init__(self, struct, source='', comment=''):
if struct.is_ordered:
self.struct = struct
self.source = source
sym = SpacegroupAnalyzer(struct)
data = sym.get_symmetry_dataset()
self.space_number = data["number"]
self.space_group = data["international"]
self.comment = comment or "None given"
else:
raise ValueError("Structure with partial occupancies cannot be "
"converted into atomic coordinates!")
示例7: parse_symmetry
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def parse_symmetry(args):
tolerance = float(args.tolerance[0])
for filename in args.filenames:
s = Structure.from_file(filename)
if args.spacegroup:
finder = SpacegroupAnalyzer(s, tolerance)
dataset = finder.get_symmetry_dataset()
print(filename)
print("Spacegroup : {}".format(dataset["international"]))
print("Int number : {}".format(dataset["number"]))
print("Hall symbol : {}".format(dataset["hall"]))
print()
示例8: _get_data_from_single_dirc
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def _get_data_from_single_dirc(dirc, src_str="str_relax.out",
src_ene='energy'):
"""
指定したdircから構造とエネルギーを読み取る
"""
src = os.path.join(dirc, src_str)
strout = StrOut.from_file(src)
src = os.path.join(dirc, src_ene)
with open(src, 'r') as rfile:
lines = rfile.readlines()
num_atoms = sum(strout.structure.composition.
to_data_dict['unit_cell_composition'].values())
energy = float(lines[0]) / num_atoms
analyzer = SpacegroupAnalyzer(strout.structure)
#std_prim = analyzer.get_primitive_standard_structure()
std_str = analyzer.get_conventional_standard_structure()
analyzer = SpacegroupAnalyzer(std_str)
wyckoffs = analyzer.get_symmetry_dataset()['wyckoffs']
formula = std_str.composition.to_data_dict['unit_cell_composition']
symbol_spg = analyzer.get_spacegroup_symbol()
num_spg = analyzer.get_spacegroup_number()
spg = [symbol_spg, num_spg]
lattice = std_str.as_dict()['lattice']
equiv_sites = analyzer.get_symmetrized_structure().equivalent_sites
equiv_indices = analyzer.get_symmetrized_structure().equivalent_indices
# Wycoffs labelと組み合わせたsites_groupのlistを作る
sites_and_wyckoffs = []
for eq_s, eq_i in zip(equiv_sites, equiv_indices):
sites_and_wyckoffs.append({'wyckoffs': wyckoffs[eq_i[0]],
'site_grp': eq_s})
# check
for i in range(len(eq_i)-1):
if wyckoffs[eq_i[i]] != wyckoffs[eq_i[i+1]] or \
len(eq_s) != len(eq_i):
print("wyckoffs label is wrong !!!!")
print(wyckoffs)
print(eq_i)
print(len(eq_s))
print(dirc)
exit()
return {'formula': formula, 'lattice': lattice, 'spg': spg,
'sites_and_wyckoffs': sites_and_wyckoffs, 'energy': energy,
'str_id': os.path.basename(dirc)}
示例9: _make_struc_file
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def _make_struc_file(self, file_name):
sym = SpacegroupAnalyzer(self._bs._structure, symprec=0.01)
with open(file_name, 'w') as f:
f.write(self._bs._structure.composition.formula+" " +
str(sym.get_spacegroup_symbol())+"\n")
for i in range(3):
line = ''
for j in range(3):
line += "%12.5f" % (
Length(self._bs._structure.lattice.matrix[i][j],
"ang").to("bohr"))
f.write(line+'\n')
ops = sym.get_symmetry_dataset()['rotations']
f.write(str(len(ops))+"\n")
for c in ops:
f.write('\n'.join([' '.join([str(int(i)) for i in row])
for row in c]))
f.write('\n')
示例10: __init__
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def __init__(self, struct, source='', comment=''):
if struct.is_ordered:
self._struct = struct
self._source = source
self._site_symbols = []
self._natoms = []
sym = SpacegroupAnalyzer(struct)
data = sym.get_symmetry_dataset()
self._space_number = data["number"]
self._space_group = data["international"]
syms = [site.specie.symbol for site in struct]
for (s, data) in itertools.groupby(syms):
self._site_symbols.append(s)
self._natoms.append(len(tuple(data)))
if comment == '':
self._comment = 'None Given'
else:
self._comment = comment
else:
raise ValueError("Structure with partial occupancies cannot be "
"converted into atomic coordinates!")
示例11: set_output_data
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def set_output_data(self, d_calc, d):
"""
set the 'output' key
"""
d["output"] = {
"structure": d_calc["output"]["structure"],
"density": d_calc.pop("density"),
"energy": d_calc["output"]["energy"],
"energy_per_atom": d_calc["output"]["energy_per_atom"]}
d["output"].update(self.get_basic_processed_data(d))
sg = SpacegroupAnalyzer(Structure.from_dict(d_calc["output"]["structure"]), 0.1)
if not sg.get_symmetry_dataset():
sg = SpacegroupAnalyzer(Structure.from_dict(d_calc["output"]["structure"]), 1e-3, 1)
d["output"]["spacegroup"] = {
"source": "spglib",
"symbol": sg.get_space_group_symbol(),
"number": sg.get_space_group_number(),
"point_group": sg.get_point_group_symbol(),
"crystal_system": sg.get_crystal_system(),
"hall": sg.get_hall()}
if d["input"]["parameters"].get("LEPSILON"):
for k in ['epsilon_static', 'epsilon_static_wolfe', 'epsilon_ionic']:
d["output"][k] = d_calc["output"][k]
示例12: get_uniq_layercoords
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def get_uniq_layercoords(struct, nlayers, top=True):
"""
returns the coordinates of unique sites in the top or bottom
nlayers of the given structure.
Args:
struct: input structure
nlayers: number of layers
top: top or bottom layers, default is top layer
Return:
numpy array of unique coordinates
"""
coords = np.array([site.coords for site in struct])
z = coords[:, 2]
z = np.around(z, decimals=4)
zu, zuind = np.unique(z, return_index=True)
z_nthlayer = z[zuind[-nlayers]]
zfilter = (z >= z_nthlayer)
if not top:
z_nthlayer = z[zuind[nlayers - 1]]
zfilter = (z <= z_nthlayer)
# site indices in the layers
indices_layers = np.argwhere(zfilter).ravel()
sa = SpacegroupAnalyzer(struct)
symm_data = sa.get_symmetry_dataset()
# equivalency mapping for the structure
# i'th site in the struct equivalent to eq_struct[i]'th site
eq_struct = symm_data["equivalent_atoms"]
# equivalency mapping for the layers
eq_layers = eq_struct[indices_layers]
# site indices of unique atoms in the layers
__, ueq_layers_indices = np.unique(eq_layers, return_index=True)
# print(ueq_layers_indices)
indices_uniq = indices_layers[ueq_layers_indices]
# coordinates of the unique atoms in the layers
return coords[indices_uniq]
示例13: convert_to_ieee
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
def convert_to_ieee(self, structure, initial_fit=True):
"""
Given a structure associated with a tensor, attempts a
calculation of the tensor in IEEE format according to
the 1987 IEEE standards.
Args:
structure (Structure): a structure associated with the
tensor to be converted to the IEEE standard
initial_fit (bool): flag to indicate whether initial
tensor is fit to the symmetry of the structure.
Defaults to true. Note that if false, inconsistent
results may be obtained due to symmetrically
equivalent, but distinct transformations
being used in different versions of spglib.
"""
def get_uvec(v):
""" Gets a unit vector parallel to input vector"""
l = np.linalg.norm(v)
if l < 1e-8:
return v
return v / l
# Check conventional setting:
sga = SpacegroupAnalyzer(structure)
dataset = sga.get_symmetry_dataset()
trans_mat = dataset['transformation_matrix']
conv_latt = Lattice(np.transpose(np.dot(np.transpose(
structure.lattice.matrix), np.linalg.inv(trans_mat))))
xtal_sys = sga.get_crystal_system()
vecs = conv_latt.matrix
lengths = np.array(conv_latt.abc)
angles = np.array(conv_latt.angles)
rotation = np.zeros((3, 3))
# IEEE rules: a,b,c || x1,x2,x3
if xtal_sys == "cubic":
rotation = [vecs[i] / lengths[i] for i in range(3)]
# IEEE rules: a=b in length; c,a || x3, x1
elif xtal_sys == "tetragonal":
rotation = np.array([vec / mag for (mag, vec) in
sorted(zip(lengths, vecs),
key=lambda x: x[0])])
if abs(lengths[2] - lengths[1]) < abs(lengths[1] - lengths[0]):
rotation[0], rotation[2] = rotation[2], rotation[0].copy()
rotation[1] = get_uvec(np.cross(rotation[2], rotation[0]))
# IEEE rules: c<a<b; c,a || x3,x1
elif xtal_sys == "orthorhombic":
rotation = [vec / mag for (mag, vec) in sorted(zip(lengths, vecs))]
rotation = np.roll(rotation, 2, axis=0)
# IEEE rules: c,a || x3,x1, c is threefold axis
# Note this also includes rhombohedral crystal systems
elif xtal_sys in ("trigonal", "hexagonal"):
# find threefold axis:
tf_index = np.argmin(abs(angles - 120.))
non_tf_mask = np.logical_not(angles == angles[tf_index])
rotation[2] = get_uvec(vecs[tf_index])
rotation[0] = get_uvec(vecs[non_tf_mask][0])
rotation[1] = get_uvec(np.cross(rotation[2], rotation[0]))
# IEEE rules: b,c || x2,x3; alpha=beta=90, c<a
elif xtal_sys == "monoclinic":
# Find unique axis
u_index = np.argmax(abs(angles - 90.))
n_umask = np.logical_not(angles == angles[u_index])
rotation[1] = get_uvec(vecs[u_index])
# Shorter of remaining lattice vectors for c axis
c = [vec / mag for (mag, vec) in
sorted(zip(lengths[n_umask], vecs[n_umask]))][0]
rotation[2] = np.array(c)
rotation[0] = np.cross(rotation[1], rotation[2])
# IEEE rules: c || x3
elif xtal_sys == "triclinic":
rotation = [vec / mag for (mag, vec) in sorted(zip(lengths, vecs))]
rotation = np.roll(rotation, 2, axis=0)
rotation[1] = get_uvec(np.cross(rotation[2], rotation[1]))
rotation[0] = np.cross(rotation[1], rotation[2])
result = self.copy()
if initial_fit:
result = result.fit_to_structure(structure)
return result.rotate(rotation, tol=1e-2)
示例14: SpacegroupAnalyzerTest
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
class SpacegroupAnalyzerTest(PymatgenTest):
def setUp(self):
p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
self.structure = p.structure
self.sg = SpacegroupAnalyzer(self.structure, 0.001)
self.disordered_structure = self.get_structure('Li10GeP2S12')
self.disordered_sg = SpacegroupAnalyzer(self.disordered_structure, 0.001)
s = p.structure.copy()
site = s[0]
del s[0]
s.append(site.species_and_occu, site.frac_coords)
self.sg3 = SpacegroupAnalyzer(s, 0.001)
graphite = self.get_structure('Graphite')
graphite.add_site_property("magmom", [0.1] * len(graphite))
self.sg4 = SpacegroupAnalyzer(graphite, 0.001)
self.structure4 = graphite
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)
def test_is_laue(self):
s = Structure.from_spacegroup("Fm-3m", np.eye(3) * 3, ["Cu"],
[[0, 0, 0]])
a = SpacegroupAnalyzer(s)
self.assertTrue(a.is_laue())
def test_magnetic(self):
lfp = PymatgenTest.get_structure("LiFePO4")
sg = SpacegroupAnalyzer(lfp, 0.1)
self.assertEqual(sg.get_space_group_symbol(), "Pnma")
magmoms = [0] * len(lfp)
magmoms[4] = 1
magmoms[5] = -1
magmoms[6] = 1
magmoms[7] = -1
lfp.add_site_property("magmom", magmoms)
sg = SpacegroupAnalyzer(lfp, 0.1)
self.assertEqual(sg.get_space_group_symbol(), "Pnma")
def test_get_space_symbol(self):
self.assertEqual(self.sg.get_space_group_symbol(), "Pnma")
self.assertEqual(self.disordered_sg.get_space_group_symbol(),
"P4_2/nmc")
self.assertEqual(self.sg3.get_space_group_symbol(), "Pnma")
self.assertEqual(self.sg4.get_space_group_symbol(), "P6_3/mmc")
def test_get_space_number(self):
self.assertEqual(self.sg.get_space_group_number(), 62)
self.assertEqual(self.disordered_sg.get_space_group_number(), 137)
self.assertEqual(self.sg4.get_space_group_number(), 194)
def test_get_hall(self):
self.assertEqual(self.sg.get_hall(), '-P 2ac 2n')
self.assertEqual(self.disordered_sg.get_hall(), 'P 4n 2n -1n')
def test_get_pointgroup(self):
self.assertEqual(self.sg.get_point_group_symbol(), 'mmm')
self.assertEqual(self.disordered_sg.get_point_group_symbol(), '4/mmm')
def test_get_symmetry_dataset(self):
ds = self.sg.get_symmetry_dataset()
self.assertEqual(ds['international'], 'Pnma')
def test_get_crystal_system(self):
crystal_system = self.sg.get_crystal_system()
self.assertEqual('orthorhombic', crystal_system)
self.assertEqual('tetragonal', self.disordered_sg.get_crystal_system())
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):
# translation vector values should all be 0 or 0.5
t = fop.translation_vector * 2
self.assertArrayAlmostEqual(t - np.round(t), 0)
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
#.........这里部分代码省略.........
示例15: SpacegroupAnalyzerTest
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_symmetry_dataset [as 别名]
class SpacegroupAnalyzerTest(PymatgenTest):
def setUp(self):
p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
self.structure = p.structure
self.sg = SpacegroupAnalyzer(self.structure, 0.001)
self.disordered_structure = self.get_structure('Li10GeP2S12')
self.disordered_sg = SpacegroupAnalyzer(self.disordered_structure, 0.001)
s = p.structure.copy()
site = s[0]
del s[0]
s.append(site.species_and_occu, site.frac_coords)
self.sg3 = SpacegroupAnalyzer(s, 0.001)
graphite = self.get_structure('Graphite')
graphite.add_site_property("magmom", [0.1] * len(graphite))
self.sg4 = SpacegroupAnalyzer(graphite, 0.001)
def test_get_space_symbol(self):
self.assertEqual(self.sg.get_spacegroup_symbol(), "Pnma")
self.assertEqual(self.disordered_sg.get_spacegroup_symbol(),
"P4_2/nmc")
self.assertEqual(self.sg3.get_spacegroup_symbol(), "Pnma")
self.assertEqual(self.sg4.get_spacegroup_symbol(), "R-3m")
def test_get_space_number(self):
self.assertEqual(self.sg.get_spacegroup_number(), 62)
self.assertEqual(self.disordered_sg.get_spacegroup_number(), 137)
self.assertEqual(self.sg4.get_spacegroup_number(), 166)
def test_get_hall(self):
self.assertEqual(self.sg.get_hall(), '-P 2ac 2n')
self.assertEqual(self.disordered_sg.get_hall(), 'P 4n 2n -1n')
def test_get_pointgroup(self):
self.assertEqual(self.sg.get_point_group(), 'mmm')
self.assertEqual(self.disordered_sg.get_point_group(), '4/mmm')
def test_get_symmetry_dataset(self):
ds = self.sg.get_symmetry_dataset()
self.assertEqual(ds['international'], 'Pnma')
def test_get_crystal_system(self):
crystal_system = self.sg.get_crystal_system()
self.assertEqual('orthorhombic', crystal_system)
self.assertEqual('tetragonal', self.disordered_sg.get_crystal_system())
def test_get_symmetry_operations(self):
fracsymmops = self.sg.get_symmetry_operations()
symmops = self.sg.get_symmetry_operations(True)
self.assertEqual(len(symmops), 8)
latt = self.structure.lattice
for fop, op in zip(fracsymmops, symmops):
for site in self.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 self.structure:
if newsite.is_periodic_image(testsite, 1e-3):
found = True
break
self.assertTrue(found)
def test_get_refined_structure(self):
for a in self.sg.get_refined_structure().lattice.angles:
self.assertEqual(a, 90)
refined = self.disordered_sg.get_refined_structure()
for a in refined.lattice.angles:
self.assertEqual(a, 90)
self.assertEqual(refined.lattice.a, refined.lattice.b)
s = self.get_structure('Li2O')
sg = SpacegroupAnalyzer(s, 0.001)
self.assertEqual(sg.get_refined_structure().num_sites, 4 * s.num_sites)
def test_get_symmetrized_structure(self):
symm_struct = self.sg.get_symmetrized_structure()
for a in symm_struct.lattice.angles:
self.assertEqual(a, 90)
self.assertEqual(len(symm_struct.equivalent_sites), 5)
symm_struct = self.disordered_sg.get_symmetrized_structure()
self.assertEqual(len(symm_struct.equivalent_sites), 8)
self.assertEqual([len(i) for i in symm_struct.equivalent_sites],
[16,4,8,4,2,8,8,8])
s1 = symm_struct.equivalent_sites[1][1]
s2 = symm_struct[symm_struct.equivalent_indices[1][1]]
self.assertEqual(s1, s2)
self.assertEqual(self.sg4.get_symmetrized_structure()[0].magmom, 0.1)
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()
#.........这里部分代码省略.........