Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
------
RuntimeError : if symmetry-determination has not succeeded.
Notes
-----
Note that crystals generated from the Protein Data Bank are often incomplete;
in such cases the space-group information will be incorrect.
"""
dataset = get_symmetry_dataset(
cell=self._spglib_cell(), symprec=symprec, angle_tolerance=angle_tolerance
)
if dataset is None:
raise RuntimeError("[SPGLIB] Symmetry-determination has not found a match.")
spg_type = get_spacegroup_type(dataset["hall_number"])
hm_symbol = Hall2HM[dataset["hall"]]
# We do not distinguish between base-centered "A", "B", and "C"
# "A" and "B" are translated to "C"
centering = CenteringType(
hm_symbol[0] if hm_symbol[0] not in {"A", "B"} else "C"
)
info = {
"international_symbol": dataset["international"],
"hall_symbol": dataset["hall"],
"hm_symbol": hm_symbol,
"centering": centering,
"international_number": dataset["number"],
"hall_number": dataset["hall_number"],
"international_full": spg_type["international_full"],
"pointgroup": spg_type["pointgroup_international"],
def get_spgroup_data_realtime():
"""
Return a dictionary that has the spacegroup number as key, and a tuple
as value, with content::
(crystal family letter, centering, has_inversion),
got in real time using spglib methods.
"""
import json
import spglib
info = {}
for hall_n in range(1, 531):
data = spglib.get_spacegroup_type(hall_n)
number = data['number']
int_short = data['international_short']
pg_int = data['pointgroup_international']
if number not in info:
info[int(number)] = (
get_crystal_family(number), # get cyrstal family
# centering from the first letter of the first
# spacegroup that I encounter
int_short[0],
pointgroup_has_inversion(
pgnum_from_pgint(pg_int)), # pointgroup has inversion
)
return info
def get_space_group_type(self, symprec=1e-5):
return spg.get_spacegroup_type(self.hall_number(symprec=symprec))
"""
This script is used to determine the transform from the system specififed by
first Hall number in each space group, into the system that correponds to the
conventional settings for that space group.
This information is needed because the normalizers and Wyckoff positions in
Bilbao Crystallographic Server are given in the conventional setttings only by
default.
"""
import spglib
from collections import defaultdict
space_hall_map = defaultdict(list)
for hall_number in range(1, 531):
dataset = spglib.get_spacegroup_type(hall_number)
number = dataset["number"]
space_hall_map[number].append(hall_number)
degenerate_spgs = []
for key, value in space_hall_map.items():
if len(value) == 1:
continue
degenerate_spgs.append(key)
first_hall = value[0]
dataset = spglib.get_spacegroup_type(first_hall)
choice = dataset["choice"]
# try:
# origin = int(choice)
# except ValueError as e:
space_hall_map = defaultdict(list)
for hall_number in range(1, 531):
dataset = spglib.get_spacegroup_type(hall_number)
number = dataset["number"]
space_hall_map[number].append(hall_number)
degenerate_spgs = []
for key, value in space_hall_map.items():
if len(value) == 1:
continue
degenerate_spgs.append(key)
first_hall = value[0]
dataset = spglib.get_spacegroup_type(first_hall)
choice = dataset["choice"]
# try:
# origin = int(choice)
# except ValueError as e:
# if choice != "H":
# print(choice)
if choice == "":
print(spglib.get_spacegroup_type(value[0])["choice"])
"""
Goes through the spglib database for different Hall numbers and extracts space
group specific intormation. The results are then written to a python file for
later use.
"""
import spglib
import pickle
space_groups = {}
space_group_database = {}
for hall_number in range(1, 531):
dataset = spglib.get_spacegroup_type(hall_number)
number = dataset["number"]
international_short = dataset["international_short"]
# Check that the spglib data has no two different international symbols for
# the same space group number
old = space_groups.get(number)
if old is not None:
if old != international_short:
raise LookupError("Two spacegroups have different point groups!")
else:
if number not in space_group_database:
space_group_database[number] = {}
# Point group. There actually seeems to be a bug in spglib 1.9.4, where
# the Hermann-Mauguin point group symbol is in the plalce of Schonflies
# data and vice versa.
- 'international`
- `international_full`
- `international_short`
- `number`
- `pointgroup_international`
- `pointgroup_schoenflies`
- `schoenflies`
None if `spglib` fails to determine space group type.
Raises:
ImportError: If `spglib` cannot be imported.
"""
_check_spglib_install()
return spglib.get_spacegroup_type(hall_number)