PyXtal: Crystal Structure Generation

1.1.3 · active · verified Thu Apr 16

PyXtal is an open-source Python library designed for the ab-initio generation of crystal structures based on symmetry constraints. It supports the generation of atomic and molecular systems across 0D to 3D dimensions, facilitates symmetry analysis, and offers structural manipulation capabilities. The library is currently at version 1.1.3 and is actively maintained with regular updates and contributions from the materials science community.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a 3D atomic crystal, specifically a diamond-like carbon structure, using the `pyxtal` class's `from_random` method. It initializes a crystal instance, attempts to generate a structure based on dimension, space group, element, and stoichiometry, and then prints the structure details or saves it to a CIF file if successful.

from pyxtal import pyxtal

# Create a new structure instance
struc = pyxtal()

# Generate a random 3D atomic crystal
# dim=3 (3D), group=227 (Fd-3m, diamond space group), species=['C'], numIons=[8] (8 Carbon atoms per conventional cell)
struc.from_random(dim=3, group=227, species=['C'], numIons=[8])

if struc.valid:
    print("Crystal generated successfully:")
    print(struc)
    # To save the structure to a CIF file
    struc.to_file("diamond.cif")
else:
    print("Failed to generate crystal.")

view raw JSON →