pyxtal.io module
This module handles reading and write crystal files.
- pyxtal.io.get_cif_str_for_pyxtal(struc, header: str = '', sym_num=None, style: str = 'mp')[source]
Get the cif string for a given structure.
The default setting for _atom_site follows the materials project cif format. TODO: make this a method of the pyxtal class
- Parameters:
struc – PyXtal structure object
header – Additional information
sym_num – Number of symmetry operations. None means write all symops
style – Format type - either ‘icsd’ or ‘mp’ (used in pymatgen)
- Returns:
CIF format string representation of the structure
- Return type:
str
- pyxtal.io.in_merged_coords(wp, pt, pts, cell)[source]
Check if a point is within a set of points.
- Parameters:
wp – Wyckoff position object
pt – Tuple of (coordinates, species) for the point to check
pts – List of (coordinates, species) tuples to check against
cell – Unit cell matrix
- Returns:
True if pt matches any point in pts, False otherwise
- Return type:
bool
- pyxtal.io.read_cif(filename)[source]
Read a CIF file, primarily designed for PyXtal CIF output format. Warning: Use caution when reading other CIF files.
- Parameters:
filename (str) – Path to the CIF structure file
- Returns:
(Lattice, list of sites) representing the crystal structure
- Return type:
tuple
- pyxtal.io.search_molecules_in_crystal(struc, tol=0.2, once=False, ignore_HH=True, max_bond_length=None)[source]
Find molecules within a crystal structure.
- Parameters:
struc (Structure) – Pymatgen Structure object
tol (float) – Bond distance tolerance factor. Default 0.2
once (bool) – Whether to find only first molecule. Default False
ignore_HH (bool) – Whether to ignore short H-H bonds. Default True
max_bond_length (float, optional) – Maximum allowed bond length for missing entries
- Returns:
List of pymatgen Molecule objects representing found molecules
- Return type:
list[Molecule]
- class pyxtal.io.structure_from_ext(struc, ref_mols, tol=0.2, ignore_HH=False, add_H=False, hn=None)[source]
Bases:
object
- pyxtal.io.write_cif(struc, filename=None, header='', permission='w', sym_num=None, style='mp')[source]
Export the structure in cif format. The default setting for _atom_site follows the materials project cif
- Parameters:
struc – pyxtal structure object
filename – path of the structure file
header – additional information
permission – write(w) or append(a+) to the given file
sym_num – the number of symmetry operations, None means writing all symops
style – icsd or mp (used in pymatgen)