CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pymatgen

Comprehensive materials science analysis library for crystal structures, molecules, and materials data with extensive computational chemistry integration.

Pending
Overview
Eval results
Files

symmetry.mddocs/

Symmetry & Crystallography

Space group analysis, point group operations, crystallographic symmetry detection, and high-symmetry k-point path generation for band structures. These tools provide comprehensive crystallographic analysis capabilities for materials science applications including structure refinement, symmetry-based property predictions, and electronic band structure calculations.

Capabilities

Space Group Analysis

Comprehensive space group detection and analysis using international crystallographic standards.

class SpacegroupAnalyzer:
    """
    Comprehensive space group analysis of crystal structures.
    
    Parameters:
    - structure: Structure object to analyze
    - symprec: Symmetry precision tolerance
    - angle_tolerance: Angle tolerance for symmetry detection in degrees
    """
    def __init__(self, structure, symprec=0.01, angle_tolerance=5): ...
    
    def get_space_group_number(self):
        """
        Get International Tables space group number.
        
        Returns:
        int: Space group number (1-230)
        """
    
    def get_space_group_symbol(self):
        """
        Get Hermann-Mauguin space group symbol.
        
        Returns:
        str: Space group symbol (e.g., "Pm-3m")
        """
    
    def get_hall_number(self):
        """
        Get Hall space group number.
        
        Returns:
        int: Hall number (1-530)
        """
    
    def get_point_group_symbol(self):
        """
        Get crystallographic point group symbol.
        
        Returns:
        str: Point group symbol (e.g., "m-3m")
        """
    
    def get_crystal_system(self):
        """
        Get crystal system classification.
        
        Returns:
        str: Crystal system (cubic, tetragonal, etc.)
        """
    
    def get_lattice_type(self):
        """
        Get Bravais lattice type.
        
        Returns:
        str: Lattice type (P, I, F, C, etc.)
        """
    
    def get_symmetry_operations(self, cartesian=False):
        """
        Get all symmetry operations for the space group.
        
        Parameters:
        cartesian: Whether to return operations in Cartesian coordinates
        
        Returns:
        list: List of SymmOp objects
        """
    
    def get_symmetry_dataset(self):
        """
        Get complete symmetry dataset from spglib.
        
        Returns:
        dict: Complete symmetry information
        """
    
    def get_symmetrized_structure(self):
        """
        Get structure with symmetry information attached.
        
        Returns:
        SymmetrizedStructure: Structure with symmetry data
        """
    
    def is_laue(self):
        """
        Check if structure has Laue symmetry (inversion center).
        
        Returns:
        bool: True if structure has inversion symmetry
        """
    
    def find_primitive(self, keep_site_properties=False):
        """
        Find primitive cell using symmetry analysis.
        
        Parameters:
        keep_site_properties: Whether to keep site properties
        
        Returns:
        Structure: Primitive cell structure
        """
    
    def get_conventional_standard_structure(self, international_monoclinic=True,
                                          symprec=None, angle_tolerance=None):
        """
        Get conventional standard structure.
        
        Parameters:
        international_monoclinic: Whether to use international monoclinic setting
        symprec: Symmetry precision override
        angle_tolerance: Angle tolerance override
        
        Returns:
        Structure: Conventional standard structure
        """
    
    def get_primitive_standard_structure(self, international_monoclinic=True,
                                       symprec=None, angle_tolerance=None):
        """
        Get primitive standard structure.
        
        Parameters:
        international_monoclinic: Whether to use international monoclinic setting
        symprec: Symmetry precision override
        angle_tolerance: Angle tolerance override
        
        Returns:
        Structure: Primitive standard structure
        """
    
    def get_refined_structure(self, keep_site_properties=True):
        """
        Get refined structure with idealized atomic positions.
        
        Parameters:
        keep_site_properties: Whether to keep site properties
        
        Returns:
        Structure: Refined structure
        """
    
    def get_ir_reciprocal_mesh(self, mesh=(10, 10, 10), is_shift=(0, 0, 0)):
        """
        Get irreducible k-points in reciprocal space mesh.
        
        Parameters:
        mesh: K-point mesh dimensions
        is_shift: K-point mesh shift
        
        Returns:
        tuple: (k_points, weights, grid_address, grid_mapping)
        """
    
    def get_ir_reciprocal_mesh_map(self, mesh=(10, 10, 10), is_shift=(0, 0, 0)):
        """
        Get mapping of reducible to irreducible k-points.
        
        Parameters:
        mesh: K-point mesh dimensions
        is_shift: K-point mesh shift
        
        Returns:
        numpy.ndarray: Mapping array
        """
    
    def get_kpoint_weights(self, kpoints, is_time_reversal=True, is_mesh_symmetry=True,
                          is_eigenvectors=False):
        """
        Get weights for k-points based on symmetry.
        
        Parameters:
        kpoints: List of k-point coordinates
        is_time_reversal: Whether to consider time reversal symmetry
        is_mesh_symmetry: Whether to consider mesh symmetry
        is_eigenvectors: Whether to return eigenvectors
        
        Returns:
        list: K-point weights
        """
    
    @property
    def symprec(self):
        """Symmetry precision tolerance."""
    
    @property
    def angle_tolerance(self):
        """Angle tolerance in degrees."""

