本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.get_conventional_standard_structure方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.get_conventional_standard_structure方法的具体用法?Python SpacegroupAnalyzer.get_conventional_standard_structure怎么用?Python SpacegroupAnalyzer.get_conventional_standard_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.get_conventional_standard_structure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cif2geom_sym2
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [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
示例2: cif
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def cif(src):
"""
cifファイルを作成
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std_str = finder.get_conventional_standard_structure()
std_cif = CifWriter(std_str, symprec=0.1)
std_cif.write_file("poscar.cif")
示例3: cif
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def cif(src='POSCAR'):
"""
cifファイルを作成
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std_str = finder.get_conventional_standard_structure()
cif_obj = CifWriter(std_str, symprec=0.1)
cif_obj.write_file('poscar.cif')
示例4: cif
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def cif(src="POSCAR"):
"""
cifファイルを作成
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std = finder.get_conventional_standard_structure()
cif = CifWriter(std, find_spacegroup=True, symprec=0.1)
cif.write_file("poscar.cif")
示例5: prim_cif
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_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)
示例6: std
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def std(src='POSCAR'):
"""
conventional standard cell に変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std_str = finder.get_conventional_standard_structure()
dstpos = Poscar(std_str)
dst = 'POSCAR_std'
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例7: standard
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def standard(src="POSCAR"):
"""
standardに変換
"""
srcpos = Poscar.from_file(src)
finder = SpacegroupAnalyzer(srcpos.structure)
std = finder.get_conventional_standard_structure()
dstpos = Poscar(std)
dst = "POSCAR_std"
Cabinet.reserve_file(dst)
dstpos.write_file(dst)
示例8: apply_transformation
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def apply_transformation(self, structure):
"""
Returns most primitive cell for structure.
Args:
structure: A structure
Returns:
The same structure in a conventional standard setting
"""
sga = SpacegroupAnalyzer(structure, symprec=self.symprec,
angle_tolerance=self.angle_tolerance)
return sga.get_conventional_standard_structure(international_monoclinic=self.international_monoclinic)
示例9: step1
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def step1():
"""
get substrate bulk structures from materialsproject for
Pt, Ag, Cu, Ni, Al, Au, Pd, Ir and do 3d relaxation(ISIF=3)
get 2d structures from the provided poscars(just poscar_graphene)
and relax in x and y only(vasp_noz bin)
- POSCAR_graphene must be made available in the directory
- creates required input files and submits the jobs to the que
- 8 + 1 jobs
- returns: step1_sub.json step1_2d.json
"""
#job directory for the runs
job_dir_sub = 'step1_sub'
job_dir_2d = 'step1_2d'
# create list of all substrate poscars
poscars_sub = []
poscars_2d = []
# substrate structures
for sub in substrates:
struct_sub = get_struct_from_mp(sub)
sa_sub = SpacegroupAnalyzer(struct_sub)
struct_sub = sa_sub.get_conventional_standard_structure()
poscars_sub.append(Poscar(struct_sub))
# 2d structures
for td in mat2ds:
poscars_2d.append(Poscar.from_file(td))
# setup calibrate and run'em
turn_knobs_sub = OrderedDict(
[
('POSCAR', poscars_sub)
])
turn_knobs_2d = OrderedDict(
[
('POSCAR', poscars_2d)
])
# normal binary
qadapter_sub, job_cmd_sub = get_run_cmmnd(nnodes=nnodes, nprocs=nprocs,
walltime=walltime,
job_bin=bin_sub, mem=mem)
# binary with z constraint
qadapter_2d, job_cmd_2d = get_run_cmmnd(nnodes=nnodes, nprocs=nprocs,
walltime=walltime,
job_bin=bin_2d, mem=mem)
run_cal(turn_knobs_sub, qadapter_sub, job_cmd_sub, job_dir_sub,
'step1_sub', incar=incar_sub, kpoints=kpoints_sub)
run_cal(turn_knobs_2d, qadapter_2d, job_cmd_2d, job_dir_2d,
'step1_2d', incar=incar_2d, kpoints=kpoints_2d)
return ['step1_sub.json', 'step1_2d.json']
示例10: _get_data_from_single_dirc
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [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)}
示例11: get_smallest_expansion
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_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
示例12: handle_subcommand_test_relax
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def handle_subcommand_test_relax(args):
default_commands = {
'lammps': 'lammps'
}
command = args.command if args.command else default_commands.get(args.software)
predict = Predict(calculator=args.software, command=command, num_workers=1)
potential = Potential.from_file(args.potential)
structure = get_structure(args.structure)
import warnings
warnings.filterwarnings("ignore") # yes I have sinned
sga = SpacegroupAnalyzer(structure)
conventional_structure = sga.get_conventional_standard_structure()
old_lattice, new_lattice = predict.lattice_constant(conventional_structure, potential)
equilibrium_structure = Structure(
new_lattice,
[s.specie.element for s in conventional_structure.sites],
[s.frac_coords for s in conventional_structure.sites])
equilibrium_structure.to(filename=args.output_filename)
示例13: get_struct_from_mp
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
from pymatgen.io.vasp.inputs import Poscar
from mpinterfaces.calibrate import CalibrateSlab
from mpinterfaces import get_struct_from_mp
from mpinterfaces.interface import Interface
from mpinterfaces.transformations import *
from mpinterfaces.utils import *
separation = 3 # in angstroms
nlayers_2d = 2
nlayers_substrate = 2
substrate_bulk = Structure.from_file('POSCAR_substrate')
# substrate_bulk = get_struct_from_mp('Ag')
sa_sub = SpacegroupAnalyzer(substrate_bulk)
substrate_bulk = sa_sub.get_conventional_standard_structure()
substrate_slab = Interface(substrate_bulk,
hkl=[1, 1, 1],
min_thick=10,
min_vac=25,
primitive=False, from_ase=True)
# substrate_slab = slab_from_file([0,0,1], 'POSCAR_substrate')
mat2d_slab = slab_from_file([0, 0, 1], 'POSCAR_2D')
# get the in-plane lattice aligned slabs
# substrate_slab.to(fmt='poscar', filename='POSCAR_substrate_slab.vasp')
mat2d_slab.to(fmt='poscar', filename='POSCAR_mat2d_slab.vasp')
# selective dynamics flag
sd_flags = CalibrateSlab.set_sd_flags(
interface=substrate_slab,
n_layers=nlayers_substrate,
top=True, bottom=False)
示例14: HighSymmKpath
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_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_spacegroup_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:
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_conventional_standard_structure [as 别名]
def __init__(
self,
api_key,
list_of_elements=[],
indices_dict=None,
slab_size=10,
vac_size=10,
host=None,
port=None,
user=None,
password=None,
symprec=0.001,
angle_tolerance=5,
database=None,
collection="Surface_Collection",
fail_safe=True,
reset=False,
):
"""
Args:
api_key (str): A String API key for accessing the MaterialsProject
list_of_elements ([str, ...]): A list of compounds or elements to create
slabs from. Must be a string that can be searched for with MPRester.
Either list_of_elements or indices_dict has to be entered in.
indices_dict ({element(str): [[h,k,l], ...]}): A dictionary of
miller indices corresponding to the composition formula
(key) to transform into a list of slabs. Either list_of_elements
or indices_dict has to be entered in.
host (str): For database insertion
port (int): For database insertion
user (str): For database insertion
password (str): For database insertion
symprec (float): See SpaceGroupAnalyzer in analyzer.py
angle_tolerance (int): See SpaceGroupAnalyzer in analyzer.py
database (str): For database insertion
"""
unit_cells_dict = {}
vaspdbinsert_params = {
"host": host,
"port": port,
"user": user,
"password": password,
"database": database,
"collection": collection,
}
elements = [key for key in indices_dict.keys()] if indices_dict else list_of_elements
# For loop will eneumerate through all the compositional
# formulas in list_of_elements or indices_dict to get a
# list of relaxed conventional unit cells froom MP. These
# will be used to generate all oriented unit cells and slabs.
for el in elements:
"""
element: str, element name of Metal
miller_index: hkl, e.g. [1, 1, 0]
api_key: to get access to MP DB
"""
# This initializes the REST adaptor. Put your own API key in.
mprest = MPRester(api_key)
# Returns a list of MPIDs with the compositional formular, the
# first MPID IS NOT the lowest energy per atom
entries = mprest.get_entries(el, inc_structure="final")
e_per_atom = [entry.energy_per_atom for entry in entries]
for entry in entries:
if min(e_per_atom) == entry.energy_per_atom:
prim_unit_cell = entry.structure
spa = SpacegroupAnalyzer(prim_unit_cell, symprec=symprec, angle_tolerance=angle_tolerance)
conv_unit_cell = spa.get_conventional_standard_structure()
print conv_unit_cell
unit_cells_dict[el] = [conv_unit_cell, min(e_per_atom)]
print el
self.api_key = api_key
self.vaspdbinsert_params = vaspdbinsert_params
self.symprec = symprec
self.angle_tolerance = angle_tolerance
self.unit_cells_dict = unit_cells_dict
self.indices_dict = indices_dict
self.elements = elements
self.ssize = slab_size
self.vsize = vac_size
self.reset = reset
self.fail_safe = fail_safe