API Reference¶
The public API mirrors the Rust crate layout: base (crystal structures and
operation containers), dataset (symmetry analysis results), data
(crystallographic classification tables), and identify (group identification
primitives). The moyopy.interface adapters provide conversion helpers to/from
pymatgen and ASE.
This page documents the core types and the space-group API. Layer-group and magnetic-space-group APIs live on additional pages:
Core types¶
Lattice + sites, the non-magnetic operation container, and the unimodular transformation type used across all group families.
moyopy.Cell
¶
A crystal structure: a lattice plus fractional positions and atomic numbers.
Create a new Cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
list[list[float]]
|
Row-wise basis vectors of the lattice. |
required |
positions
|
list[list[float]]
|
Fractional coordinates of each site. |
required |
numbers
|
list[int]
|
Atomic number of each site. Must have the same length as |
required |
deserialize_json
classmethod
¶
Deserialize an object from a JSON string.
moyopy.Operations
¶
A list of crystallographic symmetry operations (rotation + translation).
translations
property
¶
Translation parts of the symmetry operations (fractional coordinates).
deserialize_json
classmethod
¶
deserialize_json(json_str: str) -> Operations
Deserialize an object from a JSON string.
from_dict
classmethod
¶
from_dict(data: dict[str, Any]) -> Operations
Create an object from a dictionary.
moyopy.UnimodularTransformation
¶
A unimodular transformation: an integer linear part with determinant +-1 plus an origin shift.
Symmetry datasets¶
Run a symmetry analysis on a moyopy.Cell and inspect the result.
moyopy.MoyoDataset
¶
MoyoDataset(cell: Cell, *, symprec: float = 0.0001, angle_tolerance: float | None = None, setting: Setting | None = None, rotate_basis: bool = True)
A dataset containing symmetry information of the input crystal structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
Cell
|
Input crystal structure. |
required |
symprec
|
float
|
Symmetry search tolerance in the unit of cell.basis. |
0.0001
|
angle_tolerance
|
float | None
|
Symmetry search tolerance in the unit of radians. |
None
|
setting
|
Setting | None
|
Preference for the setting of the space group. |
None
|
rotate_basis
|
bool
|
Whether to rotate the basis vectors of the input cell to those of the standardized cell. |
True
|
angle_tolerance
property
¶
angle_tolerance: float | None
Actually used angle_tolerance in iterative symmetry search.
mapping_std_prim
property
¶
Mapping sites in the input cell to those in the primitive standardized cell.
The i-th atom in the input cell is mapped to the mapping_to_std_prim[i]-th atom
in the primitive standardized cell.
orbits
property
¶
Spglib's crystallographic_orbits not equivalent_atoms.
The i-th atom in the input cell is equivalent to the orbits[i]-th atom in the
input cell. For example, orbits=[0, 0, 2, 2, 2, 2] means the first two atoms
are equivalent and the last four atoms are equivalent to each other.
prim_std_cell
property
¶
prim_std_cell: Cell
Primitive standardized cell.
Same transformation convention as the standardized cell above::
prim_std_cell.basis.T = std_rotation_matrix @ cell.basis.T @ prim_std_linear
x_prim_std = np.linalg.inv(prim_std_linear) @ (x_input - prim_std_origin_shift)
prim_std_linear
property
¶
Linear part of transformation from the input cell to the primitive standardized cell.
prim_std_origin_shift
property
¶
Origin shift of transformation from the input cell to the primitive standardized cell.
site_symmetry_symbols
property
¶
Site symmetry symbols for each site in the input cell.
The orientation of the site symmetry is w.r.t. the standardized cell.
std_cell
property
¶
std_cell: Cell
Standardized cell.
The input cell is related to the standardized cell by
(std_linear, std_origin_shift) and std_rotation_matrix:
Lattice::
std_cell.basis.T = std_rotation_matrix @ cell.basis.T @ std_linear
Fractional positions::
x_std = np.linalg.inv(std_linear) @ (x_input - std_origin_shift)
std_rotation_matrix is a rigid rotation (orthogonal matrix) applied
only to the Cartesian lattice basis. It does not affect fractional
coordinates.
std_linear
property
¶
Linear part of transformation from the input cell to the standardized cell.
std_origin_shift
property
¶
Origin shift of transformation from the input cell to the standardized cell.
std_rotation_matrix
property
¶
Rigid rotation (orthogonal matrix) applied to the lattice basis.
deserialize_json
classmethod
¶
deserialize_json(json_str: str) -> Self
Deserialize an object from a JSON string.
normalizer_wyckoff_positions
¶
normalizer_wyckoff_positions(*, preserve_chirality: bool = False, primitive: bool = False) -> NormalizerWyckoffPositions
Wyckoff positions of the standardized cell under the action of the Euclidean normalizer, decomposed into the stabilizer of the Wyckoff sequence and coset representatives of the distinct sequences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preserve_chirality
|
bool
|
If |
False
|
primitive
|
bool
|
If |
False
|
Crystallographic data¶
Hall symbols, settings, centering, classification tables, and helpers to fetch operations by ITA number.
moyopy.Setting
¶
Preference for the setting of the space group.
hall_number
classmethod
¶
Specific Hall number from 1 to 530.
moyopy.Centering
¶
moyopy.HallSymbolEntry
¶
HallSymbolEntry(hall_number: int)
An entry containing space-group information for a specified hall_number.
moyopy.SpaceGroupType
¶
SpaceGroupType(number: int)
Space-group type information.
arithmetic_symbol
property
¶
arithmetic_symbol: str
Symbol for arithmetic crystal class.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/arithmetic_crystal_class.rs for string values.
bravais_class
property
¶
bravais_class: str
Bravais class.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/classification.rs for string values.
crystal_family
property
¶
crystal_family: str
Crystal family.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/classification.rs for string values.
crystal_system
property
¶
crystal_system: str
Crystal system.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/classification.rs for string values.
geometric_crystal_class
property
¶
geometric_crystal_class: str
Geometric crystal class.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/classification.rs for string values.
lattice_system
property
¶
lattice_system: str
Lattice system.
See https://github.com/spglib/moyo/blob/main/moyo/src/data/classification.rs for string values.
moyopy.ArithmeticCrystalClass
¶
ArithmeticCrystalClass(arithmetic_number: int)
Arithmetic crystal class information.
moyopy.operations_from_number
¶
operations_from_number(number: int, *, setting: Setting | None = None, primitive: bool = False) -> Operations
Group identification¶
Identify point groups and space groups from a primitive list of symmetry operations.
moyopy.PointGroup
¶
Point group identified from a list of rotation matrices.
Identify the point group of the given primitive rotations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim_rotations
|
list[list[list[int]]]
|
Rotation matrices in the primitive cell. |
required |
basis
|
list[list[float]] | None
|
Row-wise basis vectors of the primitive lattice. If |
None
|
moyopy.SpaceGroup
¶
SpaceGroup(prim_rotations: list[list[int]], prim_translations: list[list[float]], *, basis: list[list[float]] | None = None, setting: Setting | None = None, epsilon: float = 0.0001)
Space group identified from a list of primitive symmetry operations.
Identify the space group from primitive rotations and translations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim_rotations
|
list[list[list[int]]]
|
Rotation matrices of the symmetry operations of the primitive cell. |
required |
prim_translations
|
list[list[float]]
|
Translation vectors of the symmetry operations of the primitive cell. |
required |
basis
|
list[list[float]] | None
|
Row-wise basis vectors of the primitive lattice. If |
None
|
setting
|
Setting | None
|
Preference for the standardized setting of the detected space-group type. |
None
|
epsilon
|
float
|
Numerical tolerance for matching translations. |
0.0001
|
moyopy.integral_normalizer
¶
integral_normalizer(prim_rotations: list[list[list[int]]], prim_translations: list[list[float]], *, prim_generators: list[int] | None = None, epsilon: float = 0.0001) -> list[UnimodularTransformation]
Compute the integral normalizer of a space group.
Returns the unimodular transformations that conjugate the given space group into itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prim_rotations
|
list[list[list[int]]]
|
Rotation matrices of the symmetry operations of the primitive cell. |
required |
prim_translations
|
list[list[float]]
|
Translation vectors of the symmetry operations of the primitive cell. |
required |
prim_generators
|
list[int] | None
|
Optional indices of operations to use as generators. If |
None
|
epsilon
|
float
|
Numerical tolerance for matching translations. |
0.0001
|
Adapters¶
Convert between moyopy.Cell and pymatgen Structure / ASE
Atoms. Requires the optional dependencies installed via
pip install moyopy[interface]. The magnetic counterpart
moyopy.interface.MoyoNonCollinearMagneticAdapter
lives on the Magnetic Space Group page.
moyopy.interface.MoyoAdapter
¶
from_disordered_structure
staticmethod
¶
Convert a disordered pymatgen Structure to a Moyo Cell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
Structure
|
A pymatgen Structure object, which may contain disordered sites. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cell |
Cell
|
The converted Moyo Cell object. |
unique_species_mapping |
dict[int, Composition]
|
A mapping from integer indices used in the Moyo Cell to the original pymatgen SpeciesLike objects. |
from_py_obj
staticmethod
¶
from_py_obj(struct: Structure | Atoms | MSONAtoms) -> Cell
Convert a Python atomic structure object to a Moyo Cell.
Args: struct: Currently supports pymatgen Structure, ASE Atoms, and MSONAtoms
Returns: moyopy.Cell: The converted Moyo cell
from_structure
staticmethod
¶
from_structure(structure: Structure) -> Cell
Convert a pymatgen Structure to a Moyo Cell.
get_structure
staticmethod
¶
get_structure(cell: Cell, *, unique_species_mapping: dict[int, Composition] | None = None) -> Structure
Convert a Moyo Cell to a pymatgen Structure.
If the Cell was created from a disordered Structure, the unique_species_mapping should be provided to reconstruct the original species.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell
|
Cell
|
The Moyo Cell to convert. |
required |
unique_species_mapping
|
dict[int, Composition] | None
|
A mapping from integer indices used in the Moyo Cell to the original pymatgen SpeciesLike objects. If None, assumes the Cell was created from an ordered Structure. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
structure |
Structure
|
The converted pymatgen Structure object. |