Point Group Analysis

Point group determination and analysis for molecular and crystalline systems.

class PointGroupAnalyzer:
    """
    Point group analysis for molecules and crystals.
    
    Parameters:
    - mol: Molecule object to analyze
    - tolerance: Distance tolerance for symmetry detection
    - eigen_tolerance: Eigenvalue tolerance for rotation analysis
    - matrix_tolerance: Matrix element tolerance
    """
    def __init__(self, mol, tolerance=0.3, eigen_tolerance=0.01, 
                 matrix_tolerance=0.1): ...
    
    def get_pointgroup(self):
        """
        Get point group classification.
        
        Returns:
        str: Point group symbol (e.g., "C2v", "D3h", "Oh")
        """
    
    def get_symmetry_operations(self):
        """
        Get all point group symmetry operations.
        
        Returns:
        list: List of SymmOp objects
        """
    
    def is_linear(self):
        """
        Check if molecule is linear.
        
        Returns:
        bool: True if molecule is linear
        """
    
    def is_valid_op(self, symm_op):
        """
        Check if symmetry operation is valid for the molecule.
        
        Parameters:
        symm_op: SymmOp object to validate
        
        Returns:
        bool: True if operation is valid
        """
    
    def get_rotational_symmetry_number(self):
        """
        Get rotational symmetry number.
        
        Returns:
        int: Rotational symmetry number
        """
    
    def get_equivalent_atoms(self):
        """
        Get symmetry-equivalent atoms.
        
        Returns:
        list: List of equivalent atom groups
        """
    
    @property
    def tolerance(self):
        """Distance tolerance for symmetry detection."""
    
    @property
    def eigen_tolerance(self):
        """Eigenvalue tolerance."""
    
    @property
    def matrix_tolerance(self):
        """Matrix element tolerance."""

Symmetrized Structures

Structures with explicit symmetry information and equivalent site groupings.

class SymmetrizedStructure:
    """
    Structure with symmetry information and equivalent site groupings.
    
    Parameters:
    - structure: Structure object
    - spacegroup: SpaceGroup object
    - equivalent_indices: List of equivalent site groups
    - wyckoff_symbols: Wyckoff symbols for each site
    """
    def __init__(self, structure, spacegroup, equivalent_indices, 
                 wyckoff_symbols): ...
    
    def copy(self):
        """
        Create copy of symmetrized structure.
        
        Returns:
        SymmetrizedStructure: Copy of the structure
        """
    
    def find_equivalent_sites(self, site):
        """
        Find all sites equivalent to given site.
        
        Parameters:
        site: Site object or site index
        
        Returns:
        list: List of equivalent sites
        """
    
    def get_space_group_info(self):
        """
        Get space group information.
        
        Returns:
        tuple: (space_group_number, international_symbol)
        """
    
    @property
    def equivalent_indices(self):
        """List of equivalent site index groups."""
    
    @property
    def wyckoff_symbols(self):
        """Wyckoff symbols for each site."""
    
    @property
    def spacegroup(self):
        """SpaceGroup object."""
    
    @property
    def equivalent_sites(self):
        """List of equivalent site groups."""

Space Group Objects

Representation of crystallographic space groups with symmetry operations.

