本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.get_primitive_standard_structure方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.get_primitive_standard_structure方法的具体用法?Python SpacegroupAnalyzer.get_primitive_standard_structure怎么用?Python SpacegroupAnalyzer.get_primitive_standard_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.get_primitive_standard_structure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prim_cif
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def prim_cif(self, dst):
"""
primitive cellでのcifフォーマットをgetする
"""
finder = SpacegroupAnalyzer(self.structure)
structure = finder.get_primitive_standard_structure()
structure = finder.get_conventional_standard_structure()
cif = CifWriter(structure, symprec=0.1)
cif.write_file(dst)
示例2: prim
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def prim(src):
"""
primitive cell に変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
prim_str = finder.get_primitive_standard_structure()
dstpos = Poscar(prim_str)
dst = 'POSCAR_prim'
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例3: primitive
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def primitive(src="POSCAR"):
"""
primitiveに変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
prim = finder.get_primitive_standard_structure()
dstpos = Poscar(prim)
dst = "POSCAR_prim"
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例4: get_smallest_expansion
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def get_smallest_expansion(structure : Structure, length : float):
"""
Finds the smallest expansion of the provided cell such that all sides are at minimum length. Will change shape of
cell if it creates a better match
:param structure: Unit cell to convert
:param length: Minimum vector difference
:return:
"""
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
sga = SpacegroupAnalyzer(structure)
structures = []
structures.append(structure)
try:
structures.append(structure.get_primitive_structure())
except:
pass
try:
structures.append(structure.get_reduced_structure('niggli'))
except:
pass
try:
structures.append(structure.get_reduced_structure('LLL'))
except:
pass
try:
structures.append(sga.get_conventional_standard_structure())
except:
pass
try:
structures.append(sga.get_primitive_standard_structure())
except:
pass
best_structure = None
for s in structures: # type: Structure
l = s.lattice
expansion = [ ceil(length / vec) for vec in l.abc ]
possible_structure = s * expansion
if best_structure == None or len(possible_structure) < len(best_structure):
best_structure = possible_structure
if structure.site_properties and not best_structure.site_properties:
def get_property(prop, atom):
i = structure.species.index(atom)
return structure.site_properties[prop][i]
site_properties = { prop : [ get_property(prop, atom) for atom in best_structure.species ] for prop in structure.site_properties}
best_structure = Structure(best_structure.lattice, best_structure.species, best_structure.frac_coords, site_properties=site_properties)
return best_structure
示例5: abi_sanitize
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def abi_sanitize(self, symprec=1e-3, angle_tolerance=5, primitive=True, primitive_standard=False):
"""
Returns a new structure in which:
* Structure is refined.
* Reduced to primitive settings.
* Lattice vectors are exchanged if the triple product is negative
Args:
symprec: Symmetry precision used to refine the structure.
if `symprec` is None, so structure refinement is peformed.
primitive (bool): Whether to convert to a primitive cell.
"""
from pymatgen.transformations.standard_transformations import PrimitiveCellTransformation, SupercellTransformation
structure = self.__class__.from_sites(self)
# Refine structure
if symprec is not None and angle_tolerance is not None:
sym_finder = SpacegroupAnalyzer(structure=structure, symprec=symprec, angle_tolerance=angle_tolerance)
structure = sym_finder.get_refined_structure()
# Convert to primitive structure.
if primitive:
if primitive_standard:
sym_finder_prim = SpacegroupAnalyzer(structure=structure, symprec=symprec, angle_tolerance=angle_tolerance)
structure = sym_finder_prim.get_primitive_standard_structure()
else:
get_prim = PrimitiveCellTransformation()
structure = get_prim.apply_transformation(structure)
# Exchange last two lattice vectors if triple product is negative.
m = structure.lattice.matrix
x_prod = np.dot(np.cross(m[0], m[1]), m[2])
if x_prod < 0:
trans = SupercellTransformation(((1, 0, 0), (0, 0, 1), (0, 1, 0)))
structure = trans.apply_transformation(structure)
m = structure.lattice.matrix
x_prod = np.dot(np.cross(m[0], m[1]), m[2])
if x_prod < 0: raise RuntimeError("x_prod is still negative!")
return structure
示例6: __init__
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def __init__(self, structure, element):
"""
Initializes an Interstitial generator using structure motifs
Args:
structure (Structure): pymatgen structure object
element (str or Element or Specie): element for the interstitial
"""
self.structure = structure
self.element = element
interstitial_finder = StructureMotifInterstitial(self.structure, self.element)
self.defect_sites = list(interstitial_finder.enumerate_defectsites())
# for multiplicity, neccessary to get prim_structure
spa = SpacegroupAnalyzer(self.structure, symprec=1e-2)
prim_struct = spa.get_primitive_standard_structure()
conv_prim_rat = int(self.structure.num_sites / prim_struct.num_sites)
self.multiplicities = [
int(interstitial_finder.get_defectsite_multiplicity(def_ind) / conv_prim_rat)
for def_ind in range(len(self.defect_sites))
]
self.count_def = 0 # for counting the index of the generated defect
示例7: test_get_primitive_standard_structure
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def test_get_primitive_standard_structure(self):
parser = CifParser(os.path.join(test_dir, 'bcc_1927.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 109.47122063400001)
self.assertAlmostEqual(prim.lattice.beta, 109.47122063400001)
self.assertAlmostEqual(prim.lattice.gamma, 109.47122063400001)
self.assertAlmostEqual(prim.lattice.a, 7.9657251015812145)
self.assertAlmostEqual(prim.lattice.b, 7.9657251015812145)
self.assertAlmostEqual(prim.lattice.c, 7.9657251015812145)
parser = CifParser(os.path.join(test_dir, 'btet_1915.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 105.015053349)
self.assertAlmostEqual(prim.lattice.beta, 105.015053349)
self.assertAlmostEqual(prim.lattice.gamma, 118.80658411899999)
self.assertAlmostEqual(prim.lattice.a, 4.1579321075608791)
self.assertAlmostEqual(prim.lattice.b, 4.1579321075608791)
self.assertAlmostEqual(prim.lattice.c, 4.1579321075608791)
parser = CifParser(os.path.join(test_dir, 'orci_1010.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 134.78923546600001)
self.assertAlmostEqual(prim.lattice.beta, 105.856239333)
self.assertAlmostEqual(prim.lattice.gamma, 91.276341676000001)
self.assertAlmostEqual(prim.lattice.a, 3.8428217771014852)
self.assertAlmostEqual(prim.lattice.b, 3.8428217771014852)
self.assertAlmostEqual(prim.lattice.c, 3.8428217771014852)
parser = CifParser(os.path.join(test_dir, 'orcc_1003.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 90)
self.assertAlmostEqual(prim.lattice.beta, 90)
self.assertAlmostEqual(prim.lattice.gamma, 164.985257335)
self.assertAlmostEqual(prim.lattice.a, 15.854897098324196)
self.assertAlmostEqual(prim.lattice.b, 15.854897098324196)
self.assertAlmostEqual(prim.lattice.c, 3.99648651)
parser = CifParser(os.path.join(test_dir, 'monoc_1028.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 63.579155761999999)
self.assertAlmostEqual(prim.lattice.beta, 116.42084423747779)
self.assertAlmostEqual(prim.lattice.gamma, 148.47965136208569)
self.assertAlmostEqual(prim.lattice.a, 7.2908007159612325)
self.assertAlmostEqual(prim.lattice.b, 7.2908007159612325)
self.assertAlmostEqual(prim.lattice.c, 6.8743926325200002)
parser = CifParser(os.path.join(test_dir, 'rhomb_1170.cif'))
structure = parser.get_structures(False)[0]
s = SpacegroupAnalyzer(structure, symprec=1e-2)
prim = s.get_primitive_standard_structure()
self.assertAlmostEqual(prim.lattice.alpha, 90)
self.assertAlmostEqual(prim.lattice.beta, 90)
self.assertAlmostEqual(prim.lattice.gamma, 120)
self.assertAlmostEqual(prim.lattice.a, 3.699919902005897)
self.assertAlmostEqual(prim.lattice.b, 3.699919902005897)
self.assertAlmostEqual(prim.lattice.c, 6.9779585500000003)
示例8: write_etree
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
def write_etree(self, celltype, cartesian=False, bandstr=False, symprec=0.4, angle_tolerance=5):
root=ET.Element('input')
root.set('{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation',
'http://xml.exciting-code.org/excitinginput.xsd')
title=ET.SubElement(root,'title')
title.text=self.title
if cartesian:
structure=ET.SubElement(root,'structure',cartesian="true",speciespath="./")
else:
structure=ET.SubElement(root,'structure',speciespath="./")
crystal=ET.SubElement(structure,'crystal')
# set scale such that lattice vector can be given in Angstrom
ang2bohr=const.value('Angstrom star')/const.value('Bohr radius')
crystal.set('scale',str(ang2bohr))
# determine which structure to use
finder=SpacegroupAnalyzer(self.structure,symprec=symprec, angle_tolerance=angle_tolerance)
if celltype=='primitive':
new_struct=finder.get_primitive_standard_structure(international_monoclinic=False)
elif celltype=='conventional':
new_struct=finder.get_conventional_standard_structure(international_monoclinic=False)
elif celltype=='unchanged':
new_struct=self.structure
else:
raise ValueError('Type of unit cell not recognized!')
# write lattice
basis=new_struct.lattice.matrix
for i in range(3):
basevect=ET.SubElement(crystal,'basevect')
basevect.text= "%16.8f %16.8f %16.8f" % (basis[i][0], basis[i][1],
basis[i][2])
# write atomic positions for each species
index=0
for i in new_struct.types_of_specie:
species=ET.SubElement(structure,'species',speciesfile=i.symbol+
'.xml')
sites=new_struct.indices_from_symbol(i.symbol)
for j in sites:
coord="%16.8f %16.8f %16.8f" % (new_struct[j].frac_coords[0],
new_struct[j].frac_coords[1],
new_struct[j].frac_coords[2])
# obtain cartesian coords from fractional ones if needed
if cartesian:
coord2=[]
for k in range(3):
inter=(new_struct[j].frac_coords[k]*basis[0][k]+\
new_struct[j].frac_coords[k]*basis[1][k]+\
new_struct[j].frac_coords[k]*basis[2][k])*ang2bohr
coord2.append(inter)
coord="%16.8f %16.8f %16.8f" % (coord2[0],
coord2[1],
coord2[2])
# write atomic positions
index=index+1
atom=ET.SubElement(species,'atom',coord=coord)
# write bandstructure if needed
if bandstr and celltype=='primitive':
kpath=HighSymmKpath(new_struct, symprec=symprec, angle_tolerance=angle_tolerance)
prop=ET.SubElement(root,'properties')
bandstrct=ET.SubElement(prop,'bandstructure')
for i in range(len(kpath.kpath['path'])):
plot=ET.SubElement(bandstrct,'plot1d')
path=ET.SubElement(plot, 'path',steps='100')
for j in range(len(kpath.kpath['path'][i])):
symbol=kpath.kpath['path'][i][j]
coords=kpath.kpath['kpoints'][symbol]
coord="%16.8f %16.8f %16.8f" % (coords[0],
coords[1],
coords[2])
if symbol=='\\Gamma':
symbol='GAMMA'
pt=ET.SubElement(path,'point',coord=coord,label=symbol)
elif bandstr and celltype is not 'primitive':
raise ValueError("Bandstructure is only implemented for the \
standard primitive unit cell!")
return root
示例9: HighSymmKpath
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_primitive_standard_structure [as 别名]
class HighSymmKpath(object):
"""
This class looks for path along high symmetry lines in
the Brillouin Zone.
It is based on Setyawan, W., & Curtarolo, S. (2010).
High-throughput electronic band structure calculations:
Challenges and tools. Computational Materials Science,
49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010
The symmetry is determined by spglib through the
SpacegroupAnalyzer class
Args:
structure (Structure): Structure object
symprec (float): Tolerance for symmetry finding
angle_tolerance (float): Angle tolerance for symmetry finding.
"""
def __init__(self, structure, symprec=0.01, angle_tolerance=5):
self._structure = structure
self._sym = SpacegroupAnalyzer(structure, symprec=symprec, angle_tolerance=angle_tolerance)
self._prim = self._sym.get_primitive_standard_structure(international_monoclinic=False)
self._conv = self._sym.get_conventional_standard_structure(international_monoclinic=False)
self._prim_rec = self._prim.lattice.reciprocal_lattice
self._kpath = None
lattice_type = self._sym.get_lattice_type()
spg_symbol = self._sym.get_space_group_symbol()
if lattice_type == "cubic":
if "P" in spg_symbol:
self._kpath = self.cubic()
elif "F" in spg_symbol:
self._kpath = self.fcc()
elif "I" in spg_symbol:
self._kpath = self.bcc()
else:
warn("Unexpected value for spg_symbol: %s" % spg_symbol)
elif lattice_type == "tetragonal":
if "P" in spg_symbol:
self._kpath = self.tet()
elif "I" in spg_symbol:
a = self._conv.lattice.abc[0]
c = self._conv.lattice.abc[2]
if c < a:
self._kpath = self.bctet1(c, a)
else:
self._kpath = self.bctet2(c, a)
else:
warn("Unexpected value for spg_symbol: %s" % spg_symbol)
elif lattice_type == "orthorhombic":
a = self._conv.lattice.abc[0]
b = self._conv.lattice.abc[1]
c = self._conv.lattice.abc[2]
if "P" in spg_symbol:
self._kpath = self.orc()
elif "F" in spg_symbol:
if 1 / a ** 2 > 1 / b ** 2 + 1 / c ** 2:
self._kpath = self.orcf1(a, b, c)
elif 1 / a ** 2 < 1 / b ** 2 + 1 / c ** 2:
self._kpath = self.orcf2(a, b, c)
else:
self._kpath = self.orcf3(a, b, c)
elif "I" in spg_symbol:
self._kpath = self.orci(a, b, c)
elif "C" in spg_symbol:
self._kpath = self.orcc(a, b, c)
else:
warn("Unexpected value for spg_symbol: %s" % spg_symbol)
elif lattice_type == "hexagonal":
self._kpath = self.hex()
elif lattice_type == "rhombohedral":
alpha = self._prim.lattice.lengths_and_angles[1][0]
if alpha < 90:
self._kpath = self.rhl1(alpha * pi / 180)
else:
self._kpath = self.rhl2(alpha * pi / 180)
elif lattice_type == "monoclinic":
a, b, c = self._conv.lattice.abc
alpha = self._conv.lattice.lengths_and_angles[1][0]
# beta = self._conv.lattice.lengths_and_angles[1][1]
if "P" in spg_symbol:
self._kpath = self.mcl(b, c, alpha * pi / 180)
elif "C" in spg_symbol:
kgamma = self._prim_rec.lengths_and_angles[1][2]
if kgamma > 90:
self._kpath = self.mclc1(a, b, c, alpha * pi / 180)
if kgamma == 90:
self._kpath = self.mclc2(a, b, c, alpha * pi / 180)
if kgamma < 90:
#.........这里部分代码省略.........