Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
structure: :class:`qmpy.Structure` object with a crystal structure.
to_primitive: Boolean specifying whether to convert the input structure
to a primitive unit cell.
no_idealize: Boolean specifying whether to "idealize" lattice vectors,
angles according to the ITC.
symprec: Float with the Cartesian distance tolerance.
verbosity: Integer with the level of standard output verbosity.
Returns: :class:`qmpy.Structure` object with the standardized unit cell
if successful, the input structure as is, otherwise.
"""
_check_spglib_install()
rev_lookup = dict(zip(structure.site_comp_indices,
structure.site_compositions))
cell = spglib.standardize_cell(
_structure_to_cell(structure),
to_primitive=to_primitive,
no_idealize=no_idealize,
symprec=symprec
)
if not _check_spglib_success(cell,
verbosity=verbosity):
return structure
_cell_to_structure(cell, structure, rev_lookup)
return structure
idealize : bool
Convert the cell into the spglib standardized form.
tol : float
Tolerance for floating point rounding errors.
Returns
-------
primitive cell : object
The primitive unit cell returned by spglib if one is found.
"""
lattice = atoms.cell
positions = atoms.get_scaled_positions()
numbers = atoms.get_atomic_numbers()
cell = (lattice, positions, numbers)
cell = spglib.standardize_cell(
cell, to_primitive=primitive, no_idealize=~idealize, symprec=tol)
if cell is None:
return atoms
_lattice, _positions, _numbers = cell
atoms = Gratoms(symbols=_numbers, cell=_lattice, pbc=atoms.pbc)
atoms.set_scaled_positions(_positions)
return atoms
print('')
print("[standardize_cell]")
print(" Standardize distorted rutile structure:")
print(" (to_primitive=0 and no_idealize=0)")
lattice, positions, numbers = spglib.standardize_cell(rutile_dist,
to_primitive=0,
no_idealize=0,
symprec=1e-1)
show_cell(lattice, positions, numbers)
print('')
print("[standardize_cell]")
print(" Standardize distorted rutile structure:")
print(" (to_primitive=0 and no_idealize=1)")
lattice, positions, numbers = spglib.standardize_cell(rutile_dist,
to_primitive=0,
no_idealize=1,
symprec=1e-1)
show_cell(lattice, positions, numbers)
print('')
print("[standardize_cell]")
print(" Standardize distorted silicon structure:")
print(" (to_primitive=1 and no_idealize=0)")
lattice, positions, numbers = spglib.standardize_cell(silicon_dist,
to_primitive=1,
no_idealize=0,
symprec=1e-1)
show_cell(lattice, positions, numbers)
print('')
structure_list = [s for s in structure_list if s.calc.results['energy'] < max_e]
e_list.sort(key=lambda x: x[1], reverse=False)
structure_list.sort(key=lambda x: x.calc.results['energy'], reverse=False)
if total_struc != None and total_struc > 0:
e_list = e_list[:total_struc]
structure_list = structure_list[:total_struc]
total_struc = len(e_list)
elif i_mode == 4:
total_struc = len(structure_list)
if pbc == [True, True, True] or pbc == [True, True, False]:
print('Analyzing symmetry')
space_g_l = []
for structure in structure_list:
if pbc == [True, True, True]:
structure.conventional_cell = standardize_cell(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers), symprec=symprec)
if structure.conventional_cell == None:
structure.conventional_cell = structure
structure.space_group = 'NULL(0)'
space_g_l.append(1)
else:
structure.conventional_cell = Atoms(cell=structure.conventional_cell[0],
scaled_positions=structure.conventional_cell[1],
numbers=structure.conventional_cell[2], pbc=pbc)
structure.space_group = get_spacegroup(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers),
symprec=symprec).replace(' ', '')
space_g_l.append(int(get_spg_n(structure.space_group)))
elif pbc == [False, False, False]:
structure.conventional_cell = structure
structure.space_group = 'P1(1)'
idealize : bool
Convert the cell into the spglib standardized form.
tol : float
Tolerance for floating point rounding errors.
Returns
-------
primitive cell : object
The primitive unit cell returned by spglib if one is found.
"""
lattice = atoms.cell
positions = atoms.get_scaled_positions()
numbers = atoms.get_atomic_numbers()
cell = (lattice, positions, numbers)
cell = spglib.standardize_cell(
cell, to_primitive=primitive, no_idealize=~idealize, symprec=tol)
if cell is None:
return atoms
_lattice, _positions, _numbers = cell
atoms = Gratoms(symbols=_numbers, cell=_lattice, pbc=atoms.pbc)
atoms.set_scaled_positions(_positions)
return atoms
print('Analyzing symmetry')
if r_cut_off == None:
if pbc == [True, True, True]:
r_cut_off = 9.0
else:
r_cut_off = 6.0
# ccf_range = r_cut_off + extend_r
# r_vector = np.linspace(0.0, ccf_range, int(ccf_range / ccf_step) + 2)
elif r_cut_off == None:
r_cut_off = 9.0
ccf_range = r_cut_off + extend_r
r_vector = np.linspace(0.0, ccf_range, int(ccf_range / ccf_step) + 2)
space_g_l = []
for structure in structure_list:
if pbc == [True, True, True] or pbc == [True, True, False]:
structure.conventional_cell = standardize_cell(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers), symprec=symprec)
if structure.conventional_cell == None:
structure.conventional_cell = structure
structure.space_group = 'NULL(0)'
space_g_l.append(1)
else:
structure.conventional_cell = Atoms(cell=structure.conventional_cell[0],
scaled_positions=structure.conventional_cell[1],
numbers=structure.conventional_cell[2], pbc=pbc)
structure.space_group = get_spacegroup(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers),
symprec=symprec).replace(' ', '')
space_g_l.append(int(get_spg_n(structure.space_group)))
elif pbc == [False, False, False]:
structure.conventional_cell = structure
structure.space_group = 'P1(1)'
))
# structure_list[-1].e = e_list[ii][1]
# structure_list[-1].n_structure = e_list[ii][2]
# structure_list.sort(key=lambda x:x.e,reverse=False)
elif i_mode == 2:
print('Reading structure')
total_struc = 0
for root, dirs, files in os.walk('struc', topdown=True):
for name in files:
structure_list.append(read(os.path.join(root, name)))
total_struc += 1
print('Analyzing symmetry')
space_g_l = []
for structure in structure_list:
structure.conventional_cell = standardize_cell(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers), symprec=symprec)
if structure.conventional_cell == None:
structure.conventional_cell = structure
structure.space_group = 'NULL(0)'
space_g_l.append(0)
else:
structure.conventional_cell = Atoms(cell=structure.conventional_cell[0],
scaled_positions=structure.conventional_cell[1],
numbers=structure.conventional_cell[2], pbc=True)
structure.space_group = get_spacegroup(
(structure.cell, structure.get_scaled_positions(wrap=True), structure.numbers),
symprec=symprec).replace(' ', '')
space_g_l.append(int(get_spg_n(structure.space_group)))
structure.conventional_cell.n_atom = len(structure.conventional_cell.numbers)
if l_cif or l_poscar:
if os.path.exists(dir_name):