class SpaceGroup:
    """
    Crystallographic space group representation.
    
    Parameters:
    - int_symbol: International (Hermann-Mauguin) symbol
    - int_number: International Tables space group number
    - symmetry_ops: List of symmetry operations
    """
    def __init__(self, int_symbol, int_number, symmetry_ops): ...
    
    @classmethod
    def from_int_number(cls, int_number, hexagonal=True):
        """
        Create SpaceGroup from international number.
        
        Parameters:
        int_number: International Tables number (1-230)
        hexagonal: Whether to use hexagonal setting for rhombohedral groups
        
        Returns:
        SpaceGroup: SpaceGroup object
        """
    
    def are_symmetrically_equivalent(self, sites1, sites2, symm_prec=1e-3):
        """
        Check if two sets of sites are symmetrically equivalent.
        
        Parameters:
        sites1, sites2: Lists of sites to compare
        symm_prec: Symmetry precision
        
        Returns:
        bool: True if sites are equivalent
        """
    
    def is_compatible(self, lattice, tol=1e-5, angle_tol=None):
        """
        Check if lattice is compatible with space group.
        
        Parameters:
        lattice: Lattice object
        tol: Length tolerance
        angle_tol: Angle tolerance
        
        Returns:
        bool: True if lattice is compatible
        """
    
    def is_subgroup(self, supergroup):
        """
        Check if this space group is a subgroup of another.
        
        Parameters:
        supergroup: SpaceGroup object
        
        Returns:
        bool: True if this is a subgroup
        """
    
    def is_supergroup(self, subgroup):
        """
        Check if this space group is a supergroup of another.
        
        Parameters:
        subgroup: SpaceGroup object
        
        Returns:
        bool: True if this is a supergroup
        """
    
    @property
    def int_number(self):
        """International Tables space group number."""
    
    @property
    def symbol(self):
        """Hermann-Mauguin symbol."""
    
    @property
    def point_group(self):
        """Associated point group symbol."""
    
    @property
    def crystal_system(self):
        """Crystal system."""
    
    @property
    def order(self):
        """Order of the space group (number of symmetry operations)."""
    
    @property
    def symmetry_ops(self):
        """List of symmetry operations."""

K-Point Path Generation

High-symmetry k-point path generation for electronic band structure calculations.

class HighSymmKpath:
    """
    High-symmetry k-point paths for band structure calculations.
    
    Parameters:
    - structure: Structure for which to generate k-paths
    - has_magmoms: Whether structure has magnetic moments
    - magmom_axis: Magnetic moment axis
    - path_type: Type of k-path generation algorithm
    - symprec: Symmetry precision
    - angle_tolerance: Angle tolerance
    - atol: Absolute tolerance
    """
    def __init__(self, structure, has_magmoms=False, magmom_axis=None,
                 path_type="setyawan_curtarolo", symprec=0.01, 
                 angle_tolerance=5, atol=1e-5): ...
    
    @property
    def kpath(self):
        """
        Dictionary containing k-path information.
        
        Returns:
        dict: K-path with 'path', 'kpoints', and 'explicit_kpoints_abs'
        """
    
    @property
    def conv(self):
        """Conventional structure used for k-path generation."""
    
    @property
    def prim(self):
        """Primitive structure."""
    
    @property
    def conventional(self):
        """Conventional structure."""
    
    @property
    def prim_rec(self):
        """Primitive reciprocal lattice."""
    
    @property
    def conv_rec(self):
        """Conventional reciprocal lattice."""
    
    def get_kpoints(self, line_density=20):
        """
        Get k-points along high-symmetry lines.
        
        Parameters:
        line_density: Number of k-points per Angstrom^-1
        
        Returns:
        Kpoints: VASP KPOINTS object for line-mode calculation
        """
class KPathSetyawanCurtarolo:
    """
    Setyawan-Curtarolo k-point paths for all crystal systems.
    
    Parameters:
    - structure: Structure object
    - symprec: Symmetry precision
    - angle_tolerance: Angle tolerance
    - atol: Absolute tolerance
    """
    def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5): ...
    
    @property
    def kpath(self):
        """K-path dictionary."""
    
    @property
    def lattice_type(self):
        """Lattice type classification."""
    
    @property
    def kpoint_coords(self):
        """High-symmetry k-point coordinates."""
    
    @property
    def path_strings(self):
        """K-path segment strings."""
class KPathSeek:
    """
    SeeK-path implementation for k-point path generation.
    
    Parameters:
    - structure: Structure object
    - symprec: Symmetry precision
    - angle_tolerance: Angle tolerance
    - atol: Absolute tolerance
    """
    def __init__(self, structure, symprec=0.01, angle_tolerance=5, atol=1e-5): ...
    
    @property
    def kpath(self):
        """K-path dictionary from SeeK-path."""
    
    @property
    def conv(self):
        """Conventional structure from SeeK-path."""
    
    @property
    def prim(self):
        """Primitive structure from SeeK-path."""

