Source code for aim2dat.utils.space_groups
"""Module containing functions to parse space groups and to get information on the lattice."""
# TODO change to libspg
# Standard library imports
from typing import Union
# Third party library imports
import ase.spacegroup as ase_sg
# Internal library imports
from aim2dat.ext_interfaces import _return_ext_interface_modules
[docs]
def get_space_group_details(space_group: Union[str, int], return_sym_operations: bool = False):
"""
Return space group details from name or international number using spglib.
Parameters
----------
space_group : str or int
Space group name or international number.
return_sym_operations : bool (optional)
Whether to return the symmetry operations as well.
Returns
-------
dict
- number : int
International number of the space group.
- international_short : str
International short symbol of the space group.
- international_full : str
International full symbol of the space group.
- international : str
International symbol of the space group.
- schoenflies : str
Schoenflies symbol of the space group.
- hall_number : int
Hall number of the space group.
- hall_symbol : str
Hall symbol of the space group.
- choice : str
Centring, origin, basis vector setting.
- pointgroup_international : str
International symbol of the crystallographic point group.
- pointgroup_schoenflies : str
Schoenflies symbol of the crystallographic point group.
- arithmetic_crystal_class_number : int
Arithmetic crystal class number.
- arithmetic_crystal_class_symbol : str
Arithmetic crystal class symbol.
- symmetry_operations : list
List of tuples containing the rotation matrix and translation as lists if
``return_sym_operations`` is set to ``True``.
"""
return _return_ext_interface_modules("spglib")._get_space_group_details(
space_group, return_sym_operations
)
[docs]
def get_lattice_type(space_group):
"""
Return the crystal system of a space group given by a string or number.
"""
from warnings import warn
warn(
"This function will be removed, please use `get_crystal_system` instead.",
DeprecationWarning,
2,
)
return get_crystal_system(space_group)
[docs]
def get_crystal_system(space_group):
"""
Return the crystal system of a space group given by a string or number.
Parameters
----------
space_group : int or str
Space group of the crystal.
Returns
-------
crystal_system : str
The crystal system of the space group, e.g. 'tetragonal'.
"""
sg_num = transform_to_nr(space_group)
bounds = {
"triclinic": (0, 3),
"monoclinic": (2, 16),
"orthorhombic": (15, 75),
"tetragonal": (74, 143),
"trigonal": (142, 168),
"hexagonal": (167, 195),
"cubic": (194, 231),
}
crystal_system = ""
for crystal_system0, bound in bounds.items():
if bound[0] < sg_num < bound[1]:
crystal_system = crystal_system0
return crystal_system