pyxtal.crystal module

Module for generating atomic crystals

class pyxtal.crystal.random_crystal(dim=3, group=227, species=None, numIons=8, factor=1.1, thickness=None, area=None, lattice=None, sites=None, conventional=True, tm=None, use_hall=False, random_state: int | None | Generator = None, use_asu: bool = False)[source]

Bases: object

Class for storing and generating atomic crystals based on symmetry constraints. Given a spacegroup, list of atomic symbols, the stoichiometry, and a volume factor, generates a random crystal consistent with the spacegroup’s symmetry.

Parameters:
  • dim – dimenion (0, 1, 2, 3)

  • group – the group number (1-56, 1-75, 1-80, 1-230)

  • species – a list of atomic symbols for each ion type, e.g., [“Ti”, “O”]

  • numIons – a list of the number of each type of atom within the primitive cell (NOT the conventional cell), e.g., [4, 2]

  • factor (optional) – volume factor used to generate the crystal

  • sites (optional) – pre-assigned wyckoff sites (e.g., [[“4a”], [“2b”]])

  • lattice (optional) – Lattice object to define the unit cell

  • tm (optional) – Tol_matrix object to define the distances

check_wp(wyckoff_sites_tmp, wyks, cell, new_site, tol)[source]
set_crystal()[source]

The main code to generate a random atomic crystal. If successful, self.valid is True

set_elemental_volumes()[source]

Set up the radii for each specie.

set_lattice(lattice)[source]

Generate or set the crystal lattice.

Parameters:

lattice – Lattice object, optional A pre-defined lattice object to use. If None, a new lattice will be generated based on the crystal’s symmetry group and dimensionality.

Raises:

RuntimeError – If a valid lattice cannot be generated after 10 attempts with increasing volume.

Note

When generating a new lattice (lattice=None):
  • For 2D crystals, unique axis is ‘c’ for groups 3-7, ‘a’ otherwise

  • For 1D crystals, unique axis is ‘a’ for groups 3-7, ‘c’ otherwise

  • For 3D crystals, unique axis is always ‘c’

If lattice generation fails due to volume constraints, the volume is incrementally increased by 10% for up to 10 attempts. When using a provided lattice, the lattice’s periodic boundary conditions (PBC) are adjusted to match the crystal’s PBC

set_sites(sites)[source]

Initialize Wyckoff sites.

Parameters:

sites (list) – List of Wyckoff sites for each species.

set_volume()[source]

Estimate the volume of a unit cell based on the number and types of ions.

The volume is calculated assuming each atom occupies a sphere with radius equal to its covalent bond radius. Example conversions:

  • 0.50 Å radius → 0.52 ų

  • 0.62 Å radius → 1.00 ų

  • 0.75 Å radius → 1.76 ų

Note

Set the volume attribute used for crystal generation.