Symmetry Operations

Individual symmetry operations and their mathematical representations.

class SymmOp:
    """
    Symmetry operation consisting of rotation matrix and translation vector.
    
    Parameters:
    - rotation_matrix: 3x3 rotation matrix
    - translation_vec: 3D translation vector
    - tol: Numerical tolerance for operations
    """
    def __init__(self, rotation_matrix, translation_vec, tol=0.01): ...
    
    def operate(self, point):
        """
        Apply symmetry operation to a point.
        
        Parameters:
        point: 3D point coordinates
        
        Returns:
        numpy.ndarray: Transformed point coordinates
        """
    
    def operate_multi(self, points):
        """
        Apply symmetry operation to multiple points.
        
        Parameters:
        points: Array of 3D point coordinates
        
        Returns:
        numpy.ndarray: Transformed point coordinates
        """
    
    def apply_rotation_only(self, vector):
        """
        Apply only the rotation part to a vector.
        
        Parameters:
        vector: 3D vector
        
        Returns:
        numpy.ndarray: Rotated vector
        """
    
    def are_symmetrically_related(self, point_a, point_b, tol=0.001):
        """
        Check if two points are related by this symmetry operation.
        
        Parameters:
        point_a, point_b: 3D point coordinates
        tol: Tolerance for comparison
        
        Returns:
        bool: True if points are symmetrically related
        """
    
    def transform_tensor(self, tensor):
        """
        Transform a tensor using this symmetry operation.
        
        Parameters:
        tensor: Input tensor
        
        Returns:
        numpy.ndarray: Transformed tensor
        """
    
    @classmethod
    def from_axis_angle_and_translation(cls, axis, angle, angle_in_radians=False,
                                      translation_vec=(0, 0, 0)):
        """
        Create symmetry operation from rotation axis and angle.
        
        Parameters:
        axis: Rotation axis vector
        angle: Rotation angle
        angle_in_radians: Whether angle is in radians
        translation_vec: Translation vector
        
        Returns:
        SymmOp: Symmetry operation object
        """
    
    @classmethod
    def from_origin_axis_angle(cls, origin, axis, angle, angle_in_radians=False):
        """
        Create rotation about axis through origin.
        
        Parameters:
        origin: Origin point for rotation
        axis: Rotation axis vector
        angle: Rotation angle
        angle_in_radians: Whether angle is in radians
        
        Returns:
        SymmOp: Symmetry operation object
        """
    
    @classmethod
    def reflection(cls, normal, origin=(0, 0, 0)):
        """
        Create reflection symmetry operation.
        
        Parameters:
        normal: Normal vector to reflection plane
        origin: Point on reflection plane
        
        Returns:
        SymmOp: Reflection operation
        """
    
    @classmethod
    def inversion(cls, origin=(0, 0, 0)):
        """
        Create inversion symmetry operation.
        
        Parameters:
        origin: Inversion center
        
        Returns:
        SymmOp: Inversion operation
        """
    
    @classmethod
    def rotoreflection(cls, axis, angle, origin=(0, 0, 0)):
        """
        Create rotoreflection (improper rotation) operation.
        
        Parameters:
        axis: Rotation axis
        angle: Rotation angle
        origin: Center point
        
        Returns:
        SymmOp: Rotoreflection operation
        """
    
    @property
    def rotation_matrix(self):
        """3x3 rotation matrix."""
    
    @property
    def translation_vector(self):
        """3D translation vector."""
    
    @property
    def inverse(self):
        """Inverse symmetry operation."""
    
    @property
    def affine_matrix(self):
        """4x4 affine transformation matrix."""

Magnetic Symmetry

Symmetry operations and analysis for magnetic structures.

class MagSymmOp:
    """
    Magnetic symmetry operation with time reversal.
    
    Parameters:
    - rotation_matrix: 3x3 rotation matrix
    - translation_vec: 3D translation vector
    - time_reversal: Whether operation includes time reversal
    - tol: Numerical tolerance
    """
    def __init__(self, rotation_matrix, translation_vec, time_reversal=False, 
                 tol=0.01): ...
    
    def operate_magmom(self, magmom):
        """
        Apply magnetic symmetry operation to magnetic moment.
        
        Parameters:
        magmom: Magnetic moment vector or Magmom object
        
        Returns:
        numpy.ndarray or Magmom: Transformed magnetic moment
        """
    
    def operate_magmom_on_site(self, site):
        """
        Apply operation to magnetic moment on a specific site.
        
        Parameters:
        site: Site object with magnetic moment
        
        Returns:
        Site: Site with transformed magnetic moment
        """
    
    @property
    def time_reversal(self):
        """Whether operation includes time reversal."""
    
    @property
    def is_identity(self):
        """Whether operation is the identity operation."""
    
    @property
    def inverse(self):
        """Inverse magnetic symmetry operation."""

Crystallographic Analysis Functions

Utility functions for crystallographic analysis and structure manipulation.

def cluster_sites(struct, tol, give_only_index=False):
    """
    Cluster sites in structure based on distance.
    
    Parameters:
    struct: Structure object
    tol: Distance tolerance for clustering
    give_only_index: Whether to return only indices
    
    Returns:
    list: Clustered sites or site indices
    """

def iterative_symmetrize(struct, tolerance=0.001, max_n=5):
    """
    Iteratively symmetrize structure to ideal positions.
    
    Parameters:
    struct: Structure to symmetrize
    tolerance: Symmetry tolerance
    max_n: Maximum number of iterations
    
    Returns:
    Structure: Symmetrized structure
    """

def check_magnetic_symmetry(struct, magmoms, precision=0.001):
    """
    Check magnetic symmetry of structure with magnetic moments.
    
    Parameters:
    struct: Structure object
    magmoms: List of magnetic moments
    precision: Precision for symmetry detection
    
    Returns:
    dict: Magnetic symmetry analysis results
    """

def get_shared_symmetry_operations(struct1, struct2, tol=0.01):
    """
    Get symmetry operations shared between two structures.
    
    Parameters:
    struct1, struct2: Structure objects to compare
    tol: Tolerance for operation comparison
    
    Returns:
    list: Shared symmetry operations
    """

def get_symmetry_equivalent_miller_indices(structure, miller_index, 
                                         max_index=6):
    """
    Get all symmetry-equivalent Miller indices.
    
    Parameters:
    structure: Structure object
    miller_index: Reference Miller index
    max_index: Maximum index to consider
    
    Returns:
    list: Symmetry-equivalent Miller indices
    """

def get_point_group_operations(mol, tolerance=0.3):
    """
    Get point group operations for a molecule.
    
    Parameters:
    mol: Molecule object
    tolerance: Distance tolerance
    
    Returns:
    list: Point group symmetry operations
    """

def find_in_coord_list(coord_list, coord, atol=1e-8):
    """
    Find coordinate in list with tolerance.
    
    Parameters:
    coord_list: List of coordinates to search
    coord: Target coordinate
    atol: Absolute tolerance
    
    Returns:
    int or None: Index of coordinate if found
    """

def in_array_list(array_list, a, tol=1e-5):
    """
    Check if array is in list of arrays.
    
    Parameters:
    array_list: List of arrays
    a: Target array
    tol: Tolerance for comparison
    
    Returns:
    bool: True if array is in list
    """

Wyckoff Position Analysis

Analysis of Wyckoff positions and site symmetries within space groups.

def get_wyckoff_symbols(struct, space_group_number, symprec=0.01):
    """
    Get Wyckoff symbols for all sites in structure.
    
    Parameters:
    struct: Structure object
    space_group_number: International space group number
    symprec: Symmetry precision
    
    Returns:
    list: Wyckoff symbols for each site
    """

def get_wyckoff_multiplicities(space_group_number):
    """
    Get Wyckoff position multiplicities for space group.
    
    Parameters:
    space_group_number: International space group number
    
    Returns:
    dict: Wyckoff symbols and their multiplicities
    """

def get_wyckoff_positions(space_group_number):
    """
    Get all Wyckoff positions for space group.
    
    Parameters:
    space_group_number: International space group number
    
    Returns:
    dict: Wyckoff positions with coordinates and site symmetries
    """

Install with Tessl CLI

npx tessl i tessl/pypi-pymatgen

docs

core-materials.md

electronic-structure.md

index.md

io-formats.md

phase-diagrams.md

structure-analysis.md

symmetry.md

transformations.md

tile.json